gildor changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml Meeting 2011 http://bit.ly/eaZi1C | OCaml 3.12.0 http://bit.ly/aNZBUp
andreas1 has joined #ocaml
andreas has quit [Ping timeout: 250 seconds]
zubeen has joined #ocaml
lamawithonel_ has joined #ocaml
lamawithonel has quit [Ping timeout: 260 seconds]
joewilliams is now known as joewilliams_away
Associat0r has joined #ocaml
elehack has joined #ocaml
alexgordon is now known as agordonfreeman
raphscallion has joined #ocaml
elehack has quit [Quit: Farewell, programs.]
smerz has quit [Remote host closed the connection]
agordonfreeman is now known as alexgordon
lopex has quit []
mfp has quit [Ping timeout: 246 seconds]
arubin has joined #ocaml
wtetzner has quit [Remote host closed the connection]
mfp has joined #ocaml
Associat0r has quit [Quit: Associat0r]
Transformer has joined #ocaml
Transformer has quit [Excess Flood]
boscop has joined #ocaml
wtetzner has joined #ocaml
raphscallion has quit [Quit: raphscallion]
eye-scuzzy has joined #ocaml
ymasory has quit [Quit: Leaving]
philtor has quit [Ping timeout: 240 seconds]
Amorphous has quit [Ping timeout: 240 seconds]
Amorphous has joined #ocaml
ulfdoz has joined #ocaml
arubin has quit [Quit: arubin]
hto_ has joined #ocaml
hto has quit [Ping timeout: 240 seconds]
mneedham has joined #ocaml
eelte has quit [Ping timeout: 240 seconds]
Associat0r has joined #ocaml
ygrek has joined #ocaml
myu2 has quit [Remote host closed the connection]
mneedham has quit [Ping timeout: 260 seconds]
mneedham has joined #ocaml
joelr has joined #ocaml
ygrek has quit [Ping timeout: 246 seconds]
Yoric has joined #ocaml
zubeen has quit []
Skolem has joined #ocaml
<Skolem> I'm having trouble figuring out the syntax for 'open'. I expect this one-line program (open Int64 print_endline "K") to print "K" when I run it with "ocaml test.ml", but instead I get ``File "test.ml", line 1, characters 11-24: Error: Syntax error'' What am I doing wrong?
hto_ has quit [Ping timeout: 240 seconds]
ikaros has joined #ocaml
joelr has quit [Quit: joelr]
joelr has joined #ocaml
joelr has quit [Client Quit]
<adrien> Skolem: try: 'open Int64;; print_endline "K"'
<adrien> or
<adrien> 'open Int64' 'let () = print_endline "K"'
<adrien> (I can't explain the rules properly early in the morning however)
<flux> but I can!
<flux> skolem, a file consists of parts of code, which are separated with ;;
<flux> skolem, each part is either an expression or a list of statements
<flux> (make it parts=blocks and it sounds better)
<flux> we should have an infobot here. xavierbot could do.
<flux> (xavierbot with persistency)
impy has quit [Ping timeout: 250 seconds]
ocp has joined #ocaml
Associat0r has quit [Quit: Associat0r]
coucou747 has joined #ocaml
eikke has joined #ocaml
ikaros has quit [Quit: Leave the magic to Houdini]
caligula has quit [Ping timeout: 240 seconds]
caligula has joined #ocaml
gildor has quit [Quit: leaving]
explodus has quit [Ping timeout: 276 seconds]
coucou747 has quit [Ping timeout: 260 seconds]
explodus has joined #ocaml
thomasga has joined #ocaml
jamii has joined #ocaml
raphscallion has joined #ocaml
larhat has joined #ocaml
hto has joined #ocaml
andreas1 has quit [Ping timeout: 250 seconds]
kaustuv_afk is now known as kaustuv
Snark has joined #ocaml
mfp has quit [Ping timeout: 240 seconds]
eelte has joined #ocaml
raphscallion has quit [Remote host closed the connection]
raphscallion has joined #ocaml
mfp has joined #ocaml
avsm has joined #ocaml
edwin has joined #ocaml
gildor has joined #ocaml
jamii has quit [Ping timeout: 276 seconds]
eelte has quit [Read error: Operation timed out]
jamii has joined #ocaml
andreas has joined #ocaml
Yoric has quit [Quit: Yoric]
f[x] has quit [Ping timeout: 252 seconds]
f[x] has joined #ocaml
zorun has quit [Ping timeout: 240 seconds]
avysk has joined #ocaml
ulfdoz_ has joined #ocaml
ulfdoz has quit [Ping timeout: 248 seconds]
ulfdoz_ is now known as ulfdoz
ygrek has joined #ocaml
lopex has joined #ocaml
_andre has joined #ocaml
roconnor has joined #ocaml
<roconnor> Question about value recursion in ocaml...
<roconnor> I'm trying to write a function to convert lists into doubly linked lists:
<roconnor> type 'a dlist = Dnil | Dnode of 'a dlist *'a *'a dlist;;
<roconnor> let listToDList l = let rec go l h = match l with [] -> Dnil | (x::xs) -> let rec r = Dnode (h,x,go xs r) in r in go l Dnil;;
<roconnor> However I get an error at "let rec r = Dnode (h,x,go xs r) in r" saying
avsm has quit [Quit: Leaving.]
<roconnor> Error: This kind of expression is not allowed as right-hand side of `let rec'
<roconnor> Is it possible to write a function to convert lists into doubly linked lists?
<rixed> roconnor: "let rec r = Dnode (h,x,go xs r)" in what order is this supposed to be evaluated? all parameters to go are supposed to be evaluated before the call to go, yet you need the result of go to build r :-/
<roconnor> ah of course ...
<ocp> roconnor: either you use lazy somewhere, or you have to create a mutable record somewhere
* roconnor tries to figure out how to use lazy around r
<roconnor> let rec r = Dnode (force h,x,go xs (lazy r)) in r still is an error :(
<roconnor> in
<roconnor> let listToDList l = let rec go l h = match l with [] -> Dnil | (x::xs) -> let rec r = Dnode (force h,x,go xs (lazy r)) in r in go l (lazy Dnil);;
<rixed> ocaml
<rixed> ^ was destined to another term :)
<rixed> roconnor: with "type 'a dlist = Dnil | Dnode of 'a dlist *'a *'a dlist Lazy.t;;", ...
<rixed> ...this parse allright: "let listToDList l = let rec go l h = match l with [] -> Dnil | (x::xs) -> let rec r = Dnode (h,x,lazy (go xs r)) in r in go l Dnil;;"
<rixed> note that you will have to force the third value of a Dnode.
<rixed> roconnor: I don't think this is suitable as a doubly linked list, though...
ygrek has quit [Ping timeout: 246 seconds]
sku has joined #ocaml
<roconnor> rixed: hmm. I'm not sure I like the Lazy in the data types.
raphscallion has quit [Ping timeout: 276 seconds]
jderque has joined #ocaml
jamii has quit [Ping timeout: 260 seconds]
Modius has quit [Ping timeout: 276 seconds]
jamii has joined #ocaml
ikaros has joined #ocaml
jamii has quit [Ping timeout: 276 seconds]
Modius has joined #ocaml
edwin has quit [Ping timeout: 250 seconds]
hto has quit [Ping timeout: 250 seconds]
jamii has joined #ocaml
<iris1> Dear experts, I've run into a puzzling problem with ocaml. I would be grateful if you could provide any insight into it. I am trying to get a backtrace for a program that exits via an uncaught exception at the bottom of a chain of function calls. I discovered the Printexc module (via Stack Overflow) and crafted a test program using the record_backtrace and print_backtrace functions in there. However, I find that this only gives me the func
<iris1> raising the exception (and the catching it), but not the intermediate ones. I would like to be able to see all the intermediate function calls in the stack trace (as is the case in most other programming languages I know). What am I doing wrong? Here is the paste of exactly what I am doing: http://pastebin.com/7cJUcuNh (this is ocaml 3.11.2 on OS X Snow Leopard 10.6.6). Thank you!
<flux> iris1, one possibility: are your functions in tail call positions?
<flux> iris1, that results in tail call optimization being invoked, and such functions disappear from the back trace
<iris1> yes they are
eye-scuzzy has quit [Quit: leaving]
fraggle_laptop has joined #ocaml
<rproust> iris1: manual solution: catch exception, print backtrace and reraise exception (so that calling function receives it too)
edwin has joined #ocaml
<iris1> flux, rproust, thank you very much! I modified my test program to remove the TC optimization from the intermediate function and it did indeed show up in the stack trace
<iris1> this will do the job for me; in my program most of the functions cannot be TC optimized away, so the stack trace should be informative enough
<iris1> I don't suppose there is any way for the stack trace to show the arguments that functions received ??
el-out_y has joined #ocaml
ymasory has joined #ocaml
<rproust> iris1: manual solution (I don't know of any automatic solution) in all your functions catch exceptions and pretty print function name + arguments. Then reraise exception to obtain a backtrace
<rproust> this is tedious and hard to maintain
hto has joined #ocaml
Yoric has joined #ocaml
<iris1> rproust: I agree. In your opinion, would it be possible to write a higher-order function to take care of this? e.g., (print_arguments_on_exceptions f) would do the same as f but would also catch & rethrow exceptions while pretty-printing the arguments. This would require the print_arguments_on_exceptions to determine the argument list of f, to dispatch on types, etc. Is it possible / easy to do this kind of reflection in ocaml?
<flux> not really. you would at least need to have different versions for different arities.
<flux> for printing, you could use for example ExtLib/Batteries Std.dump
<rproust> you can have with_pretty_print_arg1: ('a -> 'b) -> ('a -> string) -> 'a -> 'b
<rproust> and as flux metionned you need another version for arity two, three, etc.
<rproust> alternatively you can use dump or Show
<rproust> with Show, it would be possible to have with
<rproust> with_pp_exc_1 : ('a -> 'b) -> 'a -> 'b
<rproust> and another for different arities
<rproust> ho… you would need the function name/line number as an extra argument… the higher order function can't guess that…
<rproust> all this could be automated via camlp4 I guess.
<iris1> what is Show?
<rproust> it's a typeclass in deriving
<iris1> looks like a module name, but it does not show up on google (or at least my google skillz are not up to this challenge)
<iris1> can you give me a URL to the doc?
<rproust> and the doc is here https://code.google.com/p/deriving/w/list
ymasory has quit [Quit: Leaving]
<iris1> Thanks! It's nice to see this in ocaml. I thought type classes were some Haskell-only nicety :-)
<rproust> well it's not excatly type classes
<rproust> it's sortof similar
<iris1> flux, rproust: Thank you for the advice about print_arguments_on_exceptions! Splitting it up by arity may be fine. Perhaps I'll try to do this one day.
f[x] has quit [Read error: Connection timed out]
f[x] has joined #ocaml
fraggle_laptop has quit [Ping timeout: 240 seconds]
Yoric has quit [Quit: Yoric]
Oejet has joined #ocaml
Yoric has joined #ocaml
myu2 has joined #ocaml
Yoric has quit [Client Quit]
sku has quit [Ping timeout: 246 seconds]
myu2 has quit [Remote host closed the connection]
jamii has quit [Ping timeout: 240 seconds]
<el-out_y> hi
<el-out_y> do someone know how to link a code with ocamlsdl?
dnolen has joined #ocaml
robinnn has joined #ocaml
jamii has joined #ocaml
<robinnn> hi
<robinnn> i need tutoriel for ocamlsdl
eikke has quit [Ping timeout: 240 seconds]
<adrien> iirc it's very close to the C api so the C tutorials are a good reference
<adrien> you also http://wiki.njh.eu/OCaml_and_SDL#testsdl_1_-_Hello.2C_World.21 for instance
jamii has quit [Ping timeout: 240 seconds]
el-out_y has quit [Quit: Lost terminal]
eikke has joined #ocaml
Modius has quit [Ping timeout: 260 seconds]
dnolen has quit [Quit: dnolen]
Modius has joined #ocaml
Tianon has quit [Ping timeout: 260 seconds]
dnolen has joined #ocaml
dnolen has quit [Client Quit]
pdhborges has joined #ocaml
eye-scuzzy has joined #ocaml
Skolem has quit [Quit: Connection reset by pear]
<robinnn> i have a problem for open image
<robinnn> win ocamlsdl
<robinnn> with
<robinnn> Fatal error: exception Sdlloader.SDLloader_exception("Couldn't open woot.jpeg")
<robinnn> ??
philtor has joined #ocaml
jamii has joined #ocaml
<pdhborges> maybe the image file is not where you think it is robinnn?
<flux> or perhaps you are missing some sdl image loader library
DimitryKakadu has joined #ocaml
Oejet has left #ocaml []
<robinnn> how resolve that Fatal error: exception Sdlmixer.SDLmixer_exception("Module format not recognized")
<robinnn> ??
lopex has quit []
larhat has quit [Quit: Leaving.]
ymasory has joined #ocaml
Yoric has joined #ocaml
eikke has quit [Ping timeout: 252 seconds]
impy has joined #ocaml
eikke has joined #ocaml
Tianon has joined #ocaml
Tianon has quit [Changing host]
Tianon has joined #ocaml
eikke has quit [Ping timeout: 248 seconds]
roconnor has quit [Remote host closed the connection]
<hcarty> robinnn: What raises the exception?
<hcarty> It sounds like the program is trying to load a format which is not supported by SDL
joewilliams_away is now known as joewilliams
lopex has joined #ocaml
ocp has quit [Ping timeout: 240 seconds]
_habnabit has joined #ocaml
<_habnabit> Is List.length an O(1) operation or an O(n) operation?
<flux> O(n)
<_habnabit> Ah okay.
<flux> the list is defined similarly as: type 'a list = EmptyList | Element of ('a * 'a list)
<flux> so while in principle one could always keep count of the list size (and sublist size), most of the time it would just be wasted cpu and memory
<flux> I think I actually had the very same question when beginning my ocaml programming ;)
<pdhborges> but then
<pdhborges> each elemento would take 64 more bits
<_habnabit> http://paste.pound-python.org/show/5797/ <- I could write this simpler if I called List.length in the loop, but then I get an O(n^2) algorithm. ;(
<flux> true
<flux> well, not sure how much simpler it would be after all
<adrien> looks alright to me, but you could also remove the "let _, l' = .* in l'" and use "snd (List.fold_left ...)"
<orbitz> Why not just stor List.length and subtract 1?
<adrien> (but I find fst/snd make the code less readable)
<_habnabit> let rev_enumerate = List.fold_left (fun accum, x -> (List.length accum, x) :: accum) []
<_habnabit> Seems simpler toe.
<_habnabit> tome
eikke has joined #ocaml
<flux> well, batteries List.mapi solves the same problem without List.length
<flux> of course it may already provide that particular function as well :)
<orbitz> In my Seq library it'd be: let rev_enumerate l = let length = List.length l in Seq.map ~f:(fun (idx, e) -> (l - idx, e)) $ Seq.enumerate l
ymasory has quit [Read error: Connection reset by peer]
f[x] has quit [Ping timeout: 250 seconds]
<pdhborges> _habnabit: drop the simplicity :P http://paste.pocoo.org/show/379128/
<_habnabit> pdhborges, hm? That's basically my original implementation
<_habnabit> pdhborges, except I used List.fold_left
f[x] has joined #ocaml
ymasory has joined #ocaml
andreas has quit [Ping timeout: 276 seconds]
jderque_ has joined #ocaml
pdhborges has quit [Quit: Leaving.]
Tobu_ has quit [Read error: Connection reset by peer]
Tobu has joined #ocaml
andreas has joined #ocaml
jderque has quit [Quit: Leaving.]
jderque_ is now known as jderque
roconnor has joined #ocaml
<roconnor> I think I got it to work
<roconnor> type 'a dlist = Dnil | Dnode of 'a dlist *'a *'a dlist;;
<roconnor> let listToDlist l = let rec go l = match l with [] -> None | (x::xs) -> Some (x,match go xs with None -> Dnil | Some (y,ys) -> let rec r = Dnode (r, y, ys) in r) in match go l with None -> Dnil | Some (y,ys) -> Dnode (Dnil, y, ys);;
<roconnor> heh, not very elegant, but a good first start maybe
_habnabit has left #ocaml []
<roconnor> oops, it is broken :(
Associat0r has joined #ocaml
* roconnor goes back to the drawing board
<adrien> that looks like a looong function, would be better to split it
<roconnor> heh ya
<roconnor> but it is totally wrong anyways
<roconnor> Exception: CamlinternalLazy.Undefined.
* roconnor sighs
andreas has quit [Ping timeout: 248 seconds]
thomasga has quit [Quit: Leaving.]
andreas has joined #ocaml
<Associat0r> do people use this? http://people.csail.mit.edu/mikelin/ocaml+twt/
<adrien> I don't, but I know some do
wagle has quit [Read error: Connection reset by peer]
<Associat0r> adrien: so it's popular?
<adrien> I don't know if its use is very widespread but I know some people use it, I don't have any numbers
<Associat0r> ok
<Associat0r> adrien: and they didn't have any problems with it?
<Associat0r> also with the newest OCaml releases?
smerz has joined #ocaml
<adrien> are you getting an error message?
<Associat0r> I didn't try it yet
<adrien> last release isn't old, I think it'll probably work with recent versions of ocaml
<adrien> worth a try
alexgordon is now known as alexgordon|
wagle has joined #ocaml
lamawithonel_ has quit [Read error: Connection reset by peer]
pdhborges has joined #ocaml
Modius has quit [Ping timeout: 250 seconds]
andreas has quit [Ping timeout: 250 seconds]
sepp2k has joined #ocaml
enthymeme has joined #ocaml
<kerneis> Associat0r: it might be hard to combine with other extensions
<kerneis> (like those used in ocsigen, for instance)
<kerneis> but you should be fine if you stick with twt only
Modius has joined #ocaml
andreas has joined #ocaml
alexgordon| is now known as alexgordon
jamii has quit [Ping timeout: 240 seconds]
lopex has quit [Ping timeout: 246 seconds]
mbac has joined #ocaml
lopex has joined #ocaml
hto has quit [Ping timeout: 250 seconds]
enthymeme has quit [Ping timeout: 240 seconds]
hto has joined #ocaml
avsm has joined #ocaml
ygrek has joined #ocaml
mcclurmc_home has joined #ocaml
avsm has quit [Quit: Leaving.]
caligula_ has joined #ocaml
caligula has quit [Ping timeout: 260 seconds]
mneedham has quit [Ping timeout: 248 seconds]
lamawithonel has joined #ocaml
ocp has joined #ocaml
lamawithonel has quit [Remote host closed the connection]
ymasory has quit [Quit: Leaving]
mneedham has joined #ocaml
Snark has quit [Quit: Ex-Chat]
pdhborges has left #ocaml []
raphscallion has joined #ocaml
avsm has joined #ocaml
robinnn has quit [Quit: Lost terminal]
_andre has quit [Quit: leaving]
ygrek has quit [Ping timeout: 246 seconds]
ymasory has joined #ocaml
jderque has quit [Quit: leaving]
Yoric has quit [Quit: Yoric]
DimitryKakadu has quit [Remote host closed the connection]
pdhborges has joined #ocaml
zorun has joined #ocaml
ikaros has quit [Read error: Operation timed out]
yroeht_ has quit [Ping timeout: 240 seconds]
ikaros has joined #ocaml
yroeht has joined #ocaml
zorun_ has joined #ocaml
alexgordon is now known as alexgordon|
mneedham has quit [Ping timeout: 276 seconds]
mneedham has joined #ocaml
mneedham_ has joined #ocaml
mcclurmc_home has quit [Ping timeout: 250 seconds]
mneedham has quit [Ping timeout: 258 seconds]
mneedham_ is now known as mneedham
joewilliams is now known as joewilliams_away
raphscallion has quit [Quit: raphscallion]
alexgordon| is now known as alexgordon
mneedham has quit [Ping timeout: 246 seconds]
sheets has joined #ocaml
joewilliams_away is now known as joewilliams
thieusoai has joined #ocaml
ymasory has quit [Quit: Leaving]
raphscallion has joined #ocaml
ocp has quit [Ping timeout: 260 seconds]
lamawithonel has joined #ocaml
lamawithonel has quit [Remote host closed the connection]
andreas has quit [Quit: Leaving.]
ulfdoz has quit [Ping timeout: 260 seconds]
edwin has quit [Remote host closed the connection]
raphscallion has quit [Quit: raphscallion]
Associat0r has quit [Quit: Associat0r]
raphscallion has joined #ocaml
raphscallion has quit [Quit: raphscallion]
jonafan_ has joined #ocaml
jonafan has quit [Ping timeout: 260 seconds]
mnabil has joined #ocaml
Fullma has quit [Quit: Fullma]
pdhborges has quit [Remote host closed the connection]
pdhborges has joined #ocaml
Amorphous has quit [Ping timeout: 250 seconds]
pdhborges has quit [Remote host closed the connection]
pdhborges has joined #ocaml
pdhborges has left #ocaml []
raphscallion has joined #ocaml
Amorphous has joined #ocaml
joewilliams is now known as joewilliams_away
eikke has quit [Ping timeout: 240 seconds]
ikaros has quit [Quit: Leave the magic to Houdini]
dnolen has joined #ocaml
lopex has quit [Ping timeout: 240 seconds]
joewilliams_away is now known as joewilliams
lopex has joined #ocaml
raphscallion has quit [Quit: raphscallion]
raphscallion has joined #ocaml
lopex has quit []