import Distribution.Simple import Distribution.Simple.PreProcess import Distribution.PackageDescription import Distribution.Simple.LocalBuildInfo import Distribution.Simple.Program -- This Setup script installs a handler for .hsx files that need to be preprocessed -- with `trhsx'. In order to use it, specify Build-Type: Custom in the .cabal file. newpp = hookedPreProcessors simpleUserHooks ++ [("hsx", ppTrhsx)] -- Define the custom hook which contains the handler for the .hsx suffix. main = defaultMainWithHooks (simpleUserHooks {hookedPreProcessors = newpp}) -- Preprocessor definition for trhsx. Based upon examples in Cabal sources. -- Trhsx needs to be called with two parameters: input filepath and output filepath. ppTrhsx :: BuildInfo -> LocalBuildInfo -> PreProcessor ppTrhsx _bi lbi = PreProcessor { platformIndependent = False, runPreProcessor = mkSimplePreProcessor $ \inFile outFile verbosity -> rawSystemProgram verbosity progTrhsx [inFile, outFile] } -- Here we assume that trhsx is on the PATH so we just specify its name. progTrhsx = ConfiguredProgram { programId = "trhsx" ,programVersion = Nothing ,programArgs = [] ,programLocation = FoundOnSystem "trhsx" }