Hello, Haskell! 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/ λ> somarFold (Suc $ Suc 2) :9:22: error: * No instance for (Num Natural) arising from the literal `2' There are instances for similar types: instance Num GHC.Num.Natural.Natural -- Defined in `GHC.Num' * In the first argument of `Suc', namely `2' In the second argument of `($)', namely `Suc 2' In the first argument of `somarFold', namely `(Suc $ Suc 2)' λ> somarFold (Suc $ Suc Zero) (Suc $ Suc $ Suc Zero) Suc (Suc (Suc (Suc (Suc Zero)))) λ> produtoFold (Suc $ Suc Zero) (Suc $ Suc $ Suc Zero) Suc (Suc (Suc (Suc (Suc (Suc Zero))))) λ> potenciaFold (Suc $ Suc Zero) (Suc $ Suc $ Suc Zero) Suc (Suc (Suc (Suc (Suc (Suc (Suc (Suc Zero))))))) λ> potenciaFold (Suc $ Suc $ Suc Zero) (Suc $ Suc Zero) Suc (Suc (Suc (Suc (Suc (Suc (Suc (Suc (Suc Zero)))))))) λ> t No 65 Folha (No 3 (No 0 Folha Folha) Folha) λ> foldArv (\ x y z -> x+y+z) 0 t 68 λ> foldArv (\ x y z -> x*y*z) 1 t 0 λ> :i Foldable type Foldable :: (* -> *) -> Constraint class Foldable t where Data.Foldable.fold :: Monoid m => t m -> m foldMap :: Monoid m => (a -> m) -> t a -> m Data.Foldable.foldMap' :: Monoid m => (a -> m) -> t a -> m foldr :: (a -> b -> b) -> b -> t a -> b Data.Foldable.foldr' :: (a -> b -> b) -> b -> t a -> b foldl :: (b -> a -> b) -> b -> t a -> b Data.Foldable.foldl' :: (b -> a -> b) -> b -> t a -> b foldr1 :: (a -> a -> a) -> t a -> a foldl1 :: (a -> a -> a) -> t a -> a Data.Foldable.toList :: t a -> [a] null :: t a -> Bool length :: t a -> Int elem :: Eq a => a -> t a -> Bool maximum :: Ord a => t a -> a minimum :: Ord a => t a -> a sum :: Num a => t a -> a product :: Num a => t a -> a {-# MINIMAL foldMap | foldr #-} -- Defined in `Data.Foldable' instance Foldable [] -- Defined in `Data.Foldable' instance Foldable Solo -- Defined in `Data.Foldable' instance Foldable Maybe -- Defined in `Data.Foldable' instance Foldable (Either a) -- Defined in `Data.Foldable' instance Foldable ((,) a) -- Defined in `Data.Foldable' λ> foldr (+) 0 t 68 λ> :t toList :1:1-6: error: Variable not in scope: toList λ> :t toList :1:1-6: error: Variable not in scope: toList λ> arvParaList t [65,3,0] λ> t No 65 Folha (No 3 (No 0 Folha Folha) Folha) λ> :t toList toList :: Foldable t => t a -> [a] λ> toList t [65,3,0] λ> v No 10 (No 5 Folha (No 6 Folha Folha)) (No 20 (No 15 Folha Folha) (No 100 Folha Folha)) λ> toList v [10,20,100,15,5,6] λ> arvParaList v [10,5,6,20,15,100] λ> toList v [10,5,6,20,15,100] λ> :t toList toList :: Foldable t => t a -> [a] λ> arvParaListFold v [10,5,6,20,15,100] λ> toList v [10,5,6,20,15,100] λ> arvParaList v [10,5,6,20,15,100] λ> n = 3 λ> :t n n :: Num a => a λ> n 3 λ> :t n n :: Integer λ>