Reputation: 5645
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.
Upvotes: 4
Views: 311
Reputation: 28097
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.
Upvotes: 6
Reputation: 52290
you can just concatenate the strings:
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.")
this works for me
Upvotes: 3