Skip to content

Commit

Permalink
feat(Control/ULiftable): instances for Except and Option (#6350)
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-wieser committed Sep 15, 2023
1 parent b0e5bef commit 5d8bd22
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Mathlib/Control/ULiftable.lean
Expand Up @@ -48,6 +48,9 @@ class ULiftable (f : Type u₀ → Type u₁) (g : Type v₀ → Type v₁) wher

namespace ULiftable

instance symm (f : Type u₀ → Type u₁) (g : Type v₀ → Type v₁) [ULiftable f g] : ULiftable g f where
congr e := (ULiftable.congr e.symm).symm

/-- The most common practical use `ULiftable` (together with `down`), this function takes
`x : M.{u} α` and lifts it to `M.{max u v} (ULift.{v} α)` -/
@[reducible]
Expand Down Expand Up @@ -160,3 +163,17 @@ instance {m m'} [ULiftable m m'] : ULiftable (WriterT s m) (WriterT (ULift s) m'
instance WriterT.instULiftableULiftULift {m m'} [ULiftable m m'] :
ULiftable (WriterT (ULift.{max v₀ u₀} s) m) (WriterT (ULift.{max v₁ u₀} s) m') :=
WriterT.uliftable' <| Equiv.ulift.trans Equiv.ulift.symm

instance Except.instULiftable {ε : Type u₀} : ULiftable (Except.{u₀,v₁} ε) (Except.{u₀,v₂} ε) where
congr e :=
{ toFun := Except.map e
invFun := Except.map e.symm
left_inv := fun f => by cases f <;> simp [Except.map]
right_inv := fun f => by cases f <;> simp [Except.map] }

instance Option.instULiftable : ULiftable Option.{u₀} Option.{u₁} where
congr e :=
{ toFun := Option.map e
invFun := Option.map e.symm
left_inv := fun f => by cases f <;> simp
right_inv := fun f => by cases f <;> simp }

0 comments on commit 5d8bd22

Please sign in to comment.