Hi,

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 side.

  Tillmann

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to