On Wed, Jun 20, 2012 at 04:56:01PM +0000, Simon Peyton-Jones wrote: > Serge > > I hope you are well. > > I'm making a significant simplification to the type inference engine, > which will have a small knock-on effect in DoCon. > > I implemented a VERY DELICATE HACK to solve your problem before, but it > has become a significant problem to maintain the hack, so I'm taking it out. > > See http://hackage.haskell.org/trac/ghc/ticket/4361, and the comments I > have added there, which tell you what change to make. It's very minor! > > This will take effect from GHC 7.6 onwards. Thanks > > Simon

This is on Ticket #4361 "(closed bug: fixed)" about compiling DoCon. Its story is as follows. * 7.4.0 failed to compile the module Pol3_ in DoCon due to 1) a certain GHC manner of constraint simplification (as Simon wrote) 2) a due to complex enough constraints used in DoCon, in particular, instance (LinSolvRing (Pol a), CommutativeRing a) => LinSolvRing (UPol (Pol a)) set in Pol3_.hs (I do not know how to simplify this constraint without loosing generality). * 7.4.1 does compile it, but, as Simon wrote, applies for this a very specific and unstable compilation method. * 7.6+ removes this latter method, and Simon P. Jones concludes > Happily, it's extremely easy to fix your source code in either of > these two ways: > > * If you use -XMonoLocalBinds (which is in any case implied by -XGADTs > and -XTypeFamilies), then GHC won't generalise the definition of x > in the example, and all will be well. > > * Alterantively, give a type signature for x, thus (in this case) > > moduloBasisx p = let x :: () > x = upLinSolvRing p > in () Now, I am trying ghc-7.6.1.20121207 built from source on Debian Linux. I. I try adding -XMonoLocalBinds for compiling DoCon: -- doco.cabal ------------------------------- ... ghc-options: -fno-warn-overlapping-patterns -fwarn-unused-binds -fwarn-unused-matches -fwarn-unused-imports -XMonoLocalBinds -O ---------------------------------------------- `make build' fails at the first module: ------------------------------------------------------ module Prelude_ where ... instance (DShow a, DShow b) => DShow (a, b) ... where dShows opts (x, y) = showChar '(' . shows1 x . showString sep . shows1 y . showChar ')' -- line 628 where opts' = addToShowOptions (- 1) $ opts {parInShow = Parens} sep = fieldSeparator opts shows1 x = (case parInShow opts of Parens -> id _ -> unparensUpper "()") . dShows opts' x aShows (a, b) = showString "(pair " . aShows a . showChar ' ' . aShows b . showChar ')' ------------------------------------------------------ The report is runghc Setup.hs build Building docon-2.12... Preprocessing library docon-2.12... [ 1 of 84] Compiling Prelude_ ( Prelude_.hs, dist/build/Prelude_.o ) Prelude_.hs:628:32: Could not deduce (a ~ b) from the context (DShow a, DShow b) bound by the instance declaration at Prelude_.hs:622:10-43 `a' is a rigid type variable bound by the instance declaration at Prelude_.hs:622:10 `b' is a rigid type variable bound by the instance declaration at Prelude_.hs:622:10 In the first argument of `shows1', namely `y' In the first argument of `(.)', namely `shows1 y' In the second argument of `(.)', namely shows1 y . showChar ')' ... ----------------------- The line 628 is marked in the code as "-- line 628". I suspect that besides -XMonoLocalBinds, I need also to add some explicit type signatures, for example, dShows opts (x, y) = showChar '(' . shows1 (x :: DShow a => a) . ... Because GHC, probably, finds some contradiction in applying shows1 to x :: a and to y :: b. II. My another attempt will be removing -XMonoLocalBinds (with this, it compiles many modules and stops at Pol3.hs) and inserting a type signature in an appropriate place (this will also need to add ScopedTypeVariables + `forall' -- thanks to people for hints ). If (II) works, then it will be, probably less restrictive than (I). This is just the current report of my attempt to compile DoCon with GHC. ------ Sergei _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs