<Koordin>
hi, how can i "try" to assign a value to a variable, and if there is an excem
<Koordin>
hi, how can i "try" to assign a value to a variable, and if there is an exception, i assign another value ?
<Yoric[DT]>
let my_variable = try some_expression with _ -> some_other_expression
<Koordin>
i've tried : let temp = try assoc a l with Not_fond -> other
<Koordin>
Not_found
<Yoric[DT]>
Yes, that should work.
<Koordin>
thanks i'll look again
Linktim has quit [Read error: 113 (No route to host)]
Koordin has quit ["Konversation terminated!"]
filp has quit ["Bye"]
jeremiah has quit [Read error: 104 (Connection reset by peer)]
Linktim_ has quit [Read error: 110 (Connection timed out)]
rmns has joined #ocaml
jeremiah has joined #ocaml
jlouis has quit ["Leaving"]
ozy` has quit []
jlouis has joined #ocaml
struktured_ has joined #ocaml
itewsh has joined #ocaml
kombinator has quit [Read error: 104 (Connection reset by peer)]
struktured has quit [Read error: 110 (Connection timed out)]
itewsh has quit ["KTHXBYE"]
bluestorm has quit ["Ex-Chat"]
Submarine has joined #ocaml
snegovik has joined #ocaml
snegovik has quit [Client Quit]
rwmjones_ has joined #ocaml
snegovik has joined #ocaml
snegovik has quit [Client Quit]
snegovik has joined #ocaml
snegovik has quit [Client Quit]
snejok has joined #ocaml
<snejok>
ho
snejok has quit [Client Quit]
itewsh has joined #ocaml
kombinator has joined #ocaml
Palace_Chan has joined #ocaml
lorph has left #ocaml []
Linktim has joined #ocaml
rmns has left #ocaml []
itewsh has quit ["KTHXBYE"]
itewsh has joined #ocaml
Linktim_ has joined #ocaml
<jonafan>
guys
<jonafan>
polymorphic variants are not helping me out
<flux>
hm, can one really write applications in metacaml that deploy some "more powerful" features, other than being a more optimized end result?
Linktim_ has quit [Read error: 104 (Connection reset by peer)]
snejok has joined #ocaml
Linktim_ has joined #ocaml
Linktim has quit [Read error: 110 (Connection timed out)]
snejok has quit [Client Quit]
GustNG has quit ["Leaving."]
<Yoric[DT]>
jonafan: can we help you?
<Yoric[DT]>
flux: well, for one thing, you can think of MetaOCaml as being Camlp4 with types.
<flux>
yoric[dt], what can you accomplish with metacaml you cannot accomplish with plain functions?
<flux>
with basically the same syntax too - and syntax customization is what camlp4 really offers
<Yoric[DT]>
Note that I'm not a specialist. I've been wanting to try MetaOCaml for some time but for the moment, I've essentially been reading about it.
<Yoric[DT]>
Well, the main difference with Camlp4 is that any code you generate is well-typed.
<Yoric[DT]>
So you can make "safe" compilation libraries.
<flux>
and with code compiled that way you can, well, execute, just as you can execute any function anyway, only that it's faster?
<flux>
I suppose it might at times be ridiculously faster, enabling certain patterns of design
<Yoric[DT]>
Code compiled that way is just regular code.
<Yoric[DT]>
So if you compiled a function, it may be called just like any other function.
<flux>
but in the end it boils down to that you have a value int -> int, and it doesn't really matter if there's a generated and compiled code behind it, or something you do every time? (other than the speed)
<flux>
that is: if one has no speed needs whatsoever, what is there to gain by using metaocaml?
<mfp>
Yoric[DT]: do you know if MetaOCaml does code generation itself or if it uses a hack like the experimental native toplevel (generate .s, compile & dynload)?
<flux>
perhaps metaocaml+camlp4 can play nice together, so that certain kinds of extensions written in camlp4 won't bring the performance down in the way they would were they written naively
<Yoric[DT]>
flux: MetaOCaml is also a nice way of implementing a compiler.
<Yoric[DT]>
flux: or, more generally, a domain-specific language inside OCaml.
<Yoric[DT]>
mfp: I have no idea.
<flux>
yoric[dt], yes, because it's fast to run the resulting code?
<Yoric[DT]>
flux: and because the resulting code is typed.
pango has joined #ocaml
<Yoric[DT]>
Essentially, you have a type system for the generating code (as usual) *and* a type system for the generated code (that's new).
<Yoric[DT]>
So if you can write typed "trampoline" code.
<Yoric[DT]>
My knowledge essentially stops there, though :)
<mfp>
hmmm so the generated code is type checked at compile compile time, so to speak?
<flux>
yoric[dt], but for a dsl you don't need to generate code, you can just interpret it, which would be just as type safe? (..but slower..)
<Yoric[DT]>
mfp: no, yes.
<Yoric[DT]>
sorry
<Yoric[DT]>
mfp: yes
<Yoric[DT]>
(the "no" was from me misreading what you had written)
<mfp>
so one can see it as a sort of camlp4 without the syntax rewriting part but with output that is guaranteed to be well-typed
<mfp>
happening at run time
<Yoric[DT]>
flux: my knowledge of MetaOCaml is too thin to be certain of my answer, but I believe MetaOCaml's type-checking is stronger than that.
<Yoric[DT]>
s/to be certain/for me to be certain/
<Yoric[DT]>
i.e. you can write a lambda-calculus interpreter and generate mistyped lambda terms
<Yoric[DT]>
Unless I'm mistaken, MetaOCaml's type system can prevent this.
<jonafan>
the problem i am having: polymorphic variants are completely unpolymorphic and it's not clear to me when or why this happens
<Yoric[DT]>
jonafan: do you have an example?
<jonafan>
ummm my example would be multiple files
<flux>
can you have a shorter example with possibly just many modules in one file?-)
<mfp>
jonafan: here's a blind guess: do you have some type a = [ `Whatever | ... ] type b = [a | ...] and then some function b -> .., then you give it some a and get a type error?
itewsh has quit [Read error: 110 (Connection timed out)]
<Yoric[DT]>
:)
sporkmonger has joined #ocaml
itewsh has joined #ocaml
sporkmonger_ has quit [Read error: 104 (Connection reset by peer)]
<mfp>
you'll need extra type annotations ((x :> b) in this case since there's no implicit subsumption)
<jonafan>
okay well, imagine you have a series of functions that take messages in the form of polymorphic variants
<jonafan>
i'm trying to make a list of those functions
<Yoric[DT]>
Unrelated question: in findlib, is there a command to ask ocamlfind to please tell me its predicates?
<flux>
yoric[dt], ocamlfind query -somesome?
<jonafan>
it seems like it can't figure out how to merge the polymorphic variant types so that they can go in a list together
<Yoric[DT]>
Nah, ocamlfind query needs predicates to be useful.
<mfp>
jonafan: then the inferred type is the intersection of the [< ...] accepted types for each func?
<jonafan>
well, each one should be [> ...]
<mfp>
do you have a | _ -> something clause in all?
<jonafan>
actually
<jonafan>
yes
<jonafan>
well wait
<jonafan>
the plot thickens:
<jonafan>
there is only one thing in this list as of yet
<jonafan>
so there's really no excuse for whatever it's complaining about
<mfp>
it's not [> ...], but [= ...]? is it a recursive function?
<jonafan>
yes, the function is recursive
<jonafan>
let me paste this one crucial file
Linktim_ has quit [Read error: 104 (Connection reset by peer)]
<Yoric[DT]>
Yeah, but what's that polymorphic variant type?
<Yoric[DT]>
Do you know about recursive modules, btw?
<Yoric[DT]>
It could be a useful tool for debugging types here.
<jonafan>
the polymorphic variant type is all the various messages that the handlers handle
<Yoric[DT]>
Yeah, but it's obviously not what you want.
<jonafan>
like `Connected or `Packet of packet or `SendSomething of what * the * server * needs
<Yoric[DT]>
Sure, but the main problem is whether it's [> ...] or [= ...] or [< ...].
Amorphous has quit [Read error: 110 (Connection timed out)]
<jonafan>
they will all be open, [> ...]
Linktim has quit [Read error: 110 (Connection timed out)]
<Yoric[DT]>
Are they open or should they be open?
<jonafan>
they are
<jonafan>
i've only finished one, though
<jonafan>
but yes, it is open
<Yoric[DT]>
ok
Amorphous has joined #ocaml
<jonafan>
i think i need to get rid of the polymorphic variant
<jonafan>
i realize this is perhaps a crazy way to write a program, but it's not something i truly intend to finish, and doing this sort of thing gives you a lot of insight in general
<Yoric[DT]>
sure
mjambon has joined #ocaml
<olegfink>
does ocamljava compiled .class file have any runtime dependencies?
<olegfink>
s/does/do/;s/file/&s/
itewsh has quit [Read error: 60 (Operation timed out)]
itewsh has joined #ocaml
rwmjones_ has quit [Read error: 104 (Connection reset by peer)]
itewsh has quit ["KTHXBYE"]
Linktim_ has quit [Read error: 110 (Connection timed out)]
rhar has joined #ocaml
rwmjones_ has joined #ocaml
itewsh has joined #ocaml
<Yoric[DT]>
Mmmhhh....
<Yoric[DT]>
Okay, I keep having problems with my library deployment.
<Yoric[DT]>
Essentially, I have a module which may be compiled either with threads or without threads and I wish to deploy both versions.
<Yoric[DT]>
Now, I'd like to put both versions of the module in the same directory.
<Yoric[DT]>
Renaming the .cma is not a problem.
<Yoric[DT]>
Renaming the .cmi, of course, cause problems.
sporkmonger has quit [Read error: 110 (Connection timed out)]
Submarine has quit [Read error: 110 (Connection timed out)]
<Yoric[DT]>
The ideal would be to put the .cmi into the .cma .
<Yoric[DT]>
It's still not possible, is it?
<jonafan>
i stripped out the polymorphic variant and defined a regular variant and my problems are gone
<Yoric[DT]>
good
* Yoric[DT]
wonders if it's feasible to extract a self-contained .cmi from a .mllib .
l_a_m_ has quit [Remote closed the connection]
itewsh has quit [Read error: 110 (Connection timed out)]
itewsh has joined #ocaml
tomh has joined #ocaml
itewsh has quit [Remote closed the connection]
eyu100 has joined #ocaml
<Yoric[DT]>
Okay, issue solved by toying with findlib.