question about kinds

Tom Pledger Tom.Pledger@peace.com
Mon, 21 Jan 2002 09:07:17 +1300


Hal Daume III writes:
 | Now, I want to say that if some data type 'd' is Traversable and
 | another data type 'e' is Traversable, then the "combined data type"
 | is Traversable.  That is, for example, I want to say that a Tree of
 | Lists is traversable, or that a List of Trees, or a List of Lists
 | is traversable.

Ashley Yakeley writes:
 | Try this:
 | 
 |  class Traversable t a where -- note no fundep
 |     traverse :: t -> (Maybe a, [t])
 :
 |  instance (Traversable a b, Traversable b c) =>
 |   Traversable a c where
 |     traverse = ...

You also have the option of doing something similar in Haskell 98,
without using multi-parameter classes.

    class Traversable f where
        traverse :: f a -> (Maybe a, [f a])

    -- Backward composition of functors
    newtype BC f g a = BC {unBC :: f (g a)}

    instance (Traversable f, Traversable g) => Traversable (BC f g) where ...

Also see http://www.cse.ogi.edu/~mpj/pubs/springschool.html

Regards,
Tom