Closed maxf closed 7 years ago
The =>
operator never was part of the language or core packages as far as I know. But it was a common idiom for apps to define
(=>) = (,)
and then use it as described in the FAQ. So unless that common usage has disappeared I think we should leave this FAQ item in place.
Thoughts, anyone?
I see. Makes sense. How do you define (=>) = (,) ?
Literally what you typed is what does it: (=>) = (,)
The type of (,)
is a -> b -> (a, b)
. That is, it takes two arguments and constructs a tuple value from them
The expression might look strange because the way to refer to an operator as a function value is to surround it by parens as above. Also, the tuple-forming operator (,)
is unusual because it has variations like (,,)
for producing tuples of different arities (3 in that case).
Maybe I missed something but (=>) = (,)
doesn't do it for me.
foo = (,)
works and lets you write foo 1 2
(but not (1 foo 2)
)
but
(=>) = (,)
yields a syntax error.
Perhaps you are trying it in elm-repl? It won't work there. It will work in code compiled with elm-make or at http://elm-lang.org/try.
You're right it works. I thought I'd tried. Anyway, this question should remain only if => is found a lot in existing code. I don't know if it's the case.
I think the existing description of =>
is fairly clear about it being an idiom and not part of the language. As such I'm inclined to leave the text as is.
Thanks for taking the time to contribute.
I can't find the commit where it's been removed but
["color" => "red"]
triggers an error, as of 0.18