Created
October 1, 2017 10:52
-
-
Save frroliveira/5d4fbdfa1fd465e8728615f6107c2716 to your computer and use it in GitHub Desktop.
Proposal of Monad Transformer for Ior
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cats.data | |
import cats.functor.Bifunctor | |
import cats.kernel.{Monoid, Semigroup} | |
import cats.{Applicative, Apply, Bitraverse, Eq, Eval, Foldable, Functor, Monad, MonadError, SemigroupK, Show, Traverse} | |
final case class IorT[F[_], A, B](value: F[Ior[A, B]]) { | |
def fold[C](fa: A => C, fb: B => C, fc: (A, B) => C): C = ??? | |
def isLeft(implicit F: Functor[F]): F[Boolean] = ??? | |
def isRight(implicit F: Functor[F]): F[Boolean] = ??? | |
def isBoth(implicit F: Functor[F]): F[Boolean] = ??? | |
def swap(implicit F: Functor[F]): IorT[F, B, A] = ??? | |
def getOrElse[BB >: B](default: => BB)(implicit F: Functor[F]): F[BB] = ??? | |
def getOrElseF[BB >: B](default: => F[BB])(implicit F: Monad[F]): F[BB] = ??? | |
def orElse[AA, BB >: B](default: => IorT[F, AA, BB])(implicit F: Monad[F]): IorT[F, AA, BB] = ??? | |
def recover(pf: PartialFunction[A, B])(implicit F: Functor[F]): IorT[F, A, B] = ??? | |
def recoverWith(pf: PartialFunction[A, IorT[F, A, B]])(implicit F: Monad[F]): IorT[F, A, B] = ??? | |
def valueOr[BB >: B](f: A => BB)(implicit F: Functor[F]): F[BB] = ??? | |
def forall(f: B => Boolean)(implicit F: Functor[F]): F[Boolean] = ??? | |
def exists(f: B => Boolean)(implicit F: Functor[F]): F[Boolean] = ??? | |
// no ensure or ensureOr methods | |
def toOption(implicit F: Functor[F]): OptionT[F, B] = ??? | |
def toEither(implicit F: Functor[F]): EitherT[F, A, B] = ??? | |
def bimap[C, D](fa: A => C, fb: B => D)(implicit F: Functor[F]): IorT[F, C, D] = ??? | |
def bitraverse[G[_], C, D](f: A => G[C], g: B => G[D])(implicit traverseF: Traverse[F], applicativeG: Applicative[G]): G[IorT[F, C, D]] = ??? | |
def applyAlt[D](ff: IorT[F, A, B => D])(implicit F: Apply[F]): IorT[F, A, D] = ??? | |
def flatMap[AA >: A, D](f: B => IorT[F, AA, D])(implicit F: Monad[F]): IorT[F, AA, D] = ??? | |
def flatMapF[AA >: A, D](f: B => F[Ior[AA, D]])(implicit F: Monad[F]): IorT[F, AA, D] = ??? | |
def transform[C, D](f: Ior[A, B] => Ior[C, D])(implicit F: Functor[F]): IorT[F, C, D] = ??? | |
def subflatMap[AA >: A, D](f: B => Ior[AA, D])(implicit F: Monad[F]): IorT[F, AA, D] = ??? | |
def map[D](f: B => D)(implicit F: Functor[F]): IorT[F, A, D] = ??? | |
def semiflatMap[D](f: B => F[D])(implicit F: Monad[F]): IorT[F, A, D] = ??? | |
def leftMap[C](f: A => C)(implicit F: Functor[F]): IorT[F, C, B] = ??? | |
// no compare or partialCompare methods | |
def ===(that: IorT[F, A, B])(implicit eq: Eq[F[Ior[A, B]]]): Boolean = ??? | |
def traverse[G[_], D](f: B => G[D])(implicit traverseF: Traverse[F], applicativeG: Applicative[G]): G[IorT[F, A, D]] = ??? | |
def foldLeft[C](c: C)(f: (C, B) => C)(implicit F: Foldable[F]): C = ??? | |
def foldRight[C](lc: Eval[C])(f: (B, Eval[C]) => Eval[C])(implicit F: Foldable[F]): Eval[C] = ??? | |
def merge[AA >: A](implicit ev: B <:< AA, F: Functor[F]): F[AA] = ??? | |
def combine(that: IorT[F, A, B])(implicit F: Apply[F], A: Semigroup[A], B: Semigroup[B]): IorT[F, A, B] = ??? | |
def show(implicit show: Show[F[Ior[A, B]]]): String = show.show(value) | |
def toNested: Nested[F, Ior[A, ?], B] = ??? | |
} | |
object IorT extends IorTInstances { | |
private[data] final class LeftPartiallyApplied[B](val dummy: Boolean = true) extends AnyVal { | |
def apply[F[_], A](fa: F[A])(implicit F: Functor[F]): IorT[F, A, B] = ??? | |
} | |
final def left[B]: LeftPartiallyApplied[B] = new LeftPartiallyApplied[B] | |
private[data] final class LeftTPartiallyApplied[F[_], B](val dummy: Boolean = true) extends AnyVal { | |
def apply[A](a: A)(implicit F: Applicative[F]): IorT[F, A, B] = ??? | |
} | |
final def leftT[F[_], B]: LeftTPartiallyApplied[F, B] = new LeftTPartiallyApplied[F, B] | |
private[data] final class RightPartiallyApplied[A](val dummy: Boolean = true) extends AnyVal { | |
def apply[F[_], B](fb: F[B])(implicit F: Functor[F]): IorT[F, A, B] = ??? | |
} | |
final def right[A]: RightPartiallyApplied[A] = new RightPartiallyApplied[A] | |
private[data] final class PurePartiallyApplied[F[_], A](val dummy: Boolean = true) extends AnyVal { | |
def apply[B](b: B)(implicit F: Applicative[F]): IorT[F, A, B] = ??? | |
} | |
final def pure[F[_], A]: PurePartiallyApplied[F, A] = new PurePartiallyApplied[F, A] | |
final def rightT[F[_], A]: PurePartiallyApplied[F, A] = pure | |
final def liftT[F[_], A, B](fb: F[B])(implicit F: Applicative[F]): IorT[F, A, B] = right(fb) | |
private[data] final class BothPartiallyApplied[F[_]](val dummy: Boolean = true) extends AnyVal { | |
def apply[A, B](a: A, B: B)(implicit F: Applicative[F]): IorT[F, A, B] = ??? | |
} | |
final def both[F[_]]: BothPartiallyApplied[F] = new BothPartiallyApplied[F] | |
private[data] final class FromIorPartiallyApplied[F[_]](val dummy: Boolean = true) extends AnyVal { | |
def apply[A, B](ior: Ior[A, B])(implicit F: Applicative[F]): IorT[F, A, B] = ??? | |
} | |
final def fromIor[F[_]]: FromIorPartiallyApplied[F] = new FromIorPartiallyApplied[F] | |
private[data] final class FromEitherPartiallyApplied[F[_]](val dummy: Boolean = true) extends AnyVal { | |
def apply[E, A](either: Either[E, A])(implicit F: Applicative[F]): IorT[F, E, A] = ??? | |
} | |
final def fromEither[F[_]]: FromEitherPartiallyApplied[F] = new FromEitherPartiallyApplied[F] | |
final def fromEitherF[F[_], E, A](feither: F[Either[E, A]])(implicit F: Functor[F]): IorT[F, E, A] = ??? | |
private[data] final class FromOptionPartiallyApplied[F[_]](val dummy: Boolean = true) extends AnyVal { | |
def apply[E, A](opt: Option[A], ifNone: => E)(implicit F: Applicative[F]): IorT[F, E, A] = ??? | |
} | |
final def fromOption[F[_]]: FromOptionPartiallyApplied[F] = new FromOptionPartiallyApplied[F] | |
final def fromOptionF[F[_], E, A](fopt: F[Option[A]], ifNone: => E)(implicit F: Functor[F]): IorT[F, E, A] = ??? | |
private[data] final class CondPartiallyApplied[F[_]](val dummy: Boolean = true) extends AnyVal { | |
def apply[E, A](test: Boolean, right: => A, left: => E)(implicit F: Applicative[F]): IorT[F, E, A] = ??? | |
} | |
final def cond[F[_]]: CondPartiallyApplied[F] = new CondPartiallyApplied[F] | |
} | |
private[data] abstract class IorTInstances extends IorTInstances1 { | |
implicit def catsDataShowForIorT[F[_], A, B](implicit sh: Show[F[Ior[A, B]]]): Show[IorT[F, A, B]] = ??? | |
implicit def catsDataBifunctorForIorT[F[_]](implicit F: Functor[F]): Bifunctor[IorT[F, ?, ?]] = ??? | |
implicit def catsDataTraverseForIorT[F[_], A](implicit F: Traverse[F]): Traverse[IorT[F, A, ?]] = ??? | |
implicit def catsDataMonoidForIorT[F[_], A, B](implicit F: Monoid[F[Ior[A, B]]]): Monoid[IorT[F, A, B]] = ??? | |
} | |
private[data] abstract class IorTInstances1 extends IorTInstances2 { | |
implicit def catsDataSemigroupForIorT[F[_], A, B](implicit F: Semigroup[F[Ior[A, B]]]): Semigroup[IorT[F, A, B]] = ??? | |
implicit def catsDataFoldableForIorT[F[_], A](implicit F: Foldable[F]): Foldable[IorT[F, A, ?]] = ??? | |
implicit def catsDataBitraverseForIorT[F[_]](implicit F: Traverse[F]): Bitraverse[IorT[F, ?, ?]] = ??? | |
implicit def catsDataMonadErrorFForIorT[F[_], E, A](implicit FE: MonadError[F, E]): MonadError[IorT[F, A, ?], E] = ??? | |
} | |
private[data] abstract class IorTInstances2 extends IorTInstances3 { | |
implicit def catsDataMonadErrorForIorT[F[_], A](implicit F: Monad[F]): MonadError[IorT[F, A, ?], A] = ??? | |
implicit def catsDataSemigroupKForIorT[F[_], A](implicit F: Monad[F]): SemigroupK[IorT[F, A, ?]] = ??? | |
implicit def catsDataEqForIorT[F[_], A, B](implicit F: Eq[F[Ior[A, B]]]): Eq[IorT[F, A, B]] = ??? | |
} | |
private[data] abstract class IorTInstances3 { | |
implicit def catsDataFunctorForIorT[F[_], A](implicit F: Functor[F]): Functor[IorT[F, A, ?]] = ??? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment