summaryrefslogtreecommitdiff
path: root/testsuite/tests/deSugar/should_compile/ds060.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/deSugar/should_compile/ds060.hs')
-rw-r--r--testsuite/tests/deSugar/should_compile/ds060.hs25
1 files changed, 25 insertions, 0 deletions
diff --git a/testsuite/tests/deSugar/should_compile/ds060.hs b/testsuite/tests/deSugar/should_compile/ds060.hs
new file mode 100644
index 0000000000..b822605742
--- /dev/null
+++ b/testsuite/tests/deSugar/should_compile/ds060.hs
@@ -0,0 +1,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
+