type ||[B <: Bool] <: Bool type IfElse[T, F] <: Any } trait True extends Bool { type &&[B <: Bool] = B type ||[B <: Bool] = True type IfElse[T, F] = T } trait False extends Bool { type &&[B <: Bool] = False type ||[B <: Bool] = B type IfElse[T, F] = F }
object MinusOne { implicit val baseCase: MinusOne[Z] { type Res = Z } = new MinusOne[Z] { type Res = Z } implicit def inductiveCase[A <: Nat]: MinusOne[Succ[A]] { type Res = A } = new MinusOne[Succ[A]] { type Res = A } }
object MinusOne { type Aux[A <: Nat, Res1 <: Nat] = MinusOne[A] { type Res = Res1 } implicit val baseCase: Aux[Z, Z] = new MinusOne[Z] { type Res = Z } implicit def inductiveCase[A <: Nat]: Aux[Succ[A], A] = new MinusOne[Succ[A]] { type Res = A } }
<: Nat } object Plus { implicit def baseCase[A <: Nat]: Plus[A, Z] { type Res = A } = new Plus[A, Z] { type Res = A } implicit def inductiveCase[A <: Nat, B <: Nat, C <: Nat, D <: Nat] (implicit ev0: MinusOne[B] { type Res = C }, ev1: Plus[Succ[A], C] { type Res = D }): Plus[A, B] { type Res = D } = new Plus[A, B] { type Res = D } }
Nat, D <: Nat] (implicit ev0: MinusOne[B] { type Res = C }, ev1: Plus[Succ[A], C] { type Res = D }): Plus[A, B] { type Res = D } = new Plus[A, B] { type Res = D }
<: Nat } object Plus { type Aux[A <: Nat, B <: Nat, Res1 <: Nat] = Plus[A, B] { type Res = Res1 } implicit def baseCase[A <: Nat]: Aux[A, Z, A] = new Plus[A, Z] { type Res = A } implicit def inductiveCase[A <: Nat, B <: Nat, C <: Nat, D <: Nat] (implicit ev0: MinusOne.Aux[B, C], ev1: Plus.Aux[Succ[A], C, D]): Aux[A, B, D] = new Plus[A, B] { type Res = D } }
object Length { implicit val baseCase: Length[HNil.type] { type Res = Z } = new Length[HNil.type] { type Res = Z } implicit def inductiveCase[H, T <: HList, N <: Nat] (implicit ev0: Length[T] { type Res = N }) = new Length[HCons[H, T]] { type Res = Succ[N] } }
object Length { type Aux[L <: HList, Res1 <: Nat] = Length[L] { type Res = Res1 } implicit val baseCase: Aux[HNil.type, Z] = new Length[HNil.type] { type Res = Z } implicit def inductiveCase[H, T <: HList, N <: Nat] (implicit ev0: Length.Aux[T, N]) = new Length[HCons[H, T]] { type Res = Succ[N] } }
= hello @ hlist(2) <console>:16: error: Implicit not found: Scary[Type].Please#Ignore You requested to access an element at the position TypelevelEncodingFor[2.type] but the HList Long :: String :: HNil is too short. hlist(2) ^ Compilation failed.
= hello @ hlist(2) <console>:16: error: Implicit not found: Scary[Type].Please#Ignore You requested to access an element at the position TypelevelEncodingFor[2.type] but the HList Long :: String :: HNil is too short. hlist(2) ^ Compilation failed.
:: hello :: HNil @ representation(0) res10: Long = 1 @ representation(1) res11: String = hello @ representation(2) <console>:19: error: Implicit not found: Scary[Type].Please#Ignore You requested to access an element at the position TypelevelEncodingFor[2.type] but the HList Long :: String :: HNil is too short. representation(2) ^