Re: failure to check completeness in instance declarations

Ross Paterson <[email protected]>
Newsgroups gmane.comp.lang.haskell.hugs.bugs
Message-ID <[email protected]>
On Fri, Mar 21, 2003 at 10:37:59AM -0800, Andrew Tolmach wrote:
> The following file is accepted by hugs (Nov.02 version on linux) without
> complaint.
> 
> data Foo a = Foo a
> 
> instance Eq (Foo a) where
> 
> z = Foo 1 == Foo 2

Incomplete instances are legal in Haskell 98, but this one isn't,
because (==) has a default definition:

	class  Eq a  where
	    (==), (/=) :: a -> a -> Bool
	    x /= y     =  not (x == y)
	    x == y     =  not (x /= y)

> Attempting to evaluate z causes a Segmentation fault (not unreasonably,
> perhaps!).

Segmentation fault is the Hugs implementation of stack overflow :-(
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.