You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During playing over #1089 , I found out that our Mapper implicits fail to resolve for cases of A => F[Response | Output[B]] when F is some complex type like:
StateT[F, State, ?]
ReaderT[F, A, B]
WriterT[F, Log, ?]
I suspect it somehow relates to complex mapping we have for F ~> G in those cases and compiler fails to go that deep in the rabbit hole, as for simple functions A => Response it works fine.
Suggestion to fix it is to make Mapper instances available as a trait and extend it in EndpointModule, so it would simplify compiler work for a single type F:
Something like:
traitMapperInstances[F[_]] {
implicitdefmapperFromKindToEffectOutputFunction[A, B](f: A=>F[Output[B]])(implicitF:Monad[F]):Mapper.Aux[G, A, B] =
instance(_.mapOutputAsync(a =>f(a)))
//rest of the conversions
}
Also, it might be valuable to introduce Endpoint.mapK for transformation of the effect of Endpoint:
defmapK[G[_]](f: F~>G):Endpoint[G, A]
The text was updated successfully, but these errors were encountered:
I'm not sure about Mapper though. I think the core of the problem using the magnet pattern in the first place (esp. when type parameters are involved). It makes it difficult to understand what you can pass to a method expecting a Mapper and almost impossible for type inference to work correctly. Even using regular functions is difficult - you have to specify the parameter types explicitly even though the endpoint already has all the necessary type information.
Actually, I start thinking that probably we should make Mapper rather an optional thing that is available only via import, and encourage users to use corresponding map* functions instead. At least, it's quite clear from the signature of endpoint methods.
During playing over #1089 , I found out that our Mapper implicits fail to resolve for cases of
A => F[Response | Output[B]]
whenF
is some complex type like:StateT[F, State, ?]
ReaderT[F, A, B]
WriterT[F, Log, ?]
I suspect it somehow relates to complex mapping we have for
F ~> G
in those cases and compiler fails to go that deep in the rabbit hole, as for simple functionsA => Response
it works fine.Suggestion to fix it is to make Mapper instances available as a trait and extend it in
EndpointModule
, so it would simplify compiler work for a single typeF
:Something like:
Also, it might be valuable to introduce
Endpoint.mapK
for transformation of the effect of Endpoint:The text was updated successfully, but these errors were encountered: