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
<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?
<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_>
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?
<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_>
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.
<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
<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.