diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c84c20..aaf2537 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [0.1.1.1] - 2019-05-20 +### Added +- `NFData` instances for configs. + ## [0.1.1.0] - 2018-11-21 ### Added - Lens for configs; diff --git a/bcd-config.cabal b/bcd-config.cabal index 0706e43..f2a0b26 100644 --- a/bcd-config.cabal +++ b/bcd-config.cabal @@ -1,5 +1,5 @@ name: bcd-config -version: 0.1.1.0 +version: 0.1.1.1 synopsis: Library to get config. description: Library to get config to different systems homepage: https://github.com/biocad/bcd-config#readme @@ -34,13 +34,14 @@ library , System.BCD.Config.FileSystem , System.BCD.Config.BioSources build-depends: base >=4.7 && <5 - , containers - , text - , unordered-containers , aeson , aeson-casing , aeson-picker + , containers + , deepseq , lens + , text + , unordered-containers default-language: Haskell2010 default-extensions: DeriveGeneric , OverloadedStrings diff --git a/src/System/BCD/Config/BioSources.hs b/src/System/BCD/Config/BioSources.hs index 5562b82..03dd49d 100644 --- a/src/System/BCD/Config/BioSources.hs +++ b/src/System/BCD/Config/BioSources.hs @@ -4,14 +4,18 @@ module System.BCD.Config.BioSources , FromJsonConfig (..) ) where +import Control.DeepSeq (NFData) import Data.Aeson.Picker ((|--)) +import GHC.Generics (Generic) import System.BCD.Config (FromJsonConfig (..), getConfigText) -- | This class contains information where to find files that are related to -- semantic common used library [bio-sources](https://github.com/biocad/bio-sources). -- That library includes dihedral angles, kmers, ideal aminoacids and functions to work with them. newtype BioSourcesConfig = BioSourcesConfig { bioSourcesPath :: FilePath } - deriving (Show, Read, Eq) + deriving (Show, Read, Eq, Generic) + +instance NFData BioSourcesConfig instance FromJsonConfig BioSourcesConfig where fromJsonConfig = do diff --git a/src/System/BCD/Config/FileSystem.hs b/src/System/BCD/Config/FileSystem.hs index b42917c..85f12ba 100644 --- a/src/System/BCD/Config/FileSystem.hs +++ b/src/System/BCD/Config/FileSystem.hs @@ -4,12 +4,16 @@ module System.BCD.Config.FileSystem , FromJsonConfig (..) ) where +import Control.DeepSeq (NFData) import Data.Aeson.Picker ((|--)) import Data.HashMap.Strict (HashMap) +import GHC.Generics (Generic) import System.BCD.Config (FromJsonConfig (..), getConfigText) newtype FileSystemConfig = FileSystemConfig (HashMap String FilePath) - deriving (Show, Read, Eq) + deriving (Show, Read, Eq, Generic) + +instance NFData FileSystemConfig instance FromJsonConfig FileSystemConfig where fromJsonConfig = do diff --git a/src/System/BCD/Config/Mongo.hs b/src/System/BCD/Config/Mongo.hs index c10dfbd..8c7328c 100644 --- a/src/System/BCD/Config/Mongo.hs +++ b/src/System/BCD/Config/Mongo.hs @@ -10,6 +10,7 @@ module System.BCD.Config.Mongo , descr ) where +import Control.DeepSeq (NFData) import Control.Lens (makeLenses) import Data.Aeson (FromJSON (..), ToJSON (..), genericParseJSON, genericToJSON) @@ -20,7 +21,6 @@ import Data.Text (Text) import GHC.Generics (Generic) import System.BCD.Config (FromJsonConfig (..), getConfigText) - data MongoConfig = MongoConfig { _host :: String , _port :: Int , _user :: String @@ -32,6 +32,8 @@ data MongoConfig = MongoConfig { _host :: String makeLenses ''MongoConfig +instance NFData MongoConfig + instance ToJSON MongoConfig where toJSON = genericToJSON $ aesonDrop 1 snakeCase instance FromJSON MongoConfig where diff --git a/src/System/BCD/Config/Mysql.hs b/src/System/BCD/Config/Mysql.hs index 657da1f..2dca781 100644 --- a/src/System/BCD/Config/Mysql.hs +++ b/src/System/BCD/Config/Mysql.hs @@ -9,6 +9,7 @@ module System.BCD.Config.Mysql , descr ) where +import Control.DeepSeq (NFData) import Control.Lens (makeLenses) import Data.Aeson (FromJSON (..), ToJSON (..), genericParseJSON, genericToJSON) @@ -27,6 +28,8 @@ data MysqlConfig = MysqlConfig { _host :: String makeLenses ''MysqlConfig +instance NFData MysqlConfig + instance ToJSON MysqlConfig where toJSON = genericToJSON $ aesonDrop 1 snakeCase instance FromJSON MysqlConfig where diff --git a/src/System/BCD/Config/Neo4j.hs b/src/System/BCD/Config/Neo4j.hs index 70804b7..cc3c432 100644 --- a/src/System/BCD/Config/Neo4j.hs +++ b/src/System/BCD/Config/Neo4j.hs @@ -12,6 +12,7 @@ module System.BCD.Config.Neo4j , descr ) where +import Control.DeepSeq (NFData) import Control.Lens (makeLenses) import Data.Aeson (FromJSON (..), ToJSON (..), genericParseJSON, genericToJSON) @@ -33,6 +34,8 @@ data Neo4jConfig = Neo4jConfig { _host :: String makeLenses ''Neo4jConfig +instance NFData Neo4jConfig + instance ToJSON Neo4jConfig where toJSON = genericToJSON $ aesonDrop 1 snakeCase instance FromJSON Neo4jConfig where diff --git a/src/System/BCD/Config/Postgres.hs b/src/System/BCD/Config/Postgres.hs index dcb6259..8d69b51 100644 --- a/src/System/BCD/Config/Postgres.hs +++ b/src/System/BCD/Config/Postgres.hs @@ -10,6 +10,7 @@ module System.BCD.Config.Postgres , descr ) where +import Control.DeepSeq (NFData) import Control.Lens (makeLenses) import Data.Aeson (FromJSON (..), ToJSON (..), genericParseJSON, genericToJSON) @@ -31,6 +32,8 @@ data PostgresConfig = PostgresConfig { _host :: String makeLenses ''PostgresConfig +instance NFData PostgresConfig + instance ToJSON PostgresConfig where toJSON = genericToJSON $ aesonDrop 1 snakeCase instance FromJSON PostgresConfig where diff --git a/src/System/BCD/Config/Redis.hs b/src/System/BCD/Config/Redis.hs index c0113df..dd34f1b 100644 --- a/src/System/BCD/Config/Redis.hs +++ b/src/System/BCD/Config/Redis.hs @@ -9,6 +9,7 @@ module System.BCD.Config.Redis , descr ) where +import Control.DeepSeq (NFData) import Control.Lens (makeLenses) import Data.Aeson (FromJSON (..), ToJSON (..), genericParseJSON, genericToJSON) @@ -27,6 +28,8 @@ data RedisConfig = RedisConfig { _host :: String makeLenses ''RedisConfig +instance NFData RedisConfig + instance ToJSON RedisConfig where toJSON = genericToJSON $ aesonDrop 1 snakeCase instance FromJSON RedisConfig where diff --git a/src/System/BCD/Config/Schrodinger.hs b/src/System/BCD/Config/Schrodinger.hs index 4efe1b1..5a23aac 100644 --- a/src/System/BCD/Config/Schrodinger.hs +++ b/src/System/BCD/Config/Schrodinger.hs @@ -8,6 +8,7 @@ module System.BCD.Config.Schrodinger , password ) where +import Control.DeepSeq (NFData) import Control.Lens (makeLenses) import Data.Aeson (FromJSON (..), ToJSON (..), genericParseJSON, genericToJSON) @@ -25,6 +26,8 @@ data SchrodingerConfig = SchrodingerConfig { _host :: String makeLenses ''SchrodingerConfig +instance NFData SchrodingerConfig + instance ToJSON SchrodingerConfig where toJSON = genericToJSON $ aesonDrop 1 snakeCase instance FromJSON SchrodingerConfig where