Comments (3)
Definitely interesting to me. I also remember seeing mentioning of interest in this.
A PR would be great!
from cats-tagless.
I'm not sure I fully understand ReifiedInvocation
but Invocation
can be seen as a specialization of Program
:) see here: https://github.com/typelevel/cats-tagless/blob/master/core/src/main/scala/cats/tagless/optimize/Program.scala
from cats-tagless.
@LukaJCB Program
is fine as a replacement for Invocation
if there is a constraint that exists for all F[_]
, e.g. some Unconstrained[F[_]]
Another example for ReifiedInvocations
is this:
def router[K, F[_]: Concurrent, M[_[_]]: ReifiedInvocations: FunctorK](load: K => F[M[F]): F[K => M[F]] =
MVar[F].of(Map.empty[K, M[F]]).map { instancesVar =>
{ key: K =>
ReifiedInvocations[M].invocations.mapK {
new (Invocation[M, ?] ~> F) {
override def apply[A](invocation: Invocation[M, A]): F[A] =
for {
instances <- instancesVar.take
mf <- instances.get(key) match {
case Some(mf) => instancesVar.put(instances) >> mf.pure[F]
case None =>
load(key).flatMap { mf =>
instancesVar.put(instances.updated(key, mf)).as(mf)
}
}
a <- invocation.invoke(mf)
} yield a
}
}
}
}
So it allows you to transform some M[_[_]]
instance, even if you don't have it yet.
In other words ReifiedInvocations#invocations
makes it possible to create an instance that does nothing other than captures method invocations, which you can run later against some other instance.
from cats-tagless.
Related Issues (20)
- Having multiple annotations on a trait without a companion throws at runtime HOT 6
- Provide method parameter names and values in Instrument HOT 6
- Trouble deriving instances for ApplicativeError/MonadError HOT 2
- [Scala 2] Support dependent method types
- Publish for scalajs 1.0 HOT 3
- Migrate to GitHub Actions
- Scala 3 feature parity HOT 38
- Migrate to sbt-spiewak, drop sbt-catalysts
- Add versions of FunctorK and ApplyK for bi- and tri-functors, with macro derivation HOT 2
- mapK with method name HOT 2
- Generalization of `FunctorK` HOT 6
- Does Aspect need to be a tagless algebra algebra? HOT 6
- Invalid link in docs for `InvariantK` HOT 7
- Support varargs
- Add ContravariantK
- Decide what to do about fullyRefined instances HOT 3
- Create Intellij plugin for macro annotaions HOT 2
- Migrate to mdoc HOT 13
- Example of build.sbt for 2.12/2.13 cross compile? HOT 2
- Derive Apply Typeclass
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cats-tagless.