DoCon and GHC

Serge D. Mechveliani mechvel at botik.ru
Wed Jan 2 20:21:15 CET 2013


On Wed, Jan 02, 2013 at 05:21:43PM +0000, Simon Peyton-Jones wrote:
> Serge
> 
> That's odd. I've tried with both 7.6 and HEAD, and both fail on T_cubeext 
> thus:
> T_cubeext.hs:102:10:
>     Overlapping instances for LinSolvRing (UPol k)
>       arising from a use of `upEucRing'
>     Matching instances:
>       instance [overlap ok] EuclideanRing a => LinSolvRing (UPol a)
>         -- Defined in `docon-2.12:Pol2_'
>       instance [overlap ok] (LinSolvRing (Pol a), CommutativeRing a) =>
>                             LinSolvRing (UPol (Pol a))
>         -- Defined in `docon-2.12:Pol3_'
>     (The choice depends on the instantiation of `k'
>      To pick the first instance above, use -XIncoherentInstances
>      when compiling the other instance declarations)
>     In the expression: upEucRing unA Map.empty
>     In an equation for `dA': dA = upEucRing unA Map.empty
> 
> I am using ghc-7.6 from Dec 3 (ie *later* than the released GHC 7.6.1), 
> so perhaps the difference in error message is due to a bug in 7.6.1 that's 
> fixed in my version.  I suggest you use the 7.6.2 release candidate.

Yes, the candidate of  7.6.1.20121207


> Anyway, the error message looks entirely legitimate.  It really does 
> matter how 'k' is instantiated!  I have no idea how it compiled before.
 

ghc-7.4.1  compiles everything in DoCon, and it is the last such version. 


> The solution is to add (EuclideanRing k) to the type sig of cubicExt.  
> Then it compiles all the way up to the top.

But the DoCon declares
              class (EuclideanRing a, FactorizationRing a) => Field a 

(EuclideanRing  is a superclass for  Field),
and the test declares
    cubicExt :: (Field k, FactorizationRing (UPol k)) =>
                 k -> k -> Domains1 k -> (Domains1 (E k), [E k], k -> E k)

So, why the compiler does not `extract'  EuclideanRing k  from  Field k
?

Regards,

------
Sergei



> | -----Original Message-----
> | From: glasgow-haskell-bugs-bounces at haskell.org [mailto:glasgow-haskell-
> | bugs-bounces at haskell.org] On Behalf Of Serge D. Mechveliani
> | Sent: 21 December 2012 18:46
> | To: Simon Peyton-Jones
> | Cc: glasgow-haskell-bugs at haskell.org
> | Subject: Re: DoCon and GHC
> | 
> | On Fri, Dec 21, 2012 at 01:45:04PM +0000, Simon Peyton-Jones wrote:
> | > OK, do this
> | >
> | > * {-# LANGUAGE ScopedTypeVariables, MonoLocalBinds #-}
> | >
> | > * import Categs( Domains1 )
> | >
> | > * Add type sig for dP'
> | >     dP' :: (LinSolvRing (Pol a), CommutativeRing a) => Domains1 (Pol
> | > a)
> | >
> | > Then it compiles.
> | >
> | > You are very close to the edge of what can be done!
> | 
> | 
> | It works. Thank you.
> | 
> | There remains only a single unlucky module:  T_cubeext.
> | The test  demotest/Main  works with exception of  T_cubeext, but I need
> | T_cubeext.cubicExt  to work.
> | 
> | Please, continue the test with
> | 
> |   make install
> |   cd demotest
> |   ghc $doconCpOpt --make Main
> | 
> | (for  $doconCpOpt =
> |   -fwarn-unused-matches -fwarn-unused-binds -fwarn-unused-imports
> |   -fno-warn-overlapping-patterns -XRecordWildCards -XNamedFieldPuns
> |   -XFlexibleContexts -XMultiParamTypeClasses -XUndecidableInstances
> |   -XTypeSynonymInstances -XFlexibleInstances -XOverlappingInstances ).
> | 
> | It reports
> | 
> | ------------------------------------------------------------------
> | ...
> | T_cubeext.hs:102:20:
> |     Could not deduce (k ~ k1)
> |     from the context (Field k, FactorizationRing (UPol k))
> |       bound by the type signature for
> |                  cubicExt :: (Field k, FactorizationRing (UPol k)) =>
> |                              k -> k -> Domains1 k -> (Domains1 (E k), [E
> | k], k -> E k)
> |       at T_cubeext.hs:(79,13)-(80,69)
> |     or from (Field k1, FactorizationRing (UPol k1))
> |       bound by the type signature for
> |                  unA :: (Field k1, FactorizationRing (UPol k1)) => UPol
> | k1
> |       at T_cubeext.hs:101:9-56
> |       `k' is a rigid type variable bound by
> |           the type signature for
> |             cubicExt :: (Field k, FactorizationRing (UPol k)) =>
> |                         k -> k -> Domains1 k -> (Domains1 (E k), [E k],
> | k -> E k)
> |           at T_cubeext.hs:79:13
> |       `k1' is a rigid type variable bound by
> |            the type signature for
> |              unA :: (Field k1, FactorizationRing (UPol k1)) => UPol k1
> |            at T_cubeext.hs:101:9
> |     Expected type: Domains1 k1
> |       Actual type: Domains1 k
> |     In the second argument of `cToUPol', namely `dK'
> |     In the expression: cToUPol "d" dK unK
> |     In an equation for `unA': unA = cToUPol "d" dK unK
> | 
> | T_cubeext.hs:105:7:
> |     Overlapping instances for LinSolvRing (UPol k1)
> |       arising from a use of `upEucRing'
> |     Matching instances:
> |       instance [overlap ok] EuclideanRing a => LinSolvRing (UPol a)
> |         -- Defined in `docon-2.12:Pol2_'
> |       instance [overlap ok] (LinSolvRing (Pol a), CommutativeRing a) =>
> |                             LinSolvRing (UPol (Pol a)) ...
> | ------------------------------------------------------------------
> | 
> | I tried  {-# LANGUAGE ScopedTypeVariables, MonoLocalBinds #-}, and
> | setting type signatures in various parts in  cubicExt.
> | But this does not help.
> | 
> | There is another point. In
> |          ``cubicExt :: (Field k, FactorizationRing (UPol k)) => ...''
> | 
> | the part       ``, FactorizationRing (UPol k)''                  (1)
> | 
> | was always considered as parasitic.  ghc-7.4.1  needs (1) to work, and
> | at least  ghc-7.4.1  does compile the test.
> | 
> | I thought, may be, the future compilers will allow to omit this part.
> | At least it is desirable for  ghc-7.6.2  to do the test in any variant,
> | with (1) or without it.



More information about the Glasgow-haskell-users mailing list