{-# LANGUAGE OverloadedStrings #-}

module Prettyprinter.Ext ( (<#>)
                         , (<##>)
                         , prettyHex
                         , prettyLines
                         , sepDecls
                         ) where

import           Numeric       (showHex)
import           Prettyprinter

infixr 6 <#>
infixr 6 <##>

(<#>) :: Doc a -> Doc a -> Doc a
<#> :: Doc a -> Doc a -> Doc a
(<#>) Doc a
x Doc a
y = Doc a
x Doc a -> Doc a -> Doc a
forall a. Semigroup a => a -> a -> a
<> Doc a
forall ann. Doc ann
hardline Doc a -> Doc a -> Doc a
forall a. Semigroup a => a -> a -> a
<> Doc a
y

(<##>) :: Doc a -> Doc a -> Doc a
<##> :: Doc a -> Doc a -> Doc a
(<##>) Doc a
x Doc a
y = Doc a
x Doc a -> Doc a -> Doc a
forall a. Semigroup a => a -> a -> a
<> Doc a
forall ann. Doc ann
hardline Doc a -> Doc a -> Doc a
forall a. Semigroup a => a -> a -> a
<> Doc a
forall ann. Doc ann
hardline Doc a -> Doc a -> Doc a
forall a. Semigroup a => a -> a -> a
<> Doc a
y

prettyHex :: (Integral a, Show a) => a -> Doc ann
prettyHex :: a -> Doc ann
prettyHex a
x = Doc ann
"0x" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty (a -> ShowS
forall a. (Integral a, Show a) => a -> ShowS
showHex a
x String
forall a. Monoid a => a
mempty)

prettyLines :: [Doc ann] -> Doc ann
prettyLines :: [Doc ann] -> Doc ann
prettyLines = (Doc ann -> Doc ann -> Doc ann) -> [Doc ann] -> Doc ann
forall (t :: * -> *) ann.
Foldable t =>
(Doc ann -> Doc ann -> Doc ann) -> t (Doc ann) -> Doc ann
concatWith Doc ann -> Doc ann -> Doc ann
forall a. Doc a -> Doc a -> Doc a
(<#>)

sepDecls :: [Doc ann] -> Doc ann
sepDecls :: [Doc ann] -> Doc ann
sepDecls = (Doc ann -> Doc ann -> Doc ann) -> [Doc ann] -> Doc ann
forall (t :: * -> *) ann.
Foldable t =>
(Doc ann -> Doc ann -> Doc ann) -> t (Doc ann) -> Doc ann
concatWith Doc ann -> Doc ann -> Doc ann
forall a. Doc a -> Doc a -> Doc a
(<##>)