Hello,

I was trying to get darcs 2.5 to compile under ghc7.  Along the way I
learned a few things:

  1. ghc 7.0.1 (the current stable release), has this bug when
  compiling the darcs source (fixed and should appear in next ghc
  release): http://hackage.haskell.org/trac/ghc/ticket/4524

  2. versions of ghc older than 7 cannot change LANGUAGE options per
  file inside of #ifdefs. (I don't have a link to a refrence, but my
  experience shows this to be true and others in #haskell have
  confirmed my experience.)

  3. http://hackage.haskell.org/trac/ghc/blog/LetGeneralisationInGhc7
  says, "The -XGADTs or -XTypeFamilies pragmas switch on
  MonoLocalBinds but, if you want, you can override it with
  -XNoMonoLocalBinds (or the equivalent LANGUAGE pragma). The type
  checker will then do its best to generalise local bindings, and your
  program will almost certainly work. However, I don't know how to
  guarantee any good properties of the type inference algorithm. So I
  think this is ok as as short term fix, but I'd like to encourage you
  to add that handful of type signatures instead."

The gist of #1 is that ghc 7.0.1 panics when compiling 1 module of
darcs when we are passing NoMonoLocaBinds.  Point #2 means we can't
simply use #ifdef to disable NoMonoLocalBinds in that file.  I didn't
check if ghc 6.12 or 6.10 barfs when passed -XNoMonoLocalBinds (an
option neither of them should understand).

Due to point #3, I think the correct way forward is to provide the
extra type signatures and NOT use NoMonoLocalBinds.  Plus, #1 and #2
work together to actually make it MORE difficult to get things working
without the extra type signatures.  Thus, I have based my work off of
Ganesh's 2.5 branch where he added in the type signatures.

I also made things work with mtl 1 or mtl 2.

When this patch bundle is applied to Ganesh's branch, it makes sure
that darcs compiles cleanly under ghc7.0.1 and ghc6.12.3 on OSX 10.5
with either mtl1 or mtl2.  Our standard build screening would be wise
though.

I have not checked if this work applied cleanly to the repo at
http://darcs.net, but the changes are small and I would hope it
applies.

Thanks,
Jason

2 patches for repository http://darcs.vm.spiny.org.uk/~ganesh/darcs-2.5-ghc7-2:

Sun Nov 28 14:44:54 PST 2010  Jason Dagit <da...@codersbase.com>
  * add conditional compilation to support mtl 1 and mtl 2.

Sun Nov 28 14:46:40 PST 2010  Jason Dagit <da...@codersbase.com>
  * loosen constraint on containers package

New patches:

[add conditional compilation to support mtl 1 and mtl 2.
Jason Dagit <da...@codersbase.com>**20101128224454
 Ignore-this: 91363939d1f26bb1e366d38123474278
] hunk ./darcs.cabal 119
   default:     False
   description: A cunning trick to have cabal install build dependencies
 
+flag old_mtl
+  description: Tells us which version of mtl was picked so we can avoid compile errors.
+
 Executable          witnesses
   main-is:          witnesses.hs
 
hunk ./darcs.cabal 162
                       System.Posix.Files
                       System.Posix.IO
       cpp-options:    -DWIN32
+      if flag(old_mtl)
+        cpp-options:  -DMTL1
       c-sources:      src/win32/send_email.c
       build-depends:  unix-compat >= 0.1.2,
                       regex-posix >= 0.94.4 && < 0.95
hunk ./darcs.cabal 170
 
     build-depends:   base          < 5,
                      extensible-exceptions >= 0.1 && < 0.2,
-                     regex-compat >= 0.71 && < 0.94,
-                     mtl          >= 1.0 && < 1.2,
-                     parsec       >= 2.0 && < 3.1,
+                     regex-compat >= 0.71 && < 0.94
+    if flag(old_mtl)
+      build-depends: mtl          >= 1.0 && < 1.2
+    else
+      build-depends: mtl          >= 2.0 && < 2.1
+    build-depends:   parsec       >= 2.0 && < 3.1,
                      html         == 1.0.*,
                      filepath     >= 1.1.0.0 && < 1.3.0.0,
                      haskeline    >= 0.6.2.2 && < 0.7,
hunk ./darcs.cabal 372
 
     if os(solaris)
       cc-options:     -DHAVE_SIGINFO_H
-
+    if flag(old_mtl)
+      cpp-options:    -DMTL1
     build-depends:   base          < 5,
                      extensible-exceptions >= 0.1 && < 0.2,
hunk ./darcs.cabal 376
-                     regex-compat >= 0.71 && < 0.94,
-                     mtl          >= 1.0 && < 1.2,
-                     parsec       >= 2.0 && < 3.1,
+                     regex-compat >= 0.71 && < 0.94
+    if flag(old_mtl)
+      build-depends: mtl          >= 1.0 && < 1.2
+    else
+      build-depends: mtl          >= 2.0 && < 2.1
+    build-depends:   parsec       >= 2.0 && < 3.1,
                      html         == 1.0.*,
                      filepath     >= 1.1.0.0 && < 1.3.0.0,
                      haskeline    >= 0.6.2.2 && < 0.7,
hunk ./darcs.cabal 517
 
   if os(solaris)
     cc-options:     -DHAVE_SIGINFO_H
+  if flag(old_mtl)
+    cpp-options:    -DMTL1
 
   build-depends:   base          < 5,
                    extensible-exceptions >= 0.1 && < 0.2,
hunk ./darcs.cabal 522
-                   regex-compat >= 0.71 && < 0.94,
-                   mtl          >= 1.0 && < 1.2,
-                   parsec       >= 2.0 && < 3.1,
+                   regex-compat >= 0.71 && < 0.94
+  if flag(old_mtl)
+    build-depends: mtl          >= 1.0 && < 1.2
+  else
+    build-depends: mtl          >= 2.0 && < 2.1
+  build-depends:   parsec       >= 2.0 && < 3.1,
                    html         == 1.0.*,
                    filepath     >= 1.1.0.0 && < 1.3.0.0,
                    haskeline    >= 0.6.2.2 && < 0.7,
hunk ./darcs.cabal 610
   if !flag(test)
     buildable: False
   else
+    if flag(old_mtl)
+      cpp-options:   -DMTL1
     buildable: True
     build-depends:   base          < 5,
                      extensible-exceptions >= 0.1 && < 0.2,
hunk ./darcs.cabal 615
-                     regex-compat >= 0.71 && < 0.94,
-                     mtl          >= 1.0 && < 1.2,
-                     parsec       >= 2.0 && < 3.1,
+                     regex-compat >= 0.71 && < 0.94
+    if flag(old_mtl)
+      build-depends: mtl          >= 1.0 && < 1.2
+    else
+      build-depends: mtl          >= 2.0 && < 2.1
+    build-depends:   parsec       >= 2.0 && < 3.1,
                      html         == 1.0.*,
                      filepath     >= 1.1.0.0 && < 1.3.0.0,
                      QuickCheck   >= 2.1.0.0,
hunk ./src/Darcs/Patch/Choices.hs 65
                       substitute
                     ) where
 
+#ifdef MTL1
 import Control.Monad.State( State(..) )
hunk ./src/Darcs/Patch/Choices.hs 67
+#else
+import Control.Monad.State ( State, state )
+#endif
 
 import Darcs.Patch
 import Darcs.Patch.Permutations ( commuteWhatWeCanRL, commuteWhatWeCanFL )
hunk ./src/Darcs/Patch/Choices.hs 259
     settleM middles = mapFL_FL (\tp -> PC tp False) $ reverseRL middles
     settleB bubble = mapFL_FL (\tp -> PC tp True) $ reverseRL bubble
 
+#ifdef MTL1
+state = State
+#endif
+
 patchSlot' :: Patchy p =>
               TaggedPatch p C(a b) -> State (PatchChoices p C(x y)) Slot
hunk ./src/Darcs/Patch/Choices.hs 265
-patchSlot' = State . patchSlot
+patchSlot' = state . patchSlot
 
 forceMatchingFirst :: forall p C(a b). Patchy p =>
                       ( FORALL(x y) TaggedPatch p C(x y) -> Bool)
hunk ./src/Darcs/SelectChanges.hs 35
 import Control.Monad ( when, (>=>) )
 import Control.Monad.Trans ( liftIO )
 import Control.Monad.Reader ( ReaderT, Reader, asks, runReader, runReaderT )
-import Control.Monad.State ( State(..), StateT, modify, gets, execStateT )
+import Control.Monad.State ( State(..), runState, StateT, modify, gets, execStateT )
 import System.Exit ( exitWith, ExitCode(ExitSuccess) )
 
 import English ( Noun(..), englishNum  )
[loosen constraint on containers package
Jason Dagit <da...@codersbase.com>**20101128224640
 Ignore-this: 192f24c7f47b91ae9c22c09a38737e57
] hunk ./darcs.cabal 186
                      old-time   == 1.0.*,
                      directory  >= 1.0.0.0 && < 1.2.0.0,
                      process    == 1.0.*,
-                     containers >= 0.1 && < 0.4,
+                     containers >= 0.1 && < 0.5,
                      array      >= 0.1 && < 0.4,
                      random     == 1.0.*,
                      tar          == 0.3.*,
hunk ./darcs.cabal 397
                    old-time   == 1.0.*,
                    directory  >= 1.0.0.0 && < 1.2.0.0,
                    process    == 1.0.*,
-                   containers >= 0.1 && < 0.4,
+                   containers >= 0.1 && < 0.5,
                    array      >= 0.1 && < 0.4,
                    random     == 1.0.*
 
hunk ./darcs.cabal 543
                    old-time   == 1.0.*,
                    directory  >= 1.0.0.0 && < 1.2.0.0,
                    process    == 1.0.*,
-                   containers >= 0.1 && < 0.4,
+                   containers >= 0.1 && < 0.5,
                    array      >= 0.1 && < 0.4,
                    random     == 1.0.*
 

Context:

[GHC 7.0 build fixes
Ganesh Sittampalam <gan...@earth.li>**20101102180602
 Ignore-this: 910e4b8308da07eda670f6734566108
] 
[get rid of n+k patterns
Ganesh Sittampalam <gan...@earth.li>**20101102180301
 Ignore-this: 44af9ac166aa7b7c61983d2587ea456e
] 
[get rid of some impredicative uses of flip
Ganesh Sittampalam <gan...@earth.li>**20101102180217
 Ignore-this: 1016f9b0cb5bf77dc806993406a111ee
 These aren't supported by GHC 7.0
] 
[dependency bumps for GHC 7.0
Ganesh Sittampalam <gan...@earth.li>**20101101071839
 Ignore-this: 840e8f80be34b80f155914609a795110
] 
[use CPP to handle change to Permissions type in GHC 7.0
Ganesh Sittampalam <gan...@earth.li>**20100928171822
 Ignore-this: 4726f827f996c50de9cd137fbab2252c
] 
[TAG 2.5
Reinier Lamers <tux_roc...@reinier.de>**20101024151805
 Ignore-this: 1561ce30bfb1950a440c03371e0e2f20
] 
Patch bundle hash:
d465122ec4e041da525166e4c6d332861ddd2658
_______________________________________________
darcs-users mailing list
darcs-users@darcs.net
http://lists.osuosl.org/mailman/listinfo/darcs-users

Reply via email to