30 Apr
2003
30 Apr
'03
6:45 p.m.
Graham Klyne wrote:
class (Eq k, Show k) => Pair a k v where newPair :: (k,v) -> a k v getPair :: a k v -> (k,v)
type MyPair4 k v = (k,v)
instance Pair (Int,String) Int String where newPair = id getPair = id
The kinds are wrong here. `Pair` takes as its first argument a type constructor of kind: * -> * -> *. The following works (with appropriate extensions enabled): instance Pair (,) Int String where newPair = id getPair = id
instance Pair (MyPair4 Int String) Int String where newPair = id getPair = id
Again the kinds are wrong. However, you can't make a Pair instance out of MyPair4 because the latter is a `type` rather than `newtype` or `data`. Hope this helps. Dean