blob: b822605742d3147819d3508703d75bcc537d888c (
plain)
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
|
-- Test for trac #322
module ShouldCompile where
instance (Num a) => Num (Maybe a) where
(Just a) + (Just b) = Just (a + b)
_ + _ = Nothing
(Just a) - (Just b) = Just (a - b)
_ - _ = Nothing
(Just a) * (Just b) = Just (a * b)
_ * _ = Nothing
negate (Just a) = Just (negate a)
negate _ = Nothing
abs (Just a) = Just (abs a)
abs _ = Nothing
signum (Just a) = Just (signum a)
signum _ = Nothing
fromInteger = Just . fromInteger
f :: Maybe Int -> Int
f 1 = 1
f Nothing = 2 -- Gives bogus "Warning: Pattern match(es) are overlapped"
f _ = 3
|