Ticket #322 (assigned bug: None)

Opened 4 years ago

Last modified 2 months ago

fromInteger-related pattern match overlap warnings

Reported by: ashley-y Assigned to: simonpj (accepted)
Priority: normal Milestone: _|_
Component: Compiler Version: 6.4
Severity: normal Keywords: warnings
Cc: Difficulty: Unknown
Test Case: ds060 Operating System: Unknown/Multiple
Architecture: Unknown/Multiple

Description (Last modified by igloo)

The compiler incorrectly gives "Warning: Pattern match(es) are 
overlapped" for this file:

{-# OPTIONS -Werror #-}

module Buggy 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
	f _ = 3

Change History

11/29/05 20:15:55 changed by nobody

Logged In: NO 

If we define the first line as:

f (Just 1) = 1

there is no problem. 

10/19/06 09:35:33 changed by igloo

  • description changed.
  • testcase set to ds060.
  • difficulty set to Unknown.
  • architecture set to Unknown.
  • milestone set to _|_.
  • keywords set to warnings.
  • os set to Unknown.

05/07/07 02:16:18 changed by simonmar

See #595

09/30/08 08:37:13 changed by simonmar

  • architecture changed from Unknown to Unknown/Multiple.

09/30/08 08:50:58 changed by simonmar

  • os changed from Unknown to Unknown/Multiple.