Skip to content

Commit

Permalink
fix(category_theory/concrete): access the carrier type by the coercion (
Browse files Browse the repository at this point in the history
#2473)

This should marginally reduce the pain of using concrete categories, as the underlying types of a bundled object should more uniformly described via a coercion, rather than the `.α` projection.

(There's still some separate pain involving `bundled.map`, but it has an orthogonal fix which I'm working on in another branch.)

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
  • Loading branch information
semorrison and semorrison committed Apr 21, 2020
1 parent 7a13a11 commit 3edb6a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/category_theory/concrete_category/bundled.lean
Expand Up @@ -35,6 +35,8 @@ def of {c : Type u → Type v} (α : Type u) [str : c α] : bundled c := ⟨α,
instance : has_coe_to_sort (bundled c) :=
{ S := Type u, coe := bundled.α }

@[simp]
lemma coe_mk (α) (str) : (@bundled.mk c α str : Type u) = α := rfl

/-
`bundled.map` is reducible so that, if we define a category
Expand All @@ -47,7 +49,7 @@ a (semi)ring homomorphism from R.α to S.α, and not merely from
-/
/-- Map over the bundled structure -/
@[reducible] def map (f : Π {α}, c α → d α) (b : bundled c) : bundled d :=
⟨b, f b.str⟩
⟨b, f b.str⟩

end bundled

Expand Down
2 changes: 1 addition & 1 deletion src/category_theory/concrete_category/bundled_hom.lean
Expand Up @@ -50,7 +50,7 @@ This instance generates the type-class problem `bundled_hom ?m` (which is why th
`[nolint]`). Currently that is not a problem, as there are almost no instances of `bundled_hom`. -/
@[nolint dangerous_instance] instance category : category (bundled c) :=
by refine
{ hom := λ X Y, @hom X.1 Y.1 X.str Y.str,
{ hom := λ X Y, @hom X Y X.str Y.str,
id := λ X, @bundled_hom.id c hom 𝒞 X X.str,
comp := λ X Y Z f g, @bundled_hom.comp c hom 𝒞 X Y Z X.str Y.str Z.str g f,
comp_id' := _,
Expand Down

0 comments on commit 3edb6a4

Please sign in to comment.