5

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?

2
  • Have you tried using the other-filrs category? Dec 20, 2011 at 3:54
  • Well, there's data-files, but I like the idea of having exactly one file to distribute. What I need is a way to make the .hs file explicitly depend on the glade file. Dec 20, 2011 at 4:14

1 Answer 1

4

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.

1
  • 1
    This change never actually landed, so we still (eight years after this question and answer) have no way to do this. Aug 7, 2019 at 21:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.