Last active
December 26, 2017 21:15
-
-
Save trepidacious/436776d5facfb5ddae8a413f55e97ecf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Id[+A](guid: Long) | |
sealed trait DeltaIOA[U, A] | |
case class GetId[U, T <: U]() extends DeltaIOA[U, Id[T]] | |
case class Put[U, T <: U](create: Id[T] => DeltaIO[U, T]) extends DeltaIOA[U, T] | |
class Widener[U, V <: U] { | |
type DIOU[A] = DeltaIOA[U, A] | |
type DIOV[A] = DeltaIOA[V, A] | |
val widenUArrow: DIOV ~> DIOU = | |
new (DIOV ~> DIOU) { | |
def apply[A](v: DIOV[A]): DIOU[A] = v match { | |
case GetId() => GetId() | |
case Put(create) => | |
val createU = ((a: Id[A]) => a: (Id[V with A])).andThen(create.andThen(dioV => Delta.widenU[U, V, A](dioV.map(vWithA => vWithA : A)))) | |
Put(createU) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment