Universe lifting for type families #
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
Equations
- ULiftable.symm f g = { congr := fun {α} {β} 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} α)
Equations
- ULiftable.up = (ULiftable.congr Equiv.ulift.symm).toFun
Instances For
The most common practical use of ULiftable
(together with up
), this function takes
x : M.{max u v} (ULift.{v} α)
and lowers it to M.{u} α
Equations
- ULiftable.down = (ULiftable.congr Equiv.ulift.symm).invFun
Instances For
convenient shortcut to avoid manipulating ULift
Equations
- ULiftable.adaptUp F G x f = ULiftable.up x >>= f ∘ ULift.down
Instances For
convenient shortcut to avoid manipulating ULift
Equations
- ULiftable.adaptDown x f = ULiftable.down (x >>= ULiftable.up ∘ f)
Instances For
map function that moves up universes
Equations
- ULiftable.upMap f x = (f ∘ ULift.down) <$> ULiftable.up x
Instances For
map function that moves down universes
Equations
- ULiftable.downMap f x = ULiftable.down ((ULift.up ∘ f) <$> x)
Instances For
Equations
- instULiftableId = { congr := fun {α} {β} F => F }
for specific state types, this function helps to create a uliftable instance
Equations
- StateT.uliftable' F = { congr := fun {α} {β} G => StateT.equiv (Equiv.piCongr F fun x => ULiftable.congr (Equiv.prodCongr G F)) }
Instances For
Equations
- instULiftableStateTStateTULift = StateT.uliftable' Equiv.ulift.symm
Equations
- StateT.instULiftableULiftULift = StateT.uliftable' (Equiv.ulift.trans Equiv.ulift.symm)
for specific reader monads, this function helps to create a uliftable instance
Equations
- ReaderT.uliftable' F = { congr := fun {α} {β} G => ReaderT.equiv (Equiv.piCongr F fun x => ULiftable.congr G) }
Instances For
Equations
- instULiftableReaderTReaderTULift = ReaderT.uliftable' Equiv.ulift.symm
Equations
- ReaderT.instULiftableULiftULift = ReaderT.uliftable' (Equiv.ulift.trans Equiv.ulift.symm)
for specific continuation passing monads, this function helps to create a uliftable instance
Equations
- ContT.uliftable' F = { congr := fun {α} {β} => ContT.equiv (ULiftable.congr F) }
Instances For
Equations
- instULiftableContTContTULift = ContT.uliftable' Equiv.ulift.symm
Equations
- ContT.instULiftableULiftULift = ContT.uliftable' (Equiv.ulift.trans Equiv.ulift.symm)
for specific writer monads, this function helps to create a uliftable instance
Equations
- WriterT.uliftable' F = { congr := fun {α} {β} G => WriterT.equiv (ULiftable.congr (Equiv.prodCongr G F)) }
Instances For
Equations
- instULiftableWriterTWriterTULift = WriterT.uliftable' Equiv.ulift.symm
Equations
- WriterT.instULiftableULiftULift = WriterT.uliftable' (Equiv.ulift.trans Equiv.ulift.symm)
Equations
- One or more equations did not get rendered due to their size.