Help understanding why preprocessor doesn't work

in package replace-prefix i have a main:

root :: FilePath
root = “/home/cmo/src/replace-prefix”

main :: IO ()
main = do
(inp:out:_) ← getArgs
cwd ← getCurrentDirectory
Text.writeFile (root </> “log”) (pack cwd)
s ← Text.readFile inp
Text.writeFile out s

it builds and runs fine. in package test-replace-prefix i have a cabal file with stanzas

executable test-replace-prefix
import: warnings
main-is: Main.hs
– other-modules:
– other-extensions:
build-depends: base ^>=4.18.2.1
, test-replace-prefix
hs-source-dirs: app
default-language: Haskell2010

library
exposed-modules: Root
hs-source-dirs: src
build-tool-depends: replace-prefix:replace-prefix

in package test-replace-prefix i have a Setup.hs

main = defaultMainWithHooks simpleUserHooks
{ hookedPreProcessors =
[ (“phs”, replace-prefix) ]
}

The error message I get is:

Error: .cabal-wrapped: can’t find source for Root in src

in package test-replace-prefix src dir I have a Root.phs which just provides a binding that returns a string

Can anyone help me understand what is happening?

Ok I figured it out. I forgot to set my build-type to custom. Now I just have to understand how to create a preprocessor. I’m looking at Distribution.Simple.PreProcess. I will figure it out tomorrow.

1 Like

The args should be original_filepath, input, output

Awesome! Thank you for pointing out skeletest to me. That’s what I was trying to implement was a way of doing inline specifications.