
I know about List Comprehensions, but what is a general Monad Comprehension? List Comprehensions are the use of set-builder notation to define a list, so I don't understand how that would generalize.

On Mon, Apr 7, 2014 at 3:33 PM, John M. Dlugosz
I know about List Comprehensions, but what is a general Monad Comprehension? List Comprehensions are the use of set-builder notation to define a list, so I don't understand how that would generalize.
Assuming that you have done a search and that you're still stumped, how can you make the question more specific? Do you think that quoting specific bits of what you have read might help us help you more? -- Kim-Ee

At one point of time, comprehensions were available for all monads. Then
it was removed, and has now been added back as a language extension (from
the cursory glance that I gave)
Basically, monad comprehensions are about using the samesyntactic sugar for
different monads (like the do notation)
Perhaps, this'll help (if you haven't seen this already)
https://ghc.haskell.org/trac/ghc/wiki/MonadComprehensions
On Mon, Apr 7, 2014 at 2:15 PM, Kim-Ee Yeoh
On Mon, Apr 7, 2014 at 3:33 PM, John M. Dlugosz
wrote: I know about List Comprehensions, but what is a general Monad Comprehension? List Comprehensions are the use of set-builder notation to define a list, so I don't understand how that would generalize.
Assuming that you have done a search and that you're still stumped, how can you make the question more specific?
Do you think that quoting specific bits of what you have read might help us help you more?
-- Kim-Ee
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On 4/7/2014 4:38 AM, akash g wrote:
At one point of time, comprehensions were available for all monads. Then it was removed, and has now been added back as a language extension (from the cursory glance that I gave)
Basically, monad comprehensions are about using the samesyntactic sugar for different monads (like the do notation)
Perhaps, this'll help (if you haven't seen this already)
Thanks for the answer, and for the link to a ghc/wiki in general!

On 04/07/2014 04:33 AM, John M. Dlugosz wrote:
I know about List Comprehensions, but what is a general Monad Comprehension? List Comprehensions are the use of set-builder notation to define a list, so I don't understand how that would generalize.
The set-builder notation to find the sums of elements from two lists looks like, list_sums = [ x + y | x <- [1,2,3], y <- [4,5,6] ] The way the list monad is defined, this is the same thing as, list_sums = do x <- [1, 2, 3] y <- [4, 5, 6] return (x + y) The set-builder notation is not obviously generalizable, but once you desugar it to do-notation, it's more clear that you could do the same thing with any monad. What actually happens might not be intuitive, but the desugaring will work at least. For the Maybe monad, you could do something like, maybe_sums = [ x + y | x <- Just 1, y <- Just 2 ] which will be desugared into, maybe_sums = do x <- Just 1 y <- Just 2 return (x + y) Any other monad will work the same.
participants (4)
-
akash g
-
John M. Dlugosz
-
Kim-Ee Yeoh
-
Michael Orlitzky