Patterns like this:
front :: [a] -> a
front (x:_) = x
front _ = error "Empty list"
seem to be common in Haskell, but I distinctively remember learning the following when I started learning Haskell:
dec :: (Integral a) => a -> a
dec (x+1) = x
dec _ = error "Bottom"
However, ghc
appears to reject that piece of code, stating:
Parse error in pattern: x + 1
While hugs
accepts it just fine. So, is this valid Haskell or not and why do these compilers behave differently.