<div dir="ltr"><div><span style="font-size:12.8px">> I have function a -> IO a. How to get function:</span><br style="font-size:12.8px"><span style="font-size:12.8px">> Maybe a -> IO (Maybe a) ?</span><br></div><div><br></div>Will mapM work:<div><br><div><a href="http://hackage.haskell.org/package/base-4.10.0.0/docs/Data-Traversable.html#v:mapM">http://hackage.haskell.org/package/base-4.10.0.0/docs/Data-Traversable.html#v:mapM</a><br></div><div><br></div><div>?</div><div><br></div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 4 September 2017 at 15:06, Baa <span dir="ltr"><<a href="mailto:aquagnu@gmail.com" target="_blank">aquagnu@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello List!<br>
<br>
I have function a -> IO a. How to get function:<br>
<br>
Maybe a -> IO (Maybe a) ?<br>
<br>
I found in Haskell mails archive such thing:<br>
<br>
class IFunctor f where<br>
imap :: Idiom i => (s -> i t) -> f s -> i (f t)<br>
<br>
which looks similar, but I didn't find any helpfull instances of<br>
`IFunctor` class in its package (and unfortunately I don't know what are<br>
the indexed types: IMonad, IFunctor, etc). Sure, there is the primitive<br>
solution like:<br>
<br>
myfunc :: a -> IO a<br>
...<br>
f x = case x of Nothing -> return Nothing<br>
Just x' -> Just <$> myfunc x'<br>
<br>
but more interesting is to know more standard and Haskelish solution<br>
(like lift's, etc). May be I miss something very obvious..<br>
<br>
===<br>
Best regards, Paul<br>
______________________________<wbr>_________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/beginners</a><br>
</blockquote></div><br></div>