Skip to content

Instantly share code, notes, and snippets.

@paulp
Created March 17, 2018 23:00
Show Gist options
  • Save paulp/5a108c6dfb00931bce7fae784fa0e158 to your computer and use it in GitHub Desktop.
Save paulp/5a108c6dfb00931bce7fae784fa0e158 to your computer and use it in GitHub Desktop.
object ttypes {
type ->[+A, +B] = (A, B)
type PairOf[+A] = A -> A
type SumOf[+A] = A \/ A
trait Interpret[T[_[_]]] {
type ^[Outer[_], Inner[_]] = Outer[T[Inner]]
trait Transform[F[_], G[_]] {
type FTF = F[T[F]]
type GTG = G[T[G]]
/** Bottom-up transforms. */
type GAlgebraicM[W[_], M[_]] = F[W ^ G] => M[G ^ G]
type AlgebraicM[M[_]] = F ^ G => M[G ^ G] // GAlgebraicM[Id, M]
type GAlgebraic[W[_]] = F[W ^ G] => G ^ G // GAlgebraicM[W, Id]
type Algebraic = F ^ G => G ^ G // GAlgebraicM[Id, Id]
/** Top-down transforms. */
type GCoalgebraicM[N[_], M[_]] = F ^ F => M[G[N ^ F]]
type CoalgebraicM[M[_]] = F ^ F => M[G ^ F ] // GCoalgebraicM[Id, M]
type GCoalgebraic[N[_]] = F ^ F => G[N ^ F] // GCoalgebraicM[N, Id]
type Coalgebraic = F ^ F => G ^ F // GCoalgebraicM[Id, Id]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment