Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think what you're complaining about is not syntax, but lack of syntax. There's nothing syntactially special about this "for loop"! What's the benefit of this then? Firstly, less to learn. If you already understand $ and lambdas, then you understand this structure, and can reuse your knowledge in many places, for example

    withTempFile "foo" $ \tmpFile -> do
       <do something with tmpFile>

    flip fmap myList $ \e -> do
      <do something with each element i>
And you can even create your own constructs. You're not limited to the ones that are built in.

(The [0..10] is actually syntax, and I think that's quite unfortunate. `range 0 10` would have been just as good.)



> (The [0..10] is actually syntax, and I think that's quite unfortunate. `range 0 10` would have been just as good.)

Well, Haskell is in fact flexible enough that you can define that range function.

But one reason to make it syntax is that you can define things like [0..], which would be between awkward to impossible to do with a single `range` function in Haskell.





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

Search: