instance scopes in ghci-6.2.1

Simon Peyton-Jones simonpj at microsoft.com
Fri May 7 10:03:51 EDT 2004


OK, this is a real bug in 6.2.1 (and the HEAD actually).
DoCon has lots of modules that contain "orphan instances"; that is,
instance declarations where neither the type nor the class are defined
in the same module.  That means that GHC has to find and load these
module interfaces just in case they contain a relevant instance.

In the case you give, the FactorizationRing Integer interface is in
module Z, but GHCi 6.2.1 doesn't go and load Z (that's the bug).  

I'll fix it.  Meanwhile, I think the only workaround is to say :m Z to
the prompt.  And similarly for any other module with an orphan instance,
namely.

	VecMatr Fraction DPair Z ResRing__ ResPol_ RsePol_
	ResEuc_ ResEuc0_ Pfact3_ Pfact__ EPol_ RPol0_ Pol3_ Pol2_ Pgcd_
Pol1_ UPol0_
	UPol_ Matr0_ Vec_ Vec0_ Fract_ Ring1_ Ring_ Semigr_ Char_ List_
RsePol0_

Sorry about this.  Orphan instances are a royal pain.

Simon

| -----Original Message-----
| From: Serge D. Mechveliani [mailto:mechvel at botik.ru]
| Sent: 07 May 2004 13:09
| To: Simon Peyton-Jones
| Subject: Re: instance scopes in ghci-6.2.1
| 
| Simon,
| 
| Thank you for quick response.
| 
| 
| On Fri, May 07, 2004 at 12:39:38PM +0100, Simon Peyton-Jones wrote:
| > | The interpreter does not find some instances
| > |
| > |   > ghci $pcpdocon
| > |   > ...
| > |    Loading package base ... linking ... done.
| >
| > Can you explain how to reproduce?  What directory?  What is
$pcpdocon?
| >
| >
| > Also I tried to follow the instructions to build docon from scratch
| > (2.06), but got the following error (ghc 6.2.1).  Don't you get
this?
| > Why do I get it if you don't?
| >
| > Simon
| 
| 
| 
| Please, find attached       docon-2.08-pre.zip
| 
| 
| Then, follow   install.txt,    `making' it with  -Onot.
| Then, run from somewhere apart
| 
|   > ghci $pcpdocon
|   > ...
|    Loading package base ... linking ... done.
|    ...
|    Loading package util ... linking ... done.
|    Loading package data ... linking ... done.
|    Loading package docon ... linking ... done.
| 
|   Prelude> :m DExport
|   DExport> factor (10 :: Integer)
|    <interactive>:1:
|     No instance for (Ring0_.FactorizationRing Integer) ...
| 
| 
| The situation is so as described in  install.txt,  notes-2.08.txt,
| please, read them.
| 
| 
| ------------------------------------------------------
| > pol/Pol3_.hs:333:
| >     Could not deduce (EuclideanRing a)
| > 	from the context (LinSolvRing (UPol (Pol a)),
| > 			  LinSolvRing (Pol a),
| > 			  CommutativeRing a,
| > 			  CommutativeRing (UPol (Pol a)),
| > 			  MulMonoid (UPol (Pol a)))
| 
| This is another (remarkable) point:
| the compiler changed its understanding of DoCon program.
| 
| DoCon used hardly the overlapping and undesidable instances, etc.
| And old compliers did understand this highly recursive
| experimental instance setting.
| 
| Now, for  docon-2.08,  I gave up and set  (EuclideanRing a)
| 
| in the context (which does not achieve the intended subtle instance).
| 
| If any user notes this and will want to exploit DoCon with such
| instance, then we will have to find out which complier is better
| at this point.
| 
| -----------------
| Serge Mechveliani
| mechvel at botik.ru
| http://www.botik.ru/~mechvel
| 
| 
| 
| 
| 



More information about the Glasgow-haskell-bugs mailing list