This time it is case
expression. I was looking for a way in haskell to define constants so I wrote this:
one = 1
two = 2
three = 3
which n =
case n of
one -> "one"
two -> "two"
three -> "three"
_ -> "unknown"
Compiler warned me that there were overlapped patterns. I only realized what the warning meant after a while. one, two and three in case
patterns must have shadowed the definitions at the beginning of the file. Using guards worked:
one = 1
two = 2
three = 3
which n =
case n of
_ | n == one -> "one"
_ | n == two -> "two"
_ | n == three -> "three"
_ -> "unknown"