verbosity 0.2.2.0 → 0.2.3.0
raw patch · 5 files changed
+60/−16 lines, 5 filesdep +safecopyPVP ok
version bump matches the API change (PVP)
Dependencies added: safecopy
API changes (from Hackage documentation)
+ Data.Verbosity.Class: modifyVerbosity :: HasVerbosity s => (Verbosity -> Verbosity) -> s -> s
Files
- ChangeLog.md +19/−8
- LICENSE +1/−1
- src/Data/Verbosity.hs +16/−2
- src/Data/Verbosity/Class.hs +8/−3
- verbosity.cabal +16/−2
ChangeLog.md view
@@ -1,31 +1,42 @@ # ChangeLog / ReleaseNotes +## 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**)++ ## Version 0.2.2.0 * Relaxed `data-default-class` dependency that allows bilding with version- 0.1.\*.-* Introducing functions:+ 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- on `cereal` package can be enabled using `-fcereal` build flag. (new)+ on `cereal` 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 of- `HasVerbosity` type class. (new)-* Introducing function `fromInt :: Int -> Maybe Verbosity`. (new)+ `HasVerbosity` type class. (**new**)+* Introducing function `fromInt :: Int -> Maybe Verbosity`. (**new**) * Introducing function- `parse :: (Eq string, IsString string) => string -> Maybe Verbosity`. (new)+ `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)+ (**new**)+* Depends on [transformers][] package in case [base][] <4.8. (**new**) * Uploaded to [Hackage][]: <http://hackage.haskell.org/package/verbosity-0.2.0.0>
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2015, Peter Trško+Copyright (c) 2015-2016 Peter Trško All rights reserved.
src/Data/Verbosity.hs view
@@ -13,6 +13,10 @@ {-# LANGUAGE BangPatterns #-} #endif +#ifdef DECLARE_SAFECOPY_INSTANCE+{-# LANGUAGE TemplateHaskell #-}+#endif+ -- | -- Module: $HEADER$ -- Description: Verbosity enum.@@ -21,8 +25,9 @@ -- -- Maintainer: peter.trsko@gmail.com -- Stability: experimental--- Portability: BangPatterns (optional), CPP, NoImplicitPrelude,--- DeriveDataTypeable (optional), DeriveGeneric (optional)+-- Portability: BangPatterns (optional), CPP, DeriveDataTypeable (optional),+-- DeriveGeneric (optional), NoImplicitPrelude,+-- TemplateHaskell (optional) -- -- Simple enum that encodes application 'Verbosity'. module Data.Verbosity@@ -72,6 +77,11 @@ import qualified Data.Binary as Binary (getWord8, putWord8) #endif +#ifdef DECLARE_SAFECOPY_INSTANCE+import Data.SafeCopy (deriveSafeCopy)+import qualified Data.SafeCopy as SafeCopy (base)+#endif+ #ifdef DECLARE_SERIALIZE_INSTANCE import qualified Data.Serialize as Cereal (Serialize(..), getWord8, putWord8) #endif@@ -139,6 +149,10 @@ instance Cereal.Serialize Verbosity where get = toEnum . fromIntegral <$> Cereal.getWord8 put = Cereal.putWord8 . fromIntegral . fromEnum+#endif++#ifdef DECLARE_SAFECOPY_INSTANCE+deriveSafeCopy 0 'SafeCopy.base ''Verbosity #endif #ifdef DECLARE_NFDATA_INSTANCE
src/Data/Verbosity/Class.hs view
@@ -2,7 +2,7 @@ -- | -- Module: $HEADER$ -- Description: Type class for accessing Verbosity.--- Copyright: (c) 2015, Peter Trško+-- Copyright: (c) 2015-2016 Peter Trško -- License: BSD3 -- -- Maintainer: peter.trsko@gmail.com@@ -24,6 +24,7 @@ HasVerbosity(..) , getVerbosity , setVerbosity+ , modifyVerbosity -- * Verbosity Re-export , module Data.Verbosity@@ -39,7 +40,7 @@ class HasVerbosity s where- -- | Lens for accessing 'Verbosity'.+ -- | Lens for accessing 'Verbosity' embedded in the type @s@. verbosity :: Functor f => (Verbosity -> f Verbosity) -> s -> f s instance HasVerbosity Verbosity where@@ -53,6 +54,10 @@ setVerbosity :: HasVerbosity s => Verbosity -> s -> s setVerbosity v = runIdentity . verbosity (const (Identity v)) +-- | Specialization of 'verbosity' lens in to modification function.+modifyVerbosity :: HasVerbosity s => (Verbosity -> Verbosity) -> s -> s+modifyVerbosity f = runIdentity . verbosity (Identity . f)+ -- $basicUsageExample -- -- Lets define simple data type that looks something like:@@ -101,5 +106,5 @@ -- -- @ -- instance 'HasVerbosity' Config where--- verbosity = appVerbosity+-- 'verbosity' = appVerbosity -- Lens generated by makeLenses. -- @
verbosity.cabal view
@@ -1,5 +1,5 @@ name: verbosity-version: 0.2.2.0+version: 0.2.3.0 synopsis: Simple enum that encodes application verbosity. description: Simple enum that encodes application verbosity with various useful instances.@@ -55,6 +55,10 @@ description: Define instance for Serialize type class. default: False +flag safecopy+ description: Define instance for SafeCopy type class.+ default: False+ library hs-source-dirs: src exposed-modules: Data.Verbosity, Data.Verbosity.Class@@ -111,6 +115,16 @@ cpp-options: -DDECLARE_SERIALIZE_INSTANCE build-depends: cereal >=0.1 && <0.6 + if flag(safecopy)+ cpp-options: -DDECLARE_SAFECOPY_INSTANCE+ build-depends: safecopy >=0.5 && <0.10+ -- Version 0.5 introduced:+ --+ -- deriveSafeCopy :: Version a -> Name -> Name -> Q [Dec]+ --+ -- It's type signature hadn't changed since. Latest version of safecopy at+ -- the moment of writing this is 0.9.1.+ source-repository head type: git location: git://github.com/trskop/verbosity@@ -118,4 +132,4 @@ source-repository this type: git location: git://github.com/trskop/verbosity.git- tag: 0.2.2.0+ tag: 0.2.3.0