Skip to content

Commit

Permalink
finished exercises on Course.Compose
Browse files Browse the repository at this point in the history
  • Loading branch information
miladz68 committed Dec 27, 2016
1 parent 19a8e58 commit 9d61d0a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ After this, the following progression of modules is recommended:
* `Course.State` -> Done
* `Course.StateT` -> Done
* `Course.Extend` -> Done
* `Course.Comonad`
* `Course.Compose`
* `Course.Comonad` -> Done
* `Course.Compose` -> Done
* `Course.Traversable`
* `Course.ListZipper`
* `Course.Parser` *(see also `Course.Person` for the parsing rules)*
Expand Down
13 changes: 6 additions & 7 deletions src/Course/Compose.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,19 @@ newtype Compose f g a =
-- Implement a Functor instance for Compose
instance (Functor f, Functor g) =>
Functor (Compose f g) where
(<$>) =
error "todo: Course.Compose (<$>)#instance (Compose f g)"
(<$>) func (Compose futor) = Compose( (func <$>) <$> futor)

instance (Applicative f, Applicative g) =>
Applicative (Compose f g) where
-- Implement the pure function for an Applicative instance for Compose
pure =
error "todo: Course.Compose pure#instance (Compose f g)"
pure a = Compose (pure (pure a))
-- Implement the (<*>) function for an Applicative instance for Compose
(<*>) =
error "todo: Course.Compose (<*>)#instance (Compose f g)"
(<*>) (Compose cfa) (Compose fa) = Compose z
where
z = ((<*>) <$> cfa) <*> fa

instance (Monad f, Monad g) =>
Monad (Compose f g) where
-- Implement the (=<<) function for a Monad instance for Compose
(=<<) =
error "todo: Course.Compose (<<=)#instance (Compose f g)"
error "This is the exercise which cannot be solved"

0 comments on commit 9d61d0a

Please sign in to comment.