jlouis_ has quit [Read error: 110 (Connection timed out)]
l_a_m has quit [Remote closed the connection]
seafood_ has joined #ocaml
mwc has joined #ocaml
ben___ has joined #ocaml
jlouis_ has joined #ocaml
netx has quit ["Leaving"]
netx has joined #ocaml
jlouis has quit [Read error: 110 (Connection timed out)]
netx has quit [Remote closed the connection]
ben___ is now known as ziph
thermoplyae has quit ["daddy's in space"]
coucou747 has quit ["bye ca veut dire tchao en anglais"]
thermoplyae has joined #ocaml
Snrrrub has joined #ocaml
monde has quit ["Leaving."]
<Snrrrub>
What's the right way to package a library that calls C code? I have something like: ocamlc -a -o mylib.cma -custom myobject.cmo mystubs.o and then when I try to link other sources to the library, the compiler complains that it can't find the .o file (even if I specify -I).
<Smerdyakov>
-I never has anything to do with linking, I think.
<Snrrrub>
Smerdyakov, I thought it specifies the directories to search for .cma files (and, presumably, other files that archives refer to)?
<Smerdyakov>
Nope. It's for searching for .cmi files.
<Snrrrub>
I see. So how do I specify the directories to search for archives and objects?
<Smerdyakov>
Maybe -L. That's the gcc convention.
<Smerdyakov>
But, really, read the manual.
<Snrrrub>
I did... :-/
<Snrrrub>
And, sadly, it's not -L. Hm.
jlouis has joined #ocaml
AxleLonghorn has joined #ocaml
AxleLonghor1 has joined #ocaml
<Smerdyakov>
I'm guessing you want "-ccopt" for linking directives.
<Smerdyakov>
Maybe "-ccopt myfile.o".
jlouis_ has quit [Read error: 110 (Connection timed out)]
<julm>
Snrrrub: here is an example of what I do:
<julm>
gcc -c my_c.c
<julm>
ar rc libmy.a my_c.o
<julm>
ocamlc -c my.ml
<julm>
ocamlc -a -o my.cma -custom -cclib -lmy my.cmo
<Snrrrub>
julm, ah, and then the -L option via -cclib will work since it's an archive and not an object file (.a not .o)
AxleLonghorn has quit [Read error: 110 (Connection timed out)]
<julm>
hum, according to man ocamlc, you should give -L via -ccopt
<Snrrrub>
julm, noted. Thanks!
<julm>
also if your library goes into `ocamlc -where`/my, then it is useless to pass -L`ocamlc -where`/my, because the -I +my will do it automatically IIRC
Optikal__ has quit []
<julm>
btw, take care not to have a my.c and a my.ml, because they both lead to the same object: my.o, so when you use ocamlopt, one will overwrite the other...
<julm>
or be sure, you actually pack the my.o from my.c into libmy.a before you run ocamlopt -c my.ml
<Snrrrub>
julm, yeah, I found that out the hard way. :-)
<julm>
xD
seafood_ has quit []
mrsolo has joined #ocaml
mrsolo has quit [Client Quit]
mrsolo has joined #ocaml
Snrrrub has quit [Read error: 104 (Connection reset by peer)]
thelema has quit [Read error: 104 (Connection reset by peer)]
zarvok has joined #ocaml
|Catch22| has joined #ocaml
jlouis_ has joined #ocaml
AxleLonghorn has joined #ocaml
goalieca has joined #ocaml
postalchris has joined #ocaml
jlouis has quit [Read error: 110 (Connection timed out)]
mwc has quit ["Leaving"]
AxleLonghor1 has quit [Read error: 110 (Connection timed out)]
evn has quit []
mrsolo has quit ["This computer has gone to sleep"]
evn has joined #ocaml
mrsolo has joined #ocaml
netx has joined #ocaml
|Catch22| has quit []
postalchris has quit [Read error: 110 (Connection timed out)]
mrsolo has quit ["This computer has gone to sleep"]
thermoplyae has quit ["daddy's in space"]
ry4n_ has joined #ocaml
ry4n__ has joined #ocaml
_shawcable_sucks has joined #ocaml
mrsolo has joined #ocaml
goalieca has quit [Connection timed out]
goalieca has joined #ocaml
ry4n_ has quit [Read error: 110 (Connection timed out)]
ry4n__ has quit [Connection timed out]
_shawcable_sucks has quit [Read error: 110 (Connection timed out)]
mrsolo has quit ["This computer has gone to sleep"]
jderque has joined #ocaml
zarvok has quit ["BitchX-1.1-final -- just do it."]
AxleLonghorn has left #ocaml []
mrsolo has joined #ocaml
seafood_ has joined #ocaml
thelema has joined #ocaml
mrsolo has quit ["This computer has gone to sleep"]
jlouis has joined #ocaml
mrsolo has joined #ocaml
Robdor has joined #ocaml
jlouis_ has quit [Read error: 110 (Connection timed out)]
mrsolo has quit ["This computer has gone to sleep"]
seafood_ has quit []
l_a_m has joined #ocaml
Robdor has quit [Remote closed the connection]
ry4n_ has joined #ocaml
mrsolo has joined #ocaml
jlouis_ has joined #ocaml
jderque has quit [Read error: 113 (No route to host)]
seafood_ has joined #ocaml
ry4n__ has joined #ocaml
jlouis has quit [Read error: 110 (Connection timed out)]
mrsolo has quit ["This computer has gone to sleep"]
goalieca has quit [Read error: 110 (Connection timed out)]
ry4n_ has quit [Read error: 110 (Connection timed out)]
ry4n__ has quit [Read error: 110 (Connection timed out)]
jlouis has joined #ocaml
LordMetroid has joined #ocaml
jlouis_ has quit [Read error: 110 (Connection timed out)]
antares has joined #ocaml
mrsolo has joined #ocaml
brooksbp has joined #ocaml
Linktim has joined #ocaml
brooksbp has quit []
filp has joined #ocaml
Yoric[DT] has joined #ocaml
<Yoric[DT]>
hi
<ziph>
hiya
lordmetroid_ has joined #ocaml
LordMetroid has quit [Nick collision from services.]
lordmetroid_ is now known as LordMetroid
LordMetroid has quit ["Leaving"]
velco has joined #ocaml
filp has quit [Remote closed the connection]
velco has quit [Client Quit]
filp has joined #ocaml
hkBst has joined #ocaml
coucou747 has joined #ocaml
<coucou747>
salut all
<Yoric[DT]>
hi
vpalle has joined #ocaml
pango has quit [Remote closed the connection]
pango has joined #ocaml
ziph has quit []
<ikatz>
is anyone on who knows ocamlyacc?
<ikatz>
i'm trying to construct lists from the input
<ikatz>
myPredicate(x1, x2, x3) should be parsed into ("myPredicate", ["x1"; "x2"; "x3"])
<ikatz>
but all i get is either a parse error or an infinite loop
<bla>
od people connected with "Romance rock" or similar.
<bla>
Very 'existential' way of living.
<bla>
;p
<mwc>
hmmm
<mwc>
an existential way of living
<Yoric[DT]>
:)
<mwc>
are you saying that existence and living are distinct and that only our prejudices conflate them?
<mwc>
how very zen.
<Yoric[DT]>
Well, I'm looking for a hand with OCaml-style existential types :)
<mwc>
Yoric[DT], this came up on the mailing list. Ocaml doesn't have them
<Yoric[DT]>
Well, it has at least two manners of encoding them.
<Yoric[DT]>
Once with 'a.'a and one with objects -- although I've seen people arguing that it's the contrary and that objects are a way of encoding existential types.
<mwc>
oh objects ;)
<mwc>
Closures are degenerate objects, and objects encode closures
<bla>
mwc, maybe polish meaning of existential doesn't fit well with this word.
<mwc>
is there any isomorphism object's don't have? :)
<mwc>
*are there
<Yoric[DT]>
Well, hammers and nails :)
<mwc>
actually, s/'//
<mwc>
Yoric[DT], indeed.
<mwc>
bla, existentialism is a philosophical doctrine (in English usage)
<Yoric[DT]>
In French, too.
<mwc>
so existential usually denotes something associated with that
<Yoric[DT]>
Plus it's supposed to be a humanism, but I wouldn't go as far as pretending I understand anything about it.
<mwc>
ie, to have an existential crisis.
<Yoric[DT]>
My problem at the moment is that I'd like to be able to put some content inside an existential type (that's easy) and get it back (that's hard).
<Yoric[DT]>
On one side, I have my existential type, which hides some type 'a.
<Yoric[DT]>
On the other side, I have a phantom type which gives me that type 'a.
<bla>
mwc, ;)
<mwc>
Yoric[DT], I think you'd have to bundle it with an observer function, 'a -> foo
<Yoric[DT]>
I'd like to write a projection from the hidden part to the visible one.
<Yoric[DT]>
I can't do that.
<Yoric[DT]>
I mean, I don't know "foo" when I write the existential type.
<Yoric[DT]>
I only know it later.
<Yoric[DT]>
(i.e. the existential type goes inside a library, the observer function is provided by the client)
<mwc>
Hmmm
<mwc>
what about something like: type 'b myrec = {stuff : 'a . 'a*'a ->'b}
<mwc>
with parenthesis to fix my associativity gaff
<Yoric[DT]>
I can't have universal types.
<Yoric[DT]>
Only existential.
<mwc>
could you fake it with a functor?
<mwc>
type myrec = {stuff : 'a . 'a*('a -> foo) } where foo comes from a functor argument?
<Yoric[DT]>
I'm trying to avoid that.
<mwc>
I don't see how else you're going to get a user-provided type in there
<Yoric[DT]>
I'll rephrase what's above, just in case.
<Yoric[DT]>
I have
<Yoric[DT]>
type my_wrapper = exists 'x.{content : 'x} -- or something such
<Yoric[DT]>
I have
<Yoric[DT]>
type 'y my_projector = exists 'x.{project : 'x ->'y}
<Yoric[DT]>
Er... no
antares has quit ["Quitte"]
<Yoric[DT]>
I have a phantom type telling me that my_wrapper actually contains information of type 'y.
<Yoric[DT]>
And I want to write a function
<Yoric[DT]>
my_wrapper -> 'y
<Yoric[DT]>
Without resorting to Obj.magic.
<Yoric[DT]>
I am willing to use objects, though, if necessary.
thelema has joined #ocaml
bongy has quit ["Leaving"]
delamarche has joined #ocaml
LordMetroid has joined #ocaml
<rwmjones>
does anyone have an email address for Xavier Clerc (ocamljava blokey)?
<rwmjones>
ok don't worry, found it
<Yoric[DT]>
mmmhhh....
<Yoric[DT]>
I have a class with a parametric type ['a].
<Yoric[DT]>
Is there a way to specify in the type of a function that I only accept objects of that class ?
<Yoric[DT]>
(without specifying 'a) ?
<Yoric[DT]>
mmhhh...
<Yoric[DT]>
Probably.
<Yoric[DT]>
But I probably can't hide 'a without resorting to existential types.
<Yoric[DT]>
Grrr...
pango has quit [Remote closed the connection]
filp has quit ["Bye"]
Morphous_ has joined #ocaml
<julm>
Yoric[DT]: is that what you want:
<julm>
module Hide
<julm>
(Common: sig type t end) :
<julm>
sig
<julm>
type t
<julm>
val mk : ('e -> Common.t) -> 'e -> t
<julm>
val get : t -> Common.t
<julm>
end =
<julm>
struct
<julm>
type t = unit -> Common.t
<julm>
let mk c e : t = fun _ -> c e
<julm>
let get t = t ()
pango has joined #ocaml
<julm>
end
<julm>
class ['a] c = object end
<julm>
module C = Hide(struct type t = int c end)
<julm>
let example (c: C.t) = C.get c
<thelema>
julm: something seems wrong about mk's definition: mk c e : t = fun _ -> c e has three parameters, no?
<julm>
nope, it's ok, it is a partial evaluation
<julm>
I mean, it delays the call to [c e]
seafood_ has quit []
<julm>
later [get] calls it
<julm>
there is a way to do it with existential too
<julm>
but in both cases
<thelema>
ah, Common.t is a closure...
<thelema>
better then to write fun () -> c e, no?
<julm>
Common.t must be known
<julm>
yep thelema
<julm>
with existential:
<julm>
module Hide
<julm>
(Common: sig type t end) :
<julm>
sig
<julm>
type t
<julm>
val mk : ('e -> Common.t) -> 'e -> t
<julm>
val get : t -> Common.t
<julm>
end =
<julm>
struct
<julm>
type 'e buc = {e : 'e; c : 'e -> Common.t}
<julm>
type 'c bucket = {c_of_buc : 'e. 'e buc -> 'c}
<julm>
type t = {c_of_bucket : 'c. 'c bucket -> 'c}
<julm>
let mk c e = {c_of_bucket = fun buc -> buc.c_of_buc {e=e; c=c}}
seafood_ has joined #ocaml
<julm>
let get t = t.c_of_bucket {c_of_buc = fun buc -> buc.c buc.e}
<julm>
end
<julm>
this was discussed on the caml-list a few weeks ago
<julm>
Yoric[DT]: you mean that: let l = [(new button :> _ widget); (new label :> _ widget)]
<Yoric[DT]>
yep
<Yoric[DT]>
I'm currently trying to get a really efficient manner of obtaining polymorphic exceptions, without resorting to Obj.magic.
<Yoric[DT]>
I have an efficient implementation with Obj.magic, a much less efficient implementation with references and I'm attempting to find something better.
ita has quit ["Hasta luego!"]
<Yoric[DT]>
With existential types, it's easy to put any content inside an exception.
<julm>
could we see your code to understand better?
<Yoric[DT]>
I can only assume we're not using the same version of OCaml/camlp4 .
<julm>
me: Camlp4 Parsing version 3.10.2+dev3 (2008-01-29)
<Yoric[DT]>
I'm using 3.10.1
<Yoric[DT]>
Mhhh... are you using Tuareg ?
<julm>
nope, I'm under Vim
jstanley has joined #ocaml
<Yoric[DT]>
Ok.
<Yoric[DT]>
Well, anyway, it compiles.
<jstanley>
what's the best way to throw away the result of a function to avoid "this expression should have type unit" warnings? e.g., List.map print_endline lst generates this in a compound statement.
<Yoric[DT]>
ignore
<Yoric[DT]>
it has type 'a -> unit
<julm>
yep ignore, not let _ =
<jstanley>
ah, thanks.
<jstanley>
i was hoping there'd be something around like that, but couldn't find it.
<Yoric[DT]>
np
<thelema>
why use List.map? use List.iter for print_endline
<jstanley>
thelema: yeah, even better, i was just using that as an example.
<julm>
Yoric[DT]: what does bind do?
<Yoric[DT]>
monadic binding
<thelema>
julm: monadic dark voodoo
<Yoric[DT]>
In practice, it's used only to propagate the phantom types.
kelaouchi has joined #ocaml
monde has joined #ocaml
ita has joined #ocaml
maayhem has joined #ocaml
<maayhem>
hello
<Yoric[DT]>
hi
<maayhem>
I have a question about polymorphic type inference:
<maayhem>
do you need more than first order unification to tell that this program is not well typed ?
<Yoric[DT]>
I don't see why you would.
<maayhem>
its simple
<maayhem>
when calling check a and check b
<maayhem>
you require that a and b are the same type, that is, the same type as the parm argument of check function.
<maayhem>
which is not the case here.
<maayhem>
e.g. 1 type variable for a, 1 type variable for b, 1 type variable for parm
<maayhem>
with type(a) = type(parm) and type(b) = type(parm)
<Yoric[DT]>
No, I mean why more than first order ?
* Yoric[DT]
admits he never knows exactly where to place the limit between first order and second order: functions or functors ?
<maayhem>
because you might need constraints other than just type_a = type_parm, more like type_a C {type_parm} and type_b C {type_parm}
<julm>
Yoric[DT]: you know, this (Obj.magic ex) may harm, for instance this segfault:
<julm>
let x =
<julm>
match run (fun () -> throw `X) with
<julm>
| Fail (`X s) -> print_string s
<julm>
| _ -> print_endline "Ok"
<julm>
Actually it's to avoid this Obj.magic that I've introduced Common.t
<julm>
in the Hide modules.
<Yoric[DT]>
maayhem: Shouldn't that be "type_a may be unified with type_parm" and "type_b may be unified with type_parm" ?
<Yoric[DT]>
julm: it does ?
<julm>
yep
<Yoric[DT]>
Strange.
<julm>
try it
<julm>
nope
<maayhem>
Yoric[DT], yes, which means type_a = type_parm and type_b = type_parm, if you are in first order.
<maayhem>
but then that makes a constraint : type_a = type_b
<maayhem>
which is untrue
<Yoric[DT]>
julm: indeed, it does.
<Yoric[DT]>
maayhem: ok, I placed the boundaries between first order and higher order at the wrong place.
<julm>
AFAIK if you wanna retrieve a value from a packed type you must know the type of this value when you declare the existential type
<Yoric[DT]>
julm: mmmhhh.... you're right.
<julm>
I mean it must not be a 'a
<julm>
hence Common.t
<Yoric[DT]>
Is the problem 'a or is that subtyping ?
<jstanley>
anyone have problems with the toplevel crashing on subsequent command line invocations of the same function? i'm getting some "hanging" behavior :(
<julm>
I do not understand
<julm>
what subtyping?
<jstanley>
(a) paste buffer into toplevel (b) execute function (works) (c) paste buffer into toplevel again (d) execute function, get hang.
<julm>
jstanley: does your function have side-effects?
<Yoric[DT]>
mmmhhh.... still segfaults with a closed polymorphic variant.
<jstanley>
julm: it does some text output
<julm>
jstanley: a lot?
<jstanley>
julm: via print_endline
<jstanley>
julm: not *tons* but a fair amount.
<julm>
could we see the code?
<jstanley>
sure, give me a few moments.
<julm>
[19:28:44] julm | what subtyping? <--- ok I see now
<julm>
jstanley: did you wait a long time when it hung?
<Yoric[DT]>
Well, anyway, the problem is indeed not subtyping.
<julm>
maybe it's just the GC
<jstanley>
julm: i don't have *that* much data around.
<julm>
Yoric[DT]: yep
<julm>
jstanley: ok
<jstanley>
in any case, it only happens after i refresh the entire buffer
<Yoric[DT]>
Probably related to the representation of 'a.'a .
<jstanley>
julm: like when i redefine the same functions
<julm>
jstanley: hum
<jstanley>
julm: i can invoke the same function multiple times and get the same verbose output with no real problem
<maayhem>
anyone has an idea regarding my question ?
<jstanley>
julm: but my emacs development environment edits ocaml code and then sends the buffer contents to the toplevel.
<julm>
Yoric[DT]: Probably related to the representation of 'a.'a . <-- well it is related to representation of poly.variants with and without data
<julm>
Yoric[DT]: but it's just an example, I could create a segfault with something else
rwmjones has left #ocaml []
<Yoric[DT]>
Fair enough.
<Yoric[DT]>
Well, I have another implementation, which *is* typesafe but is slowed down a lot by the use of references.
<Yoric[DT]>
I came to existentials as a way of finding a way to circumvent references.
<Yoric[DT]>
s/circumvent/avoid/
<julm>
Yoric[DT]: but existentials are inside a record, like a reference
<julm>
jstanley: can you reproduce the hang without using emacs' machinery
<julm>
"If the function returns either a value or no result, it uses an option type."
<julm>
Most of the time I avoid that
<julm>
I guess it is my fearing of the useless allocation
<Yoric[DT]>
I believe the consensus has become that people may provide several implementations, but at least one should use option types rather than exceptions.
<thelema>
julm: you prefer to raise an exception on no result?
<julm>
yes, but only when the said function is the kind of function called a lot of times
<julm>
after all, I can wrap a function raising an exception without loosing too much, not the reciprocal
<julm>
AFAIK of course
<julm>
btw, I heard Lisp has a more powerful exception machinery
<julm>
for instance in Lisp one could raise an exception, which could then be caught at an outer level, and then from this outer level we can revert the program flow to the raising point of the exception
<julm>
anyone knowledgeable on Lisp around?
<flux>
julm, exceptions + call/cc?
<flux>
I suppose the same could be done with the call/cc-module for ocaml too
<thelema>
VB has this "powerful feature", it's called "on error continue"
<thelema>
err, "on error resume next"
<julm>
also thelema: I have the habit to accurately specify inside commentaries the raises which may occur, so I have not been really harmed by uncaught exception as of now.
psnively has quit []
<julm>
thelema: ok
<flux>
I wonder how that kind of exception handling could be used efficiently
<julm>
flux: don't know :/
<julm>
+I
<flux>
if you know a function you call can use such exceptions, you could just pass the thing to do on exception as an argument
<julm>
indeed
<flux>
I mean, don't you need to know quite a lot about a function to provide such services to it?
<flux>
maybe a lisper would know differently
<julm>
maybe
<flux>
btw, regarding those exception systems with Obj.magic, I would personally be very suspicious about them until someone can extract the same code, proven correct, from coq (or prove its usage by other means) :-)
<julm>
outch
<thermoplyae>
i've only used resuming in exceptions in lisp when i was writing the exception handler into the function itself
<thermoplyae>
because, yes, you do need to know quite a bit
psnively has joined #ocaml
<thermoplyae>
i'm not enough of a lisper to tell you how they manage to do it efficiently though
<thelema>
save the IP on exception and jump back to it on resume
<flux>
I didn't mean efficiently in the cpu-time sense, but in the sense that you get useful things done..
<thermoplyae>
sounds reasonable
<thermoplyae>
you can use it for things like loggers
<thermoplyae>
raise an exception, handle the log write, jump back
<flux>
so is that mechanism in Common Lisp?
<thermoplyae>
maybe that's a useful example
<thermoplyae>
yeah
<flux>
funny, though, because I thought CL doesn't have a general call/cc mechanism
AxleLonghorn has joined #ocaml
lxuser has joined #ocaml
<Yoric[DT]>
julm: actually, with this exception framework, you can do pretty much the same thing in OCaml :)
<lxuser>
i get the following error message when trying to build an ocaml app
<lxuser>
Camlp4: Uncaught exception: DynLoader.Error ("pa_ifdef.cmo", "file not found in path")
<Yoric[DT]>
lxuser: did you write the Makefile ?
<Yoric[DT]>
julm: One more reason to improve the performance of this library.
postalchris has quit [Connection timed out]
<lxuser>
nope
<Yoric[DT]>
lxuser: basically, it's probably suited for OCaml 3.09- and you probably have 3.10+.
<thelema>
One would need to program differently - when I raise an exception, it's usually because that function can't continue. If i had to write exceptions that would not guarantee leaving the function, I'd have to if something-bad then raise_exception else do rest of function -- what would get returned if the error handler resumed my function...
<Yoric[DT]>
thelema: I was thinking about raising an exception and putting the rest of the function inside the exception constructor.
<Yoric[DT]>
lxuser: might work if you install Camlp5.
<Yoric[DT]>
I'm not sure how to use it, though.
<Yoric[DT]>
thelema: that wouldn't work with imperative loops, but everything else should work.
<thelema>
Yoric[DT]: exception Continuable of string * (unit -> 'a)?
<Yoric[DT]>
thelema: and to do that, you need to be aware that your exception is going to be used for resumption.
<Yoric[DT]>
why string ?
<Yoric[DT]>
But yeah, something like this.
<thelema>
same reason Failure and Invalid_argument use string
<Yoric[DT]>
ok
<lxuser>
so what am I supposed to change in the Makefile ? can I just change camlp4 to camlp5 and expect it to work?
<Yoric[DT]>
lxuser: I think so -- provided you have Camlp5 installed.
<Yoric[DT]>
julm: mmmhhh.... from what I see, it looks like this module not being able to see polymorphic types is a bug.