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?
Filed under: Uncategorized | 3 Comments
“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.”
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.
Well.. I don\\\’t agree.. If you look it from the other side