module Language.PureScript.Publish.BoxesHelpers ( Boxes.Box , Boxes.nullBox , module Language.PureScript.Publish.BoxesHelpers ) where import Prelude import Data.Text (Text) import Data.Text qualified as T import System.IO (hPutStr, stderr) import Text.PrettyPrint.Boxes qualified as Boxes width :: Int width :: Int width = Int 79 indentWidth :: Int indentWidth :: Int indentWidth = Int 2 para :: String -> Boxes.Box para :: String -> Box para = Alignment -> Int -> String -> Box Boxes.para Alignment Boxes.left Int width indented :: Boxes.Box -> Boxes.Box indented :: Box -> Box indented Box b = forall (f :: * -> *). Foldable f => Alignment -> f Box -> Box Boxes.hcat Alignment Boxes.left [Int -> Int -> Box Boxes.emptyBox Int 1 Int indentWidth, Box b] successivelyIndented :: [String] -> Boxes.Box successivelyIndented :: [String] -> Box successivelyIndented [] = Box Boxes.nullBox successivelyIndented (String x:[String] xs) = forall (f :: * -> *). Foldable f => Alignment -> f Box -> Box Boxes.vcat Alignment Boxes.left [String -> Box para String x, Box -> Box indented ([String] -> Box successivelyIndented [String] xs)] vcat :: [Boxes.Box] -> Boxes.Box vcat :: [Box] -> Box vcat = forall (f :: * -> *). Foldable f => Alignment -> f Box -> Box Boxes.vcat Alignment Boxes.left spacer :: Boxes.Box spacer :: Box spacer = Int -> Int -> Box Boxes.emptyBox Int 1 Int 1 bulletedList :: (a -> String) -> [a] -> [Boxes.Box] bulletedList :: forall a. (a -> String) -> [a] -> [Box] bulletedList a -> String f = forall a b. (a -> b) -> [a] -> [b] map (Box -> Box indented forall b c a. (b -> c) -> (a -> b) -> a -> c . String -> Box para forall b c a. (b -> c) -> (a -> b) -> a -> c . (String "* " forall a. [a] -> [a] -> [a] ++) forall b c a. (b -> c) -> (a -> b) -> a -> c . a -> String f) bulletedListT :: (a -> Text) -> [a] -> [Boxes.Box] bulletedListT :: forall a. (a -> Text) -> [a] -> [Box] bulletedListT a -> Text f = forall a. (a -> String) -> [a] -> [Box] bulletedList (Text -> String T.unpack forall b c a. (b -> c) -> (a -> b) -> a -> c . a -> Text f) printToStderr :: Boxes.Box -> IO () printToStderr :: Box -> IO () printToStderr = Handle -> String -> IO () hPutStr Handle stderr forall b c a. (b -> c) -> (a -> b) -> a -> c . Box -> String Boxes.render