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

David Luposchainsky dluposchainsky at googlemail.com
Fri Nov 29 12:47:47 UTC 2013


On 29.11.2013 13:42, Ivan Lazar Miljenovic wrote:
> On 29 November 2013 23:35, David Luposchainsky
> <dluposchainsky at googlemail.com> wrote:
>
>> Async is a Functor (but not Applicative). When asyncs finish and you
>> poll their result with `wait`, you potentially get back an IO <thunk>.
>> (Just the first example that came to mind.)
> 
> Except wait :: Async a -> IO a, so it's actually in the IO monad
> (which _is_ a monad :p).

Sure, but now you're in IO (and can $! in IO of course). But sometimes
you may not want to `wait` just yet, and evaluate the Async's eventual
result directly to WHNF, so that if you then `wait`, you get an already
evaluated thing in IO.


More information about the Libraries mailing list