-
Notifications
You must be signed in to change notification settings - Fork 11
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
Introduce the right Kan extension #31
Conversation
Kan extensions are a way to take two functors `f` and `g` and make a third that "extends" `f`s domain along `g`. There are a few transformations from the canonical definition of the right Kan extension to the definition here, but this formulation should be equivalent. Many people have said Kan extensions are the most universal constructions. We show that here by defining Codensity and Yoneda in terms of Ran.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM
Given this comment, maybe it should be (f : Type → Type)
→ λ(g : Type → Type)
→ λ(a : Type)
→ ∀(b : Type) → (f b → a) → g b |
I think since it's a standalone concept and would just cause code duplication I'll merge as is. I believe |
Oh, sorry for being unclear. The two are different.
∀(f : Type → Type) → ∀(g : Type → Type) → ∀(a : Type) → Type λ(f : Type → Type)
→ λ(g : Type → Type)
→ λ(a : Type)
→ ∀(b : Type)
→ (a → f b)
→ g b
∀(f : Type → Type) → ∀(g : Type → Type) → ∀(a : Type) → Type λ(f : Type → Type)
→ λ(g : Type → Type)
→ λ(a : Type)
→ ∀(b : Type)
→ (f b → a)
→ g b N.B. The derived types end up being similarly defined, but over their variance:
∀(f : Type → Type) → ∀(a : Type) → Type ./../../Ran/Covariant/Type ./../../Id/Type
∀(f : Type → Type) → ∀(a : Type) → Type ./../../Ran/Contravariant/Type ./../../Id/Type It makes an impact in expressions like
∀(f : Type → Type)
→ ∀(g : Type → Type)
→ ∀(a : Type)
→ ./../../Comonad/Type f
→ ./../../Functor/Type g
→ g a
→ ./Type f g a λ(f : Type → Type)
→ λ(g : Type → Type)
→ λ(a : Type)
→ λ(comonad : ./../../Comonad/Type f)
→ λ(functor : ./../../Functor/Type g)
→ λ(x : g a)
→ λ(b : Type)
→ λ(k : a → f b)
→ functor.map a b (λ(y : a) → comonad.extract b (k y)) x
∀(f : Type → Type)
→ ∀(g : Type → Type)
→ ∀(a : Type)
→ ./../../Applicative/Type f
→ ./../../Contravariant/Type g
→ g a
→ ./Type f g a λ(f : Type → Type)
→ λ(g : Type → Type)
→ λ(a : Type)
→ λ(applicative : ./../../Applicative/Type f)
→ λ(contravariant : ./../../Contravariant/Type g)
→ λ(x : g a)
→ λ(b : Type)
→ λ(k : f b → a)
→ contravariant.map a b (λ(y : b) → k (applicative.pure b y)) x
∀(f : Type → Type)
→ ∀(g : Type → Type)
→ ∀(a : Type)
→ ./../../Applicative/Type f
→ ./Type f g a
→ g a λ(f : Type → Type)
→ λ(g : Type → Type)
→ λ(a : Type)
→ λ(applicative : ./../../Applicative/Type f)
→ λ(ran : ./Type f g a)
→ ran a (applicative.pure a)
∀(f : Type → Type)
→ ∀(g : Type → Type)
→ ∀(a : Type)
→ ./../../Comonad/Type f
→ ./Type f g a
→ g a λ(f : Type → Type)
→ λ(g : Type → Type)
→ λ(a : Type)
→ λ(comonad : ./../../Comonad/Type f)
→ λ(ran : ./Type f g a)
→ ran a (comonad.extract a) I.e. Where one version requires Ends up with a version of I'm down to submit a PR, if that seems useful. |
Re: #30
First go an implementing
Ran f g a
. There's more that could be moved from Codensity/Yoneda, but requires some additional concepts. E.g.Applicative (Ran f g)
if we have a an isomorphism betweenf
andg
(or at leastforall (a : Type) -> f a -> g a
andforall (a : Type) -> g a -> f a
).Ran/lower
if we haveforall (a : Type) -> f a -> a
(I think).I didn't want to add these just things for the sake of redefining everything in terms of Ran, but can if they're wanted.
In any case, let me know if this is what we're thinking and if anything needs to change!