module Distribution.Verbosity (
Verbosity,
silent, normal, verbose, deafening,
moreVerbose, lessVerbose,
intToVerbosity, flagToVerbosity,
showForCabal, showForGHC
) where
import Data.List (elemIndex)
import Distribution.ReadE
data Verbosity = Silent | Normal | Verbose | Deafening
deriving (D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow, D:Read ::
(Int -> ReadS a)
-> ReadS [a]
-> ReadPrec a
-> ReadPrec [a]
-> T:Read aRead, D:Eq :: (a -> a -> Bool) -> (a -> a -> Bool) -> T:Eq aEq, D:Ord ::
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> T:Ord aOrd, D:Enum ::
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> T:Enum aEnum, D:Bounded :: a -> a -> T:Bounded aBounded)
silent :: Verbosity
silent = Silent :: VerbositySilent
normal :: Verbosity
normal = Normal :: VerbosityNormal
verbose :: Verbosity
verbose = Verbose :: VerbosityVerbose
deafening :: Verbosity
deafening = Deafening :: VerbosityDeafening
moreVerbose :: Verbosity -> Verbosity
moreVerbose Silent = Silent :: VerbositySilent
moreVerbose Normal = Verbose :: VerbosityVerbose
moreVerbose Verbose = Deafening :: VerbosityDeafening
moreVerbose Deafening = Deafening :: VerbosityDeafening
lessVerbose :: Verbosity -> Verbosity
lessVerbose Deafening = Deafening :: VerbosityDeafening
lessVerbose Verbose = Normal :: VerbosityNormal
lessVerbose Normal = Silent :: VerbositySilent
lessVerbose Silent = Silent :: VerbositySilent
intToVerbosity :: Int -> Maybe Verbosity
intToVerbosity 0 = Just :: a -> Maybe aJust Silent :: VerbositySilent
intToVerbosity 1 = Just :: a -> Maybe aJust Normal :: VerbosityNormal
intToVerbosity 2 = Just :: a -> Maybe aJust Verbose :: VerbosityVerbose
intToVerbosity 3 = Just :: a -> Maybe aJust Deafening :: VerbosityDeafening
intToVerbosity _ = Nothing :: Maybe aNothing
flagToVerbosity :: ReadE Verbosity
flagToVerbosity = ReadE :: (String -> Either ErrorMsg a) -> ReadE aReadE ($) :: (a -> b) -> a -> b$ \s ->
case reads :: Read a => ReadS areads s :: Strings of
[(i, "")] ->
case intToVerbosity :: Int -> Maybe VerbosityintToVerbosity i :: Inti of
Just v -> Right :: b -> Either a bRight v :: Verbosityv
Nothing -> Left :: a -> Either a bLeft ("Bad verbosity: " (++) :: [a] -> [a] -> [a]++ show :: Show a => a -> Stringshow i :: Inti (++) :: [a] -> [a] -> [a]++
". Valid values are 0..3")
_ -> Left :: a -> Either a bLeft ("Can't parse verbosity " (++) :: [a] -> [a] -> [a]++ s :: Strings)
showForCabal, showForGHC :: Verbosity -> String
showForCabal v = maybe :: b -> (a -> b) -> Maybe a -> bmaybe (error :: [Char] -> aerror "unknown verbosity") show :: Show a => a -> Stringshow ($) :: (a -> b) -> a -> b$
elemIndex :: Eq a => a -> [a] -> Maybe IntelemIndex v :: Verbosityv [silent :: Verbositysilent,normal :: Verbositynormal,verbose :: Verbosityverbose,deafening :: Verbositydeafening]
showForGHC v = maybe :: b -> (a -> b) -> Maybe a -> bmaybe (error :: [Char] -> aerror "unknown verbosity") show :: Show a => a -> Stringshow ($) :: (a -> b) -> a -> b$
elemIndex :: Eq a => a -> [a] -> Maybe IntelemIndex v :: Verbosityv [silent :: Verbositysilent,normal :: Verbositynormal,__ :: Verbosity__,verbose :: Verbosityverbose,deafening :: Verbositydeafening]
where __ = silent :: Verbositysilent