module Control.Monad.Log.Label where
import Control.Monad.Log
#if !(MIN_VERSION_base(4,8,0))
import Control.Applicative
#endif
import Data.Aeson
import Data.Text (Text)
data Label = Label Text deriving (Show, Eq, Ord)
instance TextShow Label where
showb (Label t) = fromText t
instance ToJSON Label where
toJSON (Label t) = toJSON t
#if MIN_VERSION_aeson(0,10,0)
toEncoding (Label t) = toEncoding t
#endif
instance FromJSON Label where
parseJSON t = Label <$> parseJSON t
withLabel :: (MonadLog Label m) => Label -> m a -> m a
withLabel = withEnv