Skip to content

Commit d47e472

Browse files
LysxiaYishuai Li
authored andcommitted
Add Hint Mode to Functor, Applicative, Monad
1 parent 961c802 commit d47e472

File tree

7 files changed

+15
-9
lines changed

7 files changed

+15
-9
lines changed

theories/Data/Monads/EitherMonad.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Section except.
7070
}.
7171

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

7575
Global Instance MonadState_eitherT {T} (MS : MonadState T m) : MonadState T eitherT :=
7676
{ get := lift get

theories/Data/Monads/OptionMonad.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Section Trans.
5454
{ mzero _A := mkOptionT (ret None) }.
5555

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

5959
Global Instance State_optionT {T} (SM : MonadState T m) : MonadState T optionT :=
6060
{ get := lift get

theories/Structures/Applicative.v

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Class Applicative@{d c} (T : Type@{d} -> Type@{c}) :=
1010
; ap : forall {A B : Type@{d}}, T (A -> B) -> T A -> T B
1111
}.
1212

13+
Global Hint Mode Applicative ! : typeclass_instances.
14+
1315
Module ApplicativeNotation.
1416
Notation "f <*> x" := (ap f x) (at level 52, left associativity).
1517
End ApplicativeNotation.

theories/Structures/Functor.v

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Set Strict Implicit.
66
Polymorphic Class Functor@{d c} (F : Type@{d} -> Type@{c}) : Type :=
77
{ fmap : forall {A B : Type@{d}}, (A -> B) -> F A -> F B }.
88

9+
Global Hint Mode Functor ! : typeclass_instances.
10+
911
Polymorphic Definition ID@{d} {T : Type@{d}} (f : T -> T) : Prop :=
1012
forall x : T, f x = x.
1113

theories/Structures/Monad.v

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Class Monad@{d c} (m : Type@{d} -> Type@{c}) : Type :=
1010
; bind : forall {t u : Type@{d}}, m t -> (t -> m u) -> m u
1111
}.
1212

13+
Global Hint Mode Monad ! : typeclass_instances.
14+
1315
Section monadic.
1416

1517
Definition liftM@{d c}

theories/Structures/MonadLaws.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ Section MonadLaws.
4040
Context {S : Type}.
4141

4242
Class MonadStateLaws (MS : MonadState S m) : Type :=
43-
{ get_put : bind get put = ret tt
43+
{ get_put : bind get put = ret tt :> m unit
4444
; put_get : forall x : S,
45-
bind (put x) (fun _ => get) = bind (put x) (fun _ => ret x)
45+
bind (put x) (fun _ => get) = bind (put x) (fun _ => ret x) :> m S
4646
; put_put : forall {A} (x y : S) (f : unit -> m A),
4747
bind (put x) (fun _ => bind (put y) f) = bind (put y) f
4848
; get_get : forall {A} (f : S -> S -> m A),

theories/Structures/Traversable.v

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ Polymorphic Class Traversable@{d r} (T : Type@{d} -> Type@{r}) : Type :=
1010
}.
1111

1212
Polymorphic Definition sequence@{d r}
13-
{T : Type@{d} -> Type@{d}}
13+
{T : Type@{d} -> Type@{r}}
1414
{Tr:Traversable T}
15-
{F : Type@{d} -> Type@{d}} {Ap:Applicative F} {A : Type@{d}}
16-
: T (F A) -> F (T A) := mapT (@id _).
15+
{F : Type@{d} -> Type@{r}} {Ap:Applicative F} {A : Type@{d}}
16+
: T (F A) -> F (T A) := mapT (@id (F A)).
1717

1818
Polymorphic Definition forT@{d r}
19-
{T : Type@{d} -> Type@{d}}
20-
{Tr:Traversable T} {F : Type@{d} -> Type@{d}} {Ap:Applicative F}
19+
{T : Type@{d} -> Type@{r}}
20+
{Tr:Traversable T} {F : Type@{d} -> Type@{r}} {Ap:Applicative F}
2121
{A B : Type@{d}} (aT:T A) (f:A -> F B) : F (T B)
2222
:= mapT f aT.

0 commit comments

Comments
 (0)