flux changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | Grab OCaml 3.10.2 from http://caml.inria.fr/ocaml/release.html (featuring new camlp4 and more!)
struktured has quit [Read error: 60 (Operation timed out)]
struktured has joined #ocaml
<Palace_Chan> I keep getting an unboud type parameter 'a error when i try to compile this:
<Palace_Chan> what do i have wrong ?
<Palace_Chan> it also says the error is on the line where i declare type 'a t
<Smerdyakov> The thing is, you never declare a [type 'a t].
<Palace_Chan> Smerdyakov, yea i just noticed i ommited the 'a before the t
<Palace_Chan> ill try to find the other compile error now
<Palace_Chan> well that same code with the 'a thing fixed just gives me a The type constructor t expects 1 argument(s),
<Palace_Chan> but is here applied to 0 argument(s) error
<Palace_Chan> i dont get how it expects one argument
<Palace_Chan> i'm comparing it to this example from inria http://caml.inria.fr/pub/docs/manual-ocaml/manual004.html
struktured has quit ["Konversation terminated!"]
mgodshall has joined #ocaml
gaja has quit ["Lost terminal"]
rog1 has quit [Read error: 113 (No route to host)]
kg4qxk has quit ["leaving"]
vbmithr_ has joined #ocaml
vbmithr_ has quit ["leaving"]
kg4qxk has joined #ocaml
jeddhaberstro has joined #ocaml
Ched- has quit [Read error: 110 (Connection timed out)]
Palace_Chan has quit [Client Quit]
pango_ has quit [Remote closed the connection]
ozy` has joined #ocaml
pango_ has joined #ocaml
jeremiah has quit [Read error: 104 (Connection reset by peer)]
jeremiah has joined #ocaml
struktured has joined #ocaml
rog1 has joined #ocaml
jeddhaberstro has quit []
struktured_ has joined #ocaml
struktured has quit [Read error: 110 (Connection timed out)]
pango_ has quit [Remote closed the connection]
hkBst has quit [Read error: 104 (Connection reset by peer)]
pango_ has joined #ocaml
pango_ has quit [Remote closed the connection]
pango_ has joined #ocaml
struktured_ has quit [Read error: 110 (Connection timed out)]
struktured_ has joined #ocaml
<thelema> pal: #
<thelema> let rec mem (s: 'a t)(x: 'a) : bool =
<thelema> oops, gone now
threeve has quit []
seafood has joined #ocaml
sporkmonger has quit []
sporkmonger has joined #ocaml
seafood_ has joined #ocaml
seafood_ has quit [Read error: 60 (Operation timed out)]
seafood has quit [Read error: 110 (Connection timed out)]
seafood has joined #ocaml
seafood has quit [Read error: 104 (Connection reset by peer)]
seafood has joined #ocaml
seafood_ has joined #ocaml
seafood__ has joined #ocaml
seafood_ has quit [Read error: 104 (Connection reset by peer)]
palomer has joined #ocaml
seafood_ has joined #ocaml
seafood___ has joined #ocaml
seafood has quit [Read error: 110 (Connection timed out)]
seafood__ has quit [Read error: 60 (Operation timed out)]
bluestorm has joined #ocaml
bluestorm has quit [Client Quit]
Associat0r has quit []
seafood has joined #ocaml
<palomer> gah!
<palomer> this seems like such a simple thng
<palomer> parsing a sexp
<palomer> it's so frigging hard!
<Myoma> palomer: Try using camllex and yacc
<Myoma> there is an example in the manual about making a calculator
<Myoma> first define a datatype, though
<Myoma> You could also look at jane st.s code they have a sexp parser
seafood_ has quit [Read error: 110 (Connection timed out)]
<Myoma> why is it hard though?
<palomer> whoa
<palomer> Myoma, I would have thought it be trivial
<palomer> it takes a little work though
seafood___ has quit [Read error: 110 (Connection timed out)]
seafood_ has joined #ocaml
<palomer> whew
<palomer> finished
<palomer> 26 locs
<palomer> :/
<Myoma> are you operating on strings directly?
<palomer> yeah
<palomer> that's how I did it
<Myoma> I think that is your mistake
<palomer> how else can I do it?
<Myoma> why don't you have an intermediate type of tokens, LPar | RPar | Symbol of string
<palomer> that's an idea
<palomer> still
<palomer> 26 locs isn't so bad
<Myoma> yes it is, that's terrible
<palomer> tokenizing would take about 10 lines
<palomer> and then I need to process what I tokenized
<palomer> your way would bring me down to 21 locs
<Myoma> no it should be much shorter than that
seafood__ has joined #ocaml
<Myoma> You are using continuation passing?
<Myoma> or building up a stack?
pattern has quit [Read error: 110 (Connection timed out)]
seafood has quit [Read error: 110 (Connection timed out)]
seafood has joined #ocaml
<Myoma> palomer, hi ?
seafood___ has joined #ocaml
seafood_ has quit [Read error: 110 (Connection timed out)]
seafood has quit [Read error: 60 (Operation timed out)]
seafood has joined #ocaml
seafood__ has quit [Read error: 110 (Connection timed out)]
mishok13 has joined #ocaml
seafood_ has joined #ocaml
seafood___ has quit [Read error: 110 (Connection timed out)]
seafood has quit [Read error: 110 (Connection timed out)]
seafood__ has joined #ocaml
lde has joined #ocaml
<palomer> high
<palomer> Myoma, here's the code:
seafood has joined #ocaml
<Myoma> can you just paste it to channel?
<Myoma> how long is it
<palomer> 26 lines
<palomer> that's my version
<palomer> doing things my way, your version would take about 21 lines
<Myoma> type tokn = LPar | RPar | Sym of string
<Myoma> type sexp = Nil | Cons of sexp * sexp | Symbol of string
<Myoma> I wrote it for this
<Myoma> let rec parse k = function
<Myoma> | (Sym ss::xs) -> k (Symbol ss) xs
<Myoma> | (LPar::RPar::xs) -> k Nil xs
<Myoma> | (LPar::xs) -> parse (fun hd ys ->
<Myoma> parse (fun tl zs ->
<Myoma> k (Cons(hd,tl)) zs)
<Myoma> (LPar::ys))
<Myoma> xs
<palomer> whoa
<palomer> what does k represent?
<Myoma> k is a continuation
<Myoma> for example, you can go
<Myoma> let test = (LPar :: Sym("foo") :: LPar :: LPar :: RPar :: RPar :: Sym("bar") :: RPar :: [])
seafood___ has joined #ocaml
<Myoma> parse (fun x y -> x) test
<Myoma> x is the parsed thing, and y is everything after it (in this case nil)
<palomer> Sym ("foo") ?
<palomer> (is the result) ?
<Myoma> "Sym ("foo") ?"?
<Myoma> no
<Myoma> run ti if you like, it should give the cons tree
<Myoma> the tokens are (foo(())bar)
<palomer> that's...mind boggling
<Myoma> the cons sould be like Cons(Symbol("foo"),...)
<palomer> the tokenizing is about 10 lines though
<palomer> so the total is 18 lines
<Myoma> Like I said earlier, you should use camllex
<palomer> but we want to minimize dependencies!
<palomer> and doesn't using camllex involve running an external program?
<Myoma> yes, the ocaml compiler
<palomer> I have to run ocamllex too
<Myoma> oh boo hoo
seafood_ has quit [Connection timed out]
<palomer> man, that program boggles my mind
<palomer> did you just pick that off the top of your head?
<Myoma> well I am glad of that ;0
<Myoma> :) *
<palomer> I couldn't imagine that people actually wrote code like that
<palomer> do you often pass continuations?
<palomer> doesn't it make the code hard to read?
<Myoma> I think the continuation passing method is simpler than the one you pasted -- That's just my opinion of course
<palomer> it IS simpler
<palomer> but it's written in a way which I'm not used to
<palomer> I mean, I read about CPS in my textbooks
<palomer> but I wasn't aware that people actually used it!
seafood__ has quit [Connection timed out]
seafood has quit [Read error: 110 (Connection timed out)]
seafood has joined #ocaml
filp has joined #ocaml
<palomer> whoa
<palomer> my version doesn't even work!
<Myoma> Is it pointless for me to suggest using camllex again? :)
<palomer> :P
<palomer> it would come out to more code in the end
<palomer> I'd use it if I could use it elsewhere
seafood_ has joined #ocaml
ozy` has quit ["Shop for a whopper"]
seafood___ has quit [Read error: 110 (Connection timed out)]
<Myoma> You shouldn't be worried about "more code" but "correct code"
seafood_ has quit [Read error: 104 (Connection reset by peer)]
seafood_ has joined #ocaml
Jedai has quit [Read error: 110 (Connection timed out)]
pattern has joined #ocaml
seafood_ has quit [Read error: 104 (Connection reset by peer)]
Jedai has joined #ocaml
seafood_ has joined #ocaml
seafood has quit [Read error: 110 (Connection timed out)]
<palomer> I can't get my head around your code
<palomer> how could it possibly work?
<Myoma> I think the key to understand it is use a high level understanding
<Myoma> when you write a recursive program, you don't consider how the execution works, You write base cases, and then you take as an axiom that the function works when you write the recursive cases. Do you know what I mean?
<palomer> yeah
<Myoma> (It's not relevant that this is a recursive function, I am just describing a thought process)
<Myoma> so we can use a similar understanding here,
<palomer> that's what I usually do
<Myoma> | (Sym ss::xs) -> k (Symbol ss) xs
<Myoma> | (LPar::RPar::xs) -> k Nil xs
<Myoma> are base cases
<Myoma> they tell 1) ocaml what the type of 'k' is
<Myoma> 2) us what the semantic meaning of 'k' is
<Myoma> so k : sexp -> tok list -> 'z
<flux> btw, it seems to me myoma could easily write a short article (blog entry) about this subject and perhaps help people on their way ;)
<Myoma> the k continuation takes the parsed object and all the garbage left over from parsing
<palomer> and combines them?
<Myoma> k could do anything it wants really
<Myoma> but now you can look at the subexpression: parse (fun hd ys -> ...) xs
<flux> I recently wrote a non-tokenizing parser for s-expressions in c++, it was quite a bit longer ;-)
<Myoma> 'hd' is Symbol ss or Nil or some parsed sexp, ys is the rest of the tokens
ulfdoz_ has joined #ocaml
<palomer> really?
<palomer> how come?
<Myoma> flux, hm good idea
ulfdoz has quit [Remote closed the connection]
<palomer> whoa, it's getting mega late
<palomer> and im getting sleepy
<palomer> I'd love to read the article when you wrote it!
* palomer is off for the night
<Myoma> :)
Jedai has quit [Read error: 110 (Connection timed out)]
Jedai has joined #ocaml
seafood_ has quit [Read error: 60 (Operation timed out)]
OChameau has joined #ocaml
seafood has joined #ocaml
Asmadeus has joined #ocaml
marmotine has joined #ocaml
maattd has joined #ocaml
Snark_ has joined #ocaml
seafood has quit [Read error: 60 (Operation timed out)]
Asmadeus has quit ["cya !"]
mfp has quit [Read error: 110 (Connection timed out)]
mfp has joined #ocaml
Proteus has joined #ocaml
Asmadeus has joined #ocaml
Ched- has joined #ocaml
hkBst has joined #ocaml
Asmadeus has quit ["cya !"]
struktured_ has quit [Read error: 110 (Connection timed out)]
munga has joined #ocaml
acatout has quit [Read error: 104 (Connection reset by peer)]
acatout has joined #ocaml
Snark_ is now known as Snark
bluestorm has joined #ocaml
bluestorm has quit [Client Quit]
filp has quit ["Bye"]
Jedai has quit [Read error: 110 (Connection timed out)]
Jedai has joined #ocaml
threeve_ has joined #ocaml
filp has joined #ocaml
Proteus has quit [No route to host]
Associat0r has joined #ocaml
Proteus has joined #ocaml
mishok13 has quit [Read error: 60 (Operation timed out)]
Proteus has quit [Read error: 113 (No route to host)]
Asmadeus has joined #ocaml
<Smerdyakov> Interesting. I got a recruiting e-mail for a quantitative finance operation that mentions Haskell early on the list of good technologies to know.
<Smerdyakov> One wonders if that's just a trick to snag good programmers.
pango_ has quit [Remote closed the connection]
pango_ has joined #ocaml
Proteus has joined #ocaml
filp has quit ["Bye"]
ecc has joined #ocaml
Proteus has quit [Read error: 113 (No route to host)]
mbishop has quit [Read error: 113 (No route to host)]
bluestorm has joined #ocaml
Linktim has joined #ocaml
Proteus has joined #ocaml
Proteus_ has joined #ocaml
Proteus has quit [Read error: 104 (Connection reset by peer)]
maattd has quit [Remote closed the connection]
Linktim has quit ["Quitte"]
filp has joined #ocaml
Amorphous has quit [Read error: 110 (Connection timed out)]
Amorphous has joined #ocaml
Proteus__ has joined #ocaml
ecc has quit [Read error: 113 (No route to host)]
Proteus has joined #ocaml
Proteus_ has quit [Read error: 113 (No route to host)]
Linktim has joined #ocaml
Asmadeus has quit [Read error: 54 (Connection reset by peer)]
jlouis has joined #ocaml
Proteus__ has quit [Read error: 113 (No route to host)]
OChameau has quit ["Leaving"]
itewsh has joined #ocaml
tvn1981a has joined #ocaml
<tvn1981a> can I create something like enum type in ocaml ? e.g., [WIN=1, LOSE = 2, TIE = 0] ?
<Myoma> No
<Myoma> you write, let win = 1 in ocaml
<Myoma> or you cal define type conclusion = Win | Lose | Tie
<bluestorm> with a let int_of_result = function TIE -> 0 | WIN -> 1 | LOSE -> 2
<tvn1981a> nice - thanks
wlmttobks has quit ["Leaving"]
wlmttobks has joined #ocaml
<tvn1981a> if I have 2 classes c1 and c2 all inherit from class c0. I can do something like let myclass = if true then new c1 else then new c2 in ... now I would like to intialize the variable myclass ? e.g., let myclass = ref Something ; if true then myClass := new c1 ... <- these syntax aren't right - what are the right ones ?
<flux> you could use either let myclass = ref None and later reset it to Some (new ..), or perhaps you can do let myclass = ref (new dummy_class) where dummy_class has only dummy methods
mbishop has joined #ocaml
Linktim has quit ["Quitte"]
Proteus_ has joined #ocaml
tomh_-_ has joined #ocaml
<palomer> Myoma, did you write an article based on that cool program?
<Myoma> palomer: No, another example of the same thing came to mind though
<palomer> what is it?
<Myoma> it sort of a silly example in ocaml, it makes sense in a pure functional setting though
<Myoma> in ocaml you could just close over some mutable cells, but anyway a tuple was used for returning two values, since it was recursive the tuple is created and destroyed lots of times. looking at it in terms of continuation (of the tuple constructor) you can do away with that
Proteus has quit [Read error: 113 (No route to host)]
itewsh has quit [Read error: 113 (No route to host)]
thelema has quit [Read error: 110 (Connection timed out)]
Proteus__ has joined #ocaml
Proteus has joined #ocaml
Proteus_ has quit [Read error: 113 (No route to host)]
filp has quit ["Bye"]
itewsh has joined #ocaml
Jedai has quit [Connection timed out]
Jedai has joined #ocaml
ygrek has joined #ocaml
Proteus__ has quit [No route to host]
Snark has quit ["Ex-Chat"]
longh has joined #ocaml
smimou has quit [Remote closed the connection]
Proteus has quit [No route to host]
Linktim has joined #ocaml
ary1 has joined #ocaml
Linktim has quit ["Quitte"]
<bluestorm> tvn1981a: if you're new to OCaml, you should stay away from object oriented programming at first
<bluestorm> it's non-trivial and might give you bad ocaml habits
<bluestorm> the natural way is to use functional programming, not the old OOP you know
<tvn1981a> I have to learn this program which is written in ocaml
<tvn1981a> it contains some oop
smimou has joined #ocaml
Proteus has joined #ocaml
bluestorm has quit [Remote closed the connection]
ary1 has left #ocaml []
sporkmonger has quit []
marmotine has quit ["mv marmotine Laurie"]
tvn1981a has quit ["ChatZilla 0.9.83 [Firefox 3.0.1/2008070206]"]
jeddhaberstro has joined #ocaml
longh has quit [Read error: 104 (Connection reset by peer)]
ygrek has quit [Remote closed the connection]
threeve_ has quit []
itewsh has quit ["KTHXBYE"]
Jedai has quit [Connection timed out]
Jedai has joined #ocaml
hkBst has quit [Read error: 104 (Connection reset by peer)]
rby has quit [Read error: 54 (Connection reset by peer)]
Jedai has quit [Read error: 60 (Operation timed out)]
Jedai has joined #ocaml
jlouis has quit ["Leaving"]
Proteus_ has joined #ocaml
rby has joined #ocaml
Proteus has quit [Read error: 104 (Connection reset by peer)]
mbishop_ has joined #ocaml
pango_ has quit [Remote closed the connection]
mbishop has quit [Read error: 110 (Connection timed out)]
Proteus_ has quit [Read error: 113 (No route to host)]
mbishop_ is now known as mbishop
tomh_-_ has quit ["http://www.mibbit.com ajax IRC Client"]
threeve has joined #ocaml
Jedai has quit [Read error: 110 (Connection timed out)]
Jedai has joined #ocaml