Hacker News new | past | comments | ask | show | jobs | submit login

I haven't seen this Haskell syntax before:

  [1,3..10] ⇔ [1,3,5,7,9]
Imagine running into this one on a production system... Someone needs to make a 'Haskell: the good parts' or at least a lint.



How is that weird, it's just uses the increment from the first to second value as step and repeat as long as it's smaller than the end value. Python does the exact same thing:

    Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) 
    [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> range(1, 10, 2)
    [1, 3, 5, 7, 9]


> Someone needs to make a 'Haskell: the good parts' or at least a lint.

Someone needs to write a book about the good parts because you haven't learned the language? It's documented right in the Prelude[1] what this desugars into.

http://www.haskell.org/ghc/docs/latest/html/libraries/base/P...


You'll see that in a lot of languages that include list comprehensions as part of their syntax.


There is a linter, called hlint, which is extremely useful. It doesn't flag that, though, nor do I see any reason it should.


Are you implying it's complex? Because a lot of languages have list comprehensions[1] (list comprehensions are awesome!). Haskells is very close to the mathmatical set-builder notation[2].

An example of a more advanced one would be

    >> [2*x | x <- [0,1..25], x^2 `rem` 3 == 0]
    [0,6,12,18,24,30,36,42,48]

Also, there is HLint for Haskell linting purposes...

[1] http://en.wikipedia.org/wiki/List_comprehension#Examples_in_...

[2] http://en.wikipedia.org/wiki/Set-builder_notation#Parallels_...




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: