How to define a function in ghci across multiple lines
Posted
by Peter McGrattan
on Stack Overflow
See other posts from Stack Overflow
or by Peter McGrattan
Published on 2010-05-17T00:16:14Z
Indexed on
2010/05/17
0:20 UTC
Read the original article
Hit count: 656
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?
© Stack Overflow or respective owner