JPMoresmau / BuildWrapper

Utility to manage haskell projects for an IDE
Other
36 stars 12 forks source link

builldwrapper-0.7.0 : build error #12

Open wavewave opened 11 years ago

wavewave commented 11 years ago

buildwrapper-0.7.0 has the following build error. On the other hand, I successfully installed buildwrapper-0.6.4 on my system. (ghc-7.6.1, linux x86-64) I think the same error message happens in hackage build log, too.

$ cabal install buildwrapper 
Resolving dependencies...
Configuring buildwrapper-0.7.0...
Building buildwrapper-0.7.0...
Preprocessing library buildwrapper-0.7.0...
[1 of 7] Compiling Language.Haskell.BuildWrapper.Base ( src/Language/Haskell/BuildWrapper/Base.hs, dist/build/Language/Haskell/BuildWrapper/Base.o )
[2 of 7] Compiling Language.Haskell.BuildWrapper.GHCStorage ( src/Language/Haskell/BuildWrapper/GHCStorage.hs, dist/build/Language/Haskell/BuildWrapper/GHCStorage.o )
[3 of 7] Compiling Language.Haskell.BuildWrapper.GHC ( src/Language/Haskell/BuildWrapper/GHC.hs, dist/build/Language/Haskell/BuildWrapper/GHC.o )

src/Language/Haskell/BuildWrapper/GHC.hs:352:57:
    Couldn't match expected type `time-1.4.0.1:Data.Time.Clock.UTC.UTCTime'
                with actual type `ClockTime'
    In the second argument of `(==)', namely `t1'
    In the second argument of `(&&)', namely `t2 == t1'
    In the expression: hasLoaded && t2 == t1

src/Language/Haskell/BuildWrapper/GHC.hs:373:47:
    Couldn't match expected type `ClockTime'
                with actual type `time-1.4.0.1:Data.Time.Clock.UTC.UTCTime'
    In the first argument of `go', namely `t2'
    In the second argument of `unless', namely `(go t2)'
    In a stmt of a 'do' block: unless ("q" == l) (go t2)
Failed to install buildwrapper-0.7.0
cabal: Error: some packages failed to install:
buildwrapper-0.7.0 failed during the building phase. The exception was:
ExitFailure 1
wavewave commented 11 years ago

I made a patch for this. This build error was caused because the output type of System.Directory.getModificationTime is changed from ClockTime to UTCTime (which is in time package) It is necessary to make a conversion function from UTCTime to ClockTime. I copied some code from convertible-text package. But using ClockTime from System.Time must be deprecated as I understand, so probably changing to Data.Time.Clock.UTCTime is better, I think.

diff -Naur buildwrapper-0.7.0/src/Language/Haskell/BuildWrapper/GHC.hs buildwrapper-0.7.0-new/src/Language/Haskell/BuildWrapper/GHC.hs
--- buildwrapper-0.7.0/src/Language/Haskell/BuildWrapper/GHC.hs 2013-02-26 16:51:53.663119702 -0500
+++ buildwrapper-0.7.0-new/src/Language/Haskell/BuildWrapper/GHC.hs 2013-02-26 17:09:52.498912226 -0500
@@ -67,9 +67,18 @@
 import System.IO (hFlush, stdout)
 import System.Directory (getModificationTime)
 import System.Time (ClockTime(TOD))
+-- 
+import Data.Time.Clock.POSIX

 type GHCApplyFunction a=FilePath -> TypecheckedModule -> Ghc a

+convertPOSIXTimeToClockTime :: POSIXTime -> ClockTime 
+convertPOSIXTimeToClockTime x = TOD rsecs rpico
+        where rsecs = floor x
+              rpico = truncate $ abs $ 1000000000000 * (x - (fromIntegral rsecs))
+
+
+
 -- | get the GHC typechecked AST
 getAST :: FilePath -- ^ the source file
         -> FilePath -- ^ the base directory
@@ -345,7 +354,7 @@
         where 
                 go :: ClockTime -> Ghc ()
                 go t1 = do
-                        t2<- GMU.liftIO $ getModificationTime fp
+                        t2<- fmap (convertPOSIXTimeToClockTime . utcTimeToPOSIXSeconds) (GMU.liftIO $ getModificationTime fp)
                         let hasLoaded=case t1 of
                                 TOD 0 _ -> False
                                 _ -> True
@@ -1233,4 +1242,4 @@
                         formatInfo=foldr getFormatInfo (0,0,0,0,0) fivs
                         in map (formatImport formatInfo) fivs

-                       
\ No newline at end of file
+                       
JPMoresmau commented 11 years ago

Yes, but it still needs to work with previous version of GHC, where getModificationTime returns a ClockTime. I've committed a change and uploaded 0.7.1, let me know if that solves the issue.

wavewave commented 11 years ago

Hi, I've checked that the new version 0.7.1 compiles well on my computer! Thanks.