The next big Haskell project is about to start! 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/ λ> tales P "Tales" 25 True λ> :t Tales :1:1-5: error: [GHC-88464] Data constructor not in scope: Tales Suggested fix: Perhaps use variable `tales' (line 15) λ> :t tales tales :: Pessoa λ> nome tales "Tales" λ> nome tales "Tales" λ> :i Pessoa type Pessoa :: * data Pessoa where P :: Nome -> Integer -> Bool -> Pessoa -- Defined at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula14.hs:12:1 instance Eq Pessoa -- Defined at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula14.hs:14:19 instance Show Pessoa -- Defined at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula14.hs:14:13 λ> :t length length :: Foldable t => t a -> Int λ> length $ nome tales 5 λ> :t P2 P2 :: Nome -> Idade -> Vegetariano -> Pessoa2 λ> idade2 hugo2 37 Aula14.hs:21:8-14: error: [GHC-83865] … * Couldn't match expected type `Pessoa2' with actual type `Pessoa' * In the pattern: P n _ _ In an equation for `nome2': nome2 (P n _ _) = n | λ> valida_nome "hugo" OK "hugo" λ> valida_nome "João Paixão" OK "Jo\65533\65533o Paix\65533\65533o" λ> valida_nome "Joao Paixao" Erro ["N\227o quero o Joao Paixao na festa"] λ> valida_nome "Joao Paixao" Erro ["Nao quero o Joao Paixao na festa"] λ> valida_idade 25 OK 25 λ> valida_idade 75 Erro ["sou etarista :("] Aula14.hs:46:44: error: [GHC-88464] … * Found hole: _ :: TalvezTurbinado Pessoa * In an equation for `valida_pessoa': valida_pessoa nome idade eh_vegetariano = _ * Relevant bindings include eh_vegetariano :: Vegetariano (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula14.hs:46:26) idade :: Idade (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula14.hs:46:20) nome :: Nome (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula14.hs:46:15) valida_pessoa :: Nome -> Idade -> Vegetariano -> TalvezTurbinado Pessoa (bound at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula14.hs:46:1) | λ> :t P :1:1: error: [GHC-88464] Data constructor not in scope: P λ> :t P P :: Nome -> Idade -> Vegetariano -> Pessoa λ> valida_pessoa "Hugo" 37 True OK (P {nome = "Hugo", idade = 37, eh_vegetariano = True}) λ> valida_pessoa "Joao Paixao" 70 False Erro ["Nao quero o Joao Paixao na festa","sou etarista :("] λ> :i Applicative type Applicative :: (* -> *) -> Constraint class Functor f => Applicative f where pure :: a -> f a (<*>) :: f (a -> b) -> f a -> f b liftA2 :: (a -> b -> c) -> f a -> f b -> f c (*>) :: f a -> f b -> f b (<*) :: f a -> f b -> f a {-# MINIMAL pure, ((<*>) | liftA2) #-} -- Defined in `GHC.Base' instance Applicative TalvezTurbinado -- Defined at Aula13.hs:113:10 instance Monoid a => Applicative ((,) a) -- Defined in `GHC.Base' instance (Monoid a, Monoid b) => Applicative ((,,) a b) -- Defined in `GHC.Base' instance (Monoid a, Monoid b, Monoid c) => Applicative ((,,,) a b c) -- Defined in `GHC.Base' instance Applicative ((->) r) -- Defined in `GHC.Base' instance Applicative IO -- Defined in `GHC.Base' instance Applicative [] -- Defined in `GHC.Base' instance Applicative Maybe -- Defined in `GHC.Base' instance Applicative Solo -- Defined in `GHC.Base' instance Applicative (Either e) -- Defined in `Data.Either' λ> [1,2] <* [3,4] [1,1,2,2] λ> [1,2] *> [3,4] [3,4,3,4] λ> [(^2), (^3)] <*> [4, 5, 6, 7] [16,25,36,49,64,125,216,343] λ> [(^2), (^3)] <* [4, 5, 6, 7] [funcao,funcao,funcao,funcao,funcao,funcao,funcao,funcao] λ> [(^2), (^3)] *> [4, 5, 6, 7] [4,5,6,7,4,5,6,7] λ> (OK "Hugo") <* (OK 37) OK "Hugo" λ> (OK "Hugo") *> (OK 37) OK 37 λ> (OK "Hugo") *> Erro ["oi"] Erro ["oi"] λ> (OK "Hugo") <* Erro ["oi"] Erro ["oi"] λ> :t (<$) (<$) :: Functor f => a -> f b -> f a λ> :t const const :: a -> b -> a λ> f = const "Hugo" λ> f 234234294821 "Hugo" λ> f True "Hugo" λ> f "hugo" "Hugo" λ> [1,2] <* [3,4] [1,1,2,2] λ> bla = liftA2 const :: [Integer] -> [Integer] :192:7-18: error: [GHC-83865] * Couldn't match type: [b0] -> [Integer] with: [Integer] Expected: [Integer] -> [Integer] Actual: [Integer] -> [b0] -> [Integer] * Probable cause: `liftA2' is applied to too few arguments In the expression: liftA2 const :: [Integer] -> [Integer] In an equation for `bla': bla = liftA2 const :: [Integer] -> [Integer] λ> bla = liftA2 const :: [Integer] -> [Integer] -> [Integer] λ> bla [1,2] [3,4] [1,1,2,2] λ> bla [3,4] [1,2] [3,3,4,4] λ> :t const const :: a -> b -> a λ> ["Hugo"] <* [1,2] ["Hugo","Hugo"] λ> ["Hugo"] <* [1,2,3,4,5,6] ["Hugo","Hugo","Hugo","Hugo","Hugo","Hugo"] λ> ["Hugo"] *> [1,2,3,4,5,6] [1,2,3,4,5,6] λ> ["Hugo", "de Holanda", "Cunha"] *> [1,2,3,4,5,6] [1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6] λ> ["Hugo", "de Holanda", "Cunha"] <* [1,2,3,4,5,6] ["Hugo","Hugo","Hugo","Hugo","Hugo","Hugo","de Holanda","de Holanda","de Holanda","de Holanda","de Holanda","de Holanda","Cunha","Cunha","Cunha","Cunha","Cunha","Cunha"] λ> (<$) :236:1-4: error: [GHC-39999] * No instance for `Show (a0 -> f0 b0 -> f0 a0)' arising from a use of `print' (maybe you haven't applied a function to enough arguments?) * In a stmt of an interactive GHCi command: print it λ> :t (<$) (<$) :: Functor f => a -> f b -> f a λ> Erro ["erro 1 da funcao", "erro 2 da funcao"] <* Erro ["erro 1 do arg", "erro 2 do arg", "erro 3 do arg"] Erro ["erro 1 da funcao","erro 2 da funcao","erro 1 do arg","erro 2 do arg","erro 3 do arg"] λ> Erro ["erro 1 da funcao", "erro 2 da funcao"] *> Erro ["erro 1 do arg", "erro 2 do arg", "erro 3 do arg"] Erro ["erro 1 da funcao","erro 2 da funcao","erro 1 do arg","erro 2 do arg","erro 3 do arg"] λ> :t (<*) (<*) :: Applicative f => f a -> f b -> f a λ> :t P P :: Nome -> Idade -> Vegetariano -> Pessoa λ> :i Alternative :1:1-11: error: Not in scope: `Alternative' Aula14.hs:52:45-50: error: … Ambiguous occurrence `liftA3' It could refer to either `Aula13.liftA3', imported from `Aula13' at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula14.hs:3:37-42 (and originally defined at Aula13.hs:75:1-6) or `Control.Applicative.liftA3', imported from `Control.Applicative' at /home/hugo/Academic/Teaching/_Atual/Teoria de Categorias/Aulas/Aula14.hs:4:1-26 (and originally defined in `GHC.Base') | λ> :t liftA4 :1:1-6: error: [GHC-88464] Variable not in scope: liftA4 Suggested fix: Perhaps use one of these: `liftA' (imported from Control.Applicative), `liftA2' (imported from Control.Applicative), `liftA3' (imported from Control.Applicative) λ> :t liftA3 liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d λ> :i Alternative type Alternative :: (* -> *) -> Constraint class Applicative f => Alternative f where empty :: f a (<|>) :: f a -> f a -> f a some :: f a -> f [a] many :: f a -> f [a] {-# MINIMAL empty, (<|>) #-} -- Defined in `GHC.Base' instance Alternative IO -- Defined in `GHC.Base' instance Alternative [] -- Defined in `GHC.Base' instance Alternative Maybe -- Defined in `GHC.Base' instance (Control.Arrow.ArrowZero a, Control.Arrow.ArrowPlus a) => Alternative (WrappedArrow a b) -- Defined in `Control.Applicative' instance GHC.Base.MonadPlus m => Alternative (WrappedMonad m) -- Defined in `Control.Applicative' instance Alternative ZipList -- Defined in `Control.Applicative' λ> [1,2,3] <|> [4,5,6] [1,2,3,4,5,6] λ> [1,2,3] <| [4,5,6] :302:9-10: error: [GHC-88464] Variable not in scope: (<|) :: [a0] -> [a1] -> t Suggested fix: Perhaps use one of these: `<' (imported from Prelude), `<$' (imported from Control.Applicative), `<*' (imported from Control.Applicative) λ> [1,2,3] <|> [] [1,2,3] λ> [] <|> [3,4,5] [3,4,5] λ> [1,2,3,4] <|> [3,4,5] [1,2,3,4,3,4,5] λ> Nothing <|> Just 5 Just 5 λ> Just 3 <|> Just 5 Just 3 λ> Just 3 <|> Nothing Just 3 λ> x = Nothing λ> y = Nothing λ> z = Just 3 λ> w = Nothing λ> x <|> y <|> z <|> w Just 3 Aula14.hs:72:13-21: error: [GHC-83865] … * Couldn't match type `Integer' with `Int' Expected: Maybe Int Actual: Maybe Integer * In the first argument of `(<|>)', namely `digit 0 s' In the expression: digit 0 s <|> digit 1 s In an equation for `binChar': binChar s = digit 0 s <|> digit 1 s | Aula14.hs:72:27-35: error: [GHC-83865] … * Couldn't match type `Integer' with `Int' Expected: Maybe Int Actual: Maybe Integer * In the second argument of `(<|>)', namely `digit 1 s' In the expression: digit 0 s <|> digit 1 s In an equation for `binChar': binChar s = digit 0 s <|> digit 1 s | λ> digit 55 "hugo" Nothing λ> digit 5 "hugo" Nothing λ> digit 5 "56 hugo oi" Just 5 λ> binChar "hugo" Nothing λ> binChar "2 hugo" Nothing λ> binChar "1 hugo" Just 1 λ> binChar "0 hugo" Just 0 λ> :t fst fst :: (a, b) -> a λ> :t snd snd :: (a, b) -> b λ> :t lst :1:1-3: error: [GHC-88464] Variable not in scope: lst Suggested fix: Perhaps use one of these: `fst' (imported from Prelude), `last' (imported from Prelude) λ> :t last last :: GHC.Stack.Types.HasCallStack => [a] -> a λ> fst hugo3 :371:5-9: error: [GHC-83865] * Couldn't match expected type `(a, b0)' with actual type `Pessoa3' * In the first argument of `fst', namely `hugo3' In the expression: fst hugo3 In an equation for `it': it = fst hugo3 * Relevant bindings include it :: a (bound at :371:1) λ> fst hugo3 :374:5-9: error: [GHC-83865] * Couldn't match expected type `(a, b0)' with actual type `Pessoa3' * In the first argument of `fst', namely `hugo3' In the expression: fst hugo3 In an equation for `it': it = fst hugo3 * Relevant bindings include it :: a (bound at :374:1) λ> nome3 hugo3 "Hugo" λ> nome3 hugo3