module UVMHS.Lib.Pretty.RenderANSI where

import UVMHS.Core

import UVMHS.Lib.TreeAnnote
import UVMHS.Lib.Sep

import UVMHS.Lib.Pretty.Color
import UVMHS.Lib.Pretty.Annotation
import UVMHS.Lib.Pretty.Common
import UVMHS.Lib.Pretty.Doc
import UVMHS.Lib.Pretty.DocA
import UVMHS.Lib.Pretty.RenderUndertags

import Data.IORef (IORef)
import qualified Data.IORef as IORef

data ANSIEnv = ANSIEnv
  -- global env
  { ANSIEnv -> 𝔹
ansiEnvDoFormat  𝔹
  -- local env
  , ANSIEnv -> Formats
ansiEnvFormats  Formats
  } deriving (ANSIEnv -> ANSIEnv -> 𝔹
(ANSIEnv -> ANSIEnv -> 𝔹)
-> (ANSIEnv -> ANSIEnv -> 𝔹) -> Eq ANSIEnv
forall a. (a -> a -> 𝔹) -> (a -> a -> 𝔹) -> Eq a
$c== :: ANSIEnv -> ANSIEnv -> 𝔹
== :: ANSIEnv -> ANSIEnv -> 𝔹
$c/= :: ANSIEnv -> ANSIEnv -> 𝔹
/= :: ANSIEnv -> ANSIEnv -> 𝔹
Eq,Eq ANSIEnv
Eq ANSIEnv =>
(ANSIEnv -> ANSIEnv -> Ordering)
-> (ANSIEnv -> ANSIEnv -> 𝔹)
-> (ANSIEnv -> ANSIEnv -> 𝔹)
-> (ANSIEnv -> ANSIEnv -> 𝔹)
-> (ANSIEnv -> ANSIEnv -> 𝔹)
-> (ANSIEnv -> ANSIEnv -> ANSIEnv)
-> (ANSIEnv -> ANSIEnv -> ANSIEnv)
-> Ord ANSIEnv
ANSIEnv -> ANSIEnv -> 𝔹
ANSIEnv -> ANSIEnv -> Ordering
ANSIEnv -> ANSIEnv -> ANSIEnv
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> 𝔹)
-> (a -> a -> 𝔹)
-> (a -> a -> 𝔹)
-> (a -> a -> 𝔹)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ANSIEnv -> ANSIEnv -> Ordering
compare :: ANSIEnv -> ANSIEnv -> Ordering
$c< :: ANSIEnv -> ANSIEnv -> 𝔹
< :: ANSIEnv -> ANSIEnv -> 𝔹
$c<= :: ANSIEnv -> ANSIEnv -> 𝔹
<= :: ANSIEnv -> ANSIEnv -> 𝔹
$c> :: ANSIEnv -> ANSIEnv -> 𝔹
> :: ANSIEnv -> ANSIEnv -> 𝔹
$c>= :: ANSIEnv -> ANSIEnv -> 𝔹
>= :: ANSIEnv -> ANSIEnv -> 𝔹
$cmax :: ANSIEnv -> ANSIEnv -> ANSIEnv
max :: ANSIEnv -> ANSIEnv -> ANSIEnv
$cmin :: ANSIEnv -> ANSIEnv -> ANSIEnv
min :: ANSIEnv -> ANSIEnv -> ANSIEnv
Ord,Int -> ANSIEnv -> ShowS
[ANSIEnv] -> ShowS
ANSIEnv -> String
(Int -> ANSIEnv -> ShowS)
-> (ANSIEnv -> String) -> ([ANSIEnv] -> ShowS) -> Show ANSIEnv
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ANSIEnv -> ShowS
showsPrec :: Int -> ANSIEnv -> ShowS
$cshow :: ANSIEnv -> String
show :: ANSIEnv -> String
$cshowList :: [ANSIEnv] -> ShowS
showList :: [ANSIEnv] -> ShowS
Show)
makeLenses ''ANSIEnv

ansiEnv₀  ANSIEnv
ansiEnv₀ :: ANSIEnv
ansiEnv₀ = 𝔹 -> Formats -> ANSIEnv
ANSIEnv 𝔹
True Formats
forall a. Null a => a
null

type RenderANSIM = RWS ANSIEnv (𝐼A 𝕊) ()

sgrLeader  𝕊
sgrLeader :: 𝕊
sgrLeader = 𝕊
"\ESC["

sgrCloser  𝕊
sgrCloser :: 𝕊
sgrCloser = 𝕊
"m"

sgrReset  𝕊
sgrReset :: 𝕊
sgrReset = 𝕊
sgrLeader 𝕊 -> 𝕊 -> 𝕊
forall a. Append a => a -> a -> a
 𝕊
"0" 𝕊 -> 𝕊 -> 𝕊
forall a. Append a => a -> a -> a
 𝕊
sgrCloser

sgrFg  Color  𝕊
sgrFg :: Color -> 𝕊
sgrFg = \case
  Color Color3Bit
c  case Color3Bit
c of
    Color3Bit
DefaultColor  𝕊
"39"
    Color3Bit
Black         𝕊
"30"
    Color3Bit
Red           𝕊
"31"
    Color3Bit
Green         𝕊
"32"
    Color3Bit
Yellow        𝕊
"33"
    Color3Bit
Blue          𝕊
"34"
    Color3Bit
Magenta       𝕊
"35"
    Color3Bit
Cyan          𝕊
"36"
    Color3Bit
GrayLight     𝕊
"37"
    Color3Bit
GrayDark      𝕊
"90"
    Color3Bit
RedLight      𝕊
"91"
    Color3Bit
GreenLight    𝕊
"92"
    Color3Bit
YellowLight   𝕊
"93"
    Color3Bit
BlueLight     𝕊
"94"
    Color3Bit
PinkLight     𝕊
"95"
    Color3Bit
TealLight     𝕊
"96"
    Color3Bit
White         𝕊
"97"
  Color8 ℕ8
c  𝕊
"38;5;" 𝕊 -> 𝕊 -> 𝕊
forall a. Append a => a -> a -> a
 ℕ8 -> 𝕊
forall a. Show a => a -> 𝕊
show𝕊 ℕ8
c
  Color24 ℕ8
r ℕ8
g ℕ8
b  𝕊
"38;2;" 𝕊 -> 𝕊 -> 𝕊
forall a. Append a => a -> a -> a
 ℕ8 -> 𝕊
forall a. Show a => a -> 𝕊
show𝕊 ℕ8
r 𝕊 -> 𝕊 -> 𝕊
forall a. Append a => a -> a -> a
 𝕊
";" 𝕊 -> 𝕊 -> 𝕊
forall a. Append a => a -> a -> a
 ℕ8 -> 𝕊
forall a. Show a => a -> 𝕊
show𝕊 ℕ8
g 𝕊 -> 𝕊 -> 𝕊
forall a. Append a => a -> a -> a
 𝕊
";" 𝕊 -> 𝕊 -> 𝕊
forall a. Append a => a -> a -> a
 ℕ8 -> 𝕊
forall a. Show a => a -> 𝕊
show𝕊 ℕ8
b

sgrBg  Color  𝕊
sgrBg :: Color -> 𝕊
sgrBg = \case
  Color Color3Bit
c  case Color3Bit
c of
    Color3Bit
DefaultColor  𝕊
"49"
    Color3Bit
Black         𝕊
"40"
    Color3Bit
Red           𝕊
"41"
    Color3Bit
Green         𝕊
"42"
    Color3Bit
Yellow        𝕊
"43"
    Color3Bit
Blue          𝕊
"44"
    Color3Bit
Magenta       𝕊
"45"
    Color3Bit
Cyan          𝕊
"46"
    Color3Bit
GrayLight     𝕊
"47"
    Color3Bit
GrayDark      𝕊
"100"
    Color3Bit
RedLight      𝕊
"101"
    Color3Bit
GreenLight    𝕊
"102"
    Color3Bit
YellowLight   𝕊
"103"
    Color3Bit
BlueLight     𝕊
"104"
    Color3Bit
PinkLight     𝕊
"105"
    Color3Bit
TealLight     𝕊
"106"
    Color3Bit
White         𝕊
"107"
  Color8 ℕ8
c  𝕊
"48;5;" 𝕊 -> 𝕊 -> 𝕊
forall a. Append a => a -> a -> a
 ℕ8 -> 𝕊
forall a. Show a => a -> 𝕊
show𝕊 ℕ8
c
  Color24 ℕ8
r ℕ8
g ℕ8
b  𝕊
"48;2;" 𝕊 -> 𝕊 -> 𝕊
forall a. Append a => a -> a -> a
 ℕ8 -> 𝕊
forall a. Show a => a -> 𝕊
show𝕊 ℕ8
r 𝕊 -> 𝕊 -> 𝕊
forall a. Append a => a -> a -> a
 𝕊
";" 𝕊 -> 𝕊 -> 𝕊
forall a. Append a => a -> a -> a
 ℕ8 -> 𝕊
forall a. Show a => a -> 𝕊
show𝕊 ℕ8
g 𝕊 -> 𝕊 -> 𝕊
forall a. Append a => a -> a -> a
 𝕊
";" 𝕊 -> 𝕊 -> 𝕊
forall a. Append a => a -> a -> a
 ℕ8 -> 𝕊
forall a. Show a => a -> 𝕊
show𝕊 ℕ8
b
  
sgrUl  𝔹  𝕊
sgrUl :: 𝔹 -> 𝕊
sgrUl 𝔹
True = 𝕊
"4"
sgrUl 𝔹
False = 𝕊
"24"

sgrBd  𝔹  𝕊
sgrBd :: 𝔹 -> 𝕊
sgrBd 𝔹
True = 𝕊
"1"
sgrBd 𝔹
False = 𝕊
"22"

sgrIt  𝔹  𝕊
sgrIt :: 𝔹 -> 𝕊
sgrIt 𝔹
True = 𝕊
"3"
sgrIt 𝔹
False = 𝕊
"23"

sgrFormat  Formats  𝐼A 𝕊
sgrFormat :: Formats -> 𝐼A 𝕊
sgrFormat (Formats 𝑂 Color
fg 𝑂 Color
bg 𝑂 𝔹
ul 𝑂 𝔹
bd 𝑂 𝔹
it) = 𝕊 -> 𝐼A 𝕊
forall a t. Single a t => a -> t
single (𝕊 -> 𝐼A 𝕊) -> 𝕊 -> 𝐼A 𝕊
forall a b. (a -> b) -> a -> b
$ 𝐼 𝕊 -> 𝕊
forall t. ToIter 𝕊 t => t -> 𝕊
stringS (𝐼 𝕊 -> 𝕊) -> 𝐼 𝕊 -> 𝕊
forall a b. (a -> b) -> a -> b
$ [𝕊] -> 𝐼 𝕊
forall a t. ToIter a t => t -> 𝐼 a
iter
  [ 𝕊
sgrLeader 
  , 𝐼 𝕊 -> 𝕊
forall a t. (Monoid a, ToIter a t) => t -> a
concat (𝐼 𝕊 -> 𝕊) -> 𝐼 𝕊 -> 𝕊
forall a b. (a -> b) -> a -> b
$ 𝕊 -> 𝑄 𝕊 -> 𝐼 𝕊
forall a t. ToIter a t => a -> t -> 𝐼 a
inbetween 𝕊
";" (𝑄 𝕊 -> 𝐼 𝕊) -> 𝑄 𝕊 -> 𝐼 𝕊
forall a b. (a -> b) -> a -> b
$ 𝐼 (𝑄 𝕊) -> 𝑄 𝕊
forall {k} (m :: k -> *) (a :: k) t.
(MonadNondet m, ToIter (m a) t) =>
t -> m a
mconcat (𝐼 (𝑄 𝕊) -> 𝑄 𝕊) -> 𝐼 (𝑄 𝕊) -> 𝑄 𝕊
forall a b. (a -> b) -> a -> b
$ (𝑂 𝕊 -> 𝑄 𝕊) -> 𝐼 (𝑂 𝕊) -> 𝐼 (𝑄 𝕊)
forall a b. (a -> b) -> 𝐼 a -> 𝐼 b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map (forall (m :: * -> *) a. (Monad m, MonadNondet m) => 𝑂 a -> m a
mzero𝑂 @𝑄) (𝐼 (𝑂 𝕊) -> 𝐼 (𝑄 𝕊)) -> 𝐼 (𝑂 𝕊) -> 𝐼 (𝑄 𝕊)
forall a b. (a -> b) -> a -> b
$ [𝑂 𝕊] -> 𝐼 (𝑂 𝕊)
forall a t. ToIter a t => t -> 𝐼 a
iter
      [ Color -> 𝕊
sgrFg (Color -> 𝕊) -> 𝑂 Color -> 𝑂 𝕊
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
^$ 𝑂 Color
fg
      , Color -> 𝕊
sgrBg (Color -> 𝕊) -> 𝑂 Color -> 𝑂 𝕊
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
^$ 𝑂 Color
bg
      , 𝔹 -> 𝕊
sgrUl (𝔹 -> 𝕊) -> 𝑂 𝔹 -> 𝑂 𝕊
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
^$ 𝑂 𝔹
ul
      , 𝔹 -> 𝕊
sgrBd (𝔹 -> 𝕊) -> 𝑂 𝔹 -> 𝑂 𝕊
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
^$ 𝑂 𝔹
bd
      , 𝔹 -> 𝕊
sgrIt (𝔹 -> 𝕊) -> 𝑂 𝔹 -> 𝑂 𝕊
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
^$ 𝑂 𝔹
it
      ]
  , 𝕊
sgrCloser
  ]

tellSgrFormat  RenderANSIM ()
tellSgrFormat :: RenderANSIM ()
tellSgrFormat = do
  Formats
cf  (ANSIEnv ⟢ Formats) -> RWST ANSIEnv (𝐼A 𝕊) () ID Formats
forall r'. (ANSIEnv ⟢ r') -> RWST ANSIEnv (𝐼A 𝕊) () ID r'
forall r (m :: * -> *) r'. MonadReader r m => (r ⟢ r') -> m r'
askL ANSIEnv ⟢ Formats
ansiEnvFormatsL
  𝐼A 𝕊 -> RenderANSIM ()
forall o (m :: * -> *). MonadWriter o m => o -> m ()
tell (𝐼A 𝕊 -> RenderANSIM ()) -> 𝐼A 𝕊 -> RenderANSIM ()
forall a b. (a -> b) -> a -> b
$ Formats -> 𝐼A 𝕊
sgrFormat Formats
cf

localFormat  Formats  RenderANSIM ()  RenderANSIM ()
localFormat :: Formats -> RenderANSIM () -> RenderANSIM ()
localFormat Formats
f RenderANSIM ()
aM = do
  (ANSIEnv ⟢ Formats)
-> (Formats -> Formats) -> RenderANSIM () -> RenderANSIM ()
forall (m :: * -> *) r₁ r₂ a.
(Monad m, MonadReader r₁ m) =>
(r₁ ⟢ r₂) -> (r₂ -> r₂) -> m a -> m a
mapEnvL ANSIEnv ⟢ Formats
ansiEnvFormatsL (Formats -> Formats -> Formats
forall a. Append a => a -> a -> a
prepend Formats
f) (RenderANSIM () -> RenderANSIM ())
-> RenderANSIM () -> RenderANSIM ()
forall a b. (a -> b) -> a -> b
$ do
    RenderANSIM ()
tellSgrFormat
    RenderANSIM ()
aM
  𝐼A 𝕊 -> RenderANSIM ()
forall o (m :: * -> *). MonadWriter o m => o -> m ()
tell (𝐼A 𝕊 -> RenderANSIM ()) -> 𝐼A 𝕊 -> RenderANSIM ()
forall a b. (a -> b) -> a -> b
$ 𝕊 -> 𝐼A 𝕊
forall a t. Single a t => a -> t
single 𝕊
sgrReset
  RenderANSIM ()
tellSgrFormat

renderChunkANSI  ChunkO  𝐼A 𝕊
renderChunkANSI :: ChunkO -> 𝐼A 𝕊
renderChunkANSI = \case
  RawChunkO     ℕ64
n 𝕊
s  ℕ64 -> 𝐼 𝕊 -> 𝐼A 𝕊
forall a. ℕ64 -> 𝐼 a -> 𝐼A a
𝐼A ℕ64
n (𝐼 𝕊 -> 𝐼A 𝕊) -> 𝐼 𝕊 -> 𝐼A 𝕊
forall a b. (a -> b) -> a -> b
$ 𝕊 -> 𝐼 𝕊
forall a t. Single a t => a -> t
single 𝕊
s
  PaddingChunkO ℕ64
n    ℕ64 -> 𝐼 𝕊 -> 𝐼A 𝕊
forall a. ℕ64 -> 𝐼 a -> 𝐼A a
𝐼A ℕ64
n (𝐼 𝕊 -> 𝐼A 𝕊) -> 𝐼 𝕊 -> 𝐼A 𝕊
forall a b. (a -> b) -> a -> b
$ 𝕊 -> 𝐼 𝕊
forall a t. Single a t => a -> t
single (𝕊 -> 𝐼 𝕊) -> 𝕊 -> 𝐼 𝕊
forall a b. (a -> b) -> a -> b
$ 𝐼 ℂ -> 𝕊
forall t. ToIter ℂ t => t -> 𝕊
string (𝐼 ℂ -> 𝕊) -> 𝐼 ℂ -> 𝕊
forall a b. (a -> b) -> a -> b
$ ℕ -> ℂ -> 𝐼 ℂ
forall n a. (Eq n, Zero n, One n, Plus n) => n -> a -> 𝐼 a
replicate (ℕ64 -> ℕ
forall a. ToNat a => a -> ℕ
nat ℕ64
n) ' '
  
formatRenderANSI  Formats  RenderANSIM ()  RenderANSIM ()
formatRenderANSI :: Formats -> RenderANSIM () -> RenderANSIM ()
formatRenderANSI Formats
fm RenderANSIM ()
xM = do
  𝔹
b  (ANSIEnv ⟢ 𝔹) -> RWST ANSIEnv (𝐼A 𝕊) () ID 𝔹
forall r'. (ANSIEnv ⟢ r') -> RWST ANSIEnv (𝐼A 𝕊) () ID r'
forall r (m :: * -> *) r'. MonadReader r m => (r ⟢ r') -> m r'
askL ANSIEnv ⟢ 𝔹
ansiEnvDoFormatL
  case 𝔹
b of
    𝔹
True  Formats -> RenderANSIM () -> RenderANSIM ()
localFormat Formats
fm RenderANSIM ()
xM
    𝔹
False  RenderANSIM ()
xM

compileOTree  TreeO  RenderANSIM ()
compileOTree :: TreeO -> RenderANSIM ()
compileOTree TreeO
sd = TreeO
-> forall b.
   Monoid b =>
   (Sep () (𝐼A ChunkO) -> b) -> (Formats -> b -> b) -> b
forall i a.
𝑇V i a -> forall b. Monoid b => (a -> b) -> (i -> b -> b) -> b
un𝑇V TreeO
sd Sep () (𝐼A ChunkO) -> RenderANSIM ()
fₑ Formats -> RenderANSIM () -> RenderANSIM ()
fₐ
  where
    fₑ  Sep () (𝐼A ChunkO)  RenderANSIM ()
    fₑ :: Sep () (𝐼A ChunkO) -> RenderANSIM ()
fₑ Sep () (𝐼A ChunkO)
chs = (𝐼A 𝕊 -> RenderANSIM ()) -> 𝐼 (𝐼A 𝕊) -> RenderANSIM ()
forall (m :: * -> *) a t.
(Monad m, ToIter a t) =>
(a -> m ()) -> t -> m ()
eachWith 𝐼A 𝕊 -> RenderANSIM ()
forall o (m :: * -> *). MonadWriter o m => o -> m ()
tell (𝐼 (𝐼A 𝕊) -> RenderANSIM ()) -> 𝐼 (𝐼A 𝕊) -> RenderANSIM ()
forall a b. (a -> b) -> a -> b
$ Sep (𝐼A 𝕊) (𝐼A 𝕊) -> 𝐼 (𝐼A 𝕊)
forall a t. ToIter a t => t -> 𝐼 a
iter (Sep (𝐼A 𝕊) (𝐼A 𝕊) -> 𝐼 (𝐼A 𝕊)) -> Sep (𝐼A 𝕊) (𝐼A 𝕊) -> 𝐼 (𝐼A 𝕊)
forall a b. (a -> b) -> a -> b
$ (() -> 𝐼A 𝕊)
-> (𝐼A ChunkO -> 𝐼A 𝕊) -> Sep () (𝐼A ChunkO) -> Sep (𝐼A 𝕊) (𝐼A 𝕊)
forall i j a b. (i -> j) -> (a -> b) -> Sep i a -> Sep j b
mapSep (𝐼A 𝕊 -> () -> 𝐼A 𝕊
forall a b. a -> b -> a
const (𝐼A 𝕊 -> () -> 𝐼A 𝕊) -> 𝐼A 𝕊 -> () -> 𝐼A 𝕊
forall a b. (a -> b) -> a -> b
$ forall a t. Single a t => a -> t
single @_ @(𝐼A _) (𝕊 -> 𝐼A 𝕊) -> 𝕊 -> 𝐼A 𝕊
forall a b. (a -> b) -> a -> b
$ String -> 𝕊
𝕤 String
"\n") (𝐼 (𝐼A 𝕊) -> 𝐼A 𝕊
forall a t. (Monoid a, ToIter a t) => t -> a
concat (𝐼 (𝐼A 𝕊) -> 𝐼A 𝕊) -> (𝐼 ChunkO -> 𝐼 (𝐼A 𝕊)) -> 𝐼 ChunkO -> 𝐼A 𝕊
forall b c a. (b -> c) -> (a -> b) -> a -> c
 (ChunkO -> 𝐼A 𝕊) -> 𝐼 ChunkO -> 𝐼 (𝐼A 𝕊)
forall a b. (a -> b) -> 𝐼 a -> 𝐼 b
forall (t :: * -> *) a b. Functor t => (a -> b) -> t a -> t b
map ChunkO -> 𝐼A 𝕊
renderChunkANSI (𝐼 ChunkO -> 𝐼A 𝕊) -> (𝐼A ChunkO -> 𝐼 ChunkO) -> 𝐼A ChunkO -> 𝐼A 𝕊
forall b c a. (b -> c) -> (a -> b) -> a -> c
 𝐼A ChunkO -> 𝐼 ChunkO
forall a t. ToIter a t => t -> 𝐼 a
iter) Sep () (𝐼A ChunkO)
chs
    fₐ  Formats  RenderANSIM ()  RenderANSIM ()
    fₐ :: Formats -> RenderANSIM () -> RenderANSIM ()
fₐ Formats
fm = Formats -> RenderANSIM () -> RenderANSIM ()
formatRenderANSI Formats
fm

execRenderANSIWith  (RenderANSIM ()  RenderANSIM ())  TreeO  𝐼A 𝕊
execRenderANSIWith :: (RenderANSIM () -> RenderANSIM ()) -> TreeO -> 𝐼A 𝕊
execRenderANSIWith RenderANSIM () -> RenderANSIM ()
f = ANSIEnv -> () -> RWS ANSIEnv (𝐼A 𝕊) () (𝐼A 𝕊) -> 𝐼A 𝕊
forall r o s a. r -> s -> RWS r o s a -> a
evalRWS ANSIEnv
ansiEnv₀ () (RWS ANSIEnv (𝐼A 𝕊) () (𝐼A 𝕊) -> 𝐼A 𝕊)
-> (RenderANSIM () -> RWS ANSIEnv (𝐼A 𝕊) () (𝐼A 𝕊))
-> RenderANSIM ()
-> 𝐼A 𝕊
forall b c a. (b -> c) -> (a -> b) -> a -> c
 RenderANSIM () -> RWS ANSIEnv (𝐼A 𝕊) () (𝐼A 𝕊)
forall o (m :: * -> *) a. (Monad m, MonadWriter o m) => m a -> m o
retOut (RenderANSIM () -> 𝐼A 𝕊)
-> (RenderANSIM () -> RenderANSIM ()) -> RenderANSIM () -> 𝐼A 𝕊
forall b c a. (b -> c) -> (a -> b) -> a -> c
 RenderANSIM () -> RenderANSIM ()
f (RenderANSIM () -> 𝐼A 𝕊)
-> (TreeO -> RenderANSIM ()) -> TreeO -> 𝐼A 𝕊
forall b c a. (b -> c) -> (a -> b) -> a -> c
 TreeO -> RenderANSIM ()
compileOTree

execRenderANSI  TreeO  𝐼A 𝕊
execRenderANSI :: TreeO -> 𝐼A 𝕊
execRenderANSI = (RenderANSIM () -> RenderANSIM ()) -> TreeO -> 𝐼A 𝕊
execRenderANSIWith RenderANSIM () -> RenderANSIM ()
forall a. a -> a
id

gv_PPRINT_COLOR  IORef 𝔹
gv_PPRINT_COLOR :: IORef 𝔹
gv_PPRINT_COLOR = IO (IORef 𝔹) -> IORef 𝔹
forall a. IO a -> a
io_UNSAFE (IO (IORef 𝔹) -> IORef 𝔹) -> IO (IORef 𝔹) -> IORef 𝔹
forall a b. (a -> b) -> a -> b
$ 𝔹 -> IO (IORef 𝔹)
forall a. a -> IO (IORef a)
IORef.newIORef 𝔹
True

ppRenderWith  (RenderANSIM ()  RenderANSIM ()) 
              (DocAM ()  DocAM ())
              (DocM ()  DocM ())
              Doc  𝕊
ppRenderWith :: (RenderANSIM () -> RenderANSIM ())
-> (DocAM () -> DocAM ()) -> (DocM () -> DocM ()) -> Doc -> 𝕊
ppRenderWith RenderANSIM () -> RenderANSIM ()
f₁ DocAM () -> DocAM ()
f₃ DocM () -> DocM ()
f₄ Doc
d = IO 𝕊 -> 𝕊
forall a. IO a -> a
io_UNSAFE (IO 𝕊 -> 𝕊) -> IO 𝕊 -> 𝕊
forall a b. (a -> b) -> a -> b
$ do
  𝔹
b  IORef 𝔹 -> IO 𝔹
forall a. IORef a -> IO a
IORef.readIORef IORef 𝔹
gv_PPRINT_COLOR
  let f₁' :: RenderANSIM () -> RenderANSIM ()
f₁' = (RenderANSIM () -> RenderANSIM ())
-> ((RenderANSIM () -> RenderANSIM ())
    -> RenderANSIM () -> RenderANSIM ())
-> RenderANSIM ()
-> RenderANSIM ()
forall a b. a -> (a -> b) -> b
appto RenderANSIM () -> RenderANSIM ()
f₁ (((RenderANSIM () -> RenderANSIM ())
  -> RenderANSIM () -> RenderANSIM ())
 -> RenderANSIM () -> RenderANSIM ())
-> ((RenderANSIM () -> RenderANSIM ())
    -> RenderANSIM () -> RenderANSIM ())
-> RenderANSIM ()
-> RenderANSIM ()
forall a b. (a -> b) -> a -> b
$ if 𝔹
b then (RenderANSIM () -> RenderANSIM ())
-> RenderANSIM () -> RenderANSIM ()
forall a. a -> a
id else (RenderANSIM () -> RenderANSIM ())
-> (RenderANSIM () -> RenderANSIM ())
-> RenderANSIM ()
-> RenderANSIM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
(∘) ((RenderANSIM () -> RenderANSIM ())
 -> (RenderANSIM () -> RenderANSIM ())
 -> RenderANSIM ()
 -> RenderANSIM ())
-> (RenderANSIM () -> RenderANSIM ())
-> (RenderANSIM () -> RenderANSIM ())
-> RenderANSIM ()
-> RenderANSIM ()
forall a b. (a -> b) -> a -> b
$ (ANSIEnv ⟢ 𝔹) -> 𝔹 -> RenderANSIM () -> RenderANSIM ()
forall a r'.
(ANSIEnv ⟢ r')
-> r' -> RWST ANSIEnv (𝐼A 𝕊) () ID a -> RWST ANSIEnv (𝐼A 𝕊) () ID a
forall r (m :: * -> *) a r'.
MonadReader r m =>
(r ⟢ r') -> r' -> m a -> m a
localL ANSIEnv ⟢ 𝔹
ansiEnvDoFormatL 𝔹
False
  𝕊 -> IO 𝕊
forall a. a -> IO a
forall (m :: * -> *) a. Return m => a -> m a
return (𝕊 -> IO 𝕊) -> 𝕊 -> IO 𝕊
forall a b. (a -> b) -> a -> b
$ Doc -> (Doc -> 𝕊) -> 𝕊
forall a b. a -> (a -> b) -> b
appto Doc
d ((Doc -> 𝕊) -> 𝕊) -> (Doc -> 𝕊) -> 𝕊
forall a b. (a -> b) -> a -> b
$
    𝐼A 𝕊 -> 𝕊
forall t. (ToIter 𝕊 t, ASized t) => t -> 𝕊
stringSS
    (𝐼A 𝕊 -> 𝕊) -> (TreeO -> 𝐼A 𝕊) -> TreeO -> 𝕊
forall b c a. (b -> c) -> (a -> b) -> a -> c
 (RenderANSIM () -> RenderANSIM ()) -> TreeO -> 𝐼A 𝕊
execRenderANSIWith RenderANSIM () -> RenderANSIM ()
f₁'
    (TreeO -> 𝕊) -> (SummaryO -> TreeO) -> SummaryO -> 𝕊
forall b c a. (b -> c) -> (a -> b) -> a -> c
 SummaryO -> TreeO
summaryOContents
    (SummaryO -> 𝕊) -> (TreeI -> SummaryO) -> TreeI -> 𝕊
forall b c a. (b -> c) -> (a -> b) -> a -> c
 TreeI -> SummaryO
execRenderUT
    (TreeI -> 𝕊) -> (DocA -> TreeI) -> DocA -> 𝕊
forall b c a. (b -> c) -> (a -> b) -> a -> c
 (DocAM () -> DocAM ()) -> DocA -> TreeI
execDocAWith DocAM () -> DocAM ()
f₃
    (DocA -> 𝕊) -> (Doc -> DocA) -> Doc -> 𝕊
forall b c a. (b -> c) -> (a -> b) -> a -> c
 (DocM () -> DocM ()) -> Doc -> DocA
execDocWith DocM () -> DocM ()
f₄

ppRender  Doc  𝕊
ppRender :: Doc -> 𝕊
ppRender = (RenderANSIM () -> RenderANSIM ())
-> (DocAM () -> DocAM ()) -> (DocM () -> DocM ()) -> Doc -> 𝕊
ppRenderWith RenderANSIM () -> RenderANSIM ()
forall a. a -> a
id DocAM () -> DocAM ()
forall a. a -> a
id DocM () -> DocM ()
forall a. a -> a
id

ppRenderNoFmt  Doc  𝕊
ppRenderNoFmt :: Doc -> 𝕊
ppRenderNoFmt = (RenderANSIM () -> RenderANSIM ())
-> (DocAM () -> DocAM ()) -> (DocM () -> DocM ()) -> Doc -> 𝕊
ppRenderWith ((ANSIEnv ⟢ 𝔹) -> 𝔹 -> RenderANSIM () -> RenderANSIM ()
forall a r'.
(ANSIEnv ⟢ r')
-> r' -> RWST ANSIEnv (𝐼A 𝕊) () ID a -> RWST ANSIEnv (𝐼A 𝕊) () ID a
forall r (m :: * -> *) a r'.
MonadReader r m =>
(r ⟢ r') -> r' -> m a -> m a
localL ANSIEnv ⟢ 𝔹
ansiEnvDoFormatL 𝔹
False) DocAM () -> DocAM ()
forall a. a -> a
id DocM () -> DocM ()
forall a. a -> a
id

ppRenderYesFmt  Doc  𝕊
ppRenderYesFmt :: Doc -> 𝕊
ppRenderYesFmt = (RenderANSIM () -> RenderANSIM ())
-> (DocAM () -> DocAM ()) -> (DocM () -> DocM ()) -> Doc -> 𝕊
ppRenderWith ((ANSIEnv ⟢ 𝔹) -> 𝔹 -> RenderANSIM () -> RenderANSIM ()
forall a r'.
(ANSIEnv ⟢ r')
-> r' -> RWST ANSIEnv (𝐼A 𝕊) () ID a -> RWST ANSIEnv (𝐼A 𝕊) () ID a
forall r (m :: * -> *) a r'.
MonadReader r m =>
(r ⟢ r') -> r' -> m a -> m a
localL ANSIEnv ⟢ 𝔹
ansiEnvDoFormatL 𝔹
True) DocAM () -> DocAM ()
forall a. a -> a
id DocM () -> DocM ()
forall a. a -> a
id

ppRenderWide  Doc  𝕊
ppRenderWide :: Doc -> 𝕊
ppRenderWide = 
  (RenderANSIM () -> RenderANSIM ())
-> (DocAM () -> DocAM ()) -> (DocM () -> DocM ()) -> Doc -> 𝕊
ppRenderWith RenderANSIM () -> RenderANSIM ()
forall a. a -> a
id 
               ((DocAEnv ⟢ 𝑂 ℕ64) -> 𝑂 ℕ64 -> DocAM () -> DocAM ()
forall a r'.
(DocAEnv ⟢ r')
-> r'
-> RWST DocAEnv TreeI DocAState ID a
-> RWST DocAEnv TreeI DocAState ID a
forall r (m :: * -> *) a r'.
MonadReader r m =>
(r ⟢ r') -> r' -> m a -> m a
localL DocAEnv ⟢ 𝑂 ℕ64
docAEnvMaxLineWidthL 𝑂 ℕ64
forall a. 𝑂 a
None 
                (DocAM () -> DocAM ())
-> (DocAM () -> DocAM ()) -> DocAM () -> DocAM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
 (DocAEnv ⟢ 𝑂 ℕ64) -> 𝑂 ℕ64 -> DocAM () -> DocAM ()
forall a r'.
(DocAEnv ⟢ r')
-> r'
-> RWST DocAEnv TreeI DocAState ID a
-> RWST DocAEnv TreeI DocAState ID a
forall r (m :: * -> *) a r'.
MonadReader r m =>
(r ⟢ r') -> r' -> m a -> m a
localL DocAEnv ⟢ 𝑂 ℕ64
docAEnvMaxRibbonWidthL 𝑂 ℕ64
forall a. 𝑂 a
None) 
               DocM () -> DocM ()
forall a. a -> a
id

ppRenderNarrow  Doc  𝕊
ppRenderNarrow :: Doc -> 𝕊
ppRenderNarrow = 
  (RenderANSIM () -> RenderANSIM ())
-> (DocAM () -> DocAM ()) -> (DocM () -> DocM ()) -> Doc -> 𝕊
ppRenderWith RenderANSIM () -> RenderANSIM ()
forall a. a -> a
id 
               ((DocAEnv ⟢ 𝑂 ℕ64) -> 𝑂 ℕ64 -> DocAM () -> DocAM ()
forall a r'.
(DocAEnv ⟢ r')
-> r'
-> RWST DocAEnv TreeI DocAState ID a
-> RWST DocAEnv TreeI DocAState ID a
forall r (m :: * -> *) a r'.
MonadReader r m =>
(r ⟢ r') -> r' -> m a -> m a
localL DocAEnv ⟢ 𝑂 ℕ64
docAEnvMaxLineWidthL (ℕ64 -> 𝑂 ℕ64
forall a. a -> 𝑂 a
Some ℕ64
forall a. Zero a => a
zero) 
                (DocAM () -> DocAM ())
-> (DocAM () -> DocAM ()) -> DocAM () -> DocAM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
 (DocAEnv ⟢ 𝑂 ℕ64) -> 𝑂 ℕ64 -> DocAM () -> DocAM ()
forall a r'.
(DocAEnv ⟢ r')
-> r'
-> RWST DocAEnv TreeI DocAState ID a
-> RWST DocAEnv TreeI DocAState ID a
forall r (m :: * -> *) a r'.
MonadReader r m =>
(r ⟢ r') -> r' -> m a -> m a
localL DocAEnv ⟢ 𝑂 ℕ64
docAEnvMaxRibbonWidthL (ℕ64 -> 𝑂 ℕ64
forall a. a -> 𝑂 a
Some ℕ64
forall a. Zero a => a
zero)) 
               DocM () -> DocM ()
forall a. a -> a
id

ppRenderNoFmtWide  Doc  𝕊
ppRenderNoFmtWide :: Doc -> 𝕊
ppRenderNoFmtWide = 
  (RenderANSIM () -> RenderANSIM ())
-> (DocAM () -> DocAM ()) -> (DocM () -> DocM ()) -> Doc -> 𝕊
ppRenderWith ((ANSIEnv ⟢ 𝔹) -> 𝔹 -> RenderANSIM () -> RenderANSIM ()
forall a r'.
(ANSIEnv ⟢ r')
-> r' -> RWST ANSIEnv (𝐼A 𝕊) () ID a -> RWST ANSIEnv (𝐼A 𝕊) () ID a
forall r (m :: * -> *) a r'.
MonadReader r m =>
(r ⟢ r') -> r' -> m a -> m a
localL ANSIEnv ⟢ 𝔹
ansiEnvDoFormatL 𝔹
False) 
               ((DocAEnv ⟢ 𝑂 ℕ64) -> 𝑂 ℕ64 -> DocAM () -> DocAM ()
forall a r'.
(DocAEnv ⟢ r')
-> r'
-> RWST DocAEnv TreeI DocAState ID a
-> RWST DocAEnv TreeI DocAState ID a
forall r (m :: * -> *) a r'.
MonadReader r m =>
(r ⟢ r') -> r' -> m a -> m a
localL DocAEnv ⟢ 𝑂 ℕ64
docAEnvMaxLineWidthL 𝑂 ℕ64
forall a. 𝑂 a
None (DocAM () -> DocAM ())
-> (DocAM () -> DocAM ()) -> DocAM () -> DocAM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
 (DocAEnv ⟢ 𝑂 ℕ64) -> 𝑂 ℕ64 -> DocAM () -> DocAM ()
forall a r'.
(DocAEnv ⟢ r')
-> r'
-> RWST DocAEnv TreeI DocAState ID a
-> RWST DocAEnv TreeI DocAState ID a
forall r (m :: * -> *) a r'.
MonadReader r m =>
(r ⟢ r') -> r' -> m a -> m a
localL DocAEnv ⟢ 𝑂 ℕ64
docAEnvMaxRibbonWidthL 𝑂 ℕ64
forall a. 𝑂 a
None)
               DocM () -> DocM ()
forall a. a -> a
id

ppRenderNoFmtNarrow  Doc  𝕊
ppRenderNoFmtNarrow :: Doc -> 𝕊
ppRenderNoFmtNarrow = 
  (RenderANSIM () -> RenderANSIM ())
-> (DocAM () -> DocAM ()) -> (DocM () -> DocM ()) -> Doc -> 𝕊
ppRenderWith ((ANSIEnv ⟢ 𝔹) -> 𝔹 -> RenderANSIM () -> RenderANSIM ()
forall a r'.
(ANSIEnv ⟢ r')
-> r' -> RWST ANSIEnv (𝐼A 𝕊) () ID a -> RWST ANSIEnv (𝐼A 𝕊) () ID a
forall r (m :: * -> *) a r'.
MonadReader r m =>
(r ⟢ r') -> r' -> m a -> m a
localL ANSIEnv ⟢ 𝔹
ansiEnvDoFormatL 𝔹
False) 
               ((DocAEnv ⟢ 𝑂 ℕ64) -> 𝑂 ℕ64 -> DocAM () -> DocAM ()
forall a r'.
(DocAEnv ⟢ r')
-> r'
-> RWST DocAEnv TreeI DocAState ID a
-> RWST DocAEnv TreeI DocAState ID a
forall r (m :: * -> *) a r'.
MonadReader r m =>
(r ⟢ r') -> r' -> m a -> m a
localL DocAEnv ⟢ 𝑂 ℕ64
docAEnvMaxLineWidthL (ℕ64 -> 𝑂 ℕ64
forall a. a -> 𝑂 a
Some ℕ64
forall a. Zero a => a
zero) 
                (DocAM () -> DocAM ())
-> (DocAM () -> DocAM ()) -> DocAM () -> DocAM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
 (DocAEnv ⟢ 𝑂 ℕ64) -> 𝑂 ℕ64 -> DocAM () -> DocAM ()
forall a r'.
(DocAEnv ⟢ r')
-> r'
-> RWST DocAEnv TreeI DocAState ID a
-> RWST DocAEnv TreeI DocAState ID a
forall r (m :: * -> *) a r'.
MonadReader r m =>
(r ⟢ r') -> r' -> m a -> m a
localL DocAEnv ⟢ 𝑂 ℕ64
docAEnvMaxRibbonWidthL (ℕ64 -> 𝑂 ℕ64
forall a. a -> 𝑂 a
Some ℕ64
forall a. Zero a => a
zero))
               DocM () -> DocM ()
forall a. a -> a
id

ppshow  (Pretty a)  a  𝕊
ppshow :: forall a. Pretty a => a -> 𝕊
ppshow = Doc -> 𝕊
ppRenderNoFmtWide (Doc -> 𝕊) -> (a -> Doc) -> a -> 𝕊
forall b c a. (b -> c) -> (a -> b) -> a -> c
 a -> Doc
forall a. Pretty a => a -> Doc
pretty

pprint  (Pretty a)  a  IO ()
pprint :: forall a. Pretty a => a -> IO ()
pprint a
x = 𝕊 -> IO ()
out (𝕊 -> IO ()) -> 𝕊 -> IO ()
forall a b. (a -> b) -> a -> b
$ Doc -> 𝕊
ppRender (Doc -> 𝕊) -> Doc -> 𝕊
forall a b. (a -> b) -> a -> b
$ Doc -> Doc
ppGroup (Doc -> Doc) -> Doc -> Doc
forall a b. (a -> b) -> a -> b
$ a -> Doc
forall a. Pretty a => a -> Doc
pretty a
x

ppColorOn  IO ()
ppColorOn :: IO ()
ppColorOn = IORef 𝔹 -> 𝔹 -> IO ()
forall a. IORef a -> a -> IO ()
IORef.writeIORef IORef 𝔹
gv_PPRINT_COLOR 𝔹
True

ppColorOff  IO ()
ppColorOff :: IO ()
ppColorOff = IORef 𝔹 -> 𝔹 -> IO ()
forall a. IORef a -> a -> IO ()
IORef.writeIORef IORef 𝔹
gv_PPRINT_COLOR 𝔹
False

pptrace  (Pretty a)  a  ()
pptrace :: forall a. Pretty a => a -> ()
pptrace a
a = IO () -> ()
forall a. IO a -> a
io_UNSAFE (IO () -> ()) -> IO () -> ()
forall a b. (a -> b) -> a -> b
$ do
  a -> IO ()
forall a. Pretty a => a -> IO ()
pprint a
a
  () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Return m => a -> m a
return ()

pptraceM  (Monad m,Pretty a)  a  m ()
pptraceM :: forall (m :: * -> *) a. (Monad m, Pretty a) => a -> m ()
pptraceM a
a = let ()
_ = a -> ()
forall a. Pretty a => a -> ()
pptrace a
a in m ()
forall (m :: * -> *). Return m => m ()
skip

ppabort  (Pretty a)  a  IO b
ppabort :: forall a b. Pretty a => a -> IO b
ppabort a
x = do a -> IO ()
forall a. Pretty a => a -> IO ()
pprint a
x ; IO b
forall a. IO a
abortIO

debugShape  Doc  IO ()
debugShape :: Doc -> IO ()
debugShape Doc
d = do
  Doc -> IO ()
forall a. Pretty a => a -> IO ()
pprint Doc
d
  Doc -> IO ()
forall a. Pretty a => a -> IO ()
pprint (Doc -> IO ()) -> Doc -> IO ()
forall a b. (a -> b) -> a -> b
$ 𝕊 -> Doc
ppString (𝕊 -> Doc) -> 𝕊 -> Doc
forall a b. (a -> b) -> a -> b
$ ShapeA -> 𝕊
forall a. Show a => a -> 𝕊
show𝕊 (ShapeA -> 𝕊) -> ShapeA -> 𝕊
forall a b. (a -> b) -> a -> b
$ Doc -> ShapeA
docShape Doc
d

instance Eq Doc where == :: Doc -> Doc -> 𝔹
(==) = 𝕊 -> 𝕊 -> 𝔹
forall a. Eq a => a -> a -> 𝔹
(≡) (𝕊 -> 𝕊 -> 𝔹) -> (Doc -> 𝕊) -> Doc -> Doc -> 𝔹
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` Doc -> 𝕊
ppRender
instance Ord Doc where compare :: Doc -> Doc -> Ordering
compare = 𝕊 -> 𝕊 -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (𝕊 -> 𝕊 -> Ordering) -> (Doc -> 𝕊) -> Doc -> Doc -> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` Doc -> 𝕊
ppRender