Testsuite: tabs -> spaces [skip ci]
[ghc.git] / testsuite / tests / deSugar / should_compile / ds020.hs
1 -- !!! ds020 -- lazy patterns (in detail)
2 --
3
4 {-# LANGUAGE NPlusKPatterns #-}
5
6 module ShouldCompile where
7
8 a ~([],[],[]) = []
9 a ~(~[],~[],~[]) = []
10
11 b ~(x:xs:ys) = []
12 b ~(~x: ~xs: ~ys) = []
13
14 c ~x ~ _ ~11111 ~3.14159265 = x
15
16 d 11 = 4
17 d 12 = 3
18 d ~(n+4) = 2
19 d ~(n+43) = 1
20 d ~(n+999) = 0
21
22 f ~(x@[]) = []
23 f x@(~[]) = []
24
25 g ~(~(~(~([])))) = []
26
27 -- pattern bindings (implicitly lazy)
28
29 ([],[],[]) = ([],[],[])
30 (~[],~[],~[]) = ([],[],[])
31
32 (x1: xs1: ys1) = []
33 (~x: ~xs: ~ys) = []
34
35 (x2 : xs2: ys2) | eq2 = []
36 | eq3 = [x2]
37 | eq4 = [x2]
38 | True = []
39 where
40 eq2 = (2::Int) == (4::Int)
41 eq3 = (3::Int) == (3::Int)
42 eq4 = (4::Int) == (2::Int)
43
44 (x3,y3) | x3 > 3 = (4, 5)
45 | x3 <= 3 = (2, 3)
46 -- above: x & y should both be \bottom.
47
48 (x4,(y4,(z4,a4))) | eq2 = ('a',('a',('a','a')))
49 | eq3 = ('b',('b',('b','b')))
50 | eq4 = ('c',('c',('c','c')))
51 | True = ('d',('d',('d','d')))
52 where
53 eq2 = (2::Int) == (4::Int)
54 eq3 = (3::Int) == (3::Int)
55 eq4 = (4::Int) == (2::Int)
56
57