Clinton
Clinton

Reputation: 23135

Is there a class with the function `(m a -> n b) -> t m a -> t n b`

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?

Upvotes: 6

Views: 112

Answers (1)

Clinton
Clinton

Reputation: 23135

The function hoist from the class MFunctor, package mmorph is the answer to my own question.

Upvotes: 7

Related Questions