本文整理汇总了Scala中scala.annotation.implicitNotFound类的典型用法代码示例。如果您正苦于以下问题:Scala implicitNotFound类的具体用法?Scala implicitNotFound怎么用?Scala implicitNotFound使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了implicitNotFound类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: HasFields
//设置package包名称以及导入依赖的类
package com.joprice.flink
import shapeless._
import shapeless.ops.record._
import scala.annotation.implicitNotFound
import shapeless.tag._
@implicitNotFound("Could not find the fields ${L} in ${T}")
trait HasFields[T, L <: HList]
object HasFields{
implicit def hnilToHasFieldMapper[T]: HasFields[T, HNil] = null
implicit def stringToHasFieldMapper[T, Head, L <: HList, Tail <: HList](
implicit
lgen: LabelledGeneric.Aux[T, L],
s: Selector[L, Symbol @@ Head],
tail: HasFields[T, Tail]
): HasFields[T, Head :: Tail] = null
implicit def symbolToHasFieldMapper[T, Head, L <: HList, Tail <: HList](
implicit
lgen: LabelledGeneric.Aux[T, L],
s: Selector[L, Head],
tail: HasFields[T, Tail]
): HasFields[T, Head :: Tail] = null
}
示例2: ined
//设置package包名称以及导入依赖的类
package nl.codestar.scala.ts.interface
import scala.annotation.implicitNotFound
import TypescriptType._
@implicitNotFound(
"Could not find a Typescript type mapping for type ${T}. Make sure an implicit TSType[${T}] or TSIType[${T}] is in scope and was defined before this point.")
trait TSType[T] { self =>
def get: TypescriptType
}
@implicitNotFound(
"Could not find a TSNamedType[${T}] in scope. If you have defined a typescript mapping, we can only use typescript types with a name at this location.")
trait TSNamedType[T] extends TSType[T] { self =>
def get: TypescriptNamedType
}
object TSType {
def apply[T](tt: TypescriptType): TSType[T] = new TSType[T] { val get = tt }
def of[T](implicit tsType: TSType[T]): TypescriptType = tsType.get
}
object TSNamedType {
def apply[T](tt: TypescriptNamedType): TSNamedType[T] = new TSNamedType[T] {
val get = tt
}
def fromString[T](s: String): TSNamedType[T] =
TypescriptType.fromString(s) match {
case t: TSExternalName => TSNamedType(t)
case _ => throw new IllegalArgumentException(s"String $s is a ")
}
}
@implicitNotFound(
"Could not find a TSIType[${T}] in scope. If you have defined a typescript mapping, we can only use typescript interface types at this location.")
trait TSIType[T] extends TSNamedType[T] { self =>
override def get: TSInterface
}
object TSIType {
def apply[T](tt: TSInterface): TSIType[T] = new TSIType[T] { val get = tt }
def fromCaseClass[T]: TSIType[T] = macro Macros.generateInterface[T]
}
示例3: Scheduler
//设置package包名称以及导入依赖的类
package korolev.util
import korolev.Async
import korolev.util.Scheduler.{Cancel, JobHandler}
import scala.annotation.implicitNotFound
import scala.concurrent.duration.FiniteDuration
@implicitNotFound("Scheduler for ${F} is not found. Ensure that it is passed to the scope (import korolev.execution.defaultScheduler)")
abstract class Scheduler[F[+ _] : Async] {
def scheduleOnce[T](delay: FiniteDuration)(job: => T): JobHandler[F, T]
def schedule[U](interval: FiniteDuration)(job: => U): Cancel
}
object Scheduler {
type Cancel = () => Unit
case class JobHandler[F[+_]: Async, +T](
cancel: Cancel,
result: F[T]
)
}
示例4: RobotAt
//设置package包名称以及导入依赖的类
package robot
import robot.RobotAt._
import shapeless._
import shapeless.nat._
import shapeless.ops.hlist.LeftFolder
import shapeless.ops.nat._
import scala.annotation.implicitNotFound
case class RobotAt[latitude <: Nat: isInsideWarehouse, longitude <: Nat: isInsideWarehouse]() {
def move(towardsDirection: Direction)(
implicit
lookForA: ProofThatItCanMove[towardsDirection.type, latitude, longitude]
) = lookForA.validMove()
def moveAlongRoute[head <: Direction, tail <: HList](route: head :: tail)(
implicit
moveAlong: FollowRoute[head :: tail, RobotAt[latitude, longitude], Router.type]
): moveAlong.Out = moveAlong(route, RobotAt[latitude, longitude]())
}
object RobotAt {
@implicitNotFound(
"""Illegal route: cannot move along route=${route} from position=${initialPosition} when using Router=${router}.
Please ensure robot stays within the confines of the warehouse (_0 <= position <= _9)."""
)
type FollowRoute[route <: HList, initialPosition, router] = LeftFolder[route, initialPosition, router]
@implicitNotFound("Illegal position: ${position} is not <= _9")
type isInsideWarehouse[position <: Nat] = position LTEq _9
}
object Warehouse {
def withRobotAt[latitude <: Nat: isInsideWarehouse, longitude <: Nat: isInsideWarehouse]() = RobotAt[latitude, longitude]()
}
示例5: MultipliableValues
//设置package包名称以及导入依赖的类
package org.scalarules.dsl.core.types
import org.scalarules.finance.core.Quantity
import org.scalarules.finance.nl._
import scala.annotation.implicitNotFound
@implicitNotFound("No member of type class MultipliableValues available in scope for combination ${A} * ${B} = ${C}")
trait MultipliableValues[A, B, C] {
def multiply(a: A, b: B): C
def leftUnit: A
def rightUnit: B
}
object MultipliableValues {
implicit def bigDecimalTimesBigDecimal: MultipliableValues[BigDecimal, BigDecimal, BigDecimal] = new MultipliableValues[BigDecimal, BigDecimal, BigDecimal] {
override def multiply(a: BigDecimal, b: BigDecimal): BigDecimal = a * b
override def leftUnit: BigDecimal = 0
override def rightUnit: BigDecimal = 0
}
implicit def somethingTimesBigDecimal[N : Quantity]: MultipliableValues[N, BigDecimal, N] = new MultipliableValues[N, BigDecimal, N] {
private val ev = implicitly[Quantity[N]]
override def multiply(a: N, b: BigDecimal): N = ev.multiply(a, b)
override def leftUnit: N = ev.zero
override def rightUnit: BigDecimal = 0
}
implicit def bigDecimalTimesSomething[N : Quantity]: MultipliableValues[BigDecimal, N, N] = new MultipliableValues[BigDecimal, N, N] {
private val ev = implicitly[Quantity[N]]
override def multiply(a: BigDecimal, b: N): N = ev.multiply(b, a)
override def leftUnit: BigDecimal = 0
override def rightUnit: N = ev.zero
}
implicit def quantityTimesPercentage[N : Quantity]: MultipliableValues[N, Percentage, N] = new MultipliableValues[N, Percentage, N] {
private val ev = implicitly[Quantity[N]]
override def multiply(a: N, b: Percentage): N = b * a
override def leftUnit: N = ev.zero
override def rightUnit: Percentage = 0.procent
}
implicit def percentageTimesQuantity[N : Quantity]: MultipliableValues[Percentage, N, N] = new MultipliableValues[Percentage, N, N] {
private val ev = implicitly[Quantity[N]]
override def multiply(a: Percentage, b: N): N = a * b
override def leftUnit: Percentage = 0.procent
override def rightUnit: N = ev.zero
}
implicit def bedragTimesPeriode: MultipliableValues[Bedrag, Periode, Bedrag] = new MultipliableValues[Bedrag, Periode, Bedrag] {
override def multiply(a: Bedrag, b: Periode): Bedrag = a * b.inMaanden
override def leftUnit: Bedrag = 0.euro
override def rightUnit: Periode = 0.maanden
}
}
示例6: AddableValue
//设置package包名称以及导入依赖的类
package org.scalarules.dsl.core.types
import org.scalarules.finance.core.Quantity
import scala.annotation.implicitNotFound
@implicitNotFound("No member of type class AddableValue available in scope for combination ${A} + ${B} = ${C}")
trait AddableValues[A, B, C] {
def plus(a: A, b: B): C
def leftUnit: A
def rightUnit: B
}
object AddableValues {
implicit def bigDecimalAddedToBigDecimal: AddableValues[BigDecimal, BigDecimal, BigDecimal] = new AddableValues[BigDecimal, BigDecimal, BigDecimal] {
override def plus(a: BigDecimal, b: BigDecimal): BigDecimal = a + b
override def leftUnit: BigDecimal = 0
override def rightUnit: BigDecimal = 0
}
implicit def intAddedToInt: AddableValues[Int, Int, Int] = new AddableValues[Int, Int, Int] {
override def plus(a: Int, b: Int): Int = a + b
override def leftUnit: Int = 0
override def rightUnit: Int = 0
}
implicit def quantityAddedToQuantity[N : Quantity]: AddableValues[N, N, N] = new AddableValues[N, N, N] {
private val ev = implicitly[Quantity[N]]
override def plus(a: N, b: N): N = ev.plus(a, b)
override def leftUnit: N = ev.zero
override def rightUnit: N = ev.zero
}
}
示例7: SubtractableValues
//设置package包名称以及导入依赖的类
package org.scalarules.dsl.core.types
import org.scalarules.finance.core.Quantity
import scala.annotation.implicitNotFound
@implicitNotFound("No member of type class SubtractableValues available in scope for combination ${A} - ${B} = ${C}")
trait SubtractableValues[A, B, C] {
def minus(a: A, b: B): C
def leftUnit: A
def rightUnit: B
}
object SubtractableValues {
implicit def bigDecimalSubtractedByBigDecimal: SubtractableValues[BigDecimal, BigDecimal, BigDecimal] = new SubtractableValues[BigDecimal, BigDecimal, BigDecimal] {
override def minus(a: BigDecimal, b: BigDecimal): BigDecimal = a - b
override def leftUnit: BigDecimal = 0
override def rightUnit: BigDecimal = 0
}
implicit def quantitySubtractedByQuantity[N : Quantity]: SubtractableValues[N, N, N] = new SubtractableValues[N, N, N] {
private val ev = implicitly[Quantity[N]]
override def minus(a: N, b: N): N = ev.minus(a, b)
override def leftUnit: N = ev.zero
override def rightUnit: N = ev.zero
}
}
示例8: Addable
//设置package包名称以及导入依赖的类
package org.scalarules.dsl.core.operators
import org.scalarules.dsl.core.types.AddableValues
import scala.annotation.implicitNotFound
@implicitNotFound("No member of type class Addable available in scope for combination ${A} + ${B} = ${C}")
sealed trait Addable[A, B, C] extends BinaryOperable[A, B, C] {
def operation(a: A, b: B): C
def identityLeft: A
def identityRight: B
def representation: String = "+"
}
object Addable {
implicit def valueAddedToValue[A, B, C](implicit ev: AddableValues[A, B, C]): Addable[A, B, C] = new Addable[A, B, C] {
override def operation(n: A, m: B): C = ev.plus(n, m)
override def identityLeft = ev.leftUnit
override def identityRight = ev.rightUnit
}
implicit def listAddedToList[A, B, C](implicit ev: AddableValues[A, B, C]): Addable[List[A], List[B], List[C]] = new Addable[List[A], List[B], List[C]] {
override def operation(n: List[A], m: List[B]): List[C] = n.zipAll(m, ev.leftUnit, ev.rightUnit).map(t => ev.plus(t._1, t._2))
override def identityLeft = List(ev.leftUnit)
override def identityRight = List(ev.rightUnit)
}
implicit def listAddedToValue[A, B, C](implicit ev: AddableValues[A, B, C]): Addable[List[A], B, List[C]] = new Addable[List[A], B, List[C]] {
override def operation(n: List[A], m: B): List[C] = n.map( ev.plus(_, m) )
override def identityLeft = List(ev.leftUnit)
override def identityRight = ev.rightUnit
}
implicit def valueAddedToList[A, B, C](implicit ev: AddableValues[A, B, C]): Addable[A, List[B], List[C]] = new Addable[A, List[B], List[C]] {
override def operation(n: A, m: List[B]): List[C] = m.map( ev.plus(n, _) )
override def identityLeft = ev.leftUnit
override def identityRight = List(ev.rightUnit)
}
}
示例9: Multipliabe
//设置package包名称以及导入依赖的类
package org.scalarules.dsl.core.operators
import org.scalarules.dsl.core.types.MultipliableValues
import scala.annotation.implicitNotFound
@implicitNotFound("No member of type class Multipliabe available in scope for combination ${A} * ${B} = ${C}")
sealed trait Multipliable[A, B, C] extends BinaryOperable[A, B, C] {
def operation(a: A, b: B): C
def identityLeft: A
def identityRight: B
def representation: String = "*"
}
object Multipliable {
implicit def valueMultipliedByValue[A, B, C](implicit ev: MultipliableValues[A, B, C]): Multipliable[A, B, C] = new Multipliable[A, B, C] {
override def operation(n: A, m: B): C = ev.multiply(n, m)
override def identityLeft = ev.leftUnit
override def identityRight = ev.rightUnit
}
implicit def listMultipliedByList[A, B, C](implicit ev: MultipliableValues[A, B, C]): Multipliable[List[A], List[B], List[C]] = new Multipliable[List[A], List[B], List[C]] {
override def operation(n: List[A], m: List[B]): List[C] = n.zip(m).map(t => ev.multiply(t._1, t._2))
override def identityLeft = List(ev.leftUnit)
override def identityRight = List(ev.rightUnit)
}
implicit def listMultipliedByValue[A, B, C](implicit ev: MultipliableValues[A, B, C]): Multipliable[List[A], B, List[C]] = new Multipliable[List[A], B, List[C]] {
override def operation(n: List[A], m: B): List[C] = n.map( ev.multiply(_, m) )
override def identityLeft = List(ev.leftUnit)
override def identityRight = ev.rightUnit
}
implicit def valueMultipliedByList[A, B, C](implicit ev: MultipliableValues[A, B, C]): Multipliable[A, List[B], List[C]] = new Multipliable[A, List[B], List[C]] {
override def operation(n: A, m: List[B]): List[C] = m.map( ev.multiply(n, _) )
override def identityLeft = ev.leftUnit
override def identityRight = List(ev.rightUnit)
}
}
示例10: Subtractable
//设置package包名称以及导入依赖的类
package org.scalarules.dsl.core.operators
import org.scalarules.dsl.core.types.SubtractableValues
import scala.annotation.implicitNotFound
@implicitNotFound("No member of type class Subtractable available in scope for combination ${A} - ${B} = ${C}")
trait Subtractable[A, B, C] extends BinaryOperable[A, B, C] {
def operation(a: A, b: B): C
def identityLeft: A
def identityRight: B
def representation: String = "-"
}
object Subtractable {
implicit def valueSubtractedByValue[A, B, C](implicit ev: SubtractableValues[A, B, C]): Subtractable[A, B, C] = new Subtractable[A, B, C] {
override def operation(n: A, m: B): C = ev.minus(n, m)
override def identityLeft = ev.leftUnit
override def identityRight = ev.rightUnit
}
implicit def listSubtractedByList[A, B, C](implicit ev: SubtractableValues[A, B, C]): Subtractable[List[A], List[B], List[C]] = new Subtractable[List[A], List[B], List[C]] {
override def operation(n: List[A], m: List[B]): List[C] = n.zipAll(m, ev.leftUnit, ev.rightUnit).map(t => ev.minus(t._1, t._2))
override def identityLeft = List(ev.leftUnit)
override def identityRight = List(ev.rightUnit)
}
implicit def listSubtractedByValue[A, B, C](implicit ev: SubtractableValues[A, B, C]): Subtractable[List[A], B, List[C]] = new Subtractable[List[A], B, List[C]] {
override def operation(n: List[A], m: B): List[C] = n.map( ev.minus(_, m) )
override def identityLeft = List(ev.leftUnit)
override def identityRight = ev.rightUnit
}
implicit def valueSubtractedByList[A, B, C](implicit ev: SubtractableValues[A, B, C]): Subtractable[A, List[B], List[C]] = new Subtractable[A, List[B], List[C]] {
override def operation(n: A, m: List[B]): List[C] = m.map( ev.minus(n, _) )
override def identityLeft = ev.leftUnit
override def identityRight = List(ev.rightUnit)
}
}
示例11: Divisible
//设置package包名称以及导入依赖的类
package org.scalarules.dsl.core.operators
import org.scalarules.dsl.core.types.DivisibleValues
import scala.annotation.implicitNotFound
@implicitNotFound("No member of type class Divisible available in scope for combination ${A} / ${B} = ${C}")
sealed trait Divisible[A, B, C] extends BinaryOperable[A, B, C] {
def operation(a: A, b: B): C
def identityLeft: A
def identityRight: B
def representation: String = "/"
}
object Divisible {
implicit def valueDividedByValue[A, B, C](implicit ev: DivisibleValues[A, B, C]): Divisible[A, B, C] = new Divisible[A, B, C] {
override def operation(n: A, m: B): C = ev.divide(n, m)
override def identityLeft = ev.leftUnit
override def identityRight = ev.rightUnit
}
implicit def listDividedByList[A, B, C](implicit ev: DivisibleValues[A, B, C]): Divisible[List[A], List[B], List[C]] = new Divisible[List[A], List[B], List[C]] {
override def operation(n: List[A], m: List[B]): List[C] = n.zip(m).map(t => ev.divide(t._1, t._2))
override def identityLeft = List(ev.leftUnit)
override def identityRight = List(ev.rightUnit)
}
implicit def listDividedByValue[A, B, C](implicit ev: DivisibleValues[A, B, C]): Divisible[List[A], B, List[C]] = new Divisible[List[A], B, List[C]] {
override def operation(n: List[A], m: B): List[C] = n.map( ev.divide(_, m) )
override def identityLeft = List(ev.leftUnit)
override def identityRight = ev.rightUnit
}
implicit def valueDividedByList[A, B, C](implicit ev: DivisibleValues[A, B, C]): Divisible[A, List[B], List[C]] = new Divisible[A, List[B], List[C]] {
override def operation(n: A, m: List[B]): List[C] = m.map( ev.divide(n, _) )
override def identityLeft = ev.leftUnit
override def identityRight = List(ev.rightUnit)
}
}
示例12: apply
//设置package包名称以及导入依赖的类
package superquants
import scala.annotation.implicitNotFound
package object laws {
@implicitNotFound("Not found Law to make Operation[${Op}] for operand1: ${P1}, and operand2: ${P2}")
trait LawTrait[P1, Op <: Operation, P2] {
type Out
def apply(p1: P1, p2: P2): Out
}
type Law[P1, O <: Operation, P2, Out0] = LawTrait[P1, O, P2] {type Out = Out0}
def Law[P1, O <: Operation, P2, Out0](f: (P1, P2) => Any) = new LawTrait[P1, O, P2] {
type Out = Out0
def apply(p1: P1, p2: P2): Out0 = f(p1, p2).asInstanceOf[Out0]
}
implicit class LawOps[T](val __p1:T) extends AnyVal {
def multiply[U](p2:U)(implicit law:LawTrait[T, Multiply,U]):law.Out = law(__p1, p2)
def divide[U](p2:U)(implicit law:LawTrait[T, Divide, U]):law.Out = law(__p1, p2)
def minus[U](p2:U)(implicit law:LawTrait[T, Minus, U]):law.Out = law(__p1, p2)
def plus[U](p2:U)(implicit law:LawTrait[T, Plus, U]):law.Out = law(__p1, p2)
}
}
示例13: NotContainsConstraint
//设置package包名称以及导入依赖的类
package ru.pavkin.todoist.api.utils
import scala.annotation.implicitNotFound
import shapeless._
@implicitNotFound("Implicit not found: NotContains[${L}, ${U}]. HList already contains type ${U}")
trait NotContainsConstraint[L <: HList, U]
object NotContainsConstraint {
def apply[L <: HList, U](implicit ev: NotContainsConstraint[L, U]): NotContainsConstraint[L, U] = ev
implicit def nilNotContains[U]: NotContainsConstraint[HNil, U] =
new NotContainsConstraint[HNil, U] {}
implicit def recurse[H <: HList, T, U](implicit
ev: H NotContainsConstraint U,
ev2: U =:!= T): NotContainsConstraint[T :: H, U] =
new NotContainsConstraint[T :: H, U] {}
}
示例14: parse
//设置package包名称以及导入依赖的类
package io.allquantor.protocol.polymorphism
import io.allquantor.protocol.Coordinates
import scala.annotation.implicitNotFound
import scala.util.Try
@implicitNotFound("Implicit not found for ${T}")
trait CoordinatorParser[T] {
def parse(value: T): Coordinates
}
object CoordinatorParser {
def parseCoordinates[T: CoordinatorParser](value: T): Coordinates = implicitly[CoordinatorParser[T]].parse(value)
implicit val stringCoordinates = new CoordinatorParser[String] {
override def parse(value: String): Coordinates = {
val (lat, long, name): (Double, Double, String) = Try(value.split(",")).flatMap { c =>
Try(
(
c(0).toDouble,
c(1).toDouble,
c(2)
)
)
}.getOrElse(
(0, 0, "----Error Parsed----")
)
Coordinates(lat, long, name)
}
}
}
示例15: ValidOutStreamType
//设置package包名称以及导入依赖的类
package sangria.streaming
import scala.annotation.implicitNotFound
@implicitNotFound(msg = "${Res} is invalid type for the resulting GraphQL type ${Out}.")
trait ValidOutStreamType[-Res, +Out]
object ValidOutStreamType extends LowPrioValidOutType {
implicit def validSubclass[Res, Out](implicit ev: Res <:< Out) = valid.asInstanceOf[ValidOutStreamType[Res, Out]]
implicit def validNothing[Out] = valid.asInstanceOf[ValidOutStreamType[Nothing, Out]]
implicit def validOption[Res, Out](implicit ev: Res <:< Out) = valid.asInstanceOf[ValidOutStreamType[Res, Option[Out]]]
}
trait LowPrioValidOutType {
val valid = new ValidOutStreamType[Any, Any] {}
implicit def validSeq[Res, Out](implicit ev: Res <:< Out) = valid.asInstanceOf[ValidOutStreamType[Res, Seq[Out]]]
}