~ubuntu-branches/ubuntu/wily/agda/wily-proposed

« back to all changes in this revision

Viewing changes to test/fail/ConstructorHeadedDivergenceIn2-2-10.agda

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2014-08-05 06:38:12 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20140805063812-io8e77niomivhd49
Tags: 2.4.0.2-1
* [6e140ac] Imported Upstream version 2.4.0.2
* [2049fc8] Update Build-Depends to match control
* [93dc4d4] Install the new primitives
* [e48f40f] Fix typo dev→doc

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
module ConstructorHeadedDivergenceIn2-2-10 where
2
 
 
3
 
data ⊤ : Set where
4
 
  tt : ⊤
5
 
 
6
 
data ℕ : Set where
7
 
  zero : ℕ
8
 
  suc : ℕ → ℕ
9
 
 
10
 
data _×_ (A B : Set) : Set where
11
 
  _,_ : A → B → A × B
12
 
 
13
 
{- Brandon Moore reports (July 2011)
14
 
In 2.2.10 the following code seems to cause typechecking
15
 
to diverge.
16
 
-}
17
 
 
18
 
f : ℕ → Set
19
 
f zero = ⊤
20
 
f (suc n) = ℕ × f n
21
 
 
22
 
enum : (n : ℕ) → f n
23
 
enum zero = tt
24
 
enum (suc n) = n , enum n
25
 
 
26
 
n : ℕ
27
 
n = _
28
 
 
29
 
test : f n
30
 
test = enum (suc n)
31
 
{-
32
 
This typechecks quickly if the definition
33
 
of test is changed to
34
 
 
35
 
test = enum n
36
 
 
37
 
I think the problem is that the body has type ℕ × f n,
38
 
and unifying it with the expected type f n invokes the
39
 
constructor-headed function specialization to resolve
40
 
n to suc n', and the process repeats.
41
 
 
42
 
Brandon
43
 
-}
44
 
 
45
 
--
 
 
b'\\ No newline at end of file'