[Haskell-cafe] What does "1 = 2" mean in Haskell?

ok at cs.otago.ac.nz ok at cs.otago.ac.nz
Sun Feb 26 23:34:20 UTC 2017


>
> Furthermore, you would not want
> ```
> main = let 1 = 2 in print "foo"
> ```
> to error, since the pattern match is unused, and haskell is a lazy
> language.

That's not at all clear.  In fact, I believe this thread exists
because the OP's daughter expected that it WOULD raise an error.

For what it's worth,
    Start = let 1 = 2 in "hello"
is rejected by the Clean compiler, even though Clean is much
like Haskell, and 1 is otherwise allowed as a pattern.

If nothing else, it would be nice to have a "dead code" warning
from the compiler about code that is certain not to be evaluated.
"2" counts as dead code in this example.




More information about the Haskell-Cafe mailing list