<adrien>
thanks, I ended up finding it (but the results from search engines were pretty bad)
Snark has quit [Quit: Ex-Chat]
Cyanure has quit [Quit: Quitte]
Yoric has joined #ocaml
emmanuelux has joined #ocaml
pkrnjevic has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
Anarchos has joined #ocaml
munga has quit [Ping timeout: 250 seconds]
<krktz>
hi
<krktz>
i'm looking for some more elegant way to do this :
<krktz>
type t = A | B | C | D
<krktz>
let to_int = function | A -> 0 | B -> 1 | C -> 2 | D -> 3
<krktz>
do you have an idea?
<thelema>
krktz: pa_do
<thelema>
there's some camlp4 that will auto-generate that kind of code for you
<krktz>
ok
<krktz>
wouldn't it be possible with Object.magic?
<krktz>
it looks like it works but can I be sure that it will be in the same order as during the definition?
<thelema>
it is possible, as variants without parameters are identical to 0, 1, 2, 3
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
Anarchos has joined #ocaml
<thelema>
krktz: # type t = A | B | C | D;;
<thelema>
type t = A | B | C | D
<thelema>
# let to_int (x:t) = (Obj.magic x : int);;
<thelema>
val to_int : t -> int = <fun>
<thelema>
# to_int A, to_int B, to_int C, to_int D;;
<thelema>
- : int * int * int * int = (0, 1, 2, 3)
oriba_ has joined #ocaml
<krktz>
thanks :)
oriba has quit [Ping timeout: 244 seconds]
vivanov has quit [Quit: Lost terminal]
boscop_ has quit [Ping timeout: 255 seconds]
* ygrek
wonders whether it is possible to build ocaml llvm bindings without building actually whole llvm?
oriba_ is now known as oriba
EM03 has joined #ocaml
<pkrnjevic>
it seems my ocaide / ocamlbuild -use-ocamlfind problem is related to eclipse not picking up $PATH when launched from Dock - works find if eclipse launched from terminal. <sigh>
<thelema>
ah, your path changes are in ~/.bashrc?
pdhborges has joined #ocaml
<pkrnjevic>
most likely
<pkrnjevic>
actually in ~/.profile which is invoked via ~/.bashrc
<pkrnjevic>
does osx support /etc/environment? and would that be picked up anyway?
<pkrnjevic>
my work around is to create a couple of sh scripts to set path and launch eclipse - dumb but "good enough"
<pdhborges>
are you talking about setting the PATH for normal apps in mac os?
<pdhborges>
there is a special plist file somewhere to do that
<pkrnjevic>
actually my godi bin path so ocamlbuld will find ocamlfind under ocaide
<pkrnjevic>
ah, i'm a 20+ year *nix guy but new to osx … i know plist exists, but that's about it