Skip to content

Commit

Permalink
IO instances are not exercises. Issue #14
Browse files Browse the repository at this point in the history
  • Loading branch information
tonymorris committed Sep 16, 2013
1 parent ec14f69 commit c90c1aa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 28 deletions.
13 changes: 5 additions & 8 deletions src/Monad/Functor.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,17 @@ instance Functor ((->) t) where
fmap =
error "todo"

-- Exercise 5
-- Relative Difficulty: 2
--
-----------------------
-- SUPPORT LIBRARIES --
-----------------------

-- | Maps a function on an IO program.
--
-- >>> fmap reverse (putStr "hi" >> return "abc")
-- hi"cba"
instance Functor IO where
fmap =
error "todo"

-----------------------
-- SUPPORT LIBRARIES --
-----------------------
P.fmap

instance Functor [] where
fmap =
Expand Down
34 changes: 14 additions & 20 deletions src/Monad/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,6 @@ instance Monad ((->) t) where
-- Exercise 11
-- Relative Difficulty: 2
--
-- | Instance the monad type-class for IO.
--
-- /Tip:/ Use standard library functions. This is not cheating.
instance Monad IO where
bind =
error "todo"
return =
error "todo"

-- Exercise 12
-- Relative Difficulty: 2
--
-- | Flattens a combined structure to a single structure.
--
-- >>> flaatten ((1 :. 2 :. 3 :. Nil) :. (1 :. 2 :. Nil) :. Nil)
Expand All @@ -133,7 +121,7 @@ flaatten ::
flaatten =
error "todo"

-- Exercise 13
-- Exercise 12
-- Relative Difficulty: 10
--
-- | Applies a structure on functions to a structure on values.
Expand Down Expand Up @@ -166,7 +154,7 @@ apply ::
apply =
error "todo"

-- Exercise 14
-- Exercise 13
-- Relative Difficulty: 6
-- (bonus: use apply + fmap')
--
Expand Down Expand Up @@ -198,7 +186,7 @@ lift2 ::
lift2 =
error "todo"

-- Exercise 15
-- Exercise 14
-- Relative Difficulty: 6
-- (bonus: use apply + lift2)
--
Expand Down Expand Up @@ -234,7 +222,7 @@ lift3 ::
lift3 =
error "todo"

-- Exercise 16
-- Exercise 15
-- Relative Difficulty: 6
-- (bonus: use apply + lift3)
--
Expand Down Expand Up @@ -271,7 +259,7 @@ lift4 ::
lift4 =
error "todo"

-- Exercise 17
-- Exercise 16
-- Relative Difficulty: 3
--
-- | Sequences a list of structures to a structure of list.
Expand All @@ -297,7 +285,7 @@ seequence ::
seequence =
error "todo"

-- Exercise 18
-- Exercise 17
-- Relative Difficulty: 3
--
-- | Traverse (map) a list of values with an effect.
Expand All @@ -324,7 +312,7 @@ traaverse ::
traaverse =
error "todo"

-- Exercise 19
-- Exercise 18
-- Relative Difficulty: 4
--
-- | Replicate an effect a given number of times.
Expand All @@ -348,7 +336,7 @@ reeplicate ::
reeplicate =
error "todo"

-- Exercise 20
-- Exercise 19
-- Relative Difficulty: 9
--
-- | Filter a list with a predicate that produces an effect.
Expand Down Expand Up @@ -379,6 +367,12 @@ filtering =
-- SUPPORT LIBRARIES --
-----------------------

instance Monad IO where
bind =
(=<<)
return =
P.return

instance Monad [] where
bind = (P.=<<)
return = P.return
Expand Down

0 comments on commit c90c1aa

Please sign in to comment.