=> vs. -> (equal-greater-than vs. dash-greater-than)

How did the syntax end up with two different tokens---"=>" for separating a pattern from its action in a match rule, and "->" for separating the arg list and the return type in a function definition?

I'm guessing it makes some sense to make them different, because -> will point at a type, while => will point at an expression.



This question could be construed as implying a criticism, since one token (either one) would have been enough (I think), and instead one has to remember which is which. But this is pretty minor. I am curious as to how it got to be this way, because it might reveal aspects of design history, process, and priorities.

-> in function types comes from math notation https://en.wikipedia.org/wiki/Function_space, and is pretty common from other functional languages https://en.wikipedia.org/wiki/Function_type#Programming_languages.

=> is also used in SML (which uses case for matching). It's helpful for it to be a different token in case we ever get something where patterns end in a type, to avoid a x: fn(A)->B ambiguity. (Is that x a fn(A) that results in the const B, or a function that returns the type B?)

Thanks! I didn't think of patterns ending with a type.