Introduce and use KList.Aux

This commit is contained in:
Dale Wijnand 2017-10-18 17:56:43 -05:00
parent 3cd8f4dadf
commit 34f9e56311
No known key found for this signature in database
GPG Key ID: 4F256E3D151DF5EF
2 changed files with 4 additions and 1 deletions

View File

@ -59,7 +59,7 @@ object AList {
}
/** AList for the arbitrary arity data structure KList. */
def klist[KL[M[_]] <: KList[M] { type Transform[N[_]] = KL[N] }]: AList[KL] = new AList[KL] {
def klist[KL[M[_]] <: KList.Aux[M, KL]]: AList[KL] = new AList[KL] {
def transform[M[_], N[_]](k: KL[M], f: M ~> N) = k.transform(f)
def foldr[M[_], T](k: KL[M], f: (M[_], T) => T, init: T): T = k.foldr(f, init)
override def apply[M[_], C](k: KL[M], f: KL[Id] => C)(implicit app: Applicative[M]): M[C] = k.apply(f)(app)

View File

@ -29,6 +29,9 @@ sealed trait KList[+M[_]] {
/** Discards the heterogeneous type information and constructs a plain List from this KList's elements. */
def toList: List[M[_]]
}
object KList {
type Aux[+M[_], Transform0[N[_]]] = KList[M] { type Transform[N[_]] = Transform0[N] }
}
final case class KCons[H, +T <: KList[M], +M[_]](head: M[H], tail: T) extends KList[M] {
final type Transform[N[_]] = KCons[H, tail.Transform[N], N]