Here's a class, I'm calling BlahMap
:
class BlahMap t where
blahMap :: (m a -> n b) -> t m a -> t n b
This is an instance of BlahMap
:
instance BlahMap (ReaderT r) where
blahMap f = ReaderT . fmap f . runReaderT
Is there an existing class in the Haskell ecosystem that does this? Or alternatively, can I just write a function blahMap
with appropriate constraints with existing classes in say mtl
or something similar? Or have I actually invented something new?
hoist
has type(forall a. m a -> n a) -> t m b -> t n b
, which is not exactly what you asked for in the OP. That being said,hoist
is probably what you're looking for and is a very useful function to know, so I like this answer. Just worth noting that the types don't exactly line up. – Indemnification