Edited to replace long parts of :info with ... poole@CPSC-M-POOLE01 haskell % ghci GHCi, version 9.4.8: https://www.haskell.org/ghc/ :? for help ghci> :type putChar putChar :: Char -> IO () ghci> :type getChar getChar :: IO Char ghci> :l IOAdder2 [1 of 1] Compiling IOAdder2 ( IOAdder2.hs, interpreted ) Ok, one module loaded. ghci> :type ask_Polite ask_Polite :: [Char] -> IO String ghci> :type show show :: Show a => a -> String ghci> :info 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 Double -- Defined in ‘GHC.Float’ instance Show Float -- Defined in ‘GHC.Float’ ... ghci> read "123" *** Exception: Prelude.read: no parse ghci> read "123" :Int :8:13: error: • Illegal term-level use of the type constructor or class ‘Int’ • imported from ‘Prelude’ at IOAdder2.hs:4:8-15 (and originally defined in ‘GHC.Types’) • In the second argument of ‘(:)’, namely ‘Int’ In the expression: read "123" : Int In an equation for ‘it’: it = read "123" : Int ghci> read "123" ::Int 123 ghci> read "123" ::Double 123.0 ghci> :info Read type Read :: * -> Constraint class Read a where readsPrec :: Int -> ReadS a readList :: ReadS [a] GHC.Read.readPrec :: Text.ParserCombinators.ReadPrec.ReadPrec a GHC.Read.readListPrec :: Text.ParserCombinators.ReadPrec.ReadPrec [a] {-# MINIMAL readsPrec | readPrec #-} -- Defined in ‘GHC.Read’ instance Read () -- Defined in ‘GHC.Read’ instance (Read a, Read b) => Read (a, b) -- Defined in ‘GHC.Read’ ... ghci> show (+3) :13:1: error: • No instance for (Show (Integer -> Integer)) arising from a use of ‘show’ (maybe you haven't applied a function to enough arguments?) • In the expression: show (+ 3) In an equation for ‘it’: it = show (+ 3) ghci> :info Eq type Eq :: * -> Constraint class Eq a where (==) :: a -> a -> Bool (/=) :: a -> a -> Bool {-# MINIMAL (==) | (/=) #-} -- Defined in ‘GHC.Classes’ instance Eq Integer -- Defined in ‘GHC.Num.Integer’ instance Eq () -- Defined in ‘GHC.Classes’ instance (Eq a, Eq b) => Eq (a, b) -- Defined in ‘GHC.Classes’ ... [1 of 1] Compiling Instanceeg ( Instanceeg.hs, interpreted ) Ok, one module loaded. ghci> Pos 3 4 == Pos 2.9999 4.00001 True ghci> Pos 3 4 == Pos 2.9999 4.01 False ghci> :l BSTree2 [1 of 1] Compiling BSTree ( BSTree2.hs, interpreted ) Ok, one module loaded. ghci> egtree Node 5 "alive" (Node 2 "be" Empty (Node 4 "fun" Empty Empty)) (Node 8 "food" Empty Empty) ghci> tolist egtree [(2,"be"),(4,"fun"),(5,"alive"),(8,"food")] ghci> :type fmap fmap :: Functor f => (a -> b) -> f a -> f b ghci> :type fmap (+1) [2..12] fmap (+1) [2..12] :: (Num b, Enum b) => [b] ghci> :type fmap (+1) fmap (+1) :: (Functor f, Num b) => f b -> f b ghci> :type map (+1) map (+1) :: Num b => [b] -> [b] ghci> fmap length egtree Node 5 5 (Node 2 2 Empty (Node 4 3 Empty Empty)) (Node 8 4 Empty Empty) ghci> fmap ("not"++) egtree Node 5 "notalive" (Node 2 "notbe" Empty (Node 4 "notfun" Empty Empty)) (Node 8 "notfood" Empty Empty) ghci> :info Functor type Functor :: (* -> *) -> Constraint class Functor f where fmap :: (a -> b) -> f a -> f b (<$) :: a -> f b -> f a {-# MINIMAL fmap #-} -- Defined in ‘GHC.Base’ instance Functor (BSTree k) -- Defined at BSTree2.hs:93:10 instance Functor ((,) a) -- Defined in ‘GHC.Base’ instance Functor ((,,) a b) -- Defined in ‘GHC.Base’ instance Functor ((,,,) a b c) -- Defined in ‘GHC.Base’ instance Functor ((->) r) -- Defined in ‘GHC.Base’ instance Functor IO -- Defined in ‘GHC.Base’ instance Functor Maybe -- Defined in ‘GHC.Base’ instance Functor Solo -- Defined in ‘GHC.Base’ instance Functor [] -- Defined in ‘GHC.Base’ instance Functor (Either a) -- Defined in ‘Data.Either’ ghci> fmap length egtree Node 5 5 (Node 2 2 Empty (Node 4 3 Empty Empty)) (Node 8 4 Empty Empty) ghci> fmap odd (fmap length egtree) Node 5 True (Node 2 False Empty (Node 4 True Empty Empty)) (Node 8 False Empty Empty) ghci> :type foldr foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b ghci> foldr (:) [] egtree ["be","fun","alive","food"] ghci> foldr (++) [] egtree "befunalivefood" ghci> :info 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 (BSTree k) -- Defined at BSTree2.hs:104:10 instance Foldable ((,) a) -- Defined in ‘Data.Foldable’ instance Foldable (Either a) -- Defined in ‘Data.Foldable’ instance Foldable Maybe -- Defined in ‘Data.Foldable’ instance Foldable Solo -- Defined in ‘Data.Foldable’ instance Foldable [] -- Defined in ‘Data.Foldable’ ghci> length egtree 4 ghci> maximum egtree "fun" ghci> foldl (flip (:)) [] egtree ["food","alive","fun","be"] ghci> sum (fmap length egtree) 14 ghci> Leaving GHCi. poole@CPSC-M-POOLE01 haskell % ghci GHCi, version 9.4.8: https://www.haskell.org/ghc/ :? for help ghci> :l BSTree3 [1 of 1] Compiling BSTree ( BSTree3.hs, interpreted ) Ok, one module loaded. ghci> foldr (:) [] egtree [(5,"alive"),(2,"be"),(4,"fun"),(8,"food")] ghci> :type (==) (==) :: Eq a => a -> a -> Bool ghci> foo t1 t2 = t1 == t2 ghci> instance Ord (BSTree k v) where t1 < t2 = length t1 < length t2 :5:15: error: • Expected kind ‘k -> *’, but ‘BSTree k’ has kind ‘*’ • In the first argument of ‘Ord’, namely ‘(BSTree k v)’ In the instance declaration for ‘Ord (BSTree k v)’ ghci> :info Ord type Ord :: * -> Constraint class Eq a => Ord a where compare :: a -> a -> Ordering (<) :: a -> a -> Bool (<=) :: a -> a -> Bool (>) :: a -> a -> Bool (>=) :: a -> a -> Bool max :: a -> a -> a min :: a -> a -> a {-# MINIMAL compare | (<=) #-} -- Defined in ‘GHC.Classes’ instance Ord () -- Defined in ‘GHC.Classes’ instance (Ord a, Ord b) => Ord (a, b) -- Defined in ‘GHC.Classes’ ... ghci>