Proposal: Rename case..of -> match..with

179 views
Skip to first unread message

Robin Heggelund Hansen

unread,
Oct 20, 2016, 10:06:53 AM10/20/16
to Elm Discuss
First of, I would like to say that for me personally, this proposal doesn't matter.
This proposal is written because I believe people with little to no Elm experience will understand the construct better.

The proposal, as the title of the post suggests, is to rename the "case..of" expression to "match..with". The reason being that I believe the words better matches what the construct does. As a non-native English speaker, case..of doesn't immediately make sense. However, match..with makes perfect sense.

Match..with is what the same construct is called in F#, so it has that going for it.

Case..of to match..with renaming could be handled by elm-format.

As said, to me personally and, I believe, other seasoned elm devs, this won't matter that much.
The question therefore becomes, how big of a difference will it make to new and future elm developers?

António Ramos

unread,
Oct 20, 2016, 10:21:44 AM10/20/16
to elm-d...@googlegroups.com
I´m a "no Elm experience people" and i dont like "match with".

to type "case of" i need 6 keystrokes(without spaces) to type "match with" i need 9 .

i would prefer to remove the "of" and just leave it as "case ?!?  ->" instead of "case ?!? of ->" 

Regards to whomever lives to type less and love more... ;)

--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Peter Damoc

unread,
Oct 20, 2016, 10:46:42 AM10/20/16
to Elm Discuss
On Thu, Oct 20, 2016 at 5:06 PM, Robin Heggelund Hansen <skinn...@gmail.com> wrote:
The proposal, as the title of the post suggests, is to rename the "case..of" expression to "match..with".

One added benefit that I'm seeing is that today, if I would have to describe "case...of", I would use the words "pattern matching". :) 

I wonder if this has been discussed before.  I did a quick search but nothing jumped out as relevant. 

> case..of to match..with renaming could be handled by elm-format.

in theory, yes, it could be handled by a tool like elm-format but in practice, in order for it to be effective, it should be handled by something that is part of the elm-platform. 
this kind of a mechanical replacement would be OK if it would be handled right away and in an official manner.
requiring installing extra tools that come with alpha warnings might be scary. 


--
There is NO FATE, we are the creators.
blog: http://damoc.ro/

OvermindDL1

unread,
Oct 20, 2016, 10:56:50 AM10/20/16
to Elm Discuss
If this were done (plenty of other precedence, OCaml uses `match ... with` too), there could be a deprecation period where both are supported and `case ... of` generated deprecation warnings... 

Joey Eremondi

unread,
Oct 20, 2016, 12:16:49 PM10/20/16
to elm-d...@googlegroups.com

There's precedence in both directions, case comes from Haskell. So changing it doesn't necessarily mean we'll match everyone else, pardon the pun.

Being easier for non native English speakers seems pretty subjective, some people might find case more intuitive as non native speakers.

To me, case is better at capturing the idea of programming by cases, that it's a branching construct, not just a pattern matcher.

Both have pros and cons, and are roughly equal in my mind, but changing it would break literally all Elm code ever, so I think the status quo wins in this case.


--

Kasey Speakman

unread,
Oct 20, 2016, 5:36:30 PM10/20/16
to Elm Discuss
But `case` is a pattern matcher. Check out how it is used here in lieu of a parser.

To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss...@googlegroups.com.

Wouter In t Velt

unread,
Oct 21, 2016, 11:09:07 AM10/21/16
to Elm Discuss
Personally I prefer "case ... of"

I find it easier to read: "(in) case [this thing] (is) of [this pattern], (do) [this function]".
It is a variant of the "if ... then ... else .." syntax.

To me, "match ... with" would be less easy to read (although other languages apparently use it), but also more confusing: "match [this] with [that]" also suggests "make [this] equal to [that]"

joseph ni

unread,
Oct 23, 2016, 2:42:48 AM10/23/16
to Elm Discuss
> The reason being that I believe the words better matches what the construct does.

To me, `case x of` conveys *what* the construct does. It says, handle all the different cases/scenarios/possibilities of `x` as follows. Ties in nicely with the compiler msg: "You haven't handled these cases of this type".

`match x with` conveys *how* it does it. I'm going to match `x` with some destructured patterns below but it says nothing about what those patterns are so we are losing the intention of the construct imo.

In some crude sense, it would be like renaming `List.map` to `List.turnAintoB`. The former is more about intention, the latter about implementation.
Reply all
Reply to author
Forward
0 new messages