libretto.lambda.PatternMatching
See thePatternMatching companion object
class PatternMatching[->[_, _], **[_, _]](using x$1: SymmetricSemigroupalCategory[->, **], x$2: BiInjective[**])
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
Type members
Classlikes
class ForLambdas[->>[_, _], V, C, LAMBDAS <: Lambdas[->>, **, V, C], E >: LinearityViolation[V, C] | UnusedInBranch[V, C] | PatternMatchError](val lambdas: LAMBDAS)(isExtractor: [X, Y] => (X ->> Y) => Option[Extractor[X, Y]], lower: [X, Y] => (X ->> Y) => Validated[E, X -> Y], lift: [X, Y] => (X -> Y) => X ->> Y)
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
enum PatternMatchError
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Value members
Concrete methods
def compilePatternMatch[A, R](cases: NonEmptyList[Exists[[Y] =>> (Pattern[A, Y], Y -> R)]]): Validated[PatternMatchError, A -> R]
def detectPatternsAndCompile[->>[_, _], Expr[_], A, R, E >: PatternMatchError](using sh: ShuffledModule[->>, **])(cases: CapturingFun[[a, b] =>> NonEmptyList[sh.Shuffled[a, b]], **, Expr, A, R])(isExtractor: [X, Y] => ->>[X, Y] => Option[Extractor[X, Y]], compile: [X, Y] => ->>[X, Y] => Validated[E, X -> Y]): Validated[E, CapturingFun[->, **, Expr, A, R]]
For functions represented as Shuffled of some arrows ->>
, this method itself detects the pattern part of each function (as the initial tree of Extractors) and subsequently compiles them as a pattern matching. This may be more convenient than compilePatternMatch, where the separation between pattern and handler is provided by the caller.
For functions represented as Shuffled of some arrows ->>
, this method itself detects the pattern part of each function (as the initial tree of Extractors) and subsequently compiles them as a pattern matching. This may be more convenient than compilePatternMatch, where the separation between pattern and handler is provided by the caller.
Attributes
def forLambdas[->>[_, _], V, C, E >: LinearityViolation[V, C] | UnusedInBranch[V, C] | PatternMatchError](lambdas: Lambdas[->>, **, V, C])(isExtractor: [X, Y] => ->>[X, Y] => Option[Extractor[X, Y]], lower: [X, Y] => ->>[X, Y] => Validated[E, X -> Y], lift: [X, Y] => (X -> Y) => ->>[X, Y]): ForLambdas[->>, V, C, lambdas.type, E]
In this article