Universe lifting for type families #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
Some functors such as option
and list
are universe polymorphic. Unlike
type polymorphism where option α
is a function application and reasoning and
generalizations that apply to functions can be used, option.{u}
and option.{v}
are not one function applied to two universe names but one polymorphic definition
instantiated twice. This means that whatever works on option.{u}
is hard
to transport over to option.{v}
. uliftable
is an attempt at improving the situation.
uliftable option.{u} option.{v}
gives us a generic and composable way to use
option.{u}
in a context that requires option.{v}
. It is often used in tandem with
ulift
but the two are purposefully decoupled.
Main definitions #
uliftable
class
Tags #
universe polymorphism functor
Given a universe polymorphic type family M.{u} : Type u₁ → Type u₂
, this class convert between instantiations, from
M.{u} : Type u₁ → Type u₂
to M.{v} : Type v₁ → Type v₂
and back
Instances of this typeclass
Instances of other typeclasses for uliftable
- uliftable.has_sizeof_inst
convenient shortcut to avoid manipulating ulift
Equations
- uliftable.adapt_up F G x f = uliftable.up x >>= f ∘ ulift.down
convenient shortcut to avoid manipulating ulift
Equations
- uliftable.adapt_down x f = uliftable.down (x >>= uliftable.up ∘ f)
map function that moves up universes
Equations
- uliftable.up_map f x = (f ∘ ulift.down) <$> uliftable.up x
for specific state types, this function helps to create a uliftable instance
Equations
- state_t.uliftable' F = {congr := λ (α : Type u₀) (β : Type u₁) (G : α ≃ β), state_t.equiv (F.Pi_congr (λ (_x : s), uliftable.congr m m' (G.prod_congr F)))}
for specific reader monads, this function helps to create a uliftable instance
Equations
- reader_t.uliftable' F = {congr := λ (α : Type u₀) (β : Type u₁) (G : α ≃ β), reader_t.equiv (F.Pi_congr (λ (_x : s), uliftable.congr m m' G))}
for specific continuation passing monads, this function helps to create a uliftable instance
Equations
- cont_t.uliftable' F = {congr := λ (α : Type u_1) (β : Type u_2), cont_t.equiv (uliftable.congr m m' F)}
for specific writer monads, this function helps to create a uliftable instance
Equations
- writer_t.uliftable' F = {congr := λ (α : Type u_3) (β : Type u_4) (G : α ≃ β), writer_t.equiv (uliftable.congr m m' (G.prod_congr F))}