Documentation

Batteries.Control.Lawful.MonadLift

Lawful version of MonadLift #

This file defines the LawfulMonadLift(T) class, which adds laws to the MonadLift(T) class.

class LawfulMonadLift (m : semiOutParam (Type u → Type v)) (n : Type u → Type w) [Monad m] [Monad n] [inst : MonadLift m n] :

The MonadLift typeclass only contains the lifting operation. LawfulMonadLift further asserts that lifting commutes with pure and bind:

monadLift (pure a) = pure a
monadLift (ma >>= f) = monadLift ma >>= monadLift ∘ f
Instances
    class LawfulMonadLiftT (m : Type u → Type v) (n : Type u → Type w) [Monad m] [Monad n] [inst : MonadLiftT m n] :

    The MonadLiftT typeclass only contains the transitive lifting operation. LawfulMonadLiftT further asserts that lifting commutes with pure and bind:

    monadLift (pure a) = pure a
    monadLift (ma >>= f) = monadLift ma >>= monadLift ∘ f
    
    Instances
      theorem monadLift_map {m : Type u_1 → Type u_2} {n : Type u_1 → Type u_3} [Monad m] [Monad n] [MonadLiftT m n] [LawfulMonadLiftT m n] {α β : Type u_1} [LawfulMonad m] [LawfulMonad n] (f : αβ) (ma : m α) :
      theorem monadLift_seq {m : Type u_1 → Type u_2} {n : Type u_1 → Type u_3} [Monad m] [Monad n] [MonadLiftT m n] [LawfulMonadLiftT m n] {α β : Type u_1} [LawfulMonad m] [LawfulMonad n] (mf : m (αβ)) (ma : m α) :
      monadLift (mf <*> ma) = monadLift mf <*> monadLift ma
      theorem monadLift_seqLeft {m : Type u_1 → Type u_2} {n : Type u_1 → Type u_3} [Monad m] [Monad n] [MonadLiftT m n] [LawfulMonadLiftT m n] {α β : Type u_1} [LawfulMonad m] [LawfulMonad n] (x : m α) (y : m β) :
      monadLift (x <* y) = monadLift x <* monadLift y
      theorem monadLift_seqRight {m : Type u_1 → Type u_2} {n : Type u_1 → Type u_3} [Monad m] [Monad n] [MonadLiftT m n] [LawfulMonadLiftT m n] {α β : Type u_1} [LawfulMonad m] [LawfulMonad n] (x : m α) (y : m β) :
      monadLift (x *> y) = monadLift x *> monadLift y

      We duplicate the theorems for monadLift to liftM since rw matches on syntax only.

      @[simp]
      theorem liftM_pure {m : Type u_1 → Type u_3} {n : Type u_1 → Type u_2} [Monad m] [Monad n] [MonadLiftT m n] [LawfulMonadLiftT m n] {α : Type u_1} (a : α) :
      @[simp]
      theorem liftM_bind {m : Type u_1 → Type u_3} {n : Type u_1 → Type u_2} [Monad m] [Monad n] [MonadLiftT m n] [LawfulMonadLiftT m n] {α β : Type u_1} (ma : m α) (f : αm β) :
      liftM (ma >>= f) = do let aliftM ma liftM (f a)
      @[simp]
      theorem liftM_map {m : Type u_1 → Type u_2} {n : Type u_1 → Type u_3} [Monad m] [Monad n] [MonadLiftT m n] [LawfulMonadLiftT m n] {α β : Type u_1} [LawfulMonad m] [LawfulMonad n] (f : αβ) (ma : m α) :
      liftM (f <$> ma) = f <$> liftM ma
      @[simp]
      theorem liftM_seq {m : Type u_1 → Type u_2} {n : Type u_1 → Type u_3} [Monad m] [Monad n] [MonadLiftT m n] [LawfulMonadLiftT m n] {α β : Type u_1} [LawfulMonad m] [LawfulMonad n] (mf : m (αβ)) (ma : m α) :
      liftM (mf <*> ma) = liftM mf <*> liftM ma
      @[simp]
      theorem liftM_seqLeft {m : Type u_1 → Type u_2} {n : Type u_1 → Type u_3} [Monad m] [Monad n] [MonadLiftT m n] [LawfulMonadLiftT m n] {α β : Type u_1} [LawfulMonad m] [LawfulMonad n] (x : m α) (y : m β) :
      liftM (x <* y) = liftM x <* liftM y
      @[simp]
      theorem liftM_seqRight {m : Type u_1 → Type u_2} {n : Type u_1 → Type u_3} [Monad m] [Monad n] [MonadLiftT m n] [LawfulMonadLiftT m n] {α β : Type u_1} [LawfulMonad m] [LawfulMonad n] (x : m α) (y : m β) :
      liftM (x *> y) = liftM x *> liftM y
      instance instLawfulMonadLiftTOfLawfulMonadLift (m : Type u_1 → Type u_2) (n : Type u_1 → Type u_3) (o : Type u_1 → Type u_4) [Monad m] [Monad n] [Monad o] [MonadLift n o] [MonadLiftT m n] [LawfulMonadLift n o] [LawfulMonadLiftT m n] :
      instance instLawfulMonadLiftT (m : Type u_1 → Type u_2) [Monad m] :
      instance StateT.instLawfulMonadLift {m : Type u_1 → Type u_2} [Monad m] [LawfulMonad m] {σ : Type u_1} :
      instance ReaderT.instLawfulMonadLift {m : Type u_1 → Type u_2} [Monad m] {ρ : Type u_1} :
      @[simp]
      theorem OptionT.lift_pure {m : Type u_1 → Type u_2} [Monad m] [LawfulMonad m] {α : Type u_1} (a : α) :
      @[simp]
      theorem OptionT.lift_bind {m : Type u_1 → Type u_2} [Monad m] [LawfulMonad m] {α β : Type u_1} (ma : m α) (f : αm β) :
      OptionT.lift (ma >>= f) = do let aOptionT.lift ma OptionT.lift (f a)
      @[simp]
      theorem ExceptT.lift_bind {m : Type u_1 → Type u_2} [Monad m] [LawfulMonad m] {α β ε : Type u_1} (ma : m α) (f : αm β) :
      ExceptT.lift (ma >>= f) = do let aExceptT.lift ma ExceptT.lift (f a)
      instance ExceptT.instLawfulMonadLift {m : Type u_1 → Type u_2} [Monad m] [LawfulMonad m] {ε : Type u_1} :
      instance ExceptT.instLawfulMonadLiftExcept {m : Type u_1 → Type u_2} [Monad m] [LawfulMonad m] {ε : Type u_1} :
      instance StateRefT'.instLawfulMonadLift {m : TypeType} {ω σ : Type} [Monad m] :
      instance Id.instMonadLiftOfPure_batteries {m : Type u_1 → Type u_2} [Pure m] :

      The pure operation of a monad m can be seen as a lifting operation from Id to m.

      Equations

      The lifting from Id to a lawful monad m induced by pure is lawful.