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

verbosity

Hackage Hackage Dependencies Haskell Programming Language BSD3 License

Build

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 for Default type class. (breaking change)

Version 0.3.0.0

  • Optional instances for JoinSemiLattice, MeetSemiLattice, BoundedJoinSemiLattice, BoundedMeetSemiLattice, Lattice, and BoundedLattice. Dependency on lattices package can be enabled using -flattices build flag. (new)
  • Optional instances for Dhall.Interpret Dhall.Inject type classes. Dependency on dhall package can be enabled using -fdhall build flag. Enabled by default. (new)
  • Optional instances for Serialise type class from serialise package that provides CBOR serialisation/deserialisation. Dependency on serialise package can be enabled using -fserialise build flag. Enabled by default. (new)
  • HasVerbosity type class now provides default implementation for verbosity lens that uses generic-lens. (change/new)
  • Dropped support for GHC < 8.2. As a consequence Data, Generic, and Typeable 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 on safecopy 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

Version 0.2.1.0

Version 0.2.0.0

  • Introducing module Data.Verbosity.Class which contains definition of HasVerbosity 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