<testcocoon>
havin opam in opam was good for performing a selfupgrade ('opam install opam' to always use the latest opam executable)
ttamttam1 has quit [Quit: ttamttam1]
Snark has joined #ocaml
ttamttam1 has joined #ocaml
ftrvxmtrx_ has joined #ocaml
hkBst has joined #ocaml
SuperNoeMan has joined #ocaml
<SuperNoeMan>
hey, I'm learning ocaml
<SuperNoeMan>
and I want to write my own reg exp matcher, that when given an expression can match that expression against strings
<SuperNoeMan>
I need to know how to define a function that uses the plus operator on strings
<SuperNoeMan>
like... so that "bill" + "julie" matches both billy and juliet
<orbitz>
let (+) s1 s2 = ...
<SuperNoeMan>
ok thanks
<SuperNoeMan>
I have an implementation question though
gour has joined #ocaml
<orbitz>
I'm not sure why you'd implement a regex like that though, why not the standard "(bill|julie)"?
<SuperNoeMan>
I think I can solve a simple regex problem by defining the + operator on strings
<SuperNoeMan>
its just practice
<SuperNoeMan>
yeah that's what I was about to ask
<SuperNoeMan>
couldn't I just express the regexs as strings themselves, and use streams to work through them
<SuperNoeMan>
and pattern match with some of the library?
<SuperNoeMan>
(yes, I know ocaml has reg ex's in its libraries as well, just for fun though :), and to learn)
<orbitz>
if you can handle regular regex you could just use + to make a new way to define it: let (+) s1 s2 = "(" ^ s1 ^ "|" ^ s2 ^ ")"
<SuperNoeMan>
orbitz... can I define types dependent on values?
<SuperNoeMan>
such as
<SuperNoeMan>
type rex = Empty | Constant of string | Either of string ^ "+" ^ string ;;
<SuperNoeMan>
?
<orbitz>
no
<orbitz>
Either is a terrible name for that too
<SuperNoeMan>
what should i call it?
<orbitz>
But why wouldn't you just do Either of (string * string) since teh "+" i sconstnat?
<orbitz>
Or
<SuperNoeMan>
because it has to match either bill or julie
<SuperNoeMan>
ah...
<orbitz>
Or of string list is probably better
<SuperNoeMan>
but wait, why is it string * string and not string ^ string in the type definition?
<orbitz>
because ^ is string concatenation, and * is tuple
<SuperNoeMan>
oh... couldn't I make it a recursive type, as in type rexp = Empty | Constant of string | Either of rexp...
<SuperNoeMan>
and then define functions over it?
<SuperNoeMan>
orbitz:
<orbitz>
sure
<orbitz>
probably either of rexp list though
<SuperNoeMan>
that would work wouldn't it? I could just parse the subject string with respect to the rex and see if they match
<SuperNoeMan>
what do you mean "either of rexp list though"?
<orbitz>
a recursive type is valid
<SuperNoeMan>
because... it could be a list of rexp's?
<orbitz>
Either should probably be a list of regexp
<SuperNoeMan>
oh
<orbitz>
you can have more than 2 things in an either in most regex implemetnations
<SuperNoeMan>
so...
fusillia has joined #ocaml
<SuperNoeMan>
how do I write rexp as a list
<orbitz>
what do you mean?
<SuperNoeMan>
rexp::x
<SuperNoeMan>
when i go to write Either of rexp::x...
<orbitz>
rexp is a type not a value
<orbitz>
Either [Empty; Empty; Empty]
<SuperNoeMan>
is that correct syntax. and yeah, I agree about rexp
<SuperNoeMan>
so I'm asking about how to express it correctly
<orbitz>
^
AltGr has joined #ocaml
<SuperNoeMan>
ok, so this is what I finally have:
<SuperNoeMan>
type rexp = Empty | Constant of string | Either of [rex] | Wildcard of [rexp] ;;
<orbitz>
no
<orbitz>
Either of rexp list
<orbitz>
I don't think you need a listof Wildcard's either
<SuperNoeMan>
and then I just define a function, match_rexp that operates on it...
<SuperNoeMan>
oh... so maybe you're thinking I could generalize Either and Wildcard as Expression
<SuperNoeMan>
and then have the function that's defined over the type differentiate?
<orbitz>
No, i'm just saying it makes more sense for Either to be a list, and for Wildcard to not
<SuperNoeMan>
oh wait... maybe my terminology is off
<SuperNoeMan>
by wildcard I mean *
<SuperNoeMan>
as in a* matches a... anything else after a, including ""
<orbitz>
Right, why do you need a list ofregex for taht?
djcoin has joined #ocaml
<SuperNoeMan>
because I could be given a regex such as "(foo + fee)*noob(dog + whale)"
<SuperNoeMan>
see how after the wildcard, there could still be an Either?
<flux>
supernoeman, maybe it should be rexp then, not rexp list
<SuperNoeMan>
ah
<orbitz>
[Either ["foo"; "fee"]; Wildcard; Contant "noob"; Either ["dog"; "whale"]]
<SuperNoeMan>
ahhhh
<flux>
oh, or that, of course :)
<flux>
because constant didn't have a 'next' link either
<SuperNoeMan>
that makes much more sense now that you defined Either as a rexp list for me, because
<flux>
..nor did Either
<SuperNoeMan>
now it can be [Either "foo*" ; "dog*cat"]
<SuperNoeMan>
I just picked up on that
<SuperNoeMan>
thank you
<orbitz>
No you can't
<SuperNoeMan>
well then that kind of makes Either a Constant + "+" + Constant type...
<SuperNoeMan>
which isn't so powerful
<orbitz>
Hrm?
<orbitz>
YOur list above won't type check
<flux>
supernoeman, btw, what difference does Empty and Constant "" have?
<SuperNoeMan>
flux: uhh... idk that string won't match ""... possibly none
Yoric has joined #ocaml
<SuperNoeMan>
I guess I was just writing my thinking down
<SuperNoeMan>
flux, should I remove Empty?
adbrown has joined #ocaml
<orbitz>
type rexp = | Constant of string | Or of rexp list | One | Many | Optional is what i'd probably start with
<SuperNoeMan>
really?
<orbitz>
Actually I takethat back
<SuperNoeMan>
what is the One | Many | Optional part about?
<orbitz>
+, *, ?
RagingDave has joined #ocaml
<orbitz>
I'd proabbly just do more of an AST actually, that makes more sense
<orbitz>
type rexp = | Root of rexp | Constant of string | Or of rexp list | One of rexp | Many of rexp | Optional of rexp
<orbitz>
something likt that
<SuperNoeMan>
well, I think an AST may be harder than is necessary. If I can define this recursively in the type, can't I have ocaml match it with the type?
Kakadu has joined #ocaml
<orbitz>
although I guess could drp the Root
<orbitz>
SuperNoeMan: I'm not sure how those two sentence are mutaully exclusive
<orbitz>
making it an AST has the obvious benefit of the inteprter is easy to implement
<SuperNoeMan>
perhaps I've got it wrong...
<SuperNoeMan>
maybe I thought of Automata when you said AST
<orbitz>
AST = Abstract Syntax Tree
<SuperNoeMan>
Automata would be harder right?
<SuperNoeMan>
no, I understand the acronym
<flux>
I would say so, but it'd also be faster
<flux>
but you wouldn't write straight up automata
mcclurmc has joined #ocaml
<flux>
you would convert and AST to automata
<SuperNoeMan>
I guess I just had the concepts backwards in my mind
<flux>
s/and/an/
<SuperNoeMan>
hmmm...
<SuperNoeMan>
so how do I convert an AST to automata?
<flux>
as you said, it's harder :P. you first create a non-deterministic finite automata, then convert it into a generalized non-deterministic finite automata, then convert that into a deterministic finite automata, and then you have the result
<flux>
maybe shortcuts exist.
<SuperNoeMan>
perhaps by using the Camlp4?
<flux>
I don't think camlp4 apply here
<SuperNoeMan>
oh, I did a search and that was what came up.
<SuperNoeMan>
it'll take me a while to understand it, I'm new to ocaml
<flux>
actually I'm pretty sure it doesn't work completely though. I started writing that in order to reverse a regular expression.
mcclurmc has quit [Ping timeout: 245 seconds]
<flux>
it, given a regular expression, produce a regular expression that matches everything the re doesn't and doesn't match anything the re does
<SuperNoeMan>
flux: would it be silly of me to just write a recursive function that takes each individual character of the string being tested against the
<flux>
(s/it/ie/, man I suck typing today)
<SuperNoeMan>
regex?
<flux>
supernoeman, no, it would be the straightforward way of doing it
<flux>
regular expression
<SuperNoeMan>
but there has to be a weakness in that...
<flux>
supernoeman, it's not very fast
<SuperNoeMan>
i mean, honestly, all this complex other stuff wouldn't exist without it
<SuperNoeMan>
ah
<flux>
you will need to do backtracking
<flux>
(but it's not hard)
<SuperNoeMan>
backtracking?
myx has joined #ocaml
<flux>
go levels of recursion and then find that match cannot be made, then you go back to the upper level and try in another way
<SuperNoeMan>
oh right, because more than one combination for a given regex could match any single candidate test?
<flux>
but your language is simpler than regexp, so you might end up with a relatively performant version anyway
<SuperNoeMan>
yeah, I was thinking so, but I'm learning it as a class, and I ahve the feeling that if I don't dig up the dirt on this problem, it will come back and bite me in the ass very hard
eikke has joined #ocaml
<orbitz>
Get It Working
<orbitz>
the simplest way possible
<orbitz>
deal with other things after it works
<flux>
be prepared to write two, one for throwing away :)
<SuperNoeMan>
why would I do that? I would have to rewrite them several times. and in fact, I can see that some of teh questions I must contend with require that I solve the problem the way in which I mention, so if I do not, I already know that I will reimplement
<SuperNoeMan>
but I agree about the quickest way to the cheese philosophy lol
<SuperNoeMan>
if only I could take that now!
<orbitz>
why would you write two? because your first one will almost always be junk until you figure out the actual problems to tsolve
<SuperNoeMan>
ah
<SuperNoeMan>
ok, probably the last question
<SuperNoeMan>
what are "the left and right operands" within ocaml? does that imply <> or am I wrong in thinking that that is vague?
<flux>
<> is the inequality operator..
<flux>
let (<>) a b = not (a = b)
<SuperNoeMan>
right
<SuperNoeMan>
oh wait...
<SuperNoeMan>
i think I understand what i'm reading now
<SuperNoeMan>
sorry...
ontologiae has joined #ocaml
<orbitz>
no needto be sorry, ocaml is not a trivial language to grok
<orbitz>
but it's amazingonce you start gettingit
<flux>
what language is trivial? I would say ocaml is quite simple, compared to many languages in the 'market'
<SuperNoeMan>
hmmm... I'm kind of the idea that you have to use the right tool for the right job
<orbitz>
IME getting people writing something useful in Python is easier than Ocaml
<SuperNoeMan>
so I can see how ocaml is good.
<flux>
well, ocaml has its more complicated things as well, but if you don't know about them, you don't mostly need to worry about them (unless you're reading other people's code)
<orbitz>
SuperNoeMan: that is not mutually exclusivewith my claim
<flux>
orbitz, is that because of standard library or something else?
<SuperNoeMan>
orbitz: :) agreed
<flux>
I suppose it helps for simple stuff to be able to just 'stringify' stuff, that's a language feature as well
<SuperNoeMan>
one thing I hate about python is the fact that it is dynamically type
<SuperNoeMan>
you catch literally no errors (that matter) at test time
<orbitz>
flux: no, just take something trivial like reading someones age and converting it to dog years, must simpler in something lke Python because you can just assume the happy path
<orbitz>
SuperNoeMan: at test time you can catch a lot of errors
<orbitz>
you just haveto write good tests
<SuperNoeMan>
it's so hard to make sure that what you've written is correct that you want to shalack your goober
<SuperNoeMan>
orbitz: but see, that's the hard part
<SuperNoeMan>
or at least, the limiting factor. The code can only be as good as the tests. With ocaml, my professors are telling me that you can essentially get a contract that avows that what you have written does what you expect it to and is 100% correct
<SuperNoeMan>
with new languages like coq...
<orbitz>
I don't think Coq is t hat new
<orbitz>
100% correct is a lie
<orbitz>
your coq impl can have a bug
<SuperNoeMan>
true dat
<orbitz>
And your proof can havea bug
<SuperNoeMan>
holy shit the coqide is a piece of shit
<SuperNoeMan>
true dat as well
<orbitz>
It is very promisign though
<SuperNoeMan>
yes :)
<orbitz>
I praise the day compiler optimizatiosn are formally verified
<flux>
I imagine it is a matter of proving the right thing, not that the proofs themselves have bugs
<SuperNoeMan>
agreed on that bit orbitz
<SuperNoeMan>
flux: well said.
<flux>
for example if you have a proof that a function terminates, its output is a permutation of its input, that its output is ascending, your function must be a working sort function
<flux>
but maybe you wanted to sort in descending order :)
<SuperNoeMan>
lol
<SuperNoeMan>
good talk.
<SuperNoeMan>
but too good. :/ alas, I must solve this problem
<orbitz>
then you just need to prove the 'reverse' function!
<flux>
and that reversing an ascending list results in a descending list..
<flux>
ACL2 seemed like an amazing tool as well. you would write lisp with assertions, and it would verify it for you.
<companion_cube>
ACL2 is still alive, isnt't it?
<SuperNoeMan>
idk, I still don't know either of coq or ACL2 well enough to note the difference in which is the better choice for what job...
<SuperNoeMan>
I know that ACL2 was used by AMD to verify that their processes do what they expect them to
<flux>
companion_cube, 6.0 was released last month..
<djcoin>
beginner42: module Foo (A: A1) (B: B1) struct end
<djcoin>
Oh but sorry, did not quite read, I guess your syntax is good
<djcoin>
it's the call that bothers you
<beginner42>
djcoin: exactly
mgodshall has quit [Client Quit]
<f[x]>
Make()()
<f[x]>
read the manual
<beginner42>
f[x]: i have done both, as i have stated before
cago has left #ocaml []
mika2 has quit [Quit: Leaving.]
<f[x]>
show the code
<beginner42>
f[x]: it wasnt the application of the functors, i didnt bind it to a module, but some value.
<beginner42>
That was the mistake. Thanks for your help
ftrvxmtrx_ has quit [Quit: Leaving]
Kakadu has quit [Quit: Konversation terminated!]
<djcoin>
so f[x] was right :) module M = ...
mye_ has joined #ocaml
mye has quit [Ping timeout: 245 seconds]
mye_ is now known as mye
hkBst has quit [Quit: Konversation terminated!]
fusillia has quit [Ping timeout: 260 seconds]
cdidd has quit [Remote host closed the connection]
tac has joined #ocaml
_andre has quit [Quit: leaving]
_andre has joined #ocaml
pango has quit [Quit: Client exiting]
ocp has joined #ocaml
pango has joined #ocaml
weie has joined #ocaml
djcoin has quit [Quit: WeeChat 0.3.9.2]
dwmw2_gone is now known as dwmw2
smondet has quit [Remote host closed the connection]
ttamttam1 has quit [Quit: ttamttam1]
mye has quit [Ping timeout: 260 seconds]
Yoric has quit [Ping timeout: 252 seconds]
psii has joined #ocaml
Submarine_ has joined #ocaml
Submarine_ has quit [Changing host]
Submarine_ has joined #ocaml
leoncamel has quit [Read error: Connection reset by peer]
lusory has quit [Ping timeout: 276 seconds]
leoncamel has joined #ocaml
milosn has joined #ocaml
ftrvxmtrx has quit [Ping timeout: 260 seconds]
beginner42 has quit [Quit: irc2go]
Anarchos has joined #ocaml
olaf_ has quit [Quit: Client exiting]
lusory has joined #ocaml
Yoric has joined #ocaml
Playground has quit [Ping timeout: 260 seconds]
mcclurmc has quit [Ping timeout: 252 seconds]
ontologiae has quit [Ping timeout: 248 seconds]
smondet has joined #ocaml
jbrown has quit [Quit: Client exiting]
tane has joined #ocaml
pkrnj has joined #ocaml
thomasga1 has quit [Quit: Leaving.]
_andre has quit [Quit: leaving]
Playground has joined #ocaml
mcclurmc has joined #ocaml
Yoric has quit [Ping timeout: 252 seconds]
Yoric has joined #ocaml
SuperNoeMan has joined #ocaml
Playground is now known as lolcathost
tac_ has joined #ocaml
tac has quit [Ping timeout: 245 seconds]
ontologiae has joined #ocaml
chambart has quit [Ping timeout: 276 seconds]
fraggle_ has quit [Read error: Connection timed out]
fraggle_ has joined #ocaml
tac_ is now known as tac
ontologiae has quit [Ping timeout: 252 seconds]
AltGr has quit [Quit: Konversation terminated!]
emmanuelux has joined #ocaml
thomasga has joined #ocaml
ftrvxmtrx has joined #ocaml
Submarine_ has quit [Ping timeout: 272 seconds]
ocp has quit [Quit: Leaving.]
troydm has quit [Read error: Operation timed out]
weie has quit [Quit: Leaving...]
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
js1 has joined #ocaml
<orbitz>
Does anyone have a good rule of thumb for when to use a functor vs HOFs? I have settled on usign a functor if type are involved and HOF if i need to paramaterize over soemthing. does that make any sense/
<SuperNoeMan>
orbitz: what do you mean by HOFs?
<thelema>
higher order functions
<thelema>
orbitz: if many functions need to be parameterized over the same collection (or significantly overlapping subsets) of functions, use a functor
<SuperNoeMan>
does anybody know how I can look at the ocaml source of regular expressions? lol
<SuperNoeMan>
I want to see what they literally wrote in order to help myself lol
<orbitz>
thelema: ok, that is bascially the same rule of thumb I came up with
<orbitz>
in this particular situation i'm trying t odecide the best stretegy for making a module that will read values from a data source and I want the ability to toss a cache in between
<SuperNoeMan>
hey, python has the help function that you can use on variables and types
<SuperNoeMan>
what's the ocaml analog, if there is one?
<thelema>
SuperNoeMan: type the name of the value, and its type will be printed at the toplevel
<thelema>
that's about it.
<orbitz>
which doesn't sound like much but IME is better than most documetnation
<thelema>
well, ocamlbrowser
<orbitz>
I do module M = Mymodule alot too
<thelema>
to get the whole signature? interesting. I find myself browsing through the online help of batteries most of the time
<orbitz>
generally my REPL is nearer
<orbitz>
I will browse help if I'm compeltley lost
<thelema>
/<modulename>Enter to load the docs for a particular module, or even just C-lBatFoo if I access the module often, like Enum
<orbitz>
is that in the REPL?
<thelema>
no, in firefox
<orbitz>
ah
<thelema>
using the search function on the toplevel docs or the browser history
<orbitz>
I'm on OS X Lion and have my terminal full screen and jumping between spaces is so terrible in OS X the REPL often aggrivates me less, but to each their own
<thelema>
I have firefox full screen in my second monitor
leoncamel has quit [Ping timeout: 260 seconds]
<SuperNoeMan>
does anybody use ledit or rlwrap?
leoncamel has joined #ocaml
ftrvxmtrx has joined #ocaml
<thelema>
rlwrap
<orbitz>
i use rlwrap
<SuperNoeMan>
I was wondering what I could use for a better toplevel that would provide some history or...
<orbitz>
some people really like utop
<SuperNoeMan>
yeah I heard about that one
<SuperNoeMan>
or read about it anyway.
<orbitz>
requires ocaml 4 if that is an issue
<orbitz>
for you
<SuperNoeMan>
I'm considering rlwrap and ledit
<orbitz>
I have seen it in action, seems ok
<orbitz>
rlwrap is just s oeasy
<thelema>
orbitz: ? utop worked under 3.12 as well
<SuperNoeMan>
hmm... any clear cut reason for choosing between teh two?
<orbitz>
thelema: does it? is that new? last time I tried it it wouldn't compile under3.12
<thelema>
maybe the current version has been updated to require 4.00
<orbitz>
SuperNoeMan: getting both of them up and running will take less time than teasing out our subjective opinions
<thelema>
ocamlbrew was originally 3.12, and it included utop
Im_Also_Greg has joined #ocaml
ImAlsoGreg has quit [Ping timeout: 276 seconds]
Demitar_ has joined #ocaml
Demitar has quit [Ping timeout: 264 seconds]
RagingDave has quit [Quit: Ex-Chat]
chambart has joined #ocaml
Snark has quit [Quit: Quitte]
smondet has quit [Ping timeout: 248 seconds]
troydm has joined #ocaml
malc_ has joined #ocaml
lolcathost is now known as Automorphism
Reventlov has quit [Quit: leaving]
psii has quit [Remote host closed the connection]
RagingDave has joined #ocaml
js1 has quit [Quit: WeeChat 0.3.8]
malc_ has quit [Quit: leaving]
cdidd has joined #ocaml
adotbrown has joined #ocaml
<wmeyer>
hi
<pippijn>
hi
Yoric has quit [Ping timeout: 252 seconds]
<wmeyer>
pippijn: how are you?
tac has quit [Ping timeout: 245 seconds]
fayden has quit [Ping timeout: 256 seconds]
gour has quit [Quit: WeeChat 0.3.8]
<emias>
[A
tani has joined #ocaml
benmachine has left #ocaml []
fayden has joined #ocaml
tane has quit [Ping timeout: 252 seconds]
leoncamel has quit [Ping timeout: 252 seconds]
wossname has quit [Remote host closed the connection]
tani has quit [Quit: Verlassend]
SuperNoeMan has quit [Remote host closed the connection]
q66 has quit [Quit: Quit]
adrien_o1w has joined #ocaml
adrien_oww has quit [Ping timeout: 260 seconds]
emmanuelux has quit [Quit: emmanuelux]
emmanuelux has joined #ocaml
RagingDave has quit [Quit: Ex-Chat]
<ousado>
wmeyer: do you mind an offtopic question?
<ousado>
basically I'm thinking about how to implement OOP-style dynamic dispatch