Connecting the build tool to Cabal (Haskell)

I tried using the bnfc tool to create a bunch of files like lexer, parser etc. for me. It works great. Now I wanted to clean it up a bit without having to manually compile the bnfc file and generate several files that clutter my /src folder.

I tried the Cabal mechanism, in which you specify the tool in the build-tools field of the .cabal file, and specify the files that you expect to receive in the extra-source-files field. This worked for me for Alex and Happy, as they were recognized as Cabal build tools, but bnfc not. Is there a way to connect bnfc or any tool in general using Cabal and use Cabal as build tools?

+5
source share
1 answer

It seems that Kabbalah does not know about bnfc (it does not appear in the list ).

It seems that there is no way to do this using only the .cabal file, but there is an example of how to connect the preprocessor in Setup.hs to the Setup.hs Sources in the tests /PackageTests/CustomPreProcess/Setup.hs using the user hook hookedPreProcessors (all the hooks are in UserHooks .hs )

+3
source

Source: https://habr.com/ru/post/1248002/


All Articles