[Haskell-cafe] Is it possible to make lazy combinators for IO?

David Feuer david.feuer at gmail.com
Mon Apr 18 20:26:08 UTC 2016


Urk.. I mean there's no need to execute the readLn action.
On Apr 18, 2016 4:18 PM, "David Feuer" <david.feuer at gmail.com> wrote:

> If
>
> f :: a -> IO a
>
> for some a, and I want to use
>
> mfix f
>
> then f must not inspect its argument in any way, or the computation
> will get stuck. In some cases, this seems a bit harsh. For example,
>
> mfix (\x -> fmap (3 :) (x `seq` readLn))
>
> looks perfectly reasonable. There is no need to inspect the return []
> action to know that the final result of the computation will begin
> with 3:. Is there a lazy IO mapping function somewhere that can work
> such magic?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160418/17aa3d14/attachment.html>


More information about the Haskell-Cafe mailing list