Documentation

Projects.Util.Monad

def sequence' {α : Type} {M : TypeType} [hM : Monad M] (ms : List (M α)) :
Equations
Instances For
    def replicateM {α : Type} {M : TypeType} [hM : Monad M] (n : ) (m : M α) :
    M (List α)
    Equations
    Instances For
      def replicateM' {α : Type} {M : TypeType} [hM : Monad M] (n : ) (m : M α) :
      Equations
      Instances For
        class MonadCnd {M : TypeType} [hM : Monad M] (p : {α : Type} → M αProp) :
        • pure {α : Type} {x : α} : p (Pure.pure x)
        • bind {α β : Type} {m : M α} {f : αM β} : p m(∀ (x : α), p (f x))p (m >>= f)
        Instances
          @[simp]
          theorem Id_pure {α : Type} :
          pure = fun (a : α) => a
          @[simp]
          theorem Id_bind {α β : Type} {m : Id α} {f : αId β} :
          m >>= f = f m
          @[inline]
          def gets {α : Type} {M : TypeType} [hM : Monad M] {σ : Type} [ : MonadState σ M] (f : σα) :
          M α
          Equations
          Instances For
            theorem run_run_snd {α β σ : Type} {m₁ : StateM σ α} {m₂ : StateM σ β} {x : σ} :
            StateT.run m₂ (StateT.run m₁ x).2 = StateT.run (do (fun (x : α) => ()) <$> m₁ m₂) x
            @[simp]
            theorem run_gets {α : Type} {M : TypeType} [hM : Monad M] {σ : Type} {f : σα} :
            (gets f).run = (do let xget pure (f x)).run
            @[simp]
            theorem run_set {M : TypeType} [hM : Monad M] {σ : Type} {s : σ} :
            (set s).run = fun (x : σ) => pure ((), s)
            @[simp]
            theorem run_set' {M : TypeType} [hM : Monad M] {σ : Type} {s : σ} :
            (StateT.set s).run = fun (x : σ) => pure ((), s)
            @[simp]
            theorem sequence_nil {α : Type} {M : TypeType} [hM : Monad M] :
            @[simp]
            theorem sequence_cons {α : Type} {M : TypeType} [hM : Monad M] [hM₂ : LawfulMonad M] {m : M α} {ms : List (M α)} :
            sequence (m :: ms) = do let xm let xssequence ms pure (x :: xs)
            @[simp]
            theorem sequence'_nil {α : Type} {M : TypeType} [hM : Monad M] [hM₂ : LawfulMonad M] :
            @[simp]
            theorem sequence'_cons {α : Type} {M : TypeType} [hM : Monad M] [hM₂ : LawfulMonad M] {m : M α} {ms : List (M α)} :
            sequence' (m :: ms) = do let _ ← m sequence' ms
            theorem MonadCnd.map {α β : Type} {M : TypeType} [hM : Monad M] [hM₂ : LawfulMonad M] {p : {α : Type} → M αProp} [H : MonadCnd p] {f : αβ} {m : M α} (h₁ : p m) :
            p (f <$> m)
            theorem MonadCnd.sequence {α : Type} {M : TypeType} [hM : Monad M] [hM₂ : LawfulMonad M] {p : {α : Type} → M αProp} [H : MonadCnd p] {ms : List (M α)} (h₁ : mms, p m) :
            theorem MonadCnd.sequence' {α : Type} {M : TypeType} [hM : Monad M] [hM₂ : LawfulMonad M] {p : {α : Type} → M αProp} [H : MonadCnd p] {ms : List (M α)} (h₁ : mms, p m) :
            theorem MonadCnd.replicateM {α : Type} {M : TypeType} [hM : Monad M] [hM₂ : LawfulMonad M] {p : {α : Type} → M αProp} [H : MonadCnd p] {m : M α} {n : } (h₁ : p m) :
            theorem MonadCnd.replicateM' {α : Type} {M : TypeType} [hM : Monad M] [hM₂ : LawfulMonad M] {p : {α : Type} → M αProp} [H : MonadCnd p] {m : M α} {n : } (h₁ : p m) :
            theorem List.mapM_eq_sequence {α β : Type} {M : TypeType} [hM : Monad M] [hM₂ : LawfulMonad M] {xs : List α} {f : αM β} :
            mapM f xs = sequence (map f xs)
            theorem List.forM_eq_sequence' {α : Type} {M : TypeType} [hM : Monad M] [hM₂ : LawfulMonad M] {xs : List α} {f : αM Unit} :
            xs.forM f = sequence' (map f xs)