
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
documentation.
I will report back if I bump into any problems with it
2009/7/13 Chaddaï Fouché
On Mon, Jul 13, 2009 at 12:41 PM, Kev Mahoney
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ï