on master help sign in
Merge pull request #1427 from david-christiansen/issue/1318

Make proof arguments to list functions implicit

commit8e94d31e730cf9b71698ad00b87bfd359fa1c6df authorDavid Christiansen <david@davidchristiansen.dk> dateTue 5 Aug 2014, 10:27 (12 years ago) parent946c0da40d07c4
4 files changed+17−16
CHANGELOG+1 libs/prelude/Prelude/List.idr+14−14 test/error004/FunErrTest.idr+1−1 test/error004/expected+1−1
CHANGELOG+1
@@ -3,6 +3,7 @@ New in 0.9.15:
33* Two new tactics: skip and fail. Skip does nothing, and fail takes a string as an argument and produces it as an error.
44* Corresponding reflected tactics Skip and Fail. Reflected Fail takes a list of ErrorReportParts as an argument, like error handlers produce, allowing access to the pretty-printer.
55* Stop showing irrelevant and inaccessible internal names in the interactive prover
6+* The proof arguments in the List library functions are now implicit and solved automatically
67
78New in 0.9.14:
89--------------
libs/prelude/Prelude/List.idr+14−14
@@ -72,9 +72,9 @@ index' _ [] = Nothing
7272
7373||| Get the first element of a non-empty list
7474||| @ ok proof that the list is non-empty
75−head : (l : List a) -> (ok : isCons l = True) -> a
76−head [] refl impossible
77−head (x::xs) p = x
75+head : (l : List a) -> {auto ok : isCons l = True} -> a
76+head [] {ok=refl} impossible
77+head (x::xs) {ok=p} = x
7878
7979||| Attempt to get the first element of a list. If the list is empty, return
8080||| `Nothing`.
@@ -84,9 +84,9 @@ head' (x::xs) = Just x
8484
8585||| Get the tail of a non-empty list.
8686||| @ ok proof that the list is non-empty
87−tail : (l : List a) -> (ok : isCons l = True) -> List a
88−tail [] refl impossible
89−tail (x::xs) p = xs
87+tail : (l : List a) -> {auto ok : isCons l = True} -> List a
88+tail [] {ok=refl} impossible
89+tail (x::xs) {ok=p} = xs
9090
9191||| Attempt to get the tail of a list.
9292|||
@@ -97,10 +97,10 @@ tail' (x::xs) = Just xs
9797
9898||| Retrieve the last element of a non-empty list.
9999||| @ ok proof that the list is non-empty
100−last : (l : List a) -> (ok : isCons l = True) -> a
101−last [] refl impossible
102−last [x] p = x
103−last (x::y::ys) p = last (y::ys) refl
100+last : (l : List a) -> {auto ok : isCons l = True} -> a
101+last [] {ok=refl} impossible
102+last [x] {ok=p} = x
103+last (x::y::ys) {ok=p} = last (y::ys) {ok=refl}
104104
105105||| Attempt to retrieve the last element of a non-empty list.
106106|||
@@ -114,10 +114,10 @@ last' (x::xs) =
114114
115115||| Return all but the last element of a non-empty list.
116116||| @ ok proof that the list is non-empty
117−init : (l : List a) -> (ok : isCons l = True) -> List a
118−init [] refl impossible
119−init [x] p = []
120−init (x::y::ys) p = x :: init (y::ys) refl
117+init : (l : List a) -> {auto ok : isCons l = True} -> List a
118+init [] {ok=refl} impossible
119+init [x] {ok=p} = []
120+init (x::y::ys) {ok=p} = x :: init (y::ys) {ok=refl}
121121
122122||| Attempt to Return all but the last element of a list.
123123|||
test/error004/FunErrTest.idr+1−1
@@ -9,7 +9,7 @@ import Language.Reflection.Utils
99total
1010cadr : (xs : List a)
1111 -> {auto cons1 : isCons xs = True}
12− -> {auto cons2 : isCons (tail xs cons1) = True}
12+ -> {auto cons2 : isCons (tail xs) = True}
1313 -> a
1414cadr (x :: (y :: _)) {cons1=refl} {cons2=refl} = y
1515cadr (x :: []) {cons1=refl} {cons2=refl} impossible
test/error004/expected+1−1
@@ -3,4 +3,4 @@ When elaborating argument cons1 to function FunErrTest.cadr:
33 Could not prove that [] has at least two elements.
44FunErrTest.idr:38:10:When elaborating right hand side of badCadr2:
55When elaborating argument cons2 to function FunErrTest.cadr:
6− Could not prove that tail [(fromInteger 1)] refl has at least two elements.
6+ Could not prove that tail [(fromInteger 1)] has at least two elements.