[Haskell-beginners] Beginners Digest, Vol 111, Issue 4

Jack Brandt jackbrandt11 at gmail.com
Mon Sep 4 17:33:30 UTC 2017


Would a specialization of return work, as in

f = return :: Maybe a -> IO (Maybe a)?

On Mon, Sep 4, 2017 at 7:00 AM, <beginners-request at haskell.org> wrote:

> Send Beginners mailing list submissions to
>         beginners at haskell.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
> or, via email, send a message with subject or body 'help' to
>         beginners-request at haskell.org
>
> You can reach the person managing the list at
>         beginners-owner at haskell.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Beginners digest..."
>
>
> Today's Topics:
>
>    1.  I have a -> f a. How to get m a -> f m a  ? (Baa)
>    2. Re:  I have a -> f a. How to get m a -> f m a ? (Imants Cekusins)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 4 Sep 2017 15:06:34 +0300
> From: Baa <aquagnu at gmail.com>
> To: beginners at haskell.org
> Subject: [Haskell-beginners] I have a -> f a. How to get m a -> f m a
>         ?
> Message-ID: <20170904150634.230dd5ff at Pavel>
> Content-Type: text/plain; charset=US-ASCII
>
> Hello List!
>
> I have function a -> IO a. How to get function:
>
>   Maybe a -> IO (Maybe a)  ?
>
> I found in Haskell mails archive such thing:
>
>    class IFunctor f where
>      imap :: Idiom i => (s -> i t) -> f s -> i (f t)
>
> which looks similar, but I didn't find any helpfull instances of
> `IFunctor` class in its package (and unfortunately I don't know what are
> the indexed types: IMonad, IFunctor, etc). Sure, there is the primitive
> solution like:
>
>    myfunc :: a -> IO a
>    ...
>    f x = case x of Nothing -> return Nothing
>                    Just x' -> Just <$> myfunc x'
>
> but more interesting is to know more standard and Haskelish solution
> (like lift's, etc). May be I miss something very obvious..
>
> ===
> Best regards, Paul
>
>
> ------------------------------
>
> Message: 2
> Date: Mon, 4 Sep 2017 15:14:42 +0300
> From: Imants Cekusins <imantc at gmail.com>
> To: The Haskell-Beginners Mailing List - Discussion of primarily
>         beginner-level topics related to Haskell <beginners at haskell.org>
> Subject: Re: [Haskell-beginners] I have a -> f a. How to get m a -> f
>         m a ?
> Message-ID:
>         <CAP1qinaEhE6HqvS0O9-CfV9Vc2x8ZvfQ_SRFXQgVH-
> yhapZZtg at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> > I have function a -> IO a. How to get function:
> >  Maybe a -> IO (Maybe a)  ?
>
> Will mapM work:
>
> http://hackage.haskell.org/package/base-4.10.0.0/docs/
> Data-Traversable.html#v:mapM
>
> ?
>
>
>
> On 4 September 2017 at 15:06, Baa <aquagnu at gmail.com> wrote:
>
> > Hello List!
> >
> > I have function a -> IO a. How to get function:
> >
> >   Maybe a -> IO (Maybe a)  ?
> >
> > I found in Haskell mails archive such thing:
> >
> >    class IFunctor f where
> >      imap :: Idiom i => (s -> i t) -> f s -> i (f t)
> >
> > which looks similar, but I didn't find any helpfull instances of
> > `IFunctor` class in its package (and unfortunately I don't know what are
> > the indexed types: IMonad, IFunctor, etc). Sure, there is the primitive
> > solution like:
> >
> >    myfunc :: a -> IO a
> >    ...
> >    f x = case x of Nothing -> return Nothing
> >                    Just x' -> Just <$> myfunc x'
> >
> > but more interesting is to know more standard and Haskelish solution
> > (like lift's, etc). May be I miss something very obvious..
> >
> > ===
> > Best regards, Paul
> > _______________________________________________
> > Beginners mailing list
> > Beginners at haskell.org
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mail.haskell.org/pipermail/beginners/
> attachments/20170904/f82f05da/attachment-0001.html>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
> ------------------------------
>
> End of Beginners Digest, Vol 111, Issue 4
> *****************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20170904/9b4c0ee6/attachment-0001.html>


More information about the Beginners mailing list