[Haskell-cafe] Aren't type system extensions fun? [Further analysis]

Roberto Zunino zunino at di.unipi.it
Thu May 29 13:08:27 EDT 2008


Isaac Dupree wrote:
>>>    foo :: (Char -> a /\ Bool -> b) -> (a,b)
> 
> a.k.a. find some value that matches both Char->a and Bool->b for some a 
> and b.  Could use type-classes to do it.

Uhmm... you mean something like (neglecting TC-related issues here)

class C a b where
    fromChar :: Char -> a
    fromBool :: Bool -> b

or some more clever thing?

If this can be encoded with method-less classes, I would be quite 
interested in knowing how.

> But why, when we can just use standard tuples instead?
> foo :: (Char -> a , Bool -> b) -> (a,b)

This makes the class dictionary explicit.

Alas, IIUC we lost type erasure (does that still hold with intersection 
types?) in this "implementation".

Zun.


More information about the Haskell-Cafe mailing list