Raptors-MacBook-Pro:haskell preveen$ ghci
GHCi, version 9.2.7: https://www.haskell.org/ghc/ :? for help
ghci> tree = Node (Node Leaf 1 Leaf) 2 (Node Leaf 3 Leaf)
<interactive>:1:8: error:
Data constructor not in scope: Node :: t6 -> t7 -> t8 -> t
<interactive>:1:14: error:
Data constructor not in scope: Node :: t3 -> t4 -> t5 -> t6
<interactive>:1:19: error: Data constructor not in scope: Leaf
<interactive>:1:26: error: Data constructor not in scope: Leaf
<interactive>:1:35: error:
Data constructor not in scope: Node :: t0 -> t1 -> t2 -> t8
<interactive>:1:40: error: Data constructor not in scope: Leaf
<interactive>:1:47: error: Data constructor not in scope: Leaf
ghci> data Tree a = Leaf | Node (Tree a) a (Tree a)
ghci> instance Functor Tree where
<interactive>:3:10: warning: [-Wmissing-methods]
• No explicit implementation for
‘fmap’
• In the instance declaration for ‘Functor Tree’
ghci> fmap f Leaf = Leaf
ghci> fmap f (Node left a right) = Node (fmap f left) (f a) (fmap f right)
ghci> tree = Node (Node Leaf 1 Leaf) 2 (Node Leaf 3 Leaf)
ghci> newTree = fmap (*2) tree
ghci> Nothing
Nothing
ghci> data Maybe a = Nothing | Just a
ghci> a
<interactive>:10:1: error: Variable not in scope: a
ghci> :k Int
Int :: *
ghci> :k Maybe
Maybe :: * -> *
ghci> ->
<interactive>:13:1: error: parse error on input ‘->’
ghci> :t ->
<interactive>:1:1: error: parse error on input ‘->’
ghci> :k Just
<interactive>:1:1: error:
Not in scope: type constructor or class ‘Just’
A data constructor of that name is in scope; did you mean DataKinds?
ghci> :t Just
Just :: a -> Maybe a
ghci> :t Some
<interactive>:1:1: error: Data constructor not in scope: Some
ghci> :k Some
<interactive>:1:1: error:
Not in scope: type constructor or class ‘Some’
ghci> :t :k Just
<interactive>:1:1: error: parse error on input ‘:’
ghci> :k Just
<interactive>:1:1: error:
Not in scope: type constructor or class ‘Just’
A data constructor of that name is in scope; did you mean DataKinds?
ghci> :k Maybe
Maybe :: * -> *
ghci> :t Just
Just :: a -> Maybe a
ghci> :k []
[] :: * -> *
ghci> :t []
[] :: [a]
ghci> :k []
[] :: * -> *
ghci> [Int]
<interactive>:26:2: error:
• Illegal term-level use of the type constructor ‘Int’
imported from ‘Prelude’ (and originally defined in ‘GHC.Types’)
• In the expression: Int
In the expression: [Int]
In an equation for ‘it’: it = [Int]
ghci> :t [Int]
<interactive>:1:2: error:
• Illegal term-level use of the type constructor ‘Int’
imported from ‘Prelude’ (and originally defined in ‘GHC.Types’)
• In the expression: Int
In the expression: [Int]
ghci> :k [Int]
[Int] :: *
ghci> :t Just
Just :: a -> Maybe a
ghci> :t Maybe
<interactive>:1:1: error:
• Illegal term-level use of the type constructor ‘Maybe’
defined at <interactive>:9:1
• In the expression: Maybe
ghci> :k Maybe
Maybe :: * -> *
ghci> :k Tree
Tree :: * -> *
ghci> :t Tree
<interactive>:1:1: error:
• Illegal term-level use of the type constructor ‘Tree’
defined at <interactive>:2:1
• In the expression: Tree
ghci> :k ->
<interactive>:1:1: error: parse error on input ‘->’
ghci> :k (->)
(->) :: * -> * -> *
ghci> :k Int -> String
Int -> String :: *
ghci> data Funny f a = Funny a (f a)
ghci> :k Funny
Funny :: (* -> *) -> * -> *
ghci> :k map
<interactive>:1:1: error: Not in scope: type variable ‘map’
ghci> :t Map
<interactive>:1:1: error:
• Data constructor not in scope: Map
• Perhaps you meant variable ‘map’ (imported from Prelude)
ghci> :k Map
<interactive>:1:1: error:
Not in scope: type constructor or class ‘Map’
ghci> p :: Int
<interactive>:42:1: error: Variable not in scope: p :: Int
ghci> x :: Int
<interactive>:43:1: error: Variable not in scope: x :: Int
ghci> -- hello
ghci> x :: Int
<interactive>:45:1: error: Variable not in scope: x :: Int
ghci> Int
<interactive>:46:1: error:
• Illegal term-level use of the type constructor ‘Int’
imported from ‘Prelude’ (and originally defined in ‘GHC.Types’)
• In the expression: Int
In an equation for ‘it’: it = Int
ghci> a :: Integer
<interactive>:47:1: error: Variable not in scope: a :: Integer
ghci> x :: Integer = 10
ghci> y :: Int = 10
ghci> y
10
ghci> :t y
y :: Int
ghci> :x
unknown command ':x'
use :? for help.
ghci> :t x
x :: Integer
ghci> Integer == Int
<interactive>:54:1: error:
• Illegal term-level use of the type constructor ‘Integer’
imported from ‘Prelude’
(and originally defined in ‘GHC.Num.Integer’)
• In the first argument of ‘(==)’, namely ‘Integer’
In the expression: Integer == Int
In an equation for ‘it’: it = Integer == Int
ghci> :t Just
Just :: a -> Maybe a
ghci> :t head
head :: [a] -> a
ghci> :t tail
tail :: [a] -> [a]
ghci> :t fst
fst :: (a, b) -> a
ghci> :t ==
<interactive>:1:1: error: parse error on input ‘==’
ghci> :t (==)
(==) :: Eq a => a -> a -> Bool
ghci> :t (+)
(+) :: Num a => a -> a -> a
ghci> + 2
<interactive>:62:1: error: parse error on input ‘+’
ghci> (+ 2)
<interactive>:63:1: error:
• No instance for (Show (Integer -> Integer))
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
ghci> (+) 2
<interactive>:64:1: error:
• No instance for (Show (Integer -> Integer))
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
ghci> (+) 2 2
4
ghci> :t Eq
<interactive>:1:1: error:
• Illegal term-level use of the type constructor ‘Eq’
imported from ‘Prelude’ (and originally defined in ‘GHC.Classes’)
• In the expression: Eq
ghci> :t (Eq)
<interactive>:1:2: error:
• Illegal term-level use of the type constructor ‘Eq’
imported from ‘Prelude’ (and originally defined in ‘GHC.Classes’)
• In the expression: Eq
ghci> :k Eq
Eq :: * -> Constraint
ghci> :k elem
<interactive>:1:1: error: Not in scope: type variable ‘elem’
ghci> :t elem
elem :: (Foldable t, Eq a) => a -> t a -> Bool
ghci> :t show
show :: Show a => a -> String
ghci> :k show
<interactive>:1:1: error:
Not in scope: type variable ‘show’
Perhaps you meant type constructor or class ‘Show’ (imported from Prelude)
ghci> :k Integral
Integral :: * -> Constraint
ghci> :k Num
Num :: * -> Constraint
ghci> :k Floating
Floating :: * -> Constraint
ghci> :k Maybe
Maybe :: * -> *
ghci>