haskell - How to define a function in ghci across multiple lines? -


I am trying to define any simple task which spreads several rows in ghci, as an example Do the following:

  Abn anne | N & gt; = 0 = N | Otherwise = -n  

So far I have tried to enter after the first line:

  prelude & gt; Abs N N & gt; = 0 = n Preface & gt; | Otherwise = -n & lt; Interactive & gt ;: 1: 0: Parse error on input `| I have tried to use the command: : { and :}  but I am not too far: 

  Prelude & gt; : {Unknown command ': {' use :? For help.  

I am using GHC interactive version 6.6 for Linux on Haskell 98, what am I missing?

, you can put them in just one line and Works (protectors do not care about vacancy)

  ab abs n | N & gt; = 0 = N | Otherwise = -n  

If you want to write your function with many definitions that match the pattern on the arguments, like:

  Fact 0 = 1 fact N = n * Fact (n-1)  

Then you will use definitions separately with semicolons

  let { Fact 0 = 1; Fact n = n * fact (n -1)}  

Comments