summaryrefslogtreecommitdiff
path: root/testsuite/tests/deSugar/should_compile/ds020.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/deSugar/should_compile/ds020.hs')
-rw-r--r--testsuite/tests/deSugar/should_compile/ds020.hs57
1 files changed, 57 insertions, 0 deletions
diff --git a/testsuite/tests/deSugar/should_compile/ds020.hs b/testsuite/tests/deSugar/should_compile/ds020.hs
new file mode 100644
index 0000000000..184c857a8f
--- /dev/null
+++ b/testsuite/tests/deSugar/should_compile/ds020.hs
@@ -0,0 +1,57 @@
+-- !!! ds020 -- lazy patterns (in detail)
+--
+
+{-# LANGUAGE NPlusKPatterns #-}
+
+module ShouldCompile where
+
+a ~([],[],[]) = []
+a ~(~[],~[],~[]) = []
+
+b ~(x:xs:ys) = []
+b ~(~x: ~xs: ~ys) = []
+
+c ~x ~ _ ~11111 ~3.14159265 = x
+
+d 11 = 4
+d 12 = 3
+d ~(n+4) = 2
+d ~(n+43) = 1
+d ~(n+999) = 0
+
+f ~(x@[]) = []
+f x@(~[]) = []
+
+g ~(~(~(~([])))) = []
+
+-- pattern bindings (implicitly lazy)
+
+([],[],[]) = ([],[],[])
+(~[],~[],~[]) = ([],[],[])
+
+(x1: xs1: ys1) = []
+(~x: ~xs: ~ys) = []
+
+(x2 : xs2: ys2) | eq2 = []
+ | eq3 = [x2]
+ | eq4 = [x2]
+ | True = []
+ where
+ eq2 = (2::Int) == (4::Int)
+ eq3 = (3::Int) == (3::Int)
+ eq4 = (4::Int) == (2::Int)
+
+(x3,y3) | x3 > 3 = (4, 5)
+ | x3 <= 3 = (2, 3)
+-- above: x & y should both be \bottom.
+
+(x4,(y4,(z4,a4))) | eq2 = ('a',('a',('a','a')))
+ | eq3 = ('b',('b',('b','b')))
+ | eq4 = ('c',('c',('c','c')))
+ | True = ('d',('d',('d','d')))
+ where
+ eq2 = (2::Int) == (4::Int)
+ eq3 = (3::Int) == (3::Int)
+ eq4 = (4::Int) == (2::Int)
+
+