on master help sign in
Combine a chunk of regxxx tests

Now reg001 contains lots of the tests which are only intended to check whether some code type checks. More to do like this...

commit5f47887822a9c4a33ccba9df999d93c5d54c5ea2 authorEdwin Brady <ecb10@st-andrews.ac.uk> dateSun 6 Sep 2015, 14:52 (11 years ago) parent2f9d287
38 files changed+170−259
idris.cabal−36 test/reg001/reg001.idr+170 test/reg005/expected test/reg005/reg005.idr−12 test/reg005/run−3 test/reg009/expected test/reg009/reg009.lidr−21 test/reg009/run−3 test/reg011/expected test/reg011/reg011.idr−11 test/reg011/run−3 test/reg012/expected test/reg012/reg012.lidr−36 test/reg012/run−3 test/reg014/expected test/reg014/reg014.idr−14 test/reg014/run−3 test/reg015/expected test/reg015/reg015.idr−3 test/reg015/run−3 test/reg019/expected test/reg019/reg019.idr−7 test/reg019/run−3 test/reg021/expected test/reg021/reg021.idr−22 test/reg021/run−3 test/reg022/expected test/reg022/reg022.idr−18 test/reg022/run−3 test/reg026/expected test/reg026/reg026.idr−16 test/reg026/run−3 test/reg030/expected test/reg030/reg030.idr−15 test/reg030/run−3 test/reg033/expected test/reg033/reg033.idr−12 test/reg033/run−3
idris.cabal−36
@@ -143,36 +143,18 @@ Extra-source-files:
143143 test/reg004/run
144144 test/reg004/*.idr
145145 test/reg004/expected
146− test/reg005/run
147− test/reg005/*.idr
148− test/reg005/expected
149146 test/reg006/run
150147 test/reg006/*.idr
151148 test/reg006/expected
152149 test/reg007/run
153150 test/reg007/*.lidr
154151 test/reg007/expected
155− test/reg009/run
156− test/reg009/*.lidr
157− test/reg009/expected
158152 test/reg010/run
159153 test/reg010/*.idr
160154 test/reg010/expected
161− test/reg011/run
162− test/reg011/*.idr
163− test/reg011/expected
164− test/reg012/run
165− test/reg012/*.lidr
166− test/reg012/expected
167155 test/reg013/run
168156 test/reg013/*.idr
169157 test/reg013/expected
170− test/reg014/run
171− test/reg014/*.idr
172− test/reg014/expected
173− test/reg015/run
174− test/reg015/*.idr
175− test/reg015/expected
176158 test/reg016/run
177159 test/reg016/*.idr
178160 test/reg016/expected
@@ -182,18 +164,9 @@ Extra-source-files:
182164 test/reg018/run
183165 test/reg018/*.idr
184166 test/reg018/expected
185− test/reg019/run
186− test/reg019/*.idr
187− test/reg019/expected
188167 test/reg020/run
189168 test/reg020/*.idr
190169 test/reg020/expected
191− test/reg021/run
192− test/reg021/*.idr
193− test/reg021/expected
194− test/reg022/run
195− test/reg022/*.idr
196− test/reg022/expected
197170 test/reg023/run
198171 test/reg023/*.idr
199172 test/reg023/expected
@@ -203,9 +176,6 @@ Extra-source-files:
203176 test/reg025/run
204177 test/reg025/*.idr
205178 test/reg025/expected
206− test/reg026/run
207− test/reg026/*.idr
208− test/reg026/expected
209179 test/reg027/run
210180 test/reg027/*.idr
211181 test/reg027/expected
@@ -215,18 +185,12 @@ Extra-source-files:
215185 test/reg029/run
216186 test/reg029/*.idr
217187 test/reg029/expected
218− test/reg030/run
219− test/reg030/*.idr
220− test/reg030/expected
221188 test/reg031/run
222189 test/reg031/*.idr
223190 test/reg031/expected
224191 test/reg032/run
225192 test/reg032/*.idr
226193 test/reg032/expected
227− test/reg033/run
228− test/reg033/*.idr
229− test/reg033/expected
230194 test/reg034/run
231195 test/reg034/*.idr
232196 test/reg034/expected
test/reg001/reg001.idr+170
@@ -1,3 +1,11 @@
1+-- Everything here should type check but at some point in the past has
2+-- not.
3+
4+import Data.So
5+import Data.Vect
6+import Data.Fin
7+import Control.Isomorphism
8+
19class Functor f => VerifiedFunctor (f : Type -> Type) where
210 identity : (fa : f a) -> map id fa = fa
311
@@ -7,3 +15,165 @@ data Imp : Type where
715testVal : Imp
816testVal = MkImp (apply id Z)
917
18+zfin : Fin 1
19+zfin = 0
20+
21+data Infer = MkInf a
22+
23+foo : Infer
24+foo = MkInf (the (Fin 1) 0)
25+
26+isAnyBy : (alpha -> Bool) -> (n : Nat ** Vect n alpha) -> Bool
27+isAnyBy _ (_ ** Nil) = False
28+isAnyBy p (_ ** (a :: as)) = p a || isAnyBy p (_ ** as)
29+
30+filterTagP : (p : alpha -> Bool) ->
31+ (as : Vect n alpha) ->
32+ So (isAnyBy p (n ** as)) ->
33+ (m : Nat ** (Vect m (a : alpha ** So (p a)), So (m > Z)))
34+filterTagP {n = S m} p (a :: as) q with (p a)
35+ | True = (_
36+ **
37+ ((a ** believe_me Oh)
38+ ::
39+ (fst (getProof (filterTagP p as (believe_me Oh)))),
40+ Oh
41+ )
42+ )
43+ | False = filterTagP p as (believe_me Oh)
44+
45+vfoldl : (P : Nat -> Type) ->
46+ ((x : Nat) -> P x -> a -> P (S x)) -> P Z
47+ -> Vect m a -> P m
48+vfoldl P cons nil (x :: xs)
49+ = vfoldl (\k => P (S k)) (\ n => cons (S n)) (cons Z nil x) xs
50+
51+
52+total soElim : (C : (b : Bool) -> So b -> Type) ->
53+ C True Oh ->
54+ (b : Bool) -> (s : So b) -> (C b s)
55+soElim C coh True Oh = coh
56+
57+soFalseElim : So False -> a
58+soFalseElim x = void (soElim C () False x)
59+ where
60+ C : (b : Bool) -> So b -> Type
61+ C True s = ()
62+ C False s = Void
63+
64+soTrue : So b -> b = True
65+soTrue {b = False} x = soFalseElim x
66+soTrue {b = True} x = Refl
67+
68+class Eq alpha => ReflEqEq alpha where
69+ reflexive_eqeq : (a : alpha) -> So (a == a)
70+
71+modifyFun : (Eq alpha) =>
72+ (alpha -> beta) ->
73+ (alpha, beta) ->
74+ (alpha -> beta)
75+modifyFun f (a, b) a' = if a' == a then b else f a'
76+
77+modifyFunLemma : (ReflEqEq alpha) =>
78+ (f : alpha -> beta) ->
79+ (ab : (alpha, beta)) ->
80+ modifyFun f ab (fst ab) = snd ab
81+modifyFunLemma f (a,b) =
82+ rewrite soTrue (reflexive_eqeq a) in Refl
83+
84+
85+Matrix : Type -> Nat -> Nat -> Type
86+Matrix a n m = Vect n (Vect m a)
87+
88+mytranspose : Matrix a (S n) (S m) -> Matrix a (S m) (S n)
89+mytranspose ((x:: []) :: []) = [[x]]
90+mytranspose [x :: y :: xs] = [x] :: (mytranspose [y :: xs])
91+mytranspose (x :: y :: xs)
92+ = let tx = mytranspose [x] in
93+ let ux = mytranspose (y :: xs) in zipWith (++) tx ux
94+
95+using (A : Type, B : A->Type, C : Type)
96+ foo2 : ((x:A) -> B x -> C) -> ((x:A ** B x) -> C)
97+ foo2 f p = f (getWitness p) (getProof p)
98+
99+
100+m_add : Maybe (Either Bool Int) -> Maybe (Either Bool Int) ->
101+ Maybe (Either Bool Int)
102+m_add x y = do x' <- x -- Extract value from x
103+ y' <- y -- Extract value from y
104+ case x' of
105+ Left _ => Nothing
106+ Right _ => Nothing
107+
108+data Ty = TyBool
109+
110+data Id a = I a
111+
112+interpTy : Ty -> Type
113+interpTy TyBool = Id Bool
114+
115+data Term : Ty -> Type where
116+ TLit : Bool -> Term TyBool
117+ TNot : Term TyBool -> Term TyBool
118+
119+map : (a -> b) -> Id a -> Id b
120+map f (I x) = I (f x)
121+
122+interp : Term t -> interpTy t
123+interp (TLit x) = I x
124+interp (TNot x) = map not (interp x)
125+
126+data Result str a = Success str a | Failure String
127+
128+instance Functor (Result str) where
129+ map f (Success s x) = Success s (f x)
130+ map f (Failure e ) = Failure e
131+
132+ParserT : (Type -> Type) -> Type -> Type -> Type
133+ParserT m str a = str -> m (Result str a)
134+
135+ap : Monad m => ParserT m str (a -> b) -> ParserT m str a ->
136+ ParserT m str b
137+ap f x = \s => do f' <- f s
138+ case f' of
139+ Failure e => (pure (Failure e))
140+ Success s' g => x s' >>= pure . map g
141+
142+X : Nat -> Type
143+X t = (c : Nat ** So (c < 5))
144+
145+column : X t -> Nat
146+column = getWitness
147+
148+data Action = Left | Ahead | Right
149+
150+admissible : X t -> Action -> Bool
151+admissible {t} x Ahead = column {t} x == 0 || column {t} x == 4
152+admissible {t} x Left = column {t} x <= 2
153+admissible {t} x Right = column {t} x >= 2
154+
155+
156+class Set univ where
157+ member : univ -> univ -> Type
158+
159+isSubsetOf : Set univ => univ -> univ -> Type
160+isSubsetOf {univ} a b = (c : univ) -> (member c a) -> (member c b)
161+
162+class Set univ => HasPower univ where
163+ Powerset : (a : univ) ->
164+ Sigma univ (\Pa => (c : univ) ->
165+ (isSubsetOf c a) -> member c Pa)
166+
167+powerset : HasPower univ => univ -> univ
168+powerset {univ} a = getWitness (Powerset a)
169+
170+mapFilter : (alpha -> beta) ->
171+ (alpha -> Bool) ->
172+ Vect n alpha ->
173+ (n : Nat ** Vect n beta)
174+mapFilter f p Nil = (_ ** Nil)
175+mapFilter f p (a :: as) with (p a)
176+ | True = (_ ** (f a) :: (getProof (mapFilter f p as)))
177+ | False = mapFilter f p as
178+
179+
test/reg005/expecteddeleted

No changes to the content.

test/reg005/reg005.idrdeleted−12
@@ -1,12 +0,0 @@
1−module reg032
2−
3−import Data.Fin
4−
5−zfin : Fin 1
6−zfin = 0
7−
8−data Infer = MkInf a
9−
10−foo : Infer
11−foo = MkInf (the (Fin 1) 0)
12−
test/reg005/rundeleted−3
@@ -1,3 +0,0 @@
1−#!/usr/bin/env bash
2−idris $@ reg005.idr --check
3−rm -f *.ibc
test/reg009/expecteddeleted

No changes to the content.

test/reg009/reg009.lidrdeleted−21
@@ -1,21 +0,0 @@
1−> import Data.So
2−> import Data.Vect
3−
4−> isAnyBy : (alpha -> Bool) -> (n : Nat ** Vect n alpha) -> Bool
5−> isAnyBy _ (_ ** Nil) = False
6−> isAnyBy p (_ ** (a :: as)) = p a || isAnyBy p (_ ** as)
7−
8−> filterTagP : (p : alpha -> Bool) ->
9−> (as : Vect n alpha) ->
10−> So (isAnyBy p (n ** as)) ->
11−> (m : Nat ** (Vect m (a : alpha ** So (p a)), So (m > Z)))
12−> filterTagP {n = S m} p (a :: as) q with (p a)
13−> | True = (_
14−> **
15−> ((a ** believe_me Oh)
16−> ::
17−> (fst (getProof (filterTagP p as (believe_me Oh)))),
18−> Oh
19−> )
20−> )
21−> | False = filterTagP p as (believe_me Oh)
test/reg009/rundeleted−3
@@ -1,3 +0,0 @@
1−#!/usr/bin/env bash
2−idris $@ reg009.lidr --check
3−rm -f reg009 *.ibc
test/reg011/expecteddeleted

No changes to the content.

test/reg011/reg011.idrdeleted−11
@@ -1,11 +0,0 @@
1−import Data.Vect
2−
3−vfoldl : (P : Nat -> Type) ->
4− ((x : Nat) -> P x -> a -> P (S x)) -> P Z
5− -> Vect m a -> P m
6−-- vfoldl P cons nil []
7−-- = nil
8−vfoldl P cons nil (x :: xs)
9− = vfoldl (\k => P (S k)) (\ n => cons (S n)) (cons Z nil x) xs
10−-- vfoldl P cons nil (x :: xs)
11−-- = vfoldl (\n => P (S n)) (\ n => cons _) (cons _ nil x) xs
test/reg011/rundeleted−3
@@ -1,3 +0,0 @@
1−#!/usr/bin/env bash
2−idris $@ reg011.idr --check
3−rm -f *.ibc
test/reg012/expecteddeleted

No changes to the content.

test/reg012/reg012.lidrdeleted−36
@@ -1,36 +0,0 @@
1−> import Data.So
2−
3−> total soElim : (C : (b : Bool) -> So b -> Type) ->
4−> C True Oh ->
5−> (b : Bool) -> (s : So b) -> (C b s)
6−> soElim C coh True Oh = coh
7−
8−> soFalseElim : So False -> a
9−> soFalseElim x = void (soElim C () False x)
10−> where
11−> C : (b : Bool) -> So b -> Type
12−> C True s = ()
13−> C False s = Void
14−
15−> soTrue : So b -> b = True
16−> soTrue {b = False} x = soFalseElim x
17−> soTrue {b = True} x = Refl
18−
19−> class Eq alpha => ReflEqEq alpha where
20−> reflexive_eqeq : (a : alpha) -> So (a == a)
21−
22−> modifyFun : (Eq alpha) =>
23−> (alpha -> beta) ->
24−> (alpha, beta) ->
25−> (alpha -> beta)
26−> modifyFun f (a, b) a' = if a' == a then b else f a'
27−
28−> modifyFunLemma : (ReflEqEq alpha) =>
29−> (f : alpha -> beta) ->
30−> (ab : (alpha, beta)) ->
31−> modifyFun f ab (fst ab) = snd ab
32−> modifyFunLemma f (a,b) =
33−> rewrite soTrue (reflexive_eqeq a) in Refl
34−
35− replace {P = \ z => ifThenElse (a == a) b (f a) = ifThenElse z b (f a)}
36− (soTrue (reflexive_eqeq a)) Refl
test/reg012/rundeleted−3
@@ -1,3 +0,0 @@
1−#!/usr/bin/env bash
2−idris $@ reg012.lidr --check
3−rm -f *.ibc
test/reg014/expecteddeleted

No changes to the content.

test/reg014/reg014.idrdeleted−14
@@ -1,14 +0,0 @@
1−module reg014
2−
3−import Data.Vect
4−
5−Matrix : Type -> Nat -> Nat -> Type
6−Matrix a n m = Vect n (Vect m a)
7−
8−mytranspose : Matrix a (S n) (S m) -> Matrix a (S m) (S n)
9−mytranspose ((x:: []) :: []) = [[x]]
10−mytranspose [x :: y :: xs] = [x] :: (mytranspose [y :: xs])
11−mytranspose (x :: y :: xs)
12− = let tx = mytranspose [x] in
13− let ux = mytranspose (y :: xs) in zipWith (++) tx ux
14−
test/reg014/rundeleted−3
@@ -1,3 +0,0 @@
1−#!/usr/bin/env bash
2−idris $@ reg014.idr --check
3−rm -f *.ibc
test/reg015/expecteddeleted

No changes to the content.

test/reg015/reg015.idrdeleted−3
@@ -1,3 +0,0 @@
1−using (A : Type, B : A->Type, C : Type)
2− foo : ((x:A) -> B x -> C) -> ((x:A ** B x) -> C)
3− foo f p = f (getWitness p) (getProof p)
test/reg015/rundeleted−3
@@ -1,3 +0,0 @@
1−#!/usr/bin/env bash
2−idris $@ reg015.idr --check
3−rm -f *.ibc
test/reg019/expecteddeleted

No changes to the content.

test/reg019/reg019.idrdeleted−7
@@ -1,7 +0,0 @@
1−m_add : Maybe (Either Bool Int) -> Maybe (Either Bool Int) ->
2− Maybe (Either Bool Int)
3−m_add x y = do x' <- x -- Extract value from x
4− y' <- y -- Extract value from y
5− case x' of
6− Left _ => Nothing
7− Right _ => Nothing
test/reg019/rundeleted−3
@@ -1,3 +0,0 @@
1−#!/usr/bin/env bash
2−idris $@ reg019.idr --check
3−rm -f *.ibc
test/reg021/expecteddeleted

No changes to the content.

test/reg021/reg021.idrdeleted−22
@@ -1,22 +0,0 @@
1−module Main
2−
3−%default total
4−
5−data Ty = TyBool
6−
7−data Id a = I a
8−
9−interpTy : Ty -> Type
10−interpTy TyBool = Id Bool
11−
12−data Term : Ty -> Type where
13− TLit : Bool -> Term TyBool
14− TNot : Term TyBool -> Term TyBool
15−
16−map : (a -> b) -> Id a -> Id b
17−map f (I x) = I (f x)
18−
19−interp : Term t -> interpTy t
20−interp (TLit x) = I x
21−interp (TNot x) = map not (interp x)
22−
test/reg021/rundeleted−3
@@ -1,3 +0,0 @@
1−#!/usr/bin/env bash
2−idris $@ reg021.idr --check
3−rm -f *.ibc
test/reg022/expecteddeleted

No changes to the content.

test/reg022/reg022.idrdeleted−18
@@ -1,18 +0,0 @@
1−module reg022
2−
3−data Result str a = Success str a | Failure String
4−
5−instance Functor (Result str) where
6− map f (Success s x) = Success s (f x)
7− map f (Failure e ) = Failure e
8−
9−ParserT : (Type -> Type) -> Type -> Type -> Type
10−ParserT m str a = str -> m (Result str a)
11−
12−ap : Monad m => ParserT m str (a -> b) -> ParserT m str a ->
13− ParserT m str b
14−ap f x = \s => do f' <- f s
15− case f' of
16− Failure e => (pure (Failure e))
17− Success s' g => x s' >>= pure . map g
18−
test/reg022/rundeleted−3
@@ -1,3 +0,0 @@
1−#!/usr/bin/env bash
2−idris $@ reg022.idr --check
3−rm -f *.ibc
test/reg026/expecteddeleted

No changes to the content.

test/reg026/reg026.idrdeleted−16
@@ -1,16 +0,0 @@
1−module Test
2−
3−import Data.So
4−
5−X : Nat -> Type
6−X t = (c : Nat ** So (c < 5))
7−
8−column : X t -> Nat
9−column = getWitness
10−
11−data Action = Left | Ahead | Right
12−
13−admissible : X t -> Action -> Bool
14−admissible {t} x Ahead = column {t} x == 0 || column {t} x == 4
15−admissible {t} x Left = column {t} x <= 2
16−admissible {t} x Right = column {t} x >= 2
test/reg026/rundeleted−3
@@ -1,3 +0,0 @@
1−#!/usr/bin/env bash
2−idris $@ reg026.idr --check reg026
3−rm -f *.ibc
test/reg030/expecteddeleted

No changes to the content.

test/reg030/reg030.idrdeleted−15
@@ -1,15 +0,0 @@
1−import Control.Isomorphism
2−
3−class Set univ where
4− member : univ -> univ -> Type
5−
6−isSubsetOf : Set univ => univ -> univ -> Type
7−isSubsetOf {univ} a b = (c : univ) -> (member c a) -> (member c b)
8−
9−class Set univ => HasPower univ where
10− Powerset : (a : univ) ->
11− Sigma univ (\Pa => (c : univ) ->
12− (isSubsetOf c a) -> member c Pa)
13−
14−powerset : HasPower univ => univ -> univ
15−powerset {univ} a = getWitness (Powerset a)
test/reg030/rundeleted−3
@@ -1,3 +0,0 @@
1−#!/usr/bin/env bash
2−idris $@ reg030.idr --check
3−rm -f *.ibc
test/reg033/expecteddeleted

No changes to the content.

test/reg033/reg033.idrdeleted−12
@@ -1,12 +0,0 @@
1−import Data.Vect
2−
3−mapFilter : (alpha -> beta) ->
4− (alpha -> Bool) ->
5− Vect n alpha ->
6− (n : Nat ** Vect n beta)
7−mapFilter f p Nil = (_ ** Nil)
8−mapFilter f p (a :: as) with (p a)
9− | True = (_ ** (f a) :: (getProof (mapFilter f p as)))
10− | False = mapFilter f p as
11−
12−
test/reg033/rundeleted−3
@@ -1,3 +0,0 @@
1−#!/usr/bin/env bash
2−idris $@ reg033.idr --check
3−rm -f reg033 *.ibc