Skip to content

Commit d80dc70

Browse files
committed
Tactic.Derive.DecEq: faster variant
1 parent cfac11f commit d80dc70

File tree

13 files changed

+475
-41
lines changed

13 files changed

+475
-41
lines changed

Meta/Init.agda

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ module Meta.Init where
55
open import Reflection.Debug public
66
open import Reflection.TCI public
77
open import Reflection.Syntax public
8-
open import Reflection.AST.Term public
9-
using (vΠ[_∶_]_)
108

119
instance
1210
iMonad-TC = Monad-TC

Reflection/Syntax.agda

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,39 @@ module Reflection.Syntax where
44

55
open import Meta.Prelude
66

7-
open import Reflection.AST.Argument public
8-
hiding (map)
9-
open import Reflection.AST.Term public
10-
hiding (_≟_; getName)
11-
open import Reflection.AST.Name public
12-
hiding (_≟_; _≡ᵇ_; _≈_; _≈?_)
137
open import Reflection.AST.Definition public
14-
hiding (_≟_)
15-
open import Reflection.AST.Meta public
16-
hiding (_≟_; _≡ᵇ_; _≈_; _≈?_)
8+
using (Definition; function; data-type; axiom; record′; constructor′; primitive′)
9+
open import Reflection.AST.Pattern public
10+
using (Pattern; con; dot; var; lit; proj; absurd)
11+
open import Reflection.AST.Term public
12+
using ( Term; pi; var; con; def; lam; pat-lam; sort; lit; meta; unknown
13+
; vLam; hLam; iLam; Π[_∶_]_; vΠ[_∶_]_; hΠ[_∶_]_; iΠ[_∶_]_
14+
; Type; Telescope
15+
; Sort; set; prop; propLit; inf
16+
; Clause; Clauses; clause; absurd-clause
17+
)
1718
open import Reflection.AST.Abstraction public
18-
using (unAbs)
19-
20-
open import Agda.Builtin.Reflection public
21-
using (ArgInfo; Modality; Visibility; Literal; Meta)
22-
19+
using (Abs; abs; unAbs)
2320
open import Reflection.AST.Argument public
24-
using (Arg; arg)
21+
using (Arg; Args; arg; vArg; hArg; iArg; unArg; _⟨∷⟩_; map-Args)
22+
open import Reflection.AST.Literal public
23+
using (Literal)
24+
open import Reflection.AST.Meta public
25+
using (Meta)
26+
open import Reflection.AST.Name public
27+
using (Name)
2528
open import Reflection.AST.Argument.Visibility public
2629
using (Visibility; visible; hidden; instance′)
2730
open import Reflection.AST.Argument.Information public
2831
using (ArgInfo; arg-info)
29-
open import Reflection.AST.Abstraction public
30-
using (Abs; abs; unAbs)
31-
open import Reflection.AST.Argument public
32-
using (vArg; hArg; iArg; unArg; _⟨∷⟩_; map-Args)
32+
open import Reflection.AST.Argument.Modality public
33+
using (Modality; modality)
34+
open import Reflection.AST.Argument.Relevance public
35+
using (Relevance; relevant; irrelevant)
3336
open import Reflection public
34-
using ( Name; Meta; Literal; Pattern; Clause
35-
; ErrorPart; strErr
36-
; Term; Type; pi; var; con; def; lam; pat-lam; agda-sort; lit; meta; unknown
37-
; Definition; data-cons; data-type; record-type
38-
)
37+
using (ErrorPart; strErr)
3938

40-
open import Reflection using (hidden; instance′; TC)
39+
open import Reflection using (TC)
4140

4241
-- ** Smart constructors
4342

@@ -103,7 +102,7 @@ pattern _◇ n = Pattern.con n []
103102
pattern _◇⟦_⟧ n x = Pattern.con n (vArg x ∷ [])
104103
pattern _◇⟦_∣_⟧ n x y = Pattern.con n (vArg x ∷ vArg y ∷ [])
105104

106-
pattern `Set = agda-sort (set (quote 0ℓ ∙))
105+
pattern `Set = sort (set (quote 0ℓ ∙))
107106

108107
-- ** useful type aliases
109108
PatTelescope = Telescope

Reflection/Utils/Args.agda

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
module Reflection.Utils.Args where
33

44
open import Meta.Prelude
5-
open import Meta.Init hiding (toℕ)
5+
open import Meta.Init
66

77
open import Data.List using (map; zip)
88
open import Data.Fin using (toℕ)

Reflection/Utils/Core.agda

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ argTys = proj₁ ∘ viewTy′
4949
resultTy : Type Type
5050
resultTy = proj₂ ∘ viewTy′
5151

52+
tyTele : Type Telescope
53+
tyTele = λ where
54+
(Π[ s ∶ a ] ty) (s , a) ∷ tyTele ty
55+
_ []
56+
5257
-- ** definitions
5358

5459
record DataDef : Set where

Reflection/Utils/Metas.agda

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mutual
2020
(lam _ (abs _ x)) findMetas x
2121
(pat-lam cs as) findMetasCl cs ++ findMetas* as
2222
(pi (arg _ a) (abs _ b)) findMetas a ++ findMetas b
23-
(agda-sort _) []
23+
(sort _) []
2424
(lit _) []
2525
m@(meta x as) m ∷ findMetas* as
2626
unknown []
@@ -33,5 +33,5 @@ mutual
3333
findMetasCl : List Clause List Term
3434
findMetasCl = λ where
3535
[] []
36-
(Clause.clause _ _ t ∷ c) findMetas t ++ findMetasCl c
37-
(Clause.absurd-clause _ _ ∷ c) findMetasCl c
36+
(clause _ _ t ∷ c) findMetas t ++ findMetasCl c
37+
(absurd-clause _ _ ∷ c) findMetasCl c

Reflection/Utils/Substitute.agda

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ mutual
2828
(lam v t) lam v (substAbs x s t)
2929
(pat-lam _ _) unknown -- ignoring for now
3030
(pi a b) pi (substArg x s a) (substAbs x s b)
31-
(agda-sort st) agda-sort (substSort x s st)
31+
(sort st) sort (substSort x s st)
3232
(lit l) lit l
3333
(meta m as) meta m (substArgs x s as)
3434
unknown unknown
@@ -75,8 +75,8 @@ module _ (f : ℕ → ℕ) where
7575
pat-lam (mapFreeVarsᶜ∗ bound cs) (mapFreeVars∗ bound as)
7676
(pi (arg i t) (abs x t′))
7777
pi (arg i (mapFreeVars bound t)) (abs x (mapFreeVars (suc bound) t′))
78-
(agda-sort s)
79-
agda-sort (mapFreeVarsˢ bound s)
78+
(sort s)
79+
sort (mapFreeVarsˢ bound s)
8080
(meta x as)
8181
meta x (mapFreeVars∗ bound as)
8282
t t

Reflection/Utils/TCI.agda

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ ensureNoMetas = λ where
7878
(lam v (abs _ t)) ensureNoMetas t
7979
(pat-lam cs args) noMetaClauses cs >> noMetaArgs args
8080
(pi a b) noMetaArg a >> noMetaAbs b
81-
(agda-sort s) noMetaSort s
81+
(sort s) noMetaSort s
8282
(lit l) return _
8383
-- (meta x _) → errorP "meta found!"
8484
(meta x _) blockOnMeta x
@@ -233,7 +233,7 @@ getDataDef n = inDebugPath "getDataDef" do
233233

234234
getRecordDef : Name M RecordDef
235235
getRecordDef n = do
236-
(record-type c fs) getDefinition n
236+
(record c fs) getDefinition n
237237
where _ error1 "Not a record definition!"
238238
args proj₁ <$> getType' n
239239
return (record { name = c ; fields = fs ; params = args })
@@ -260,7 +260,7 @@ getFuel s = do
260260

261261
isSort : Term M Bool
262262
isSort t = do
263-
(agda-sort _) normalise t
263+
(sort _) normalise t
264264
where _ return false
265265
return true
266266

Tactic.agda

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ open import Tactic.J public
1818
open import Tactic.ReduceDec public
1919

2020
open import Tactic.Derive.DecEq public
21+
open import Tactic.Derive.DecEqFast
2122
open import Tactic.Derive.Show public
2223
open import Tactic.Derive.HsType public; open import Tactic.Derive.HsType.Tests
2324
open import Tactic.Derive.Convertible public

Tactic/Derive/Convertible.agda

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ doPatternLambda hole = patternLambda =<< initTCEnvWithGoal hole
119119
-- Deriving a Convertible instance. Usage
120120
-- unquoteDecl iName = deriveConvertible iName (quote AgdaTy) (quote HsTy)
121121
deriveConvertible : Name Name Name R.TC ⊤
122-
deriveConvertible instName agdaName hsName = initUnquoteWithGoal ⦃ defaultTCOptions ⦄ (agda-sort (lit 0)) do
122+
deriveConvertible instName agdaName hsName = initUnquoteWithGoal ⦃ defaultTCOptions ⦄ (sort (lit 0)) do
123123
agdaDef getDefinition agdaName
124124
hsDef getDefinition hsName
125125
-- instName ← freshName $ "Convertible" S.++ show hsName

Tactic/Derive/DecEq.agda

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ open import Relation.Nullary
2121
open import Reflection.Tactic
2222
open import Reflection.QuotedDefinitions
2323
open import Reflection.AST.DeBruijn
24+
open import Reflection.AST.Pattern using () renaming (_≟_ to _≟-Pattern_)
2425

2526
open import Class.DecEq.Core
2627
open import Class.Functor

0 commit comments

Comments
 (0)