[Haskell-cafe] partial kinds and instances

Matthew Pocock matthew.pocock at ncl.ac.uk
Mon Apr 16 09:15:42 EDT 2007


I saw that it's possible to peal off kinds from the right-hand side when 
instantiating classes. Is it possible to peel them off from the left-hand 
side? Or in any order?

I have been told in #haskell by people who seems to know that Very Bad Things 
happen if you do this without also making the kind system more clever.

Is there a quick fix that will give me the same effect, without introducing a 
newtype or re-writing the original type declaration to introduce the extra 
types in a different order?

Illustrative code below.


data MyType e = Singleton e  

data MyOtherType k v 
  = Empty
  | Node k v

data YetAnotherType k v
  = OtherEmpty
  | OtherNode k v

type RevYAT v k = YetAnotherType k v

class Iterable ite where
  iterate :: ite e -> [e]

instance Iterable MyType where
  iterate (Singleton e) = [e]

instance Iterable (MyOtherType k) where
  iterate ite = []  --broken but illustrative

instance Iterable (RevYAT v) where
  iterate it = []  --broken again

   Type synonym `RevMOM' should have 2 arguments, but has been given 1
    In the instance declaration for `Iterable (RevYAT v)'

More information about the Haskell-Cafe mailing list