Skip to content

Instantly share code, notes, and snippets.

@trepidacious
Last active December 26, 2017 21:15
Show Gist options
  • Save trepidacious/436776d5facfb5ddae8a413f55e97ecf to your computer and use it in GitHub Desktop.
Save trepidacious/436776d5facfb5ddae8a413f55e97ecf to your computer and use it in GitHub Desktop.
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