Created
April 10, 2023 22:59
-
-
Save LSLeary/96ef434a596633a9e231560104feca62 to your computer and use it in GitHub Desktop.
See: https://www.reddit.com/r/haskell/comments/12hq6z6/the_free_boolean_cube_an_exploration_of_things/
This file contains hidden or 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
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