[Haskell-cafe] 1 = 0?
Vo Minh Thu
noteed at gmail.com
Tue Jun 17 10:54:38 UTC 2014
2014-06-17 12:51 GMT+02:00 Roman Cheplyaka <roma at ro-che.info>:
> * Alexey Muranov <alexey.muranov at gmail.com> [2014-06-17 03:25:10-0700]
>> Is this the expected behavior that
>>
>> 1 = 0
>>
>> does not raise any error? What does this mean?
>
> 1 is a valid (nullary) pattern, so yes. This pattern binding obviously fails.
>
> Prelude> let x at 1 = 0
> Prelude> x
> *** Exception: <interactive>:2:5-11: Irrefutable pattern failed for pattern x at 1
If it can make things clearer, you can do something similar with any
constructor:
> let Just x = Just 5 in x
> let Just x = Nothing in x
*** Exception: <interactive>:19:5-20: Irrefutable pattern failed for
pattern Data.Maybe.Just x
More information about the Haskell-Cafe
mailing list