Skip to content

Commit

Permalink
Make prettyToText return strict Text and add prettyToLazyText. Export…
Browse files Browse the repository at this point in the history
… Doc
  • Loading branch information
newhoggy committed Nov 17, 2023
1 parent 74fe801 commit b801e3b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cardano-api/internal/Cardano/Api/Pretty.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module Cardano.Api.Pretty
( Ann
, Doc
, Pretty(..)
, ShowOf(..)
, viaShow
, prettyToLazyText
, prettyToText
, prettyToString
, pshow
Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit b801e3b

Please sign in to comment.