File: MonadPlus.v

package info (click to toggle)
coq-ext-lib 0.13.0-3
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 808 kB
  • sloc: makefile: 44; python: 31; sh: 4; lisp: 3
file content (16 lines) | stat: -rw-r--r-- 498 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Require Import ExtLib.Structures.Monad.

Set Implicit Arguments.

Class MonadPlus (m : Type -> Type) : Type :=
{ mplus : forall {A B:Type}, m A -> m B -> m (A + B)%type }.

Definition mjoin {m : Type -> Type} {M : Monad m} {MP : MonadPlus m} {T} (a b : m T) : m T :=
  bind (mplus a b) (fun x =>
    match x with
      | inl x | inr x => ret x
    end).

Module MonadPlusNotation.
  Notation "x <+> y" := (@mplus _ _ _ _ x y) (at level 54, left associativity) : monad_scope.
End MonadPlusNotation.