Skip to content

Commit

Permalink
Move Data.Monads.ListMonad to Data.List
Browse files Browse the repository at this point in the history
  • Loading branch information
liyishuai committed Jan 12, 2022
1 parent ca0795c commit 027479b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
1 change: 0 additions & 1 deletion _CoqProject
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ theories/Data/Monads/FuelMonadLaws.v
theories/Data/Monads/FuelMonad.v
theories/Data/Monads/IdentityMonadLaws.v
theories/Data/Monads/IdentityMonad.v
theories/Data/Monads/ListMonad.v
theories/Data/Monads/OptionMonadLaws.v
theories/Data/Monads/OptionMonad.v
theories/Data/Monads/ReaderMonadLaws.v
Expand Down
16 changes: 11 additions & 5 deletions theories/Data/List.v
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Global Instance Foldable_list@{u} {T : Type@{u}} : Foldable (list T) T :=

Require Import ExtLib.Structures.Traversable.
Require Import ExtLib.Structures.Functor.
Require Import ExtLib.Structures.Monad.
Require Import ExtLib.Structures.Monads.
Require Import ExtLib.Structures.Applicative.

Section traversable.
Expand All @@ -120,10 +120,16 @@ Global Instance Traversable_list@{} : Traversable list :=

Monomorphic Universe listU.

Global Instance Monad_list@{} : Monad@{listU listU} list :=
{ ret := fun _ x => x :: nil
; bind := fun _ _ x f =>
List.fold_right (fun x acc => f x ++ acc) nil x
Global Instance Monad_list : Monad list :=
{ ret := fun _ v => v :: nil
; bind := fun _ _ l f => flat_map f l
}.

Global Instance MonadZero_list : MonadZero list :=
{ mzero := @nil }.

Global Instance MonadPlus_list : MonadPlus list :=
{ mplus _A _B a b := List.map inl a ++ List.map inr b
}.

Section list.
Expand Down
17 changes: 0 additions & 17 deletions theories/Data/Monads/ListMonad.v

This file was deleted.

0 comments on commit 027479b

Please sign in to comment.