[Haskell-cafe] ANN: exists-0.1
illissius at gmail.com
Mon Feb 6 20:07:32 CET 2012
2012/2/6 Tillmann Rendel <rendel at informatik.uni-marburg.de>:
> Gábor Lehel wrote:
>> data E = forall a. C a => E a
>> I don't know if anyone's ever set out what the precise requirements
>> are for a type class method to be useful with existentials.
> More than you seem to think. For example:
> data Number = forall a . Num a => Number a
> foo :: Number -> Number
> foo (Number x) = Number (x * x + 3)
> So the binary operation (*) can be used.
> Note that from a type-checking perspective, the pattern match on (Number x)
> also extracts the type, which is then available when checking the right-hand
I think what I really meant to say by "useful with exisentials" was
"you can write an instance for the existential which forwards to the
instance wrapped by the existential and it will be useful", but you're
quite right to point out that these are not the same.
More information about the Haskell-Cafe