[Haskell-cafe] Optional C dependencies / build-time feature toggles

Simon Michael simon at joyful.com
Wed Dec 14 16:06:26 UTC 2016


On 12/11/16 8:53 AM, Tobias Dammers wrote:
> The pipe dream would be for those dependencies to be optional *at run
> time*, such that the application would test for their presence on
> startup, or load them dynamically when and if they're needed. However,
> I'm also fine with making them compile-time feature toggles, such that
> users can enable only the ones they need. Doing some sort of
> autotools-style dependency discovery would of course be cool as well
> (i.e., only enable mysql support if libmysqlclient is present).

Hello Tobias,

I asked for this, but indeed it's not easy to see how to implement it. I 
will say that the C libs required by sprinkles are all widely used so 
installing them wasn't too hard; and, it's nice having all of the power 
available from the start.

Still, you may add more C-based storage back ends in future, and even 
one C lib does create friction and slow down adoption.

compile-time cabal flags (cabal install sprinkles -fmysql -fpostgres) 
add complexity for maintainer, tools and users. I suppose they might be 
justified here. You'd have to decide on manual vs automatic flags 
(toggleable by Cabal), and enabled or disabled by default. (If they are 
enabled and automatic, and the required C lib is missing, will Cabal 
quietly skip that feature or give an error ?).

The build-type: Configure suggestion sounds intriguing. A custom 
Setup.hs for fancy install behaviour might also be interesting, at 
minimum you could detect the C lib status and give more useful user 
advice. These also add complexity.

Or, you could publish multiple semi-redundant packages - sprinkles, 
sprinkles-postgres, sprinkles-mysql, sprinkles-sqlite, sprinkles-all, 
sprinkles-lib... simpler packages, but more of them.



More information about the Haskell-Cafe mailing list