* 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
<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>
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!]