stefan@stefans-MacBook-Pro curs06 % stack ghci stack ghci Note: No local targets specified, so a plain ghci will be started with no package hiding or package options. You are using snapshot: lts-17.8 If you want to use package hiding and options, then you can try one of the following: * If you want to start a different project configuration than /Users/stefan/.stack/global-project/stack.yaml, then you can use stack init to create a new stack.yaml for the packages in the current directory. * If you want to use the project configuration at /Users/stefan/.stack/global-project/stack.yaml, then you can add to its 'packages' field. Configuring GHCi with the following packages: GHCi, version 8.10.4: https://www.haskell.org/ghc/ :? for help :l c06 :l c06 Loaded GHCi configuration from /private/var/folders/fz/fc0rvjms0vdgllq7mwph1tfr0000gn/T/haskell-stack-ghci/2a3bbd58/ghci-script Prelude> :l c06 [1 of 1] Compiling Main ( c06.hs, interpreted ) Ok, one module loaded. *Main> *Main> *Main> *Main> f 13 f 13 136 *Main> :r :r [1 of 1] Compiling Main ( c06.hs, interpreted ) Ok, one module loaded. *Main> swap (13, 14) swap (13, 14) (14,13) *Main> swap ('A', 14) swap ('A', 14) (14,'A') *Main> swap ('A', True) swap ('A', True) (True,'A') *Main> :r :r [1 of 1] Compiling Main ( c06.hs, interpreted ) Ok, one module loaded. *Main> ordoneaza (1, 3) ordoneaza (1, 3) (1,3) *Main> ordoneaza (3, 1) ordoneaza (3, 1) (1,3) *Main> ordoneaza ('A', 'B') ordoneaza ('A', 'B') ('A','B') *Main> ordoneaza ('C', 'B') ordoneaza ('C', 'B') ('B','C') *Main> :i Ord :i 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 a, Ord b) => Ord (Either a b) -- Defined in ‘Data.Either’ instance Ord a => Ord [a] -- Defined in ‘GHC.Classes’ instance Ord Word -- Defined in ‘GHC.Classes’ instance Ord Ordering -- Defined in ‘GHC.Classes’ instance Ord Int -- Defined in ‘GHC.Classes’ instance Ord Float -- Defined in ‘GHC.Classes’ instance Ord Double -- Defined in ‘GHC.Classes’ instance Ord Char -- Defined in ‘GHC.Classes’ instance Ord Bool -- Defined in ‘GHC.Classes’ instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n, Ord o) => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -- Defined in ‘GHC.Classes’ instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n) => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -- Defined in ‘GHC.Classes’ instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m) => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m) -- Defined in ‘GHC.Classes’ instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l) => Ord (a, b, c, d, e, f, g, h, i, j, k, l) -- Defined in ‘GHC.Classes’ instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k) => Ord (a, b, c, d, e, f, g, h, i, j, k) -- Defined in ‘GHC.Classes’ instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j) => Ord (a, b, c, d, e, f, g, h, i, j) -- Defined in ‘GHC.Classes’ instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i) => Ord (a, b, c, d, e, f, g, h, i) -- Defined in ‘GHC.Classes’ instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h) => Ord (a, b, c, d, e, f, g, h) -- Defined in ‘GHC.Classes’ instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g) => Ord (a, b, c, d, e, f, g) -- Defined in ‘GHC.Classes’ instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f) => Ord (a, b, c, d, e, f) -- Defined in ‘GHC.Classes’ instance (Ord a, Ord b, Ord c, Ord d, Ord e) => Ord (a, b, c, d, e) -- Defined in ‘GHC.Classes’ instance (Ord a, Ord b, Ord c, Ord d) => Ord (a, b, c, d) -- Defined in ‘GHC.Classes’ instance (Ord a, Ord b, Ord c) => Ord (a, b, c) -- Defined in ‘GHC.Classes’ instance (Ord a, Ord b) => Ord (a, b) -- Defined in ‘GHC.Classes’ instance Ord () -- Defined in ‘GHC.Classes’ instance Ord a => Ord (Maybe a) -- Defined in ‘GHC.Maybe’ instance Ord Integer -- Defined in ‘integer-gmp-1.0.3.0:GHC.Integer.Type’ *Main> :r :r [1 of 1] Compiling Main ( c06.hs, interpreted ) Ok, one module loaded. *Main> :r :r [1 of 1] Compiling Main ( c06.hs, interpreted ) Ok, one module loaded. *Main> ordoneaza (n2, n3) ordoneaza (n2, n3) *** Exception: c06.hs:(26,3)-(28,33): Non-exhaustive patterns in function <= *Main> :r :r [1 of 1] Compiling Main ( c06.hs, interpreted ) Ok, one module loaded. *Main> ordoneaza (n2, n3) ordoneaza (n2, n3) (Succ (Succ Zero),Succ (Succ (Succ Zero))) *Main> :r :r [1 of 1] Compiling Main ( c06.hs, interpreted ) Ok, one module loaded. *Main> ordoneaza (n2, n3) ordoneaza (n2, n3) (Succ (Succ (Succ Zero)),Succ (Succ Zero)) *Main> :i Num :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 Word -- Defined in ‘GHC.Num’ instance Num Integer -- Defined in ‘GHC.Num’ instance Num Int -- Defined in ‘GHC.Num’ instance Num Float -- Defined in ‘GHC.Float’ instance Num Double -- Defined in ‘GHC.Float’ *Main> :r :r [1 of 1] Compiling Main ( c06.hs, interpreted ) c06.hs:38:1: error: The type signature for ‘mister’ lacks an accompanying binding Perhaps you meant ‘mister'’ (Defined at c06.hs:43:1) | 38 | mister :: a -> a | ^^^^^^ Failed, no modules loaded. Prelude> :r :r [1 of 1] Compiling Main ( c06.hs, interpreted ) Ok, one module loaded. *Main> exf (10, 'A') exf (10, 'A') ('A',1) *Main> exf (-10, 'A') exf (-10, 'A') ('A',-1) *Main> exf (-23, 'A') exf (-23, 'A') ('A',-1) *Main> exf (-0, 'A') exf (-0, 'A') ('A',0) *Main> :r :r [1 of 1] Compiling Main ( c06.hs, interpreted ) c06.hs:77:36: error: parse error on input ‘then’ | 77 | else x > y then | ^^^^ Failed, no modules loaded. Prelude> :r :r [1 of 1] Compiling Main ( c06.hs, interpreted ) c06.hs:58:1: error: The type signature for ‘exf2’ lacks an accompanying binding Perhaps you meant ‘exf’ (Defined at c06.hs:52:1) | 58 | exf2 :: [a] -> a | ^^^^ c06.hs:69:41: error: Not in scope: type variable ‘b’ | 69 | data ABC a = Leaf | Node a (ABC a) (ABC b) deriving (Show, Eq) | ^ Failed, no modules loaded. Prelude> :r :r [1 of 1] Compiling Main ( c06.hs, interpreted ) c06.hs:58:1: error: The type signature for ‘exf2’ lacks an accompanying binding Perhaps you meant ‘exf’ (Defined at c06.hs:52:1) | 58 | exf2 :: [a] -> a | ^^^^ Failed, no modules loaded. Prelude> :r :r [1 of 1] Compiling Main ( c06.hs, interpreted ) Ok, one module loaded. *Main> insert 2 (insert 5 (insert 1 Leaf)) insert 2 (insert 5 (insert 1 Leaf)) Node 2 (Node 2 Leaf Leaf) (Node 5 Leaf Leaf) *Main> :r :r [1 of 1] Compiling Main ( c06.hs, interpreted ) Ok, one module loaded. *Main> insert 2 (insert 5 (insert 1 Leaf)) insert 2 (insert 5 (insert 1 Leaf)) Node 1 Leaf (Node 5 (Node 2 Leaf Leaf) Leaf) *Main> :r :r [1 of 1] Compiling Main ( c06.hs, interpreted ) Ok, one module loaded. *Main> f 10 f 10 :38:1: error: Variable not in scope: f :: t0 -> t *Main> :r :r Ok, one module loaded. *Main> fib 10 fib 10 55 *Main> fib 20 fib 20 6765 *Main> fib 30 fib 30 832040 *Main> fib 32 fib 32 2178309 *Main> :h :h Commands available from the prompt: evaluate/run : repeat last command :{\n ..lines.. \n:}\n multiline command :add [*] ... add module(s) to the current target set :browse[!] [[*]] display the names defined by module (!: more details; *: all top-level names) :cd change directory to :cmd run the commands returned by ::IO String :complete [] list completions for partial input string :ctags[!] [] create tags file for Vi (default: "tags") (!: use regex instead of line number) :def[!] define command : (later defined command has precedence, :: is always a builtin command) (!: redefine an existing command name) :doc display docs for the given name (experimental) :edit edit file :edit edit last module :etags [] create tags file for Emacs (default: "TAGS") :help, :? display this list of commands :info[!] [ ...] display information about the given names (!: do not filter instances) :instances display the class instances available for :issafe [] display safe haskell information of module :kind[!] show the kind of (!: also print the normalised type) :load[!] [*] ... load module(s) and their dependents (!: defer type errors) :main [ ...] run the main function with the given arguments :module [+/-] [*] ... set the context for expression evaluation :quit exit GHCi :reload[!] reload the current module set (!: defer type errors) :run function [ ...] run the function with the given arguments :script run the script :type show the type of :type +d show the type of , defaulting type variables :type +v show the type of , with its specified tyvars :unadd ... remove module(s) from the current target set :undef undefine user-defined command : :: run the builtin command :! run the shell command -- Commands for debugging: :abandon at a breakpoint, abandon current computation :back [] go back in the history N steps (after :trace) :break [] [] set a breakpoint at the specified location :break set a breakpoint on the specified function :continue resume after a breakpoint :delete ... delete the specified breakpoints :delete * delete all breakpoints :disable ... disable the specified breakpoints :disable * disable all breakpoints :enable ... enable the specified breakpoints :enable * enable all breakpoints :force print , forcing unevaluated parts :forward [] go forward in the history N step s(after :back) :history [] after :trace, show the execution history :list show the source code around current breakpoint :list show the source code for :list [] show the source code around line number :print [ ...] show a value without forcing its computation :sprint [ ...] simplified version of :print :step single-step after stopping at a breakpoint :step single-step into :steplocal single-step within the current top-level binding :stepmodule single-step restricted to the current module :trace trace after stopping at a breakpoint :trace evaluate with tracing on (see :history) -- Commands for changing settings: :set