trait ImplicitApply[F] extends AnyRef
A dependent type class that apply F
with implicit values as parameters.
Imports
import com.thoughtworks.feature.ImplicitApply._
This will enable the implicitApply method for any functions
Author:
杨博 (Yang Bo) <[email protected]>
- F
The function type to be implicitly apply
- Source
- ImplicitApply.scala
Given a function
f
that requires anOrdering[Int]
val f = { x: Ordering[Int] => "OK" }
Then
f
can implicitly apply as long as its parameter is implicitly available,f.implicitApply should be("OK")
, Given a function
f
that requires an call-by-nameOrdering[Int]
def f0(x: => Ordering[Int]) = "OK" val f = f0 _
Then
f
can implicitly apply as long as its parameter is implicitly available,f.implicitApply should be("OK")
- Note
You can optionally add an implicit modifier on the function parameter.
val f = { implicit x: Ordering[Int] => "OK" } f.implicitApply should be("OK")
It is very useful when you create a curried function.
def g[A] = { (i: A, j: A) => implicit x: Ordering[A] => import x._ if (i > j) { s"$i is greater than $j" } else { s"$i is not greater than $j" } } g(1, 2).implicitApply should be("1 is not greater than 2")
Examples:
Linear Supertypes
Type Hierarchy
Ordering
- Alphabetic
- By Inheritance
Inherited
- ImplicitApply
- AnyRef
- Any
Implicitly
- by ImplicitApplyOps
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
Visibility
- Public
- All
Type Members
- abstract type Out
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
+(other: String): String
- Implicit
- This member is added by an implicit conversion from ImplicitApply[F] to any2stringadd[ImplicitApply[F]] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
-
def
->[B](y: B): (ImplicitApply[F], B)
- Implicit
- This member is added by an implicit conversion from ImplicitApply[F] to ArrowAssoc[ImplicitApply[F]] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @inline()
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
ensuring(cond: (ImplicitApply[F]) ⇒ Boolean, msg: ⇒ Any): ImplicitApply[F]
- Implicit
- This member is added by an implicit conversion from ImplicitApply[F] to Ensuring[ImplicitApply[F]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: (ImplicitApply[F]) ⇒ Boolean): ImplicitApply[F]
- Implicit
- This member is added by an implicit conversion from ImplicitApply[F] to Ensuring[ImplicitApply[F]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean, msg: ⇒ Any): ImplicitApply[F]
- Implicit
- This member is added by an implicit conversion from ImplicitApply[F] to Ensuring[ImplicitApply[F]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean): ImplicitApply[F]
- Implicit
- This member is added by an implicit conversion from ImplicitApply[F] to Ensuring[ImplicitApply[F]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from ImplicitApply[F] to StringFormat[ImplicitApply[F]] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @inline()
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
def
implicitApply(implicit implicitApply: ImplicitApply[ImplicitApply[F]]): Out
- Implicit
- This member is added by an implicit conversion from ImplicitApply[F] to ImplicitApplyOps[ImplicitApply[F]] performed by method ImplicitApplyOps in com.thoughtworks.feature.ImplicitApply.
- Definition Classes
- ImplicitApplyOps
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
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( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
→[B](y: B): (ImplicitApply[F], B)
- Implicit
- This member is added by an implicit conversion from ImplicitApply[F] to ArrowAssoc[ImplicitApply[F]] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc