New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
We need a toIO
operation and type class
#73
Comments
So the problem with this is, taken together with trait <->[F[_], G[_]] {
def left: F ~> G
def right: G ~> F
} That's a very, very constraining type. With that said though, your argument that So maybe the isomorphism is a fair way to describe things: all base effect types (i.e. non-MTL) must be directly isomorphic to If we're going to have this, I would actually rather have a more general version: trait ToAsync[F[_]] {
def to[G[_]: Async, A](fa: F[A]): G[A]
} Effectively generalizing the Stepping away from the pros and cons for a minute, do you have any concrete use-cases that this would aid (either in the generic or the specific |
Examples of data types that are not Use caseI built a new data type in Monix called Iterant, making use of higher-kinded polymorphism for evaluation. I've been told that it resembles the efforts for "ListT done right", or what FS2 did years ago; I wouldn't know, because I've been living under a rock 🙂 So one of its operators is sealed trait Iterant[F[_], A] {
// ...
def mapEval[B](f: A => F[B])(implicit F: Sync[F]): Iterant[F, B]
} Here we need But to keep the operators consistent and because trait Observable[+A] {
//...
def mapEval[F[_], B](f: A => F[B])(implicit F: Effect[F]): Self[B]
} But requiring Therefore in this
All I would care about in this instance is to have an This is why I would be perfectly fine with requiring a data type that's able to convert to |
In contrast with the above use case, an example where I actually need an |
@alexandru Okay to close? |
Yes |
We have
LiftIO
as a lawless type class that's then inherited byAsync
.I think we also need a
ToIO
type class to be inherited byEffect
:Reasons:
Effect
, going throughtoIO
for evaluating anF[_]
might actually be easier to do than going throughrunAsync
, we can already expresstoIO
in terms ofrunAsync
so allEffect
instances can do ittoIO
and we already have precedent for such operations in Cats, e.g.Applicative.unit
But I'd also like a different
ToIO
type class because there are data types out there that can be converted toIO
, but that can't implementEffect
. Not sure if it can have any laws though.If there's agreement I can work on the PR.
So what do you think?
The text was updated successfully, but these errors were encountered: