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/_Atual/Teoria de Categorias/Aulas/ λ> S $ S $ S $ Zero S (S (S Zero)) λ> S $ S $ S $ Zero == Zero :17:13-24: error: [GHC-83865] * Couldn't match expected type `Natural' with actual type `Bool' * In the second argument of `($)', namely `Zero == Zero' In the second argument of `($)', namely `S $ Zero == Zero' In the second argument of `($)', namely `S $ S $ Zero == Zero' λ> Zero == S $ S $ S $ Zero :20:1-9: error: [GHC-83865] * Couldn't match expected type `Natural -> b' with actual type `Bool' * In the first argument of `($)', namely `Zero == S' In the expression: Zero == S $ S $ S $ Zero In an equation for `it': it = Zero == S $ S $ S $ Zero * Relevant bindings include it :: b (bound at :20:1) :20:9: error: [GHC-83865] * Couldn't match expected type `Natural' with actual type `Natural -> Natural' * Probable cause: `S' is applied to too few arguments In the second argument of `(==)', namely `S' In the first argument of `($)', namely `Zero == S' In the expression: Zero == S $ S $ S $ Zero λ> Zero == (S $ S $ S $ Zero) False λ> (S $ S $ S $ Zero) == Zero False λ> :i ($) ($) :: (a -> b) -> a -> b -- Defined in `GHC.Base' infixr 0 $ λ> :i (+) type Num :: * -> Constraint class Num a where (+) :: a -> a -> a ... -- Defined in `GHC.Num' infixl 6 + λ> :i (*) type Num :: * -> Constraint class Num a where ... (*) :: a -> a -> a ... -- Defined in `GHC.Num' infixl 7 * λ> :i (==) type Eq :: * -> Constraint class Eq a where (==) :: a -> a -> Bool ... -- Defined in `GHC.Classes' infix 4 == λ> h 10 -296588 λ> h' 10 -296588 λ> :t show show :: Show a => a -> String λ> :t (show . S . S) (show . S . S) :: Natural -> String λ> nome_bonito "Malaquias" False λ> par seis True λ> par cinco False λ> sinal 12136127361 :78:1-17: error: [GHC-39999] * No instance for `Show Sinais' arising from a use of `print' * In a stmt of an interactive GHCi command: print it λ> sinal 12136127361 Positivo λ> sinal 0 Nenhum λ> sinal -2342342 :84:7: error: [GHC-39999] * No instance for `Num (Integer -> Sinais)' arising from a use of `-' (maybe you haven't applied a function to enough arguments?) * In the expression: sinal - 2342342 In an equation for `it': it = sinal - 2342342 λ> sinal (-2342342) Negativo Aula09.hs:112:15: error: [GHC-88464] … Variable not in scope: y :: Natural | Aula09.hs:112:31: error: [GHC-88464] … Variable not in scope: y :: Natural | Aula09.hs:112:43: error: [GHC-88464] … Variable not in scope: y :: Natural | Compilation failed. Aula09.hs:108:1-10: error: [GHC-94426] … Invalid type signature: Antecessor :: ... Suggested fix: A type signature should be of form :: | Compilation failed. Aula09.hs:108:1-10: error: [GHC-94426] … Invalid type signature: Antecessor :: ... Suggested fix: A type signature should be of form :: | Compilation failed. Aula09.hs:108:1-10: error: [GHC-44432] … The type signature for `antecessor' lacks an accompanying binding | Compilation failed. Aula09.hs:115:19: error: [GHC-88464] … * Found hole: _ :: Natural * In an equation for `fibo': fibo x | x == Zero = Zero | x == S Zero = S Zero | otherwise = _ * Relevant bindings include x :: Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:112:6) fibo :: Natural -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:112:1) Valid hole fits include x :: Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:112:6) Zero :: Natural (defined at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:17:3) zero :: Natural (defined at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:21:1) um :: Natural (defined at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:22:1) dois :: Natural (defined at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:23:1) tres :: Natural (defined at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:24:1) (Some hole fits suppressed; use -fmax-valid-hole-fits=N or -fno-max-valid-hole-fits) | Compilation failed. λ> antecessor quatro S (S (S Zero)) λ> antecesso um :113:1-9: error: [GHC-88464] Variable not in scope: antecesso :: Natural -> t Suggested fix: Perhaps use `antecessor' (line 109) λ> antecessor um Zero λ> antecessor Zero *** Exception: /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:109:1-20: Non-exhaustive patterns in function antecessor λ> antecessor Zero Zero λ> fibo cinco S (S (S (S (S Zero)))) λ> fibo seis S (S (S (S (S (S (S (S Zero))))))) λ> fibo (fibo seis) S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S Zero)))))))))))))))))))) λ> take 10 naturais [0,1,2,3,4,5,6,7,8,9] λ> take 10 quadrados [0,1,4,9,16,25,36,49,64,81] λ> take 10 pares [0,2,4,6,8,10,12,14,16,18] λ> 10 in quadrados :151:4-5: error: [GHC-58481] parse error on input `in' λ> elem 4 quadrados True λ> elem 10 quadrados Interrupted. λ> :type um um :: Natural λ> :i um um :: Natural -- Defined at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:22:1 λ> :i Show type Show :: * -> Constraint class Show a where showsPrec :: Int -> a -> ShowS show :: a -> String showList :: [a] -> ShowS {-# MINIMAL showsPrec | show #-} -- Defined in `GHC.Show' instance Show a => Show (Lista a) -- Defined at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:12:13 instance Show Natural -- Defined at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:19:13 instance Show Sinais -- Defined at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:86:12 instance Show Double -- Defined in `GHC.Float' instance Show Float -- Defined in `GHC.Float' instance Show () -- Defined in `GHC.Show' instance (Show a, Show b) => Show (a, b) -- Defined in `GHC.Show' instance (Show a, Show b, Show c) => Show (a, b, c) -- Defined in `GHC.Show' instance (Show a, Show b, Show c, Show d) => Show (a, b, c, d) -- Defined in `GHC.Show' instance (Show a, Show b, Show c, Show d, Show e) => Show (a, b, c, d, e) -- Defined in `GHC.Show' instance (Show a, Show b, Show c, Show d, Show e, Show f) => Show (a, b, c, d, e, f) -- Defined in `GHC.Show' instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g) => Show (a, b, c, d, e, f, g) -- Defined in `GHC.Show' instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h) => Show (a, b, c, d, e, f, g, h) -- Defined in `GHC.Show' instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i) => Show (a, b, c, d, e, f, g, h, i) -- Defined in `GHC.Show' instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j) => Show (a, b, c, d, e, f, g, h, i, j) -- Defined in `GHC.Show' instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k) => Show (a, b, c, d, e, f, g, h, i, j, k) -- Defined in `GHC.Show' instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l) => Show (a, b, c, d, e, f, g, h, i, j, k, l) -- Defined in `GHC.Show' instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m) -- Defined in `GHC.Show' instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m, Show n) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -- Defined in `GHC.Show' instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m, Show n, Show o) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -- Defined in `GHC.Show' instance Show Bool -- Defined in `GHC.Show' instance Show Char -- Defined in `GHC.Show' instance Show Int -- Defined in `GHC.Show' instance Show Integer -- Defined in `GHC.Show' instance Show a => Show [a] -- Defined in `GHC.Show' instance Show a => Show (Maybe a) -- Defined in `GHC.Show' instance Show Ordering -- Defined in `GHC.Show' instance Show GHC.Types.RuntimeRep -- Defined in `GHC.Show' instance Show a => Show (Solo a) -- Defined in `GHC.Show' instance Show Word -- Defined in `GHC.Show' instance (Show a, Show b) => Show (Either a b) -- Defined in `Data.Either' λ> Show Natural :191:1-4: error: [GHC-31891] * Illegal term-level use of the type constructor or class `Show' * imported from `Prelude' at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:3:8-13 (and originally defined in `GHC.Show') * Perhaps use variable `show' (imported from Prelude) * In the expression: Show Natural In an equation for `it': it = Show Natural λ> :i Num type Num :: * -> Constraint class Num a where (+) :: a -> a -> a (-) :: a -> a -> a (*) :: a -> a -> a negate :: a -> a abs :: a -> a signum :: a -> a fromInteger :: Integer -> a {-# MINIMAL (+), (*), abs, signum, fromInteger, (negate | (-)) #-} -- Defined in `GHC.Num' instance Num Double -- Defined in `GHC.Float' instance Num Float -- Defined in `GHC.Float' instance Num Int -- Defined in `GHC.Num' instance Num Integer -- Defined in `GHC.Num' instance Num Word -- Defined in `GHC.Num' Aula09.hs:141:9: error: [GHC-88464] … * Found hole: _ :: Natural -> Natural -> Natural * In an equation for `*': (*) = _ In the instance declaration for `Num Natural' * Relevant bindings include (*) :: Natural -> Natural -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:141:3) Valid hole fits include (*) :: Natural -> Natural -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:141:3) soma :: Natural -> Natural -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:104:1) produto :: Natural -> Natural -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:135:1) (-) :: forall a. Num a => a -> a -> a with (-) @Natural (imported from `Prelude' at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:3:8-13 (and originally defined in `GHC.Num')) asTypeOf :: forall a. a -> a -> a with asTypeOf @Natural (imported from `Prelude' at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:3:8-13 (and originally defined in `GHC.Base')) const :: forall a b. a -> b -> a with const @Natural @Natural (imported from `Prelude' at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:3:8-13 (and originally defined in `GHC.Base')) (Some hole fits suppressed; use -fmax-valid-hole-fits=N or -fno-max-valid-hole-fits) | Aula09.hs:142:9: error: [GHC-88464] … * Found hole: _ :: Natural -> Natural * In an equation for `abs': abs = _ In the instance declaration for `Num Natural' * Relevant bindings include abs :: Natural -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:142:3) Valid hole fits include abs :: Natural -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:142:3) S :: Natural -> Natural (defined at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:18:3) mais2 :: Natural -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:64:1) fibo :: Natural -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:113:1) antecessor :: Natural -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:109:1) negate :: forall a. Num a => a -> a with negate @Natural (imported from `Prelude' at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:3:8-13 (and originally defined in `GHC.Num')) (Some hole fits suppressed; use -fmax-valid-hole-fits=N or -fno-max-valid-hole-fits) | Aula09.hs:143:12: error: [GHC-88464] … * Found hole: _ :: Natural -> Natural * In an equation for `signum': signum = _ In the instance declaration for `Num Natural' * Relevant bindings include signum :: Natural -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:143:3) Valid hole fits include signum :: Natural -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:143:3) S :: Natural -> Natural (defined at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:18:3) mais2 :: Natural -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:64:1) fibo :: Natural -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:113:1) antecessor :: Natural -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:109:1) negate :: forall a. Num a => a -> a with negate @Natural (imported from `Prelude' at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:3:8-13 (and originally defined in `GHC.Num')) (Some hole fits suppressed; use -fmax-valid-hole-fits=N or -fno-max-valid-hole-fits) | Aula09.hs:144:17: error: [GHC-88464] … * Found hole: _ :: Integer -> Natural * In an equation for `fromInteger': fromInteger = _ In the instance declaration for `Num Natural' * Relevant bindings include fromInteger :: Integer -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:144:3) Valid hole fits include fromInteger :: Integer -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:144:3) fromInteger :: forall a. Num a => Integer -> a with fromInteger @Natural (imported from `Prelude' at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:3:8-13 (and originally defined in `GHC.Num')) fromIntegral :: forall a b. (Integral a, Num b) => a -> b with fromIntegral @Integer @Natural (imported from `Prelude' at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:3:8-13 (and originally defined in `GHC.Real')) | Aula09.hs:145:12: error: [GHC-88464] … * Found hole: _ :: Natural -> Natural * In an equation for `negate': negate = _ In the instance declaration for `Num Natural' * Relevant bindings include negate :: Natural -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:145:3) Valid hole fits include negate :: Natural -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:145:3) S :: Natural -> Natural (defined at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:18:3) mais2 :: Natural -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:64:1) fibo :: Natural -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:113:1) antecessor :: Natural -> Natural (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:109:1) negate :: forall a. Num a => a -> a with negate @Natural (imported from `Prelude' at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula09.hs:3:8-13 (and originally defined in `GHC.Num')) (Some hole fits suppressed; use -fmax-valid-hole-fits=N or -fno-max-valid-hole-fits) | Compilation failed. λ> produto tres dois S (S (S (S (S (S Zero))))) λ> produto zero seis Zero λ> produto um seis S (S (S (S (S (S Zero))))) λ> produto um tres S (S (S Zero)) Aula09.hs:144:10-20: warning: [GHC-06201] [-Wmissing-methods] … * No explicit implementation for `fromInteger' * In the instance declaration for `Num Natural' | Aula09.hs:144:10-20: warning: [GHC-06201] [-Wmissing-methods] … * No explicit implementation for `fromInteger' * In the instance declaration for `Num Natural' | λ> fromInteger 6 6 λ> deInteiro 6 S (S (S (S (S (S Zero))))) λ> deInteiro 50 S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S Zero))))))))))))))))))))))))))))))))))))))))))))))))) λ> :t deInteiro deInteiro :: Integer -> Natural λ> :t fromInteger fromInteger :: Num a => Integer -> a λ> x = fromInteger 6 λ> :t x x :: Num a => a λ> x = fromInteger 6 :: Natural λ> x S (S (S (S (S (S Zero))))) λ> um + um S (S Zero) λ> tres * dois S (S (S (S (S (S Zero))))) Aula09.hs:156:21: error: [GHC-83865] … * Couldn't match expected type `Integer' with actual type `Natural' * In the first argument of `(+)', namely `x' In the expression: x + 1 In an equation for `paraInteiro': paraInteiro (S x) = x + 1 | Compilation failed. λ> paraInteiro seis 6 λ> exemploDoido tres "HugoHugoHugoHugoHugoHugoHugoHugo" λ>