forked from agda/agda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CHANGELOG
5147 lines (3627 loc) · 157 KB
/
CHANGELOG
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
------------------------------------------------------------------------
-- Release notes for Agda version 2.4.2.4
------------------------------------------------------------------------
Important changes since 2.4.2.3:
Installation and infrastructure
===============================
* Removed support for GHC 7.4.2.
Pragmas and options
===================
* Option --copatterns is now on by default. To switch off
parsing of copatterns, use:
{-# OPTIONS --no-copatterns #-}
* Option --rewriting is now needed to use REWRITE pragmas
and rewriting during reduction. Rewriting is not --safe.
To use rewriting, first specify a relation symbol `R` that will
later be used to add rewrite rules. A canonical candidate would be
propositional equality
{-# BUILTIN REWRITE _≡_ #-}
but any symbol `R` of type `Δ → A → A → Set i` for some `A` and
`i` is accepted. Then symbols `q` can be added to rewriting
provided their type is of the form `Γ → R ds l r`. This will add
a rewrite rule
Γ ⊢ l ↦ r : A[ds/Δ]
to the signature, which fires whenever a term is an instance of `l`.
For example, if
plus0 : ∀ x → x + 0 ≡ x
(ideally, there is a proof for `plus0`, but it could be a
postulate), then
{-# REWRITE plus0 #-}
will prompt Agda to rewrite any well-typed term of the form `t + 0`
to `t`.
Some caveats: Agda accepts and applies rewrite rules naively, it is
very easy to break consistency and termination of type checking.
Some examples of rewrite rules that should /not/ be added:
refl : ∀ x → x ≡ x -- Agda loops
plus-sym : ∀ x y → x + y ≡ y + x -- Agda loops
absurd : true ≡ false -- Breaks consistency
Adding only proven equations should at least preserve consistency,
but this is only a conjecture, so know what you are doing!
Using rewriting, you are entering into the wilderness, where you are
on your own!
Language
========
* forall / ∀ now parses like λ, i.e., the following parses now [Issue 1583]:
⊤ × ∀ (B : Set) → B → B
* The underscore pattern _ can now also stand for an inaccessible
pattern (dot pattern). This alleviates the need for writing `._'.
[Issue 1605] Instead of
transVOld : ∀{A : Set} (a b c : A) → a ≡ b → b ≡ c → a ≡ c
transVOld _ ._ ._ refl refl = refl
one can now write
transVNew : ∀{A : Set} (a b c : A) → a ≡ b → b ≡ c → a ≡ c
transVNew _ _ _ refl refl = refl
and let Agda decide where to put the dots. This was always possible
by using hidden arguments
transH : ∀{A : Set}{a b c : A} → a ≡ b → b ≡ c → a ≡ c
transH refl refl = refl
which is now equivalent to
transHNew : ∀{A : Set}{a b c : A} → a ≡ b → b ≡ c → a ≡ c
transHNew {a = _}{b = _}{c = _} refl refl = refl
Before, underscore _ stood for an unnamed variable that could not be
instantiated by an inaccessible pattern. If one no wants to prevent
Agda from instantiating, one needs to use a variable name other than
underscore (however, in practice this situation seems unlikely).
Type checking
=============
* Polarity of phantom arguments to data and record types has changed. [Issue 1596]
Polarity of size arguments is Nonvariant (both monotone and antitone).
Polarity of other arguments is Covariant (monotone).
Both were Invariant before (neither monotone nor antitone).
The following example type-checks now:
open import Common.Size
-- List should be monotone in both arguments
-- (even when `cons' is missing).
data List (i : Size) (A : Set) : Set where
[] : List i A
castLL : ∀{i A} → List i (List i A) → List ∞ (List ∞ A)
castLL x = x
-- Stream should be antitone in the first and monotone in the second argument
-- (even with field `tail' missing).
record Stream (i : Size) (A : Set) : Set where
coinductive
field
head : A
castSS : ∀{i A} → Stream ∞ (Stream ∞ A) → Stream i (Stream i A)
castSS x = x
* SIZELT lambdas must be consistent [Issue 1523, see Abel and Pientka, ICFP 2013].
When lambda-abstracting over type (Size< size) then size must be
non-zero, for any valid instantiation of size variables.
The good:
data Nat (i : Size) : Set where
zero : ∀ (j : Size< i) → Nat i
suc : ∀ (j : Size< i) → Nat j → Nat i
{-# TERMINATING #-}
-- This definition is fine, the termination checker is too strict at the moment.
fix : ∀ {C : Size → Set}
→ (∀ i → (∀ (j : Size< i) → Nat j -> C j) → Nat i → C i)
→ ∀ i → Nat i → C i
fix t i (zero j) = t i (λ (k : Size< i) → fix t k) (zero j)
fix t i (suc j n) = t i (λ (k : Size< i) → fix t k) (suc j n)
The λ (k : Size< i) is fine in both cases, as context
i : Size, j : Size< i
guarantees that i is non-zero.
The bad:
record Stream {i : Size} (A : Set) : Set where
coinductive
constructor _∷ˢ_
field
head : A
tail : ∀ {j : Size< i} → Stream {j} A
open Stream public
_++ˢ_ : ∀ {i A} → List A → Stream {i} A → Stream {i} A
[] ++ˢ s = s
(a ∷ as) ++ˢ s = a ∷ˢ (as ++ˢ s)
This fails, maybe unjustified, at
i : Size, s : Stream {i} A
⊢
a ∷ˢ (λ {j : Size< i} → as ++ˢ s)
Fixed by defining the constructor by copattern matching:
record Stream {i : Size} (A : Set) : Set where
coinductive
field
head : A
tail : ∀ {j : Size< i} → Stream {j} A
open Stream public
_∷ˢ_ : ∀ {i A} → A → Stream {i} A → Stream {↑ i} A
head (a ∷ˢ as) = a
tail (a ∷ˢ as) = as
_++ˢ_ : ∀ {i A} → List A → Stream {i} A → Stream {i} A
[] ++ˢ s = s
(a ∷ as) ++ˢ s = a ∷ˢ (as ++ˢ s)
The ugly:
fix : ∀ {C : Size → Set}
→ (∀ i → (∀ (j : Size< i) → C j) → C i)
→ ∀ i → C i
fix t i = t i λ (j : Size< i) → fix t j
For i=0, there is no such j at runtime, leading to looping
behavior.
Interaction
===========
* Issue 635 has been fixed. Case splitting does not spit out implicit
record patterns any more.
record Cont : Set₁ where
constructor _◃_
field
Sh : Set
Pos : Sh → Set
open Cont
data W (C : Cont) : Set where
sup : (s : Sh C) (k : Pos C s → W C) → W C
bogus : {C : Cont} → W C → Set
bogus w = {!w!}
Case splitting on w yielded, since the fix of issue 473,
bogus {Sh ◃ Pos} (sup s k) = ?
Now it gives, as expected,
bogus (sup s k) = ?
Performance
===========
* As one result of the 21st Agda Implementor's Meeting (AIM XXI),
serialization of the standard library is 50% faster (time reduced by
a third), without using additional disk space for the interface
files.
Bug fixes
=========
* Issues fixed ( see https://github.com/agda/agda/issues ):
1546 (copattern matching and with-clauses)
1560 (positivity checker inefficiency)
1584 (let pattern with trailing implicit)
------------------------------------------------------------------------
-- Release notes for Agda version 2.4.2.3
------------------------------------------------------------------------
Important changes since 2.4.2.2:
Installation and infrastructure
===============================
* Added support for GHC 7.10.1.
* Removed support for GHC 7.0.4.
Language
========
* _ is no longer a valid name for a definition. The following fails now:
[Issue 1465]
postulate _ : Set
* Typed bindings can now contain hiding information [Issue 1391].
This means you can now write
assoc : (xs {ys zs} : List A) → ((xs ++ ys) ++ zs) ≡ (xs ++ (ys ++ zs))
instead of the longer
assoc : (xs : List A) {ys zs : List A} → ...
It also works with irrelevance
.(xs {ys zs} : List A) → ...
but of course does not make sense if there is hiding information already.
Thus, this is (still) a parse error:
{xs {ys zs} : List A} → ...
* The builtins for sized types no longer need accompanying postulates.
The BUILTIN pragmas for size stuff now also declare the identifiers
they bind to.
{-# BUILTIN SIZEUNIV SizeUniv #-} -- SizeUniv : SizeUniv
{-# BUILTIN SIZE Size #-} -- Size : SizeUniv
{-# BUILTIN SIZELT Size<_ #-} -- Size<_ : ..Size → SizeUniv
{-# BUILTIN SIZESUC ↑_ #-} -- ↑_ : Size → Size
{-# BUILTIN SIZEINF ∞ #-} -- ∞ : Size
Size and Size< now live in the new universe SizeUniv.
It is forbidden to build function spaces in this universe,
in order to prevent the malicious assumption of a size predecessor
pred : (i : Size) → Size< i
[Issue 1428].
* Unambiguous notations (coming from syntax declarations) that resolve
to ambiguous names are now parsed unambiguously [Issue 1194].
* If only some instances of an overloaded name have a given
associated notation (coming from syntax declarations), then this
name can only be resolved to the given instances of the
name, not to other instances [Issue 1194].
Previously, if different instances of an overloaded name had
/different/ associated notations, then none of the notations could
be used. Now all of them can be used.
Note that notation identity does not only involve the right-hand
side of the syntax declaration. For instance, the following
notations are not seen as identical, because the implicit argument
names are different:
module A where
data D : Set where
c : {x y : D} → D
syntax c {x = a} {y = b} = a ∙ b
module B where
data D : Set where
c : {y x : D} → D
syntax c {y = a} {x = b} = a ∙ b
* If an overloaded operator is in scope with at least two distinct
fixities, then it gets the default fixity [Issue 1436].
Similarly, if two or more identical notations for a given overloaded
name are in scope, and these notations do not all have the
same fixity, then they get the default fixity.
Type checking
=============
* Functions of varying arity can now have with-clauses and use rewrite.
Example:
NPred : Nat → Set
NPred 0 = Bool
NPred (suc n) = Nat → NPred n
const : Bool → ∀{n} → NPred n
const b {0} = b
const b {suc n} m = const b {n}
allOdd : ∀ n → NPred n
allOdd 0 = true
allOdd (suc n) m with even m
... | true = const false
... | false = allOdd n
* Function defined by copattern matching can now have with-clauses
and use rewrite. Example:
{-# OPTIONS --copatterns #-}
record Stream (A : Set) : Set where
coinductive
constructor delay
field
force : A × Stream A
open Stream
map : ∀{A B} → (A → B) → Stream A → Stream B
force (map f s) with force s
... | a , as = f a , map f as
record Bisim {A B} (R : A → B → Set) (s : Stream A) (t : Stream B) : Set where
coinductive
constructor ~delay
field
~force : let a , as = force s
b , bs = force t
in R a b × Bisim R as bs
open Bisim
SEq : ∀{A} (s t : Stream A) → Set
SEq = Bisim (_≡_)
-- Slightly weird definition of symmetry to demonstrate rewrite.
~sym' : ∀{A} {s t : Stream A} → SEq s t → SEq t s
~force (~sym' {s = s} {t} p) with force s | force t | ~force p
... | a , as | b , bs | r , q rewrite r = refl , ~sym' q
* Instances can now be defined by copattern matching. [Issue 1413]
The following example extends the one in
[Abel, Pientka, Thibodeau, Setzer, POPL 2013, Section 2.2]:
{-# OPTIONS --copatterns #-}
-- The Monad type class
record Monad (M : Set → Set) : Set1 where
field
return : {A : Set} → A → M A
_>>=_ : {A B : Set} → M A → (A → M B) → M B
open Monad {{...}}
-- The State newtype
record State (S A : Set) : Set where
field
runState : S → A × S
open State
-- State is an instance of Monad
instance
stateMonad : {S : Set} → Monad (State S)
runState (return {{stateMonad}} a ) s = a , s -- NEW
runState (_>>=_ {{stateMonad}} m k) s₀ = -- NEW
let a , s₁ = runState m s₀
in runState (k a) s₁
-- stateMonad fulfills the monad laws
leftId : {A B S : Set}(a : A)(k : A → State S B) →
(return a >>= k) ≡ k a
leftId a k = refl
rightId : {A B S : Set}(m : State S A) →
(m >>= return) ≡ m
rightId m = refl
assoc : {A B C S : Set}(m : State S A)(k : A → State S B)(l : B → State S C) →
((m >>= k) >>= l) ≡ (m >>= λ a → k a >>= l)
assoc m k l = refl
Emacs mode
==========
* The new menu option "Switch to another version of Agda" tries to do
what it says.
* Changed feature: Interactively split result.
[ This is as before: ]
Make-case (C-c C-c) with no variables given tries to split on the
result to introduce projection patterns. The hole needs to be of
record type, of course.
test : {A B : Set} (a : A) (b : B) → A × B
test a b = ?
Result-splitting ? will produce the new clauses:
proj₁ (test a b) = ?
proj₂ (test a b) = ?
[ This has changed: ]
If hole is of function type, make-case will introduce only pattern
variables (as much as it can).
testFun : {A B : Set} (a : A) (b : B) → A × B
testFun = ?
Result-splitting ? will produce the new clause:
testFun a b = ?
A second invocation of make-case will then introduce projection patterns.
Error messages
==============
* Agda now suggests corrections of misspelled options, e.g.
{-# OPTIONS
--dont-termination-check
--without-k
--senf-gurke
#-}
Unrecognized options:
--dont-termination-check (did you mean --no-termination-check ?)
--without-k (did you mean --without-K ?)
--senf-gurke
Nothing close to --senf-gurke, I am afraid.
Compiler backends
=================
* The Epic backend has been removed [Issue 1481].
Bug fixes
=========
* Fixed bug with unquoteDecl not working in instance blocks [Issue 1491].
* Other issues fixed ( see https://code.google.com/p/agda/issues )
1497
1500
------------------------------------------------------------------------
-- Release notes for Agda version 2.4.2.2
------------------------------------------------------------------------
Important changes since 2.4.2.1:
Bug fixes
=========
* Compilation on Windows fixed.
* Other issues fixed ( see https://code.google.com/p/agda/issues )
1332
1353
1360
1366
1369
------------------------------------------------------------------------
-- Release notes for Agda version 2.4.2.1
------------------------------------------------------------------------
Important changes since 2.4.2:
Pragmas and options
===================
* New pragma {-# TERMINATING #-} replacing {-# NO_TERMINATION_CHECK #-}
Complements the existing pragma {-# NON_TERMINATING #-}.
Skips termination check for the associated definitions and marks
them as terminating. Thus, it is a replacement for
{-# NO_TERMINATION_CHECK #-} with the same semantics.
You can no longer use pragma {-# NO_TERMINATION_CHECK #-} to skip
the termination check, but must label your definitions as either
{-# TERMINATING #-} or {-# NON_TERMINATING #-} instead.
Note: {-# OPTION --no-termination-check #-} labels all your
definitions as {-# TERMINATING #-}, putting you in the danger zone
of a loop in the type checker.
Language
========
* Referring to a local variable shadowed by module opening is now
an error. Previous behavior was preferring the local over the
imported definitions. [Issue 1266]
Note that module parameters are locals as well as variables bound by
λ, dependent function type, patterns, and let.
Example:
module M where
A = Set1
test : (A : Set) → let open M in A
The last A produces an error, since it could refer to the local
variable A or to the definition imported from module M.
* `with` on a variable bound by a module telescope or a pattern of a
parent function is now forbidden. [Issue 1342]
data Unit : Set where
unit : Unit
id : (A : Set) → A → A
id A a = a
module M (x : Unit) where
dx : Unit → Unit
dx unit = x
g : ∀ u → x ≡ dx u
g with x
g | unit = id (∀ u → unit ≡ dx u) ?
Even though this code looks right, Agda complains about the type
expression `∀ u → unit ≡ dx u`. If you ask Agda what should go
there instead, it happily tells you that it wants
`∀ u → unit ≡ dx u`. In fact what you do not see and Agda
will never show you is that the two expressions actually differ in
the invisible first argument to `dx`, which is visible only outside
module `M`. What Agda wants is an invisible `unit` after `dx`, but all
you can write is an invisible `x` (which is inserted behind the
scenes).
To avoid those kinds of paradoxes, `with` is now outlawed on module
parameters. This should ensure that the invisible arguments are
always exactly the module parameters.
Since a `where` block is desugared as module with pattern variables
of the parent clause as module parameters, the same strikes you for
uses of `with` on pattern variables of the parent function.
f : Unit → Unit
f x = unit
where
dx : Unit → Unit
dx unit = x
g : ∀ u → x ≡ dx u
g with x
g | unit = id ((u : Unit) → unit ≡ dx u) ?
The `with` on pattern variable `x` of the parent clause `f x = unit`
is outlawed now.
Type checking
=============
* Termination check failure is now a proper error.
We no longer continue type checking after termination check failures.
Use pragmas {-# NON_TERMINATING #-} and {-# NO_TERMINATION_CHECK #-}
near the offending definitions if you want to do so.
Or switch off the termination checker altogether with
{-# OPTIONS --no-termination-check #-} (at your own risk!).
* (Since Agda 2.4.2:) Termination checking --without-K restricts
structural descent to arguments ending in data types or `Size`.
Likewise, guardedness is only tracked when result type is data or
record type.
mutual
data WOne : Set where wrap : FOne → WOne
FOne = ⊥ → WOne
noo : (X : Set) → (WOne ≡ X) → X → ⊥
noo .WOne refl (wrap f) = noo FOne iso f
`noo` is rejected since at type `X` the structural descent
`f < wrap f` is discounted --without-K.
data Pandora : Set where
C : ∞ ⊥ → Pandora
loop : (A : Set) → A ≡ Pandora → A
loop .Pandora refl = C (♯ (loop ⊥ foo))
`loop` is rejected since guardedness is not tracked at type `A`
--without-K.
See issues 1023, 1264, 1292.
Termination checking
====================
* The termination checker can now recognize simple subterms in dot
patterns.
data Subst : (d : Nat) → Set where
c₁ : ∀ {d} → Subst d → Subst d
c₂ : ∀ {d₁ d₂} → Subst d₁ → Subst d₂ → Subst (suc d₁ + d₂)
postulate
comp : ∀ {d₁ d₂} → Subst d₁ → Subst d₂ → Subst (d₁ + d₂)
lookup : ∀ d → Nat → Subst d → Set₁
lookup d zero (c₁ ρ) = Set
lookup d (suc v) (c₁ ρ) = lookup d v ρ
lookup .(suc d₁ + d₂) v (c₂ {d₁} {d₂} ρ σ) = lookup (d₁ + d₂) v (comp ρ σ)
The dot pattern here is actually normalized, so it is
suc (d₁ + d₂)
and the corresponding recursive call argument is (d₁ + d₂).
In such simple cases, Agda can now recognize that the pattern is
constructor applied to call argument, which is valid descent.
Note however, that Agda only looks for syntactic equality when
identifying subterms, since it is not allowed to normalize terms on
the rhs during termination checking.
Actually writing the dot pattern has no effect, this works as well,
and looks pretty magical... ;-)
hidden : ∀{d} → Nat → Subst d → Set₁
hidden zero (c₁ ρ) = Set
hidden (suc v) (c₁ ρ) = hidden v ρ
hidden v (c₂ ρ σ) = hidden v (comp ρ σ)
Tools
=====
LaTeX-backend
-------------
* Fixed the issue of identifiers containing operators being typeset with
excessive math spacing.
Bug fixes
=========
* Issue 1194
* Issue 836: Fields and constructors can be qualified by the
record/data *type* as well as by their record/data module.
This now works also for record/data type imported from
parametrized modules:
module M (_ : Set₁) where
record R : Set₁ where
field
X : Set
open M Set using (R) -- rather than using (module R)
X : R → Set
X = R.X
------------------------------------------------------------------------
-- Release notes for Agda version 2.4.2
------------------------------------------------------------------------
Important changes since 2.4.0.2:
Pragmas and options
===================
* New option: --with-K.
This can be used to override a global --without-K in a file, by
adding a pragma {-# OPTIONS --with-K #-}.
* New pragma {-# NON_TERMINATING #-}
This is a safer version of NO_TERMINATION_CHECK which doesn't treat the
affected functions as terminating. This means that NON_TERMINATING functions
do not reduce during type checking. They do reduce at run-time and when
invoking C-c C-n at top-level (but not in a hole).
Language
========
* Instance search is now more efficient and recursive (see issue 938)
(but without termination check yet).
A new keyword `instance' has been introduced (in the style of
`abstract' and `private') which must now be used for every
definition/postulate that has to be taken into account during instance
resolution. For example:
record RawMonoid (A : Set) : Set where
field
nil : A
_++_ : A -> A -> A
open RawMonoid {{...}}
instance
rawMonoidList : {A : Set} -> RawMonoid (List A)
rawMonoidList = record { nil = []; _++_ = List._++_ }
rawMonoidMaybe : {A : Set} {{m : RawMonoid A}} -> RawMonoid (Maybe A)
rawMonoidMaybe {A} = record { nil = nothing ; _++_ = catMaybe }
where
catMaybe : Maybe A -> Maybe A -> Maybe A
catMaybe nothing mb = mb
catMaybe ma nothing = ma
catMaybe (just a) (just b) = just (a ++ b)
Moreover, each type of an instance must end in (something that reduces
to) a named type (e.g. a record, a datatype or a postulate). This
allows us to build a simple index structure
data/record name --> possible instances
that speeds up instance search.
Instance search takes into account all local bindings and all global
'instance' bindings and the search is recursive. For instance,
searching for
? : RawMonoid (Maybe (List A))
will consider the candidates {rawMonoidList, rawMonoidMaybe}, fail to
unify the first one, succeeding with the second one
? = rawMonoidMaybe {A = List A} {{m = ?m}} : RawMonoid (Maybe (List A))
and continue with goal
?m : RawMonoid (List A)
This will then find
?m = rawMonoidList {A = A}
and putting together we have the solution.
Be careful that there is no termination check for now, you can easily
make Agda loop by declaring the identity function as an instance. But
it shouldn’t be possible to make Agda loop by only declaring
structurally recursive instances (whatever that means).
Additionally:
* Uniqueness of instances is up to definitional equality (see issue 899).
* Instances of the following form are allowed:
EqSigma : {A : Set} {B : A → Set} {{EqA : Eq A}}
{{EqB : {a : A} → Eq (B a)}}
→ Eq (Σ A B)
When searching recursively for an instance of type
`{a : A} → Eq (B a)', a lambda will automatically be introduced and
instance search will search for something of type `Eq (B a)' in
the context extended by `a : A'. When searching for an instance, the
`a' argument does not have to be implicit, but in the definition of
EqSigma, instance search will only be able to use EqB if `a' is implicit.
* There is no longer any attempt to solve irrelevant metas by instance
search.
* Constructors of records and datatypes are automatically added to the
instance table.
* You can now use 'quote' in patterns.
For instance, here is a function that unquotes a (closed) natural number
term.
unquoteNat : Term → Maybe Nat
unquoteNat (con (quote Nat.zero) []) = just zero
unquoteNat (con (quote Nat.suc) (arg _ n ∷ [])) = fmap suc (unquoteNat n)
unquoteNat _ = nothing
* The builtin constructors AGDATERMUNSUPPORTED and AGDASORTUNSUPPORTED are now
translated to meta variables when unquoting.
* New syntactic sugar 'tactic e' and 'tactic e | e1 | .. | en'.
It desugars as follows and makes it less unwieldy to call reflection-based
tactics.
tactic e --> quoteGoal g in unquote (e g)
tactic e | e1 | .. | en --> quoteGoal g in unquote (e g) e1 .. en
Note that in the second form the tactic function should generate a function
from a number of new subgoals to the original goal. The type of e should be
Term -> Term in both cases.
* New reflection builtins for literals.
The Term data type AGDATERM now needs an additional constructor AGDATERMLIT
taking a reflected literal defined as follows (with appropriate builtin
bindings for the types Nat, Float, etc).
data Literal : Set where
nat : Nat → Literal
float : Float → Literal
char : Char → Literal
string : String → Literal
qname : QName → Literal
{-# BUILTIN AGDALITERAL Literal #-}
{-# BUILTIN AGDALITNAT nat #-}
{-# BUILTIN AGDALITFLOAT float #-}
{-# BUILTIN AGDALITCHAR char #-}
{-# BUILTIN AGDALITSTRING string #-}
{-# BUILTIN AGDALITQNAME qname #-}
When quoting (quoteGoal or quoteTerm) literals will be mapped to the
AGDATERMLIT constructor. Previously natural number literals were quoted
to suc/zero application and other literals were quoted to
AGDATERMUNSUPPORTED.
* New reflection builtins for function definitions.
AGDAFUNDEF should now map to a data type defined as follows
(with {-# BUILTIN QNAME QName #-}
{-# BUILTIN ARG Arg #-}
{-# BUILTIN AGDATERM Term #-}
{-# BUILTIN AGDATYPE Type #-}
{-# BUILTIN AGDALITERAL Literal #-}).
data Pattern : Set where
con : QName → List (Arg Pattern) → Pattern
dot : Pattern
var : Pattern
lit : Literal → Pattern
proj : QName → Pattern
absurd : Pattern
{-# BUILTIN AGDAPATTERN Pattern #-}
{-# BUILTIN AGDAPATCON con #-}
{-# BUILTIN AGDAPATDOT dot #-}
{-# BUILTIN AGDAPATVAR var #-}
{-# BUILTIN AGDAPATLIT lit #-}
{-# BUILTIN AGDAPATPROJ proj #-}
{-# BUILTIN AGDAPATABSURD absurd #-}
data Clause : Set where
clause : List (Arg Pattern) → Term → Clause
absurd-clause : List (Arg Pattern) → Clause
{-# BUILTIN AGDACLAUSE Clause #-}
{-# BUILTIN AGDACLAUSECLAUSE clause #-}
{-# BUILTIN AGDACLAUSEABSURD absurd-clause #-}
data FunDef : Set where
fun-def : Type → List Clause → FunDef
{-# BUILTIN AGDAFUNDEF FunDef #-}
{-# BUILTIN AGDAFUNDEFCON fun-def #-}
* New reflection builtins for extended (pattern-matching) lambda.
The AGDATERM data type has been augmented with a constructor
AGDATERMEXTLAM : List AGDACLAUSE → List (ARG AGDATERM) → AGDATERM
Absurd lambdas (λ ()) are quoted to extended lambdas with an absurd clause.
* Unquoting declarations.
You can now define (recursive) functions by reflection using the new
unquoteDecl declaration
unquoteDecl x = e
Here e should have type AGDAFUNDEF and evaluate to a closed value. This value
is then spliced in as the definition of x. In the body e, x has type QNAME
which lets you splice in recursive definitions.
Standard modifiers, such as fixity declarations, can be applied to x as
expected.
* Quoted levels
Universe levels are now quoted properly instead of being quoted to
AGDASORTUNSUPPORTED. Setω still gets an unsupported sort, however.
* Module applicants can now be operator applications. Example:
postulate
[_] : A -> B
module M (b : B) where
module N (a : A) = M [ a ]
[See Issue 1245.]
* Minor change in module application semantics. [Issue 892]
Previously re-exported functions were not redefined when instantiating a
module. For instance
module A where f = ...
module B (X : Set) where
open A public
module C = B Nat
In this example C.f would be an alias for A.f, so if both A and C were opened
f would not be ambiguous. However, this behaviour is not correct when A and B
share some module parameters (issue 892). To fix this C now defines its own
copy of f (which evaluates to A.f), which means that opening A and C results
in an ambiguous f.
Type checking
=============
* Recursive records need to be declared as either inductive or coinductive.
'inductive' is no longer default for recursive records.
Examples:
record _×_ (A B : Set) : Set where
constructor _,_
field
fst : A
snd : B
record Tree (A : Set) : Set where
inductive
constructor tree
field
elem : A
subtrees : List (Tree A)
record Stream (A : Set) : Set where
coinductive
constructor _::_
field
head : A
tail : Stream A
If you are using old-style (musical) coinduction, a record may have
to be declared as inductive, paradoxically.