gildor changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.12.1 http://bit.ly/nNVIVH
<Juzor> okay
<zaltekk> why do you say fun x -> main x instead of just main
<pippijn> for clarity, I think
<mrvn> zaltekk: no reason
<mrvn> as pippijn says
<thelema_> ?? let arg1 = Sys.argv.(1) in let arg2_int = int_of_string Sys.argv.(2) in ...
<Juzor> yep
err404 has quit [Remote host closed the connection]
<Juzor> how do you know I intended to parse ints ?
<mrvn> crystal ball
<pippijn> mindreading is part of #ocaml chatters' job description
<Juzor> ^^
<thelema_> I use a magic 8 ball
roha has joined #ocaml
rzys has joined #ocaml
Tobu has quit [Ping timeout: 260 seconds]
Tobu has joined #ocaml
ulfdoz_ has joined #ocaml
ulfdoz has quit [Ping timeout: 272 seconds]
ulfdoz_ is now known as ulfdoz
cdidd has joined #ocaml
letrec has joined #ocaml
tmaedaZ is now known as tmaeda
my_nick_was_take has joined #ocaml
Zedrikov has quit [Ping timeout: 260 seconds]
tmaeda has quit [Quit: Quit Nadoka 0.7.1-trunk (rev: 187) - http://www.atdot.net/nadoka/]
haelix has quit [Read error: Operation timed out]
haelix has joined #ocaml
Juzor has quit [Ping timeout: 246 seconds]
my_nick_was_take has quit [Quit: Bye all, see you next time!]
Juzor has joined #ocaml
roha has quit [Ping timeout: 250 seconds]
rzys has quit [Ping timeout: 272 seconds]
oriba has quit [Quit: oriba]
caligula__ has quit [Ping timeout: 265 seconds]
smerz has quit [Ping timeout: 246 seconds]
Juzor1 has joined #ocaml
Juzor has quit [Ping timeout: 248 seconds]
mjonsson has quit [Remote host closed the connection]
emmanuelux has quit [Ping timeout: 252 seconds]
NihilistDandy has quit [Ping timeout: 245 seconds]
sivoais has quit [Quit: Lost terminal]
sivoais has joined #ocaml
Tobu has quit [Ping timeout: 272 seconds]
Tobu has joined #ocaml
pr0zac has joined #ocaml
caligula has joined #ocaml
Tobu has quit [Ping timeout: 260 seconds]
Tobu has joined #ocaml
Fnar has quit [Ping timeout: 245 seconds]
bitbckt has quit [Read error: Operation timed out]
bitbckt has joined #ocaml
Tobu has quit [Ping timeout: 272 seconds]
Tobu has joined #ocaml
Fnar has joined #ocaml
Fnar has quit [Changing host]
Fnar has joined #ocaml
jamii has joined #ocaml
tufisi has joined #ocaml
Tobu has quit [Ping timeout: 272 seconds]
Tobu has joined #ocaml
Zedrikov has joined #ocaml
Snark has joined #ocaml
eni has joined #ocaml
rzys has joined #ocaml
roha has joined #ocaml
ulfdoz has quit [Quit: brb]
ulfdoz has joined #ocaml
ulfdoz has quit [Quit: deprecated]
ulfdoz has joined #ocaml
<flux> I was amazed how one of its first examples worked: #use "printf.ml";;
<flux> but I'm not sure if that's giving the right idea about how to use use modules..
<flux> it's good that 2.7 Scope has an example about rebinding.
<flux> hmm, it calls the error referring to a non-existing value (Unbound value) a "runtime error"
<flux> (2.11)
<flux> although I'm unsure to what call if, if syntax errors are a class of their own, and those errors with syntax errors make "compiling errors" or some such
<flux> it seems to give a good overview on things a newcomer to ocaml might do wrong :)
<adrien> if-then-else, open as a way to _load_ modules, ... ?
<flux> what about if-then-else?
<adrien> if foo then do_this (); do_that ()
<flux> where is that?
<adrien> # if true then (); () else ();;
<adrien> Error: Syntax error
<flux> where are you picking that code from?
<adrien> syntax error for the else because ocaml "ends" the "then" as early as it can
* adrien has to afk for a few minutes
<flux> in some pages the code isn't properly indented
Tobu has quit [Ping timeout: 272 seconds]
Tobu has joined #ocaml
eni has quit [Ping timeout: 260 seconds]
<flux> heh, at least one python example has slipped in
<flux> yeah, it seems the author has mixed #use with Open consistently, which leads me into thinking he must not be very familiar with OCaml :-o
<flux> hmm, records are introduced after Arrays and Hashtbls..
<adrien> or maybe he has developed his own style of ocaml ;p
<flux> adrien, I wonder though how he would make use of the Str module with #use, perhaps he just has ocaml sources around :)
<flux> then he talks about aggregate types, this is probably the first time I've heard sum types being called that. it's not a bad name for them, but probably quite rare?
<flux> and the whole pdf doesn't really mention the module system at all
<flux> but I suppose it's work in progress.
<flux> so perhaps Hickey's Introduction to Objective Caml is still better
<adrien> flux: ah... indeed :P
iZsh has quit [Ping timeout: 265 seconds]
jamii has quit [Ping timeout: 246 seconds]
mnabil has joined #ocaml
<pippijn> mrvn: pity, I'm new to ocaml but none of that is new to me
<pippijn> mrvn: at least the ocaml language one, I haven't seen the others, yet
Submarine has joined #ocaml
jamii has joined #ocaml
Submarine has quit [Read error: Connection reset by peer]
roha has quit [Ping timeout: 240 seconds]
rzys has quit [Ping timeout: 244 seconds]
ftrvxmtrx has quit [Read error: Connection reset by peer]
reynir has quit [Ping timeout: 246 seconds]
reynir has joined #ocaml
ftrvxmtrx has joined #ocaml
<flux> pippijn, perhaps you aren't new enough :)
<pippijn> I've used ocaml for 2 weeks or so
<flux> oh :)
<pippijn> (not 2 weeks ago, just 2 weeks and then I stopped because my semester started and it's super busy)
<flux> maybe there should be a cheatsheet generator. you could pick which categories to have. I wouldn't have the oo stuff in 'level 1' cheatsheets, for example.
<pippijn> (now I'm back doing java at work)
<reynir> In the compiler class we wrote a compiler of a subset of java 1.1 in ocaml :)
<mrvn> I like the local scope syntax: let rect = Sdlvideo.({ r_x = 0; r_y = 0; r_w = 512; r_h = 256; }) in
larhat has quit [Quit: Leaving.]
jamii has quit [Ping timeout: 246 seconds]
iZsh has joined #ocaml
<pippijn> mrvn: Arg.align Arg.([...])
ftrvxmtrx has quit [Ping timeout: 265 seconds]
<pippijn> but I find myself using "let open .. in" more often
<rly> The OCaml compiler is much quicker than GHC, right?
<rly> Is that because of proper engineering in the compiler or because the language is simpler or .... ?
<mrvn> rly: it is far quicker to output a result
<mrvn> because it doesn't optimize
<mrvn> The type system is simpler too but that doesn't gain so much
<rly> So, it's just tokenize, parse, basic compile.
<rly> I recently tried some SML code and I was already like .... wow, this is fast.
<mrvn> +type inference, and some simple optimisation
<Qrntz> are there any pitfalls to creating a more heavily optimizing ocamlopt (except reduced compilation speed)? just wondering.
<rly> Not the generated code, but the loading of code and when changing somec ode.
<mrvn> if you want really fast then try go from google. The whole compiler builds in 10s.
<rly> mrvn: and the same for changes?
<mrvn> rly: 10s from pure source to finshed binary.
<mrvn> Qrntz: you always have to be carefull that you don't optimize in bugs.
<rly> mrvn: but Go doesn't have any fancy types.
<mrvn> Qrntz: as recently discussed some major shortfalls of the compiler are that it doesn't inline closure arguments and it doesn't reduce polymorphic types to the actual types when inlineing. Those two could give a fair bit of speedup.
<rly> AFAIK, it ignores everything that has happened in the past 20 years.
<Qrntz> mrvn, interesting…
<mrvn> Qrntz: go write patch and become famous. :)
ftrvxmtrx has joined #ocaml
<Qrntz> mrvn, heh, wish I knew the internals that well.
<Qrntz> I've been interested in how ocamlopt generates code since the very moment I started ocaml, though
<mrvn> Qrntz: then be happy it is kept simple. Makes it much easier to understand.
<rly> Is OCaml written in OCaml? If so, can it be bootstrapped? If so, how?
<Qrntz> mrvn, indeed.
<mrvn> rly: ocaml + c. And the source seems to be self contained.
<adrien> rly: the ocaml compiler doesn't try to gain 1% of speed
<adrien> if there is something with a notable gain, it can go in
<adrien> but less than 5% and only in some specific benchmark at the cost of complexity in the compiler? that usually doesn't get in
<rly> adrien: by 'the compiler' you mean the native code compiler which doesn't do fancy optimizations?
<adrien> I mean "ocamlopt"
<adrien> "ocamlc" does a bit less than "ocamlopt"
<rly> Does it even optimize (map f . map g) l to (map (f.g) l)?
<mrvn> Some optimization could be done for both byte and native code
<adrien> (but mostly because it skips things not appropriate for bytecode)
<adrien> rly: no
<mrvn> rly: how could it?
<adrien> rly: it's only possible if f is pure
<adrien> and it can't know that
<mrvn> it would also need internal knowledge of map or have to vectorize it
<rly> adrien: if f and g are in code which it has access to, it could.
<mrvn> rly: f and g aren't even inlined
<adrien> but to be honest, I prefer a dumb compiler that really does what I is written, it predictable
<adrien> rly: it doesn't know such things
<rly> adrien: yes, I think a good case could be made for that.
<rly> adrien: smart compilers are nice when you don't have to wait for them.
<mrvn> adrien: I always wanted to write a C compiler like that.
<adrien> if it knew that, it could eliminate some dead code in modules, which would be really the nicest benefit I think
<rly> What I don't get it why OCaml code is so fast then.
<rly> Are the others doing it so wrong then?
<mrvn> rly: because 1) it is really hard to write code that doesn't stall the cpu pipeline and dumb code just fills the gaps better, 2) ocaml source code is efficient, 3) optimizing just works really hard to get those last 5% speed.
<adrien> probably, the first thing is that it's simple; then it's quite pragmatic
<mrvn> rly: Where you get problems is with small loops or heavy arithmetic code.
<mrvn> rly: things where unrolling and reordering has huge gains.
<mrvn> rly: also common subexpression elimination gains you a lot but people tend to do that manualy in ocaml.
<mrvn> as in let x = 3 * y + z in foo x; bar x; baz x
<adrien> that one depends
<adrien> in some cases, it's a loss
<adrien> and it'll depend on the machine quite a lot
avsm has joined #ocaml
<mrvn> adrien: computing x 3 times is never faster
<rly> Is there a way to get rid of the let a = 3;; let b = 4;; stuff and just write a=3; b=4 or something similar?
<mrvn> rly: no. a=3 is a comparison
<adrien> mrvn: in some cases, I've done that manually and that was slower
<adrien> and XL was mentionning that too
<rly> Does camlp integrate with the error messages?
<mrvn> adrien: I would call that a compiler bug then
<rly> So, let's say one writes a different surface syntax on top of OCaml, does it properly create error messages then for the new surface syntax?
<mrvn> rly: since you mention camlp. With camlp you can do pretty much anything.
<mrvn> rly: iirc someone wrote a shell grammar for camlp so you could compile your shell scripts as ocaml code.
<rly> And naturally, it also depends on how fast camlp executes, because one wouldn't want to get lots of slower compiles again.
<rly> mrvn: heh, I thought of that too once.
<rly> mrvn: cool that someone did.
<adrien> mrvn: might be different from what I saw but I quite clearly remember XL stating expression folding could be slower too
thizanne has quit [Remote host closed the connection]
<adrien> mrvn: was the shell thing cash or something else? I'd be quite interested in that actually
<mrvn> adrien: I found that years ago. no idea anymore
<adrien> ok, I'll try to find it
eni has joined #ocaml
Juzor1 has left #ocaml []
avsm has quit [Quit: Leaving.]
bnwr has quit [Quit: Changing server]
Fabio has joined #ocaml
emmanuelux has joined #ocaml
bnwr has joined #ocaml
ftrvxmtrx has quit [Ping timeout: 246 seconds]
ygrek has joined #ocaml
Zedrikov has quit [Ping timeout: 260 seconds]
eni is now known as albacker
albacker has quit [Changing host]
albacker has joined #ocaml
smerz has joined #ocaml
avsm has joined #ocaml
jamii has joined #ocaml
ikaros has joined #ocaml
iago has joined #ocaml
avsm1 has joined #ocaml
avsm has quit [Read error: Connection reset by peer]
ftrvxmtrx has joined #ocaml
avsm1 has quit [Quit: Leaving.]
sanders___ has joined #ocaml
NougatRillettes has joined #ocaml
iago has quit [Quit: Leaving]
IbnFirnas has joined #ocaml
reynir has quit [Ping timeout: 244 seconds]
hefner has quit [Quit: now you have two problems.]
tufisi has quit [Read error: Connection reset by peer]
tufisi has joined #ocaml
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
roha has joined #ocaml
rzys has joined #ocaml
reynir has joined #ocaml
reynir has quit [Ping timeout: 260 seconds]
reynir has joined #ocaml
iZsh has quit [Quit: Coyote finally caught me]
avsm has joined #ocaml
letrec has quit [Ping timeout: 248 seconds]
Tobu has quit [Ping timeout: 260 seconds]
bitbckt has quit [Ping timeout: 245 seconds]
bitbckt has joined #ocaml
dgfitch has quit [Remote host closed the connection]
Tobu has joined #ocaml
Tobu has quit [Changing host]
Tobu has joined #ocaml
The_third_bug has joined #ocaml
ftrvxmtrx_ has joined #ocaml
The_third_bug has quit [Ping timeout: 265 seconds]
The_third_bug has joined #ocaml
ftrvxmtrx has quit [Ping timeout: 260 seconds]
mnabil has quit [Ping timeout: 265 seconds]
smerz_ has joined #ocaml
flx_ has joined #ocaml
pango_ has joined #ocaml
dgfitch has joined #ocaml
ftrvxmtrx__ has joined #ocaml
bacam_ has joined #ocaml
ftrvxmtrx_ has quit [*.net *.split]
pango has quit [*.net *.split]
bacam has quit [*.net *.split]
diml has quit [*.net *.split]
flux has quit [*.net *.split]
flx_ is now known as flux
mnabil has joined #ocaml
bacam_ is now known as bacam
diml has joined #ocaml
machine2 has quit [Ping timeout: 272 seconds]
machine2 has joined #ocaml
Smerdyakov has joined #ocaml
ftrvxmtrx__ has quit [Ping timeout: 260 seconds]
ftrvxmtrx__ has joined #ocaml
snearch has joined #ocaml
absalon has joined #ocaml
pango_ is now known as pango
<mrvn> Some improvement on the map renderer: http://mrvn.homeip.net/map/map.png
<thelema_> mrvn: looking nice.
<reynir> mrvn: what is it for? It looks cool
<mrvn> A Siedler clone.
<mrvn> One problem is that I can hardly draw. I'm hoping eventually someone will draw me some nice textured tiles, items, units and buildings.
Smerdyakov has quit [Quit: Leaving]
<mrvn> s/hardly/barely/
foocraft_ is now known as foocraft
The_third_bug has quit [Ping timeout: 265 seconds]
The_third_bug has joined #ocaml
absalon has quit [Quit: Ex-Chat]
<pippijn> what library should I look at for a game client?
<pippijn> mrvn: maybe you know, as you're developing a game
<pippijn> ocamlnet?
<mrvn> probably a good choice.
<pippijn> is there an echo client/server example?
<mrvn> check libocamlnet-ocaml-doc
<pippijn> ah
<pippijn> lots of examples, good
<mrvn> I'm not sure though if ocmlnet gains you that much for your own game. I'm assuming you will write your own protocol and not use http.
<pippijn> I already have the protocol
<pippijn> and a client written in C++
<pippijn> and a server written in the same language
<mrvn> The just open a socket, connect it, use select to wait for data and parse that into ocaml structures.
<pippijn> I just need a simple event loop
<pippijn> is there an event loop for ocaml?
<mrvn> there is Unix.select
<pippijn> hm
<mrvn> and several event libs
<pippijn> maybe this
<pippijn> I use libev in my C++ client, too :)
<adrien> glib's!
<pippijn> nope.
<pippijn> but I'm going to try and make it mostly independent of the event loop
<pippijn> so it can be replaced
<pippijn> in case I want a GTK client at some point
<adrien> use lwt?
<reynir> mrvn: I think there's a website for free game art
<pippijn> adrien: you would recommend that?
<reynir> mrvn: http://opengameart.org
<zorun> Lwt is cool
<adrien> pippijn: it uses libev, it integrates with glib's loop and lablgtk, and it does some more
<pippijn> oh
<pippijn> it uses libev? really?
<adrien> and if you have stuff that would typically be blocking (I/O), it'll help
<adrien> yes
<adrien> libev or select
<pippijn> ok
<adrien> chosen at compile-time
<pippijn> lwt doesn't have a lot of examples, it seems
<Qrntz> the biggest one is probably ocsigen :-)
<mrvn> reynir: most of that art truely sucks and the search interface is totaly unusable.
<adrien> the search interface is bad but you can end up "getting" it
<adrien> and browsing by tags works quite well
Smerdyakov has joined #ocaml
Smerdyakov is now known as adamc
Submarine has quit [Quit: Leaving]
adamc has left #ocaml []
rzys has quit [Ping timeout: 260 seconds]
roha has quit [Ping timeout: 260 seconds]
sanders___ has quit [Ping timeout: 264 seconds]
reynir has quit [Quit: Reconnecting]
reynir has joined #ocaml
BiDOrD_ has joined #ocaml
<flux> pippijn, don't use that, it's broken, should say on the front page :). I should put that in bold..
<pippijn> ocaml-ev?
<flux> that
<flux> I still don't understand what's the problem
<pippijn> ok
<pippijn> oh
sanders___ has joined #ocaml
<pippijn> ok, well, I'm trying lwt now
<pippijn> I'm still confused as to how it's supposed to be used for sequential code
BiDOrD has quit [Ping timeout: 245 seconds]
<flux> it is a bit confusing, yes. but if you're talking about system calls, basically you write it like: instead of let a = Unix.read blahblah it is Lwt_unix.read blahblah >>= fun a -> ..
<pippijn> I want to open a socket and resolve a hostname, then connect to the resolved host and set the socket to non-blocking
<flux> if you use Lwt functions for that, they are probably nonblocking automatically
<adrien> if you have some chunk of code that will run while nothing else is running, do not try to use lwt there
<pippijn> adrien: what about logging?
<adrien> I mean
<pippijn> there is Lwt_log
<adrien> don't use the lwt features there
<pippijn> that returns a thread
machine2 has quit [Quit: : http://www.beta.facefox.com/index.php?do=/user/register/]
<pippijn> adrien: I don't know that.. I want to write a client library much more than a client
<pippijn> I don't know if someone will use it to create many clients in one process
<pippijn> so I think it should be non-blocking
<adrien> I don't know Lwt_log but basically, use the thread stuffs when you actually have several things that are running at the same time and some operations might be blocking
<pippijn> at least for resolving
<pippijn> and connecting, of course
<flux> does Lwt come with non-blocking resolver?
<adrien> do you need interactivity while it's resolving?
<pippijn> me, I don't need that, no
<adrien> if it makes no sense to do something else while it's resolving, don't overengineer
<pippijn> ok
<pippijn> Lwt_log.log returns a thread
<flux> you're supposed to sequence your code with the Lwt binding operator >>=
<pippijn> ok
<flux> (or use the syntax extensions to provide you with a bit more nicer syntax)
<pippijn> that's ugly for the log code
<flux> well, you can also push stuff to run on the main loop without that sequencing
<flux> I don't remember the function, but its type is probably 'a Lwt.t -> unit
rzys has joined #ocaml
<pippijn> is this how you write lwt code?
roha has joined #ocaml
<pippijn> val gethostbyname : string -> host_entry Lwt.t
<pippijn> it seems to have an async resolver
cdidd has quit [Read error: Operation timed out]
<flux> in principle yes, but you can type it in another way
<flux> for example, with less parenthesis
<flux> as I wrote above
milosn has quit [Read error: Connection reset by peer]
<pippijn> ok
<flux> foo 4 2 >>= fun returnvalue ->
<flux> bar (returnvalue + 3) >>= fun () ->
<flux> etc
<flux> with the syntax extension it becomes more natural, so that's perhaps something to look into
milosn has joined #ocaml
datkin has quit [Ping timeout: 260 seconds]
datkin has joined #ocaml
<mrvn> Added items and units: http://mrvn.homeip.net/map/map.png, you see what I mean with "I can barely draw"? :)
<pippijn> :)
struktured has joined #ocaml
<albacker> what kind of questions on functional and Ocaml programming would you think about to ask in an interview?
<zorun> albacker: is that used in the real world?
<zorun> :)
<zorun> it mostly depends on your public, I guess
sgnb` has joined #ocaml
<zorun> is it a lecture?
<albacker> internship interview
<mrvn> albacker: something about modules, functors, variant types and records, objects and tail recursion
<zorun> oh, at Jane's Street?
<albacker> zorun, everywhere
<albacker> mrvn, what about functional programming in general?
datkin has quit [Ping timeout: 246 seconds]
<mrvn> albacker: that too
sgnb` has quit [Remote host closed the connection]
tlockney_ has joined #ocaml
<mrvn> for an internship you shouldn't need to know a lot. It is not like you wan't earn ocaml quickly if you have some basic knowledge in programming and functional languages.
sgnb` has joined #ocaml
<mrvn> s/wan't/can't/
<mrvn> s/earn/learn/
adrien_ has joined #ocaml
hcarty_ has joined #ocaml
<albacker> :)
<albacker> you are right
ygrek has quit [Quit: Leaving]
<albacker> zorun, what about at jane's street, what kind of questions do they ask?
ikaros has quit [*.net *.split]
emmanuelux has quit [*.net *.split]
Snark has quit [*.net *.split]
sgnb has quit [*.net *.split]
hcarty has quit [*.net *.split]
yroeht has quit [*.net *.split]
tlockney has quit [*.net *.split]
adrien has quit [*.net *.split]
ikaros has joined #ocaml
yroeht has joined #ocaml
Snark has joined #ocaml
emmanuelux has joined #ocaml
<zorun> albacker: I honestly don't know
<albacker> ah, since you asked I thought you had an idea.
Snark has quit [Client Quit]
datkin has joined #ocaml
struktured has quit [Remote host closed the connection]
struktured has joined #ocaml
struktured has quit [Remote host closed the connection]
<mrvn> anyone using sdl? I can't Sdlvideo.blit a surface without loosing the alpha channel.
struktured has joined #ocaml
<pippijn> adrien_: http://paste.xinu.at/HPeG/
<pippijn> is this recursive calling of "start" is the right way?
<pippijn> I don't really like it
<pippijn> ok, maybe I don't need lwt in this area
<mrvn> you are missing a second thread
<zaltekk> if i'm applying a function with multiple parameters and i want one of them to be an expression like i + 1, do i need to do f ((i+1) j)
<zaltekk> with the two sets of parens?
<mrvn> no
<zaltekk> it seems to think f (i+1) j isn't f applied to i+1 and j
<mrvn> but it is
<zaltekk> err looks like i oversimplified
<Qrntz> zaltekk, you can use «succ i» instead of «i + 1»; just saying, some people prefer that
<zaltekk> hmm, okay.
<zaltekk> only my second day with ocaml
<albacker> pippijn, is that awesome wm?
<albacker> or dwm ?
<pippijn> xmonad
snearch has quit [Quit: Verlassend]
<zaltekk> does xmonad still have issues displaying swing uis?
<pippijn> maybe
<pippijn> I don't use swing uis
<zaltekk> i remember netbeans and eclipse being unusable
<zaltekk> but that was over a year ago
<zaltekk> i've been using i3
<pippijn> eclipse is usable
<pippijn> I use it every day at work
<pippijn> for a long time..
<albacker> i use awesome
<zaltekk> pippijn: okay, it must have been fixed them
Anarchos has joined #ocaml
<zaltekk> finally got my solution for the caltech exercise 3.3 working
<Anarchos> Who does know a C/C++ parser targeting Ocaml as the abstract target language ?
<Anarchos> I must admit i tried Elsa/Olmar but i am unable to compile it without some hacks, and the first test fails when i tried it
tufisi has quit [Ping timeout: 260 seconds]
<pippijn> ok, I think I found a good way
<pippijn> it will be like a fold over the infinite list of network packets
<rly> zaltekk: foo n m f = sum (map f (enumFrom n m))
<rly> zaltekk: that seems a lot better.
<rly> Fill in obvious definitions for enumFrom if you like.
krktz has quit [Remote host closed the connection]
krktz has joined #ocaml
adrien_ is now known as adrien
Tobu has quit [Ping timeout: 272 seconds]
reynir has quit [Ping timeout: 244 seconds]
iZsh has joined #ocaml
reynir has joined #ocaml
Tobu has joined #ocaml
rzys has quit [Ping timeout: 260 seconds]
roha has quit [Ping timeout: 265 seconds]
Smerdyakov has joined #ocaml
deelazy has joined #ocaml
deelazy has quit [Client Quit]
deelazy has joined #ocaml
deelazy has quit [Client Quit]
deelazy has joined #ocaml
deelazy has quit [Client Quit]
Juzor has joined #ocaml
roha has joined #ocaml
rzys has joined #ocaml
datkin has quit [Read error: Connection reset by peer]
Anarchos has quit [Quit: noz mad ganeoc'h]
sanders___ has quit [Quit: Leaving]
<pippijn> can I tell Unix.read to write into a string starting at a certain position?
<mrvn> it already does that
<pippijn> one that is not position 0
<mrvn> read fd buff ofs len reads len characters from descriptor fd, storing them in string buff, starting at position ofs in string buff. Return the number of characters actually read.
Fabio has quit [Quit: Leaving]
<pippijn> oh
<pippijn> strange.. I get Invalid_argument if I have ofs <> 0
<pippijn> oh I know
<adrien> :-)
<pippijn> mrvn: thanks
<albacker> why would you use variant types ?
<albacker> and i'm not talking about type = ... but about the `foo (type definition on the fly).. it's also the first time i see this.
jamii has quit [Ping timeout: 246 seconds]
<mrvn> albacker: That's a hash variant type.
<albacker> mrvn, why is that useful, can you give me an example?
<mrvn> They allow sub and supertypes.
<adrien> no need to define them, and some kind of inheritance for instance
<adrien> lablgtk shows how they can help
<mrvn> let f = function `Foo -> "Foo" | `Bar -> "Bar" | _ -> "<unknown>";;
<mrvn> val f : [> `Bar | `Foo ] -> string = <fun>
<mrvn> # f `Blub;;
<mrvn> - : string = "<unknown>"
<adrien> for instance, it uses `FOO in the OCaml interface when the GTK+ API uses "FOO" (the _string_, so with no type checking)
<adrien> or does it use enums in the GTK+ API?
<adrien> and, unlike non-polymorphic variants, you don't have to type Gtk.Bar.Baz.FOO (the full path) to use them
<adrien> night
<mrvn> One nice thing with hash variants is that they don't collidetype foo = [ `Foo ]
<mrvn> type bar = [ `Bar | `Foo ]
<albacker> so the advantage is that you don't need to define them?
<mrvn> Makes it easier to define functions that use the same flags but different subsets.
larhat has joined #ocaml
<mrvn> albacker: that too
<mrvn> But the main thing is that you have types [< bar ] a subset of bar, [ bar ] exactly bar and [> bar ] a superset of bar.
Tobu_ has joined #ocaml
Tobu has quit [Ping timeout: 260 seconds]
larhat has quit [Read error: Connection reset by peer]
larhat has joined #ocaml
albacker has quit [Ping timeout: 245 seconds]
larhat has quit [Quit: Leaving.]
mnabil has quit [Ping timeout: 244 seconds]
letrec has joined #ocaml
reynir has quit [Ping timeout: 265 seconds]
rzys has quit [Ping timeout: 245 seconds]
roha has quit [Ping timeout: 245 seconds]
mnabil has joined #ocaml
mfp has quit [Ping timeout: 272 seconds]
Smerdyakov has quit [Quit: Leaving]