verbosity
Simple enum that encodes application verbosity.
https://github.com/trskop/verbosity
LTS Haskell 22.33: | 0.4.0.0 |
Stackage Nightly 2023-12-26: | 0.4.0.0 |
Latest on Hackage: | 0.4.0.0 |
BSD-3-Clause licensed by Peter Trško
Maintained by [email protected]
This version can be pinned in stack with:
verbosity-0.4.0.0@sha256:b396e2cb6880cf0b23794579f1903bace1c07db48d536ce3df0c80bc4569233d,4958
Module documentation for 0.4.0.0
Depends on 6 packages(full list with versions):
verbosity
Description
Simple enum that encodes application verbosity with various useful instances.
Example
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
module Main.Options
( AppConfig(..)
, quietFlag
, incrementVerbosityFlag
)
where
import GHC.Generics (Generic)
import Data.Verbosity (Verbosity)
import qualified Data.Verbosity as Verbosity (Verbosity(Silent), increment')
import Data.Verbosity.Class (HasVerbosity, modifyVerbosity, setVerbosity)
import qualified Options.Applicative as Options
-- | Application configuration.
data AppConfig = AppConfig
{ verbosity :: Verbosity
-- , ...
}
deriving stock (Generic, Show)
deriving anyclass (HasVerbosity)
-- | Option for suppressing unnecessary output.
--
-- > -q, --quiet
-- > Quiet mode. Suppress normal diagnostic or result output.
quietFlag :: HasVerbosity a => Options.Parser (a -> a)
quietFlag = Options.flag id (setVerbosity Verbosity.Silent) $ mconcat
[ Options.long "quiet"
, Options.short 'q'
, Options.help "Quiet mode. Suppress normal diagnostic or result output."
]
-- | Flag for incrementing verbosity by one level. It can be used multiple
-- times to increase it more.
--
-- > -v
-- > Increment verbosity by one level. Can be used multiple times.
--
-- See 'Verbosity.increment'' for more details.
--
-- Note that this definition uses 'Options.flag'' under the hood to allow using
-- 'Control.Applicative.some' and 'Control.Applicative.many' combinators. In
-- other words, it will fail when used without these combinators or
-- 'Control.Applicative.optional'.
incrementVerbosityFlag :: HasVerbosity a => Options.Parser (a -> a)
incrementVerbosityFlag =
Options.flag' (modifyVerbosity Verbosity.increment') $ mconcat
[ Options.short 'v'
, Options.help "Increment verbosity by one level. Can be used multiple times."
]
Changes
ChangeLog / ReleaseNotes
Version 0.4.0.0
-
Bumped lower bound of
dhall
library set to 1.23.0. Version 1.22.0 supported Dhall Standard 7.0.0, however, it failed to deserialise new-style enums properly, which was fixed in version 1.23.0. (breaking change) -
Dhall library restructured to fit with current Dhall best practices.
-
Bumped upper bound of
lattices
to support versions 2.* (breaking change) -
Bumped upper bound of
generic-lens
to support versions 2.* (change) -
Bumped upper bound of
safecopy
to support versions 0.10.* (change) -
Removed
data-default
dependency and associated instance forDefault
type class. (breaking change)
Version 0.3.0.0
- Optional instances for
JoinSemiLattice
,MeetSemiLattice
,BoundedJoinSemiLattice
,BoundedMeetSemiLattice
,Lattice
, andBoundedLattice
. Dependency onlattices
package can be enabled using-flattices
build flag. (new) - Optional instances for
Dhall.Interpret
Dhall.Inject
type classes. Dependency ondhall
package can be enabled using-fdhall
build flag. Enabled by default. (new) - Optional instances for
Serialise
type class fromserialise
package that provides CBOR serialisation/deserialisation. Dependency onserialise
package can be enabled using-fserialise
build flag. Enabled by default. (new) HasVerbosity
type class now provides default implementation forverbosity
lens that usesgeneric-lens
. (change/new)- Dropped support for GHC < 8.2. As a consequence
Data
,Generic
, andTypeable
are always derived. The last one is implied by the fact that GHC now always derives it. (breaking change) - Uploaded to Hackage: http://hackage.haskell.org/package/verbosity-0.3.0.0
Version 0.2.3.0
- Introducing function
modifyVerbosity :: HasVerbosity s => (Verbosity -> Verbosity) -> s -> s
(new) - Introducing optional instance for safecopy’s
SafeCopy
type class. Dependency onsafecopy
package can be enabled using-fsafecopy
build flag. (new) - Uploaded to Hackage: http://hackage.haskell.org/package/verbosity-0.2.3.0
Version 0.2.2.0
- Relaxed
data-default-class
dependency that allows bilding with version 0.1.*. (change) - Introducing functions (new):
increment :: Verbosity -> Maybe Verbosity
increment' :: Verbosity -> Verbosity
- Uploaded to Hackage: http://hackage.haskell.org/package/verbosity-0.2.2.0
Version 0.2.1.0
- Introducing optional instance for cereal’s
Serialize
type class. Dependency oncereal
package can be enabled using-fcereal
build flag. (new) - Uploaded to Hackage: http://hackage.haskell.org/package/verbosity-0.2.1.0
Version 0.2.0.0
- Introducing module
Data.Verbosity.Class
which contains definition ofHasVerbosity
type class. (new) - Introducing function
fromInt :: Int -> Maybe Verbosity
. (new) - Introducing function
parse :: (Eq string, IsString string) => string -> Maybe Verbosity
. (new) - NFData instance, if compiled with
-fdeepseq
, which is the default case. (new) - Depends on transformers package in case base <4.8. (new)
- Uploaded to Hackage: http://hackage.haskell.org/package/verbosity-0.2.0.0
Version 0.1.0.0
- First public release.
- Uploaded to Hackage: http://hackage.haskell.org/package/verbosity-0.1.0.0