How to write multiple lines function in GHCi in Haskell
:set +m
let's define a function called f(x) = x + 1 in multiple lines mode
>:set +m
>let
>f::Int->Int
>f x = x + 1
> -- the newline will end defintion of function f
>f 1
2
Apparently, there is some bug/issue in GHCi 7.10.3 for multiple line mode, e.g.
:{
ff::Int -> Int
ff x = x + 1
:}
ff 1, parse error on input ‘=’
GHCi 7.10.3 does not recognize 'prompt2' any more.
GHCi 8.4.3 use prompt-cont (stand for: prompt continuation)
Download the Haskell Framework (GHC and GHCi 8.4.3) and install it,
above error has not gone away
The problem is the last line need to be EMPTY line.
:{
ff::Int -> Int
ff x = x + 1
<-- empty line here
:}