-
Notifications
You must be signed in to change notification settings - Fork 50
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
Freestyle Effects for @tagless #507
Conversation
trait Implicits { | ||
implicit def freeStyleEitherMHandler[M[_]]( | ||
implicit ME: MonadError[M, E]): EitherM.Handler[M] = new EitherM.Handler[M] { | ||
def either[A](fa: Either[E, A]): M[A] = fa.fold(ME.raiseError[A], ME.pure[A]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be ME.fromEither(fa)
|
||
implicit def freeStyleErrorMHandler[M[_]]( | ||
implicit ME: MonadError[M, Throwable]): ErrorM.Handler[M] = new ErrorM.Handler[M] { | ||
def either[A](fa: Either[Throwable, A]): M[A] = fa.fold(ME.raiseError[A], ME.pure[A]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also be ME.fromEither(fa)
.
|
||
final class FutureOps[A](f: Future[A]) { | ||
|
||
def to[F[_]](implicit AC: AsyncContext[F], E: ExecutionContext): F[A] = future2AsyncM[F, A](f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I think I would call this unsafeTo
, but the AsyncM
type class has no real "suspension" guarantees.
We could implement it more safely for Eval[Future[A]]
or a method which takes => Future[A]
.
We just have to remember that when we want to end up in something like monix Task
or cats.effect.IO
, this to
method is probably not the best route.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, I've just deprecated it in 9acae08
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Created #509
68e02b6
to
9acae08
Compare
This PR brings support for freestyle-effects for @tagless final encoding.
From now on,
asyncCatsEffect
andasyncGuava
have been moved tofreestyle.async
(both async integrations are not really tied tofree
.Releases a new minor version due to the breaking changes in this PR: 0.6.0.