Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] Private types in 3.11, again
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Dario Teixeira <darioteixeira@y...>
Subject: Re: [Caml-list] Private types in 3.11, again
Hi,

And once more, thanks for your very informative reply.  I spent the last
few days exploring these issues (there's quite some info on the Haskell
wiki) and weighting in the pros/cons of each solution.

I've decided for an approach similar to that taken by the Ocsigen guys.
That is, acknowledge that a proper modeling of this problem requires GADTs,
and that since Ocaml does not have them (yet), this is one of those cases
where the use of Obj.magic is justified.  Yes, I know Obj.magic is evil
and all that, but it does allow me to model the problem in a way that is
not too contrived and that is easily ported to a GADT solution once it
does become available in Ocaml.  In the end it's about choosing the lesser
of two evils, and so I've made my peace with having to use Obj.magic.


> In your first example, you want to simultaneously deconstruct a
> value, a reconstruct a new value with the same polymorphic type.
> For this, you need the expressive power of GADTs, i.e. the ability
> to instanciate type variables differently inside different branches
> of a pattern-matching. Since they are not available in ocaml,
> (...)

Thanks for the explanation.  So there is indeed an "expression deficit"
that GADTs fix.  Also, note that this little link-node example is not
the only instance in my current project where GADTs would be useful.
(I'm guessing that eventually reaching the limits of the type system
is part of the journey for an Ocaml programmer!...)

Best regards,
Dario Teixeira