packages feed

hasql-optparse-applicative 0.5 → 0.6

raw patch · 2 files changed

+92/−47 lines, 2 filesdep +attoparsecdep +attoparsec-timedep ~hasql-poolPVP ok

version bump matches the API change (PVP)

Dependencies added: attoparsec, attoparsec-time

Dependency ranges changed: hasql-pool

API changes (from Hackage documentation)

+ Hasql.OptparseApplicative: attoparsedOption :: Parser a -> Mod OptionFields a -> Parser a

Files

hasql-optparse-applicative.cabal view
@@ -1,52 +1,68 @@-name:-  hasql-optparse-applicative-version:-  0.5-synopsis:-  "optparse-applicative" parsers for "hasql"-category:-  Hasql, Database, PostgreSQL, Options-homepage:-  https://github.com/sannsyn/hasql-optparse-applicative +cabal-version: 3.0+name:          hasql-optparse-applicative+version:       0.6+synopsis:      "optparse-applicative" parsers for "hasql"+category:      Hasql, Database, PostgreSQL, Options+homepage:      https://github.com/sannsyn/hasql-optparse-applicative  bug-reports:   https://github.com/sannsyn/hasql-optparse-applicative/issues -author:-  Nikita Volkov <nikita.y.volkov@mail.ru>-maintainer:-  Nikita Volkov <nikita.y.volkov@mail.ru>-copyright:-  (c) 2016, Sannsyn AS-license:-  MIT-license-file:-  LICENSE-build-type:-  Simple-cabal-version:-  >=1.10 +author:        Nikita Volkov <nikita.y.volkov@mail.ru>+maintainer:    Nikita Volkov <nikita.y.volkov@mail.ru>+copyright:     (c) 2016, Sannsyn AS+license:       MIT+license-file:  LICENSE  source-repository head-  type:-    git-  location:-    git://github.com/sannsyn/hasql-optparse-applicative.git-+  type:     git+  location: git://github.com/sannsyn/hasql-optparse-applicative.git  library-  hs-source-dirs:-    library+  hs-source-dirs:     library   default-extensions:-    Arrows, BangPatterns, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFoldable, DeriveFunctor, DeriveGeneric, DeriveTraversable, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, LambdaCase, LiberalTypeSynonyms, MagicHash, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, TemplateHaskell, TupleSections, TypeFamilies, TypeOperators, UnboxedTuples-  default-language:-    Haskell2010-  other-modules:-  exposed-modules:-    Hasql.OptparseApplicative+    NoImplicitPrelude+    NoMonomorphismRestriction+    Arrows+    BangPatterns+    ConstraintKinds+    DataKinds+    DefaultSignatures+    DeriveDataTypeable+    DeriveFoldable+    DeriveFunctor+    DeriveGeneric+    DeriveTraversable+    EmptyDataDecls+    FlexibleContexts+    FlexibleInstances+    FunctionalDependencies+    GADTs+    GeneralizedNewtypeDeriving+    LambdaCase+    LiberalTypeSynonyms+    MagicHash+    MultiParamTypeClasses+    MultiWayIf+    OverloadedStrings+    ParallelListComp+    PatternGuards+    QuasiQuotes+    RankNTypes+    RecordWildCards+    ScopedTypeVariables+    StandaloneDeriving+    TemplateHaskell+    TupleSections+    TypeFamilies+    TypeOperators+    UnboxedTuples++  default-language:   Haskell2010+  exposed-modules:    Hasql.OptparseApplicative   build-depends:-    hasql >= 1.6 && < 1.7,-    hasql-pool >= 0.8 && < 0.9,-    -- -    optparse-applicative >= 0.17 && < 0.18,-    -- -    base-prelude < 2+    , attoparsec >=0.14 && <0.15+    , attoparsec-time >=1.0.3 && <1.1+    , base-prelude <2+    , hasql >=1.6 && <1.7+    , hasql-pool >=0.9 && <0.10+    , optparse-applicative >=0.17 && <0.18
library/Hasql/OptparseApplicative.hs view
@@ -1,6 +1,8 @@ module Hasql.OptparseApplicative where -import BasePrelude hiding (option)+import qualified Attoparsec.Time.Text as C+import BasePrelude+import qualified Data.Attoparsec.Text as D import qualified Hasql.Connection as A import qualified Hasql.Pool as B import Options.Applicative@@ -12,7 +14,11 @@ -- if you don't want it changed. poolSettings :: (String -> String) -> Parser (IO B.Pool) poolSettings updatedName =-  B.acquire <$> size <*> acquisitionTimeout <*> connectionSettings updatedName+  B.acquire+    <$> size+    <*> acquisitionTimeout+    <*> connectionLifetime+    <*> connectionSettings updatedName   where     size =       option auto . mconcat $@@ -22,12 +28,19 @@           help "Amount of connections in the pool"         ]     acquisitionTimeout =-      optional . fmap (* 1000000) . option auto . mconcat $+      attoparsedOption C.diffTime . mconcat $         [ long (updatedName "pool-acquisition-timeout"),           value 10,           showDefault,-          help "How long it takes until the attempt to connect is considered timed out. In seconds"+          help "How long it takes until the attempt to connect is considered timed out"         ]+    connectionLifetime =+      attoparsedOption C.diffTime . mconcat $+        [ long (updatedName "pool-connection-lifetime"),+          value (fromIntegral (24 * 60 * 60)),+          showDefault,+          help "Maximal lifetime for connections. Allows to periodically clean up the connection resources to avoid server-side leaks"+        ]  -- | Given a function, which updates the long names produces a parser -- of @Hasql.Connection.'A.Settings'@.@@ -70,3 +83,19 @@         strOption $           long (updatedName "database")             <> help "Database name"++-- * Helpers++-- timeout name def help =+--   attoparsedOption C.diffTime mconcat $+--     [ long name,+--       value def,+--       showDefault,+--       help "How long it takes until the attempt to connect is considered timed out. In seconds"+--     ]+--   where+--     reader = eitherReader $++attoparsedOption :: D.Parser a -> Mod OptionFields a -> Parser a+attoparsedOption parser =+  option $ eitherReader $ D.parseOnly (parser <* D.endOfInput) . fromString