mirror of https://github.com/sbt/sbt.git
variance fixes, inference fixes with Result hierarchy
This commit is contained in:
parent
86c938d198
commit
b1bb6ce5ec
|
|
@ -1,22 +1,28 @@
|
||||||
|
/* sbt -- Simple Build Tool
|
||||||
|
* Copyright 2010 Mark Harrah
|
||||||
|
*/
|
||||||
package sbt
|
package sbt
|
||||||
|
|
||||||
import Types._
|
import Types._
|
||||||
|
|
||||||
sealed trait HList
|
sealed trait HList
|
||||||
{
|
{
|
||||||
|
type ToM[M[_]] <: MList[M]
|
||||||
type Up <: MList[Id]
|
type Up <: MList[Id]
|
||||||
def up: Up
|
def up: Up
|
||||||
}
|
}
|
||||||
sealed trait HNil extends HList
|
sealed trait HNil extends HList
|
||||||
{
|
{
|
||||||
type Up = MNil[Id]
|
type ToM[M[_]] = MNil
|
||||||
|
type Up = MNil
|
||||||
def up = MNil
|
def up = MNil
|
||||||
def :+: [G](g: G): G :+: HNil = HCons(g, this)
|
def :+: [G](g: G): G :+: HNil = HCons(g, this)
|
||||||
}
|
}
|
||||||
object HNil extends HNil
|
object HNil extends HNil
|
||||||
final case class HCons[H, T <: HList](head : H, tail : T) extends HList
|
final case class HCons[H, T <: HList](head : H, tail : T) extends HList
|
||||||
{
|
{
|
||||||
type Up = MCons[H, T#Up, Id]
|
type ToM[M[_]] = MCons[H, tail.ToM[M], M]
|
||||||
def up = MCons[H,T#Up, Id](head, tail.up)
|
type Up = MCons[H, tail.Up, Id]
|
||||||
|
def up = MCons[H,tail.Up, Id](head, tail.up)
|
||||||
def :+: [G](g: G): G :+: H :+: T = HCons(g, this)
|
def :+: [G](g: G): G :+: H :+: T = HCons(g, this)
|
||||||
}
|
}
|
||||||
|
|
@ -1,42 +1,33 @@
|
||||||
|
/* sbt -- Simple Build Tool
|
||||||
|
* Copyright 2010 Mark Harrah
|
||||||
|
*/
|
||||||
package sbt
|
package sbt
|
||||||
|
|
||||||
import Types._
|
import Types._
|
||||||
|
|
||||||
sealed trait MList[M[_]]
|
sealed trait MList[+M[_]]
|
||||||
{
|
{
|
||||||
type Map[N[_]] <: MList[N]
|
type Map[N[_]] <: MList[N]
|
||||||
def map[N[_]](f: M ~> N): Map[N]
|
def map[N[_]](f: M ~> N): Map[N]
|
||||||
|
|
||||||
type Down <: HList
|
|
||||||
def down: Down
|
|
||||||
|
|
||||||
def toList: List[M[_]]
|
def toList: List[M[_]]
|
||||||
}
|
}
|
||||||
final case class MCons[H, T <: MList[M], M[_]](head: M[H], tail: T) extends MList[M]
|
final case class MCons[H, +T <: MList[M], +M[_]](head: M[H], tail: T) extends MList[M]
|
||||||
{
|
{
|
||||||
type Down = M[H] :+: T#Down
|
type Map[N[_]] = MCons[H, tail.Map[N], N]
|
||||||
def down = HCons(head, tail.down)
|
|
||||||
|
|
||||||
type Map[N[_]] = MCons[H, T#Map[N], N]
|
|
||||||
def map[N[_]](f: M ~> N) = MCons( f(head), tail.map(f) )
|
def map[N[_]](f: M ~> N) = MCons( f(head), tail.map(f) )
|
||||||
|
|
||||||
def :^: [G](g: M[G]): MCons[G, MCons[H, T, M], M] = MCons(g, this)
|
def :^: [N[X] >: M[X], G](g: N[G]): MCons[G, MCons[H, T, N], N] = MCons(g, this)
|
||||||
|
|
||||||
def toList = head :: tail.toList
|
def toList = head :: tail.toList
|
||||||
}
|
}
|
||||||
sealed class MNil[M[_]] extends MList[M]
|
sealed class MNil extends MList[Nothing]
|
||||||
{
|
{
|
||||||
type Down = HNil
|
type Map[N[_]] = MNil
|
||||||
def down = HNil
|
def map[N[_]](f: Nothing ~> N) = MNil
|
||||||
|
|
||||||
type Map[N[_]] = MNil[N]
|
def :^: [M[_], H](h: M[H]): MCons[H, MNil, M] = MCons(h, this)
|
||||||
def map[N[_]](f: M ~> N): MNil[N] = new MNil[N]
|
|
||||||
|
|
||||||
def :^: [H](h: M[H]): MCons[H, MNil[M], M] = MCons(h, this)
|
|
||||||
|
|
||||||
def toList = Nil
|
def toList = Nil
|
||||||
}
|
}
|
||||||
object MNil extends MNil[Id]
|
object MNil extends MNil
|
||||||
{
|
|
||||||
implicit def apply[N[_]]: MNil[N] = new MNil[N]
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
/* sbt -- Simple Build Tool
|
||||||
|
* Copyright 2010 Mark Harrah
|
||||||
|
*/
|
||||||
package sbt
|
package sbt
|
||||||
|
|
||||||
trait TypeFunctions
|
trait TypeFunctions
|
||||||
|
|
@ -7,11 +10,11 @@ trait TypeFunctions
|
||||||
trait P1of2[M[_,_], A] { type Apply[B] = M[A,B] }
|
trait P1of2[M[_,_], A] { type Apply[B] = M[A,B] }
|
||||||
trait Down[M[_]] { type Apply[B] = Id[M[B]] }
|
trait Down[M[_]] { type Apply[B] = Id[M[B]] }
|
||||||
|
|
||||||
trait ~>[A[_], B[_]]
|
trait ~>[-A[_], +B[_]]
|
||||||
{
|
{
|
||||||
def apply[T](a: A[T]): B[T]
|
def apply[T](a: A[T]): B[T]
|
||||||
}
|
}
|
||||||
def Id: Id ~> Id =
|
def Id: Id ~> Id =
|
||||||
new ~>[Id, Id] { def apply[T](a: T): T = a }
|
new (Id ~> Id) { def apply[T](a: T): T = a }
|
||||||
}
|
}
|
||||||
object TypeFunctions extends TypeFunctions
|
object TypeFunctions extends TypeFunctions
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
/* sbt -- Simple Build Tool
|
||||||
|
* Copyright 2010 Mark Harrah
|
||||||
|
*/
|
||||||
package sbt
|
package sbt
|
||||||
|
|
||||||
object Types extends TypeFunctions
|
object Types extends TypeFunctions
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue