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