Question

I'm using the file-embed package thusly:

import qualified Data.ByteString as B
import qualified Data.ByteString.Internal as B (w2c)
import qualified Data.FileEmbed as E

initWindow = do
    b <- Gtk.builderNew
    let glade = map B.w2c $ B.unpack $ $(E.embedFile "window.glade") in
        Gtk.builderAddFromString b glade
    ...

Is it possible to make cabal rebuild this file even when only the glade file changes?

Was it helpful?

Solution

Support for this will be/has been added in GHC 7.4/7.6. The problem is that the compiler doesn't allow TemplateHaskell splices to add file dependencies yet. See this ticket for more information.

When this change lands, you can use the following code to create a new embedFile' function:

import Data.FileEmbed

import Language.Haskell.TH.Syntax
import Language.Haskell.TH.Lib

embedFile' :: FilePath -> Q Exp
embedFile' path = do
  qAddDependentFile path
  embedFile path

This has to be in a separate module from where you use the TH function.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top