
29 May
2008
29 May
'08
1:08 p.m.
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.