{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Cardano.Logging.Types.DocuGenerator
(module Cardano.Logging.Types.DocuGenerator)
where
import Cardano.Logging.Types (Namespace)
import Data.Text (Text, unpack)
import Data.Text.Lazy.Builder (Builder)
newtype Documented a = Documented {forall a. Documented a -> [DocMsg a]
undoc :: [DocMsg a]}
deriving stock Int -> Documented a -> ShowS
[Documented a] -> ShowS
Documented a -> String
(Int -> Documented a -> ShowS)
-> (Documented a -> String)
-> ([Documented a] -> ShowS)
-> Show (Documented a)
forall a. Int -> Documented a -> ShowS
forall a. [Documented a] -> ShowS
forall a. Documented a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Int -> Documented a -> ShowS
showsPrec :: Int -> Documented a -> ShowS
$cshow :: forall a. Documented a -> String
show :: Documented a -> String
$cshowList :: forall a. [Documented a] -> ShowS
showList :: [Documented a] -> ShowS
Show
deriving newtype NonEmpty (Documented a) -> Documented a
Documented a -> Documented a -> Documented a
(Documented a -> Documented a -> Documented a)
-> (NonEmpty (Documented a) -> Documented a)
-> (forall b. Integral b => b -> Documented a -> Documented a)
-> Semigroup (Documented a)
forall b. Integral b => b -> Documented a -> Documented a
forall a. NonEmpty (Documented a) -> Documented a
forall a. Documented a -> Documented a -> Documented a
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
forall a b. Integral b => b -> Documented a -> Documented a
$c<> :: forall a. Documented a -> Documented a -> Documented a
<> :: Documented a -> Documented a -> Documented a
$csconcat :: forall a. NonEmpty (Documented a) -> Documented a
sconcat :: NonEmpty (Documented a) -> Documented a
$cstimes :: forall a b. Integral b => b -> Documented a -> Documented a
stimes :: forall b. Integral b => b -> Documented a -> Documented a
Semigroup
data DocMsg a = DocMsg {
forall a. DocMsg a -> Namespace a
dmNamespace :: Namespace a
, forall a. DocMsg a -> [(Text, Text)]
dmMetricsMD :: [(Text, Text)]
, forall a. DocMsg a -> Text
dmMarkdown :: Text
}
instance Show (DocMsg a) where
show :: DocMsg a -> String
show (DocMsg Namespace a
_ [(Text, Text)]
_ Text
md) = Text -> String
unpack Text
md
data DocuResult =
DocuTracer Builder
| DocuMetric Builder
| DocuDatapoint Builder
deriving Int -> DocuResult -> ShowS
[DocuResult] -> ShowS
DocuResult -> String
(Int -> DocuResult -> ShowS)
-> (DocuResult -> String)
-> ([DocuResult] -> ShowS)
-> Show DocuResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DocuResult -> ShowS
showsPrec :: Int -> DocuResult -> ShowS
$cshow :: DocuResult -> String
show :: DocuResult -> String
$cshowList :: [DocuResult] -> ShowS
showList :: [DocuResult] -> ShowS
Show
unpackDocu :: DocuResult -> Builder
unpackDocu :: DocuResult -> Builder
unpackDocu (DocuTracer Builder
b) = Builder
b
unpackDocu (DocuMetric Builder
b) = Builder
b
unpackDocu (DocuDatapoint Builder
b) = Builder
b
resultIsTracer :: DocuResult -> Bool
resultIsTracer :: DocuResult -> Bool
resultIsTracer DocuTracer{} = Bool
True
resultIsTracer DocuResult
_ = Bool
False
resultIsMetric :: DocuResult -> Bool
resultIsMetric :: DocuResult -> Bool
resultIsMetric DocuMetric{} = Bool
True
resultIsMetric DocuResult
_ = Bool
False
resultIsDatapoint :: DocuResult -> Bool
resultIsDatapoint :: DocuResult -> Bool
resultIsDatapoint DocuDatapoint{} = Bool
True
resultIsDatapoint DocuResult
_ = Bool
False