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 Hint Mode to Functor, Applicative, Monad #126

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion theories/Data/Monads/EitherMonad.v
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Section except.
}.

Global Instance MonadT_eitherT : MonadT eitherT m :=
{ lift := fun _ c => mkEitherT (liftM ret c) }.
{ lift := fun _ c => mkEitherT (liftM inr c) }.

Global Instance MonadState_eitherT {T} (MS : MonadState T m) : MonadState T eitherT :=
{ get := lift get
Expand Down
2 changes: 1 addition & 1 deletion theories/Data/Monads/OptionMonad.v
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Section Trans.
{ mzero _A := mkOptionT (ret None) }.

Global Instance MonadT_optionT : MonadT optionT m :=
{ lift _A aM := mkOptionT (liftM ret aM) }.
{ lift _A aM := mkOptionT (liftM Some aM) }.

Global Instance State_optionT {T} (SM : MonadState T m) : MonadState T optionT :=
{ get := lift get
Expand Down
2 changes: 2 additions & 0 deletions theories/Structures/Applicative.v
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Class Applicative@{d c} (T : Type@{d} -> Type@{c}) :=
; ap : forall {A B : Type@{d}}, T (A -> B) -> T A -> T B
}.

Global Hint Mode Applicative ! : typeclass_instances.

Module ApplicativeNotation.
Notation "f <*> x" := (ap f x) (at level 52, left associativity).
End ApplicativeNotation.
Expand Down
2 changes: 2 additions & 0 deletions theories/Structures/Functor.v
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Set Strict Implicit.
Polymorphic Class Functor@{d c} (F : Type@{d} -> Type@{c}) : Type :=
{ fmap : forall {A B : Type@{d}}, (A -> B) -> F A -> F B }.

Global Hint Mode Functor ! : typeclass_instances.

Polymorphic Definition ID@{d} {T : Type@{d}} (f : T -> T) : Prop :=
forall x : T, f x = x.

Expand Down
2 changes: 2 additions & 0 deletions theories/Structures/Monad.v
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
; bind : forall {t u : Type@{d}}, m t -> (t -> m u) -> m u
}.

Global Hint Mode Monad ! : typeclass_instances.

Section monadic.

Definition liftM@{d c}
Expand Down Expand Up @@ -53,7 +55,7 @@

Module MonadBaseNotation.

Delimit Scope monad_scope with monad.

Check warning on line 58 in theories/Structures/Monad.v

View workflow job for this annotation

GitHub Actions / build (coqorg/coq:8.11)

Declaring a scope implicitly is deprecated; use in advance an

Check warning on line 58 in theories/Structures/Monad.v

View workflow job for this annotation

GitHub Actions / build (coqorg/coq:8.12)

Declaring a scope implicitly is deprecated; use in advance an

Check warning on line 58 in theories/Structures/Monad.v

View workflow job for this annotation

GitHub Actions / build (coqorg/coq:8.16)

Declaring a scope implicitly is deprecated; use in advance an

Check warning on line 58 in theories/Structures/Monad.v

View workflow job for this annotation

GitHub Actions / build (coqorg/coq:8.13)

Declaring a scope implicitly is deprecated; use in advance an

Check warning on line 58 in theories/Structures/Monad.v

View workflow job for this annotation

GitHub Actions / build (coqorg/coq:8.14)

Declaring a scope implicitly is deprecated; use in advance an

Check warning on line 58 in theories/Structures/Monad.v

View workflow job for this annotation

GitHub Actions / build (coqorg/coq:8.15)

Declaring a scope implicitly is deprecated; use in advance an

Check warning on line 58 in theories/Structures/Monad.v

View workflow job for this annotation

GitHub Actions / build (coqorg/coq:8.18)

Declaring a scope implicitly is deprecated; use in advance an

Check warning on line 58 in theories/Structures/Monad.v

View workflow job for this annotation

GitHub Actions / build (coqorg/coq:dev)

Declaring a scope implicitly is deprecated; use in advance an

Check warning on line 58 in theories/Structures/Monad.v

View workflow job for this annotation

GitHub Actions / build (coqorg/coq:8.17)

Declaring a scope implicitly is deprecated; use in advance an

Check warning on line 58 in theories/Structures/Monad.v

View workflow job for this annotation

GitHub Actions / build (coqorg/coq:8.11)

Declaring a scope implicitly is deprecated; use in advance an

Check warning on line 58 in theories/Structures/Monad.v

View workflow job for this annotation

GitHub Actions / build (coqorg/coq:8.12)

Declaring a scope implicitly is deprecated; use in advance an

Check warning on line 58 in theories/Structures/Monad.v

View workflow job for this annotation

GitHub Actions / build (coqorg/coq:8.18)

Declaring a scope implicitly is deprecated; use in advance an

Check warning on line 58 in theories/Structures/Monad.v

View workflow job for this annotation

GitHub Actions / build (coqorg/coq:8.17)

Declaring a scope implicitly is deprecated; use in advance an

Check warning on line 58 in theories/Structures/Monad.v

View workflow job for this annotation

GitHub Actions / build (coqorg/coq:8.16)

Declaring a scope implicitly is deprecated; use in advance an

Check warning on line 58 in theories/Structures/Monad.v

View workflow job for this annotation

GitHub Actions / build (coqorg/coq:8.13)

Declaring a scope implicitly is deprecated; use in advance an

Check warning on line 58 in theories/Structures/Monad.v

View workflow job for this annotation

GitHub Actions / build (coqorg/coq:8.15)

Declaring a scope implicitly is deprecated; use in advance an

Check warning on line 58 in theories/Structures/Monad.v

View workflow job for this annotation

GitHub Actions / build (coqorg/coq:dev)

Declaring a scope implicitly is deprecated; use in advance an

Check warning on line 58 in theories/Structures/Monad.v

View workflow job for this annotation

GitHub Actions / build (coqorg/coq:8.14)

Declaring a scope implicitly is deprecated; use in advance an

Notation "c >>= f" := (@bind _ _ _ _ c f) (at level 58, left associativity) : monad_scope.
Notation "f =<< c" := (@bind _ _ _ _ c f) (at level 61, right associativity) : monad_scope.
Expand Down
4 changes: 2 additions & 2 deletions theories/Structures/MonadLaws.v
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ Section MonadLaws.
Context {S : Type}.

Class MonadStateLaws (MS : MonadState S m) : Type :=
{ get_put : bind get put = ret tt
{ get_put : bind get put = ret tt :> m unit
; put_get : forall x : S,
bind (put x) (fun _ => get) = bind (put x) (fun _ => ret x)
bind (put x) (fun _ => get) = bind (put x) (fun _ => ret x) :> m S
; put_put : forall {A} (x y : S) (f : unit -> m A),
bind (put x) (fun _ => bind (put y) f) = bind (put y) f
; get_get : forall {A} (f : S -> S -> m A),
Expand Down
10 changes: 5 additions & 5 deletions theories/Structures/Traversable.v
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ Polymorphic Class Traversable@{d r} (T : Type@{d} -> Type@{r}) : Type :=
}.

Polymorphic Definition sequence@{d r}
{T : Type@{d} -> Type@{d}}
{T : Type@{d} -> Type@{r}}
{Tr:Traversable T}
{F : Type@{d} -> Type@{d}} {Ap:Applicative F} {A : Type@{d}}
: T (F A) -> F (T A) := mapT (@id _).
{F : Type@{d} -> Type@{r}} {Ap:Applicative F} {A : Type@{d}}
: T (F A) -> F (T A) := mapT (@id (F A)).

Polymorphic Definition forT@{d r}
{T : Type@{d} -> Type@{d}}
{Tr:Traversable T} {F : Type@{d} -> Type@{d}} {Ap:Applicative F}
{T : Type@{d} -> Type@{r}}
{Tr:Traversable T} {F : Type@{d} -> Type@{r}} {Ap:Applicative F}
{A B : Type@{d}} (aT:T A) (f:A -> F B) : F (T B)
:= mapT f aT.
Loading