Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add StateT Monad Transformer #952

Open
wants to merge 6 commits into
base: coq-8.16
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add StateT Monad Transformer
  • Loading branch information
JasonGross committed Apr 24, 2023
commit de0cc6b29b74c1f49976d9dd8456f1d620c13424
7 changes: 7 additions & 0 deletions utils/theories/monad_utils.v
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ Import MCMonadNotation.

Open Scope monad.

Definition StateT S M T := S -> M (T * S)%type.
Definition StateT_Monad {S T} {TM : Monad T} : Monad (StateT S T) :=
{| ret A a st := ret (a, st) ;
bind A B m f st := '(m, st) <- m st;; f m st
|}.
#[export] Hint Extern 1 (Monad (StateT ?S ?T)) => simple apply (@StateT_Monad S T) : typeclass_instances.

Section MapOpt.
Context {A} {B} (f : A -> option B).

Expand Down