Quantcast

Monads of functions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Monads of functions

Szymon Pajzert
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

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Monads of functions

Szymon Pajzert
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 <[hidden email]> 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


_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Loading...