verbosity: Simple enum that encodes application verbosity.

[ bsd3, data, library ] [ Propose Tags ]

Simple enum that encodes application verbosity with various useful instances.


[Skip to Readme]
Versions [faq] 0.1.0.0, 0.2.0.0, 0.2.1.0, 0.2.2.0, 0.2.3.0, 0.3.0.0
Change log ChangeLog.md
Dependencies base (>=4.10 && <5), binary (>=0.5 && <0.11), cereal (>=0.1 && <0.6), data-default-class (>=0.0 && <0.2), deepseq (>=1.1.0.0 && <2), dhall (>=1.0.1 && <2), generic-lens (>=1.0.0.2 && <2), lattices (>=1.4 && <2), safecopy (>=0.5 && <0.10), serialise (>=0.2.1 && <1) [details]
License BSD-3-Clause
Copyright (c) 2015-2019 Peter Trško
Author Peter Trško
Maintainer peter.trsko@gmail.com
Category Data
Home page https://github.com/trskop/verbosity
Bug tracker https://github.com/trskop/verbosity/issues
Source repo head: git clone git://github.com/trskop/verbosity
this: git clone git://github.com/trskop/verbosity.git(tag 0.3.0.0)
Uploaded by PeterTrsko at Sat Mar 9 16:08:08 UTC 2019
Distributions LTSHaskell:0.2.3.0, NixOS:0.3.0.0, Stackage:0.3.0.0
Downloads 1881 total (115 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2019-03-09 [all 1 reports]

Modules

[Index] [Quick Jump]

Flags

NameDescriptionDefaultType
pedantic

Pass additional warning flags to GHC.

DisabledManual
binary

Derive instances for Binary type class.

EnabledAutomatic
data-default

Derive instances for Default type class.

EnabledAutomatic
deepseq

Define instance for NFData type class.

EnabledAutomatic
cereal

Define instance for Serialize type class.

DisabledAutomatic
safecopy

Define instance for SafeCopy type class.

DisabledAutomatic
lattices

Define instances for JoinSemiLattice, MeetSemiLattice, BoundedJoinSemiLattice, BoundedMeetSemiLattice, Lattice, and BoundedLattice.

DisabledAutomatic
dhall

Define Verbosity instance for (Dhall) Interpret type class. Implies ghc-generics flag as well.

EnabledAutomatic
serialise

Define instance for Serialise type class.

EnabledAutomatic

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for verbosity-0.3.0.0

[back to package description]

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."
        ]