
9 Sep
2007
9 Sep
'07
10:12 a.m.
On Sun, 9 Sep 2007, Stuart Cook wrote:
(Inspired by this[1] reddit thread.)
When combining monadic and non-monadic code, I've often wished for a magical combinator of type
(Monad m) => ((a -> b) -> c) -> (a -> m b) -> m c
which would let me inject a monadic function into a pure one, then wrap the ultimate result to ensure that no nastiness escapes.
If the signature would be (Monad m) => ((a -> b) -> c) -> m (a -> b) -> m c it would be possible, and the implementation would be 'liftM'/'fmap'. In the Reader monad you can even convert (a -> m b) to m (a -> b)