lifting

Lifting a higher order function in Haskell

試著忘記壹切 提交于 2019-11-26 22:40:58
I'm trying to construct a function of type: liftSumthing :: ((a -> m b) -> m b) -> (a -> t m b) -> t m b where t is a monad transformer. Specifically, I'm interested in doing this: liftSumthingIO :: MonadIO m => ((a -> IO b) -> IO b) -> (a -> m b) -> m b I fiddled with some Haskell wizardry libs and but to no avail. How do I get it right, or maybe there is a ready solution somewhere which I did not find? This can't be done generically over all MonadIO instances because of the IO type in a negative position. There are some libraries on hackage that do this for specific instances ( monad-control

Lifting a higher order function in Haskell

醉酒当歌 提交于 2019-11-26 08:24:02
问题 I\'m trying to construct a function of type: liftSumthing :: ((a -> m b) -> m b) -> (a -> t m b) -> t m b where t is a monad transformer. Specifically, I\'m interested in doing this: liftSumthingIO :: MonadIO m => ((a -> IO b) -> IO b) -> (a -> m b) -> m b I fiddled with some Haskell wizardry libs and but to no avail. How do I get it right, or maybe there is a ready solution somewhere which I did not find? 回答1: This can't be done generically over all MonadIO instances because of the IO type