verbosity: Simple enum that encodes application verbosity.

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Simple enum that encodes application verbosity with various useful instances.


[Skip to Readme]

Properties

Versions 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.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), 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 2019-03-09T16:06:38Z

Modules

[Index] [Quick Jump]

Flags

Manual Flags

NameDescriptionDefault
pedantic

Pass additional warning flags to GHC.

Disabled
Automatic Flags
NameDescriptionDefault
binary

Derive instances for Binary type class.

Enabled
data-default

Derive instances for Default 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


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