From b801e3b44312d38fddca4a065ccf929514bcd742 Mon Sep 17 00:00:00 2001 From: John Ky Date: Fri, 17 Nov 2023 20:46:02 +1100 Subject: [PATCH] Make prettyToText return strict Text and add prettyToLazyText. Export Doc --- cardano-api/internal/Cardano/Api/Pretty.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cardano-api/internal/Cardano/Api/Pretty.hs b/cardano-api/internal/Cardano/Api/Pretty.hs index 73c6b41c9b..b5cff832d3 100644 --- a/cardano-api/internal/Cardano/Api/Pretty.hs +++ b/cardano-api/internal/Cardano/Api/Pretty.hs @@ -1,8 +1,10 @@ module Cardano.Api.Pretty ( Ann + , Doc , Pretty(..) , ShowOf(..) , viaShow + , prettyToLazyText , prettyToText , prettyToString , pshow @@ -17,6 +19,7 @@ module Cardano.Api.Pretty , white ) where +import qualified Data.Text as Text import qualified Data.Text.Lazy as TextLazy import Prettyprinter import Prettyprinter.Render.Terminal @@ -34,8 +37,11 @@ instance Show a => Pretty (ShowOf a) where prettyToString :: Doc AnsiStyle -> String prettyToString = show -prettyToText :: Doc AnsiStyle -> TextLazy.Text -prettyToText = renderLazy . layoutPretty defaultLayoutOptions +prettyToLazyText :: Doc AnsiStyle -> TextLazy.Text +prettyToLazyText = renderLazy . layoutPretty defaultLayoutOptions + +prettyToText :: Doc AnsiStyle -> Text.Text +prettyToText = TextLazy.toStrict . prettyToLazyText black :: Doc AnsiStyle -> Doc AnsiStyle black = annotate (color Black)