-
Notifications
You must be signed in to change notification settings - Fork 5
Notes for Week 13 Applicative Functors Part 2 Applicative Functors
learnhaskell-brisbane edited this page Feb 27, 2012
·
6 revisions
* What's the difference between Functors and Applicative Functors ?
* What's the difference between $ and <$> ?
Demonstrate using an IO action as a Functor and as an Applicative Functor.
Make the following Tree type an instance of Applicative:
data Tree a = Node (Tree a) (Tree a)
| Leaf a
deriving Show
Prove that it follows the two Applicative laws.
Write 3 Applicative alternative functions (concatPure, concatFmap, concatDollar) for the following function:
concat :: Maybe String -> Maybe String -> Maybe String
concat (Just x) (Just y) = Just (x ++ y)
Test functions:
---------------
testConcatPure = concatPure (Just "Yes") (Just "No") == (Just "YesNo")
testConcatFmap = concatFmap (Just "Yes") (Just "No") == (Just "YesNo")
testConcatDollar = concatDollar (Just "Yes") (Just "No") == (Just "YesNo")
//TODO
//TODO
//TODO