2 ms·
How on earth do those functional programmer folks always come up with the worst names for simple existing concepts, with totally different names? Worse than per
by rurban 10y ago
How on earth do those functional programmer folks always come up with the worst names for simple existing concepts, with totally different names? Worse than perl.
-> instead of comma?
-o / linear instead of refcaps?
"linear types" are certainly not linear. They are a simple reference capability, already in usage for decades. https://en.wikipedia.org/wiki/Object-capability_model https://en.wikipedia.org/wiki/Object-capability_model
e.g. https://tutorial.ponylang.org/capabilities/reference-capabilities.html https://tutorial.ponylang.org/capabilities/reference-capabil...
Consuming a value changes its type to enable reasoning for concurrency.
As to the claim: Sure. Not only makes a refcaps type system concurrency predictable, it also makes it decidable at compile-time, and much faster. rust could learn a lot from this to avoid locking.
- irishsultan 10y ago> -> instead of comma? Because a comma would be a very unusual notation to separate the parameter and return value of a function. For example a function with type "a -> b -> c" is not a function taking three parameters, it's a function taking something of type a returning another function of type (b -> c). Writing that as "a, b, c" would be an extremely weird way to write that.
- rurban 10y agoYes, I was wrong. I should have said () vs ->. You would write your "a -> b -> c" as (a) -> b (b) -> c and then combined: ((a) -> b) -> c. A function taking a function. But Haskell just flattens nested these lists. E.g. take this: inc :: Num a => a -> a is normally written as func inc (Num a) -> Num; 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. func inc (Num a) -> Num; func inc (Integer a) -> Integer; 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.
- Ericson2314 10y agoSorry you got the paren association wrong. It's right associative: curried function returns a function.
- irishsultan 10y agoHaskell 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.
- runeks 10y agoHaskell doesn't use a comma to separate function arguments because it doesn't try to follow tradition, but rather tries to take a step back, and rethink what a programming language is, using components that are as modular as possible. -> is not arbitrary notation, it's the symbol for a profunctor[1], and it has a very precise mathematical meaning. It's not made to be recognizable by programmers that are familiar with C notation, because that's a very high price to pay for the loss of generality offered. If you had chosen to separate the arguments to a function using a comma, you would have to invent new syntax to describe linearity (because you have one less comma than number of arguments). Many languages constantly invent new syntax to describe useful add-ons, until their compilers are too complex to maintain at reasonable cost. Haskell avoids this by having carefully chosen which constructs to build the language out of, instead of going for recognizability/tradition. [1] https://en.m.wikipedia.org/wiki/Profunctor https://en.m.wikipedia.org/wiki/Profunctor
- kagebe 10y agoLinear types are a more fundamental concept (in functional programming and type theory) than reference capabilities, since they apply to values of any type and a linear type system does not need any references or objects that have state and behaviour. The "linearity" of linear types comes from the typing rules of values with a linear type: They must be used exactly once. In fact, the simple typing rules of a linear type system allows one to implement all manner of capabilities and especially capabilities for references.
- kvb 10y agoThese are linear types by analogy to linear logic[0], so the terminology dates to the 80's at the latest. In contrast to your accusation, I think FP folks rarely make up terminology, usually preferring to borrow liberally from neighboring fields of mathematics. [0] https://en.wikipedia.org/wiki/Linear_logic https://en.wikipedia.org/wiki/Linear_logic