ulfdoz has quit [Read error: 110 (Connection timed out)]
ikaros_ has quit ["Leave the magic to Houdini"]
Narrenschiff has quit [Read error: 110 (Connection timed out)]
Narrenschiff_ is now known as Narrenschiff
Alpounet has joined #ocaml
alp_ has quit [Read error: 104 (Connection reset by peer)]
Pimm has quit [Read error: 110 (Connection timed out)]
joewilliams has joined #ocaml
tmaedaZ is now known as tmaeda0
Narrenschiff has quit []
joewilliams has quit [Read error: 113 (No route to host)]
Associat0r has quit []
ofaurax has quit ["Leaving"]
ski_ has quit ["Lost terminal"]
slash_ has joined #ocaml
johnnowak has joined #ocaml
jeddhaberstro has joined #ocaml
jeddhaberstro has quit [Client Quit]
r2q2 has joined #ocaml
_unK has quit [Remote closed the connection]
tar_ has joined #ocaml
r2q2 has quit [Remote closed the connection]
eldragon has left #ocaml []
slash_ has quit [Client Quit]
johnnowak has quit []
ski_ has joined #ocaml
ygrek has joined #ocaml
ttamttam has joined #ocaml
ttamttam has quit ["Leaving."]
struktured has quit [Read error: 110 (Connection timed out)]
_zack has joined #ocaml
jcaose_ has joined #ocaml
Associat0r has joined #ocaml
zhijie has quit [Remote closed the connection]
itewsh has joined #ocaml
ulfdoz has joined #ocaml
tar_ has quit []
<olegfink>
hmm, should `ocamlc -where` be in ld's -L path when it is called by ocaml?
Pimm has joined #ocaml
<olegfink>
ah *whoops*
Narrenschiff has joined #ocaml
jcaose has joined #ocaml
munga has joined #ocaml
<Camarade_Tux>
thelema: on the other hand, you still want a global file to enable profiling ;p
jcaose_ has quit [Read error: 110 (Connection timed out)]
Vince has joined #ocaml
Vince has quit [Remote closed the connection]
tar_ has joined #ocaml
<Camarade_Tux>
anyone used lablgtk2 with threading? I get a constant, non-zero CPU usage for the following program: "let () = GtkThread.main ()", linking only against threads and lablgtk2
<Camarade_Tux>
moreover, if I try to profile it, it raises an exception (Unix.select)
<EliasAmaral>
what says the exception? every unix system call have a specific error code when it fails
tmaeda0 is now known as tmaedaZ
<Camarade_Tux>
it's not very verbose: Fatal error: exception Unix.Unix_error(11, "select", "")
<Camarade_Tux>
but profiling seems to work for bytecode
<Camarade_Tux>
or that ocamlbuild doesn't handle profiling in bytecode
ttamttam has joined #ocaml
<olegfink>
Camarade_Tux: 11 is EINTR
<Camarade_Tux>
olegfink: oh, right, I think I'm increasingly blind, I didn't even see '11' ><
<olegfink>
strange that is shows as 11
<olegfink>
# (Obj.magic 11 : Unix.error) ;;
<olegfink>
- : Unix.error = Unix.EINTR
<EliasAmaral>
well, if you got this error, you have to call the function again
<mrvn>
The number doesn't represent unix errno though. That is just the order of constructors in the Unix module.
<EliasAmaral>
but not on the profiler.. in your code
<EliasAmaral>
ah.
<EliasAmaral>
well maybe there is specific instructions on how obtaining errno in Unix documentation
<olegfink>
mrvn: at least I could cast it to Unix.error
<EliasAmaral>
man Unix (i think this works)
<mrvn>
olegfink: Obj.magic casts everything
<olegfink>
(in a way that it said it was EINTR ;-)
<mrvn>
Use Unix.error_message
<olegfink>
it wants Unix.error, not int.
<mrvn>
And the Unix_error exception gives you an error
<EliasAmaral>
olegfink, type a = Test | Test2, (Obj.magic 0 : a). type a = Test2 | Test, (Obj.magic 0 : a)
<EliasAmaral>
olegfink, I think the obj.magic trick is affected by the order of definitions
<mrvn>
Obj.magic just disables the type system. It doesn't cast anything or checks ynthing.
<mrvn>
It takes the argument and claims it has the type you specify.
<Camarade_Tux>
man Unix says 11 corresponds to Unix.EINTR anyway ;p
<EliasAmaral>
but if data layout is affected by the order of definitions in source code then this method for understanding error codes seems unreliable
<EliasAmaral>
ok, you have to call the select again Camarade_Tux
<mrvn>
EliasAmaral: You are not supposed to understand the "11".
<EliasAmaral>
the unix semantics says that if a syscall is interrupted, it fails with errno = EINTR and you have to call it again
<Camarade_Tux>
I don't call it, my code is only: "let () = GtkThread.main ()" ;-)
<EliasAmaral>
mrvn, yeah, the actual number is implementation-dependent, one must use the C macros (or the ocaml equivalent)
<EliasAmaral>
Camarade_Tux, so maybe this module is broken o.o
<EliasAmaral>
Camarade_Tux, it's pretty common kind of error (that caught me while doing low level networking code)
<EliasAmaral>
a pretty
thrasibule has joined #ocaml
ofaurax has joined #ocaml
thrasibule_ has joined #ocaml
ulfdoz has quit [Read error: 60 (Operation timed out)]
thrasibule has quit [Read error: 110 (Connection timed out)]
BiDOrD has quit [Read error: 54 (Connection reset by peer)]
BiDOrD has joined #ocaml
ikaros has joined #ocaml
<mfp>
Camarade_Tux: check whether unix.cmxa is being linked twice --- doing so (e.g. when loading a cmxs that includes unix.cma in a program linked against it) results in this kind of errors
ygrek has quit [Remote closed the connection]
<Camarade_Tux>
I've been able to profile my testcase by lowering the runtime: 66.67 0.02 0.02 caml_thread_leave_blocking_section
munga has quit [Read error: 60 (Operation timed out)]
<thelema>
Camarade_Tux: yes, things like debug, profiling, bytecode/native, annot and others which *don't affect the correctness of the code* can and should be global compilation options
BiDOrD has quit [Read error: 110 (Connection timed out)]
BiDOrD has joined #ocaml
tar_ has quit []
struktured has joined #ocaml
<thelema>
things like required libraries, preprocessing macros, etc. should be part of the file somehow.
slash_ has joined #ocaml
joewilliams has joined #ocaml
<olegfink>
thelema: specifying preprocessor configuration in the translation unit itself likely opens the door to some existential questions...
<olegfink>
thought I won't mind some notation ideologically similar to what embedded perl &friends do, e.g. I mark sections of my unit to be run by specific pp, the compiler driver calls it and merges the output back into the program
tmaedaZ0 has joined #ocaml
mbac has joined #ocaml
<mbac>
(string * int) list -> (string * int -> string * int) -> string * int -> (string * int) list
tmaedaZ has quit [Read error: 110 (Connection timed out)]
<mbac>
is there a known function with this type signature (or the polymorphic equivalent) which will basically map over stuff and if there were "no matches" will append the 3rd argument to the list
<mfp>
what's a "match"?
<mfp>
a non-empty list? -> fun l f x -> match l with [] -> [x] | l -> List.map f l
alp_ has joined #ocaml
_unK has joined #ocaml
Alpounet has quit [Read error: 104 (Connection reset by peer)]
thrasibule_ has quit [Read error: 60 (Operation timed out)]
ikaros has joined #ocaml
<thelema>
mbac: you want a map where the given function can throw an exception (or return None), and in which case a default is returned?
<thelema>
This is easy to do in two steps, which can be composed in a straightforward way.
<thelema>
or just wrap your function to deal with the "no matches" case
<thelema>
let f_with_default f default x = match f x with None -> default | Some y -> y
<thelema>
olegfink: the "scope" of the preprocessor configuration naturally cannot be the whole file anymore, yes.
<palomer>
obj.magic can be used to circumvent the value restriction
<palomer>
which is pretty cool in my books
TaXules has quit [Remote closed the connection]
<thelema>
Obj.magic is dangerous.
_unK has quit [Remote closed the connection]
joewilliams has quit [Remote closed the connection]
ofaurax has quit [K-lined]
TaXules has joined #ocaml
<palomer>
but so convenient when no other choices exist
<thelema>
there's always another choice. That other choice might have some cost, though.
Pimm has quit [Read error: 110 (Connection timed out)]
<palomer>
thelema, I've run into a problem which didn't have another choice
<palomer>
any way you cut it, I had to use obj.magic
<thelema>
I'll take your word on that. Every problem I've solved with Obj.magic had another solution (usually variable initialization and me not wanting to make something an option type)
<EliasAmaral>
maybe if there are situations when obj.magic is seem as unavoidable the ml type system isn't really suitable for the job (or, maybe, the software wasn't designed to be ml-friendly)
<thelema>
yes, palomer seems very good at finding those kinds of situations
ski_ has quit ["Lost terminal"]
<palomer>
the only way of avoiding obj.magic in my case is to have camlp4 provide some form of type equality
<palomer>
right now I'm having to do it dynamically
<thelema>
palomer: it doesn't. I just wanted feedback
<thelema>
found it.
<palomer>
oh, you pasted this?
<thelema>
palomer: I typed it all in, from the ocaml sources
<palomer>
cool
<thelema>
It might be the first time anyone has listed all of these
<thelema>
outside the source code
TaXules has quit [Remote closed the connection]
<EliasAmaral>
thelema, this have something to do with objects? i found it only on 'Object types' section, regarding method types)
<palomer>
yeah, people often use it in objects
<thelema>
EliasAmaral: it's important for objects and apparently records
<palomer>
it has uses for records
<palomer>
for example, if you wanted to encode lambda calculus
<thelema>
EliasAmaral: without this extra syntax, one can't specify a specifically polymorphic type
<mrvn>
And 'a. can't be used outside of records or objects
<EliasAmaral>
but 'a list isn't?
<palomer>
I once asked jacques garrigue why it's only available for records and objects
<palomer>
he told me that's the only time it's useful
<EliasAmaral>
hm
<palomer>
I strongly disagreed
<mrvn>
palomer: 'a. ('a, 'a -> unit) list
<EliasAmaral>
i just can't get it.. ocaml still has a lot of things i don't understand
<palomer>
mrvn, hmm?
<palomer>
EliasAmaral, wait until you need something like this, or else it seems pointless
<mrvn>
palomer: just an example where 'a. outside of records would be nice
<palomer>
yeah
<palomer>
it would also be nice simply to annotate functions to make sensical type errors
<mrvn>
palomer: then do so
<palomer>
I can't
<palomer>
let f : 'a . 'a -> 'a = ...
TaXules has joined #ocaml
<palomer>
I'm sure the list is going to come up with a solution
<palomer>
let's hope it doesn't involve specifying 5 different functors
<mrvn>
palomer: That type makes no sense
<mrvn>
palomer: Where would you get the 'a from to apply to f?
<palomer>
let f : 'a. 'a -> 'a = fun x -> x
<palomer>
would be the same as let f x = x
<mrvn>
palomer: no
<thelema>
palomer: I get a type error when I paste that explicit f into ocaml
<thelema>
# let f : 'a. 'a -> 'a = fun x -> x
<thelema>
Error: Parse error: ident_of_ctyp: this type is not an identifier
<mrvn>
The former says f is a function that for which a 'a exists with 'a -> 'a. Not that it takes any 'a.
<palomer>
thelema, well, you can't do it, but sometimes I'd like to
<mrvn>
palomer: not in that example. That type simply makes no sense.
<palomer>
mrvn, I don't see why it doesn't make sense
<palomer>
I read 'a. 'a -> 'a as "for any 'a, 'a -> 'a"
<mrvn>
palomer: because you restrict f to some specific 'a without also coupling a value to it that you can use.
<EliasAmaral>
palomer, why this is different of simply 'a -> -a?
<mrvn>
palomer: In 'a. ('a, 'a -> unit) you have a value and a function you can apply it to.
<mrvn>
EliasAmaral: plain 'a -> 'a is way broader.
<EliasAmaral>
x. y in a type is used to restrict a polymorphic y to values x permits?
<palomer>
mrvn, I have the opposite interpretation of 'a . 'a -> 'a
<palomer>
let id_record = {body : 'a. 'a -> 'a}
<EliasAmaral>
well, this interpretation is wrong, because 'a permits everything
<mfp>
palomer: are you trying to encode existential types?
<palomer>
let _ = id.body 5
<palomer>
let _ = id.body "foo"
<palomer>
mfp, no, I'm trying to apply obj.magic to cast to universally quantified types
<palomer>
let id = {body = fun x -> x}
<mfp>
how are you going to use such types?
<mfp>
the example you gave -> {bar = Obj.magic a} with let a = fun x -> x + 1 is conceptually wrong
<palomer>
ok, in this case the resulting program is unsafe
<palomer>
but it's a test case
<mrvn>
palomer: How is body.id different from id : 'a -> 'a?
<palomer>
well, for one, you'll never run into the value restriction with this kind of stuff
<palomer>
but sometimes I simply want to annotate my types with 'a to explictily tell the compiler that those variables will be generalized
<palomer>
for clearer type errors
<mrvn>
# let id = fun x -> x;;
<mrvn>
val id : 'a -> 'a = <fun>
<mrvn>
id 1;;
<mrvn>
id "foo";;
<palomer>
yes, in this case it's the same
<mrvn>
palomer: In the record you need the 'a. to make the resulting overall type not be ['a] foo
slash_ has quit [Client Quit]
<mrvn>
In a function that is basically implicit
<mfp>
palomer: like this?
<mfp>
# let foo (type a) (x : a) = x + 1;;
<mfp>
Error: This expression has type a but an expression was expected of type int
<mfp>
(2nd x underlined)
<palomer>
what's type a?
<mfp>
an explicitly named generic type
<mfp>
new in 3.12
<palomer>
mfp, I sometimes have good reason to want to generalize variables which are not in the context
<palomer>
oh, that's cool!
<palomer>
I've always wanted to do that
thrasibule has quit [Read error: 113 (No route to host)]
<palomer>
that's REALLY cool
<mfp>
this is btw. what allows you to escape the functor trap too
<mrvn>
So you can force a type to stay general even if the type inference decides it should be something else?
<palomer>
let foo _ = let bar (type a) (x:a) = x <--what's the type of this?
<mfp>
# let uniq (type x) ?(compare = compare) l = let module S = Set.Make(struct type t = x let compare = compare end) in S.elements (List.fold_right S.add l S.empty);;
<mfp>
val uniq : ?compare:('a -> 'a -> int) -> 'a list -> 'a list = <fun>
<palomer>
mrvn, which use case are you talking about?
<palomer>
mrvn, the annotating or the obj.magic?
<mrvn>
palomer: (type a)
<palomer>
annotating is a small convenience to save a little time correcting type errors
<thelema>
palomer: new in 3.12
<palomer>
(type a) is like system F's big lambda
<thelema>
n/m
<Camarade_Tux>
follow-up to non-zero cpu usage for lablgtk2 apps calling gtkThread.main (), in gtkThread.ml, line 75: 'Thread.delay 0.001;', 0.001 seems too low and 0.002 gave much lower cpu usage and should still be ok, I'll try something a bit different though: adjust the time delay according to UI activity: when there is no activity, increase it, and where there is some again, lower it
<mfp>
mrvn: "the type t is considered abstract in its scope (the arguments that follow it and the body of the function), and then replaced by a fresh type variable."
<mrvn>
And you can't use 'a for that: # let foo (x : 'a) = x + 1;;
<mrvn>
val foo : int -> int = <fun>
<mfp>
palomer: syntax error ;)
<palomer>
let foo _ = let bar (type a) (x:a) = x in bar
<mfp>
val foo : 'a -> 'b -> 'b = <fun>
<palomer>
oh, then it still doesn't help me:(
<mrvn>
palomer: google for universal and ocaml. There are several solutions without Obj.magic
<mfp>
you wanted 'b. 'a -> 'b -> 'b ?
<mrvn>
mfp: which makes no sense as it is already 'b
<palomer>
I wanted 'a -> ('b. 'b -> 'b)
<mfp>
how many 'b. 'b -> 'b functions are there apart from identity and raise Exn?
<mrvn>
mfp: millions
<mfp>
modulo side effects?
<mrvn>
yep
<palomer>
up to beta/alpha/let equivalence?
<mrvn>
no, I ment with side effects you get millions
<palomer>
oh
<mrvn>
mfp: You could have 'a -> 'a list and many more though.
Amorphous has quit [Read error: 104 (Connection reset by peer)]
<thelema>
mfp: as much as you were technically correct that 'let module M = ' syntax was added a long time ago, using this within an expression is a 3.12 feature
<mfp>
indeed, because of the use of type a
<thelema>
oops, mis-read. yes, [let M = FOO in M.x] wasn't just added, it's the local open that was added.
Amorphous has joined #ocaml
<thelema>
is there a way to fix all the warnings I get from ocamldoc like: Warning: Element Array not found
<palomer>
let _ = let module X = (struct let f = 4 end) in X.f;;
<palomer>
let foo = <:expr< let module FOO = (struct let x = 5 end) in FOO.x >> <---camlp4 doesn't like this
<palomer>
any suggestions?
<palomer>
ahh, right revised syntax
<mfp>
let module FOO = struct value x = 5; end in FOO.x
<thelema>
does anyone know what's up with OMake's OCamlLibraryInstall function?
<thelema>
for instance, how to use it with findlib
<palomer>
I do it manually using the output from OCamlLibrary
<thelema>
output from OCamlLibrary?
<thelema>
it has output?
<mfp>
OCamlLibrary & friends return the target
<thelema>
hmmm...
<mfp>
so you can do .DEFAULT: OCamlLibrary(foo, foo)
<thelema>
ok, that's something different.
<thelema>
how can I have the omakefile succeed even if some command doesn't return 0
<thelema>
is the best way to put [|| true] at the end of those commands?
<mfp>
maybe capturing the output with $(shell ) ?
<thelema>
n/m, that wasn't the problem. I thought somehow my install-doc was failing, but it just needed to be marked .PHONY
<palomer>
yeah
<palomer>
I've had that problem before
<EliasAmaral>
is omake development dead? last realease was in 2007
<thelema>
seems to have quieted to nothing since 2008
<thelema>
that said, there's a lot of active users
<thelema>
maybe it's perfect, like TeX
_zack has quit ["Leaving."]
palomer has quit [Read error: 104 (Connection reset by peer)]
gues9845 has joined #ocaml
<gues9845>
I'm trying to pick up ocaml and I'm reading Hickey's book. Is it a good book to learn from?
<mfp>
many consider it the best
<gues9845>
hm, I have a draft copy, is it worth buying a copy?
<gues9845>
(it's a legit draft copy)
gues9845 has left #ocaml []
derenrich has joined #ocaml
_unK has joined #ocaml
<Camarade_Tux>
I don't know if it has been published yet
<thelema>
and then I'll make a more public release announcement if it's releasable
ttamttam has quit ["Leaving."]
<Camarade_Tux>
btw, anyone know the implications of ld-ocaml license-wise with gpl code with the static exception which most ocaml libraries use?
middayc has joined #ocaml
<derenrich>
maybe stupid question: if ocaml is polymorphic why isn't there a generic "+" operator which works on floats and ints?
<EliasAmaral>
ocaml have strong types
<EliasAmaral>
polymorphism is provided if you want generic types (like, say, 'a list is the set of all lists)
slash_ has joined #ocaml
<Camarade_Tux>
derenrich: don't take my word for granted but this is currently possible if the values have the same representation in memory which is not the case for int vs float
<EliasAmaral>
this function is generic: let put a b = a :: b, it works for all lists
<Camarade_Tux>
note this may actually come to ocaml
<EliasAmaral>
it's possible if you use a + (int_of_float b), for example
<EliasAmaral>
a + b in SML works if a is int and b is float, but they use a trick..
<EliasAmaral>
that maybe ocaml folks shold have used, btw
<derenrich>
right
<derenrich>
haskell has strong types and doesn't have this problem, it's why i ask
smimou has quit [Read error: 104 (Connection reset by peer)]
smimram has joined #ocaml
<derenrich>
it just makes the language feel ugly
<EliasAmaral>
in a theoretical point of view, no
BiDOrD has quit [Read error: 104 (Connection reset by peer)]
<EliasAmaral>
but for the average use, yes, the ocaml syntax is painful in this aspect
<EliasAmaral>
but, every language have it's syntactic quirks..
<derenrich>
true
<derenrich>
i mean theoretically it's not pure functional, correct?
BiDOrD has joined #ocaml
<EliasAmaral>
no, nothing to do with it imo
<orbitz>
haskell also has typeclases whic are a huge diff
<orbitz>
haskell has other painful numeric problems though
<EliasAmaral>
the SML + is just really a ugly syntax sugar in the point of view of the language definition
ulfdoz has quit [Read error: 110 (Connection timed out)]
<EliasAmaral>
it's ugly because you couldn't do something like this in SML itself, it's hard coded in language
<orbitz>
It took me awhile but i decided that + and +. is actually a good thing
<EliasAmaral>
orbitz, type classes, this is something i don't know
<orbitz>
EliasAmaral: typeclasses are why you can have + work fo rany numeric type in Haskell
<EliasAmaral>
orbitz, there is a "numeric tower" in haskell?
<EliasAmaral>
orbitz, scheme numeric tower is just wonderful, i wonder if this is hard to do in a ML-like language
<orbitz>
EliasAmaral: numbers in haskell are a clusterfuck right now
<orbitz>
EliasAmaral: there is a big typeclass heirarchy and a real mess between floats and ints
<orbitz>
not quite as powerful as haskell ones though
<orbitz>
I think you can do some magic iwth modules though
tmaedaZ has joined #ocaml
<EliasAmaral>
yeah: many things seems to be out of ocaml for sake of handling better with type errors (ocaml handles nicely some hard object type errors, and maybe this is why ocaml was created)
<orbitz>
I'm not sure if things were left out of ocaml explicity fo rbetter type errors
<orbitz>
more likely fo rsimplicity of language and implemetnation
<EliasAmaral>
'bounded polymorphism' is that 'a. (...) ?
<orbitz>
I don't know
slash_ has quit [Client Quit]
valross has joined #ocaml
<mfp>
Camarade_Tux: ld.ocaml is MIT-licensed; it doesn't introduce any additional restrictions
<mfp>
as for redistributing .cmxs files hmm in fact that satisfies even LGPL without the static linking exception
<Camarade_Tux>
oh, snap, yes, I thought ocaml libraries used GPL with static exception, not LGPL with static exception, of course it works =)
bogen has quit [Read error: 110 (Connection timed out)]
bogen has joined #ocaml
haelix_ is now known as haelix
thrasibule has joined #ocaml
<derenrich>
is there a way to get auto bigints in ocaml?