Alpounet changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | 3.11.1 out now! Get yours from http://caml.inria.fr/ocaml/release.html
onigiri has quit []
mbishop_ has joined #ocaml
r0bby has joined #ocaml
Alpounet has quit [Read error: 60 (Operation timed out)]
tmaeda is now known as tmaedaZ
ulfdoz_ has joined #ocaml
mbishop has quit [Read error: 113 (No route to host)]
mbishop has joined #ocaml
mbishop_ has quit [No route to host]
ulfdoz has quit [Read error: 110 (Connection timed out)]
ulfdoz_ is now known as ulfdoz
<NYNix> :q!
NYNix has quit ["leaving"]
NYNix has joined #ocaml
Amorphous has quit [Connection timed out]
Amorphous has joined #ocaml
tmaedaZ is now known as tmaeda
seanmcl has quit []
seanmcl has joined #ocaml
<NYNix> gpg
NYNix has quit ["leaving"]
seanmcl has quit []
caligula__ has joined #ocaml
caligula_ has quit [Read error: 110 (Connection timed out)]
jeddhaberstro has quit [Client Quit]
thrasibule has joined #ocaml
nnyby has quit ["leaving"]
tarbo2 has quit [Connection timed out]
slash_ has quit [Client Quit]
verte has joined #ocaml
verte is now known as verte-work
thrasibule has quit [Read error: 110 (Connection timed out)]
tarbo2 has joined #ocaml
verte-work has quit ["~~~ Crash in JIT!"]
ski_ has joined #ocaml
f[x] has joined #ocaml
_zack has joined #ocaml
ttamttam has joined #ocaml
kaustuv_ has joined #ocaml
verte has joined #ocaml
kaustuv_` has quit [Read error: 110 (Connection timed out)]
_zack has quit ["Leaving."]
munga has joined #ocaml
_zack has joined #ocaml
ikaros has joined #ocaml
|Jedai| has joined #ocaml
Jedai has quit [Read error: 110 (Connection timed out)]
rwmjones has quit [Read error: 113 (No route to host)]
subito has joined #ocaml
ikaros has quit ["Leave the magic to Houdini"]
ikaros has joined #ocaml
rwmjones has joined #ocaml
ikaros has quit ["Leave the magic to Houdini"]
ikaros has joined #ocaml
headspin has joined #ocaml
<headspin> Hi, how can I create a record that is defined in another file/module? For tFunction = {name:string; ...} in one file and {"bla";...} in another file doesnt work. using tuples instead works... what am I doing wrong?
Modius has quit [Read error: 104 (Connection reset by peer)]
Modius has joined #ocaml
<headspin> working example with tuples: tFunction = string * .... and in the other file ("bla",...)
<headspin> oh, the initialization of records is of couse {name="bla"; ...}. help me ;)
<headspin> idling all day eh?
<flux> { ModuleName.name = "bar" }
<Camarade_Tux> (you only need to specify ModuleName once per record btw)
valross has joined #ocaml
rwmjones is now known as rwmjones__
rjones has joined #ocaml
rjones is now known as rwmjones
tmaeda is now known as tmaedaZ
verte has quit [Read error: 148 (No route to host)]
<headspin> thx ;)
subito has quit [Remote closed the connection]
<headspin> it's me again ;). how is indirect recursion handled in ocaml? google didnt help. if to functions call each other, how do i tell ocaml that the second exists, when it processes the first one? "let rec" doesnt help here, and i didnt find a way to "declare" the function...
<headspin> s/to/two
<rwmjones> headspin, let rec ... and ...
<rwmjones> let rec f1 x = ... and f2 x = ...
<headspin> thank you very much :)
julm_ has joined #ocaml
<rwmjones> on the other hand, you can't define two functions some distance apart and make them mutually recursive.
<rwmjones> the only way to do that is to have a reference to one of the functions
<rwmjones> like ...
<rwmjones> let f = ref None
<rwmjones> let g x = (* something involving !f *)
<flux> rwmjones, well, you can, if the functions take the recursion function as a parameter
<rwmjones> f := fun ....
<rwmjones> f := Some (fun ...)
<rwmjones> yeah, that too
<rwmjones> I use the reference method coz it's easier to get my imperative head around :-)
munga has quit [Read error: 113 (No route to host)]
headspin has quit ["Page closed"]
julm has quit [Read error: 110 (Connection timed out)]
rwmjones has quit ["This computer has gone to sleep"]
rwmjones__ is now known as rwmjones
<det> I imagine the red and parameter methods are much slower than using and
<det> ref*
verte has joined #ocaml
<thelema> det: that sounds like a job for mr. stopwatch
<det> As requested
<det> for odd/even test
<det> program is 2.5x slower with ref
<det> and 4x slower with passing function as param
<det> test cases there
<flux> ..did you notice, how many times you needed to do the test to find the difference?
<det> Yeah, it depends on what you are doing of course
<det> most of the time it wont matter
<flux> I needed to reduce the number of iterations so it would compile
<flux> (32-bit)
<flux> but I got numbers like 0.9/1.2/2.8
<det> I would have expected a larger gap between the first 2
<flux> talking about ocamlopt obviously, I assume so were you
<det> yes
<det> 0.9/1.2 seems really unlikely to me
<det> are you sure about those numbers?
<flux> ./foo 0.94s user 0.00s system 97% cpu 0.970 total
<flux> ./foo 1.16s user 0.00s system 97% cpu 1.191 total
<flux> if is_even 1000067296 then ..
<det> strange that ref does so much better on your computer
<flux> heh, I tried it on an older Xeon we have around
<flux> ./foo 3,56s user 0,00s system 100% cpu 3,558 total
<thelema> wow, you must have a fast computer - I'm getting 5s, 9.8s, 16.1s
<flux> ./foo 3,55s user 0,01s system 100% cpu 3,557 total
<flux> thelema, as I said, I needed to adjust the number of iterations
<flux> thelema, because of 31-bit signed integer..
<thelema> ah. I'm using a 64-bit machine, so...
<flux> maybe cache and GC play some role here?
<flux> although, it's a very short program
<flux> and I suppose not much allocation, if any, is happening..
<thelema> probably not much - what allocation makes it into the major heap?
<flux> in any case I find it interesting that the older machine I get, the smaller the gap :)
<flux> the last case is the worst of the bunch continuously, though
<flux> too bad the optimizer doesn't see (?!) through higher order functions
<thelema> the optimizer is pretty literal, but I thought it miht be able to inline the last one into the first one
<det> I guess known vs unknown function calls have a larger gap on modern computers
<thelema> it might just be measuring 4 billion dereferences
<thelema> closures are definitely more expensive than plain functions to call
ikaros has quit ["Leave the magic to Houdini"]
<thelema> in other news, gdb now has reverse debugging (I assume like ocaml)
f[x] has quit [Read error: 110 (Connection timed out)]
tmaedaZ is now known as tmaeda
Alpounet has joined #ocaml
hjpark has joined #ocaml
<hjpark> how to convert char -> string ?
hjpark has left #ocaml []
<flux> String.make 1
valross has quit [Remote closed the connection]
hkBst has joined #ocaml
* rwmjones finishes the semi-annual update to all the fedora ocaml packages ... http://cocan.org/fedora
hkBst has quit [Remote closed the connection]
<Alpounet> wow good work rwmjones
verte_ has joined #ocaml
verte has quit [Nick collision from services.]
verte_ is now known as verte
hkBst has joined #ocaml
verte has quit [Read error: 145 (Connection timed out)]
Ched has quit [Remote closed the connection]
_andre has joined #ocaml
Ched has joined #ocaml
_andre has quit ["leaving"]
julm_ is now known as julm
<hcarty> The (somewhat) new release candidate for Lwt looks very interesting
<hcarty> Parallel processing pieces, toplevel updates, Glib/Gtk integration. I'm impressed.
* Camarade_Tux heard glib/gtk? :P
<hcarty> Camarade_Tux: :-) http://ocsigen.org/lwt/install
<hcarty> See the Changelog on the right for 2.0.0
ski_ has quit ["Lost terminal"]
<hcarty> And here for a short example: http://ocsigen.org/darcsweb/?r=lwt;a=headblob;f=/examples/ex_gtk.ml
<rwmjones> is there any documentation on FRP in plain terms?
* rwmjones is trying to understand http://erratique.ch/software/react/doc/React
<hcarty> rwmjones: I've used React a bit with Gtk
<hcarty> lablgtk2 that is
<Camarade_Tux> hcarty: thanks, I hadn't really looked at lwt before and it looks really nice :)
<rwmjones> hcarty how?
<hcarty> After being inspired by the FrGui project from Jane St's 2007 projects.
<Camarade_Tux> (btw, sleeping helped me go further in ocaml-gir)
<hcarty> rwmjones: My most recent use was for glorified mutability
<hcarty> rwmjones: A plot output window which would automatically adjust based on signals from other inputs (mouse clicks, resize the window, etc)
<hcarty> rwmjones: It's useful for sending signals between widgets, so that, for example, the slider can tell the text box and the Cairo widgets to update based on its value
<hcarty> rwmjones: You can do this without FRP/React, but I've found the FRP approach to be cleaner
<rwmjones> I'm failing to understand the basics at the moment
<hcarty> My (very) limited understanding is that it's kind of like hiding a variable in a function ... "let x () = 1" rather than "let x = 1"
<hcarty> But there is more magic going on ... 1 is mutable or somesuch.
<hcarty> So any call to "x ()" may set off a chain of other events, which result in the proper value of x being returned
<hcarty> I'm sure I'm not using the terminology correctly as my experience with FRP is entirely as a user and not a theorist.
<Camarade_Tux> core 0.6.0 with readline support, hmmm
<hcarty> Camarade_Tux: core? Jane St. core?
<Camarade_Tux> hcarty: check your inbox ;)
<hcarty> Is readline the hip new thing in OCaml-land?? :-)
<Camarade_Tux> it sounds really weird to see an ocaml library with readline support :P
<Camarade_Tux> leaving, I need a to find a place where I can have internet access on linux so I can git push...
<rwmjones> hcarty, do you have any example code using react / lablgtk etc?
onigiri has joined #ocaml
<hcarty> rwmjones: It's an example, but not the cleanest - http://0ok.org/cgit/cgit.cgi/gtk-light/tree/toplevel.ml
<hcarty> rwmjones: the React module is expected to be open'd here
willb has quit [Read error: 110 (Connection timed out)]
Associat0r has joined #ocaml
<hcarty> rwmjones: This is the simplest example I found useful when trying to figure out how to use/apply FRP: http://codepad.org/SXfjuBjx
<rwmjones> cheers, I'll take a look
<hcarty> And this is what sparked my interest in the first place: http://lambda-the-ultimate.org/node/1918
<palomer> hcarty, that's pretty cool
<hcarty> The LTU one uses some camlp4 magic, but it's pretty cool even without it.
<hcarty> palomer: Which one? I agree on both :-)
<hcarty> palomer: Chris King did some very interesting work.
<palomer> your little codepad example
<palomer> how does FRP help us with GUI signals?
<hcarty> palomer: Yes, I've found it to be very useful in GUIs in particular. I haven't had a need for it elsewhere.
<hcarty> palomer: I think the results of stringing multiple GUI elements together with FRP is cleaner than without.
<hcarty> In my specific experience, of course.
seanmcl has joined #ocaml
<palomer> but...what does it help with, exactly?
ikaros has joined #ocaml
<kaustuv_> anyone play with the new Core yet?
* Camarade_Tux wonders if using lablwebkit+labldbus+lablgtk+react+lwt altogether is a good idea :P
Hadaka has quit [Remote closed the connection]
<palomer> add OSET!
<Camarade_Tux> hahaha ^^
<kaustuv_> playing katamari damashi with ocaml libs can be injurious to your health
Hadaka has joined #ocaml
<Alpounet> Camarade_Tux, yeah, it'd ease the installation of your browser obviously :D
willb has joined #ocaml
ttamttam has quit ["Leaving."]
willy-n has joined #ocaml
<willy-n> hi
<willy-n> i used ocaml-mode with emacs, i have the colorated syntax, but i don't know how to execute the code
<willy-n> somebody know that with emacs?
* thelema uses tuareg - maybe it's the same
<thelema> C-c C-s
<thelema> and then C-c C-b
<hcarty> palomer: Making the code cleaner and easier to follow? I'm not sure how else to say it.
<hcarty> palomer: I'm not deep enough in to the library/libraries or the theory behind them to give a better response yet.
<willy-n> C-c C-b is undefined
<willy-n> C-c C-s open a buffer with ocaml
<willy-n> where is the list of all the command in mode?
<hcarty> Camarade_Tux: For a project which requires/benefits from webkit, dbus, gtk, threading and FRP it probably is a good thing.
<thelema> willy-n: try C-c C-h
<hcarty> Camarade_Tux: Thought it would likely be a _better_ thing if some support modules were involved to make everyone play nicely together :-)
hkBst has quit [Connection reset by peer]
<willy-n> he said C-c DEL is undefined
<thelema> willy-n: you have some terminal setting problems
<willy-n> ah?
<willy-n> and how i fix this?
<thelema> this might help: http://www.cs.cmu.edu/cgi-bin/info2www?(emacs)DEL Does Not Delete
<palomer> hcarty, but in which aspect? signals? deciding the size of the widgets?
<willy-n> uhm, i just installed emacs and ocaml-mode
<willy-n> and ocmal in gentoo distribution
<willy-n> at the faculty, we use kate
<willy-n> but i don't like kde
<thelema> are you using x11 version of ocaml?
<thelema> err, x11 version of emacs
<willy-n> no
<thelema> what terminal are you using?
<willy-n> xterm
<thelema> try gnome-terminal (or rxvt) or use the x11 version of emacs - that's the easiest way to solve this.
<willy-n> uhm
<willy-n> x11 emacs is xemacs?
<thelema> no, xemacs is a different project.
<thelema> gnu emacs runs in a terminal and it also runs directly in X
<hcarty> palomer: Both. I've used it for propagating signals between widgets, which then determine the size/zoom/etc.
<thelema> does anyone have a nice suggestion of a data structure to represent a partition of the integers 1..n?
<thelema> Maybe I should just go with a pair of arrays
<kaustuv_> thelema: discrete interval encoding trees
<thelema> kaustuv_: I have an implementation of DIET for sets and maps, but neither is really a partition
<kaustuv_> OK, so what is a partition?
<thelema> kaustuv_: I want to quickly find what other elements are in a partition of a particular element
<thelema> err, the same partition as a particular element
<kaustuv_> use a union-find structure?
<thelema> and I'll have to split partitions a lot
<kaustuv_> how big is n?
Associat0r has quit []
<thelema> probably less than 5000
<thelema> although I'm not really sure. I'm implementing DFA minimization
<kaustuv_> just use lists or arrays or whatever then.
<thelema> thanks for the pointer to disjoint-sets
<willy-n> is not to easy to use emacs
<kaustuv_> ocaml will traverse a 5k element list in basically no time. As long as you avoid copying it, partitioning is the same as storing a mutable field in the elements of the list with a partition id
<kaustuv_> of course if you want persistence that's a different issue
<thelema> so the cost of traversing the list to find elements in the same partition is trivial?
<thelema> wow - the second time today I find a reference to the inverse ackermann function, which I've never expected a use for before
kaustuv_ has quit [Read error: 60 (Operation timed out)]
kaustuv_ has joined #ocaml
ttamttam has joined #ocaml
<kaustuv_> I am considering writing an ocaml binding for: https://projects.coin-or.org/Osi
<kaustuv_> Is it feasible to write bindings for libraries written in C++?
<thelema> kaustuv_: my inderstanding is that you have to go through C
<kaustuv_> Yes, the stubs will be in C, but are there other surprises in store?
<thelema> I've never done it before, but I'd expect that if your stubs were any good, no.
<willy-n> pff
<willy-n> i don't want to install gnome-terminal just for that
<willy-n> i merge rxvt, the output are the same
<thelema> hmm... I expected rxvt to correctly handle DEL BS and C-h
<thelema> well, try merging the x11 build of emacs (if you don't have it already)
<willy-n> rxvt said "No module found for entry nil" for C-c C-h
f[x] has joined #ocaml
<thelema> were you in ocaml mode at the time?
Modius has quit [Read error: 60 (Operation timed out)]
<willy-n> yes
<willy-n> in down of buffer i have (caml)
<thelema> got me - C-c C-h produces a list of keybindings that start with C-c
albacker has joined #ocaml
_zack has quit ["Leaving."]
<willy-n> yes
<willy-n> me too
<willy-n> if i m on the objective caml buffer
<willy-n> pfiou
<willy-n> is not easy emacs
<thelema> is new. Everything new is hard until it becomes not new.
<willy-n> :)
<willy-n> and now
<willy-n> i want to send my .ml i ve wrote on emacs to this buffer
<flux> I'd suggest installing tuareg-mode, atleast it cas C-c C-b built in :), among nicer (IMO) indentation and colorization
<willy-n> uhm ok
<willy-n> veni vidi vici
<willy-n> tuareg works fine
<willy-n> i use it now
<willy-n> thanks
Hadaka has quit [Remote closed the connection]
<willy-n> have we a reset command for ocaml buffer?
<willy-n> or we must closed the buffer and restart it
<kaustuv_> C-c C-k C-c C-s enter
<thelema> usually you don't need to reset - later definitions shadow earlier ones.
<willy-n> ok
<flux> if you've used #load for your own files, you may need to reset
<flux> but otherwise, not really
<willy-n> and for clear the buffer?
<thelema> there are many ways to go wrong not-resetting
<willy-n> blank the buffer ?
<thelema> willy-n: what kaustuv_ said
<kaustuv_> C-l C-l on a modern emacs will put the current line at the top, which is as good as clearing
<kaustuv_> better in fact because you don't accidentally clear useful stuff
<willy-n> ah ok
<willy-n> on the editing buffer
<willy-n> pfiou
* thelema didn't realize that multiple C-l's did anything
<willy-n> level up
<willy-n> lol
Hadaka has joined #ocaml
Narrenschiff has joined #ocaml
_zack has joined #ocaml
<willy-n> uhm
<willy-n> ocaml is used in other domain than the studying?
<willy-n> for professional work?
<thelema> heh
<thelema> yes
<willy-n> where?
<thelema> the financial world has multiple uses for OCaml.
<thelema> Microsoft uses it to verify properties of device drivers for certification
<thelema> And it's found homes in various scientific communities.
tmaeda is now known as tmaedaZ
Hadaka has quit [Remote closed the connection]
Hadaka has joined #ocaml
<albacker> you should put an article with ocaml usages since everyone that comes here asks it. i did! and i've seen others doing it. you can /topic the article :D
<thelema> albacker: that sounds like a good project for a newer member of the community - researching and writing about different uses of ocaml
Hadaka has quit [Remote closed the connection]
ched_ has joined #ocaml
Ched has quit [Read error: 113 (No route to host)]
Ched has joined #ocaml
ched_ has quit [Read error: 113 (No route to host)]
Hadaka has joined #ocaml
Hadaka has quit [Remote closed the connection]
Submarine has joined #ocaml
dodek_ has joined #ocaml
gareth__ has joined #ocaml
<gareth__> hello, can you recommend a *physical* ocaml book? I have already got/mostly-read "the little mler"
<kaustuv_> gareth__: are you OK with PDFs that you can print?
<gareth__> kaustuv_, afraid not
<kaustuv_> gareth__: too bad, because http://www.cs.caltech.edu/courses/cs134/cs134b/book.pdf is really good
ulfdoz has quit ["brb"]
<gareth__> i might have to buy an ebook reader...
<hcarty> A second to kaustuv_'s recommendation. That's an excellent book.
<palomer> hcarty, so let's say a widget changes size, then the whole widget structure needs to be updated, right?
<hcarty> palomer: I used it, for example, to tie a slider to a map (Cairo canvas drawn with PLplot). The slider affects how the map zooms in and out.
<kaustuv_> gareth__: know any ebook readers that can run ocaml?
<kaustuv_> (I ask only half jokingly)
* palomer will probably get into reactive programming
<palomer> looks like fun
<gareth__> heh, i guess if you hack them enough....
<gareth__> really i want one to read digital words on though
_zack has quit [Read error: 104 (Connection reset by peer)]
ulfdoz has joined #ocaml
<dodek_> i find it annoying that you can't use type constuctor as function
<dodek_> for instance, i have card type
<palomer> can reactive programming help with user input?
<dodek_> of suit * rank
<kaustuv_> when you say "can't", do you mean "can't easily"?
<dodek_> yeah, can't easily
<dodek_> i need to redefine constuctor as function
<dodek_> under different name
<dodek_> should i go on with example or there is no need for you to hear it?
<kaustuv_> I used to be bothered by it until I did an analysis of my main piece of code (about 35k lines of ocaml) and there were less than a dozen cases where having constructors be functions would have made the code any better
<kaustuv_> Unsurprisingly, all of them were in a parser written in a combinatorial style
<kaustuv_> For what it's worth, I think the difference between Foo of int * int and Foo of (int * int) is an ugly wart with very questionable performance-based justification
<dodek_> how's that different? i'm fairly new to ocaml.
<kaustuv_> The former is a binary constructor, the latter a unary constructor whose argument is a pair
Narrenschiff has quit []
<kaustuv_> The difference is that the latter has one extra "box" if you know what that is.
<kaustuv_> The reason I bring it up is that this is the main technical reason why there is no canonical way to treat OCaml data constructors as functions.
<seanmcl> I can think of lots of places having constructors be functions is nice
<seanmcl> foldl All [x, y, z] f
<seanmcl> if you have formulas data Form = True | False | All Var Form | ...
<hcarty> palomer: The LTU example I linked uses FRP for input
* kaustuv_ waves at seanmcl
<dodek_> it doesn't matter if i use foo * bar or (foo * bar)
<dodek_> i need to provide tuple as an argument anyway
<dodek_> i think i'm missing something.
<hcarty> dodek_: It matters when pattern matching
<dodek_> oh that's unusual
<seanmcl> kaustuv: how do you wave. I just started irc recently :)
<hcarty> dodek_: "type t = A of int * int match A (1, 2) with A x -> ..." won't work
<seanmcl> I'm addicted to haskell's irc channel
<hcarty> dodek_: "type t = A of (int * int) match A (1, 2) with A x -> ..." will work
<dodek_> seanmcl: regarding that code - i just wanted to do something similar
<dodek_> hcarty: that's interesting
<dodek_> now i wonder why it doesn't matter when constructing but matters when matching.
Hadaka has joined #ocaml
<seanmcl> dodek: you can't curry constructors like you can in Haskell
<seanmcl> you probably know that htough
<hcarty> dodek_: I ran up against this recently. And the error message isn't very helpful when you don't understand the float * float vs (float * float) distinction.
<dodek_> seanmcl: i know, and i'm very unhappy because of that.
<dodek_> talking about haskell, is there in ocaml something resembling [1..n] from haskell?
<kaustuv_> seanmcl: I would say the difference between fold_left (fun e x -> All(x, e)) l and fold_left (flip o All) l is rather minor, and the former is even clearer
<seanmcl> dodek: no
<hcarty> dodek_: Batteries has ( -- )
<dodek_> Batteries? what's that?
chahibi_ has joined #ocaml
chahibi has quit [Connection reset by peer]
<hcarty> A super-duper library for OCaml
<hcarty> Now with Bells _and_ Whistes.
<seanmcl> kaustuv: yeah, with the flip (that I missed) you're probably right
<dodek_> :)
<hcarty> Whistles that is.
<seanmcl> I just find that so ugly
<dodek_> i guess i need to read about it
<hcarty> It's a very nice stdlib supplement/replacement
<dodek_> too bad i can't use it in my current problem
<kaustuv_> well, I got it wrong too. It's All o flip, not flip o All.
<kaustuv_> Or maybe not. Who knows.
<seanmcl> kaustuv: do you seriously prefer ocaml syntax?
<kaustuv_> No, I like SML's over OCaml's. I like ML more than Haskell, though.
<seanmcl> I prefer not having enormous space leaks when I do stupdid things in haskell
<seanmcl> but the syntax seems far superior to me
<seanmcl> what don't you like about haskell?
<seanmcl> (syntax)
<seanmcl> I've heard lots of Haskell bashing rants, but syntax has never been included
<kaustuv_> Well, this is probably offtopic here, but I like to read files from top to bottom. Haskellers have an annoying tendency of writing functions first and datatypes much later
<kaustuv_> This also extends to their preference for where. I prefer let ... in to where.
<kaustuv_> I also miss being able to say: let x = f(x) in ...
<seanmcl> I rather like putting unimporatant functions later in the file, though I see your point. I haven't seen people putting types after the functions that operate on them. You must have been reading some weird Haskell code :)
<seanmcl> why can't you say that?
<kaustuv_> Much of the Haskell standard library is written that way
<seanmcl> I miss local
<kaustuv_> because it's lazy, and creates a cyclic structure
<seanmcl> oh, I see
<kaustuv_> It's basically SML's let rec x = f(x)
<kaustuv_> (err, let val rec x = f(x) ... haven't written SML in a while, as you can tell)
<seanmcl> yeah, i prefer that part of ocaml to sml. having fun be recursive by default is annoying sometimes
<seanmcl> name shadowing is bad I've come to think, so I don't miss that very much
<seanmcl> local types/values, exceptions, those I miss
<seanmcl> what's your 35k of code?
<kaustuv_> It's a system that translates TLA (a temporal logic) proof scripts into proof obligations for Isabelle, Zenon, SMT solvers, DPs etc. There will be a release announcement soon.
<kaustuv_> I think explicit shadowing is quite beneficial in catching silly mistakes, not to mention gives a good hint to the GC that the old binding can be trashed
<kaustuv_> And I see no rhyme or reason for this being cyclic in Haskell: do { x <- x ; return 42 }
<seanmcl> I guess just so you can write ones = 1 : ones
<kaustuv_> Yes, I think I would prefer a strict variant of Haskell. Purity is great. Laziness is an annoyance when you don't want it. Explicit laziness please.
jeddhaberstro has joined #ocaml
<seanmcl> since do { x <- x; return 42 } = x >>= \x -> return 42, you seem to be right
<seanmcl> that doesn't make sense to me
<seanmcl> I read a blog post by norman ramsey who said it took him 5 years to appreciate default laziness, and now he swears by it.
<seanmcl> I wrote this program this morning
<seanmcl> index n i (x:xs) = i `seq` if x == n then i else index n (i+1) xs
<seanmcl> it ate 2GB of memory in 5 seconds when the element was not in an infinite list
<seanmcl> oh
<seanmcl> ndex n i (x:xs) = if x == n then i else index n (i+1) xs
<seanmcl> without the seq it kills you
<kaustuv_> I believe (but correct me) in modern Haskell compilers you can avoid inserting `seq`s by using bang patterns
<seanmcl> seems like you can often avoid them
<seanmcl> and -O2 figures out almost all of the places you forgot
<kaustuv_> but it might require magic pragmas
<seanmcl> yeah, it's a little scary writing big programs
<seanmcl> but at least there are a lot of tools to play with
<seanmcl> to find your space bugs
<kaustuv_> Oh speaking of tools, why on earth does Haskell not do exhaustiveness checking on pattern matches? Why is that a whole different tool?
<seanmcl> It does
<dodek_> List.map obviously does not work for strings. what equivalent do you suggest?
<seanmcl> you have to turn the warning on
<seanmcl> you have to implode/explode
<seanmcl> and use map
<kaustuv_> String.map
<seanmcl> There's also probably a string library
<kaustuv_> oh wait, String.map is in extlib. Sorry.
<seanmcl> not sure what you mean, 'a whole different tool'
<dodek_> i haven't found in stdlib anything interesting
<dodek_> except of iter, which does not accumulate the result
<seanmcl> one reason they turn some warnings off is to use view patterns
<seanmcl> the compiler can't figure out if they overlap
<seanmcl> at least, not right now
<kaustuv_> dodek_: I would recommend using extlib at least, or one of the other extended standard library packages
<dodek_> kaustuv_: i'm afraid this isn't possible
<dodek_> i'm writing a program for contest
<kaustuv_> seanmcl: I was thinking of http://community.haskell.org/~ndm/catch/ but apparently that does quite a bit more than simples structural reasoning
<dodek_> and they do not allow external libraries.
<seanmcl> Can't you use Array.map
<seanmcl> since strings are mutable arrays in ocaml
<seanmcl> ?
<kaustuv_> No, strings and arrays are not the same. They even have different tags
<dodek_> oh, are they? i'm used to think of strings as lists of characters
<seanmcl> but strings are mutable. An annoying hole in the HOL Light type system
<seanmcl> so I figured they must be arrays
<kaustuv_> Yes, but array elements are always 1 word long. Strings are much more compact.
<dodek_> This expression has type string but is here used with type 'a array
<seanmcl> yeah, I'm wrong
<seanmcl> dodek, you can just write what you want using String.get. Annoying, but if you don't want another stdlib, seems like the only way
<dodek_> so, how can i coerce string to the list of characters?
<seanmcl> you can walk over it and use string.get
<seanmcl> basically an imperative loop
<kaustuv_> let smap f s = let ss = String.create (String.length s) in for i = 0 to String.length s - 1 do ss.[i] <- f s.[i] done ; ss ;;
<kaustuv_>
<dodek_> i thought there would be nicer way to do it, but...
<kaustuv_> (not thread-safe)
<dodek_> hm. now i recall it needs to accumulate results into a list
<kaustuv_> The OCaml standard library is almost the bare minimum required to write an OCaml compiler. It is unreasonable to expect people to use only the stdlib for anything serioues.
albacker has quit ["Leaving"]
ttamttam has quit ["Leaving."]
<kaustuv_> Hmm, I guess I was wrong about x <- x being cyclic in Haskell. I seem to recall some weirdness about shadowing in do notation, but I no long remember the details.
Submarine has quit ["Leaving"]
julm has quit ["oodo"]
<willy-n> thanks for all
willy-n has quit ["Leaving"]
<dodek_> what am i doing wrong here?
<kaustuv_> dodek_: <- is only applicable to strings, arrays and mutable record fields. In your case I would suggest: let result = ref [] in for ... do result := f s.[i] :: !result done ; result
<dodek_> what's ref [] ?
<kaustuv_> ref : 'a -> 'a ref creates a reference, and ( := ) : 'a ref -> 'a -> unit updates a reference
<dodek_> oh, they're like pointers
<dodek_> and ! is like dereferencing
<kaustuv_> yes, except without pointer arithmetic. So more like Java references.
<dodek_> i fixed my code, thanks.
<dodek_> i don't really know much about java :)
<kaustuv_> well, if you grok pointers already, you'll have no trouble with refs
<dodek_> pointers are fun.
<dodek_> i call a function in interactive mode and it throws an exception. how can i print a backtrace?
<hcarty> dodek_: As far as I know, it's not possible. The toplevel does not produce debug symbols.
<hcarty> dodek_: There is a patch to enable this though.
<hcarty> dodek_: You may be able to catch the exception and print the backtrace, but I don't think that would work here. Recent OCaml versions added support from printing backtraces from within a running OCaml program but I haven't used that functionality.
<dodek_> that's a shame.
gareth__ has quit [Remote closed the connection]
gareth__ has joined #ocaml
<hcarty> It certainly is
<hcarty> http://skydeck.com/blog/programming/more-stack-traces-in-ocaml -- this talks about the patch if you're interested
<hcarty> I haven't used it
<kaustuv_> Back traces have limited utility in a language with tail call elimination. I can't explain this remark because I am off to catch a train.
f[x] has quit [Read error: 110 (Connection timed out)]
<hcarty> I have found the back traces in OCaml to be very useful.
gareth__ has quit [Remote closed the connection]
ikaros has quit ["Leave the magic to Houdini"]
<dodek_> but still they're useful. i can tell it from my experience in lisp.
<dodek_> anyway, i need to get some sleep.
Nutssh has joined #ocaml
dodek_ has quit ["leaving"]
willb has quit [Read error: 110 (Connection timed out)]
thrasibule has joined #ocaml