I'm trying to define any simple function that spans multiple lines in ghci, take the following as an example:
let abs n | n >= 0 = n
| otherwise = -n
So far I've tried pressing Enter after the first line:
Prelude> let abs n | n >= 0 = n
Prelude> | otherwise = -n
<interactive>:1:0: parse error on input `|'
I've also attempted to use the :{
and :}
commands but I don't get far:
Prelude> :{
unknown command ':{'
use :? for help.
I'm using GHC Interactive version 6.6 for Haskell 98 on Linux, what am I missing?
GHCi now has a multiline-input mode, enabled with :set +m. For example,
Prelude> :set +m
Prelude> let fac 0 = 1
Prelude| fac n = n * fac (n-1)
Prelude|
Prelude> fac 10
3628800