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
TheseT monad transformer (plus IO instances and tests) #1162
Conversation
Not sure what this failure is - it doesn't look obvious that it's actually anything to do with the PR (appears to be in MiMa and something to do with the JS backend) |
@@ -256,6 +256,9 @@ object ScalazArbitrary { | |||
implicit def eitherTArb[F[+_], A, B](implicit A: Arbitrary[F[A \/ B]]): Arbitrary[EitherT[F, A, B]] = | |||
Functor[Arbitrary].map(A)(EitherT[F, A, B](_)) | |||
|
|||
implicit def theseTArb[F[+_], A, B](implicit A: Arbitrary[F[A \&/ B]]): Arbitrary[TheseT[F, A, B]] = |
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.
implicit def theseTArb[F[_], A, B]
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.
I have made this change
Conflicts: core/src/main/scala/scalaz/TheseT.scala
👍🏼 |
def &&&[AA >: A, C](t: TheseT[F, AA, C])(implicit M: Semigroup[AA], F: Apply[F]): TheseT[F, AA, (B, C)] | ||
= TheseT(F.apply2(run, t.run)(_ &&& _)) | ||
|
||
def ===[AA >: A, BB >: B](x: TheseT[F, AA, BB])(implicit EA: Equal[AA], EB: Equal[BB], F: Apply[F]): F[Boolean] |
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.
I think we should define Equal[TheseT[F, A, B]
instance and then remove this method. WDYT?
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.
I agree, otherwise 👍
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.
EitherT
defines both ===
as an instance method on EitherT
(along the lines of the above) and also a Equal
instance (in EitherTInstances
) [1]. This is presumably a mistake [2] and I took the view that the former was more useful because the most common value for F
is presumably IO
(or a stack with IO
in it) and thus there will be no implicit Equal[EitherT[F, A, B]]
I do agree that the instance method ===
with a return type other than Boolean
is a bit iffy; I was just trying to keep TheseT
as close to EitherT
as possible
[1] -
implicit def eitherTEqual[F[_], A, B](implicit F0: Equal[F[A \/ B]]): Equal[EitherT[F, A, B]]
= F0.contramap((_: EitherT[F, A, B]).run)
[2] - just because et1 === et2
is never using the typeclass but the instance method
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.
I did as you ask because I just can't take the silent treatment anymore
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.
sorry for the delay. 75935e138206a8fbf is LGTM
type TheseTListInt[A] = TheseT[List, Int, A] | ||
type TheseTOptionInt[A] = TheseT[Option, Int, A] | ||
|
||
implicit def TheseTListIntEqual[A: Equal]: Equal[TheseTListInt[A]] = new Equal[TheseTListInt[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.
I think this is unnecessary because now there is implicit def theseTEqual
in ThereT.scala
.
* Added TheseT and MonadIO/LiftIO/MonadCatchIO instances * Added tests for laws for TheseT * Added EitherT.toThese * requested removing variance annotation * requested removing the TheseTFunctions trait * Added TheseT and MonadIO/LiftIO/MonadCatchIO instances * Added tests for laws for TheseT * Added EitherT.toThese * requested removing variance annotation * requested removing the TheseTFunctions trait * use kind projector for M[_[_], _] * removed === in favour of Equal[TheseT[?[_], ?, ?] * Removed unnecessary implicit
TheseT is a monad transformer for
\&/
(pronounced these).A \&/ B
represents having either anA
, or aB
, or bothTheseT[M, A, B]
is essentially an ops class for aM[A \&/ B]
. TheseT is both a monad and it supports many of the operations one finds on\&/