Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Simon Peyton Jones <simonpj <at> microsoft.com>
Subject: patch applied (ghc): relaxed instance termination test
Newsgroups: gmane.comp.lang.haskell.cvs.ghc
Date: Thursday 9th February 2006 10:24:20 UTC (over 11 years ago)
Mon Feb  6 03:16:51 PST 2006  Ross Paterson 
  * relaxed instance termination test
  
  With -fglasgow-exts but not -fallow-undecidable-instances, GHC 6.4
  requires that instances be of the following form:
  
   (1) each assertion in the context must constrain distinct variables
       mentioned in the head, and
  
   (2) at least one argument of the head must be a non-variable type.
  
  This patch replaces these rules with the requirement that each assertion
  in the context satisfy
  
   (1) no variable has more occurrences in the assertion than in the head,
and
  
   (2) the assertion has fewer constructors and variables (taken together
       and counting repetitions) than the head.
  
  This allows all instances permitted by the old rule, plus such instances
as
  
         instance C a
         instance Show (s a) => Show (Sized s a)
         instance (Eq a, Show b) => C2 a b
         instance C2 Int a => C3 Bool [a]
         instance C2 Int a => C3 [a] b
         instance C4 a a => C4 [a] [a]
  
  but still ensures that under any substitution assertions in the context
  will be smaller than the head, so context reduction must terminate.
  
  This is probably the best we can do if we consider each instance in
  isolation.

    M ./ghc/compiler/typecheck/TcInstDcls.lhs -1 +3
    M! ./ghc/compiler/typecheck/TcMType.lhs -21 +92
 
CD: 3ms