Mo’ comprehensions

30Dec06

I was solving some programming puzzles today, and found myself pining for Map comprehensions.

Maybe there should be a Comprehensible class that’s automatically mapped to comprehension syntax. It’s rather odd to have them only for lists. That would be both more general and more elegant than just bringing back monad comprehensions.

Is there any obvious reason why this wouldn’t work?

About these ads


3 Responses to “Mo’ comprehensions”

  1. “Sometime before the Haskell 98 standard the list comprehension syntax was first generalized to monad comprehension but then specialized back as it caused type ambiguity: ['c'] wouldn’t mean a list of one element, the character c, but the result of return ‘c’ in any monad.”

  2. 2 Dylan Thurston

    Furthermore, Map and Set aren’t even monads, since they require the extra equality type constraint on their argument. The advantage of comprehensions over monad notation is quite small, but the do notation is nice and I wish there were some way to support that.

  3. Well.. I don\\\’t agree.. If you look it from the other side


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: