Re:Linear types make performance more predictable
by irishsultan on Wednesday March 15, 2017 @10:24AM
(#13876284)
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.
Re:Linear types make performance more predictable
by Ericson2314 on Wednesday March 15, 2017 @10:13AM
(#13876206)
Sorry you got the paren association wrong. It's right associative: curried function returns a function.
E.g. take this:
is normally written as A function taking a Num and returning a Num. The a is normally written as T, a generic type variable, thus forbidding type-promotions from e.g. overflowing Integer to Num. This inc will wrap around.This is normally written without dependent types as generic for all subtypes.
Now Haskell calls that "pattern matching", but of course it is not pattern matching, it is polymorphism, static dispatch based on signatures. Pattern matching has a well-established meaning already, if strings or structural matching. Dispatch does much more than just matching. A match only finds exact candidates, dispatch also finds the closest candidate, which doesn't need to match.