Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An adjunction(?) #107

Open
masaeedu opened this issue May 22, 2021 · 0 comments
Open

An adjunction(?) #107

masaeedu opened this issue May 22, 2021 · 0 comments

Comments

@masaeedu
Copy link

masaeedu commented May 22, 2021

Hello there. So here's a neat little thing that possibly demonstrates Dict being one half of an adjunction between the Heyting algebra of constraints and the CCC of types and functions we know and love:

data a :- b
  where
  Proof :: (a  b) => a :- b
infixr 0 :-

instance Category (:-)
  where
  id = Proof
  Proof . Proof = Proof

-- A functor Constraint -> Type
type Dict :: Constraint -> Type
data Dict c
  where
  Dict :: c => Dict c

-- A functor Type -> Constraint
type Only :: Type -> Constraint
class Only x
  where
  only :: x

instance c => Only (Dict c)
  where
  only = Dict

type M c = Only (Dict c)
type C x = Dict (Only x)

-- The unit of the adjunction
unit :: c :- M c
unit = Proof

-- The counit of the adjunction
counit :: C x -> x
counit Dict = only

I don't have a lot of time to explore this further but I figured I'd dump the beginning of the idea here and someone can tear it apart if it's wrong/build on it if it makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant