Proposal: Add a strict version of <$> for monads

David Luposchainsky dluposchainsky at
Fri Nov 29 12:32:48 UTC 2013

On 29.11.2013 13:19, Twan van Laarhoven wrote:
> In the same vein as strict fmap, does a strict (<*>) make sense as well?

I think this brings up a good point: strictness annotations may make
sense in multiple other scenarios, not just for fmap. Can't we
encapsulate similar functionality in a separate function first, wait for
it to settle, and then introduce infix versions of it if really necessary?

What about

    seqM :: Monad m => m a -> m a
    seqM m = m >>= (return $!)

This would allow local definitions of

    f  <$!>  x = seqM (f  <$>  x)
    mf <*!> mx = seqM (mf <*> mx)

until the dust settles. If <$!> is really used in abundance, then add
<$!> as an infix.

The reason why I'm hesitant to introduce a new infix for this is because
I think infix is generally less readable than letter-based names. I
agree that infix is good to have for functions you use a lot -- to the
point where the infix is the standard application, like >>= and <$> --
but for <$!> I don't see this (yet).


More information about the Libraries mailing list