Skip to content

Commit d69052d

Browse files
Adding more examples to the warn on term holes tests
1 parent 5f8522d commit d69052d

File tree

4 files changed

+51
-22
lines changed

4 files changed

+51
-22
lines changed

tests/tests.cabal

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2628,7 +2628,9 @@ executable typed-holes
26282628
main-is: Main.hs
26292629

26302630
ghc-options: -fplugin=LiquidHaskell
2631-
other-modules: Example1
2631+
other-modules: Example0
2632+
, Example1
2633+
, Example2
26322634
build-depends: base
26332635
, liquid-prelude
26342636
, liquidhaskell

tests/typed-holes/Example0.hs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{-@ LIQUID "--expect-error-containing=Hole Found" @-}
2+
{-@ LIQUID "--warn-on-term-holes" @-}
3+
4+
module Example0 where
5+
hole = undefined
6+
7+
{-@ listLength :: xs:[a] -> {v : Nat | v == len xs} @-}
8+
listLength :: [a] -> Int
9+
listLength [] = hole
10+
listLength (_:xs) = 1 + listLength xs

tests/typed-holes/Example1.hs

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,17 @@
11
{-@ LIQUID "--expect-error-containing=Hole Found" @-}
2-
{-@ LIQUID "--exact-data-cons" @-}
32
{-@ LIQUID "--warn-on-term-holes" @-}
4-
-- Based on https://ucsd-progsys.github.io/liquidhaskell-blog/2016/10/06/structural-induction.lhs/
53

64
module Example1 where
7-
import Prelude hiding ((<>))
8-
import Language.Haskell.Liquid.ProofCombinators ((===), (***), QED(QED), Proof)
9-
10-
hole = undefined
5+
import Language.Haskell.Liquid.ProofCombinators (Proof)
116

12-
{-@ reflect empty @-}
13-
empty :: [a]
14-
empty = []
7+
hole = undefined
158

16-
{-@ infix <> @-}
17-
{-@ reflect <> @-}
18-
(<>) :: [a] -> [a] -> [a]
19-
[] <> xs = xs
20-
(x:xs) <> ys = x : (xs <> ys)
9+
{-@ listLength :: xs:[a] -> {v : Nat | v == len xs} @-}
10+
listLength :: [a] -> Int
11+
listLength [] = 0
12+
listLength (_:xs) = 1 + listLength xs
13+
{-@ measure listLength @-}
2114

22-
{-@ leftId :: x:[a] -> { (empty <> x) == x } @-}
23-
leftId :: [a] -> Proof
24-
leftId x
25-
= empty <> x
26-
=== hole
27-
=== x
28-
*** QED
15+
{-@ listLengthProof :: xs:[a] -> {listLength xs == len xs} @-}
16+
listLengthProof :: [a] -> Proof
17+
listLengthProof = hole

tests/typed-holes/Example2.hs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{-@ LIQUID "--expect-error-containing=Hole Found" @-}
2+
{-@ LIQUID "--exact-data-cons" @-}
3+
{-@ LIQUID "--warn-on-term-holes" @-}
4+
-- Based on https://ucsd-progsys.github.io/liquidhaskell-blog/2016/10/06/structural-induction.lhs/
5+
6+
module Example2 where
7+
import Prelude hiding ((<>))
8+
import Language.Haskell.Liquid.ProofCombinators ((===), (***), QED(QED), Proof)
9+
10+
hole = undefined
11+
12+
{-@ reflect empty @-}
13+
empty :: [a]
14+
empty = []
15+
16+
{-@ infix <> @-}
17+
{-@ reflect <> @-}
18+
(<>) :: [a] -> [a] -> [a]
19+
[] <> xs = xs
20+
(x:xs) <> ys = x : (xs <> ys)
21+
22+
{-@ leftId :: x:[a] -> { (empty <> x) == x } @-}
23+
leftId :: [a] -> Proof
24+
leftId x
25+
= empty <> x
26+
=== hole
27+
=== x
28+
*** QED

0 commit comments

Comments
 (0)