-
Notifications
You must be signed in to change notification settings - Fork 5
Notes for Week 12 Applicative Functors Part 1 Functors and Functor Laws
newmana edited this page Feb 28, 2012
·
18 revisions
* What are Functors useful for?
* What's the difference between fmap and (.) ? Explain.
Demonstrate using an IO action as a Functor.
Make the following Tree type an instance of Functor:
data Tree a = Node (Tree a) (Tree a) | Leaf a deriving (Show, Eq)
Use the following test to get it working (returns true):
testFmap = (fmap (+1000) $ Node (Leaf 100) (Leaf 200)) == (Node (Leaf 1100) (Leaf 1200))
Prove that it follows the two Functor laws by writing the following tests:
--testIdLaw =
--testComposeLaw =
- http://hackage.haskell.org/packages/archive/base/4.2.0.0/doc/html/Data-Functor.html
- http://www.haskell.org/haskellwiki/Category_theory/Functor
- http://www.catonmat.net/blog/on-functors/
- Deriving Functor http://www.mail-archive.com/[email protected]/msg02116.html
//TODO
//TODO