final case class Functoid[+A](get: Provider) extends AbstractFunctoid[A, Functoid] with Product with Serializable
A function that receives its arguments from DI object graph, including named instances via izumi.distage.model.definition.Id annotation.
The following syntaxes are supported by extractor macro:
Inline lambda:
make[Unit].from { i: Int @Id("special") => () }
Method reference:
def constructor(@Id("special") i: Int): Unit = () make[Unit].from(constructor _) make[Unit].from(constructor(_))
Function value with an annotated signature:
val constructor: (Int @Id("special"), String @Id("special")) => Unit = (_, _) => () make[Unit].from(constructor)
Using intermediate vals will lose annotations when converting a method into a function value,
Prefer passing inline lambdas such as { x => y }
or method references such as (method _)
or (method(_))
.:
def constructorMethod(@Id("special") i: Int): Unit = () val constructor = constructorMethod _ make[Unit].from(constructor) // SURPRISE: Will summon regular Int, not a "special" Int from DI object graph make[Unit].from(constructorMethod _) // Will work correctly: summon "special" Int
Prefer annotating parameter types, not parameters: class X(i: Int @Id("special")) { ... }
final case class X(i: Int @Id("special")) make[X].from(X.apply _) // summons special Int
Functoid forms an applicative functor via its izumi.distage.model.providers.Functoid.pure & izumi.distage.model.providers.AbstractFunctoid.map2 methods
- Note
javax.inject.Named
annotation is also supported- See also
Functoid is based on the Magnet Pattern: http://spray.io/blog/2012-12-13-the-magnet-pattern/
Essentially Functoid is a function-like entity with additional properties, so it's funny name is reasonable enough: https://en.wiktionary.org/wiki/-oid#English
- Alphabetic
- By Inheritance
- Functoid
- Serializable
- Product
- Equals
- AbstractFunctoid
- 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
- def addDependencies(keys: Iterable[DIKey]): Functoid[A]
- Definition Classes
- AbstractFunctoid
- def addDependency(key: DIKey): Functoid[A]
- Definition Classes
- AbstractFunctoid
- def addDependency[B](name: Identifier)(implicit arg0: Tag[B]): Functoid[A]
- Definition Classes
- AbstractFunctoid
- def addDependency[B](implicit arg0: Tag[B]): Functoid[A]
Add
B
as an unused dependency of this FunctoidAdd
B
as an unused dependency of this Functoid- Definition Classes
- AbstractFunctoid
- def annotateAllParameters(name: Identifier): Functoid[A]
Add an
@Id(name)
annotation to all unannotated parametersAdd an
@Id(name)
annotation to all unannotated parameters- Definition Classes
- AbstractFunctoid
- def annotateParameter[P](name: Identifier)(implicit arg0: Tag[P]): Functoid[A]
Add an
@Id
annotation to an unannotated parameterP
, e.g.Add an
@Id
annotation to an unannotated parameterP
, e.g. for .annotateParameter[P]("my-id"), transform lambda(p: P) => x(p)
into(p: P @Id("my-id")) => x(p)
- Definition Classes
- AbstractFunctoid
- def annotateParameterWhen(name: Identifier)(predicate: (BasicKey) => Boolean): Functoid[A]
Add an
@Id(name)
annotation to all parameters matchingpredicate
Add an
@Id(name)
annotation to all parameters matchingpredicate
- Definition Classes
- AbstractFunctoid
- def ap[B, C](that: Functoid[B])(implicit ev: <:<[A, (B) => C], tag: Tag[C]): Functoid[C]
Apply a function produced by
this
Functoid to the argument produced bythat
Functoid.Apply a function produced by
this
Functoid to the argument produced bythat
Functoid.Same as
this.map2(that)((f, a) => f(a))
- Definition Classes
- AbstractFunctoid
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def create[B](provider: Provider): Functoid[B]
- Attributes
- protected
- Definition Classes
- Functoid → AbstractFunctoid
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def flatAp[B](that: Functoid[(A) => B])(implicit arg0: Tag[B]): Functoid[B]
Applicative's
ap
method - can be used to chain transformations likeflatMap
.Applicative's
ap
method - can be used to chain transformations likeflatMap
.Apply a function produced by
that
Functoid to the value produced bythis
Functoid.Same as
this.map2(that)((a, f) => f(a))
- Definition Classes
- AbstractFunctoid
- val get: Provider
- Definition Classes
- Functoid → AbstractFunctoid
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def map[B](f: (A) => B)(implicit arg0: Tag[B]): Functoid[B]
- Definition Classes
- AbstractFunctoid
- def map2[B, C](that: Functoid[B])(f: (A, B) => C)(implicit arg0: Tag[C]): Functoid[C]
- Definition Classes
- AbstractFunctoid
- 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()
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- 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()
- def zip[B](that: Functoid[B]): Functoid[(A, B)]
- Definition Classes
- AbstractFunctoid