dark_light changed the topic of #ocaml to: OCaml 3.09.2 available! Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
katana has joined #ocaml
svref has quit ["Client exiting"]
tristram has quit [Read error: 110 (Connection timed out)]
hikozaemon has joined #ocaml
woggle has joined #ocaml
rillig has quit ["exit(EXIT_SUCCESS)"]
Smerdyakov has joined #ocaml
chessguy has joined #ocaml
pango_ has joined #ocaml
chessguy has quit [" Try HydraIRC -> http://www.hydrairc.com <-"]
pango has quit [Remote closed the connection]
jcreigh has joined #ocaml
jcreigh has quit ["Cuius rei demonstrationem mirabilem sane detexi. Hanc marginis exiguitas non caperet."]
Smerdyakov has quit ["Leaving"]
jcreigh has joined #ocaml
shekmalhen has joined #ocaml
<zvrba> ... what is the easiest way of enumerating strings "aaa" ... "zzz" ?
smimou has joined #ocaml
<zvrba> actually, not strings but a 3-element list of their ASCII representation (so, [97, 97, 97] ...)
tristram has joined #ocaml
jcreigh has quit ["Cuius rei demonstrationem mirabilem sane detexi. Hanc marginis exiguitas non caperet."]
shekmalhen has quit ["Nh eribve, fgv!"]
katana has quit [Nick collision from services.]
katana_ has joined #ocaml
finelemon has quit [Read error: 110 (Connection timed out)]
pango_ has quit [Remote closed the connection]
pango has joined #ocaml
ramkrsna has quit [Read error: 110 (Connection timed out)]
ramkrsna has joined #ocaml
love-pingoo has joined #ocaml
rillig has joined #ocaml
magnus-- has joined #ocaml
psed has joined #ocaml
<psed> hello
<magnus--> Hi
<psed> I'm looking for an equivalent of the LISP "let*"
<psed> this doesn't work in OCaml, since the first variable isn't bound yet:
<psed> let rec file = open_in_bin name and size = in_channel_length file in ...
<psed> err.without the "rec"
<psed> and *with* the rec, OCaml complains that the expression isn't allowed
<smimou> yes
<psed> why's that?
<smimou> without rec it's impossible since you cannot have terms with free variables
<psed> yes
<smimou> (I don't now if that's allowed in lisp)
<psed> no, no
<smimou> now with rec
<smimou> hum why don't you simply put size before and remove the rec ?
<psed> in lisp, "let" works just like in ocaml, but there's also a "let*" that allows you to define new variables using ones defined a line earlier
<magnus--> psed: Simply do this: let file = open ... in let size = in_channel ... in
<smimou> ah no
<psed> magnus--: okay, I know that works
<psed> magnus--: but why doesn't "let rec" work?
<magnus--> psed: I don't know.. I'm a relative newbie too :)
<psed> ok :)
<magnus--> and actually I have a question of my own
<magnus--> If I try to compile this code:
<magnus--> type foo = Foo of int * int
<magnus--> let bar (Foo pair) = pair
<magnus--> I get this error:
<magnus--> The constructor Foo expects 2 argument(s),
<magnus--> but is here applied to 1 argument(s)
<zmdkrbou> magnus--: let bar = function Foo pair -> pair
<psed> what are you trying to do?
<smimou> psed: I guess ocaml wants to avoid things like let rec f = g 0 and g x = f in ...
<smimou> so values with non-arrow types are forbidden
<psed> smimou: mutual recursion is perfectly allowed
<psed> ahm
<psed> "g x = f"?
<magnus--> zmdkrbou: Aha... that's odd that it works with function but not with let
<zmdkrbou> magnus--: the keyword function introduces pattern matching
<smimou> psed: actually you cannot compute a value for f or g
<pango> magnus--: try type foo = Foo of (int * int)
<zmdkrbou> in "let f a b c = ..." arguments a b and c cannot be patterns (this is not haskell)
<magnus--> pango: That works :)
<smimou> zmdkrbou: they can I think
<zmdkrbou> gni ?
* zmdkrbou tests
<smimou> the pb is that you can only match *one* pattern
<psed> zmdkrbou: I don't think you gave magnus-- the correct code
<smimou> magnus--: you can do let bar (Foo (x, y)) = (x, y) I think
<magnus--> I'll just introduce a match ... with
<zmdkrbou> psed: i think i did :)
<psed> magnus--: tell me what do you want to do, please
<psed> # let bar = function Foo pair -> pair;;
<psed> The constructor Foo expects 2 argument(s),
<psed> but is here applied to 1 argument(s)
<smimou> yes same problem
<zmdkrbou> psed: s/Foo pair/(Foo pair)/ yes
<psed> yes, because that's the wrong syntax
<smimou> the constructor Foo takes *two* arguments
<psed> # let bar = function (Foo pair) -> pair;;
<psed> The constructor Foo expects 2 argument(s),
<psed> but is here applied to 1 argument(s)
<smimou> no one couple
<zmdkrbou> grumpf
<smimou> not one couple
<psed> zmdkrbou: how about actually *testing* what you say?
* zmdkrbou slaps ocaml :)
<psed> :)
<smimou> it would work if you had declared foo with
<smimou> type foo = Foo of (int * int)
<psed> there's no need to change the type definition
<smimou> then it would take one argument which is a pair and not two argument
<smimou> s
<psed> # let bar = function (Foo (x, y) as p) -> p;;
<psed> val bar : foo -> foo = <fun>
<magnus--> psed: I'm doing a toy compiler, and I bumped into this slight annoyance
<psed> magnus--: use what I jus tpasted
<smimou> it's a quite dirty subtility of ocaml's syntax
<psed> :)
<psed> or no
<psed> oops
<psed> ;)
<smimou> no
<psed> # let bar = function Foo (x, y) -> (x, y);;
<psed> val bar : foo -> int * int = <fun>
<magnus--> psed: yup, that's what I'll use
<smimou> # let bar (Foo (x, y)) = (x, y);;
<zmdkrbou> (anyway a type foo = Foo int * int is just useless :p)
<smimou> val bar : foo -> int * int = <fun>
<magnus--> zmdkrbou: My actual type is much more useful, but I wanted to extract a minimal example
<psed> pango, oh, thanks ;)
<magnus--> thanks everyone!
<psed> pango, I'm just not sure why this kind of definition isn't allowed
<smimou> wasn't my counter-example satisfactory ?
<psed> smimou, your example is circular
<smimou> yes that's the point
<psed> but the common usage is linear
<psed> let a = 0 and b = a + 1 and c = b - 1 ...
<smimou> not the common usage of let rec
<psed> it's quite natural to define new values in terms of the previous ones
<pango> psed: just use let in for that
<zmdkrbou> let a = 0 in let b = a + 1 ...
<psed> ok
<pango> and is used for simultaneous definitions
<magnus--> psed: let .... and is like (labels ...)
<magnus--> if you speak common lisp
<psed> I know; I was looking for (let* ...)
<magnus--> let* is let ... in let ... in ... :)
<psed> yeah
<psed> suckage! :P
<magnus--> flet is also let.. in let ... in ...
<psed> is int32 the native machine 32-bit type?
<smimou> no
<smimou> it's nativeint
<smimou> ah sorry yes
<psed> so, on 32-bit machines int32 is the same as nativeint?
<smimou> yes exactly
<psed> thanks
<psed> is there a way to find out whether we're running on a little- or big-endian machine in OCaml?
<smimou> none that I'm aware of
<smimou> you shouldn't have to ask yourself those questions in caml
<psed> I know
<pango> it's available from the runtime, but the name currently escapes me...
<psed> and yet, I'd like to
<psed> are you aware of the ICFP contest? :)
<magnus--> are you writing the UM?
<psed> well, I already did ;)
<psed> I took 53. place with my friend
<zmdkrbou> you can't know that :)
<psed> well, as far as the frozen stats show ;)
<smimou> we wrote an UM in caml also and had to bind unsigned 32-bits arthmetic operations
* magnus-- 151th place, alone
<psed> I wrote a pretty quick UM in C
<smimou> ours was not so fast
<psed> I used OCaml in other puzzles
<psed> and I'm trying to port my UM to OCaml now, just for fun :)
<zmdkrbou> smimou: you mean slow :)
<magnus--> I did everything in C
<smimou> zmdkrbou: :p
<psed> and also to verify why exactly I'm getting more free_arrays than alloc_arrays :P
<magnus--> I tried first to write an UM in haskell but then I realized my folly
<psed> smimou: you had to bind them? what do you mean? import C functions?
<smimou> yes
<psed> I thought the int32 module would be sufficient?
<smimou> it uses signed operations unfortunately
<psed> ohhh...
<psed> right
<magnus--> Int64 might be useful for simulating unsinged 32 bit ops
<psed> if by "useful" you mean "even more slow" ;)
<smimou> niark
<zmdkrbou> and then you have to use modulo by hand
<psed> sigh
<psed> that was a really fun contest ;)
<magnus--> Int64.to_int32 does mod automatically
<magnus--> it just grabs the low 32 bits
<magnus--> psed: yeah I loved it :) I worked on BLACK mostly
<psed> a pity I didn't manage to finish my raytracer in time
<psed> I spent more than 24h on it :P
<magnus--> between social occations
<psed> the final 14h just porting from OCaml using a Nil/Inl/Inr/Pair type to 2D
<psed> I wish I wouldn't need to sleep :)
<magnus--> hehe
<magnus--> next time I need to form/find a team to join
<magnus--> this was too much for one person
<magnus--> or even two people
<psed> yeah...the top teams had many people
<psed> 10 people, even
<psed> like The Caml Riders
<smimou> well smartasses were only 4 I think...
<magnus--> but they are smartasses
<psed> PhDs? :P
<smimou> I've heard that they are working at google
<psed> PhDs. ;D
<smimou> heh
<psed> I'm just a lowly student ;P
<zmdkrbou> yep, smartass are from google and they are 4
<psed> nice.
<zmdkrbou> and i don't think the caml riders were actually 10 to participate :)
<pango> caml/config.h defines ARCH_BIG_ENDIAN on big endian platforms
<pango> and it's undefined otherwise
<psed> PLOP were 4, FUN were 5, CamlNuggets were 6
<psed> and the Riders were 10: http://www.lri.fr/~filliatr/icfp-2006/
<psed> pango, thank you
<zmdkrbou> yes but i was speaking of "actually participating" :)
<zmdkrbou> but i don't know
<psed> ah
<psed> me neither, then
<psed> anyway, this was the best contest I've ever taken part in
<psed> and I did my share of ACMs and olympics ;)
<smimou> yes, much more fun than past years
<psed> hacking into UMIX was just like a movie ;)
<psed> and yet much more real
slipstream has joined #ocaml
magnus-- has quit ["Leaving"]
slipstream-- has quit [Read error: 110 (Connection timed out)]
love-pingoo has quit ["Connection reset by pear"]
hikozaemon has quit ["Leaving..."]
<zvrba> anyone alive?
<zmdkrbou> yup
<zvrba> what's the preferred style of defining functions?
* zmdkrbou kills zvrba .oO( hin hin hin, i'm the only one left ! \o/ )
<zmdkrbou> let f x y = x + y
<zvrba> that vs. let f (x,y) = x + y
<zvrba> ?
<zmdkrbou> oh, it's curryfied vs. uncurryfied
<zvrba> yeah, so which one is preferred and why?
<zmdkrbou> f x y (aka curryfied) is better :)
<zvrba> heeh
<zvrba> :)
<zmdkrbou> it's better because you can do partial application
<zvrba> i understand that part
<zvrba> so why does sml standard library define many functions as uncurrified?
<zvrba> (nobody alive in #sml :P)
magnus- has joined #ocaml
<zmdkrbou> heh
* zmdkrbou won't say "because sml sucks"
<zmdkrbou> really, i don't know
<zvrba> some people wouldn't agree with you :P
<zmdkrbou> that sound strange
<zvrba> what?
<zmdkrbou> that they use uncurryfied versions
<zvrba> it seems that only higher-order functions are currified
<zvrba> taking the function as 1st argument and the rest as a tuple
<zvrba> which kinda makes sense to me..
<zmdkrbou> bof, depends on the function
falconair_ has joined #ocaml
<zmdkrbou> but i don't see the interest
<zvrba> a matter of style I guess
* zmdkrbou prefers full curryfied form for aesthetic reasons (and partial application reason)
<zvrba> ok, i got that part :P
<zvrba> :)
<zvrba> can you pattern-match on non-currified versions?
<zvrba> or you have to make smth. like match (x,y) with ...
<magnus-> I think curried functions are stupid
<magnus-> in the sense that they have a specific order of specialization as you apply arguments
<zmdkrbou> zvrba: you can only match one argument so yes, you have to group in a tuple
<zvrba> :)
<zmdkrbou> magnus-: man labels
<falconair_> i recently started looking at ocaml (i have mainly java background)....for some reason I can't find any thing about threads in ocaml...can any one help me out here
<magnus-> zmdkrbou: okay
<zmdkrbou> plus you can't do partial application in uncerryfied versions so "specialization" is meaningless
<zmdkrbou> falconair_: the most important thing to know about is : ocaml sucks at threading
<zvrba> zmdkrbou: i'm sure you can always define a lambda
<zmdkrbou> ?
<zvrba> zmdkrbou: and tumble function arguments as you like
<zvrba> anonymous functions
<zmdkrbou> so what ?
<zvrba> so nothing
* zmdkrbou doesn't get it, sorry
<zvrba> it's not like you "can't do" partial applications of non-currified functions
<zmdkrbou> oh, yep
<zmdkrbou> but doing partial application of uncurryfied functions is like taking the 1 times curryfied version and applying it to the rest of the args ...
<falconair_> zmdkrbou: would you happen to know if the same is true of F# ?
<zmdkrbou> beeeeurk F# :)
<zmdkrbou> i don't know anything about F# ...
<falconair_> crap, just how bad is concurrent stuff on ocaml? I was thinking of writing an app to process streaming data (like stock quotes)
<zmdkrbou> falconair_: but i hope for F# it has better threads support ... otherwise it's pure waste
<zmdkrbou> falconair_: there's is a *big* problem with concurrence and threads in ocaml
<zmdkrbou> you can use separate processes :)
<magnus-> falconair: I think SML and haskell are both better at concurrent stuff
<magnus-> tho don't quote me on that
<falconair_> haskell monads make me want to kill my self
<magnus-> falcon: agreed... so perhaps SML might work
<zmdkrbou> falconair_: you may try mlton, i think it would be much better for threads
<zmdkrbou> from what i heard
<zvrba> monads! :)
<falconair_> i was interested in ocaml, in part, because it is fairly popular and actually used by some financial houses...is mlton more than an academic lang?
* zvrba just reading on category theory :D
<zvrba> yes
<magnus-> mlton is an implementation of SML (Standard ML)
<magnus-> there's another implementation too called SML/NJ
<zvrba> and Poly/ML
<falconair_> zvrba: i tried understanding category theory too...i know functors and morphisms but i don't have a clue what they actually mean
<zvrba> and MoscowML
<zvrba> ...
<zvrba> falconair_: well, i just bought a decent book
<zvrba> it's nice abstraction
<falconair_> zvrba: i might have it :)
<falconair_> which one?
<zvrba> conceptual mathematics
<zmdkrbou> falconair_: mlton is more than an academic lang, it's aimed at being used in "real life" yes
<zmdkrbou> i would say ocaml is more academic
<zvrba> a first introduction to categories
<zvrba> and smerdyakov would say that ocaml is an ugly hack ontop of SML :)
<falconair_> zvrba: isn't that the one that is supposed to be for high school students?
<zmdkrbou> rhoo
<zmdkrbou> :)
<magnus-> falconair: mlton gives fast executables, SML/NJ is nice for development
<zvrba> falconair_: so... ?
<zvrba> it's nice as an introduction
<zvrba> gives you a background for more advanced stuff if you need it
<falconair_> nothing wrong with it, i guess despite a few attempts i'm apparently not motivated enough (in other words, too stoopid) :)
<zmdkrbou> hahah categories for high school students
<zmdkrbou> man, you have some great skilled schools there :)
<magnus-> which emacs mode is to prefer for ocaml?
<zmdkrbou> vim :)
<falconair_> i thought Pierce's Category Theory for Comp. Scientists is better...at least it gets to be point more quickly
<magnus-> tuareg or ocaml-mode?
<zvrba> falconair_: i got that one too
<smimou> tuareg
<magnus-> smimou: thanks
<zvrba> falconair_: i decided to leave it for later :P
<zvrba> falconair_: no use of getting quicker to the point if you don't understand the point :P
<zvrba> the 1st one is easy to read
<zvrba> many examples
<falconair_> but you find out more quickly if it is over your head :)
<zvrba> huh?
<zvrba> find out what? it's not that i'm in a hurry...
<falconair_> thanks dudes, looks google tells me that haskell has a nice thread library, so i'm off to #haskell
<zvrba> ... :P
<zvrba> good luck :D
<zvrba> are you sure you need threads?
<zvrba> List.map
<zvrba> (Word.fromInt o Option.valOf o Int.fromString)
<zvrba> (String.tokens (fn #"," => true | _ => false) line)
<zvrba> I *love* functional programming :D
Tekhne has quit [Remote closed the connection]
love-pingoo has joined #ocaml
psed has left #ocaml []
Smerdyakov has joined #ocaml
_jol_ has joined #ocaml
asbeta has joined #ocaml
_jol_ has quit ["leaving"]
pango has quit ["Leaving"]
pango has joined #ocaml
Revision17 has joined #ocaml
cmeme has quit ["Client terminated by server"]
cmeme has joined #ocaml
gim has joined #ocaml
sylvan has quit [Read error: 110 (Connection timed out)]
shekmalhen has joined #ocaml
_jol_ has joined #ocaml
smimou has quit [Read error: 110 (Connection timed out)]
katana__ has joined #ocaml
Revision17 has quit [Read error: 110 (Connection timed out)]
smimou has joined #ocaml
katana_ has quit [Read error: 110 (Connection timed out)]
rillig has quit ["exit(EXIT_SUCCESS)"]
pango has quit [Killed by Idoru. (Tor connects to freenode are temporarily blocked. Apologies for the inconvenience.)]
_JusSx_ has joined #ocaml
_jol_ has quit ["leaving"]
pango has joined #ocaml
sh3kmalhen has joined #ocaml
shekmalhen has quit [Nick collision from services.]
sh3kmalhen is now known as shekmalhen
sh3kmalhen has joined #ocaml
sh3kmalhen has quit [Remote closed the connection]
_JusSx_ has quit ["leaving"]
Revision17 has joined #ocaml
Nargg is now known as Norgg
jcreigh has joined #ocaml
joelr1 has joined #ocaml
<joelr1> good evening
<joelr1> what is the meaning of the tuple-like construct in data below?
<joelr1> type (’a, ’b) cap =
<joelr1> {
<joelr1> width : int;
<joelr1> height : int;
<joelr1> data : (’a, ’b, Bigarray.c layout) Bigarray.Array2.t
<joelr1> }
<pango> rather looks like a parametrized type
<joelr1> so a and b don't have anything to do with bigarray?
<joelr1> 'a and 'b
<pango> they parametrize Bigarray.clayout, like int is parametrizing int list
<joelr1> ok, thanks!
<joelr1> btw, does anyone have jon harrop's book "scientific ocaml"? what do you think of it?
love-pingoo has quit ["Connection reset by pear"]
joelr1 has quit []
jcreigh has quit ["Cuius rei demonstrationem mirabilem sane detexi. Hanc marginis exiguitas non caperet."]
Revision17 has quit [Read error: 104 (Connection reset by peer)]
Revision17 has joined #ocaml
smimou has quit ["bli"]
dark_light has joined #ocaml
gim has quit []