Skip to content

Instantly share code, notes, and snippets.

@gleachkr
Last active June 29, 2016 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gleachkr/884d8cdbb27b7e50b0c04686b78f2e9a to your computer and use it in GitHub Desktop.
Save gleachkr/884d8cdbb27b7e50b0c04686b78f2e9a to your computer and use it in GitHub Desktop.
{-#LANGUAGE FlexibleInstances, FlexibleContexts #-}
--This could be sort of amusing in a presentation.
module Sets where
import Data.Set as S
data Fix f = Fix (f (Fix f))
type V = Fix Set
instance Show (Fix Set) where
show (Fix x) = show x
instance Eq (Fix Set) where
(Fix x) == (Fix y) = x == y
instance Ord (Fix Set) where
(Fix x) <= (Fix y) = x <= y
ev :: V
ev = Fix empty
sv :: V -> V
sv x = Fix $ singleton x
uv :: V -> V -> V
uv (Fix x) (Fix y) = Fix $ union x y
elv :: V -> V -> Bool
elv x (Fix y) = x `elem` y
omegaList :: [V]
omegaList = ev : Prelude.map sv omegaList
omega :: V
omega = Fix (fromList omegaList)
omegaPlus :: V
omegaPlus = sv omega
aczel :: V
aczel = sv aczel
newtype DoublePowerSet a = Dps (a -> Bool -> Bool)
type NotASet = Fix DoublePowerSet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment