flux changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml MOOC http://1149.fr/ocaml-mooc | OCaml 4.03.0 announced http://ocaml.org/releases/4.03.html | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
al-maisan has quit [Quit: See you later..]
adelbertc has quit [Quit: Connection closed for inactivity]
tautologico has quit [Ping timeout: 264 seconds]
tautologico has joined #ocaml
tautologico has quit [Ping timeout: 276 seconds]
AltGr has left #ocaml [#ocaml]
Algebr`` has quit [Ping timeout: 250 seconds]
sdothum has quit [Quit: ZNC - 1.6.0 - http://znc.in]
sdothum has joined #ocaml
sepp2k has quit [Quit: Leaving.]
darkf has joined #ocaml
Algebr`` has joined #ocaml
jeffmo has joined #ocaml
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Read error: Connection reset by peer]
FreeBirdLjj has joined #ocaml
tautologico has joined #ocaml
Orion3k has quit [Ping timeout: 276 seconds]
Orion3k has joined #ocaml
Algebr`` has quit [Ping timeout: 250 seconds]
copy` has quit [Quit: Connection closed for inactivity]
Orion3k has quit [Ping timeout: 240 seconds]
kushal has quit [Quit: Leaving]
tautologico has quit [Ping timeout: 240 seconds]
Orion3k has joined #ocaml
nicholasf has joined #ocaml
kushal has joined #ocaml
nicholasf has quit [Read error: Connection reset by peer]
nicholasf has joined #ocaml
zv has joined #ocaml
sh0t has quit [Remote host closed the connection]
pyon has quit [Quit: fix config]
pyon has joined #ocaml
jeffmo has quit [Quit: jeffmo]
unbalancedparen has quit [Quit: WeeChat 1.5]
rgrinberg has quit [Ping timeout: 258 seconds]
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
AlexDenisov has joined #ocaml
FreeBirdLjj has quit [Read error: Connection reset by peer]
FreeBirdLjj has joined #ocaml
tmtwd has joined #ocaml
tg has quit [Ping timeout: 252 seconds]
jonasen has joined #ocaml
eikke has quit [Remote host closed the connection]
sdothum has quit [Quit: ZNC - 1.6.0 - http://znc.in]
al-maisan has joined #ocaml
ggole has joined #ocaml
mattrepl has quit [Quit: mattrepl]
darkf_ has joined #ocaml
darkf has quit [Ping timeout: 250 seconds]
mattrepl has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
tmtwd has quit [Ping timeout: 240 seconds]
mattrepl has quit [Ping timeout: 264 seconds]
ollehar has joined #ocaml
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tmtwd has joined #ocaml
Simn has joined #ocaml
kushal has quit [Quit: Leaving]
A1977494 has joined #ocaml
ollehar has quit [Quit: ollehar]
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
darkf_ is now known as darkf
yomimono has joined #ocaml
AltGr has joined #ocaml
tmtwd has quit [Ping timeout: 250 seconds]
AlexDenisov has joined #ocaml
AlexDenisov has quit [Read error: Connection reset by peer]
AlexDenisov has joined #ocaml
Algebr`` has joined #ocaml
AlexDenisov has quit [Read error: Connection reset by peer]
AlexDenisov has joined #ocaml
AlexDenisov has quit [Read error: Connection reset by peer]
<Algebr``> Can I compile ocaml code into byte code programmatically
<Algebr``> like using something from compiler-libs rather than calling the shell
<Algebr``> how rather can how one use findlib programmatically
<Algebr``> I guess that is the better question since I need to use findlib pacakges as well
dexterph has joined #ocaml
<Algebr``> okay findlib doesn't seem to expose this functionality?
AlexDenisov has joined #ocaml
<Algebr``> #require "findlib.dynload";;
<Algebr``> Error: Reference to undefined global `Fl_split' hmm....
nicholasf has quit [Remote host closed the connection]
jonasen has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<Algebr``> okay, I guess I can use ocamlbuild programmatically and it will use findlib indirectly...
jonasen has joined #ocaml
<Algebr``> Drup: ping
nicholasf has joined #ocaml
<Algebr``> nvm...
AlexDenisov has quit [Read error: Connection reset by peer]
AlexDenisov has joined #ocaml
<Algebr``> How can i use compiler-lib Compile.implementation with findlib?
kushal has joined #ocaml
yomimono has quit [Ping timeout: 240 seconds]
thegameg has quit [Ping timeout: 244 seconds]
gasche` has joined #ocaml
struk|desk2 has joined #ocaml
aggelos_ has quit [Ping timeout: 244 seconds]
martintrojer has quit [Ping timeout: 244 seconds]
dmbaturin has quit [Ping timeout: 244 seconds]
Algebr`` has quit [Read error: Connection reset by peer]
aggelos_ has joined #ocaml
struk|desk has quit [Ping timeout: 244 seconds]
gasche has quit [Ping timeout: 244 seconds]
bernardo1pc has quit [Ping timeout: 244 seconds]
engil has quit [Ping timeout: 244 seconds]
jstolarek has quit [Ping timeout: 244 seconds]
bernardofpc has joined #ocaml
dmbaturin has joined #ocaml
engil has joined #ocaml
Khady has quit [Ping timeout: 244 seconds]
jstolarek has joined #ocaml
Khady has joined #ocaml
martintrojer has joined #ocaml
thegameg has joined #ocaml
M-Illandan has quit [Ping timeout: 260 seconds]
M-Illandan has joined #ocaml
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
larhat has joined #ocaml
yomimono has joined #ocaml
dhil has joined #ocaml
nicholas_ has joined #ocaml
AlexDenisov has joined #ocaml
nicholasf has quit [Ping timeout: 272 seconds]
AlexDenisov has quit [Client Quit]
AlexDenisov has joined #ocaml
Hakey has quit [Ping timeout: 276 seconds]
jwatzman|work has joined #ocaml
AlexDenisov has quit [Read error: Connection reset by peer]
AlexDeni_ has joined #ocaml
AlexDeni_ has quit [Read error: Connection reset by peer]
AlexDenisov has joined #ocaml
AlexDenisov has quit [Read error: Connection reset by peer]
AlexDenisov has joined #ocaml
kakadu has joined #ocaml
tane has joined #ocaml
<beginner> what can be wrong if i get unbound module pervasives although OCAML_LIB points to the folder containing pervasives?
copy` has joined #ocaml
<mrvn> Are you trying to run ocaml in-place in the source directory?
<beginner> no
martinkl_ has joined #ocaml
richi235 has quit [Ping timeout: 276 seconds]
AlexDenisov has quit [Read error: Connection reset by peer]
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
richi235 has joined #ocaml
AlexDenisov has joined #ocaml
dhil has quit [Ping timeout: 264 seconds]
spion has quit [Ping timeout: 276 seconds]
spion has joined #ocaml
dhil has joined #ocaml
sepp2k has joined #ocaml
martinkl_ has quit [Ping timeout: 252 seconds]
martinkl_ has joined #ocaml
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
f- has quit [Ping timeout: 250 seconds]
tizoc has quit [Quit: Coyote finally caught me]
yomimono has quit [Ping timeout: 260 seconds]
f- has joined #ocaml
yomimono has joined #ocaml
clog has quit [Ping timeout: 272 seconds]
clog has joined #ocaml
silver has joined #ocaml
al-damiri has joined #ocaml
freehck has joined #ocaml
tane has quit [Quit: Verlassend]
<beginner> mrvn: the problem was that it tried to compile the pervasives.ml file and i had to set -nopervasive, although the cmi files were in this folder
tautologico has joined #ocaml
<beginner> has something changed between 4.02 and 4.03 that requires adding -nopervasive, when using a custom ocaml folder?
sdothum has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
tautologico has quit [Ping timeout: 260 seconds]
copy` has quit [Quit: Connection closed for inactivity]
Sorella has quit [Quit: Connection closed for inactivity]
tautologico has joined #ocaml
dhil has quit [Ping timeout: 250 seconds]
A19774941 has joined #ocaml
rgrinberg has joined #ocaml
A1977494 has quit [Ping timeout: 250 seconds]
pyon has quit [Ping timeout: 264 seconds]
nicholas_ has quit [Remote host closed the connection]
ocalm has joined #ocaml
freehck has quit [Remote host closed the connection]
mattrepl has joined #ocaml
ocalm has left #ocaml ["Leaving"]
ocalm has joined #ocaml
sh0t has joined #ocaml
AlexDenisov has joined #ocaml
tizoc has joined #ocaml
pyon has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
FreeBird_ has joined #ocaml
pyon has quit [Read error: Connection reset by peer]
pyon has joined #ocaml
FreeBird_ has quit [Remote host closed the connection]
agarwal1975 has quit [Quit: agarwal1975]
FreeBirdLjj has quit [Ping timeout: 276 seconds]
tautologico has quit [Ping timeout: 244 seconds]
f- has left #ocaml [#ocaml]
<Drup> compilation and instalation in // with opam 2.0 *_*
tautologico has joined #ocaml
ocaml157 has joined #ocaml
fluter has joined #ocaml
ocaml157 has quit [Quit: Page closed]
<zozozo> coool
<zozozo> installing coq will be less of a pain if other packages can be built in //
<companion_cube> it's already built in // ?
<Drup> it already builts in parallel
<Drup> (you can change the amount of parallelism in the file ~/.opam/config)
<companion_cube> so I don't get what's so cool with opam 2.0
<Drup> there is now one action for build and one for install, they are not bundled
<Drup> (and it tracks files that are installed too, which is great)
dhil has joined #ocaml
<companion_cube> yeah, this is much more important
<companion_cube> also I hope it tries to restore old state, now
<companion_cube> it's so annoying when one failure uninstalls a bunch of stuff
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
AlexDenisov has joined #ocaml
Submarine has joined #ocaml
Simn has quit [Read error: Connection reset by peer]
unbalancedparen has joined #ocaml
<companion_cube> oh, seliopou finally released \o/
<companion_cube> (seliopou: btw, what is cstruct used for?)
orbitz_ has quit [Read error: Connection reset by peer]
orbitz has joined #ocaml
beginner has quit [Remote host closed the connection]
Trou has joined #ocaml
jonasen has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tautologico has quit [Ping timeout: 240 seconds]
tautologico has joined #ocaml
_gt has joined #ocaml
_gt has quit [Client Quit]
_gt has joined #ocaml
brub has joined #ocaml
<Trou> hello, I have trouble compiling a caml source into a shared module
A19774941 has quit [Remote host closed the connection]
<Trou> once built, my .so has missing symbols
<Trou> undefined symbol: caml_int_of_string
<Trou> the .so doesn't depend on any caml runtime .so
<seliopou> companion_cube: :D
<seliopou> cstruct is basically there for efficient memcpy
<companion_cube> why not use bigarray?
<seliopou> because it doesn't have an efficient memcpy :)
<seliopou> (last i checked)
<seliopou> I think this only really matters for the buffered interface
<companion_cube> oh
<companion_cube> Bigarray.blit isn't memcpy?
<companion_cube> it's written in C, I thought it was memcpy
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
AlexDenisov has joined #ocaml
AlexDenisov has quit [Client Quit]
<ggole> It's memmove plus some checks
<ggole> And a lock
<companion_cube> memmove = memcpy in practice
<companion_cube> so it should be ok?
<ggole> If the other stuff isn't too slow, I would suppose so
<Trou> OK I managed to find what was wrong
<companion_cube> looks fine
<Trou> i needed -output-obj, not -shared
<Trou> and also needed -runtime-variant _pic
gasche` is now known as gasche
tautologico has quit [Ping timeout: 250 seconds]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit []
slash^ has joined #ocaml
<seliopou> companion_cube ggole between strings and bigarrays is what I was contemplating (though was not being clear about)
<companion_cube> and finally you chose cstruct? :D
<companion_cube> (if I wrote bindings for D, I would call them Dstruct)
dexterph has quit [Ping timeout: 276 seconds]
yomimono has quit [Ping timeout: 240 seconds]
tane has joined #ocaml
Trou has left #ocaml [#ocaml]
maufred_ has joined #ocaml
martinkl_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
zapu has joined #ocaml
maufred has quit [Ping timeout: 272 seconds]
vishesh has quit [Ping timeout: 272 seconds]
zapus has quit [Ping timeout: 272 seconds]
<seliopou> haha
<seliopou> companion_cube it's what was convenient. not married to it but would like a fast copy between strings and bigarrays
dhil has quit [Ping timeout: 240 seconds]
copy` has joined #ocaml
slash^ has quit [*.net *.split]
silver has quit [*.net *.split]
sepp2k has quit [*.net *.split]
dmbaturin has quit [*.net *.split]
AltGr has quit [*.net *.split]
jjk has quit [*.net *.split]
adi___ has quit [*.net *.split]
bronsen has quit [*.net *.split]
maurer has quit [*.net *.split]
hannes has quit [*.net *.split]
nzyuzin has quit [*.net *.split]
smondet has quit [*.net *.split]
Madars has quit [*.net *.split]
srax has quit [*.net *.split]
Drup has quit [*.net *.split]
dinosaure has quit [*.net *.split]
<companion_cube> yeah yeah, I just don't really get why cstruct is more convenient than bigarray
<seliopou> convenient and _fast_ :)
<seliopou> i have the need... the need... for speed :D
nzyuzin has joined #ocaml
hannes has joined #ocaml
smondet has joined #ocaml
dmbaturin has joined #ocaml
srax has joined #ocaml
Drup has joined #ocaml
dinosaure has joined #ocaml
jjk has joined #ocaml
adi___ has joined #ocaml
sepp2k has joined #ocaml
maurer has joined #ocaml
Madars has joined #ocaml
bronsen has joined #ocaml
slash^ has joined #ocaml
<tormen> hmm. yojson of a hashtable... I found this : https://stackoverflow.com/questions/28994718/defining-a-type-alias-for-hash-table-in-ocaml ... but it uses a Table_j and I don't see where it is defined / comes from... so not sure how to translate that ;)
<tormen> ... plus I don't know atd :/
Submarine has quit [Ping timeout: 276 seconds]
<tormen> atd: okey : Atdgen is a command-line program that takes as input type definitions in the ATD syntax and produces OCaml code suitable for data serialization and deserialization.
mcspud has quit [Ping timeout: 250 seconds]
vishesh has joined #ocaml
<tormen> hmm. for now I only use yojson. but I guess at this point I'll have to add atdgen ... ?
<companion_cube> seliopou: not but really, I still don't get it, why would cstruct be faster than bigarray ?!
<companion_cube> doesn't cstruct rely on bigarray?
<seliopou> Ohhh sorry i thought we were doing a thing... 1 sec
mcspud has joined #ocaml
<companion_cube> hmm ok
<companion_cube> it seems very ugly to rely on string's internal representation, but why not
tane has quit [Quit: Leaving]
<seliopou> :D
<Drup> seliopou: hum, how do you do for jsoo ?
<seliopou> cstruct has a little stub file that you need to know to include to get that working
<seliopou> admittedly not ideal, but possible
<companion_cube> what bothers me is that cstruct is a thin layer above char bigarray, except it pulls lots of depdendencies with it
<seliopou> really? isn't it just ocplib-endian?
<companion_cube> & sexplib
<seliopou> oh yeah well :/
<companion_cube> (oh, ocplib-endian doesn't need ocpbuild, nice)
<companion_cube> & depopt on ppx_tools -_-
<seliopou> i have a dep on ocplib-endian anyways so that's not a big deal
<seliopou> but sexplib yes would be better to... not have that
<companion_cube> it's not in your opam f ile then
<seliopou> ugh, relying on transitive dep
<companion_cube> ugh indeed
<seliopou> i'll fix that for next release
<seliopou> thanks
<Drup> companion_cube: what's the issue with depopts on ppx_tools ?
<companion_cube> annoying recompilation?
<Drup> (it should be (ppx_tools | base_no_ppx), though
<companion_cube> also, ppx cancer
<Drup> eh, I see
Submarine has joined #ocaml
<Drup> have you looked at the ppx extension or is it just random bunzliesque argumentation ?
<Drup> (don't bother answering, I already know it's the later :p)
<companion_cube> sure
<companion_cube> I think it would actually be nice if ppx extensions were separated from the base package
Algebr` has joined #ocaml
<Drup> having a depopts is pretty much equivalent, but it allows to have a unified ocamlfind package
_andre has joined #ocaml
<tormen> okey atdgen -j creates the Table_j ;) ... atdgen seems nice :)
<_andre> hi
<_andre> does anyone have an example of converting a char** to a string array using Ctypes?
mcspud has quit [Ping timeout: 250 seconds]
larhat has quit [Quit: Leaving.]
jwatzman|work has quit [Ping timeout: 250 seconds]
mcspud has joined #ocaml
tane has joined #ocaml
sepp2k has quit [Quit: Leaving.]
rgrinberg has quit [Ping timeout: 250 seconds]
silver has joined #ocaml
Submarine has quit [Ping timeout: 244 seconds]
Submarine has joined #ocaml
rgrinberg has joined #ocaml
AlexRussia has quit [Ping timeout: 252 seconds]
A1977494 has joined #ocaml
dave24 has quit [Quit: leaving]
shinnya has joined #ocaml
sdothum has quit [Quit: ZNC - 1.6.0 - http://znc.in]
sdothum has joined #ocaml
_gt has quit [Quit: leaving]
tmtwd has joined #ocaml
A1977494 has quit [Quit: Leaving.]
<tormen> Hmmm. Yesterday I talked about my pg_enum implementation: a postgresql enumeration represented by a corresponding ocaml variant type. with an "umbrella" variant type I can write a pgenum_to_int32 function but for the int32_to_pgenum version I have the problem that the output type of the function changes depending on the enum ... I have the feeling that there is a way in ocaml to have one function being able
<tormen> to return either variant type a or b or c... but how ? :(
<tormen> ... for now I have one function int_to_pgenum per pg_enum type but it would be great to have a universal function :))
<tormen> Could someone point me in the right "type thingy" direction ?
<Drup> what does pgenum look like ?
jlouis has joined #ocaml
jlouis has quit [Client Quit]
jlouis has joined #ocaml
darkf has quit [Read error: Connection reset by peer]
darkf has joined #ocaml
kushal has quit [Ping timeout: 264 seconds]
<tormen> Drup: for instance: type company_legal_form = Sas |Sarl |Ltd |GmbH and other_enum = |A |B |C ... and then the umbrella type pgenum = Company_Legal_Form of company_legal_form | Foo of other_enum
<tormen> so for now I have pgenum_to_int : pgenum -> int and then
<tormen> int_to_company_legal_form int -> company_legal_form and int_to_other_enum : int -> other_enum... :(
<Algebr`> Drup: how can you use Js.wrap_callback with functions that use ?arg , example fun ?a b ->
<tormen> ... I also have the same problem when unwrapping different result-types grouped together with a Result_type umbrella variant... for now I have one "unpack" function per result type... :(
<Drup> Algebr: how would it behave on the js side ? match on the arity ?
<tormen> Drup ... but I guess I am doing so many things wrong that you don't even know where to start ;)
<Algebr`> ah, its fine, got aorund it
<Algebr`> oh what an annoyance
<Algebr`> -a doesn't work if a is bound to a float
<Algebr`> ah, but -. does
tmtwd has quit [Ping timeout: 252 seconds]
<Algebr`> duh
<tormen> ... I guess these are cases where you need to define a function with a type variable of some sort that parametrizes the return value ? and then you call the function with the return type you need ?? ... something along these lines ?
<tormen> I have another case where I would like to write a function like : lst_of_pairs_to_hashtbl lst : ('a*'b) list -> ('a, 'b) Hashtbl.t ... so again the output type needs to vary ... the function logic not.
<flux> tormen, well, you can annotate your fnctions if that's what you mean, like let foo : 'a -> 'a = fun i -> i
<flux> or you can annotate the variables in the pattern match: let foo (i : 'a) : 'a = i
<flux> tormen, but you don't _need_ to define it in this case
seangrove has joined #ocaml
<flux> tormen, because let foo i = i just works(TM)
<tormen> flux: for now I am only able to write: lst_of_int_string_pairs_to_hashtbl lst = let x : (int, string) Hashtbl.t = Hashtbl.create ...
<flux> you only _need_ to define it if you want to make it more strict than what the type inference by default would permit
<tormen> but there is probably a way to write a generic function lst_of_pairs_to_hashtbl : ... no ?
<flux> sure..
<tormen> how ??? booooohoooooo ... I am soooo curious ... but can't put it together :(
<flux> let hashtbl_of_list kvs = let hashtbl = Hashtbl.create 10 in List.iter (fun (k, v) -> Hashtbl.add hashtbl k v) kvs; hashtbl
darkf has quit [Quit: Leaving]
<tormen> ahhh *darn* ... you don't NEED to define the type of the hashtbl of course as it gets deducted...
<tormen> ... pfff sorry for this really stupid question :(
<flux> not really that stupid, it's part of the learning process ;-)
<tormen> flux: but ... my other problem where I have type pgenum = |A of type a |B of type b and type a = |Enum_item_a_1 |Enum_item_a_2 ... same for type b
<tormen> and I want to write ONE function that can EITHER return type a or type b ... is that possible ?
<tormen> flux: thanks :))) you are too kind!!!
<flux> well, it is possible to have a function that has its return type depend on its argument value, with GADTs, but that's an advanced subject and probably not relevant
<flux> it seems you would just write a function that returns A (type a) or B (type b), so the type is always the same
<Drup> tormen: what's your end goal ? Being able to translate anything to an int to be able to fit it in the postgre database ?
<tormen> ... having too many years in my life wrote SHELL scripts and PYTHON scripts ... my mind is POISENED with non-typed way of programming. I really, really appologize for these shortcomings !! But all the more GLAD and THANKFUL for any assistance in overcoming these limitations in my BRAIN ^^
<Algebr`> yay
<tormen> s/wrote/written/
<tormen> Drup: endgoal: postgres stores int. in ocaml I want to use typed Variants representing the different int values.
<tormen> Drup: then I want int_to_pgenum pgenum_to_int ... the latter is fine using an "umbrella Variant" that regroups my different enum variant types
<tormen> but the former... ?? for now I have one function for pgenum type which feels extremely wrong
<Algebr`> Drup:
<tormen> (and each int value represents one item in the enumeration)
<Algebr`> How can I get that feature of the ocaml top level js_of_ocaml where it shows the generated JS
<Algebr`> takes an OCaml phrase and gives back the entire compiled JS, I want that.
<zozozo> Isn't there a ppx that generates to_int/from_int functions for argumentless variants ?
<tormen> flux: but I think that is basically what I want something like : "int_to_pgenum <target-type> <int>"....
<tormen> so <target-type> being used as parameter ... but then I still don't know how to access the variants of <target-type> ((to then get to the corresponding int values))...
<tormen> Drup: if you could tell me if what I want to achieve is possible and maybe provide me the keyword(s) then I would be really glad ... (see my end-goal description :))
<tormen> ... as variants are meant to group together different types it seems a natural problem to want to unwrap / unpack these variants to get to the different types again...
<tormen> but the only way I know to do that is one unwrap function per variant...
<tormen> (to me that feels like the same problem but from a slightly different perspective ... than my pgenum problem)
<zozozo> tormen: one function per type would be the usual solution
<tormen> okey... really ? seems so ... cumbersome to write unpack_A = function | A x -> x | _ -> failwith "boohoo" ;; unpack_B = function | B x -> x | _ -> failwith "boohoo again" ;; ??
kakadu has quit [Quit: Page closed]
<tormen> s/seems/it seems/
<tormen> zozozo: I guess I am missing a big big elephant in the room somewhere ... dunno ... ;)
dhil has joined #ocaml
<zozozo> Usually you would rather write function A x -> do_something_a x | B x -> do_something_b x
<zozozo> Because if you have too many failwith, it usually means there's something wrong
<tormen> zozozo: ahhh yes so more unpack f = function |A a -> f a |B b -> f b ? ... but then again that is not possible because f can't take a AND b as input...
<zozozo> Well actually, it looks more like a pack function than unpack, and I'd say use something like function A x -> pack_a x | B x -> pack_b x
<tormen> zozozo: in my case I use the variant as a way to regroup different result types. I do that in order to be able to have COMMON functions being able to do common things on all results
rgrinberg has quit [Ping timeout: 258 seconds]
<tormen> ... but then at some point I need the actual results again ... so I need my unpack_A, unpack_B functions like I described them ... at least I think I need them ;)
<zozozo> If your results have different types, then it's probable you need different functions to analyse them I'd say
<zozozo> So maybe define only one result type ?
<tormen> zozozo: I kind of have ONE result type thats my type results = |Result_type_A of type_a |Result_type_B of type_b variant...
<tormen> but as I want to do some COMMON stuff on all results (like logging) I pass the results via the variant to my common-functions and afterwards need to unpack the results again...
dhil has quit [Ping timeout: 264 seconds]
<tormen> wrong approach ?
ggole_ has joined #ocaml
ggole has quit [Ping timeout: 250 seconds]
<tormen> flux: Thanks a lot !!! - Same goes to zozozo and Drup :)))
<Algebr`> getting so much trouble with gadts and lists
<Algebr`> I want to do list.map over a list of GADT constructors
<Algebr`> but keep getting compiler errors of expressions having less general type sigantures
<mrvn> annotate all GADTs
<ggole_> Algebr`: sometimes using GADTs require functions passed as arguments be polymorphic
<ggole_> Since arguments cannot be polymorphic in OCaml, you typically need to introduce a record/object with polymorphic field as a workaround.
<Algebr`> i did annonate it but I must have screwed up the annotations
jonasen has joined #ocaml
octachron has joined #ocaml
rgrinberg has joined #ocaml
MercurialAlchemi has joined #ocaml
ocalm has quit [Ping timeout: 260 seconds]
<mrvn> ggole_: I don't see that happening. With a GADT ocaml knows the type inside a GADT so no polymorphism is needed. It just doesn't infer the type of GADTs on it's on.
<mrvn> s/on/own/
<mrvn> Algebr`: did you annotate as: type a . ...?
<Algebr`> yea, oddly enough rearranging some things helped the type checker and I'm getting the correct inference now without hand holding
<Algebr`> okay awesome.
<Algebr`> if you use oasis dynamic and opam pin http then it craps out
<Algebr`> with cannot find _oasis find
<Algebr`> not sure whose's fault this lies with, oasis or opam
<ggole_> mrvn: type t = Wrap : 'a s -> t and then fun f -> function (Wrap a) -> Wrap (f a): it won't type check
<ggole_> Use a polymorphic wrapper for f and it will
<ggole_> This turns up sometimes writing higher order operations on GADT aware data structures
<mrvn> because a is unbound
<mrvn> type wise
<mrvn> ggole_: Your t is universal so you can only use it with polymorphic functions in this case. No type information in the GADT
<ggole_> It's an 'a s. Useful functions could be written over it, depending on the definition of s.
<ggole_> eg, type 'a s = B : bool -> bool s | I : int -> int s and then it's quite easy to write a function that increments an int and negates a bool.
Sorella has joined #ocaml
<mrvn> ggole_: Usualy you have something like type _ t = Int : int -> int t. Then when you match the Int ocaml knows the content is an int.
<mrvn> or your example.
<mrvn> So you have an universal box containing a typed box. That measn your f must accept a GADT.
<ggole_> That's what such data structures are usually used for, yes.
nicholasf has joined #ocaml
<ggole_> But the type that it accepts doesn't have to be known.
zv has quit [Quit: WeeChat 1.5]
<mrvn> let (wrap : type a . (a s -> a s) -> t -> t) = fun f (Warp a) -> Wrap (f a) ?
<ggole_> Try it.
<ggole_> (You tend to get really great, really easy to understand error messages doing this stuff.)
<mrvn> # let wrap : type a . (a s -> a s) -> t -> t = fun f (Wrap a) -> Wrap (f a);;
<mrvn> Error: This expression has type a#0 s but an expression was expected of type
<mrvn> a s
<mrvn> Type a#0 is not compatible with type a
<ggole_> mrvn: right. Now, how would you change this to make it type check?
AlexDenisov has joined #ocaml
<flux> tormen, btw, while I'm not saying this is the preferred way of dealing with it, this is also possible: type _ typ = Int : int typ | Float : float typ let mk (type t) (typ : t typ) (x : t) = match typ with Int -> string_of_int x | Float -> string_of_float x
<mrvn> ggole_: problem is you can't specify f in ocamls type system: let f : type a . a s -> a s = function | B b -> B b | I i -> I i;; val f : 'a s -> 'a s = <fun>
<mrvn> ggole_: it lost the type a
<mrvn> ggole_: I think in this case you are right, you have to use a record or object.
<mrvn> universal GADTs are a big pain to write
<ggole_> Yeah. With proper rank-n types you could at least just use an annotation.
kakadu has joined #ocaml
Orion3k has quit [Ping timeout: 276 seconds]
kakadu has quit [Remote host closed the connection]
kakadu has joined #ocaml
Orion3k has joined #ocaml
octachron_ has joined #ocaml
octachron_ has quit [Client Quit]
octachron has quit [Ping timeout: 276 seconds]
tmtwd has joined #ocaml
seangrove has quit [Ping timeout: 252 seconds]
gasche has quit [Ping timeout: 252 seconds]
martinkl_ has joined #ocaml
gasche has joined #ocaml
jonasen has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
rand__ has joined #ocaml
_andre has quit [Quit: \]
martinkl_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
martinkl_ has joined #ocaml
tautologico has joined #ocaml
martinkl_ has quit [Client Quit]
Orion3k has quit [Ping timeout: 276 seconds]
seangrove has joined #ocaml
ollehar has joined #ocaml
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
fraggle_ has quit [Remote host closed the connection]
Orion3k has joined #ocaml
fraggle_ has joined #ocaml
<Algebr`> yessss, got the GADT to work
<Algebr`> fantastic, such power
<Algebr`> rather, expressiveness
AlexDenisov has joined #ocaml
<Drup> such power, much expressiveness, very type. :3
Orion3k has quit [Max SendQ exceeded]
orbifx1 has joined #ocaml
slash^ has quit [Read error: Connection reset by peer]
Orion3k has joined #ocaml
tautologico has quit [Ping timeout: 260 seconds]
Orion3k has quit [Ping timeout: 264 seconds]
martinkl_ has joined #ocaml
hongbo has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
tmtwd has quit [Ping timeout: 252 seconds]
unbalancedparen has quit [Quit: WeeChat 1.5]
martinkl_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Orion3k has joined #ocaml
Orion3k has quit [Ping timeout: 276 seconds]
ggole_ has quit []
Reventlov has quit [Quit: leaving]
MercurialAlchemi has quit [Ping timeout: 260 seconds]
jackweirdy has joined #ocaml
Algebr` has quit [Ping timeout: 250 seconds]
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
nicholasf has quit [Remote host closed the connection]
shinnya has quit [Ping timeout: 250 seconds]
tautologico has joined #ocaml
Guest94180 has joined #ocaml
Guest94180 has quit [Client Quit]
brub has quit [Remote host closed the connection]
martinkl_ has joined #ocaml
govg has quit [Ping timeout: 276 seconds]
govg has joined #ocaml
<flux> is there a plain old file server for cohttp, it doesn't seem to come with one? one supporting ranges?
martinkl_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tautologico has quit [Ping timeout: 250 seconds]
martinkl_ has joined #ocaml
tane has quit [Quit: Leaving]
martinkl_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<rgrinberg> flux: you would have to build something like that yourself. on top of cohttp of course if you'd like
<flux> seems so
rand__ has quit [Quit: leaving]
al-damiri has quit [Quit: Connection closed for inactivity]
Algebr` has joined #ocaml
jackweirdy has quit [Quit: Textual IRC Client: www.textualapp.com]
madroach has quit [Ping timeout: 244 seconds]
kakadu has quit [Remote host closed the connection]
madroach has joined #ocaml
nicholasf has joined #ocaml
Algebr` has quit [Ping timeout: 265 seconds]