Skip to content

Comment on Haskell style list comprehensions in Ruby

Comments

Cue to Haskell people lamenting the fact that this is an abomination and not by any means "Haskell-style list comprehensions".

Still very nice though.

Haskell person here... I personally find Haskell list comprehensions to be ridiculously ugly, and are an unnecessary bit of syntactic sugar over the List Monad.

... you might want to read up on monad comprehensions :)

http://hackage.haskell.org/trac/ghc/wiki/MonadComprehensions

Okay, as much as I hate syntactic sugar... that's pretty freakin awesome.

That's all well and good, but why not just use do notation?

I find this interesting. As someone who emphatically doesn't know Haskell, but has recently started learning, I think list comprehensions are wonderful. That said, I haven't got to the chapter on Monads yet, so... :)

What do you find ugly about them?

List comprehensions as a programming technique are incredibly useful, don't get me wrong. I am just not a fan of syntactic sugar in general.

EDIT: On a more elaborate note, I think that the extreme variety of programming styles enabled by Haskell is more of a weakness than a strength. True, defining your own abstractions and operators is part of the fun, but seeing declarative style (pattern-matching in function defs, where blocks, function args on left-hand side, guards), expression style (let blocks, lambda abstractions, case statements, if clauses), applicative style (<$>, <* >, <$, <* , * >, <|>), and arrow style (* * * , &&&, ^>>, ^<<, >>^, <<^, <+>, +++, |||, >>>, <<<) all in the same file can get pretty overwhelming even if you're already pretty fluent in the language.

We don't need any help being confusing, people. We already have Monads, for god's sake.

"A monads is just a monoid in the category of endofunctors, what's the problem?"

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.