Skip to content

Commit 165d746

Browse files
Tragicusqvermande
authored and
qvermande
committed
declare axioms_ as typeclass and typeclass option for HB.structure
1 parent e8e4f0c commit 165d746

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
`T` to `S.type` whenever `T` is not a global type (e.g. a variable). Note
1313
that `S.pack` can cast a `t : T` to `S.type` only if an instance of the
1414
class `S` on `t` is found by type class inference
15+
- **New** Attribute `#[typeclass]` to declare the class of a
16+
structure (`axioms_`) as a type class on the subject with all arguments in
17+
output mode but for the subject that is in input mode.
1518

1619
## [1.7.0] - 2024-01-10
1720

HB/common/utils-synterp.elpi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ with-attributes P :-
2424
att "primitive" bool,
2525
att "non_forgetful_inheritance" bool,
2626
att "hnf" bool,
27+
att "typeclass" bool,
2728
] Opts, !,
2829
Opts => (save-docstring, P).
2930

HB/structure.elpi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ declare Module BSkel Sort :- std.do! [
127127
])
128128
(coq.say "declare:" ClassName "should be an inductive", fail),
129129

130+
if (get-option "typeclass" tt) (
131+
coq.TC.declare-class ClassName,
132+
coq.hints.add-mode ClassName "typeclass_instances" {std.append {std.map {std.iota {w-params.nparams MLwP}} (_\ r\ r = mode-output)} [mode-input]})
133+
(true),
134+
130135
if-verbose (coq.say {header} "accumulating various props"),
131136
std.flatten [
132137
Factories, [ClassAlias], [is-structure Structure],

tests/coercion.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ HB.mixin Record isSigma (T : Type) (P : T -> Prop) (x : T) := {
55
_ : P x
66
}.
77

8-
#[short(type="sigType")]
8+
#[short(type="sigType"), typeclass]
99
HB.structure Definition Sig (T : Type) (P : T -> Prop) := {x of isSigma T P x}.
1010

1111
Section Sigma.
@@ -45,7 +45,7 @@ Fail Check x : sigType A P.
4545
End Sigma.
4646

4747
HB.mixin Record isSigmaT (P : Type -> Prop) (x : Type) := { _ : P x }.
48-
#[short(type="sigTType")]
48+
#[short(type="sigTType"), typeclass]
4949
HB.structure Definition SigT (P : Type -> Prop) := {x of isSigmaT P x}.
5050

5151
Section SigmaT.

0 commit comments

Comments
 (0)