trait Syntax2 extends ImplicitPuns
All implicit syntax in BIO is available automatically without wildcard imports with the help of so-called "implicit punning", as in the following example:
import izumi.functional.bio.Monad2 def loop[F[+_, +_]: Monad2]: F[Nothing, Nothing] = { val unitEffect: F[Nothing, Unit] = Monad2[F].unit unitEffect.flatMap(loop) }
Note that a .flatMap
method is available on the unitEffect
value of an abstract type parameter F
,
even though we did not import any syntax implicits using a wildcard import.
The flatMap
method was added by the implicit punning on the Monad2
name.
In short, implicit punning just means that instead of creating a companion object for a type with the same name as the type,
we create "companion" implicit conversions with the same name. So that whenever you import the type,
you are also always importing the syntax-providing implicit conversions.
This happens to be a great fit for Tagless Final Style, since nearly all TF code will import the names of the used typeclasses.
Implicit Punning for typeclass syntax relieves the programmer from having to manually import syntax implicits in every file in their codebase.
- Note
The order of conversions is such to allow otherwise conflicting type classes to not conflict, e.g. code using constraints such as
def x[F[+_, +_]: Functor2: Applicative2: Monad2]
will compile and run normally when using syntax, despite ambiguity of implicits caused by all 3 implicits inheriting from Functor2. This is because, due to the priority order being from most-specific to least-specific, theMonad2
syntax will be used in such a case, where theMonad2[F]
implicit is actually unambiguous.
- Alphabetic
- By Inheritance
- Syntax2
- ImplicitPuns
- ImplicitPuns1
- ImplicitPuns2
- ImplicitPuns3
- ImplicitPuns4
- ImplicitPuns5
- ImplicitPuns6
- ImplicitPuns7
- ImplicitPuns8
- ImplicitPuns9
- ImplicitPuns10
- ImplicitPuns11
- ImplicitPuns12
- ImplicitPuns13
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def Applicative2[F[+_, +_]](implicit arg0: Applicative2[F]): Applicative2[F]
- Definition Classes
- ImplicitPuns11
- Annotations
- @inline()
- implicit final def Applicative2[F[+_, +_], E, A](self: F[E, A])(implicit arg0: Applicative2[F]): ApplicativeOps[F, E, A]
- Definition Classes
- ImplicitPuns11
- Annotations
- @inline()
- final def ApplicativeError2[F[+_, +_]](implicit arg0: ApplicativeError2[F]): ApplicativeError2[F]
- Definition Classes
- ImplicitPuns8
- Annotations
- @inline()
- implicit final def ApplicativeError2[F[+_, +_], E, A](self: F[E, A])(implicit arg0: ApplicativeError2[F]): ApplicativeErrorOps[F, E, A]
- Definition Classes
- ImplicitPuns8
- Annotations
- @inline()
- final def Async2[F[+_, +_]](implicit arg0: Async2[F]): Async2[F]
- Definition Classes
- ImplicitPuns1
- Annotations
- @inline()
- implicit final def Async2[F[+_, +_], E, A](self: F[E, A])(implicit arg0: Async2[F]): AsyncOps[F, E, A]
- Definition Classes
- ImplicitPuns1
- Annotations
- @inline()
- final def Bifunctor2[F[+_, +_]](implicit arg0: Bifunctor2[F]): Bifunctor2[F]
- Definition Classes
- ImplicitPuns12
- Annotations
- @inline()
- implicit final def Bifunctor2[F[+_, +_], E, A](self: F[E, A])(implicit arg0: Functor2[F]): FunctorOps[F, E, A]
- Definition Classes
- ImplicitPuns12
- Annotations
- @inline()
- implicit final def Bifunctor2[F[+_, +_], E, A](self: F[E, A])(implicit arg0: Bifunctor2[F]): BifunctorOps[F, E, A]
- Definition Classes
- ImplicitPuns12
- Annotations
- @inline()
- final def Bracket2[F[+_, +_]](implicit arg0: Bracket2[F]): Bracket2[F]
- Definition Classes
- ImplicitPuns6
- Annotations
- @inline()
- implicit final def Bracket2[F[+_, +_], E, A](self: F[E, A])(implicit arg0: Bracket2[F]): BracketOps[F, E, A]
- Definition Classes
- ImplicitPuns6
- Annotations
- @inline()
- final def Concurrent2[F[+_, +_]](implicit arg0: Concurrent2[F]): Concurrent2[F]
- Definition Classes
- ImplicitPuns2
- Annotations
- @inline()
- implicit final def Concurrent2[F[+_, +_], E, A](self: F[E, A])(implicit arg0: Panic2[F]): PanicOps[F, E, A]
- Definition Classes
- ImplicitPuns2
- Annotations
- @inline()
- implicit final def Concurrent2[F[+_, +_], E, A](self: F[E, A])(implicit arg0: Concurrent2[F]): ConcurrentOps[F, E, A]
- Definition Classes
- ImplicitPuns2
- Annotations
- @inline()
- final def Error2[F[+_, +_]](implicit arg0: Error2[F]): Error2[F]
- Definition Classes
- ImplicitPuns7
- Annotations
- @inline()
- implicit final def Error2[F[+_, +_], E, A](self: F[E, A])(implicit arg0: Error2[F]): ErrorOps[F, E, A]
- Definition Classes
- ImplicitPuns7
- Annotations
- @inline()
- def F[F[+_, +_]](implicit F: Functor2[F]): F.F.type
A convenient dependent summoner for BIO hierarchy.
A convenient dependent summoner for BIO hierarchy. Auto-narrows to the most powerful available class:
import izumi.functional.bio.{F, Temporal2} def y[F[+_, +_]: Temporal2] = { F.timeout(5.seconds)(F.forever(F.unit)) }
- final def Fork2[F[+_, +_]](implicit arg0: Fork2[F]): Fork2[F]
- Definition Classes
- ImplicitPuns
- Annotations
- @inline()
- implicit final def Fork2[F[+_, +_], E, A](self: F[E, A])(implicit arg0: Fork2[F]): ForkOps[F, E, A]
- Definition Classes
- ImplicitPuns
- Annotations
- @inline()
- final def Functor2[F[+_, +_]](implicit arg0: Functor2[F]): Functor2[F]
- Definition Classes
- ImplicitPuns13
- Annotations
- @inline()
- implicit final def Functor2[F[+_, +_], E, A](self: F[E, A])(implicit arg0: Functor2[F]): FunctorOps[F, E, A]
- Definition Classes
- ImplicitPuns13
- Annotations
- @inline()
- final def Guarantee2[F[+_, +_]](implicit arg0: Guarantee2[F]): Guarantee2[F]
- Definition Classes
- ImplicitPuns9
- Annotations
- @inline()
- implicit final def Guarantee2[F[+_, +_], E, A](self: F[E, A])(implicit arg0: Guarantee2[F]): GuaranteeOps[F, E, A]
- Definition Classes
- ImplicitPuns9
- Annotations
- @inline()
- final def IO2[F[+_, +_]](implicit arg0: IO2[F]): IO2[F]
- Definition Classes
- ImplicitPuns4
- Annotations
- @inline()
- final def IO2[F[+_, +_], A](effect: => A)(implicit F: IO2[F]): F[Throwable, A]
Shorthand for IO2#syncThrowable
Shorthand for IO2#syncThrowable
IO2(println("Hello world!"))
- Definition Classes
- ImplicitPuns4
- Annotations
- @inline()
- implicit final def IO2[F[+_, +_], E, A](self: F[E, A])(implicit arg0: IO2[F]): IOOps[F, E, A]
- Definition Classes
- ImplicitPuns4
- Annotations
- @inline()
- final def Monad2[F[+_, +_]](implicit arg0: Monad2[F]): Monad2[F]
- Definition Classes
- ImplicitPuns10
- Annotations
- @inline()
- implicit final def Monad2[F[+_, +_], E, A](self: F[E, A])(implicit arg0: Monad2[F]): MonadOps[F, E, A]
- Definition Classes
- ImplicitPuns10
- Annotations
- @inline()
- final def Panic2[F[+_, +_]](implicit arg0: Panic2[F]): Panic2[F]
- Definition Classes
- ImplicitPuns5
- Annotations
- @inline()
- implicit final def Panic2[F[+_, +_], E, A](self: F[E, A])(implicit arg0: Panic2[F]): PanicOps[F, E, A]
- Definition Classes
- ImplicitPuns5
- Annotations
- @inline()
- final def Parallel2[F[+_, +_]](implicit arg0: Parallel2[F]): Parallel2[F]
- Definition Classes
- ImplicitPuns3
- Annotations
- @inline()
- implicit final def Parallel2[F[+_, +_], E, A](self: F[E, A])(implicit arg0: Monad2[F]): MonadOps[F, E, A]
- Definition Classes
- ImplicitPuns3
- Annotations
- @inline()
- implicit final def Parallel2[F[+_, +_], E, A](self: F[E, A])(implicit arg0: Parallel2[F]): ParallelOps[F, E, A]
- Definition Classes
- ImplicitPuns3
- Annotations
- @inline()
- final def Temporal2[F[+_, +_]](implicit arg0: Temporal2[F]): Temporal2[F]
- Definition Classes
- ImplicitPuns
- Annotations
- @inline()
- implicit final def Temporal2[F[+_, +_], E, A](self: F[E, A])(implicit arg0: Error2[F]): ErrorOps[F, E, A]
- Definition Classes
- ImplicitPuns
- Annotations
- @inline()
- implicit final def Temporal2[F[+_, +_], E, A](self: F[E, A])(implicit arg0: Temporal2[F]): TemporalOps[F, E, A]
- Definition Classes
- ImplicitPuns
- Annotations
- @inline()
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()