Gabriella439 / Haskell-MMorph-Library

Monad morphisms
BSD 3-Clause "New" or "Revised" License
47 stars 26 forks source link

A more general hoist #25

Closed louispan closed 8 years ago

louispan commented 8 years ago

Is it possible for hoist to be even more general by making the hoisted return type existential? i.e. evenMoreGeneralHoist :: Monad m => (forall a b. m a -> n b) -> t m c -> t n d

Use case: I want to hoist MaybeT IO a to IO () by hoisting with void . runMaybeT. I like using MaybeT in conjunction with void $ runMaybeT $ forever as a way of terminating recursive loops.

Right now, hoisting with void . runMaybeT gives the following error: Couldn't match type ‘a’ with ‘()’ ‘a’ is a rigid type variable bound by a type expected by the context: MaybeT IO a -> IO a

louispan commented 8 years ago

Sorry, I take that back. I think I've misunderstood the usage of hoist. For my use case, I can just use runMaybeT.