Skip to content

Instantly share code, notes, and snippets.

Created November 23, 2014 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/266c1a5b9fc75e3e8a37 to your computer and use it in GitHub Desktop.
Save anonymous/266c1a5b9fc75e3e8a37 to your computer and use it in GitHub Desktop.
{-#LANGUAGE PolyKinds, TypeFamilies, TypeOperators, ConstraintKinds, UndecidableInstances, FlexibleInstances, FunctionalDependencies, MultiParamTypeClasses, TypeOperators, KindSignatures #-}
import qualified Prelude ((.), id, String)
import Data.Proxy
import GHC.Exts
import GHC.TypeLits
class SmallCategory cat where
name :: Proxy cat -> Prelude.String
id ::(Objects cat a, CategoryMorphism cat morph) => morph a a
type Objects cat :: a -> Constraint
-- type Morph cat :: a -> a -> b
class CategoryMorphism cat morph | cat -> morph, morph -> cat where
(.) :: (Objects cat a, Objects cat b, Objects cat c) => b `morph` c -> a `morph` b -> a `morph` c
instance SmallCategory "Hask" where
id = Prelude.id
name Proxy = "Hask"
type Objects "Hask" = Vacuous "Hask"
-- type Morph "Hask" = (->)
instance CategoryMorphism "Hask" (->) where
(.) = (Prelude..)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment