diff --git a/password-instances/ChangeLog.md b/password-instances/ChangeLog.md index 9338b7f..328aa0d 100644 --- a/password-instances/ChangeLog.md +++ b/password-instances/ChangeLog.md @@ -1,5 +1,15 @@ # Changelog for `password-instances` +## 3.1.0.0 + +- Added cabal flags (`aeson`, `http-api-data`, `persistent`) to make + dependencies optional. All flags default to `True`. +- Added compile-time error if all flags are disabled. +- Split into dedicated packages + [#87](https://github.com/cdepillabout/password/pull/87) +- and add flags to parametrize dependencies + [#89](https://github.com/cdepillabout/password/pull/89) + ## 3.0.0.0 - The `password-instances` library now depends on the new diff --git a/password-instances/password-instances.cabal b/password-instances/password-instances.cabal index 535fdc6..7fd6644 100644 --- a/password-instances/password-instances.cabal +++ b/password-instances/password-instances.cabal @@ -1,7 +1,7 @@ cabal-version: 1.12 name: password-instances -version: 3.0.0.0 +version: 3.1.0.0 category: Security synopsis: typeclass instances for password package description: A library providing typeclass instances for common libraries for the types from the password package. @@ -21,6 +21,21 @@ source-repository head type: git location: https://github.com/cdepillabout/password +flag aeson + description: Enable instances for Aeson + default: True + manual: True + +flag http-api-data + description: Enable instances for HTTP API Data + default: True + manual: True + +flag persistent + description: Enable instances for Persistent + default: True + manual: True + custom-setup setup-depends: base >= 4.9 && < 5 @@ -35,10 +50,21 @@ library Paths_password_instances build-depends: base >= 4.9 && < 5 - , password-aeson - , password-http-api-data - , password-persistent ghc-options: -Wall default-language: Haskell2010 + default-extensions: + CPP + if flag(aeson) + build-depends: + password-aeson + cpp-options: -DFLAG_AESON + if flag(http-api-data) + build-depends: + password-http-api-data + cpp-options: -DFLAG_HTTP_API_DATA + if flag(persistent) + build-depends: + password-persistent + cpp-options: -DFLAG_PERSISTENT diff --git a/password-instances/src/Data/Password/Instances.hs b/password-instances/src/Data/Password/Instances.hs index ebfb3ad..a5d4bf1 100644 --- a/password-instances/src/Data/Password/Instances.hs +++ b/password-instances/src/Data/Password/Instances.hs @@ -16,6 +16,18 @@ See the "Data.Password.Types" module for more information. module Data.Password.Instances (module E) where +#if !defined(FLAG_AESON) && !defined(FLAG_HTTP_API_DATA) && !defined(FLAG_PERSISTENT) +#error "At least one of the flags (aeson, http-api-data, persistent) must be enabled" +#endif + +#ifdef FLAG_AESON import Data.Password.Aeson as E +#endif + +#ifdef FLAG_HTTP_API_DATA import Data.Password.HttpApiData as E +#endif + +#ifdef FLAG_PERSISTENT import Data.Password.Persistent as E +#endif