Anyone know a common name for a function that lifts only one side (only the codomain) of another function into a functor/monad/effect?

Something like

Monad m => (a -> b) -> a -> m b

Feels like this transformation comes up often when using asynchronous frameworks. It "lifts" a synchronous function into an `async` function.

Perhaps it doesn't need a name, since it's maybe just the composition

liftM f . return

#functionalprogramming #haskell #typescript

@benjaminedwardwebb maybe some kind of Profunctor (see profunctors package)?

:t rmap pure (undefined :: Int -> Char)
Applicative f => Int -> f Char

Buy yeah, generally just applying pure to the output...

@robinp @benjaminedwardwebb Isn't the profunctor here just (->) with rmap = (.)?

@barubary @benjaminedwardwebb yes, it seems the case. I brought up Profunctor as it is something that gives a name to something slightly related.. okay, in retrospect, that is true for many things, so no hard argument here.

I advise a game: look at the recursion-schemes package, take some inspiration to naming things from there, and come up with a name for rmap pure.

@barubary @benjaminedwardwebb
guys, you won't believe this, but I accidentally got nearer to solve this.

I believe things of shape 'a -> f b' are more generally called a Star (if we treat a->b as a Profunctor, and f is a Functor). See https://hackage.haskell.org/package/profunctors-5.6.2/docs/Data-Profunctor-Types.html#t:Star

It literally says "lifting a Functor into a Profunctor". Now, obviously since f only has Functor constraint in Star, we don't have pure (so we need to construct by 'Star . rmap pure . f').

(TBC)

Data.Profunctor.Types

@barubary @benjaminedwardwebb

... now the question is, does a Star which has 'Applicative f' as a constraint instead of just 'Functor f' exists and named? Then it could have a class method 'pureStar' defined as 'Star . rmap pure', to achieve the original goal.

Unless #Haskell people know a name for that class, we might call it AppStar or PureStar :)

@barubary @benjaminedwardwebb aside, I got there by looking at the foldl package, whose Fold class has a Cosieve instance... clicikng Cosieve says "A Profunctor p is a Cosieve on f if it is a subprofunctor of Costar f." which is something to wrap my head around at a later time...

@robinp @barubary that's cool.

I wasn't familiar with profunctors, but I like that it puts a name to the shape of a one argument function viewed as a bifunctor with associated variance.