# Help understanding why preprocessor doesn't work

**URL:** <https://discourse.haskell.org/t/help-understanding-why-preprocessor-doesnt-work/13435>\
**Category:** Learn\
**Created:** [December 20, 2025, 5:30am UTC](https://discourse.haskell.org/t/help-understanding-why-preprocessor-doesnt-work/13435 "2025-12-20T05:30:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![foobobity](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/foobobity/32/5422_2.png) [@foobobity](https://discourse.haskell.org/u/foobobity)\
**Post date:** [December 20, 2025, 5:30am UTC](https://discourse.haskell.org/t/help-understanding-why-preprocessor-doesnt-work/13435/1 "2025-12-20T05:30:11Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![foobobity](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/foobobity/32/5422_2.png) [@foobobity](https://discourse.haskell.org/u/foobobity)\
**Post date:** [December 20, 2025, 6:27am UTC](https://discourse.haskell.org/t/help-understanding-why-preprocessor-doesnt-work/13435/2 "2025-12-20T06:27:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![brandonchinn178](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/brandonchinn178/32/5103_2.png) [@brandonchinn178](https://discourse.haskell.org/u/brandonchinn178)\
**Post date:** [December 20, 2025, 4:14pm UTC](https://discourse.haskell.org/t/help-understanding-why-preprocessor-doesnt-work/13435/3 "2025-12-20T16:14:41Z")

</div>

The args should be original\_filepath, input, output

> <https://github.com/brandonchinn178/skeletest/blob/main/src%2Fbin%2Fskeletest-preprocessor.hs>

---

<div class="post-metadata">

**Author:** ![foobobity](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/foobobity/32/5422_2.png) [@foobobity](https://discourse.haskell.org/u/foobobity)\
**Post date:** [December 20, 2025, 5:54pm UTC](https://discourse.haskell.org/t/help-understanding-why-preprocessor-doesnt-work/13435/4 "2025-12-20T17:54:14Z")

</div>

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