Strictifying monadic values, take 3

Johan Tibell johan.tibell at gmail.com
Sat Apr 26 21:13:00 UTC 2014


+1 on <$!>

+0 on the other proposal, which will requires a local definition to be
useful.
On Apr 26, 2014 10:33 PM, "Edward Kmett" <ekmett at gmail.com> wrote:

> +1 for me on (<$!>). I have inlined it in multiple packages.
>
> I'm neutral on the other combinator.
>
> -Edward
>
>
> On Sat, Apr 26, 2014 at 3:14 PM, David Luposchainsky <
> dluposchainsky at googlemail.com> wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> (HTML-rendered version of the text below see [1])
>>
>>
>> Strictifying Monadic values
>> ===========================
>>
>> Half a year ago, Johan Tibell proposed adding a strict
>> equivalent to fmap [2]. This discussion got lost in details,
>> it was reopened, it ended in bikeshedding again. This is
>> a third attempt to get this through, with individual
>> options and no alternatives proposed, compiled from the
>> two more popular responses in the other threads.
>>
>> Please do not propose alternative implementations here,
>> we've been through this twice already. Vote ±1 on each
>> point to show (dis)agreement. I think this functionality
>> should be in the standard libraries in one way or
>> another, regardless of how it's named in the end.
>>
>>
>>
>> 1. Add a strict version of <$>, named <$!>.
>>
>>   ```haskell
>>   infixl 4 <$!>
>>
>>   (<$!>) :: Monad m => (a -> b) -> m a -> m b
>>   f <$!> m = do x <- m
>>                 return $! f x
>>   ```
>>
>>   This is closely related to fmap in terms of functionality,
>>   but requires a Monad constraint.
>>
>>   This would allow defining
>>
>>   ```haskell
>>   seqM m = id <$!> m
>>   ```
>>
>>   if such a function is needed.
>>
>>
>>
>> 2. Add a seqM function that evaluates the "contents" of a
>>   monadic action to WHNF.
>>
>>   ```haskell
>>   seqM :: Monad m => m a -> m a
>>   seqM m = do x <- m
>>               return $! x
>>   ```
>>
>>   This is less close to fmap, but allows building other
>>   strict operations (locally and as needed) based on it
>>   easier, for example
>>
>>   ```haskell
>>    f <$!>  x = seqM ( f <$>  x)
>>   mf <*!> mx = seqM (mf <*> mx)
>>   mf <*!  mx = seqM (mf <*  mx)
>>   mf  *!> mx = seqM (mf  *> mx)
>>   ```
>>
>>   If these operators then turn out to be used (and locally
>>   reinvented) very often by different people, reconsider
>>   adding them as well.
>>
>>
>>
>> A voting period of two weeks (until 10-05-2014) should be
>> sufficient to allow everyone to join in.
>>
>>
>> Greetings,
>> David
>>
>>
>> Links:
>> [1]: https://github.com/quchen/articles/blob/master/seqm_proposal.md
>> [2]: http://www.haskell.org/pipermail/libraries/2013-November/021728.html
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.14 (GNU/Linux)
>> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>>
>> iQEcBAEBAgAGBQJTXAWmAAoJELrQsaT5WQUs9GgH/3Vr2nDUDyX7pU24Vs0Dfq6e
>> 43xcgY5ZBXCk/v/L6b14DA2br+jc32GkAnwkoWvJYQDNc6E6QwdPUnyaFpNPthA3
>> 7NDcuGukJPzpkkA/YCVqq4Yu6jIwjcVm/xMQaRmASWMnlJxEypFuuMirWVUgg+ED
>> Zl9x2VUoFUoRq6TpE1TGcOS0eoevqvu7LDdTJkGEC7wNxZOD4a2hjyiv90e2LmYL
>> mP0pPKVj2NfSjIfDa/q+ONIHN+hrQqriku9OJSGU8UVxOfAvi86W42xsFV6fNdVE
>> OKc/TTKM4V23G7qw3Dpz1EGnXqqLdYlv1ck2EF05tmSOjJ6Bx2lAUBypRyjX6IA=
>> =+wNo
>> -----END PGP SIGNATURE-----
>> _______________________________________________
>> Libraries mailing list
>> Libraries at haskell.org
>> http://www.haskell.org/mailman/listinfo/libraries
>>
>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140426/0a4207bd/attachment.html>


More information about the Libraries mailing list