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

Module with TemplateHaskell doesn't recompile when it should #5866

Closed
tom-audm opened this issue Jan 30, 2019 · 1 comment
Closed

Module with TemplateHaskell doesn't recompile when it should #5866

tom-audm opened this issue Jan 30, 2019 · 1 comment

Comments

@tom-audm
Copy link

tl;dr: a module with TemplateHaskell that should have been recompiled wasn't.

$ cabal --version
cabal-install version 2.2.0.0
$ mkdir /tmp/th_recompile
$ cd /tmp/th_recompile
$ git init
Initialized empty Git repository in /tmp/th_recompile/.git/

Then add these files:

th-recompile.cabal:

name:                th-recompile
version:             0.1.0.0
license:             BSD3
build-type:          Simple
cabal-version:       >=1.10

executable th-recompile
  main-is:
    Main.hs
  other-modules:
    Hash
  other-extensions:
    TemplateHaskell
  build-depends:
      base <5
    , gitrev
  -- hs-source-dirs:
  default-language:
    Haskell2010

Hash.hs:

{-# LANGUAGE TemplateHaskell #-}

module Hash where

import Development.GitRev

printIt = print $(gitHash)

Main.hs:

{-# LANGUAGE TemplateHaskell #-}
import Development.GitRev

import Hash

main = do
   print $(gitHash)
   printIt

Setup.hs:

import Distribution.Simple
main = defaultMain
$ git add Main.hs Hash.hs th-recompile.cabal Setup.hs
$ git commit -m 'Init'
$ cabal new-run
Resolving dependencies...
Build profile: -w ghc-8.4.4 -O1
In order, the following will be built (use -v for more details):
 - th-recompile-0.1.0.0 (exe:th-recompile) --enable-profiling (first run)
Configuring executable 'th-recompile' for th-recompile-0.1.0.0..
Preprocessing executable 'th-recompile' for th-recompile-0.1.0.0..
Building executable 'th-recompile' for th-recompile-0.1.0.0..
[1 of 2] Compiling Hash             ( Hash.hs, /tmp/th_recompile/dist-newstyle/build/x86_64-linux/ghc-8.4.4/th-recompile-0.1.0.0/x/th-recompile/build/th-recompile/th-recompile-tmp/Hash.dyn_o )
[2 of 2] Compiling Main             ( Main.hs, /tmp/th_recompile/dist-newstyle/build/x86_64-linux/ghc-8.4.4/th-recompile-0.1.0.0/x/th-recompile/build/th-recompile/th-recompile-tmp/Main.dyn_o )
[1 of 2] Compiling Hash             ( Hash.hs, /tmp/th_recompile/dist-newstyle/build/x86_64-linux/ghc-8.4.4/th-recompile-0.1.0.0/x/th-recompile/build/th-recompile/th-recompile-tmp/Hash.p_o )
[2 of 2] Compiling Main             ( Main.hs, /tmp/th_recompile/dist-newstyle/build/x86_64-linux/ghc-8.4.4/th-recompile-0.1.0.0/x/th-recompile/build/th-recompile/th-recompile-tmp/Main.p_o )
Linking /tmp/th_recompile/dist-newstyle/build/x86_64-linux/ghc-8.4.4/th-recompile-0.1.0.0/x/th-recompile/build/th-recompile/th-recompile ...
"2b46b5914d9f51a7f3f2e94001c96f4ebda05b07"
"2b46b5914d9f51a7f3f2e94001c96f4ebda05b07"
$ echo '' >> Main.hs
$ git add Main.hs
$ git commit -m 'Trivial'
$ cabal new-run
Build profile: -w ghc-8.4.4 -O1
In order, the following will be built (use -v for more details):
 - th-recompile-0.1.0.0 (exe:th-recompile) --enable-profiling (file Main.hs changed)
Preprocessing executable 'th-recompile' for th-recompile-0.1.0.0..
Building executable 'th-recompile' for th-recompile-0.1.0.0..
[2 of 2] Compiling Main             ( Main.hs, /tmp/th_recompile/dist-newstyle/build/x86_64-linux/ghc-8.4.4/th-recompile-0.1.0.0/x/th-recompile/build/th-recompile/th-recompile-tmp/Main.dyn_o )
[2 of 2] Compiling Main             ( Main.hs, /tmp/th_recompile/dist-newstyle/build/x86_64-linux/ghc-8.4.4/th-recompile-0.1.0.0/x/th-recompile/build/th-recompile/th-recompile-tmp/Main.p_o )
Linking /tmp/th_recompile/dist-newstyle/build/x86_64-linux/ghc-8.4.4/th-recompile-0.1.0.0/x/th-recompile/build/th-recompile/th-recompile ...
"456c2795231983904d57c62c48e255bc557b0f2a"
"2b46b5914d9f51a7f3f2e94001c96f4ebda05b07"

(Hash.hs should have been recompiled but it wasn't)

@phadej
Copy link
Collaborator

phadej commented Jan 30, 2019

Duplicate of #4746

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