-
Notifications
You must be signed in to change notification settings - Fork 67
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
add kleisli triple #381
add kleisli triple #381
Conversation
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.
Very nice - just a few minor things to tweak.
-- see https://ncatlab.org/nlab/show/extension+system (the naming differs) | ||
|
||
open import Level | ||
open import Categories.Category |
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.
Can you please use Categories.Category.Core
(unless you really need more) and also using
clauses and and for all open import
below.
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.
Sure, fixed it!
open MR C | ||
|
||
-- a kleisli triple is a relative monad with J = idF | ||
Kleisli : Set (o ⊔ ℓ ⊔ e) |
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.
I'm wondering if the type should be called KleisliTriple
as there are too many Kleisli
things already? (The implication below can keep its name)
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.
As a slightly polemic point, nLab seems to promote the name "extension system" https://ncatlab.org/nlab/show/extension+system. I am more used to the name "Kleisli triple", but nLab may well change the trend. I do not really have any opinion on this.
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.
I would be fine with either KleisliTriple
or ExtensionSystem
.
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.
I chose KleisliTriple
and KleisliCotriple
for now.
module η = NaturalTransformation η | ||
|
||
assoc' : ∀ {X : Obj} → μ.η X ∘ F₁ (μ.η X) ≈ μ.η X ∘ μ.η (F₀ X) | ||
assoc' = begin |
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 is the exact same proof as commute
above -- factor out please.
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.
Done, I wasn't sure about the naming, so i just named it commute'
and added a comment.
μ = ntHelper {F = F ∘F F} {G = F} record | ||
{ η = λ X → extend id | ||
; commute = λ f → begin | ||
extend id ∘ extend (unit ∘ extend (unit ∘ f)) ≈⟨ sym K.assoc ⟩ |
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 repeated use of sym K.assoc
makes me think that RelativeMonad
should be extended to have sym-assoc
in its API (this is optional, but would be nice).
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.
Changed it for RelativeMonad
and RelativeComonad
and also fixed places where its used.
identityʳ' : ∀ {X Y} {k : X ⇒ F₀ Y} → (μ.η Y ∘ F₁ k) ∘ η.η X ≈ k | ||
identityʳ' {X} {Y} {k} = begin | ||
((μ.η Y ∘ F₁ k) ∘ η.η X) ≈⟨ pullʳ (sym (η.commute _)) ⟩ | ||
(μ.η Y ∘ η.η (F₀ Y) ∘ k) ≈⟨ pullˡ M.identityʳ ⟩ |
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.
cancelˡ M.identityʳ
should cut out 1 line.
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.
Yup, thanks!
Thanks for the feedback! I've also added |
Small proof that kleisli triples are equivalent to monads. I'm looking for some feedback and then I'd do the same for comonads.
I've defined the kleisli-triple as a typedef for
RMonad idF
to avoid redundancy, but this might make things a little unclear.