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

« back to all changes in this revision

Viewing changes to test/succeed/IndexInference.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
 
{-# OPTIONS -v tc.conv.irr:50 #-}
2
 
module IndexInference where
3
 
 
4
 
data Nat : Set where
5
 
  zero : Nat
6
 
  suc  : Nat -> Nat
7
 
 
8
 
data Vec (A : Set) : Nat -> Set where
9
 
  []   : Vec A zero
10
 
  _::_ : {n : Nat} -> A -> Vec A n -> Vec A (suc n)
11
 
 
12
 
infixr 40 _::_
13
 
 
14
 
foo : Vec Nat _ -> Nat
15
 
foo (a :: b :: c :: []) = c
16
 
 
17
 
 
18
 
pred : Nat → Nat
19
 
pred (zero ) = zero
20
 
pred (suc n) = n
21
 
 
22
 
data ⊥ : Set where
23
 
record ⊤ : Set where
24
 
 
25
 
NonZero : Nat → Set
26
 
NonZero zero    = ⊥
27
 
NonZero (suc n) = ⊤
28
 
 
29
 
data Fin (n : Nat) : Set where
30
 
  zero : .(NonZero n) → Fin n
31
 
  suc  : .(NonZero n) → Fin (pred n) → Fin n
32
 
 
33
 
data SubVec (A : Set)(n : Nat) : Fin n → Set where
34
 
  []   : .{p : NonZero n} → SubVec A n (zero p)
35
 
  _::_ : .{p : NonZero n}{k : Fin (pred n)} → A → SubVec A (pred n) k → SubVec A n (suc p k)
36
 
 
37
 
bar : {A : Set} → SubVec A (suc (suc (suc zero))) _ → A
38
 
bar (a :: []) = a