otel-effectful-1.0.0: src/Prettyprinter/Extra.hs
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Prettyprinter.Extra where
import Data.Aeson qualified as Aeson
import Data.Aeson.Key qualified as Aeson.Key
import Data.Aeson.Text qualified as Aeson
import Data.List qualified as List
import Prettyprinter.Internal (Doc (..), Pretty (..))
#if MIN_VERSION_prettyprinter(1,7,2)
import Prettyprinter.Internal (PrettyAnn (prettyAnn))
#endif
import Prelude
intercalate :: Doc ann -> [Doc ann] -> Doc ann
intercalate x = mconcat . List.intersperse x
unwords :: [Doc ann] -> Doc ann
unwords = intercalate " "
null :: Doc ann -> Bool
null Empty = True
null _ = False
#if !MIN_VERSION_prettyprinter(1,7,2)
class PrettyAnn ann a where
prettyAnn :: a -> Doc ann
#endif
instance PrettyAnn ann Aeson.Key where
prettyAnn = pretty . Aeson.Key.toText
instance PrettyAnn ann Aeson.Value where
prettyAnn (Aeson.String t) = pretty t
prettyAnn v = pretty $ Aeson.encodeToLazyText v
instance {-# OVERLAPPING #-} PrettyAnn ann (Aeson.Key, Aeson.Value) where
prettyAnn (key, value) = prettyAnn key <> "=" <> prettyAnn value