[Haskell-cafe] Custom Setup.hs and Paths module

Erik de Castro Lopo mle+hs at mega-nerd.com
Wed Jul 3 03:39:03 CEST 2013


Daniel Díaz Casanueva wrote:

> Hi everyone.
> 
> I am writing a package where I am using the Paths module that cabal
> generates automatically. After adding the Paths module to the
> "other-modules" section in my cabal file everything worked just fine, until
> I wanted to write a custom Setup.hs. This Setup.hs just writes a couple of
> files in the system and then calls "defaultMain". The thing is that now
> "cabal install" does not find the Paths module, so the package is broken.

I ran into the same problem. I ended up fixing it by *not* using the auto
generated Paths module and instead parsing the cabal file in Setup.hs.

This is not has horrible as it sounds as I used the Cabal insfrastructure
to do it. Basically something like this:

    import Distribution.Simple
    import Distribution.PackageDescription
    import Distribution.PackageDescription.Parse (readPackageDescription)
    import Distribution.Verbosity (silent)

    version <- fmap (showVersion . pkgVersion . package . packageDescription)
                    $ readPackageDescription silent "my-package.cabal"

and then used that version String to write a trivial 5 line file Version.hs.

HTH,
Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/



More information about the Haskell-Cafe mailing list