on master help sign in
Add test for VList view

In particular it checks that everything is erased which should be, so that vlist definitely runs in linear time

commit069a2ac9f5290535494b6b50293e5c0c35ea4abf authorEdwin Brady <ecb10@st-andrews.ac.uk> dateTue 12 Apr 2016, 16:40 (11 years ago) parent1d32dd1
4 files changed+39
idris.cabal+3 test/views003/expected+1 test/views003/run+4 test/views003/views003.idr+31
idris.cabal+3
@@ -827,6 +827,9 @@ Extra-source-files:
827827 test/views002/run
828828 test/views002/*.idr
829829 test/views002/expected
830+ test/views003/run
831+ test/views003/*.idr
832+ test/views003/expected
830833
831834 test/docs001/run
832835 test/docs001/input
test/views003/expectednew file+1
@@ -0,0 +1 @@
1+True
test/views003/runnew file+4
@@ -0,0 +1,4 @@
1+#!/usr/bin/env bash
2+${IDRIS:-idris} $@ views003.idr -o views003 --warnreach
3+./views003 10000
4+rm -f views003 *.ibc
test/views003/views003.idrnew file+31
@@ -0,0 +1,31 @@
1+import System
2+import Data.List.Views
3+
4+data Palindrome : List a -> Type where
5+ PNil : Palindrome []
6+ POne : Palindrome [x]
7+ PRec : Palindrome xs -> Palindrome (x :: xs ++ [x])
8+
9+total
10+palindrome : DecEq a => (xs : List a) -> Maybe (Palindrome xs)
11+palindrome xs with (vlist xs)
12+ palindrome [] | VNil = Just PNil
13+ palindrome [x] | VOne = Just POne
14+ palindrome (x :: (ys ++ [y])) | (VCons z) with (decEq x y)
15+ palindrome (y :: (ys ++ [y])) | (VCons urec) | (Yes Refl)
16+ = case palindrome ys | urec of
17+ Nothing => Nothing
18+ Just x => Just (PRec x)
19+ palindrome (x :: (ys ++ [y])) | (VCons z) | (No contra)
20+ = Nothing
21+
22+palinBool : DecEq a => List a -> Bool
23+palinBool xs = case palindrome xs of
24+ Nothing => False
25+ Just _ => True
26+
27+main : IO ()
28+main = do [_, num] <- getArgs
29+ let list = replicate (cast num) 'a'
30+ printLn (palinBool list)
31+