[Haskell-cafe] Why does "instance Ord Pat" causes <<loop>>

Bulat Ziganshin bulat.ziganshin at gmail.com
Mon Dec 8 04:20:10 EST 2008


Hello Martin,

Monday, December 8, 2008, 12:04:06 PM, you wrote:

> Now it took me about a week to realise, that 'instance Ord Pat' causes
> ghc to loop.

>  naive Ord
>  
>> instance Ord Exp

>> instance Ord Pat

i think you just don't learned this part of Haskell. empty
instance declarations like these are possible but they doesn't mean
automatic definition of some suitable compare. they just bring in some
default definitions which may be mutual recursive, such as (==) and
(/=) definitions in Eq class. this is intended to that your define
either (==) or (/=), but compiler doesn't check this, so if you don't
define anything, you will get endless loop

if you want compiler to infer automatic instance definitions, the only
way is to use GHC extension, smth like

deriving instance Ord for Pat


-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com



More information about the Haskell-Cafe mailing list