Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builldwrapper-0.7.0 : build error #12

Open
wavewave opened this issue Feb 26, 2013 · 3 comments
Open

builldwrapper-0.7.0 : build error #12

wavewave opened this issue Feb 26, 2013 · 3 comments

Comments

@wavewave
Copy link

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

wavewave commented Mar 2, 2013

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants