Packages

final case class Functoid[+A](get: Provider) extends 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.Functoid#map2 methods

Note

javax.inject.Named annotation is also supported

See also

izumi.distage.model.reflection.macros.FunctoidMacro]

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

Linear Supertypes
Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Functoid
  2. Serializable
  3. Product
  4. Equals
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new Functoid(get: Provider)

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def addDependencies(keys: Iterable[DIKey]): Functoid[A]
  5. def addDependency(key: DIKey): Functoid[A]
  6. def addDependency[B](name: Identifier)(implicit arg0: Tag[B]): Functoid[A]
  7. def addDependency[B](implicit arg0: Tag[B]): Functoid[A]

    Add B as an unused dependency of this Provider

  8. def ap[B, C](that: Functoid[B])(implicit ev: <:<[A, (B) => C], tag: Tag[C]): Functoid[C]

    Apply a function produced by this Provider to the argument produced by that Provider

  9. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  10. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  11. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  13. def flatAp[B](that: Functoid[(A) => B])(implicit arg0: Tag[B]): Functoid[B]

    Applicative's ap method - can be used to chain transformations like flatMap.

    Applicative's ap method - can be used to chain transformations like flatMap. Apply a function produced by that Provider to the value produced by this Provider

  14. val get: Provider
  15. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  16. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  17. def map[B](f: (A) => B)(implicit arg0: Tag[B]): Functoid[B]
  18. def map2[B, C](that: Functoid[B])(f: (A, B) => C)(implicit arg0: Tag[C]): Functoid[C]
  19. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  20. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  21. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  22. def productElementNames: Iterator[String]
    Definition Classes
    Product
  23. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  24. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  25. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  26. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  27. def zip[B](that: Functoid[B]): Functoid[(A, B)]

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped