Skip to content

Commit

Permalink
Finished exercises with Bifunctor
Browse files Browse the repository at this point in the history
  • Loading branch information
Anastasios Valtinos committed Oct 12, 2022
1 parent 7bcdc75 commit 0ae4df2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Haskell Excercises & Code/Chapter25 - Composing Types/funExer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,13 @@ instance Bifunctor (SemiDrei a) where
data Quadriceps a b c d = Quadzzz a b c d

instance Bifunctor (Quadriceps a b) where
bimap f g (Quadzzz a b c d) = Quadriceps a b (f c) (g d)
bimap f g (Quadzzz a b c d) = Quadzzz a b (f c) (g d)
first f (Quadzzz a b c d) = Quadzzz a b (f c) d
second f (Quadzzz a b c d) = Quadzzz a b c (f d)

-- 7.
data MyEither a b = MyLeft a | MyRight b

instance Bifunctor MyEither where
bimap f g (MyLeft a) = MyLeft (f a)
bimap f g (MyRight b) = MyRight (g b)

0 comments on commit 0ae4df2

Please sign in to comment.