Skip to content

Commit 4c3ad63

Browse files
author
Gregory Malecha
committed
a bit more polymorphism.
1 parent 87f6e9d commit 4c3ad63

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

theories/Core/Any.v

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ Set Implicit Arguments.
22
Set Strict Implicit.
33

44
(** This class should be used when no requirements are needed **)
5-
Class Any (T : Type) : Type.
5+
Polymorphic Class Any (T : Type) : Type.
66

7-
Global Instance Any_a (T : Type) : Any T.
7+
Global Polymorphic Instance Any_a (T : Type) : Any T.
88

9-
10-
Definition RESOLVE (T : Type) : Type := T.
9+
Polymorphic Definition RESOLVE (T : Type) : Type := T.
1110

1211
Existing Class RESOLVE.
1312

theories/Structures/Functor.v

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,25 @@ Require Import ExtLib.Core.Any.
33
Set Implicit Arguments.
44
Set Strict Implicit.
55

6-
Section functor.
7-
Variable F : Type -> Type.
6+
Polymorphic Class Functor (F : Type@{d} -> Type) : Type :=
7+
{ fmap : forall {A B : Type@{d}}, (A -> B) -> F A -> F B }.
88

9-
Class Functor : Type :=
10-
{ fmap : forall A B, (A -> B) -> F A -> F B }.
9+
Polymorphic Definition ID {T : Type@{d}} (f : T -> T) : Prop :=
10+
forall x, f x = x.
1111

12-
Definition ID {T : Type} (f : T -> T) : Prop :=
13-
forall x, f x = x.
12+
Polymorphic Class PFunctor (F : Type@{d} -> Type) : Type :=
13+
{ FunP : Type@{d} -> Type
14+
; pfmap : forall {A B : Type@{d}} {P : FunP B}, (A -> B) -> F A -> F B
15+
}.
1416

15-
Class PFunctor : Type :=
16-
{ FunP : Type -> Type
17-
; pfmap : forall {A B} {P : FunP B}, (A -> B) -> F A -> F B
18-
}.
17+
Existing Class FunP.
18+
Hint Extern 0 (@FunP _ _ _) => progress (simpl FunP) : typeclass_instances.
1919

20-
Existing Class FunP.
21-
Hint Extern 0 (@FunP _ _ _) => progress (simpl FunP) : typeclass_instances.
22-
23-
Global Instance PFunctor_From_Functor (F : Functor) : PFunctor :=
24-
{ FunP := Any
25-
; pfmap := fun _ _ _ f x => fmap f x
26-
}.
27-
End functor.
20+
Global Polymorphic Instance PFunctor_From_Functor
21+
(F : Type@{d} -> Type) (FunF : Functor F) : PFunctor F :=
22+
{ FunP := Any
23+
; pfmap := fun _ _ _ f x => fmap f x
24+
}.
2825

2926
Module FunctorNotation.
3027
Notation "f <$> x" := (@pfmap _ _ _ _ _ f x) (at level 51, right associativity).

0 commit comments

Comments
 (0)