I have two different types of users; let's call them BasicUser
and EnrichedUser
.
I get a value of the Foo
user type inside a container C
that has a cats.Functor
instance:
val basicUserF: C[BasicUser] = getBasicUser(…)
Now I'd like to map over this value (using the functor instance) to turn the contained BasicUser
into an EnrichedUser
user, staying in the container:
import cats.syntax.all._
val enrichedUserF: C[EnrichedUser] = basicUserF.map(user => enrichUser(user))
However, enrichUser
doesn't return EnrichedUser
, but rather OptionT[Future, EnrichedUser]
, so I end up with the following type:
val enrichedUserThing: C[OptionT[Future, EnrichedUser]] = …
How can I get from this type to OptionT[Future, C[EnrichedUser]]
(which I'll ultimately turn into a JSON-serialized Akka HTTP response)?