Skip to content
Snippets Groups Projects

Add `MThrow` and replace `MGuard`

Merged Thibaut Pérami requested to merge tperami/stdpp:mthrow into master
All threads resolved!

The MR is the result of !488 (closed) and !501 (closed).

This adds the MThrow E M type class expresses the fact that the monad M allow error of type E to be thrown and any point with signature mthrow : E → M A. There is an alias MFail := MThrow unit and mfail := mthrow () for monads that can fail without any error payload like option.

This then replaces mguard with guard : P → {Decision P} → M P using mfail. The original guard notation disappears. As such we've replaced guard P; mx with guard P;; mx in all lemmas. This MR further more replaces case_option_guard with a more general case_guard.

It also adds guard_or : E → P → {Decision P} → M P that throws an E instead of unit if P is false. Technically guard is just a notation for guard_or () like mfail and MFail.

These changes are very much breaking changes.

This is joint work with @adamAndMath.

Edited by Thibaut Pérami

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Thibaut Pérami changed the description

    changed the description

  • Robbert Krebbers
  • I really like this MR. I left some comments.

  • Thibaut Pérami added 47 commits

    added 47 commits

    Compare with previous version

  • Thibaut Pérami added 1 commit

    added 1 commit

    • be8b07a1 - Add elem_of_mfail and set_unfold_elem_of_mfail

    Compare with previous version

  • Thibaut Pérami added 6 commits

    added 6 commits

    • 3c515bc1 - Replace `MGuard` with `MFail`
    • 6033d66d - Add changelog entries for MFail
    • 880fbd0d - Add comment justifying use of bind in lemmas
    • 85515295 - Update comment
    • 8366ea79 - Update changelog for MThrow
    • c797eac6 - Add elem_of_mfail and set_unfold_elem_of_mfail

    Compare with previous version

  • Thibaut Pérami resolved all threads

    resolved all threads

  • Thibaut Pérami added 12 commits

    added 12 commits

    Compare with previous version

  • Thibaut Pérami added 2 commits

    added 2 commits

    • 2324921e - Update changelog for MThrow
    • bcde0cd0 - Add elem_of_mfail and set_unfold_elem_of_mfail

    Compare with previous version

  • Modulo small comments this looks good to me.

  • Thibaut Pérami added 2 commits

    added 2 commits

    • 7cb3cad0 - Update changelog for MThrow
    • 689d93f2 - Add elem_of_mfail and set_unfold_elem_of_mfail

    Compare with previous version

  • Ralf Jung
  • Thibaut Pérami added 2 commits

    added 2 commits

    • aa654072 - Update changelog for MThrow
    • 81d3831d - Add elem_of_mfail and set_unfold_elem_of_mfail

    Compare with previous version

  • Thibaut Pérami added 1 commit

    added 1 commit

    • 0cd59db8 - Add elem_of_mfail and set_unfold_elem_of_mfail

    Compare with previous version

  • Thibaut Pérami resolved all threads

    resolved all threads

  • Ralf Jung
  • Thibaut Pérami added 17 commits

    added 17 commits

    Compare with previous version

  • Thibaut Pérami resolved all threads

    resolved all threads

  • Going to merge. Thanks a lot @adamAndMath and @tperami !

  • @iris-users

    Add new typeclass MThrow E M to generally represent throwing an error of type E in monad M. (by Thibaut Pérami and Mathias Adam Møller) As a consequence:

    • Replace MGuard with MThrow and define guard in terms of MThrow.
    • The new guard is an ordinary function, while the old guard was a notation. Hence, use the monadic bind to compose guards. For example, write guard P;; m/p ← guard P; m instead of guard P; m/guard P as p; m.
    • Replace the tactic case_option_guard with a more general case_guard version.
  • Robbert Krebbers mentioned in commit 75a2c419

    mentioned in commit 75a2c419

  • Please register or sign in to reply
    Loading