autopack alternatives and similar packages
Based on the "Cabal" category
Do you think we are missing an alternative of autopack or a related project?
Custom Setup to automate package modules discovery.
autopack is in early beta phase. ⚠️
Usually, when working on a Haskell project, you end up having lots of modules.
During the development, you can add, remove or rename any of them. And this is
fine unless you continuously need remembering to add, remove or rename the
corresponding module line in the
.cabal file. Sometimes all you want is to
Cabal dealing with it, so you won't need to patch any files when
performing any operations on modules. Good news, everyone! This project was
created precisely to help to solve this particular issue.
autopack is a Haskell library that provides custom setup functions that
discover all exposed
.hs files for your library from the
folders. It uses this information to prehook the list of identified modules into
exposed-modules field of the library stanza of your package description.
You can use Cabal's custom setup scripts to use this library in your project. In the next section, we are going to give detailed instructions on that.
For now, all you need to keep in mind to use
- It uses
hs-source-dirsfield to establish where to look up for modules.
- It can work only with
.hsextension at the moment.
- It adds all discovered modules into
exposed-modulesof the library stanza.
- If there are already some modules in the
autopackwill concatenate lists.
How to use
First, make sure that you are using the Cabal version at least
2.0 in your
.cabal file. For example:
Now you need to change the
field in your
package_name.cabal file to
Custom instead of the default
Then you have to add
custom-setup section before you defining your library
stanza. It should have the
autopack dependency so you can use it in your
custom-setup setup-depends: base , autopack
And the final preparation. You should add the
Setup.hs module (or replace the
default one) in the root directory of the package with the following content:
import Autopack (defaultMainAutoModules) main :: IO () main = defaultMainAutoModules
You are all set up now!
You can remove
exposed-module field from your
file completely, and
autopack will discover all the
.hs modules in your
folders for you during the build.
Cabal does not currently provide the feature of automatic modules
discovery, there are some workarounds for this process. One of them is this
autopack that uses
Cabal's Setup feature to discover all modules
during the pre-build stage of
Cabal. Another tool that provides it
hpack. It is the wrapper on
Cabal syntax via
YAML where there is no need to write modules explicitly.
They are added to the
exposed-modules field of the
.cabal file during the
.cabal step of the tool work process.
*Note that all licence references and agreements mentioned in the autopack README section above are relevant to that project's source code only.