Skip to content

Instantly share code, notes, and snippets.

@paulp
Created October 10, 2016 14:37
Show Gist options
  • Save paulp/513f5bcc327fa4259f326e3dbcc8123a to your computer and use it in GitHub Desktop.
Save paulp/513f5bcc327fa4259f326e3dbcc8123a to your computer and use it in GitHub Desktop.
type Algebra[F[_], A] = F[A] => A
type AlgebraM[M[_], F[_], A] = F[A] => M[A] // Why isn't F ~> M sufficient?
type Coalgebra[F[_], A] = A => F[A]
/** What do these type aliases buy - they are composing type
* constructors in different orders, but no more simply?
*/
type GAlgebra[W[_], F[_], A] = Algebra [ λ[X => F[W[X]]], A]
type GAlgebraM[W[_], M[_], F[_], A] = AlgebraM[M, λ[X => F[W[X]]], A]
type GCoalgebraM[N[_], M[_], F[_], A] = Coalgebra[λ[X => M[F[N[X]]]], A]
type GCoalgebra[N[_], F[_], A] = Coalgebra[λ[X => F[N[X]]] , A]
type CoalgebraM[M[_], F[_], A] = Coalgebra[λ[X => M[ F[X]] ], A]
type ElgotCoalgebraM[E[_], M[_], F[_], A] = Coalgebra[λ[X => M[E[F[X]]]], A]
type ElgotCoalgebra[E[_], F[_], A] = Coalgebra[λ[X => E[F[X]]] , A]
@paulp
Copy link
Author

paulp commented Oct 11, 2016

The aliases on the left are clearer in a narrow context, assuming they are used meaningfully. But when they aren't used consistently, then you multiply the number of names and concepts yet one still must recognize both forms.

If it's case class ElgotCoalgebraM[E[_], M[_], F[_], A](run: Coalgebra[λ[X => M[E[F[X]]]], A]) then it means something when you have an ElgotCoalgebraM in your type signature. But as a type alias it's just one of many permutations of letters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment