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
nicholasf has quit [Remote host closed the connection]
sepp2k has quit [Quit: Leaving.]
tautologico has quit [Ping timeout: 260 seconds]
nicholasf has joined #ocaml
hugomg has joined #ocaml
<hugomg> Hi there, I need to flatten a big tree data-structure I have into a sequential list of elements. What data structure should I use for the output? In Python I would use generators for this because yielding is O(1) and it would let me lazily stream the data so I don't need to hold everything in memory. However, I dunno what would be the best choice in Ocaml because there isn't something equivalent to generators or coroutines AFAIK...
tautologico has joined #ocaml
<Drup> hugomg: companion_cube's sequence library
<Drup> (for that specific use case, it's the most efficient, by a lot)
Guest60744 is now known as kandu
<hugomg> thanks! Looking at Containser.sequence it looks doesn't do the "lazy streaming" that I wanted but it appends things in O(1) which should be good enough :)
<Drup> hugomg: most importantly, flatmap/concat are extremely efficient
nicholasf has quit [Read error: Connection reset by peer]
nicholasf has joined #ocaml
groovy2shoes has quit [Quit: Leaving]
groovy2shoes has joined #ocaml
Algebr`` has quit [Ping timeout: 252 seconds]
pierpa has quit [Ping timeout: 240 seconds]
Algebr`` has joined #ocaml
Algebr`` has quit [Remote host closed the connection]
Algebr`` has joined #ocaml
hugomg has quit [Quit: Ex-Chat]
FreeBirdLjj has joined #ocaml
Algebr`` has quit [Ping timeout: 250 seconds]
sh0t has joined #ocaml
tautologico has quit [Ping timeout: 250 seconds]
govg has quit [Ping timeout: 240 seconds]
tautologico has joined #ocaml
picolino has quit [Ping timeout: 240 seconds]
picolino has joined #ocaml
rgrinberg has quit [Ping timeout: 240 seconds]
picolino has quit [Ping timeout: 252 seconds]
picolino has joined #ocaml
ygrek_ has quit [Ping timeout: 276 seconds]
tmtwd has joined #ocaml
rgrinberg has joined #ocaml
pyon has quit [Quit: fix config]
pyon has joined #ocaml
tautologico has quit [Ping timeout: 244 seconds]
govg has joined #ocaml
kushal has joined #ocaml
nicholasf has quit [Ping timeout: 260 seconds]
nicholasf has joined #ocaml
nicholas_ has joined #ocaml
tmtwd has quit [Ping timeout: 258 seconds]
FreeBirdLjj has quit [Remote host closed the connection]
tmtwd has joined #ocaml
FreeBirdLjj has joined #ocaml
nicholasf has quit [Ping timeout: 250 seconds]
nicholasf has joined #ocaml
nicholas_ has quit [Ping timeout: 260 seconds]
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
sdothum has quit [Quit: ZNC - 1.6.0 - http://znc.in]
rgrinberg has quit [Ping timeout: 260 seconds]
tautologico has joined #ocaml
AlexDenisov has joined #ocaml
sh0t has quit [Read error: Connection reset by peer]
struk|desk has joined #ocaml
tmtwd has quit [Ping timeout: 244 seconds]
kushal has quit [Read error: Connection reset by peer]
FreeBirdLjj has quit [Read error: Connection reset by peer]
jonasen has joined #ocaml
FreeBirdLjj has joined #ocaml
kdas__ has joined #ocaml
kdas__ has quit [Ping timeout: 250 seconds]
copy` has quit [Quit: Connection closed for inactivity]
tmtwd has joined #ocaml
tmtwd has quit [Ping timeout: 250 seconds]
tautologico has quit [Ping timeout: 240 seconds]
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
tmtwd has joined #ocaml
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
jjk has quit [Ping timeout: 258 seconds]
jjk has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
MercurialAlchemi has joined #ocaml
A1977494 has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
nicholas_ has joined #ocaml
nicholasf has quit [Ping timeout: 240 seconds]
tmtwd has quit [Ping timeout: 244 seconds]
nicholasf has joined #ocaml
AlexDenisov has joined #ocaml
nicholas_ has quit [Ping timeout: 264 seconds]
Simn has joined #ocaml
ygrek_ has joined #ocaml
MercurialAlchemi has quit [Remote host closed the connection]
nicholasf has quit [Ping timeout: 240 seconds]
nicholas_ has joined #ocaml
dexterph has joined #ocaml
kushal has joined #ocaml
nicholas_ has quit [Remote host closed the connection]
ggole has joined #ocaml
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
AlexDenisov has joined #ocaml
dave24 has joined #ocaml
AltGr has joined #ocaml
nicholasf has joined #ocaml
ygrek_ has quit [Ping timeout: 244 seconds]
rand__ has joined #ocaml
nicholasf has quit [Read error: Connection reset by peer]
nicholasf has joined #ocaml
orbitz_ has joined #ocaml
orbitz has quit [Read error: Connection reset by peer]
kdas__ has joined #ocaml
kushal has quit [Ping timeout: 250 seconds]
kdas__ is now known as kushal
kushal has quit [Changing host]
kushal has joined #ocaml
nicholasf has quit [Remote host closed the connection]
silver has joined #ocaml
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
jwatzman|work has joined #ocaml
AlexDenisov has joined #ocaml
dhil has joined #ocaml
freehck has quit [Remote host closed the connection]
sdothum has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
nicholasf has joined #ocaml
kushal has quit [Ping timeout: 276 seconds]
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
nicholasf has quit [Ping timeout: 250 seconds]
kushal has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
mquin is now known as ISO3103
ISO3103 is now known as mquin
freehck has joined #ocaml
larhat has joined #ocaml
wolfcore has quit [Ping timeout: 244 seconds]
brub has joined #ocaml
teiresias has quit [Ping timeout: 244 seconds]
wolfcore has joined #ocaml
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tautologico has joined #ocaml
larhat has quit [Read error: Connection reset by peer]
larhat has joined #ocaml
wolfcore has quit [Ping timeout: 260 seconds]
wolfcore has joined #ocaml
copy` has joined #ocaml
tautologico has quit [Ping timeout: 264 seconds]
f- has quit [Ping timeout: 272 seconds]
f- has joined #ocaml
yomimono has joined #ocaml
AlexRussia has quit [Ping timeout: 250 seconds]
troydm has quit [Ping timeout: 244 seconds]
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
srcerer has quit [Ping timeout: 258 seconds]
srcerer has joined #ocaml
rgrinberg has joined #ocaml
larhat has quit [Read error: Connection reset by peer]
AlexRussia has joined #ocaml
malc_ has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
AlexDenisov has joined #ocaml
AlexDenisov has quit [Client Quit]
AlexDenisov has joined #ocaml
A19774941 has joined #ocaml
A1977494 has quit [Ping timeout: 258 seconds]
dhil has quit [Ping timeout: 276 seconds]
sh0t has joined #ocaml
<adrien> seliopou: hey, after seeing yet more mentions of stuff similar to Intel's DPDK (i.e. taking away the control of a network adapter and giving it entirely and directly to a userland application), I've started to wonder if the same existed for ocaml and mirage
<adrien> especially with zero-copy operations
<adrien> re-inventing the wheel feels much safer when it's done with ocaml
dhil has joined #ocaml
<seliopou> adrien: i know that mirage has its own tcp stack (https://github.com/mirage/mirage-tcpip) though I'm not sure about the details of how it does its io
<yomimono> adrien: not sure how close this is to dpdk, but it's possible to have Xen give access to a network adapter (via PV) to the unikernel
<yomimono> not sure how this works in the solo5 case -- djwillia or mato could tell you, though
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
FreeBird_ has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 244 seconds]
FreeBird_ has quit [Ping timeout: 244 seconds]
larhat has joined #ocaml
pierpa has joined #ocaml
unbalancedparen has joined #ocaml
<Drup> Algebr: should I make my comment about your jsoo blog post here ?
<Drup> Because there are things dangerously wrong in it.
<Drup> Ok, you say some stuff about nullability at the end
<Drup> your approach is a big unsafe hack, though, you really shouldn't check for nullability that way. nullability tracked by the typesystem is a good thing, not a thing that should be walked around
<Drup> the fact that you wroten __hidden__ with a raw js exp, instead of using jsoo's record building syntax is a huge hint that the type is wrong.
rand__ has quit [Quit: leaving]
<Drup> (honestly though, you should just pick a better example)
tane has joined #ocaml
dhil has quit [Ping timeout: 272 seconds]
<tormen> L
<tormen> oops
<yomimono> loops!
<tormen> :D Let's say you have 10 variables v1...v10 and you want to apply the same function fn to all of them ... can you somehow do something like [v1;v2;..;v10] = List.map [v1;v2;...;v10] fn
<tormen> or does one have to write let v1 = fn v1 in let v2 = fn v2 ... ?
<zozozo> tormen: List.map fn [v1; ...]
<zozozo> will yield [ fn v1; ... ; fn v10 ]
<tormen> yes, but as I said, I have tuple with 10 variables, so I have 10 variables so I need not a list with all of them packed.... :(
<zozozo> a tuple or a list ?
<tormen> zozozo: 10 variables
<zozozo> do you want to keep the result of the funciton application ?
<tormen> zozozo: but the reason I have 10 variables in the first place is because they come from a database row from pg_enum (so from a tuple)
<tormen> I am in the to_string function to print the database row
<tormen> and want to apply a transformation function on 10 entries of my row
<malc_> tormen: put another way you want to iterated over a elements of a tuple, right?
<tormen> ... I don't like tuples very much ;) ... it would be so cool to map a function over a tuple ... but I guess I am missing the big picture
<tormen> malc_: ... not ALL of them
<malc_> tormen: first N
<tormen> malc_: because in my database table I only need to touch SOME of the fields to convert them to a string
<tormen> malc_: no... a mix
<malc_> tormen: either way there's no iteration over tuple elements, be it some or all
A19774941 has quit [Quit: Leaving.]
<tormen> ...~.~,\`~.
<tormen> ~
<tormen> ~>
<tormen> arg sorry. tried to kill my ssh connection, but it was still active. Sorry about the noise.
<tormen> (using [enter] ~ .)
<tormen> hmm. it would be useful if ocaml could see that I call List.map with a list of 10 elements and so be happy if I match it to a list of 10 elements... like in : [v1;v2;..;v10] = List.map [v1;v2;...;v10] fn
<tormen> ... but I guess I am missing something big time as to why this is not a good idea or not possible... ;)
<tormen> ... ocaml complained that [] is a pattern not matched by my [v1;....;v10]= ... yes if I would call List.map on a list VARIABLE that would make sense, but here I am calling List.map on a list VALUE of specific 10 elements... ?
<tormen> I see the advantages of strong typing, but have still difficutlties to understand it some times :(
<companion_cube> it's too complicated
<companion_cube> the compiler would have to know that `map` preserves the length
<companion_cube> in general this kind of things is undecidable
<pierpa> the ocaml compiler does not do a whole program analisys, so it cannot know that List.map always returns a list of the same length as its input
<companion_cube> (of course for `map` it's relatively simple, but if you do the same with more complicated calls…)
<tormen> companion_cube: "the compiler would have to know that `map` preserves the length" okey that was the obvious thing I was missing here ;)
<companion_cube> ^^
<tormen> ... yeah okey I get it... ah mince ;)
<companion_cube> yeah, compilation is hard
* Drup whispers to companion_cube: gggaaddttssss
<tormen> ... but it's also just so ugly and cumbersome to write let v1=fn v1 in let v2=fn v2 in let ... let v10=fn v10 ... where this shouts for a "map" sort of solution...
ocaml1012 has joined #ocaml
<companion_cube> Drup: hu
<companion_cube> that would still be so ugly
<companion_cube> I would whisper "dependent types" into your ear, but well
<Drup> actually, in that case, it works.
<tormen> in my ear ?
<tormen> ;)
* tormen is googleing "dependent types"
<companion_cube> in everyone's ear
<ocaml1012> I'm trying ocamlopt.opt for the first time. When I run `ocp-memprof --exec ocamlopt.opt -c myProg.ml` it is very quick (< 1 second). But when I actually compile and run that program, it takes 10 seconds to terminate.
<companion_cube> Drup: but who wants to use GADTs for the length of lists…
<ocaml1012> Is ocamopt.opt actually compiling and running my code?
<companion_cube> it's too close to the fringe of OCaml's typing to be actually usable
<companion_cube> ocaml1012: it only compiles the code
<companion_cube> it doesn't run it
<ocaml1012> companion_cube: thanks. How is it performing memory analysis without running it?
<companion_cube> memory analysis? what do you mean?
<companion_cube> ah, this
<ocaml1012> "Memory profiling of" would suggest some memory profiling?
<companion_cube> this is only done when you run the program
<ocaml1012> companion_cube: I ran `ocp-memprof --exec ocamlopt.opt -c myProg.ml` . It is running my program, or not?
<ocaml1012> Because it takes less than 1 second to finish, whereas compiling with ocamlc and running ./a.out takes about 10 seconds.
<tormen> companion_cube: can you see a way how I can avoid my 10 let vx = fn vx ? (knowing that the 10 variables are some elements of a bigger tuple of fields coming from the database)
<Drup> companion_cube, tormen: http://pastebin.com/AgXRYPfn
<Drup> there you go, no more pesky warning
<Drup> aren't you happy ? :D
<companion_cube> oh wait --exec
<Drup> (works only with 4.03)
jtmcf has quit [Remote host closed the connection]
<companion_cube> ocaml1012: I don't know what ocp-memprof does exactly, sorry
<tormen> Drup: hey cool :))) I am really curious :))
<Drup> (it will be even better with 4.04, with local open in patterns)
<companion_cube> but it's very possible that it's faster than ocamlc, because ocamlopt compiles into native code, whereas ocamlc compiles to bytecode
<companion_cube> Drup: this is cool, but in practice it's pretty useless
<Drup> tormen: be careful with this code, you probably shouldn't use it like that, and certainly not if you don't understand it
<adrien> yomimono, seliopou : thanks, I'll try to dig a bit deeper; I'm also interested in not going through a VM but doing it directly in a linux' userland
jtmcf has joined #ocaml
<adrien> might be simpler to deploy in some places
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<Drup> companion_cube: why useless ? :)
<companion_cube> well, ok, you can write `map`, but not much more
Kakadu has joined #ocaml
<yomimono> adrien: ah, cool; mirage can also run on top of a tap device in linux
<Drup> companion_cube: you can write pp and to_list, that's what tormen needs :p
<companion_cube> tss
<yomimono> no dpdk backend atm though
<dave24> 5
<tormen> Drup: yeah it looks nice :) .... about the understanding ... ;) where do I start reading about GADTs ? http://homepage.cs.uiowa.edu/~astump/papers/icfp09.pdf ?
<Drup> wow, I didn't know that paper
<companion_cube> Drup: anyway, I think OCaml's type system is too limited for such fine grained invariants
<ggole> Why not just use a list, pattern match, and muffle the warning?
<companion_cube> GADTs are nice, but not as a replacement for dependent types
<ggole> I've done this for test code: it works fine
tautologico has joined #ocaml
<tormen> ggole: feels wrong ^^
<Drup> tormen: ok, now, it's not the paper to follow at all
<Drup> no*
<adrien> yomimono: oh, that's really interesting
<tormen> okey.... the title seemed promising ;)
<adrien> yomimono: like very very interesting
<tormen> Drup: any other recommandation ?
<adrien> with one very specific thing in mind :)
<yomimono> adrien: you might want to drop a mail to mirageos-devel with your specific use case if you don't mind sharing it publicly
<yomimono> otherwise I'm happy to chat a bit if you'd rather not share widely :)
<Drup> (side note on the tap device: having good instructions to make it work under linux would be nice, I never managed to do it)
<Drup> (there are instructions for OSX, but not linux)
f- has quit [Ping timeout: 250 seconds]
silver_ has joined #ocaml
<yomimono> (if I knew the answer to this I would write it up)
silver has quit [Ping timeout: 258 seconds]
f- has joined #ocaml
<adrien> yomimono: well, the goal is to make it free software but currently I'd like to keep it for myself until I can play with it a bit :P
<yomimono> :)
<adrien> yomimono: I'll evaluate the whole setup when I have time; thing is, I think that as long as there's an access to a tun, it cannot not work
ocaml1012 has quit [Ping timeout: 250 seconds]
tautologico has quit [Ping timeout: 240 seconds]
butts_butts has joined #ocaml
tautologico has joined #ocaml
baroud has joined #ocaml
dhil has joined #ocaml
<tormen> Drup: hmm. Line 4 of your pastebin: (a) "*" because (::) takes 2 input arguments ? (b) and why does it return -> ('a, unit -> 'r) t (why (unit -> 'r) ??)
<tormen> the "." in the type annotation ": type a b r. (a -> b) -> (a, r) t -> (b, r) t =" means that there are 3 (polymorphic) type variables a,b and r in the expression following the "." ?
darkf has quit [Quit: FREEEEEAKS]
tane has quit [Quit: Verlassend]
<ggole> In type a . foo, the type variable a is locally abstract rather than just polymorphic
dexterph has quit [Ping timeout: 240 seconds]
<tormen> ggole: okey, "locally abstract" vs "polymorphic" ... locally abstract = polymorphic with local, limited scope ?
shinnya has joined #ocaml
<ggole> Basically, you can use them for types that have limited scope, like existentials or types within local modules
<ggole> It's very common to need to use them for programming with GADTS.
<ggole> Note that the type a and . syntax are separate: you can use . syntax to indicate that a regular type variable should be polymorphic
tmtwd has joined #ocaml
<tormen> ggole: hmm. can you give an example of the last part "that a regular type variable should be polymorphic" ?
<tormen> Drup: I guess your pastebin is an example for """Another use of GADTs is singleton types, where a GADT value represents exactly one type. This value can be used as runtime representation for this type, and a function receiving it can have a polytypic behavior.""" ? because that seems like what I want to do ?
<Drup> no, it doesn't have much to do with singleton types, in this case
<tormen> Drup: I thought "a GADT value represents exactly one type" means that the list with 10 elements would become it's own type of a list of 10 elements... and thus map gets this type and returns it (hence the return value of map has 10 elements again) ?
<ggole> tormen: say you wrote let rec f x = x and g () = f 0, f '1' in g (): this doesn't type check because let-rec bound variables are not polymorphic within the bindings (only within the body)
<ggole> You could annotate f with a polymorphic type like this: let rec f : 'a . 'a -> 'a = fun x -> x and g () = f 0, f '1' in g ();;
<ggole> Which does type check.
mattrepl has quit [Quit: mattrepl]
<tormen> ggole: okey. so "'a" is the polymorphic type and if one would write : let rec f : a . a -> a = ... then "a" would be locally abstract ?
tmtwd has quit [Ping timeout: 272 seconds]
butts_butts has quit [Remote host closed the connection]
<ggole> You also need the type keyword: it's either 'a . 'a or type a . a
<ggole> In the second case a is locally abstract
<tormen> ggole: okey, thanks. I just realize that I think I would have written : let rec f : 'a -> 'a = ... or would that not be possible ?
<ggole> That is possible, but doesn't type check: try it
<ggole> It's because 'a without further qualification is a unification variable rather than a rigid variable: it will happily unify with a concrete type
<tormen> hmm. what does that mean "doesn't type check" ? you mean ocaml won't control if it really returns the same type that it got ? (that f really transforms 'a into 'a) ?
<ggole> I mean let rec f : 'a -> 'a = fun x -> x and g () = f 0, f '1' in g () will not type check
agarwal1975 has joined #ocaml
<tormen> s/control/check/
<ggole> The way that type variables work in OCaml is that they are unified, so all 'a are required to be the same
<ggole> But that type doesn't have to be polymorphic (unless you use . )
<ggole> eg, let x : 'a = 0 type checks fine, unifying 'a with the type of 0
MercurialAlchemi has joined #ocaml
<tormen> ah when you say "will not type check" you mean it will fail type checking ?
<ggole> Oh, now I see what you meant. Yes, that is correct.
<tormen> ahhh :) ok ... let me reread ;)
<tormen> Which does type check = Which passes type checking, right ?
<tormen> (just to make sure)
<ggole> Yes
<tormen> hun. so just f : 'a -> 'a = fun x -> x is the "id" function but usable only on ONE type within the module (scope of where f is defined) ?
<tormen> (so only int or only char for instance, but not first int, then char...)
<ggole> No, let bindings are polymorphic within the body of the let
slash^ has joined #ocaml
<ggole> The restriction here is because the use of f is not within the body of the let
kakadu_ has joined #ocaml
govg has quit [Ping timeout: 276 seconds]
kakadu_ has quit [Client Quit]
<tormen> ggole: if you know some place that defines "type variable" "polymorphic type variable" "locally abstract" "existentials" ... I would really be glad to RTFM...
<ggole> There's the manual, but it isn't really easy reading.
<ggole> Maybe RWO?
<ggole> (Which is https://realworldocaml.org/, if you don't know it already.)
kakadu_ has joined #ocaml
<tormen> ggole: I can check if they cover that. I'll read http://caml.inria.fr/pub/docs/manual-ocaml-400/manual021.html#toc80 about locally abstract types ... but what are "existentials" ?
A1977494 has joined #ocaml
<tormen> (ggole: The first 10 chapters don't ;)
<ggole> I can't remember any decent explanation of existentials off the top of my head.
<ggole> I'm sure there are some around, just not that I can put my finger on.
kakadu_ has quit [Ping timeout: 260 seconds]
kakadu_ has joined #ocaml
<tormen> ggole: thanks ! - saved oure discussion that for later follow-up :)
kakadu_ has quit [Client Quit]
AlexDenisov has joined #ocaml
<tormen> Drup: Thanks a lot for the pastebin. Even though I don't understand it, it is really cool to have it ^^
sepp2k has joined #ocaml
<tormen> Drup: what makes it 4.0.3 only ?
<tormen> s/4.0.3/4.03/
<Drup> the fact that it redefines :: and []
<Drup> you can't do that before, you need to use new constructors
<tormen> ah yes ... true :)
jwatzman|work has quit [Quit: jwatzman|work]
<ggole> You can redefine :: in < 4.03
<ggole> It isn't very useful though.
<tormen> I stumbled about this because I wanted to pass (::) as a function which I think you can't before 4.03 ... 4.03 introduces a function for it I think...
mattrepl has joined #ocaml
<tormen> "cons"
<malc_> ggole: how do you redefine it on == 4.03?
<ggole> type useless = ::
<ggole> Oh, wait: 4.03. See Drup's thing.
kakadu_ has joined #ocaml
Simn has quit [Read error: Connection reset by peer]
kakadu_ has quit [Client Quit]
<malc_> my brain hurts
kakadu_ has joined #ocaml
<Drup> malc_: doh :p
kakadu_ has quit [Client Quit]
MercurialAlchemi has quit [Remote host closed the connection]
rgrinberg has quit [Ping timeout: 276 seconds]
<tormen> hm. deriving_joyson does not seem to like 4.03
larhat has quit [Quit: Leaving.]
<tormen> s/_/-/
tautologico has quit [Ping timeout: 240 seconds]
<tormen> malc_: :D
baroud has quit [Ping timeout: 250 seconds]
tautologico has joined #ocaml
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
martinkl_ has joined #ocaml
troydm has joined #ocaml
tautologico has quit [Ping timeout: 244 seconds]
govg has joined #ocaml
agarwal1975 has quit [Ping timeout: 240 seconds]
agarwal1975 has joined #ocaml
jeffmo has joined #ocaml
AlexDenisov has joined #ocaml
rgrinberg has joined #ocaml
Anarchos has joined #ocaml
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Algebr`` has joined #ocaml
yomimono has quit [Ping timeout: 250 seconds]
Simn has joined #ocaml
agarwal1975 has quit [Quit: agarwal1975]
agarwal1975 has joined #ocaml
kandu has quit [Ping timeout: 260 seconds]
<Algebr``> when did ppx deriving switch over to using result types
<Algebr``> specifically from the result package
<Algebr``> ohhhh, didn't realize that ppx switch over to result and dropped its own usage of polyvariants for `ok `err
<Algebr``> this caused some very strange type erros
manizzle has quit [Ping timeout: 264 seconds]
ggole has quit [Ping timeout: 258 seconds]
ollehar has joined #ocaml
jonasen has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
jeffmo has quit [Read error: Connection reset by peer]
jeffmo has joined #ocaml
Kakadu has quit [Quit: Page closed]
silver_ is now known as silver
rgrinberg has quit [Ping timeout: 244 seconds]
pierpa has quit [Ping timeout: 264 seconds]
tmtwd has joined #ocaml
AlexDenisov has joined #ocaml
dhil has quit [Ping timeout: 250 seconds]
<tormen> Hmm. I have 2 Variant types and would like to combine them ... so type x = |A |B ;; type y = |C |D ... I would like to allow "A C" ... is there ANOTHER WAY to define a type allowing "A C" ... other than defining type x = |A of y |B of y ?
malc_ has quit [Remote host closed the connection]
rgrinberg has joined #ocaml
<ollehar> tormen: [`Bla; `Blaha]
<ollehar> or
<ollehar> that other type thingy
<ollehar> [> ... ]
<ollehar> or [< ...]
<ollehar> wait no
<ollehar> tormen: why would you want another way?
<Algebr``> yes, poly variant based subtyping
<ollehar> Algebr``: oh, so you think you're better than my "type thingy"? ;)
<Algebr``> lol
<gasche> I think that (type t = A of x | B of y) is often a good solution when (x) and (y) really represent separate/different things
<gasche> (for more information on polymorphic variant as recommended by ollehar, see http://caml.inria.fr/pub/docs/manual-ocaml/lablexamples.html#sec46 )
<hongbo> gasche: recently, I found a very elegant use case for polymorphic variant in BuckleScript FFI
<hongbo> in JavaScript, there is an event listener pattern: modeled by typescript as ` on (string , Function)`
<hongbo> but that's very coarse grained, in BuckleScript, it would be like `on : [`line of string -> unit | `close of unit -> unit ] -> unit`, and `on (`line (fun ... ) )` will be literally translated into `on ("line", callback)`
brub has quit [Remote host closed the connection]
<Algebr``> nice
mattrepl has quit [Quit: mattrepl]
tmtwd has quit [Ping timeout: 272 seconds]
tmtwd has joined #ocaml
tmtwd has quit [Ping timeout: 272 seconds]
Kakadu has joined #ocaml
manizzle has joined #ocaml
<tormen> ollehar: Algebr`` gasche : Thaaaaaanks a lot :))
<tormen> I'll have a look at the type thingies :)) hehe
ollehar has quit [Quit: ollehar]
hugomg has joined #ocaml
<tormen> gasche: I love such (when you wrote I think that...) general guidelines :))) Thanks !
<tormen> ... some guidance in the jungle of possibilities ;)
tautologico has joined #ocaml
<gasche> hongbo: good point; I remember also using them to design an API for a rest-like service that had various response status for each endpoints
<gasche> (polymorphic variant made sense as most endpoints would share some possible return codes but not others)
<gasche> although in practice I found out that the documentation/specification of these endpoints was erroneous, and they could all return pretty much any error code, and I switched to over-approximating with the same return set for all of them
<gasche> (and I suspect this kind of harsh realization is also common in the Javascript world)
<tormen> gasche: hmmm just in my case it would be type t = A of x
<gasche> hm
<tormen> gasche: hmmm just in my case it would be type t = A of x | B of x | C of x ... because I want to comine the choices of A B C with the choices of x ... ... ah its complicated ;)
<gasche> my understanding is that you have a type (x) with some cases, and a type (y) with some others, and that you were describing a "common type" with two constructors, one having a (x) parameter and the other a (y), so it could be (type t = X of x | Y of y); (t) would not have one constructor for each constructor of (x) or (y), just one for all x's, and one for all y's
<tormen> ... because ideally you would then provide A,x as a tuple... but I can't .. ;)
<gasche> could you give more information about your use-case?
<gasche> (dependent pairing is available with GADTs, but again it's better to keep things simple as long as you can)
<tormen> gasche: hehe :)
<tormen> gasche: as your time is precious I prefer to invest it when I will REALLY need it ... here I have solution, I just think it might not be the best one in terms of "niceness"...
<gasche> you could also define a function (some would call it a view) that takes a (type t = X of x | Y of y) and returns a (type kind = IsX | IsY) when it makes sense
<gasche> but with pattern-matching it's easy to tell if something is a (X _) or a (Y _)
<tormen> gasche: My usecase: I am encoding pg_enums (postgresql) enums with variant types.
<tormen> I have special pg_enum that actually lists the legal forms per country (so FR SARL, DE GMBH, UK LTD) and it is nice to have all the FR types together so FR SARL FR SAS ...
<tormen> ... but as I said: your time is precious for me and I don't want to waste it.
<tormen> .... then I have a pg_enum_to_int32 and int32_to_legal_form function to transform between int and Variants (int being stored in the database).
<gasche> so in this case, one thing you can do is to have a plain enum for all legal forms, (FR_SARL, DE_GMBH...), and a "country : legal_form -> country" option that returns a FR, DE, UK... when you need the separation
ollehar has joined #ocaml
manizzle has quit [Ping timeout: 240 seconds]
<gasche> (one advantage is that the API is simple for beginner to understand and that there is a simple mapping from any valid legal form to an OCaml value, for example when people transcribe examples written in another language into OCaml)
jerith has quit [Quit: Press Ze Button!]
<tormen> gasche: yeah I thought about that ... but the front-end will need the list that in FR there is SARL and SAS and DE has GMBH ... so I got the idea to cut the info in 2 ... (FR_SARL -> FR SARL)...
<tormen> hehe
jeffmo has quit [Read error: Connection reset by peer]
jeffmo has joined #ocaml
<tormen> I'll think about it.
<tormen> If we manage to finish our MVP and our startup works, I will send a check :))
SaidinWoT has joined #ocaml
<Algebr``> famous last words
jerith has joined #ocaml
jerith has quit [Remote host closed the connection]
<tormen> ... hehe for now it looks good. But of course: Ideas are easy. Implementation is hard. :))
mattrepl has joined #ocaml
jerith has joined #ocaml
orbifx has joined #ocaml
_whitelogger has joined #ocaml
adelbertc has joined #ocaml
AlexDenisov has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
jeffmo has quit [Quit: jeffmo]
ontologiae has joined #ocaml
unbalancedparen has quit [Read error: Connection reset by peer]
unbalancedparen has joined #ocaml
tautologico has joined #ocaml
slash^ has quit [Read error: Connection reset by peer]
hugomg has quit [Quit: Ex-Chat]
octachron has joined #ocaml
freehck has quit [Ping timeout: 260 seconds]
martinkl_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pyon has quit [Quit: ... flowering silent scarlet piece of night.]
orbifx has quit [Ping timeout: 250 seconds]
apache2 has quit [Remote host closed the connection]
ahf has quit [Quit: Bye.]
jlouis has quit [Remote host closed the connection]
A1977494 has quit [Remote host closed the connection]
kakadu has quit [Remote host closed the connection]
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
agarwal1975 has quit [Quit: agarwal1975]
tautologico has quit [Ping timeout: 250 seconds]
ahf has joined #ocaml
ontologiae has quit [Ping timeout: 276 seconds]
pyon has joined #ocaml
tautologico has joined #ocaml
octachron has quit [Quit: Leaving]
ontologiae has joined #ocaml
ontologiae has quit [Ping timeout: 260 seconds]
ollehar has quit [Ping timeout: 264 seconds]
manizzle has joined #ocaml
agarwal1975 has joined #ocaml
cnu- has quit [Ping timeout: 258 seconds]
al-damiri has quit [Quit: Connection closed for inactivity]
<Algebr``> Drup: I think I have a bug report/feature request for ocp-browser
madroach has quit [Ping timeout: 244 seconds]
<Algebr``> Drup: I have a type defined: type 'a component_api = (<isMounted : bool Js.t Js.meth; .. > as 'a) Js.t
<Algebr``>
<Algebr``> but ocp-browser reports it as: component_api 'a Js.t
<Algebr``> I want that 'a expanded out with the fields
madroach has joined #ocaml
<Drup> huum, I'm not surprised that doesn't work
<Drup> please open a ticket
<Algebr``> why not surprised?
<Drup> intuition based on how outcometree works
<Algebr``> i see, it would help me quite a bit if that worked
manizzle has quit [Read error: No route to host]
manizzle has joined #ocaml
silver has quit [Quit: rakede]