Why Range syntax got removed in favor of List.range

341 views
Skip to first unread message

أحمد حبنكة

unread,
Nov 12, 2016, 6:53:05 PM11/12/16
to Elm Discuss
I was reading the elm-dev list and I knew that elm 0.18 removed the range syntax, so code like this : 
[2..3]
won't work anymore.

I want to know what are the foundations behind this decision ?

Max Goldstein

unread,
Nov 12, 2016, 7:28:38 PM11/12/16
to Elm Discuss
One explanation I've heard is, "if we didn't have this piece of syntax, would we add it today?" And we wouldn't. The other reason is that it's hard to search for in documentation. Finally, the implementation was buggy if you tried to use floats (although I agree that's a weak excuse!).

Robin Heggelund Hansen

unread,
Nov 12, 2016, 9:01:55 PM11/12/16
to Elm Discuss
I remember Evan said that range syntax was one of the things he was asked most about from new coders. Not only "what's this?" but also "how do I make a range, I couldn't find anything in the documentation."

Then one comes to realize that there are other problems with range syntax. In addition to being more syntax to learn, and harder to discover through documentation, it's also not as flexible as a regular function. Then you also have to ask yourself if you use ranges enough that it actually warrants its own syntax.

Joey Eremondi

unread,
Nov 12, 2016, 9:44:15 PM11/12/16
to elm-d...@googlegroups.com
it's also not as flexible as a regular function

For example, if you want the range [0 .. n] for n in [0 .. k]:

Old syntax:
  map (\x -> [0 .. x]) [0 .. k]
New syntax:
  map (Range 0) (Range 0 k)

Not much savings in terms of length, but one less lambda, since it turns into a partial application.

One of the main goals of elm is simplicity: with a small core of features that are easy for someone to learn. It's much easier to learn all of Elm than all of Haskell, Java, C#, or even JS. So when we can make the language smaller with virtually no harm, we do.

There's nothing special about ranges, so they don't get special treatment. They were there probably only as a leftover from Haskell, and many of those leftovers have already been removed (i.e. $ and . replaced with <| and <<)
.

--
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.

أحمد حبنكة

unread,
Nov 13, 2016, 10:58:32 AM11/13/16
to Elm Discuss
hmmm if it is "can't find it in the documentation" then fix the documentation, when the documentation is unfixable for this feature I think it may be better to remove it, was this the case ?  

The syntax of ranges is not specific to haskell, ruby and some other languages implement it.  

Now for the fact that most new coders ask "what's this" or "how do I make a range" maybe the problem lies in the docs not in the feature itself.  

still if it is confusing for most beginners then I agree it's probably better to remove it although I find hard to believe that this feature is hard to understand !! 

Robin Heggelund Hansen

unread,
Nov 13, 2016, 2:04:52 PM11/13/16
to Elm Discuss
Fixing the docs could of course be done, and you're right, it's not something that's hard to understand. However, the question you should be asking is "is there any reason why range isn't  a function to begin with?"

Andrew Radford

unread,
Nov 13, 2016, 4:37:34 PM11/13/16
to Elm Discuss
Yeah It would be great if there was [x..y] and Range

Francesco Orsenigo

unread,
Nov 13, 2016, 4:47:17 PM11/13/16
to Elm Discuss

Why would you want two different (and entirely equivalent) solutions to the same problem?

Andrew Radford

unread,
Nov 13, 2016, 5:21:46 PM11/13/16
to Elm Discuss
Simply cause then I can use whichever one suits best, makes the code more readable etc

Francesco Orsenigo

unread,
Nov 13, 2016, 5:32:12 PM11/13/16
to elm-d...@googlegroups.com
What do you mean with "suits best"?
Readability is largely a matter of familiarity.
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Elm Discuss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/elm-discuss/z8t8u2f3iWk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> elm-discuss...@googlegroups.com.

joseph ni

unread,
Nov 13, 2016, 5:50:06 PM11/13/16
to Elm Discuss
The _real_ question is why List.Range only increments, List.Range 5 1 = [ ]

Max Goldstein

unread,
Nov 13, 2016, 7:43:49 PM11/13/16
to Elm Discuss
Sometimes it's useful to pass arguments to List.range and have it be empty when a > b.

Perhaps there should be List.rangeWithStep 5 1 -1 to solve your problem.

Andrew Radford

unread,
Nov 14, 2016, 1:43:01 AM11/14/16
to Elm Discuss
Not really, with familiar symbols, you can construct very unreadable things.

أحمد حبنكة

unread,
Nov 14, 2016, 4:27:14 PM11/14/16
to Elm Discuss
hmmm I agree, if we want to make it a function though then we can replace the `List.range` function with `..` operator and construct ranges like this `1..2` (no need for brackets)

This is how it's done in ruby and it's a function :) , the range syntax removal is acceptable in this situation but replacing it with `List.range 1 5` seems liitle bad for me

As for floating points we could remove support for them altogether as I don't think anyone would use it anyway, if intervals are needed then a data structure other than lists is going to be better.

أحمد حبنكة

unread,
Nov 14, 2016, 4:29:58 PM11/14/16
to Elm Discuss
What do you think about my suggestion in previous reply ? replacing List.range with List.(..) operator ?

Witold Szczerba

unread,
Nov 14, 2016, 6:09:18 PM11/14/16
to elm-d...@googlegroups.com
I think List.range is just fine. No need for special syntax and strange function names like ".." (hard to browse, find online, etc.). 

--
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.

Francesco Orsenigo

unread,
Nov 14, 2016, 6:13:08 PM11/14/16
to elm-d...@googlegroups.com
Yup.
It is just not used often enough to warrant special syntax.

On Tue, Nov 15, 2016 at 10:09 AM, Witold Szczerba
<witold...@gmail.com> wrote:
> I think List.range is just fine. No need for special syntax and strange
> function names like ".." (hard to browse, find online, etc.).
>
> On Mon, Nov 14, 2016 at 10:29 PM, أحمد حبنكة <ahmad1...@gmail.com>
> wrote:
>>
>> What do you think about my suggestion in previous reply ? replacing
>> List.range with List.(..) operator ?
>>
>>
>> بتاريخ الاثنين، 14 نوفمبر، 2016 2:43:49 ص UTC+2، كتب Max Goldstein:
>>>
>>> Sometimes it's useful to pass arguments to List.range and have it be
>>> empty when a > b.
>>>
>>> Perhaps there should be List.rangeWithStep 5 1 -1 to solve your problem.
>>
>> --
>> 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...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Elm Discuss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/elm-discuss/z8t8u2f3iWk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> elm-discuss...@googlegroups.com.

Joey Eremondi

unread,
Nov 14, 2016, 6:14:58 PM11/14/16
to elm-d...@googlegroups.com
It's also worth mentioning that adding syntax for something usually indicates that it's a "core" feature.

In C-like languages, looping from integers in a range is the key iteration structure. But in Elm, fold and map are much more important. So having special syntax could give beginners the idea that [..] is a primary iteration tool, when it actually comes up in relatively few cases.

On Mon, Nov 14, 2016 at 3:13 PM, Francesco Orsenigo <francesco...@gmail.com> wrote:
Yup.
It is just not used often enough to warrant special syntax.

On Tue, Nov 15, 2016 at 10:09 AM, Witold Szczerba
<witold...@gmail.com> wrote:
> I think List.range is just fine. No need for special syntax and strange
> function names like ".." (hard to browse, find online, etc.).
>
> On Mon, Nov 14, 2016 at 10:29 PM, أحمد حبنكة <ahmad1...@gmail.com>
> wrote:
>>
>> What do you think about my suggestion in previous reply ? replacing
>> List.range with List.(..) operator ?
>>
>>
>> بتاريخ الاثنين، 14 نوفمبر، 2016 2:43:49 ص UTC+2، كتب Max Goldstein:
>>>
>>> Sometimes it's useful to pass arguments to List.range and have it be
>>> empty when a > b.
>>>
>>> Perhaps there should be List.rangeWithStep 5 1 -1 to solve your problem.
>>
>> --
>> 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

>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Elm Discuss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/elm-discuss/z8t8u2f3iWk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to

> For more options, visit https://groups.google.com/d/optout.

--
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.

Andrew Radford

unread,
Nov 15, 2016, 5:59:52 AM11/15/16
to Elm Discuss
Lists are pretty core, I don't really have a problem with short expressive syntax that reads well. 'Well' meaning closer to reading like English. i.e I'd never say "I'll drink Bourbon on the range of days from 1 to 3, then Scotch on the days that range from day 4 to day 7". No way, it's just "Bourbon on days 1-3, Scotch on days 4-7". In other words, when you declare a range, the more interesting and important thing you are trying to express is what you are doing with that range - i.e. what I'm drinking, the 'List.Range' clutter waters that down as noise in a lot of cases.

I can see this is probably a 50/50 among users - so although I personally will miss it a little bit, I can see how the decision to make it easier for newcomers to the language to get started would tip the balance in favor of List.Range. After all, 'Lets be mainstream' effectively means 'Let's convert people who currently just use JS' so this call must be in pursuit of increasing the 'conversion ratio'




On Monday, 14 November 2016 23:14:58 UTC, Joey Eremondi wrote:
It's also worth mentioning that adding syntax for something usually indicates that it's a "core" feature.

In C-like languages, looping from integers in a range is the key iteration structure. But in Elm, fold and map are much more important. So having special syntax could give beginners the idea that [..] is a primary iteration tool, when it actually comes up in relatively few cases.
On Mon, Nov 14, 2016 at 3:13 PM, Francesco Orsenigo <francesco...@gmail.com> wrote:
Yup.
It is just not used often enough to warrant special syntax.

On Tue, Nov 15, 2016 at 10:09 AM, Witold Szczerba
<witold...@gmail.com> wrote:
> I think List.range is just fine. No need for special syntax and strange
> function names like ".." (hard to browse, find online, etc.).
>
> On Mon, Nov 14, 2016 at 10:29 PM, أحمد حبنكة <ahmad1...@gmail.com>
> wrote:
>>
>> What do you think about my suggestion in previous reply ? replacing
>> List.range with List.(..) operator ?
>>
>>
>> بتاريخ الاثنين، 14 نوفمبر، 2016 2:43:49 ص UTC+2، كتب Max Goldstein:
>>>
>>> Sometimes it's useful to pass arguments to List.range and have it be
>>> empty when a > b.
>>>
>>> Perhaps there should be List.rangeWithStep 5 1 -1 to solve your problem.
>>
>> --
>> 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

>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Elm Discuss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/elm-discuss/z8t8u2f3iWk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to

> For more options, visit https://groups.google.com/d/optout.

--
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...@googlegroups.com.

Witold Szczerba

unread,
Nov 15, 2016, 7:15:13 AM11/15/16
to elm-d...@googlegroups.com
I really like the change (getting rid of an exceptional syntax), but what's more important is how other things adapts: see the example provided by Joey:
>For example, if you want the range [0 .. n] for n in [0 .. k]:
>
> Old syntax:
>   map (\x -> [0 .. x]) [0 .. k]
New syntax:
  map (Range 0) (Range 0 k)

OK, it's just very simple piece of code, imagine something more sophisticated… You can partially apply a function, but not the range syntax. In functional languages like Elm, the more you have is nothing but a normal function the better, other "building" blocks just get in the way.

Regards,
Witold Szczerba


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

Andrew Radford

unread,
Nov 15, 2016, 8:00:40 AM11/15/16
to Elm Discuss
I'd agree with all that - but it was also trivially achievable in 0.17. Make no mistake, this is a reduction of the Elm language, the gamble being that it will result in more new users moving to and sticking with Elm, than existing users bailing in favour of some other alternative. I suspect it will probably work.

Max Goldstein

unread,
Nov 15, 2016, 8:47:43 AM11/15/16
to Elm Discuss
If someone was so tenuously commuted to Elm that this syntax removal drives them away, oh well.

Yes, the Elm language is getting smaller. That's been true for a few releases now. Evan is trying to remove hurdles for new users (because we need a lot of new users!), not preserve legacy code (Elm is young and inherently easy to refactor).

Andrew Radford

unread,
Nov 15, 2016, 10:19:54 AM11/15/16
to Elm Discuss
I don't think flippantly dismissing anyone who abandons Elm as having a tenuous connection is fair.  A lot of existing users, especially long time users who when they started, may have done so because of the 'niceties' like this, and they are now being slowly eroded. Maybe you could say they are now better off going to purescript/websharper/whatever, but they are also the guys actually using Elm to get real stuff done, and  often act as evangelists /'recruiters' to bring more newcomers to Elm in the first place. Simplifying Elm to attract the JS hordes may be a good way to grow the user base, but it will come at the expense of some of these guys leaving, which is a bit sad. 

As usual, it's a tricky (but hopefully correct) BDFL decision for the good of the language ecosystem and usage, but not a clear slam-dunk for the language itself according to a lot of people.

Robin Heggelund Hansen

unread,
Nov 15, 2016, 10:30:52 AM11/15/16
to Elm Discuss
I seem to remember that the discussion to keep or remove range syntax was done here on the mailing list, and a lot of people had no hard feelings about it going away. This was very much a community decision.

Nick H

unread,
Nov 15, 2016, 11:59:50 AM11/15/16
to elm-d...@googlegroups.com
Responses ranged from "I'd rather get rid of it" to "I like it, but I wouldn't complain if it went away." There was also a lovely tangent about Hoogle.

Nobody was worried at that time that changing the syntax would drive away our existing user base. Maybe they were blinded by the fact that it's not that important.

Andrew Radford

unread,
Nov 15, 2016, 3:23:38 PM11/15/16
to Elm Discuss
No, it wasn't.  Some parts of the community were aware of it, but calling it a community decision is overstating it. 

Duane Johnson

unread,
Nov 15, 2016, 4:04:27 PM11/15/16
to elm-d...@googlegroups.com

On Tue, Nov 15, 2016 at 1:23 PM, 'Andrew Radford' via Elm Discuss <elm-d...@googlegroups.com> wrote:
No, it wasn't.  Some parts of the community were aware of it, but calling it a community decision is overstating it.

While I wish it were otherwise, my experience from other communities is that consensus (if that's what you're looking for), or even an attempt at complete inclusion, in community decision-making is both procedurally costly and an impediment to progress.

Nick H

unread,
Nov 15, 2016, 4:27:39 PM11/15/16
to elm-d...@googlegroups.com
What do you think about my suggestion in previous reply ? replacing List.range with List.(..) operator ?

Forgive me if somebody has already pointed this out, but it is very easy to write such a function yourself.

(..) : Int -> Int -> List Int
(..) a b = List.range a b

If this is something that people are interested in, I think it's worth adding to elm-community/list-extra

--
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.

Andrew Radford

unread,
Nov 15, 2016, 4:38:42 PM11/15/16
to Elm Discuss
I agree with you there. I'm just pointing out that calling this a community decision is misrepresenting things. 

Duane Johnson

unread,
Nov 15, 2016, 8:12:59 PM11/15/16
to elm-d...@googlegroups.com

On Tue, Nov 15, 2016 at 2:38 PM, 'Andrew Radford' via Elm Discuss <elm-d...@googlegroups.com> wrote:
I agree with you there. I'm just pointing out that calling this a community decision is misrepresenting things. 

What would a community decision look like to you (procedurally)?
Reply all
Reply to author
Forward
0 new messages