{-# LANGUAGE DeriveDataTypeable #-}-- | A module to deal with verbosity, how \'chatty\' a program should be.-- This module defines the 'Verbosity' data type, along with functions-- for manipulating a global verbosity value.moduleSystem.Console.CmdArgs.Verbosity(Verbosity(..),setVerbosity,getVerbosity,isNormal,isLoud,whenNormal,whenLoud)whereimportControl.MonadimportData.DataimportData.IORefimportSystem.IO.Unsafe-- | The verbosity data typedataVerbosity=Quiet-- ^ Only output essential messages (typically errors)|Normal-- ^ Output normal messages (typically errors and warnings)|Loud-- ^ Output lots of messages (typically errors, warnings and status updates)deriving(Eq,Ord,Bounded,Enum,Show,Read,Data,Typeable){-# NOINLINE ref #-}ref::IORefVerbosityref=unsafePerformIO$newIORefNormal-- | Set the global verbosity.setVerbosity::Verbosity->IO()setVerbosity=writeIORefref-- | Get the global verbosity. Initially @Normal@ before any calls to 'setVerbosity'.getVerbosity::IOVerbositygetVerbosity=readIORefref-- | Used to test if warnings should be output to the user.-- @True@ if the verbosity is set to 'Normal' or 'Loud' (when @--quiet@ is /not/ specified).isNormal::IOBoolisNormal=fmap(>=Normal)getVerbosity-- | Used to test if status updates should be output to the user.-- @True@ if the verbosity is set to 'Loud' (when @--verbose@ is specified).isLoud::IOBoolisLoud=fmap(>=Loud)getVerbosity-- | An action to perform if the verbosity is normal or higher, based on 'isNormal'.whenNormal::IO()->IO()whenNormalact=dob<-isNormalwhenbact-- | An action to perform if the verbosity is loud, based on 'isLoud'.whenLoud::IO()->IO()whenLoudact=dob<-isLoudwhenbact