PROPOSAL: classes for traversals

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


Hello Ross,

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

RP>         http://www.soi.city.ac.uk/~ross/traversals/
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

3)
-- 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 HotPOP.com





More information about the Libraries mailing list