Cannot enter multiline operators in GHCi

let x=1 y=2 z=3 

doesn't work in GHCi, forcing me to use let {x=1;y=2;y=3} . How can I fix this problem?

+6
source share
1 answer

The documentation says:

GHCi also has a multi-line mode, enabled: set + m, in which GHCi automatically detects when the current statement is not completed, and allows you to add additional lines. Multi-line input ends with an empty string.

Multiline mode makes GHCi very similar, for example. Python interpreter:

 Prelude> :set +m Prelude> let x = 1 Prelude| y = 2 Prelude| z = 3 Prelude| Prelude> (x, y, z) (1,2,3) 

This hidden gem is great for playing with readable code!

If you want this to be the default behavior, you can create a .ghci file in your home directory using the line :set +m . (Now that it has come, I actually did it.)

+12
source

Source: https://habr.com/ru/post/951459/


All Articles