Skip to content

Notes for Week 14 Applicative Functors Part 3 Monoids

mattcallanan edited this page Mar 7, 2012 · 5 revisions

Links:

Exercises:

Exercise 1

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 [])

Exercise 2

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

Exercise 3

Now make the Tree an instance of Foldable.

Questions raised during the group:

//TODO

Answers to Exercises:

//TODO

Interesting Asides

//TODO
Clone this wiki locally