Documentation

Std.WP.EStack

Exception Postcondition Stack Notation #

A monad transformer stack carries one exception postcondition for each transformer that throws. A stack of postconditions is a right-nested × chain with the marker type EStackEnd as its last component. EStack⟨Nat → σ → Prop, String → σ → Prop⟩ is the stack of ExceptT Nat (ExceptT String (StateM σ)), and estack⟨e₁, e₂⟩ is a value of it. The notation hides the nesting and the markers. EStackEnd and EStackEnd.mk are abbreviations of Unit and (), so the unexpanders can recognize a stack while every Unit instance still applies.

A base monad has one exception postcondition and no stack, so it does not use the notation: Except ε carries a bare ε → Prop.

Any other type of exception postconditions can declare a ToEStack instance, and vcgen then weakens its values one stack component at a time.

@[reducible, inline]

The last component of an exception postcondition stack. It reduces to Unit, so every Unit instance applies. It is a named constant, so only a stack prints as EStack⟨…⟩.

Instances For
    @[reducible, inline]

    The value of the last stack component. It reduces to (). It is a named constant, so only a stack value prints as estack⟨…⟩.

    Instances For

      Exception postcondition stack type: EStack⟨ε₁ → l, ε₂ → l⟩ is (ε₁ → l) × (ε₂ → l) × EStack⟨⟩.

      Instances For

        Exception postcondition stack value: estack⟨e₁, e₂⟩ is (e₁, e₂, ()).

        Instances For

          Prints a product that ends in EStack⟨⟩ as EStack⟨e₁, e₂, …⟩.

          Instances For

            Prints a tuple that ends in estack⟨⟩ as estack⟨e₁, e₂, …⟩.

            Instances For

              ⊥ at the end of an exception postcondition stack is the empty stack value.

              class Std.WP.ToEStack (E : Type u) (T : outParam (Type u)) [Assertion E] [Assertion T] :

              toEStack exposes the exception postconditions E as a stack. Example: Thrown with the field onThrow : String → Prop has toEStack t = estack⟨t.onThrow⟩, and vcgen weakens onThrow.

              Instances