本文整理汇总了Scala中scala.annotation.implicitNotFound类的典型用法代码示例。如果您正苦于以下问题:Scala implicitNotFound类的具体用法?Scala implicitNotFound怎么用?Scala implicitNotFound使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了implicitNotFound类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:joprice,项目名称:flink-extensions,代码行数:30,代码来源:HasFields.scala
示例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]
}
开发者ID:code-star,项目名称:scala-ts-interfaces,代码行数:49,代码来源:TSType.scala
示例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]
)
}
开发者ID:fomkin,项目名称:korolev,代码行数:24,代码来源:Scheduler.scala
示例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]()
}
开发者ID:memoizr,项目名称:robot-tlp,代码行数:38,代码来源:robot.scala
示例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
}
}
开发者ID:scala-rules,项目名称:rule-engine,代码行数:53,代码来源:MultipliableValues.scala
示例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
}
}
开发者ID:scala-rules,项目名称:rule-engine,代码行数:34,代码来源:AddableValues.scala
示例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
}
}
开发者ID:scala-rules,项目名称:rule-engine,代码行数:29,代码来源:SubtractableValues.scala
示例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)
}
}
开发者ID:scala-rules,项目名称:rule-engine,代码行数:40,代码来源:Addable.scala
示例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)
}
}
开发者ID:scala-rules,项目名称:rule-engine,代码行数:41,代码来源:Multipliable.scala
示例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)
}
}
开发者ID:scala-rules,项目名称:rule-engine,代码行数:40,代码来源:Subtractable.scala
示例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)
}
}
开发者ID:scala-rules,项目名称:rule-engine,代码行数:40,代码来源:Divisible.scala
示例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)
}
}
开发者ID:Rudogma,项目名称:scala-superquants,代码行数:29,代码来源:package.scala
示例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] {}
}
开发者ID:vpavkin,项目名称:scalist,代码行数:20,代码来源:NotContainsConstraint.scala
示例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)
}
}
}
开发者ID:allquantor,项目名称:socketpublisher,代码行数:34,代码来源:CoordinatorParser.scala
示例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]]]
}
开发者ID:sangria-graphql,项目名称:sangria-streaming-api,代码行数:19,代码来源:ValidOutStreamType.scala
示例16: toPredicate
//设置package包名称以及导入依赖的类
package rere.ql.typeclasses
import rere.ql.types._
import rere.ql.util.{FunctionProxyQuery, ProxyQuery}
import scala.annotation.implicitNotFound
@implicitNotFound("Very likely type ${In} cannot be used as predicate")
trait ToPredicate[In] {
type Out <: ReqlDatum
def toPredicate(in: In): ReqlPredicate[Out]
}
object ToPredicate {
@implicitNotFound("Very likely type ${In} cannot be used as predicate of type ${Out0}")
type Aux[In, Out0] = ToPredicate[In] { type Out = Out0 }
type Projection[T] = Aux[T, T]
def apply[In](in: In)(implicit conv: ToPredicate[In]): ReqlPredicate[conv.Out] = {
conv.toPredicate(in)
}
implicit def datumToPredicate[In <: ReqlDatum]: Projection[In] = {
new ToPredicate[In] {
final type Out = In
override def toPredicate(in: In): ReqlPredicate[Out] = {
new ProxyQuery(in) with ReqlPredicate[Out]
}
}
}
implicit def functionToPredicate[In <: ReqlDatum : Transmuter]: Aux[In => ReqlBoolean, In] = {
new ToPredicate[In => ReqlBoolean] {
final type Out = In
override def toPredicate(in: In => ReqlBoolean): ReqlPredicate[Out] = {
new FunctionProxyQuery[Out, ReqlBoolean](in) with ReqlPredicate[Out]
}
}
}
}
开发者ID:pbaun,项目名称:rere,代码行数:43,代码来源:ToPredicate.scala
示例17: toFilterPredicate
//设置package包名称以及导入依赖的类
package rere.ql.typeclasses
import rere.ql.types._
import rere.ql.util.{FunctionProxyQuery, ProxyQuery}
import scala.annotation.implicitNotFound
@implicitNotFound("Very likely type ${In} cannot be used as predicate")
trait ToFilterPredicate[In] {
type Out <: ReqlDatum
def toFilterPredicate(in: In): ReqlFilterPredicate[Out]
}
object ToFilterPredicate {
type Aux[In, Out0] = ToFilterPredicate[In] { type Out = Out0 }
type Projection[T] = Aux[T, T]
def apply[In](in: In)(implicit conv: ToFilterPredicate[In]): ReqlFilterPredicate[conv.Out] = {
conv.toFilterPredicate(in)
}
implicit def objectToFilterPredicate[In <: ReqlObject]: Projection[In] = {
new ToFilterPredicate[In] {
final type Out = In
override def toFilterPredicate(in: In): ReqlFilterPredicate[Out] = {
new ProxyQuery(in) with ReqlFilterPredicate[Out]
}
}
}
implicit def functionToFilterPredicate[In <: ReqlDatum : Transmuter]: Aux[In => ReqlBoolean, In] = {
new ToFilterPredicate[In => ReqlBoolean] {
final type Out = In
override def toFilterPredicate(in: In => ReqlBoolean): ReqlFilterPredicate[Out] = {
new FunctionProxyQuery[Out, ReqlBoolean](in) with ReqlFilterPredicate[Out]
}
}
}
}
开发者ID:pbaun,项目名称:rere,代码行数:43,代码来源:ToFilterPredicate.scala
示例18: join
//设置package包名称以及导入依赖的类
package lattice
import scala.annotation.implicitNotFound
@implicitNotFound("type ${V} does not have a Lattice instance")
trait Lattice[V] {
def join(current: V, next: V): V
def empty: V
}
object Lattice {
implicit def pair[T](implicit lattice: Lattice[T]): Lattice[(T, T)] = {
new Lattice[(T, T)] {
def join(current: (T, T), next: (T, T)): (T, T) =
(lattice.join(current._1, next._1), lattice.join(current._2, next._2))
def empty: (T, T) =
(lattice.empty, lattice.empty)
}
}
def trivial[T >: Null]: Lattice[T] = {
new Lattice[T] {
override def empty: T = null
override def join(current: T, next: T): T = {
if (current == null) next
else throw LatticeViolationException(current, next)
}
}
}
}
final case class LatticeViolationException[D](current: D, next: D) extends IllegalStateException(
s"Violation of lattice with current $current and next $next!"
)
开发者ID:phaller,项目名称:reactive-async,代码行数:39,代码来源:Lattice.scala
示例19: for
//设置package包名称以及导入依赖的类
package com.qvantel.jsonapi
import scala.annotation.implicitNotFound
import _root_.spray.json._
@implicitNotFound(msg = "Cannot find JsonApiReader or JsonApiFormat type class for ${T}")
trait JsonApiReader[T] extends RootJsonReader[T] {
override def read(primary: JsValue): T = read(primary, Map.empty[(String, String), JsObject], Set.empty[String], "")
def read(primary: JsValue, included: Set[JsObject]): T =
read(primary, handleIncludes(included), Set.empty[String], "")
def read(primary: JsValue, included: Set[JsObject], includePaths: Set[String], includePath: String): T =
read(primary, handleIncludes(included), includePaths, includePath)
def read(primary: JsValue,
included: Map[(String, String), JsObject],
includePaths: Set[String],
includePath: String): T
private[this] def handleIncludes(includes: Set[JsObject]): Map[(String, String), JsObject] = {
import _root_.spray.json.DefaultJsonProtocol._
import _root_.spray.json.lenses.JsonLenses._
includes.map { json =>
val id = json.extract[String]('id)
val tpe = json.extract[String]('type)
((id, tpe), json)
}.toMap
}
}
@implicitNotFound(msg = "Cannot find JsonApiWriter or JsonApiFormat type class for ${T}")
trait JsonApiWriter[T] extends RootJsonWriter[T] {
def included(obj: T): Set[JsObject]
}
@implicitNotFound(msg = "Cannot find JsonApiFormat type class for ${T}")
trait JsonApiFormat[T] extends JsonApiReader[T] with JsonApiWriter[T] with RootJsonFormat[T]
开发者ID:qvantel,项目名称:jsonapi-scala,代码行数:39,代码来源:JsonApiFormat.scala
示例20: acceptedType
//设置package包名称以及导入依赖的类
package com.avsystem.scex
import scala.annotation.implicitNotFound
trait Setter[-T] extends (T => Unit) {
def acceptedType: Type
}
// just to look nicer in Java
abstract class AbstractSetter[-T] extends Setter[T]
@implicitNotFound("Property being set has type ${B}, but value has type ${A} and no conversion is available")
case class SetterConversion[-A, +B](fun: A => B) extends AnyVal
object SetterConversion {
def convert[A, B](a: A)(implicit sc: SetterConversion[A, B]): B =
sc.fun(a)
implicit def fallbackConversion[A]: SetterConversion[A, A] =
SetterConversion(identity)
}
开发者ID:AVSystem,项目名称:scex,代码行数:22,代码来源:Setter.scala
注:本文中的scala.annotation.implicitNotFound类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论