jonasen_ has quit [Read error: Connection reset by peer]
shinnya has quit [Ping timeout: 240 seconds]
jonasen has joined #ocaml
dhil has joined #ocaml
<thizanne>
http://paste.awesom.eu/thizanne/oYw3 does someone here have an explanation for the value of `b` ? (keywords: extensible variants, or-patterns)
<thizanne>
(it works as intended if t is a usual sum type)
<Drup>
thizanne: bug report
<Drup>
that's just buggy
mengu_ has quit [Remote host closed the connection]
freusque has quit [Quit: WeeChat 1.7.1]
FreeBirdLjj has joined #ocaml
dhil has quit [Ping timeout: 260 seconds]
mengu has joined #ocaml
wtetzner has joined #ocaml
mengu has quit [Ping timeout: 248 seconds]
MercurialAlchemi has quit [Ping timeout: 246 seconds]
Guest64795 has joined #ocaml
Guest64795 has quit [Client Quit]
fraya has joined #ocaml
zmt00 has joined #ocaml
lostman has joined #ocaml
<lostman>
how can I write a function that takes some Map module from int to string? I essentially want to abstract over the ordering I created the map with. Can't quite figure it out
mengu has joined #ocaml
dhil has joined #ocaml
mengu has quit [Ping timeout: 246 seconds]
shiyas has quit [Ping timeout: 246 seconds]
fraya has quit [Quit: Leaving]
AltGr has left #ocaml [#ocaml]
mengu has joined #ocaml
jbrown has joined #ocaml
mengu has quit [Ping timeout: 260 seconds]
dhil has quit [Ping timeout: 248 seconds]
zolk3ri has quit [Ping timeout: 246 seconds]
<Denommus>
lostman: do you know how functors work?
dhil has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
zolk3ri has joined #ocaml
jonasen has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<lostman>
Denommus: yeah
<lostman>
should be something like let f (module M: Map.S with type key = float and type t = ???) = ..., right?
<lostman>
what does type (+'a) t mean?
<lostman>
saw that in definition of Map
<Drup>
you don't have to add any typing equality of M.t, if you want to abstract over it, it should stay .. abstract
shinnya has joined #ocaml
<Denommus>
lostman: no
<Denommus>
lostman: it would be something like module Foo(M: SOME_SIGNATURE) = struct ... end
<Denommus>
lostman: the SOME_SIGNATURE describes a module that contains the ordering function you want. Then, inside Foo, you'd have your function
<Denommus>
that can use M.your_ordering_function
<octachron>
lostman, +'a t means that t is covariant in its first parameter
<octachron>
also another option may be to use first-class module "let f (type a) (module M: Map.S with type key = a) = … "
<Denommus>
lostman: while passing a module to a function is possible (because OCaml is powerful af), it's usually not what you really want. What you usually want is a functor
<Denommus>
octachron: no, that makes things overly complicated -.-
jnavila has joined #ocaml
<Drup>
Denommus: It depends
FreeBirdLjj has joined #ocaml
jonasen has joined #ocaml
<Denommus>
Drup: I think the case for first-class modules are for heterogeneous data structures, which is not the case
<Denommus>
and even then you might model your problem in such a way that you don't need them
shinnya has quit [Ping timeout: 240 seconds]
<Drup>
You always can
<Drup>
it depends which kind of flexibility you want
tane has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 248 seconds]
jonasen has quit [Client Quit]
<octachron>
Denommus, functors are both more powerful and more syntactically clunky than first-class modules, so first-class modules may be a better fit than functors in specific context
FreeBirdLjj has joined #ocaml
jonasen has joined #ocaml
Anarchos has joined #ocaml
jnavila has quit [Ping timeout: 240 seconds]
frefity has quit [Quit: Ex-Chat]
<lostman>
but I already minted two different maps: M1 and M2 and now I just want to apply same functions to both of those. wouldn't first class modules be better here than functors? is something like this possible: let f (type a) (module M: Map.S with type key = int) k v x = M.add k v x;;
<lostman>
this throws an error `The type constructor M.t would escape its scope`
<Drup>
lostman: what do you want to implement ?
<Denommus>
lostman: can you show us a snippet?
kakadu has quit [Quit: Konversation terminated!]
wtetzner has quit [Ping timeout: 248 seconds]
<lostman>
Drup: I have two maps, `string IntMapAsc.t` and `string IntMapDesc.t` and want to write a function that iterates over them and produces a list
<Drup>
lostman: write your iteration function over iterators like sequence and then just plugin in IntMapX.iter when you glue things together
<Drup>
sometimes, good old high order functions are all that you need ;)
<lostman>
Drup: I'm messing with React and Reason and the stdlib is rather thin. I don't see anything resembling iterators
<Drup>
(you don't actually need the sequence library, but it makes things so much easier and it works everywhere, so no reason not to :)
jnavila has joined #ocaml
<Drup>
The idea is just to abstract away the map, and just work on iterators
<lostman>
Drup: ah, I see now how it works. Should do the trick. I'm just sad this didn't work: `let f (module M: Map.S with type key = int) m = M.map (fun k v -> string_of_int k ^ v) m |> M.bindings |> List.map snd;;`
mk9_ has joined #ocaml
<Drup>
You can't really write that, yeah
<Drup>
(try to write the type this would have, you will see why)
lgd_ has joined #ocaml
<Drup>
btw, you shouldn't map on Maps like that, just write a fold, it's much more efficient
jnavila has quit [Ping timeout: 258 seconds]
lgd has quit [Ping timeout: 240 seconds]
dhil has quit [Ping timeout: 240 seconds]
samrat has quit [Ping timeout: 258 seconds]
jnavila has joined #ocaml
kakadu has joined #ocaml
Algebr has joined #ocaml
kakadu_ has joined #ocaml
kakadu has quit [Ping timeout: 240 seconds]
mk9_ has quit [Quit: mk9_]
jonasen has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
enterprisey has joined #ocaml
ygrek_ has joined #ocaml
kerrhau has joined #ocaml
kerrhau has joined #ocaml
kerrhau has quit [Changing host]
tane has quit [Quit: Leaving]
enterprisey has quit [Remote host closed the connection]
kerrhau has quit [Ping timeout: 248 seconds]
kerrhau has joined #ocaml
kerrhau has quit [Changing host]
kerrhau has joined #ocaml
_andre has quit [Quit: leaving]
enterprisey has joined #ocaml
shinnya has joined #ocaml
sepp2k has quit [Quit: Leaving.]
Algebr has quit [Remote host closed the connection]
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
Guest12513 has joined #ocaml
Guest12513 has quit [Remote host closed the connection]
KongWubba has joined #ocaml
<orbifx[m]>
Is the a library for writing system related programs (making directories, calling other programs etc), in a function way?