Library MonadVM.Support.TransactionStateNotation

Notation for the generated transaction-state operations. let* threads the state through successive actions; read reads a lens; return produces a value without changing the state. All three expand directly to the existing operations, with no new implementation or assumptions.
Require Import MonadVM.State.

Declare Scope transaction_state_scope.
Delimit Scope transaction_state_scope with transaction_state.

Notation "'let*' x ':=' action 'in' next" :=
  (MonadVM.State.TransactionState.M.(MonadVM.Monad.State.State_result.op_letdollar)
    action (fun x ⇒ next))
  (at level 200, x ident, action at level 100, next at level 200)
  : transaction_state_scope.

Notation "'let*' ' p ':=' action 'in' next" :=
  (MonadVM.State.TransactionState.M.(MonadVM.Monad.State.State_result.op_letdollar)
    action (fun p ⇒ next))
  (at level 200, p pattern, action at level 100, next at level 200)
  : transaction_state_scope.

Notation "'read' lens" :=
  (MonadVM.State.TransactionState.M.(MonadVM.Monad.State.State_result.op_exclamation) lens)
  (at level 10, lens at level 9) : transaction_state_scope.

Notation "'return' value" :=
  (MonadVM.State.TransactionState.M.(MonadVM.Monad.State.State_result._return) value)
  (at level 10, value at level 9) : transaction_state_scope.