-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Put liftT on the companion object of XorT #1215
Changes from 4 commits
20b8a58
bbf98aa
ff457d9
480b8f3
1e277cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -219,6 +219,21 @@ trait XorTFunctions { | |
|
||
final def pure[F[_], A, B](b: B)(implicit F: Applicative[F]): XorT[F, A, B] = right(F.pure(b)) | ||
|
||
/** | ||
* Alias for [[XorT.right]] | ||
* {{{ | ||
* scala> import cats.data.XorT | ||
* scala> import cats.instances.option._ | ||
* scala> val o: Option[Int] = Some(3) | ||
* scala> val n: Option[Int] = None | ||
* scala> XorT.liftT(o) | ||
* res0: cats.data.XorT[Option,Nothing,Int] = XorT(Some(Right(3))) | ||
* scala> XorT.liftT(n) | ||
* res1: cats.data.XorT[Option,Nothing,Int] = XorT(None) | ||
* }}} | ||
*/ | ||
final def liftT[F[_], A, B](fb: F[B])(implicit F: Functor[F]): XorT[F, A, B] = right(fb) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we even need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without the implicit evidence for a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed. I made the mistake of believing that was just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All good, I'm just happy I could answer :) |
||
|
||
/** Transforms an `Xor` into an `XorT`, lifted into the specified `Applicative`. | ||
* | ||
* Note: The return type is a FromXorPartiallyApplied[F], which has an apply method | ||
|
@@ -280,7 +295,7 @@ private[data] abstract class XorTInstances extends XorTInstances1 { | |
type TC[M[_]] = Functor[M] | ||
|
||
def liftT[M[_]: Functor, A](ma: M[A]): XorT[M, E, A] = | ||
XorT(Functor[M].map(ma)(Xor.right)) | ||
XorT.liftT(ma) | ||
} | ||
|
||
implicit def catsMonoidForXorT[F[_], L, A](implicit F: Monoid[F[L Xor A]]): Monoid[XorT[F, L, 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.
Could you please use
import cats.implicits._
here? See #1026 for justification.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.
Totally, thanks for the link.