Created
April 5, 2017 13:20
-
-
Save aaronlevin/019096a4bde72a5eff5b4e21cf7e9fab to your computer and use it in GitHub Desktop.
Simulacrum-Generated FlatMap object in typelevel cats
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
// https://github.com/mpilquist/simulacrum | |
trait FlatMap[F[_]] extends Apply[F] with _root_.scala.Serializable { | |
def flatMap[A, B](fa: F[A])(f: _root_.scala.Function1[A, F[B]]): F[B]; | |
def >>=[A, B](fa: F[A])(f: _root_.scala.Function1[A, F[B]]): F[B] = flatMap(fa)(f); | |
def flatten[A](ffa: F[F[A]]): F[A] = flatMap(ffa)(((fa) => fa)); | |
def followedBy[A, B](fa: F[A])(fb: F[B]): F[B] = flatMap(fa)(((x$1) => fb)); | |
@inline final def >>[A, B](fa: F[A])(fb: F[B]): F[B] = followedBy(fa)(fb); | |
def followedByEval[A, B](fa: F[A])(fb: Eval[F[B]]): F[B] = flatMap(fa)(((x$2) => fb.value)); | |
override def ap[A, B](ff: F[_root_.scala.Function1[A, B]])(fa: F[A]): F[B] = flatMap(ff)(((f) => map(fa)(f))); | |
override def product[A, B](fa: F[A], fb: F[B]): F[scala.Tuple2[A, B]] = flatMap(fa)(((a) => map(fb)(((b) => scala.Tuple2(a, b))))); | |
def mproduct[A, B](fa: F[A])(f: _root_.scala.Function1[A, F[B]]): F[scala.Tuple2[A, B]] = flatMap(fa)(((a) => map(f(a))(((x$3) => scala.Tuple2(a, x$3))))); | |
def ifM[B](fa: F[Boolean])(ifTrue: => F[B], ifFalse: => F[B]): F[B] = flatMap(fa)(((x$4) => if (x$4) | |
ifTrue | |
else | |
ifFalse)); | |
def tailRecM[A, B](a: A)(f: _root_.scala.Function1[A, F[Either[A, B]]]): F[B] | |
}; | |
/** generated FlatMap object, where object Ops holds the conversions to support For-Comprehension syntax **/ | |
object FlatMap { | |
@scala.inline def apply[F[_]](implicit instance: FlatMap[F]): FlatMap[F] = instance; | |
trait Ops[F[_], C] { | |
val typeClassInstance: FlatMap[F]; | |
def self: F[C]; | |
def flatMap[B](f: _root_.scala.Function1[C, F[B]]) = typeClassInstance.flatMap[C, B](self)(f); | |
def >>=[B](f: _root_.scala.Function1[C, F[B]]) = typeClassInstance.>>=[C, B](self)(f); | |
def flatten[A](implicit ev$macro$25: _root_.scala.Predef.<:<[C, F[A]]) = typeClassInstance.flatten(self.asInstanceOf[F[F[A]]]); | |
def followedBy[B](fb: F[B]) = typeClassInstance.followedBy[C, B](self)(fb); | |
def >>[B](fb: F[B]) = typeClassInstance.>>[C, B](self)(fb); | |
def followedByEval[B](fb: Eval[F[B]]) = typeClassInstance.followedByEval[C, B](self)(fb); | |
def mproduct[B](f: _root_.scala.Function1[C, F[B]]) = typeClassInstance.mproduct[C, B](self)(f) | |
}; | |
trait ToFlatMapOps { | |
@java.lang.SuppressWarnings(scala.Array("org.wartremover.warts.ExplicitImplicitTypes", "org.wartremover.warts.ImplicitConversion")) implicit def toFlatMapOps[F[_], C](target: F[C])(implicit tc: FlatMap[F]): Ops[F, C] = { | |
final class $anon extends Ops[F, C] { | |
val self = target; | |
val typeClassInstance = tc | |
}; | |
new $anon() | |
} | |
}; | |
object nonInheritedOps extends ToFlatMapOps; | |
trait AllOps[F[_], C] extends Ops[F, C] with Apply.AllOps[F, C] { | |
val typeClassInstance: FlatMap[F] | |
}; | |
object ops { | |
@java.lang.SuppressWarnings(scala.Array("org.wartremover.warts.ExplicitImplicitTypes", "org.wartremover.warts.ImplicitConversion")) implicit def toAllFlatMapOps[F[_], C](target: F[C])(implicit tc: FlatMap[F]): AllOps[F, C] = { | |
final class $anon extends AllOps[F, C] { | |
val self = target; | |
val typeClassInstance = tc | |
}; | |
new $anon() | |
} | |
} | |
}; | |
() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment