1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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)
|