4 ms·
Haskell doesn't call that pattern matching, or at least I've never heard that usage. What Haskell calls pattern matching is if you have a single type (e.g. May
by irishsultan 10y ago
Haskell doesn't call that pattern matching, or at least I've never heard that usage.
What Haskell calls pattern matching is if you have a single type (e.g. Maybe a) with two different constructors (in this case Just and Nothing) where "Just something" will match with a value constructed with that first constructor and Nothing with the second constructor.
Note that his isn't the only thing you have wrong, there are no values of type Num, because Num is not a type. In the expression "inc :: Num a => a -> a" the only type is a, which has a restriction namely that the type has to implement the Num typeclass. The parameters don't have a name in the type signature.