PROPOSAL: classes for traversals

Bulat Ziganshin bulatz at
Sat Nov 19 09:51:44 EST 2005

Hello Ross,

Friday, November 18, 2005, 2:05:37 PM, you wrote:

RP> Comments most welcome.

1) imho, it's better to change "Prelude." to "List." here:

instance Foldable [] where
        foldr = Prelude.foldr
        foldl = Prelude.foldl
        foldr1 = Prelude.foldr1
        foldl1 = Prelude.foldl1

and in other places where you use list functions listed in Prelude

2) i can try to make Template Haskell machinery to automatically
derive instances of Foldable and Traversable, using your examples
for Tree as sample

-- If @f@ is also a 'Functor', define @('<$>') = 'fmap'@.
-- If it is also a 'Monad', define @'pure' = 'return'@ and @('<*>') = 'ap'@.

why you don't just define:

instance Monad m => Applicative m where
        pure = return
        (<*>) = ap

RP> They are proposed for the base package, and would replace FunctorM.

it is a beatiful contribution. but it doesn't work without definitions
for All, Any and so on :)

Best regards,
 Bulat                            mailto:bulatz at

More information about the Libraries mailing list