verbosity: Simple enum that encodes application verbosity.

[ bsd3, data, library ] [ Propose Tags ] [ Report a vulnerability ]

Simple enum that encodes application verbosity with various useful instances.


[Skip to Readme]

Flags

Manual Flags

NameDescriptionDefault
pedantic

Pass additional warning flags to GHC.

Disabled
Automatic Flags
NameDescriptionDefault
binary

Derive instances for Binary type class.

Enabled
deepseq

Define instance for NFData type class.

Enabled
cereal

Define instance for Serialize type class.

Disabled
safecopy

Define instance for SafeCopy type class.

Disabled
lattices

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

Disabled
dhall

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

Enabled
serialise

Define instance for Serialise type class.

Enabled

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

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.2.0.0, 0.2.1.0, 0.2.2.0, 0.2.3.0, 0.3.0.0, 0.4.0.0
Change log ChangeLog.md
Dependencies base (>=4.10 && <5), binary (>=0.5 && <0.11), cereal (>=0.1 && <0.6), deepseq (>=1.1.0.0 && <2), dhall (>=1.23.0 && <2), generic-lens (>=1.0.0.2 && <3), lattices (>=1.4 && <3), safecopy (>=0.5 && <0.11), serialise (>=0.2.1 && <1) [details]
License BSD-3-Clause
Copyright (c) 2015-2020 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.4.0.0)
Uploaded by PeterTrsko at 2020-02-16T17:32:45Z
Distributions LTSHaskell:0.4.0.0, NixOS:0.4.0.0
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 4798 total (44 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2020-02-16 [all 1 reports]

Readme for verbosity-0.4.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."
        ]