[Haskell-beginners] Monads of functions

Szymon Pajzert szymonpajzert at gmail.com
Sun May 7 10:44:46 UTC 2017


Colleague has helped me with the solution for the Reader, without general
solution (probably it's not possible to do so for every monad):

foo :: (a -> Reader r b) -> Reader r (a -> b)
foo f = do
    r <- ask
    return $ \a -> runReader (f a) r

Hope that's gonna help someone in the future.

On 6 May 2017 at 11:08, Szymon Pajzert <szymonpajzert at gmail.com> wrote:

> Hello,
>
> Lately I'm working with Reader monad. Because of that, I have to use
> function of signature:
>
> Monad m => (a -> m b) -> m (a -> b).
>
> Is this even possible to do so? Thanks in advance for your help.
>
> Best Regards,
> Szymon Pajzert
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20170507/ce020058/attachment.html>


More information about the Beginners mailing list