gildor changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.12.0 http://bit.ly/aNZBUp
ikawe has joined #ocaml
elehack has joined #ocaml
blackswan has joined #ocaml
blackswan has quit [Ping timeout: 265 seconds]
blackswan has joined #ocaml
blackswan has quit [Ping timeout: 265 seconds]
elehack has quit [Quit: not a typewriter]
valross has quit [Ping timeout: 240 seconds]
blackswan has joined #ocaml
valross has joined #ocaml
blackswan has quit [Ping timeout: 265 seconds]
boscop_ has joined #ocaml
boscop has quit [Ping timeout: 245 seconds]
chee has quit [Ping timeout: 245 seconds]
jeddhaberstro has joined #ocaml
q[mrw] has joined #ocaml
patronus has quit [Quit: leaving]
patronus has joined #ocaml
blackswan has joined #ocaml
blackswan has left #ocaml []
q[mrw] has quit [Ping timeout: 260 seconds]
jakedouglas1 has quit [Quit: Leaving.]
Associat0r has quit [Quit: Associat0r]
Modius has joined #ocaml
Modius has quit [Max SendQ exceeded]
jakedouglas has joined #ocaml
Modius has joined #ocaml
jakedouglas has quit [Quit: Leaving.]
joewilliams is now known as joewilliams_away
_JFT_ has joined #ocaml
_JFT_ has quit [Client Quit]
carm has quit [Remote host closed the connection]
q[mrw] has joined #ocaml
jeddhaberstro has quit [Quit: jeddhaberstro]
ulfdoz has joined #ocaml
Associat0r has joined #ocaml
ygrek has joined #ocaml
q[mrw] has quit [Ping timeout: 276 seconds]
ulfdoz has quit [Ping timeout: 276 seconds]
xmarteo has joined #ocaml
coucou747 has joined #ocaml
ttamttam has joined #ocaml
Amorphous has quit [Ping timeout: 276 seconds]
Sgeo has joined #ocaml
* Sgeo is coming at OCaml from a minor Haskell background
ftrvxmtrx has quit [Quit: Leaving]
Amorphous has joined #ocaml
dark has joined #ocaml
<dark> Can someone help me with a shift/reduce conflict in ocamlyacc? It happens because I don't know much about parsing, http://paste.pocoo.org/show/245641/
<dark> It says "2 shift/reduce conflicts"
<dark> I think I know that one is avb vs. a v b
<dark> i.e. the letter "v" can be both part of an identifier, or an operator
<dark> (and thus one would need spaces)
<dark> if this is the case i don't know how to avoid it :( a\/b? a|b?..
<dark> actually
<dark> the "v" thing is part of the lexer
<Sgeo> How, exactly, does Lazy.lazy work?
<Sgeo> Given that OCaml is usually strict, I mean
<dark> you mean the lazy keyword?
<dark> it isn't a function
<Sgeo> Ah
<dark> I mean, Lazy.lazy_from_val is strict
<dark> it evaluates the argument and returns a fake lazy value
<dark> if you want to build lazy values without the lazy keyword, you build with lazy_from_fun
<Sgeo> Is ocaml-tutorial.org considered decent?
<dark> I don't know the actual implementation, but a possible implementation of lazy values in strict languages are closures
<dark> Sgeo, hmm.. it's for people that already know a bit of C++, etc..
<Sgeo> I know imperative languages
<dark> it was useful during the first steps, but after that, the manual & some books were better
<Sgeo> I'd say Python is my native language. But I also know a touch of Haskell
<dark> there is also a free book at the site
<dark> (i mean, useful to me)
<Sgeo> Does the OO-ness of OCaml make up for the syntax?
<dark> hmmm.. make up?
<dark> I think the OO syntax of ocaml is okay
<Sgeo> I think OCaml's syntax will give me nightmares tonight
<Sgeo> Haven't gotten to the OO part yet
<dark> ocaml syntax is a bit messier now I'm exposed to haskell, but..
<dark> the OO part is the best part of ocaml's syntax o.o
<Sgeo> Ah, ok
<dark> it has ruby-like methods (i.e. you don't need the extra () after a method call)
<dark> so a#b +1 is a method call, plus a sum
<dark> the # might be a bit strange
<dark> but I mean, ocaml has "the type of objects with method b that returns an int"
<dark> # let f a = a#b + 1;;
<dark> val f : < b : int; .. > -> int = <fun>
<dark> this is just nice
<dark> you don't need to specify the type of a, and it will work on all objects with method b, regardless of class origin
<Sgeo> Type-safe duck-typing... I once described something like that... Um, something in Scala, IIRC
<dark> yes^^
<dark> to me, {}-less languages are more interesting
<dark> scala has a java-like syntax, right?
<Sgeo> Um.. it's been a while since I glanced at Scala
<dark> this is what gives me nightmares .-.
<dark> the problem of ocaml syntax is some ambiguities that force you do put extra ()
|marius| has joined #ocaml
<dark> and it prefers to bind in a way that makes functional programming less verbose
<dark> so you sometimes has to write (a; b; c) because it will reject a; b; c in that context
<dark> (inside a "else" clause, IIRC)
<Sgeo> At least it's not weird backwards int list
<dark> backwards?
<Sgeo> List a --Haskell
<dark> Ah
<dark> int list was probably the biggest mistake of ocaml designers
<dark> linguistically it is decent ("a int list"), but.. this doesn't compose well
<dark> if you need to parametrize with 2 types, you need to write (a, b) type
<dark> instead of type a b
<dark> and then you don't have currying with types ._.
<dark> that is, (type a) being a type
<Sgeo> type a would be kind * -> * in Haskell
<Sgeo> iirc
<dark> tuareg mode has some annoying bugs here, with comments and syntax highlighting
<Sgeo> Suppose I use the module inclusion thing, but chain two extension modules that are unaware of eachother
<Sgeo> What happens?
<dark> it justs defines what is defined in A, then define what is defined in B
<dark> B may shadow A's contents
<dark> just*
<Sgeo> Would all of A's contents be unavailable?
<dark> yes
<dark> shadowing is a problem in ocaml, it doesn't have the facilities of haskell to hide some imports, etc
<dark> in fact, ocaml has a design problem: most modules has a type t, and some standard functions like map
<dark> so you can't really open modules
<dark> it is supposed that you use, in your code, List.map, etc
<dark> i mean, it's actually nice, but it doesn't scale well for many parameters
<dark> there is a "local open" for just a expression that alleviates the problem
<Sgeo> "OCaml also has a way to label arguments and have optional arguments with default values."
<Sgeo> Ok, it's starting to become worth it
<Sgeo> But how do optional arguments work with currying?
ftrvxmtrx has joined #ocaml
<Sgeo> You can do the duck-typing like thing on constructors?
<Sgeo> Oh, they're bad for type safety, apparently
<dark> Sgeo, to be fair, it works badly with currying. because you can't have a function with no non-optional arguments
<dark> i.e. the last argument must be non-optional
<dark> and if you apply the last non-optional argument, you lose the optional-ness
noj has joined #ocaml
<dark> so let f ?(a=1) c d = c + d * a
<dark> f 1 is int -> int
<dark> when you apply c, you got jumped over a
<dark> but f ~a:2 is still int -> int
<Sgeo> I saw an example that was like let f ?(a=0) () = (* stuff *)
<dark> er, int -> int -> int
<dark> yes, he put the extra () because ?(a=0) can't be the last parameter
<dark> actually
<dark> # let f ?(a=1) = a;;
<dark> Warning 16: this optional argument cannot be erased.
<dark> val f : ?a:int -> int = <fun>
<dark> now i'm confused
<dark> interesting, i think this is a new feature
<dark> # let f c ?(a=1) = a + c;;
<dark> Warning 16: this optional argument cannot be erased.
<dark> val f : int -> ?a:int -> int = <fun>
<dark> # f 1;;
<dark> - : ?a:int -> int = <fun>
<dark> now it's a better compromise imo :)
<dark> (look that you lost the actual optional-ness, when the last argument is "optional")
<dark> (because the last argument can never be in fact "optional"; if it were, how to diff between returning a function and applying it with 0 arguments)
<dark> *?
Vassia has joined #ocaml
Vassia has quit [Ping timeout: 240 seconds]
munga has joined #ocaml
oriba has joined #ocaml
ygrek has quit [Remote host closed the connection]
valross has quit [Quit: Ex-Chat]
patronus has quit [*.net *.split]
schmrkc has quit [*.net *.split]
ztfw` has quit [*.net *.split]
fabjan has quit [*.net *.split]
joewilliams_away has quit [*.net *.split]
dcolish has quit [*.net *.split]
nimred has quit [*.net *.split]
nejimban has quit [*.net *.split]
ztfw` has joined #ocaml
joewilliams_away has joined #ocaml
fabjan has joined #ocaml
patronus has joined #ocaml
nejimban has joined #ocaml
nimred has joined #ocaml
schmrkc has joined #ocaml
Edward has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
oriba has quit [Quit: Verlassend]
Vassia has joined #ocaml
Vassia has quit [Ping timeout: 240 seconds]
|marius| has quit [Remote host closed the connection]
dark has quit [Ping timeout: 265 seconds]
Edward has quit [Ping timeout: 248 seconds]
Edward has joined #ocaml
ygrek has joined #ocaml
_andre has joined #ocaml
ftrvxmtrx has joined #ocaml
Edward has quit []
ygrek has quit [Ping timeout: 245 seconds]
pikachuyann has joined #ocaml
maskd has quit [Quit: leaving]
dcolish has joined #ocaml
maskd has joined #ocaml
Vassia has joined #ocaml
Vassia has quit [Ping timeout: 260 seconds]
boscop_ has left #ocaml []
boscop has joined #ocaml
Edward has joined #ocaml
<th5> Does anyone have an opinion on when to use records (vs products) ?
<gildor> th5: products you mean tupples (a, b, c)?
<gildor> tuples
<th5> yes - well i mean the product (AND) part of ADT's - as opposed to the sum part (OR - as in type t = THIS | THAT)
<th5> type t = T of a * b vs type t = {field_a : a; field_b : b}
<gildor> You should switch to record when a tuple is more than 3 elements
<gildor> (at least that what i do)
<th5> Hmm
<th5> Right now I don't use records often. Still, there's a lot of code that I read that is hard to figure out becuase there are so many parameters to each constructor
<th5> that sounds like a good rule of thumb though
<gildor> if tuples are part of a variant type, you can go further 5 or even more it they are typed
<gildor> i.e. type t = Toto of string * string * string is not good
<gildor> but type t = Toto of string * my_typ_z * int is ok
<th5> I see what you mean.
<gildor> when using let rec ... tuple = ... you can also go over the 3 elements limit if the function is not too long
<gildor> (same for List.fold et al)
<gildor> (not too long = less then 20 lines)
<th5> My other idea was making a bunch of types with only one constructors: type age = Age of int so that type person = age * ... but that seems like bad style - probably will go for records just want to avoid type foo = int * int * int (like you said above)
<th5> thanks
<gildor> th5: a nice extension of 3.11 is private abbreviation
<gildor> that will help you in this case:
<gildor> type age = private int type person = age * ...
<gildor> so you can stay with a record, falling in the snd case I said above
<gildor> (i.e. " string * my_typ_z * int is ok")
Vassia has joined #ocaml
joewilliams_away has left #ocaml []
joewilliams has joined #ocaml
Vassia has quit [Ping timeout: 260 seconds]
jakedouglas has joined #ocaml
thieusoai has quit [Read error: Connection reset by peer]
<thelema> th5: on list v. tuple: if you're going to access the elements of the group other than through pattern matching, use a record.
thelema_ has joined #ocaml
thelema has quit [Ping timeout: 265 seconds]
Edward has quit [Ping timeout: 245 seconds]
thelema_ is now known as thelema
ftrvxmtrx has quit [Ping timeout: 265 seconds]
ikaros has joined #ocaml
ygrek has joined #ocaml
ftrvxmtrx has joined #ocaml
chee has joined #ocaml
ttamttam has quit [Remote host closed the connection]
Vassia has joined #ocaml
Vassia has quit [Ping timeout: 276 seconds]
Edward has joined #ocaml
sepp2k has joined #ocaml
Anarchos has joined #ocaml
ulfdoz has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
munga has quit [Ping timeout: 276 seconds]
ttamttam has joined #ocaml
travisbrady has joined #ocaml
ttamttam has quit [Ping timeout: 276 seconds]
<travisbrady> I'm using bitstring and when attempting to read a Bitstring from a socket with bitstring_of_chan my code blocks indefinitely. Anyone know why this might be?
Vassia has joined #ocaml
<Anarchos> travisbrady no idea
<travisbrady> It happens in the 2nd iteration. If my socket contains 16 chars it reads those correctly (i hacked bitstring_of_chan to print a bunch to stdout) and then it calls 'input chan tmp 0 tmpsize' again and blocks forever
Vassia has quit [Ping timeout: 246 seconds]
<travisbrady> I'm on mac os 10.5 with ocaml 3.11.1 with the latest bitstring
<Anarchos> travisbrady are your strigns ending with \0 ?
_andre has quit [Ping timeout: 240 seconds]
Edward has quit [Read error: Connection reset by peer]
<travisbrady> Anarchos: Yes
<Anarchos> i can't help you, i nver use Bitstring :/
<hcarty> travisbrady: If/when he is around, rwmjones is likely the best person to ask
<travisbrady> Anarchos: I think it's actually not really a bitstring issue. But more an issue of calling input on a chan
<travisbrady> hcarty: thank you
<Anarchos> travisbrady maybe input needs a flush or \n at the end of string
willb1 has quit [Ping timeout: 240 seconds]
itewsh has joined #ocaml
willb1 has joined #ocaml
<rwmjones> test
<rwmjones> wierd, that worked
<rwmjones> travisbrady: I was having problems sending to this channel before, but it seems to be working now
<rwmjones> travisbrady: it looks like a flush problem anyway
<travisbrady> rwmjones: ahh, thanks for responding
<travisbrady> are you able to reproduce it?
ftrvxmtrx has joined #ocaml
<rwmjones> well, I do use bitstring_of_chan OK ... did you have a look at the implementation?
<rwmjones> let me find it ...
<rwmjones> my reading of that is the sender much close the channel before the function will return
<travisbrady> I did look at the impl yes, I actually copied it into my code and peppered it with flush_alls and prints to see what was happening.
<rwmjones> a bitstring is nothing too special ... it's just a simple triple of (data, startbit, lenbits)
<travisbrady> Ahh...so maybe this function won't work for me then.
<rwmjones> so you could read from the socket yourself, and just make a bitstring
th5 has quit [Remote host closed the connection]
<rwmjones> or read from the socket into your own string and then use bitstring_of_string
<travisbrady> I'm attempting to communicate with a kdb+ server via it's binary protocol.
th5 has joined #ocaml
<travisbrady> yeah, i'd previously written a little memcached binary client using bitstring and I handled all the reading myself. but I noticed bitstring_of_chan and thought it looked pretty slick.
<rwmjones> maybe bitstring_of_chan_max? if you know how many bytes are coming in
_andre has joined #ocaml
<Anarchos> rwmjones do you know the byterun internally ?
<rwmjones> I don't understand ..
<Anarchos> rwmjones i wonder why there is enter/leave_blocking_section function instead of a semaphore
iratsu has quit [Read error: Operation timed out]
iratsu has joined #ocaml
dark has joined #ocaml
<gildor> rwmjones: from time to time, I also not able to talk on the channel
<gildor> join -> leave -> join is enough to solve this
<gildor> rwmjones: I think it is related to unauthentification
thieusoai has joined #ocaml
<rwmjones> it was very strange .. I didn't rejoin, but I was suddenly able to talk again
Anarchos has quit [Ping timeout: 264 seconds]
Anarchos has joined #ocaml
iratsu has quit [Ping timeout: 240 seconds]
_andre has quit [Quit: *puff*]
<pikachuyann> bonne nuit / good night
Vassia has joined #ocaml
pikachuyann has quit [Quit: 'night]
Vassia has quit [Ping timeout: 276 seconds]
|marius| has joined #ocaml
sepp2k has quit [Quit: Leaving.]
Edward has joined #ocaml
iratsu has joined #ocaml
valross has joined #ocaml
drk-sd is now known as drksd
dark has quit [Ping timeout: 265 seconds]
iratsu has quit [Ping timeout: 240 seconds]
ygrek has quit [Ping timeout: 245 seconds]
ulfdoz has quit [Ping timeout: 245 seconds]
willb1 has quit [Ping timeout: 260 seconds]
dark has joined #ocaml
iratsu has joined #ocaml
oriba has joined #ocaml
willb1 has joined #ocaml
willb1 has quit [Read error: Connection reset by peer]
willb1 has joined #ocaml
willb1 has left #ocaml []
iratsu has quit [Ping timeout: 240 seconds]
Sgeo_ has joined #ocaml
Sgeo has quit [Ping timeout: 245 seconds]
ssbr_ has joined #ocaml
ssbr has quit [Ping timeout: 252 seconds]
ssbr_ has quit [Read error: Connection reset by peer]
ssbr has joined #ocaml
rudi_s has quit [Read error: Operation timed out]
ikaros has quit [Quit: Leave the magic to Houdini]
rudi_s has joined #ocaml
itewsh has quit [Quit: o/]
ssbr has quit [Ping timeout: 276 seconds]
ssbr has joined #ocaml
xmarteo has quit [Quit: Debian GNU/Hurd is Good.]
Edward has quit []
philtor has joined #ocaml
<|marius|> greetings -- does anyone know how to affect ocamlfind link order? (i have a library that i depend on that's not ocamlfound, but it's depended-on by an ocamlfound library)
|marius| has quit [Remote host closed the connection]
<julm> |marius|: you could set OCAMLPATH to a directory with a META.yourproject containing a directory=""
<julm> (if he comes back)
philtor has quit [Ping timeout: 265 seconds]
xmarteo has joined #ocaml
oriba has quit [Quit: Verlassend]
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]