Skip to content

Commit

Permalink
finished exercises on Course.Extend
Browse files Browse the repository at this point in the history
  • Loading branch information
miladz68 committed Dec 27, 2016
1 parent d07a2e5 commit 1dfba10
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ After this, the following progression of modules is recommended:
* `Course.FileIO` -> Done
* `Course.State` -> Done
* `Course.StateT` -> Done
* `Course.Extend`
* `Course.Extend` -> Done
* `Course.Comonad`
* `Course.Compose`
* `Course.Traversable`
Expand Down
14 changes: 6 additions & 8 deletions src/Course/Extend.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ instance Extend Id where
(Id a -> b)
-> Id a
-> Id b
(<<=) =
error "todo: Course.Extend (<<=)#instance Id"
(<<=) f ida = Id $ f ida

-- | Implement the @Extend@ instance for @List@.
--
Expand All @@ -51,8 +50,8 @@ instance Extend List where
(List a -> b)
-> List a
-> List b
(<<=) =
error "todo: Course.Extend (<<=)#instance List"
(<<=) _ Nil = Nil
(<<=) fla la@(_:.res) = fla la :. (<<=) fla res

-- | Implement the @Extend@ instance for @Optional@.
--
Expand All @@ -66,8 +65,8 @@ instance Extend Optional where
(Optional a -> b)
-> Optional a
-> Optional b
(<<=) =
error "todo: Course.Extend (<<=)#instance Optional"
(<<=) _ Empty = Empty
(<<=) f a = Full (f a)

-- | Duplicate the functor using extension.
--
Expand All @@ -86,5 +85,4 @@ cojoin ::
Extend f =>
f a
-> f (f a)
cojoin =
error "todo: Course.Extend#cojoin"
cojoin fa = id <<= fa

0 comments on commit 1dfba10

Please sign in to comment.