gildor changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.12.0+beta1 http://permalink.gmane.org/gmane.comp.lang.caml.inria/49168
mjonsson has joined #ocaml
philtor has quit [Ping timeout: 265 seconds]
aja has joined #ocaml
travisbrady has quit [Quit: travisbrady]
jakedouglas has quit [Quit: Leaving.]
jakedouglas has joined #ocaml
joewilliams_away is now known as joewilliams
sshc_ is now known as sshc
mfp has quit [Ping timeout: 265 seconds]
mfp has joined #ocaml
philtor has joined #ocaml
|marius| has quit [Remote host closed the connection]
elehack has quit [Quit: not a typewriter]
|marius| has joined #ocaml
joewilliams is now known as joewilliams_away
dark has joined #ocaml
<dark> how can i declare a tuple matching that bind both the tuple members and the tuple itself?
<dark> like let f (a, b) = a + b
<dark> invalid code, let f (pair = (a, b)) = g (a + b) pair
<dark> i mean, let f (a, b) binds the members
<dark> let f (a, b) = let pair = (a, b) in g (a + b) pair binds both, but not in the same matching
<|marius|> like so:
<|marius|> # let f ((a, b) as t) = (a, b, t)
<|marius|> ;;
<|marius|> val f : 'a * 'b -> 'a * 'b * ('a * 'b) = <fun>
<|marius|> # f (1, 2);;
<|marius|> - : int * int * (int * int) = (1, 2, (1, 2))
<|marius|> #
<dark> ah, it was "as"! yes, thanks =)
jakedouglas has quit [*.net *.split]
hcarty has quit [*.net *.split]
<dark> do i really need a method in order to retrieve each object's "val"?
<dark> it has been some time since i last touched ocaml.. http://caml.inria.fr/pub/docs/manual-ocaml/manual005.html seems to imply so
jakedouglas has joined #ocaml
hcarty has joined #ocaml
<dark> ps: i'm quite happy to see that let x = object method a = 1 end;; actually works
<dark> and thus class forms seems to be just a sugar for nice type display & constructor
<dark> type q = < a : int > let f () : q = object method a = 1 end
<dark> in fact this is valid code, wow :)
philtor has quit [Ping timeout: 260 seconds]
jakedouglas has quit [*.net *.split]
hcarty has quit [*.net *.split]
jakedouglas has joined #ocaml
hcarty has joined #ocaml
ulfdoz has joined #ocaml
|marius| has quit [Remote host closed the connection]
Tianon has quit [Ping timeout: 240 seconds]
|marius| has joined #ocaml
Tianon has joined #ocaml
Tianon has quit [Changing host]
Tianon has joined #ocaml
|marius| has quit [Remote host closed the connection]
Tianon has quit [Ping timeout: 260 seconds]
|marius| has joined #ocaml
mjonsson has quit [Ping timeout: 276 seconds]
Tianon has joined #ocaml
Tianon has quit [Changing host]
Tianon has joined #ocaml
ttamttam has joined #ocaml
ygrek has joined #ocaml
chee has quit [Ping timeout: 245 seconds]
philtor has joined #ocaml
ulfdoz has quit [Ping timeout: 276 seconds]
jakedouglas has quit [Quit: Leaving.]
ttamttam has quit [Quit: Leaving.]
Amorphous has quit [Ping timeout: 265 seconds]
Yoric has joined #ocaml
philtor has quit [Ping timeout: 246 seconds]
Associat0r has quit [Quit: Associat0r]
Amorphous has joined #ocaml
ttamttam has joined #ocaml
valross has quit [Quit: Ex-Chat]
ftrvxmtrx has quit [Quit: Leaving]
coucou747 has joined #ocaml
Yoric has quit [Quit: Yoric]
ygrek has quit [Ping timeout: 245 seconds]
ftrvxmtrx has joined #ocaml
Yoric has joined #ocaml
<ente> would it be hard for me to learn ocaml? I had one semester of SML at university and I liked it
<ente> but it had it's quirks, like andalso and + being for both +. and + (in ocaml) depending on the context
<ente> and defaulting to int
<ente> I assume you all know that :D
|marius| has quit [Remote host closed the connection]
<gildor> ente: coming from SML, I think it won't be a big problem to learn OCaml
<gildor> ente: start here http://www.ocaml-tutorial.org/
<ente> thanks
patronus has quit [Ping timeout: 240 seconds]
patronus has joined #ocaml
verte has joined #ocaml
Associat0r has joined #ocaml
<ente> thanks!
<ente> the second one looks really promising
metasyntax`` has joined #ocaml
th5 has joined #ocaml
metasyntax has quit [Ping timeout: 276 seconds]
avsm has joined #ocaml
ygrek has joined #ocaml
marteo has joined #ocaml
oriba has joined #ocaml
oriba has quit [Client Quit]
Tianon has quit [Ping timeout: 276 seconds]
despa has quit [Ping timeout: 252 seconds]
Tianon has joined #ocaml
Tianon has quit [Changing host]
Tianon has joined #ocaml
jamii has joined #ocaml
barismetin has joined #ocaml
Tianon has quit [Ping timeout: 260 seconds]
Tianon has joined #ocaml
Tianon has quit [Changing host]
Tianon has joined #ocaml
ztfw has joined #ocaml
dest has joined #ocaml
Anarchos has joined #ocaml
Yoric_ has joined #ocaml
metasyntax`` is now known as metasyntax
Yoric has quit [Ping timeout: 258 seconds]
Yoric_ is now known as Yoric
mjonsson has joined #ocaml
ente has quit [Quit: java]
aja has quit [Read error: Connection reset by peer]
verte has quit [Quit: ~~~ Crash in JIT!]
Vassia has joined #ocaml
Vassia has left #ocaml []
Vassia has joined #ocaml
Vassia has left #ocaml []
Vassia has joined #ocaml
Vassia has left #ocaml []
mjonsson has quit [Read error: Operation timed out]
sepp2k has joined #ocaml
sepp2k has quit [Remote host closed the connection]
<dark> http://caml.inria.fr/pub/docs/manual-camlp4/manual007.html is annoying at the mandatory [] for matches
joewilliams_away is now known as joewilliams
<dark> i would like some features of it in the regular syntax, such as \+ instead of (+)
<dark> list int instead of int list
<dark> "There is a syntax difference between data constructors with several parameters and data constructors with one parameter of type tuple." <- this is likely to be the most valuable feature of this revised syntax
<dark> i didn't liked do { } and the overuse of [], but the rest is fine. ;-;
<adrien> mandatory 'else ()' branches
<dark> i have mixed feelings
<dark> while i like brevity, i dislike the ending problems
<adrien> and a few others, like delimiting match clauses (or the whole thing, I can't remember)
<adrien> but I don't like everything in the revised syntax
<dark> i mean, it's annoying to have to write () sometimes..
<dark> but it's even more annoying to write [ ] all the time o.O
<dark> [] is ugly (well it doesn't need shift, but the whole idea of conciseness is to be beautiful for me, not to require less keystrokes)
<dark> while writing ocaml i most likely spend time thinking and not typing
<dark> but at least
<dark> the [ fills the space of the extra | in the beginning
<dark> it may work well..
<adrien> mandatory I'd like a middle ground in the syntaxes: one that would help catch errors but not change everything
<dark> i would like to change the type syntax
<dark> also i liked the x.val better than !x
<dark> in fact... it makes sense to write my own record with a val
<dark> and start using this convention
<rwmjones> yeah, !x seems to bother a lot of C programmers I know
<rwmjones> if !debug then printf "a debug message";
<avsm> once people get past the whole "let" hurdle, everything else seems minor :)
<adrien> well, I sometimes read it as "if not debug"
<f[x]> \+ is not in current camlp4r
<dark> in that syntax chart, how one would define a top level function?
<dark> value f x = .. ?
ygrek has quit [Ping timeout: 245 seconds]
<dark> i enjoy the overuse of let .-.
<_mpu> what is let _ = blah blah ?
<dark> _mpu, execs blah blah, then binds the result to nothing
<dark> _mpu, think about match blah blah with _ -> (), but without actually returning ()
<dark> (it's a statement, not expression.. unless there is a "in" after it)
<_mpu> I forgot the in
<_mpu> oops
<dark> _mpu, let can bind patterns like match
<_mpu> no I did not forget it :)
<dark> _mpu, like: let f (a, b as c) = a, b, c
_unK has joined #ocaml
<_mpu> it as a 'a * 'b -> 'a * 'b * ('a * 'b) function .
<_mpu> ?
<dark> _mpu, yes, what's the value of f (1, 2) :
<dark> ?
<_mpu> (1,2,(1,2))
<dark> a is 1, b is 2.. c is (a, b)
<dark> think about match (1, 2) with a, b as c -> a, b, c
<dark> returns the same thing, but binding with match, not let
<dark> _mpu, in fact, let _ = .. is used in lieu of C's int main() { }
<dark> because there are some syntatical problems into putting expressions straight at top level
<_mpu> that's in this context I've seen it
<dark> (the compiler needs some guessing sometimes, and it will not be available if you type print_int 9 in place of statements)
<dark> you would sometimes need ;;
<dark> or exemple, this will compile: let _ = print_int 9 let _ = print_int 9 (you could use ; but it's just an illustration)
<dark> suppose you want to turn the first let _ = print_int 9 into print_int 9
<dark> print_int 9 let _ = print_int 9 is a syntax error, you need ;;
<dark> print_int 9;; let _ = print_int 9 works
<dark> if all your top-level code is composed of statements, you can avoid this ugly ;;
<_mpu> a statement only triggers side effects while an expression evaluates to something
<_mpu> is that true ^
avsm has quit [Quit: Leaving.]
avsm has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
<gildor> are the some Lwt experts around?
<gildor> in Lwt_unix, some functions are missing like Unix.mkdir
<gildor> does it means I can use one directly from Unix.
<dark> <_mpu> a statement only triggers side effects while an expression evaluates to something
<dark> i don't quite understand this statement
<dark> of course side effects are achieved by evaluating expressions..but defining new names or types seems like a side effect to me, too
jakedouglas has joined #ocaml
<dark> anyway "side effect" is usually reserved for what expressions does besides returning a value
<hcarty> dark, _mpu: let () = ... is often a bit safer
<hcarty> than let _ = ... as that can accidentally hide mistakes
<dark> hcarty, so that you can ensure the expression return unit?
<hcarty> dark: Yes
<dark> it makes sense
<avsm> gildor: you have to be careful of exceptoins
<avsm> even if the call doesnt block, raising a direct exception (Unix_error) will cause all hell to break loose
<avsm> so it's best to bind it into Lwt_unix
<dark> what's lwt?
<avsm> light weight threading library
ttamttam has quit [Remote host closed the connection]
<hcarty> Which happens to come with a pretty cool enhanced toplevel
Yoric has quit [Quit: Yoric]
<gildor> avsm: ok for the exception, I already get this
<gildor> avsm: could you have a look at http://ocaml.pastebin.com/XiDePjij
<gildor> avsm: I tried to "lwt"-ify mkdir
<avsm> why not just bind mkdtemp(3)
<gildor> I can
<gildor> but I try to learn lwt right now
<avsm> that looks fine as long as mkdir doesnt block
<gildor> (and mkdtemp is BSD, which is not a big deal but nevertheless)
<gildor> If I want to prevent block, I can detach the computation ?
<avsm> the problem is that mkdir can block if the underlying filesystem blocks (e.g. nfs)
<avsm> but it doesnt really have a blocking/nonblocking option as it doesnt work on FDs
<avsm> so detaching it to a thread is the only safe way probably,but its very heavyweight
<avsm> i'm guessing this is why mkdir isnt already bound ;)
<gildor> avsm: just have a look in the ocaml source
<gildor> avsm: no use to detach
<gildor> there is not non-blocking sections
<gildor> so in this case, I must run an external process
<gildor> so I suppose, the solution I pick is ok
<avsm> thats horrible
<avsm> just call the syscall...
<avsm> a whole process just to mkdir is not great
<gildor> indeed
<avsm> traditionally, i guess disk-level blocking isnt considered blocking
<avsm> i wonder what pthread does if a single mkdir blocks on a stale nfs mount. probably just hangs everything
<gildor> I think that they consider FS metadata manipulation as non-blocking
<gildor> (after all creating a directory should be mostly metadata manipulation wrt as creating a file and its content)
<gildor> so the probability to block mkdir is << than to create a file
barismetin has quit [Remote host closed the connection]
travisbrady has joined #ocaml
avsm has quit [Quit: Leaving.]
qwr has joined #ocaml
barismetin has joined #ocaml
|marius| has joined #ocaml
barismetin has quit [Remote host closed the connection]
barismetin has joined #ocaml
ygrek has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
|marius| has quit [Remote host closed the connection]
nejimban has quit [Ping timeout: 240 seconds]
th5 has quit [Quit: th5]
nejimban has joined #ocaml
chee1 has joined #ocaml
chee1 has quit [Changing host]
chee1 has joined #ocaml
chee1 is now known as chee
joewilliams is now known as joewilliams_away
ygrek has quit [Ping timeout: 245 seconds]
Anarchos has joined #ocaml
ftrvxmtrx has joined #ocaml
barismetin has quit [Remote host closed the connection]
|marius| has joined #ocaml
|marius| has quit [Remote host closed the connection]
|marius| has joined #ocaml
|marius| has quit [Remote host closed the connection]
|marius| has joined #ocaml
philtor has joined #ocaml
sepp2k has joined #ocaml
philtor has quit [Ping timeout: 260 seconds]
joewilliams_away is now known as joewilliams
ygrek has joined #ocaml
<dark> if inside an object i can mark a variable mutable and do x <- x + y., why can't i mark a variable mutable outside an object?
<dark> and just do the same
<dark> i suppose this has something to do with the type system, but i can see completely
<dark> the thing is, if you return x, the caller can't do x <- y, because the caller does not know x is "mutable"
<dark> mutability is a concept kept only inside a class. maybe it simplify some analysis?
<dark> couldn't mutability be kept across the whole type system?
<dark> it seems that a function or method can't accept a mutable parameter and handle with its mutability
<dark> if they accepted, mutable int vs. int would be just like C++'s int vs. const int, and the compiler would need to do this analysis
<dark> so a method can change a mutable member, but this doesn't mess with the type system
<dark> because there is no "free" mutability created and returned, all mutability is "static"
<flux> dark, what's wrong with ref?
<dark> i think one could have the function let f x = x <- 1 with type mutable int -> void. and i could do print_int (let mutable x = 0 in f x; x + 2), it would print 3
<dark> flux, nothing, but if ref has nothing wrong, why to have mutable values in objects?
<flux> no idea
<dark> ... but if mutable values in objects are a win, why not to let you do high-order mutability with them?
<dark> i mean, pass a mutable to a function and handle mutability there
<flux> btw, also records allow for mutable fields
<dark> yes, but i can't pass x.contents to a function and expect it to be able to change it
<dark> i have to pass x
<flux> it might be that if ocaml were to have plain mutable values, they would nede to be handled similarly to 'ref'
<dark> btw bitC try to do this (having x itself mutable, and dealing with this with a more complex type system)
<flux> in other words, maybe minor heap is assumed to be immutable?
<dark> hmmm? this is a concept i don't understand
<dark> minor heap/
<flux> the things that make gc work
<dark> hmm
<dark> bitC is having problems with the type of functions like map, they explode in complexity for some tasks
<dark> but i don't know if this is related to this kind of mutability
ygrek has quit [Ping timeout: 245 seconds]
Yoric has joined #ocaml
<qwr> dark: i think that no mutable bindings is mostly for simplification of the language
<qwr> dark: it is possible to have them in a language with ml-like typesystem
<qwr> dark: although it makes the language "unclean" in some ways
<dark> yes it's what it seems to me
<dark> too
<qwr> dark: i think that what would basically change... let x = y in fun () -> y would be different from fun () -> x
<qwr> dark: as x might be reference, not just a binding
<dark> no, mutability would be preserved.. the only way for it to disappear is to be passed into a function that expects immutable values
<dark> i mean, if y is of type mutable int, both expressions would have type unit -> mutable int
<flux> dark, ocaml doesn't really have automatic coercions..
<qwr> dark: damn i messed the example up. let y = x in should have been there ;)
<flux> dark, would it be coerced or copied?
<dark> so, s/y/x/
<dark> coerced, i suppose. sometimes a generic type can be specified in a particular context, right?
<dark> mainly types with 'a, but there are similar rules for mutability
<qwr> dark: i meant, let y = x in in fun () -> y would be different from fun () -> x
<flux> qwr, in dark's model I understand they would be the same
<flux> unless you perhaps mean: let y : int = x in fun () -> y..
<qwr> flux: that's one unholy model ;)
<dark> basically you could do mutable int -> int automatically but not int -> mutable int
<flux> dark, that would be the first automatic cast in ocaml
<dark> so yes i think this is a coercion
<dark> hmm
<dark> but that's not what happens with type variables?
<qwr> dark: look at yeti, it has mutable variables
<dark> hm
<flux> dark, example?
<dark> flux, a function that receives 'a can receive int; a function that receives int can receive mutable int
<qwr> dark: but they don't have special types
<dark> so int is kind like a quantification, that also matches the mutable version
<dark> special types, qwr
<dark> ?
<flux> dark, it's not really a coercion in my mind. the function has no idea what it has received.
<flux> dark, how about: let f (a : int) (b : mutable int) = assert (b = a); b <- b + 1; assert (b = a + 1); in let a : mutable int = 5 in f a a ?
<qwr> dark: variable mutability isn't directly visible in yeti type-system
<dark> flux, interesting
<dark> flux, i suppose the compiler has to copy the first a
<qwr> dark: basically, it's property of the binding there, not property of the value
<dark> because f doesn't expect a to be mutable
<dark> qwr, hmm
<flux> dark, how would it know to do that?
<flux> dark, it might get both a and b from another, separately compiled, module
<dark> flux, in the degenerate case where you don't know i think you must copy
<flux> dark, or do you mean to do that always when coercing?
<qwr> dark: automatic coercions interact really bad with type inference
<dark> no, just when you can't prove it doesn't do anything wrong
<dark> you need some theorems to do the easy checks..
<dark> i saw some things on bitc mailing list about this: type inference + first class mutability
<dark> and this was their biggest problem
<dark> (something to do with "region analysis", but i haven't understood those things yet)
joewilliams is now known as joewilliams_away
<qwr> dark: say you have expression (a x)
<qwr> dark: where type of x may be coerced
<qwr> dark: now you but into function f x = a x;
<qwr> dark: what is the type of x and f ?
<qwr> dark: especially f, as inside of it the type of x is obviously 'a
<qwr> dark: and attempting to special-case it will end up in a gigantic hack, afaik
<qwr> dark: but you can mutable bindings without coercing anything and keep some sanity
<qwr> can have
dark has quit [Ping timeout: 265 seconds]
<qwr> only thing is, that there isn't really a need for those in ocaml. ref works as well.
ulfdoz has joined #ocaml
joewilliams_away is now known as joewilliams
dark has joined #ocaml
ygrek has joined #ocaml
ftrvxmtrx has quit [Ping timeout: 264 seconds]
dskippy has joined #ocaml
<dskippy> I am having a simple problem running an example from ocaml-shout. I installed ocaml-shout using apt get, and also got the source from savonet. Now I am trying to run the examples from the source and getting "Error: Unbound value Shout.init" This is my command line: ocaml /usr/lib/ocaml/shout/shout.cma examples/shoutfile.ml
<adrien> dskippy: you should do something like: ocamlfind ocamlc -packages shout examples/shoutfile.ml
<adrien> it'll create an executable (a.out)
ftrvxmtrx has joined #ocaml
<adrien> ocamlfind makes it easier to run/compile things (I think you're missing an '-I' entry on your command-line) and it's always a good idea to use it
<adrien> if absolutely need, you can use ocamlfind's "query" feature to get all the arguments if absolutely needed
<dskippy> adrien: Thanks, I'm going to try that. I'm really new to OCaml, especially compiling stuff. I might have a really uninformed question in two seconds.
dark has quit [Ping timeout: 265 seconds]
<dskippy> adrien: I did this and got the error shown. http://paste.pocoo.org/show/240568/
Yoric has quit [Quit: Yoric]
philtor has joined #ocaml
<adrien> hmmm, must be a typo or a small error in what I gave you but I don't have shout (yet) so I can't tell you right now
ulfdoz has quit [Ping timeout: 276 seconds]
<dskippy> But that's how you normally compile stuff that requires installed, compiled, shared libraries?
<dskippy> Kind of like pkg-config for C compilation?
<adrien> yup :-)
<adrien> well, I can't tell you so try: ocamlfind list | grep -i shout
<adrien> that'll give you the exact name of the package
dark has joined #ocaml
<adrien> and are you sure you have the '-dev' package on your system,
<adrien> ?
<dskippy> I have the dev package for sure.
<dskippy> That command gives me back "shout (version: 0.2.6)"
<adrien> no, stupid me: add '-linkpkg' when calling ocamlfind
<adrien> it's simply compiling and linking in one call, so you need -linkpkg
pheredhel has joined #ocaml
<dskippy> Oh that works, adrien, thank you!
<adrien> ^^
<adrien> btw, for more complex builds, there are "quite" automated systems like omake, ocamlbuild, ocamlmakefile and probably one or two I've forgotten
philtor has quit [Ping timeout: 246 seconds]
<dskippy> adrien: What are the majority of people using?
<dskippy> Do you have a favorite?
<adrien> (forgot to mention the regular configure+makefile+autotools)
<adrien> ocamlbuild is used more and more, among others it comes with ocaml
<adrien> omake is nice and works well but I haven't really used it
<adrien> ocamlmakefile is a big makefile for which you set a few variables and does the rest "automatically"
<adrien> (it's possible to easily figure out dependencies between files/modules when compiling ocaml, and these three take advantage of that)
<dskippy> Awesome. Thanks so much. I'll look into using one of them.
<adrien> :-)
<dskippy> Do you, or anyone, have an recommendations for books or web sites on learning OCaml for someone who's programmed a long time, knows Scheme, Haskell, Lisp, Python, C, etc, and is about to write a large project in OCaml?
<dskippy> (hypothetically speaking of course. :) )
Yoric has joined #ocaml
<dark> there is some excellent book at caml.inria.fr
<dark> there is a section on "resources
<dark> there, there is the manual, the library reference, and books
<dark> also tutorials
<dark> dskippy, there are a tutorial aimed for java/c++/c programmers at ocaml-tutorial.org
<dskippy> Cool. Thanks.
<dark> but it's rather basic
dark has quit [Ping timeout: 265 seconds]
Yoric has quit [Quit: Yoric]
sepp2k has quit [Quit: Leaving.]
jakedouglas has quit [Quit: Leaving.]
ygrek has quit [Ping timeout: 245 seconds]
Anarchos has quit [Ping timeout: 252 seconds]
Yoric has joined #ocaml
valross has joined #ocaml
Yoric has quit [Client Quit]
dskippy has quit [Quit: Leaving.]
valross has quit [Remote host closed the connection]
dark has joined #ocaml
jakedouglas has joined #ocaml
philtor has joined #ocaml
philtor has quit [Ping timeout: 240 seconds]
valross has joined #ocaml
marteo has quit [Quit: Debian GNU/Hurd is Good.]
jakedouglas has quit [Quit: Leaving.]
jakedouglas has joined #ocaml
liftM has joined #ocaml
<liftM> Am I right that physical equality (==) is always translated by the ocaml compiler into a single pointer comparison?
<dark> # [1, 2] == [1, 2];;
<dark> - : bool = false
<dark> liftM, looks like
<qwr> dark: its because you construct list here
<dark> i mean, it looks like it's just a pointer comparison
<qwr> dark: for primitive types it behavies the same as = afaik
<dark> hmm
<qwr> e1 == e2 tests for physical equality of e1 and e2. On integers and characters, physical equality is identical to structural equality. On mutable structures, e1 == e2 is true if and only if physical modification of e1 also affects e2. On non-mutable structures, the behavior of (==) is implementation-dependent; however, it is guaranteed that e1 == e2 implies compare e1 e2 = 0.
<qwr> (from the doc)
<dark> so he asked what the current implementation effectively does
<dark> i think
<dark> but the "always" maybe means "required by the specs" so i think it's no, it's implementation-dependent
<qwr> i think the compiler probably implements it using pointer value comparision...
mjonsson has joined #ocaml