-
Notifications
You must be signed in to change notification settings - Fork 5
Notes for Week 14 Applicative Functors Part 3 Monoids
mattcallanan edited this page Mar 7, 2012
·
5 revisions
You just started working for Dodgy Bros Inc. They've asked you to write DodgyList, which is a list
in every respect except the implementation of Functor will be rewritten so fmap always returns empty list [].
Use this test:
testDodgy = (fmap (+100) (DodgyList [1..10])) == (DodgyList [])
Make the following Tree type an instance of Monoid where the contents of the tree are also an instance of Monoid:
data Tree a = Empty | Node (Tree a) (Tree a) | Leaf a deriving (Show, Eq)
To get you started:
instance Monoid a => Monoid (Tree a) where
Now make the Tree an instance of Foldable.
//TODO
//TODO
//TODO