Applicative Comprehensions

Simon Peyton Jones simonpj at microsoft.com
Mon Oct 12 09:08:00 UTC 2015


Sounds reasonable to me.   Do-notation and comprehension notation are really just syntactic sugar for the same thing.

Simon

From: ghc-devs [mailto:ghc-devs-bounces at haskell.org] On Behalf Of David A Roberts
Sent: 12 October 2015 09:10
To: ghc-devs at haskell.org
Subject: Applicative Comprehensions

Hi,
I raised this question on #haskell, and was advised that this was probably the best place to discuss.
I see that Applicative Do is scheduled for GHC 8.0 [1], and was hoping that this might also enable support for Applicative Comprehensions [2]. Is this likely to be the case? If not, would it be difficult to extend the support for Applicative Do to also handle comprehensions? I'm willing to submit patches if necessary, but I'm not at all familiar with GHC internals, so would need some guidance.
I understand that comprehensions tend not to be used much in idiomatic Haskell, but I find them to be useful for implementing DSLs, so would really like to see this be supported. For example, a matrix could be written in a familiar notation:
> [ i + 2*j | i <- rows, j <- cols ]
which is a little more readable (to those not familiar with Haskell) than
> (\i j -> i + 2*j) <$> row <*> cols
or

> do { i <- rows; j <- cols; return (i + 2*j) }
[1] https://ghc.haskell.org/trac/ghc/wiki/Status/GHC-8.0.1#LandedinHEAD
[2] https://ghc.haskell.org/trac/ghc/wiki/GeneralizedMonadComprehensions#Applicativefunctor
--
David A Roberts
https://davidar.io<https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fdavidar.io&data=01%7c01%7csimonpj%40064d.mgd.microsoft.com%7c1b9d9b3d0c48462fe9b708d2d2dc85b7%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=TVwAqgK%2bfp8IxsiPnkBDQ6nRGZmCDB4oJNiGX%2f%2f9N8U%3d>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20151012/b77a18c9/attachment-0001.html>


More information about the ghc-devs mailing list