<flux__>
yes: type ('a, 'n) node = Node of ('n * 'a * 'n) type ('a, 'b) either = Left of 'a | Right of 'b type ('a, 'r0, 'b0, 'r1, 'b1) tree = Zero of 'b1 | Succ of ('a, 'r0, 'b0, 'r1, 'b1) tree' and ('a, 'r0, 'b0, 'r1, 'b1) tree' = Tree of (('a, ('a, 'b0) node, ('a, ('r1, 'b1) either) node, 'r0, 'b0) tree)
<flux__>
that's not all of it, though
<flux__>
Black2 is type ('a) black2 = ('a, 'a option) node, but then I can't make the final type definition RedBlackTree a
<flux__>
maybe due to my inability to be fluent in haskell..
_velco is now known as velco
<flux__>
ah, a simple mistake, here it is: type 'a redblacktree = ('a, ('a black2, 'a) node, 'a black2, 'a, unit) tree
<flux__>
now I wonder how difficult it is to actually implement the code :)
<love-pingoo>
I thought polymorphic variants were great, but it's the first time I really use them, and I end up with mixed feelings..
<love-pingoo>
You still need to declare datatypes (with restrictions on recursive types) you need coercions and you get ugly huge error messages
<love-pingoo>
It may not be worth the subtyping you get (positive formula :> formula)
<flux__>
I briefly used polymorphic variants for splitting a big match to several submatches but splitting the datatype into several subtypes, but still without introducing real hierarchy
<flux__>
but, after a while, I just replaced the whole hierarchy with passing a function instead of sum-type
<love-pingoo>
I don't get it..
<flux__>
such as: type a = [ `A1 of int | `A2 of string ] type b = [ `B1 of float | `B2 of int ] type msg = [ a | b ]
<flux__>
although if you can do that with ordinary variants, I'm interested :-)
<flux__>
then match `A1 42 with #a as msg -> handle_a msg | #b as msg -> handle_b msg
<love-pingoo>
how do you use a function for doing that ?
<flux__>
and type checker doesn't complain in handle_a or handle_b that all cases are not handled, and the handlers don't need to have a wildcard-match
<love-pingoo>
the #t thing is cute and I like it, but it's just syntactic sugar :\
<flux__>
how is it just syntactic sugar?
<love-pingoo>
doesn't really justify using polymorphic variants alone, I'd say
<flux__>
I can now modify type a, and handle_a, and nothing else
<love-pingoo>
flux__: #a can be seen as a shortcut for `A1 _ | `A2 _
bpalmer_ has joined #ocaml
<flux__>
something that reduces the amount of effects caused by a modification isn't syntactic sugar, imo
<love-pingoo>
could be generated by a p4 extension even for normal variants, right ?
<flux__>
well even lambda functions is syntactic sugar in that case
<love-pingoo>
what do you reduce them to ?
<flux__>
to named functions
<flux__>
with compiler-generated names
<flux__>
I suppose that's what really happening anyway
<mattam>
indeeed, that's called lambda lifting
<mattam>
-1e
Debolaz2 has joined #ocaml
<flux__>
love-pingoo, note that actually normal variants can't do that
Debolaz2 has quit [Remote closed the connection]
<love-pingoo>
I'd rather say named functions are sugar for let f = fun x -> ...
Debolaz2 has joined #ocaml
<flux__>
love-pingoo, because the type of [ `A1 | `A2 ] is not the same as the original type
<love-pingoo>
the [ t | ... ] thing is specific to polymorphic variants, you're right
<flux__>
so it gets the advantage of not getting proper compile time diagnostics
<love-pingoo>
and for core variants, the #t is pretty useless, it's equivalent to _ :)
<flux__>
well the example would've converted into | (A1 _ | A2_) as msg -> handle_a msg
Debolaz2 is now known as Debolaz
<flux__>
infact the slicing would be nice in many other cases too
<flux__>
plus the fact that you don't need to write the module name to pattern match a value from another module
<flux__>
it would seem to me polymorphic variants would be great :-). but alas, I haven't used them a lot, and even when I use, I used explicit type specifications in functions
<flux__>
so I might turn into thinking similarly to the way of love-pingoo in time.. except atleast for those narrow special cases.
bpalmer_ has quit ["Chatzilla 0.9.67+ [SeaMonkey rv:1.8.0.7/20060910]"]
bzzbzz has quit ["leaving"]
swater has joined #ocaml
bluestorm has quit [Remote closed the connection]
bluestorm has joined #ocaml
ziggurat has joined #ocaml
nonpop has joined #ocaml
ChoJin has joined #ocaml
klapmuetz has joined #ocaml
<flux__>
funny how nobody appears to have implemented STM for ocaml..
johnnowak has quit []
klapmuet1 has quit [Read error: 110 (Connection timed out)]
joelr1 has joined #ocaml
<joelr1>
good day
joelr1 has left #ocaml []
ikaros has quit [Read error: 110 (Connection timed out)]
Submarine has joined #ocaml
ikaros has joined #ocaml
love-pingoo has quit ["Leaving"]
postalchris has joined #ocaml
pango has quit [Remote closed the connection]
pango has joined #ocaml
Smerdyakov has joined #ocaml
Smerdyakov has quit ["Leaving"]
Smerdyakov has joined #ocaml
Submarine_ has joined #ocaml
Smerdyakov has quit [Client Quit]
Submarine has quit [Read error: 113 (No route to host)]
love-pingoo has joined #ocaml
Smerdyakov has joined #ocaml
Submarine_ has quit [Remote closed the connection]
bluestorm has quit [Remote closed the connection]
ChoJin has quit ["Leaving"]
bluestorm has joined #ocaml
levi_home has quit [Read error: 110 (Connection timed out)]
Submarine has joined #ocaml
levi_home has joined #ocaml
Submarine has quit ["Leaving"]
slipstream has joined #ocaml
slipstream-- has quit [Read error: 110 (Connection timed out)]
pango has quit ["Leaving"]
pango has joined #ocaml
slowriot has joined #ocaml
Eridius has quit [pratchett.freenode.net irc.freenode.net]
descender has quit [pratchett.freenode.net irc.freenode.net]
eradman has quit [pratchett.freenode.net irc.freenode.net]
ppsmimou has quit [pratchett.freenode.net irc.freenode.net]
xian has quit [pratchett.freenode.net irc.freenode.net]
mellum has quit [pratchett.freenode.net irc.freenode.net]
Eridius has joined #ocaml
descender has joined #ocaml
ppsmimou has joined #ocaml
eradman has joined #ocaml
xian has joined #ocaml
mellum has joined #ocaml
descender has quit [pratchett.freenode.net irc.freenode.net]
ppsmimou has quit [pratchett.freenode.net irc.freenode.net]
eradman has quit [pratchett.freenode.net irc.freenode.net]
mellum has quit [pratchett.freenode.net irc.freenode.net]
Eridius has quit [pratchett.freenode.net irc.freenode.net]
xian has quit [pratchett.freenode.net irc.freenode.net]
Eridius has joined #ocaml
descender has joined #ocaml
ppsmimou has joined #ocaml
eradman has joined #ocaml
xian has joined #ocaml
mellum has joined #ocaml
descender has quit [pratchett.freenode.net irc.freenode.net]
ppsmimou has quit [pratchett.freenode.net irc.freenode.net]
eradman has quit [pratchett.freenode.net irc.freenode.net]
mellum has quit [pratchett.freenode.net irc.freenode.net]
Eridius has quit [pratchett.freenode.net irc.freenode.net]
xian has quit [pratchett.freenode.net irc.freenode.net]
Eridius has joined #ocaml
descender has joined #ocaml
ppsmimou has joined #ocaml
eradman has joined #ocaml
xian has joined #ocaml
mellum has joined #ocaml
Eridius has quit [Remote closed the connection]
Eridius has joined #ocaml
descender has quit [pratchett.freenode.net irc.freenode.net]
ppsmimou has quit [pratchett.freenode.net irc.freenode.net]
eradman has quit [pratchett.freenode.net irc.freenode.net]
mellum has quit [pratchett.freenode.net irc.freenode.net]
xian has quit [pratchett.freenode.net irc.freenode.net]
descender has joined #ocaml
ppsmimou has joined #ocaml
eradman has joined #ocaml
xian has joined #ocaml
mellum has joined #ocaml
velco has quit [Client Quit]
descender has quit [Connection timed out]
descender has joined #ocaml
stevan_ has quit [Read error: 110 (Connection timed out)]