Skip to content

Commit

Permalink
Merge pull request #3 from scrive/dev-jco-no-issue-add-showtp-function
Browse files Browse the repository at this point in the history
[NO-ISSUE] Add `showtp` pretty printing function
  • Loading branch information
joncol authored Jul 6, 2022
2 parents ab21d22 + 773a2bf commit 1c04ad9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions scrive-prelude.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,5 @@ library
, fields-json
, hpqtypes
, optics
, pretty-simple
, text
13 changes: 13 additions & 0 deletions src/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module Prelude (
, unexpectedError
, throwLeft
, showt
, showtp
) where

import Control.Applicative
Expand All @@ -66,13 +67,17 @@ import GHC.Stack (HasCallStack, withFrozenCallStack)
import Optics
import Text.JSON.FromJSValue
import Text.JSON.ToJSValue
import Text.Pretty.Simple
( OutputOptions(..), defaultOutputOptionsDarkBg, pShowOpt
)
import "base" Prelude hiding
( (!!), (&&), (||), all, and, any, error, fail, head, id, last, maximum
, minimum, not, or, read, tail
)
import qualified Data.Either.Optics as O
import qualified Data.Maybe.Optics as O
import qualified Data.Text as T
import qualified Data.Text.Lazy as TL
import qualified Data.Tuple.Optics as O
import qualified Optics as O
( A_Fold, A_Getter, A_Lens, A_Prism, A_ReversedLens, A_ReversedPrism, A_Review
Expand Down Expand Up @@ -223,3 +228,11 @@ negativeIndexError fname = unexpectedError $ fname <> " received a negative inde

showt :: Show a => a -> Text
showt = T.pack . show

-- | Pretty print anything with a `Show` instance.
showtp :: Show a => a -> T.Text
showtp = TL.toStrict . pShowOpt
(defaultOutputOptionsDarkBg { outputOptionsCompact = True
, outputOptionsPageWidth = 180
}
)

0 comments on commit 1c04ad9

Please sign in to comment.