[Haskell-cafe] Are GADTs what I need?

Kev Mahoney maillist at kevinmahoney.co.uk
Mon Jul 13 12:35:38 EDT 2009

Thanks, I hadn't noticed Data.Dynamic. It never even occurred to me
that something like this would be in the standard libraries. It looks
like it's precisely what I was looking for, after a brief scan of the

I will report back if I bump into any problems with it

2009/7/13 Chaddaï Fouché <chaddai.fouche at gmail.com>:
> On Mon, Jul 13, 2009 at 12:41 PM, Kev
> Mahoney<maillist at kevinmahoney.co.uk> wrote:
>> So far, I've learnt you can do this:
>> data Value where
>> VInt :: Integer -> Value
>> ...
>> VWrapper :: a -> Value
>> which can let you encode arbitrary 'dynamic' types into Value. I was
>> hoping to be able to pattern match to get the value out again e.g.
> As such this type is pretty useless, since you don't know anything
> about a, you can't do anything with it... Which is why you add
> typeclass constraints, so you can use this value. Data.Dynamic adds a
> Typeable constraint, which allows you to do safe coercing, so you can
> have a "typecase", if not like you tried to do it.
> --
> Jedaï

More information about the Haskell-Cafe mailing list