builders

oxygen.meta.K0.SumGeneric.builders
object builders

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
builders.type

Members list

Value members

Concrete methods

def instanceFromLazyTypeClasses[TC[_] : Type](autoDeriveChildren: [i <: A] => ProductGeneric[i] => Expr[TC[i]])(use: ValExpressions[TC] => Expr[TC[A]]): Expr[TC[A]]

Same as instanceFromLazyTypeClasses, except typed for the most common case of: summon[ TC[] ] => TC[]

Same as instanceFromLazyTypeClasses, except typed for the most common case of: summon[ TC[] ] => TC[]

Attributes

def mapToSeq[B](mapCase: [i <: A] => Case[i] => B): Seq[B]

This is useful when you want to get some Seq of "something else" out of your A.

This is useful when you want to get some Seq of "something else" out of your A.

Hint: You are almost certainly going to want to call ProductGeneric.typeClassInstance from within mapField.

Attributes

def matchOnInput[B : Type, C : Type](input: Expr[B])(useCase: [i <: A] => Case[i] => (Expr[B], Expr[C]))(default: Expr[C]): Expr[C]

This is useful when you have some generic thing, and can create a representation of it from a Case. A common example would be the canonical scala JsonDecoder. Example json: { "MySubType": ... } This function would allow you to match on a String, and do Expr(kase.name) in order to then use the child case decoder for MySubType.

This is useful when you have some generic thing, and can create a representation of it from a Case. A common example would be the canonical scala JsonDecoder. Example json: { "MySubType": ... } This function would allow you to match on a String, and do Expr(kase.name) in order to then use the child case decoder for MySubType.

If you need to match on more than 1 thing, you probably want MatchBuilder.instance and/or MatchBuilder.value.

Hint: You are almost certainly going to want to call SumGeneric.typeClassInstance from within useCase.

Warning: This is currently only tested to work where useCase.Expr[B] returns a constant. Ex: (??? : String) match { case "a" => ...; case "b" => ... }

Attributes

def matchOnInstance[B : Type](instance: Expr[A])(useCase: [i <: A] => (x$1: Case[i], x$2: Expr[i]) => Expr[B]): Expr[B]

This is useful when you have an instance of A, and want to do things differently depending on which sub-type of A you have. A common example would be the canonical scala JsonEncoder. We are able to auto-derive all the child case JsonEncoders for myEnum: MyEnum, but how do we know which one to call? This would then allow you to wrap a child JsonAST in { "MySubType": ... }. This function gives you an exhaustive match on myEnum: MyEnum, the ability to use a child TC[_] instance, and then modify that Expr.

This is useful when you have an instance of A, and want to do things differently depending on which sub-type of A you have. A common example would be the canonical scala JsonEncoder. We are able to auto-derive all the child case JsonEncoders for myEnum: MyEnum, but how do we know which one to call? This would then allow you to wrap a child JsonAST in { "MySubType": ... }. This function gives you an exhaustive match on myEnum: MyEnum, the ability to use a child TC[_] instance, and then modify that Expr.

Hint: You are almost certainly going to want to call SumGeneric.typeClassInstance from within useCase.

If you need to match on more than 1 thing, you probably want MatchBuilder.instance and/or MatchBuilder.value.

Attributes

def withLazyTypeClasses[TC[_] : Type, O : Type](autoDerive: [i <: A] => ProductGeneric[i] => Expr[TC[i]])(use: ValExpressions[TC] => Expr[O]): Expr[O]

This will summon instances for all case children. If no instance is found, it will auto-derive the child instance in place.

This will summon instances for all case children. If no instance is found, it will auto-derive the child instance in place.

You should call withLazyTypeClasses[TC] when you are trying to derive a TC[A]. You should not call withLazyTypeClasses[OtherTC] when you are trying to derive a TC[A].

Attributes

def withLazyTypeClassesNoAutoDerive[TC[_] : Type, O : Type](use: ValExpressions[TC] => Expr[O]): Expr[O]

Similar to withLazyTypeClasses, except if no instance is found, a compile error will be created instead of auto-deriving.

Similar to withLazyTypeClasses, except if no instance is found, a compile error will be created instead of auto-deriving.

You should not call withLazyTypeClassesNoAutoDerive[TC] when you are trying to derive a TC[A]. You should call withLazyTypeClassesNoAutoDerive[OtherTC] when you are trying to derive a TC[A].

Attributes

def withLazyValExpressions[F[_] : Type, O : Type](make: [i <: A] => Case[i] => Expr[F[i]])(use: ValExpressions[F] => Expr[O]): Expr[O]
def withValExpressions[F[_] : Type, O : Type](make: [i <: A] => Case[i] => Expr[F[i]])(use: ValExpressions[F] => Expr[O]): Expr[O]