Applicative Comprehensions

Simon Marlow marlowsd at gmail.com
Thu Oct 15 10:59:32 UTC 2015


On 12/10/2015 09:09, David A Roberts wrote:
> 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) }

Good idea - it's not currently implemented, but it wouldn't be hard to 
do.  Want to make a feature request and CC me on it?  Sounds like 
something that might just fit into my train journey to work :)

Cheers,
Simon


More information about the ghc-devs mailing list