I have a Haskell function which reports a long error message. Although I can write this message in one line, I want to break it into two or more e.g.
foo a b | a > b = a
| a == b = b
| otherwise = error "Blah blah blah blah in this line and
some more blah in this line also."
GHCi does not compile it. Any suggestion? A casual googleing did not produce any answer.
You can use ghc's multi-line string syntax for this:
foo a b | a > b = a
| a == b = b
| otherwise = error "Blah blah blah blah in this line and \
\some more blah in this line also."
For errors it doesn't matter much, but in other contexts it can be more efficient than concatenating strings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With