Skip to content

Instantly share code, notes, and snippets.

@LSLeary
Created April 10, 2023 22:59
Show Gist options
  • Save LSLeary/96ef434a596633a9e231560104feca62 to your computer and use it in GitHub Desktop.
Save LSLeary/96ef434a596633a9e231560104feca62 to your computer and use it in GitHub Desktop.
module Cube where
import Data.Functor.Const (Const(..))
import Data.Functor.Product (Product(..))
import Data.Functor.Sum (Sum(..))
type (&&) = Product
type (||) = Sum
-- Functor Origin
data Empty s
-- Functor Axes
type Ann = Const
type Rec f = f
type Con f a = Ann a && Rec f
-- Functor Cube
type C0 f a = Empty
type CX f a = Ann a -- Const a
type CY f a = Rec f -- f
type CZ f a = Con f a -- Const a && f
type CXY f a = Ann a || Rec f -- Const a || f
type CXZ f a = Ann a || Con f a -- Const a || Const a && f
type CYZ f a = Rec f || Con f a -- f || Const a && f
type CXYZ f a = Ann a || Rec f || Con f a -- Const a || f || Const a && f
-- Fixpoint Appendix
-- Let t := Fix (CXY f a)
-- Then:
-- t ~= Fix (Const a || f)
-- ~= (Const a || f) t
-- ~= Const a t + f t
-- ~= a + f t
-- ~= Free f a
-- Let t := Fix (CZ f a)
-- Then:
-- t ~= Fix (Const a && f)
-- ~= (Const a && f) t
-- ~= Const a t * f t
-- ~= a * f t
-- ~= Cofree f a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment