The lambdas must flow. If I break, you can: 1. Restart: M-x haskell-process-restart 2. Configure logging: C-h v haskell-process-log (useful for debugging) 3. General config: M-x customize-mode 4. Hide these tips: C-h v haskell-process-show-debug-tips Changed directory: /home/hugo/Academic/Teaching/2023.2/TCPF/Aulas/ λ> :i Coprod type Coprod :: * -> * -> * data Coprod a b = Esq a | Dir b -- Defined at /home/hugo/Academic/Teaching/2023.2/TCPF/Aulas/Aula15.hs:4:1 instance (Eq a, Eq b) => Eq (Coprod a b) -- Defined at /home/hugo/Academic/Teaching/2023.2/TCPF/Aulas/Aula15.hs:5:13 instance (Show a, Show b) => Show (Coprod a b) -- Defined at /home/hugo/Academic/Teaching/2023.2/TCPF/Aulas/Aula15.hs:5:17 λ> :t Esq Esq :: a -> Coprod a b λ> :t Dir Dir :: b -> Coprod a b λ> y Esq "Hugo" λ> x Dir 2 λ> undefined *** Exception: Prelude.undefined CallStack (from HasCallStack): error, called at libraries/base/GHC/Err.hs:74:14 in base:GHC.Err undefined, called at :20:1 in interactive:Ghci3 λ> :t seq seq :: a -> b -> b λ> :t Esq Esq :: a -> Coprod a b λ> Esq 2 Esq 2 λ> 2 2 λ> 2 + 2 4 λ> Esq 2 Esq 2 λ> :i Either type Either :: * -> * -> * data Either a b = Left a | Right b -- Defined in `Data.Either' instance Applicative (Either e) -- Defined in `Data.Either' instance (Eq a, Eq b) => Eq (Either a b) -- Defined in `Data.Either' instance Functor (Either a) -- Defined in `Data.Either' instance Monad (Either e) -- Defined in `Data.Either' instance (Ord a, Ord b) => Ord (Either a b) -- Defined in `Data.Either' instance Semigroup (Either a b) -- Defined in `Data.Either' instance (Show a, Show b) => Show (Either a b) -- Defined in `Data.Either' instance (Read a, Read b) => Read (Either a b) -- Defined in `Data.Either' instance Foldable (Either a) -- Defined in `Data.Foldable' instance Traversable (Either a) -- Defined in `Data.Traversable' λ> :t Left Left :: a -> Either a b λ> :t Right Right :: b -> Either a b λ> :t either either :: (a -> c) -> (b -> c) -> Either a b -> c λ> :t (either f g) :1:9: error: Variable not in scope: f :: a -> c :1:11: error: Variable not in scope: g :: b -> c λ> :t (either f g) (either f g) :: Either String Integer -> Bool λ> h == either f g :35:6-15: error: * Couldn't match type: Either String Integer with: Coprod String Integer Expected: Coprod String Integer -> Bool Actual: Either String Integer -> Bool * In the second argument of `(==)', namely `either f g' In the expression: h == either f g In an equation for `it': it = h == either f g λ> :i Maybe type Maybe :: * -> * data Maybe a = Nothing | Just a -- Defined in `GHC.Maybe' instance Applicative Maybe -- Defined in `GHC.Base' instance Eq a => Eq (Maybe a) -- Defined in `GHC.Maybe' instance Functor Maybe -- Defined in `GHC.Base' instance Monad Maybe -- Defined in `GHC.Base' instance Semigroup a => Monoid (Maybe a) -- Defined in `GHC.Base' instance Ord a => Ord (Maybe a) -- Defined in `GHC.Maybe' instance Semigroup a => Semigroup (Maybe a) -- Defined in `GHC.Base' instance Show a => Show (Maybe a) -- Defined in `GHC.Show' instance MonadFail Maybe -- Defined in `Control.Monad.Fail' instance Read a => Read (Maybe a) -- Defined in `GHC.Read' instance Foldable Maybe -- Defined in `Data.Foldable' instance Traversable Maybe -- Defined in `Data.Traversable' λ> :t maybe maybe :: b -> (a -> b) -> Maybe a -> b λ> par ("Hugo",36) λ> :t fst fst :: (a, b) -> a λ> :t snd snd :: (a, b) -> b λ> fst par "Hugo" λ> snd par 36 λ> :i Par type Par :: * -> * -> * data Par a b = MkPar {proj_a :: a, proj_b :: b} -- Defined at /home/hugo/Academic/Teaching/2023.2/TCPF/Aulas/Aula15.hs:40:1 instance (Eq a, Eq b) => Eq (Par a b) -- Defined at /home/hugo/Academic/Teaching/2023.2/TCPF/Aulas/Aula15.hs:41:13 instance (Show a, Show b) => Show (Par a b) -- Defined at /home/hugo/Academic/Teaching/2023.2/TCPF/Aulas/Aula15.hs:41:17 λ> :t MkPar MkPar :: a -> b -> Par a b λ> :t proj_a proj_a :: Par a b -> a λ> :t proj_b proj_b :: Par a b -> b λ> outro_par MkPar {proj_a = "Hugo", proj_b = 36} λ> proj_a outro_par "Hugo" λ> outro_par { proj_b = 37 } MkPar {proj_a = "Hugo", proj_b = 37} λ> prod k j prod k j :: Bool -> Prod String Integer λ> prod True :60:6-9: error: * Couldn't match expected type `c -> a' with actual type `Bool' * In the first argument of `prod', namely `True' In the expression: prod True In an equation for `it': it = prod True * Relevant bindings include it :: (c -> b) -> c -> Prod a b (bound at :60:1) λ> prod k j True MkProd {proj_a = "Hugo", proj_b = 36} λ> prod k j False MkProd {proj_a = "n\227o-Hugo", proj_b = 0} λ> :i Maybe type Maybe :: * -> * data Maybe a = Nothing | Just a -- Defined in `GHC.Maybe' instance Applicative Maybe -- Defined in `GHC.Base' instance Eq a => Eq (Maybe a) -- Defined in `GHC.Maybe' instance Functor Maybe -- Defined in `GHC.Base' instance Monad Maybe -- Defined in `GHC.Base' instance Semigroup a => Monoid (Maybe a) -- Defined in `GHC.Base' instance Ord a => Ord (Maybe a) -- Defined in `GHC.Maybe' instance Semigroup a => Semigroup (Maybe a) -- Defined in `GHC.Base' instance Show a => Show (Maybe a) -- Defined in `GHC.Show' instance MonadFail Maybe -- Defined in `Control.Monad.Fail' instance Read a => Read (Maybe a) -- Defined in `GHC.Read' instance Foldable Maybe -- Defined in `Data.Foldable' instance Traversable Maybe -- Defined in `Data.Traversable' λ> :i [] type [] :: * -> * data [] a = [] | a : [a] -- Defined in `GHC.Types' instance Applicative [] -- Defined in `GHC.Base' instance Eq a => Eq [a] -- Defined in `GHC.Classes' instance Functor [] -- Defined in `GHC.Base' instance Monad [] -- Defined in `GHC.Base' instance Monoid [a] -- Defined in `GHC.Base' instance Ord a => Ord [a] -- Defined in `GHC.Classes' instance Semigroup [a] -- Defined in `GHC.Base' instance Show a => Show [a] -- Defined in `GHC.Show' instance MonadFail [] -- Defined in `Control.Monad.Fail' instance Read a => Read [a] -- Defined in `GHC.Read' instance Foldable [] -- Defined in `Data.Foldable' instance Traversable [] -- Defined in `Data.Traversable' λ>