From 0ae4df24055d3fce638480fd1acc5c4ab3bb55c4 Mon Sep 17 00:00:00 2001 From: Anastasios Valtinos Date: Wed, 12 Oct 2022 16:24:31 +0300 Subject: [PATCH] Finished exercises with Bifunctor --- .../Chapter25 - Composing Types/funExer.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Haskell Excercises & Code/Chapter25 - Composing Types/funExer.hs b/Haskell Excercises & Code/Chapter25 - Composing Types/funExer.hs index 3cf7571..f52e7ad 100644 --- a/Haskell Excercises & Code/Chapter25 - Composing Types/funExer.hs +++ b/Haskell Excercises & Code/Chapter25 - Composing Types/funExer.hs @@ -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) \ No newline at end of file