Why is it that when I do range in Haskell, this works:
[LT .. GT]
but this doesn’t:
[LT..GT]
and what does this cryptic error mean:
<interactive>:1:2:
Failed to load interface for `LT':
Use -v to see a list of the files searched for.
<interactive>:1:2:
A section must be enclosed in parentheses thus: (`LT..` GT)
However, When I use Ints, the second form (without spaces) works:
[1..3]
It’s because
LT..is interpreted as the.operator in theLTmodule.It means GHC cannot find a module named
LT. The same message appears if you use a qualified name with a non-existing library:In Haskell, a section is an infix operator with a partial application, e.g.
(* 3), which is equivalent to\x -> x * 3.In your case,
LT..is interpreted as an infix.operator, and theGTis part of the section formed with this operator.A section must be enclosed in parenthesis, and since the misinterpretation does not, the parser will complain like this.
Another example of the error: