Major Overhaul of Pattern Match Checking (Fixes #595)
[ghc.git] / testsuite / tests / pmcheck / should_compile / T322.hs
1 {-# OPTIONS -fwarn-incomplete-patterns -fwarn-overlapping-patterns -Werror #-}
2
3 module T322 where
4
5 instance (Num a) => Num (Maybe a) where
6 (Just a) + (Just b) = Just (a + b)
7 _ + _ = Nothing
8
9 (Just a) - (Just b) = Just (a - b)
10 _ - _ = Nothing
11
12 (Just a) * (Just b) = Just (a * b)
13 _ * _ = Nothing
14
15 negate (Just a) = Just (negate a)
16 negate _ = Nothing
17
18 abs (Just a) = Just (abs a)
19 abs _ = Nothing
20
21 signum (Just a) = Just (signum a)
22 signum _ = Nothing
23
24 fromInteger = Just . fromInteger
25
26 f :: Maybe Int -> Int
27 f 1 = 1
28 f Nothing = 2
29 f _ = 3