Live data from Hacker News

Haskell style list comprehensions in Ruby

gist.github.com

11–20 of 29 posts

Re: Haskell style list comprehensions in Ruby

#11

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.

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?

Re: Haskell style list comprehensions in Ruby

#12
post #11

Earlier quoted context omitted.

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.

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 (* * * , &&&, ^>>, ^>^, , +++, |||, >>>, We don't need any help being confusing, people. We already have Monads, for god's sake.

Re: Haskell style list comprehensions in Ruby

#13

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

Re: Haskell style list comprehensions in Ruby

#14
post #4

This has no business being at the top of HN.

Why not? Seems pretty damn cool to me. Edit: didn't realise you were the author :)

It's awesomely cool, but it also defines a global method_missing, which puts you in for a world of pain before even considering the overloaded operators.

It's one of those hacks that are cute and great to play with and awesome proof of concept for new features, but if I saw it in a production codebase, I'd want to strangle someone.

Re: Haskell style list comprehensions in Ruby

#15
post #13

Earlier quoted context omitted.

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.

Re: Haskell style list comprehensions in Ruby

#17

As someone who is still learning Ruby and would like to learn Haskell I have no idea what is going on here. Would someone be kind enough to explain? Thanks.

It's just adding a syntactic construct to ruby which looks similar to haskells list comprehensions. Explanation for haskell: http://learnyouahaskell.com/starting-out#im-a-list-comprehen...

Re: Haskell style list comprehensions in Ruby

#18
post #13

Earlier quoted context omitted.

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

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

Re: Haskell style list comprehensions in Ruby

#19
Side question, rant. I love the syntactic side of list or dict comprehension (in python) and often use them but as soon as I have to debug or expand the functionality, I have to slice them into for loop. And then I hate myself for being lazy/clever and more and more, when I start typing a = [, I hear an internal voice: wait, aren't you being wrongfully clever one again?

I am the only one?

Re: Haskell style list comprehensions in Ruby

#20
post #11

Earlier quoted context omitted.

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…

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