- map_const : ∀ {α β : Type u}, Functor.mapConst = Functor.map ∘ Function.const β
Instances
- map_const : ∀ {α β : Type u}, Functor.mapConst = Functor.map ∘ Function.const β
- seqLeft_eq : ∀ {α β : Type u} (x : f α) (y : f β), (SeqLeft.seqLeft x fun x => y) = Seq.seq (Function.const β <$> x) fun x => y
- seqRight_eq : ∀ {α β : Type u} (x : f α) (y : f β), (SeqRight.seqRight x fun x => y) = Seq.seq (Function.const α id <$> x) fun x => y
Instances
@[simp]
theorem
pure_id_seq
{f : Type u_1 → Type u_2}
{α : Type u_1}
[Applicative f]
[LawfulApplicative f]
(x : f α)
:
- map_const : ∀ {α β : Type u}, Functor.mapConst = Functor.map ∘ Function.const β
- seqLeft_eq : ∀ {α β : Type u} (x : m α) (y : m β), (SeqLeft.seqLeft x fun x => y) = Seq.seq (Function.const β <$> x) fun x => y
- seqRight_eq : ∀ {α β : Type u} (x : m α) (y : m β), (SeqRight.seqRight x fun x => y) = Seq.seq (Function.const α id <$> x) fun x => y
Instances
@[simp]
theorem
bind_pure_unit
{m : Type u_1 → Type u_2}
[Monad m]
[LawfulMonad m]
{x : m PUnit}
:
(do
x
pure PUnit.unit) = x
theorem
seqRight_eq_bind
{m : Type u_1 → Type u_2}
{α : Type u_1}
{β : Type u_1}
[Monad m]
[LawfulMonad m]
(x : m α)
(y : m β)
:
(SeqRight.seqRight x fun x => y) = do
let _ ← x
y
theorem
seqLeft_eq_bind
{m : Type u_1 → Type u_2}
{α : Type u_1}
{β : Type u_1}
[Monad m]
[LawfulMonad m]
(x : m α)
(y : m β)
:
(SeqLeft.seqLeft x fun x => y) = do
let a ← x
let _ ← y
pure a
Id #
ExceptT #
theorem
ExceptT.ext
{m : Type u_1 → Type u_2}
{ε : Type u_1}
{α : Type u_1}
[Monad m]
{x : ExceptT ε m α}
{y : ExceptT ε m α}
(h : ExceptT.run x = ExceptT.run y)
:
x = y
@[simp]
theorem
ExceptT.run_lift
{m : Type u → Type v}
{α : Type u}
{ε : Type u}
[Monad m]
(x : m α)
:
ExceptT.run (ExceptT.lift x) = Except.ok <$> x
@[simp]
theorem
ExceptT.run_throw
{m : Type u_1 → Type u_2}
{ε : Type u_1}
{β : Type u_1}
{e : ε}
[Monad m]
:
ExceptT.run (throw e) = pure (Except.error e)
@[simp]
theorem
ExceptT.run_bind_lift
{m : Type u_1 → Type u_2}
{α : Type u_1}
{ε : Type u_1}
{β : Type u_1}
[Monad m]
[LawfulMonad m]
(x : m α)
(f : α → ExceptT ε m β)
:
ExceptT.run (ExceptT.lift x >>= f) = do
let a ← x
ExceptT.run (f a)
theorem
ExceptT.run_bind
{m : Type u_1 → Type u_2}
{ε : Type u_1}
{α : Type u_1}
{β : Type u_1}
{f : α → ExceptT ε m β}
[Monad m]
(x : ExceptT ε m α)
:
ExceptT.run (x >>= f) = do
let x ← ExceptT.run x
match x with
| Except.ok x => ExceptT.run (f x)
| Except.error e => pure (Except.error e)
@[simp]
theorem
ExceptT.lift_pure
{m : Type u_1 → Type u_2}
{α : Type u_1}
{ε : Type u_1}
[Monad m]
[LawfulMonad m]
(a : α)
:
ExceptT.lift (pure a) = pure a
@[simp]
theorem
ExceptT.run_map
{m : Type u_1 → Type u_2}
{α : Type u_1}
{β : Type u_1}
{ε : Type u_1}
[Monad m]
[LawfulMonad m]
(f : α → β)
(x : ExceptT ε m α)
:
ExceptT.run (f <$> x) = Except.map f <$> ExceptT.run x
theorem
ExceptT.seqLeft_eq
{α : Type u}
{β : Type u}
{ε : Type u}
{m : Type u → Type v}
[Monad m]
[LawfulMonad m]
(x : ExceptT ε m α)
(y : ExceptT ε m β)
:
(SeqLeft.seqLeft x fun x => y) = Seq.seq (Function.const β <$> x) fun x => y
theorem
ExceptT.seqRight_eq
{m : Type u_1 → Type u_2}
{ε : Type u_1}
{α : Type u_1}
{β : Type u_1}
[Monad m]
[LawfulMonad m]
(x : ExceptT ε m α)
(y : ExceptT ε m β)
:
(SeqRight.seqRight x fun x => y) = Seq.seq (Function.const α id <$> x) fun x => y
instance
ExceptT.instLawfulMonadExceptTInstMonadExceptT
{m : Type u_1 → Type u_2}
{ε : Type u_1}
[Monad m]
[LawfulMonad m]
:
LawfulMonad (ExceptT ε m)
ReaderT #
theorem
ReaderT.ext
{ρ : Type u_1}
{m : Type u_1 → Type u_2}
{α : Type u_1}
{x : ReaderT ρ m α}
{y : ReaderT ρ m α}
(h : ∀ (ctx : ρ), ReaderT.run x ctx = ReaderT.run y ctx)
:
x = y
@[simp]
theorem
ReaderT.run_bind
{m : Type u_1 → Type u_2}
{ρ : Type u_1}
{α : Type u_1}
{β : Type u_1}
[Monad m]
(x : ReaderT ρ m α)
(f : α → ReaderT ρ m β)
(ctx : ρ)
:
ReaderT.run (x >>= f) ctx = do
let a ← ReaderT.run x ctx
ReaderT.run (f a) ctx
@[simp]
theorem
ReaderT.run_mapConst
{m : Type u_1 → Type u_2}
{α : Type u_1}
{ρ : Type u_1}
{β : Type u_1}
[Monad m]
(a : α)
(x : ReaderT ρ m β)
(ctx : ρ)
:
ReaderT.run (Functor.mapConst a x) ctx = Functor.mapConst a (ReaderT.run x ctx)
@[simp]
theorem
ReaderT.run_map
{m : Type u_1 → Type u_2}
{α : Type u_1}
{β : Type u_1}
{ρ : Type u_1}
[Monad m]
(f : α → β)
(x : ReaderT ρ m α)
(ctx : ρ)
:
ReaderT.run (f <$> x) ctx = f <$> ReaderT.run x ctx
@[simp]
theorem
ReaderT.run_monadLift
{n : Type u_1 → Type u_2}
{m : Type u_1 → Type u_3}
{α : Type u_1}
{ρ : Type u_1}
[MonadLiftT n m]
(x : n α)
(ctx : ρ)
:
ReaderT.run (monadLift x) ctx = monadLift x
@[simp]
theorem
ReaderT.run_monadMap
{n : Type u → Type u_1}
{m : Type u → Type u_2}
{ρ : Type u}
{α : Type u}
[MonadFunctor n m]
(f : {β : Type u} → n β → n β)
(x : ReaderT ρ m α)
(ctx : ρ)
:
ReaderT.run (monadMap f x) ctx = monadMap f (ReaderT.run x ctx)
@[simp]
theorem
ReaderT.run_read
{m : Type u_1 → Type u_2}
{ρ : Type u_1}
[Monad m]
(ctx : ρ)
:
ReaderT.run ReaderT.read ctx = pure ctx
@[simp]
theorem
ReaderT.run_seq
{m : Type u → Type u_1}
{ρ : Type u}
{α : Type u}
{β : Type u}
[Monad m]
(f : ReaderT ρ m (α → β))
(x : ReaderT ρ m α)
(ctx : ρ)
:
ReaderT.run (Seq.seq f fun x => x) ctx = Seq.seq (ReaderT.run f ctx) fun x => ReaderT.run x ctx
@[simp]
theorem
ReaderT.run_seqRight
{m : Type u_1 → Type u_2}
{ρ : Type u_1}
{α : Type u_1}
{β : Type u_1}
[Monad m]
(x : ReaderT ρ m α)
(y : ReaderT ρ m β)
(ctx : ρ)
:
ReaderT.run (SeqRight.seqRight x fun x => y) ctx = SeqRight.seqRight (ReaderT.run x ctx) fun x => ReaderT.run y ctx
@[simp]
theorem
ReaderT.run_seqLeft
{m : Type u_1 → Type u_2}
{ρ : Type u_1}
{α : Type u_1}
{β : Type u_1}
[Monad m]
(x : ReaderT ρ m α)
(y : ReaderT ρ m β)
(ctx : ρ)
:
ReaderT.run (SeqLeft.seqLeft x fun x => y) ctx = SeqLeft.seqLeft (ReaderT.run x ctx) fun x => ReaderT.run y ctx
instance
ReaderT.instLawfulFunctorReaderTInstFunctorReaderT
{m : Type u_1 → Type u_2}
{ρ : Type u_1}
[Monad m]
[LawfulFunctor m]
:
LawfulFunctor (ReaderT ρ m)
instance
ReaderT.instLawfulApplicativeReaderTInstApplicativeReaderT
{m : Type u_1 → Type u_2}
{ρ : Type u_1}
[Monad m]
[LawfulApplicative m]
:
LawfulApplicative (ReaderT ρ m)
instance
ReaderT.instLawfulMonadReaderTInstMonadReaderT
{m : Type u_1 → Type u_2}
{ρ : Type u_1}
[Monad m]
[LawfulMonad m]
:
LawfulMonad (ReaderT ρ m)
StateRefT #
instance
instLawfulMonadStateRefT'InstMonadStateRefT'
{m : Type → Type}
{ω : Type}
{σ : Type}
[Monad m]
[LawfulMonad m]
:
LawfulMonad (StateRefT' ω σ m)
StateT #
theorem
StateT.ext
{σ : Type u_1}
{m : Type u_1 → Type u_2}
{α : Type u_1}
{x : StateT σ m α}
{y : StateT σ m α}
(h : ∀ (s : σ), StateT.run x s = StateT.run y s)
:
x = y
@[simp]
theorem
StateT.run'_eq
{m : Type u_1 → Type u_2}
{σ : Type u_1}
{α : Type u_1}
[Monad m]
(x : StateT σ m α)
(s : σ)
:
StateT.run' x s = (fun x => x.fst) <$> StateT.run x s
@[simp]
theorem
StateT.run_bind
{m : Type u_1 → Type u_2}
{σ : Type u_1}
{α : Type u_1}
{β : Type u_1}
[Monad m]
(x : StateT σ m α)
(f : α → StateT σ m β)
(s : σ)
:
StateT.run (x >>= f) s = do
let p ← StateT.run x s
StateT.run (f p.fst) p.snd
@[simp]
theorem
StateT.run_map
{m : Type u → Type u_1}
{α : Type u}
{β : Type u}
{σ : Type u}
[Monad m]
[LawfulMonad m]
(f : α → β)
(x : StateT σ m α)
(s : σ)
:
StateT.run (f <$> x) s = (fun p => (f p.fst, p.snd)) <$> StateT.run x s
@[simp]
theorem
StateT.run_get
{m : Type u_1 → Type u_2}
{σ : Type u_1}
[Monad m]
(s : σ)
:
StateT.run get s = pure (s, s)
@[simp]
theorem
StateT.run_set
{m : Type u_1 → Type u_2}
{σ : Type u_1}
[Monad m]
(s : σ)
(s' : σ)
:
StateT.run (set s') s = pure (PUnit.unit, s')
@[simp]
theorem
StateT.run_modify
{m : Type u_1 → Type u_2}
{σ : Type u_1}
[Monad m]
(f : σ → σ)
(s : σ)
:
StateT.run (modify f) s = pure (PUnit.unit, f s)
@[simp]
theorem
StateT.run_lift
{m : Type u → Type u_1}
{α : Type u}
{σ : Type u}
[Monad m]
(x : m α)
(s : σ)
:
StateT.run (StateT.lift x) s = do
let a ← x
pure (a, s)
@[simp]
theorem
StateT.run_bind_lift
{m : Type u → Type u_1}
{β : Type u}
{α : Type u}
{σ : Type u}
[Monad m]
[LawfulMonad m]
(x : m α)
(f : α → StateT σ m β)
(s : σ)
:
StateT.run (StateT.lift x >>= f) s = do
let a ← x
StateT.run (f a) s
@[simp]
theorem
StateT.run_monadLift
{m : Type u → Type u_1}
{n : Type u → Type u_2}
{α : Type u}
{σ : Type u}
[Monad m]
[MonadLiftT n m]
(x : n α)
(s : σ)
:
StateT.run (monadLift x) s = do
let a ← monadLift x
pure (a, s)
@[simp]
theorem
StateT.run_monadMap
{m : Type u → Type u_1}
{n : Type u → Type u_2}
{σ : Type u}
{α : Type u}
[Monad m]
[MonadFunctor n m]
(f : {β : Type u} → n β → n β)
(x : StateT σ m α)
(s : σ)
:
StateT.run (monadMap f x) s = monadMap f (StateT.run x s)
@[simp]
theorem
StateT.run_seq
{m : Type u → Type u_1}
{α : Type u}
{β : Type u}
{σ : Type u}
[Monad m]
[LawfulMonad m]
(f : StateT σ m (α → β))
(x : StateT σ m α)
(s : σ)
:
StateT.run (Seq.seq f fun x => x) s = do
let fs ← StateT.run f s
(fun p => (Prod.fst (α → β) σ fs p.fst, p.snd)) <$> StateT.run x fs.snd
@[simp]
theorem
StateT.run_seqRight
{m : Type u_1 → Type u_2}
{σ : Type u_1}
{α : Type u_1}
{β : Type u_1}
[Monad m]
[LawfulMonad m]
(x : StateT σ m α)
(y : StateT σ m β)
(s : σ)
:
StateT.run (SeqRight.seqRight x fun x => y) s = do
let p ← StateT.run x s
StateT.run y p.snd
@[simp]
theorem
StateT.run_seqLeft
{m : Type u → Type u_1}
{α : Type u}
{β : Type u}
{σ : Type u}
[Monad m]
[LawfulMonad m]
(x : StateT σ m α)
(y : StateT σ m β)
(s : σ)
:
StateT.run (SeqLeft.seqLeft x fun x => y) s = do
let p ← StateT.run x s
let p' ← StateT.run y p.snd
pure (p.fst, p'.snd)
theorem
StateT.seqRight_eq
{m : Type u_1 → Type u_2}
{σ : Type u_1}
{α : Type u_1}
{β : Type u_1}
[Monad m]
[LawfulMonad m]
(x : StateT σ m α)
(y : StateT σ m β)
:
(SeqRight.seqRight x fun x => y) = Seq.seq (Function.const α id <$> x) fun x => y
theorem
StateT.seqLeft_eq
{m : Type u_1 → Type u_2}
{σ : Type u_1}
{α : Type u_1}
{β : Type u_1}
[Monad m]
[LawfulMonad m]
(x : StateT σ m α)
(y : StateT σ m β)
:
(SeqLeft.seqLeft x fun x => y) = Seq.seq (Function.const β <$> x) fun x => y
instance
StateT.instLawfulMonadStateTInstMonadStateT
{m : Type u_1 → Type u_2}
{σ : Type u_1}
[Monad m]
[LawfulMonad m]
:
LawfulMonad (StateT σ m)