Friday 29 April 2016

Haskell: GHCi: multi line expressions


By default, GHCi don't allow multi line expressions. For example, try to type the expression `1+2*3` in multi lines. You can't.

Prelude> 1+

<interactive>:9:3:
    parse error (possibly incorrect indentation or mismatched brackets)


To span an expression across multiple lines, you need to use multiline block. You should type :{ to start a multi line block, and type :} to end multi line block.

Prelude> :{
Prelude| 1+
Prelude| 2
Prelude| *
Prelude| 3
Prelude| :}
7



Previous                                                 Next                                                 Home

No comments:

Post a Comment