module Util where
str :: String -> String -> String
str :: String -> String -> String
str = String -> String -> String
showString
char :: Char -> String -> String
char :: Char -> String -> String
char Char
c = (Char
c Char -> String -> String
forall a. a -> [a] -> [a]
:)
nl :: String -> String
nl :: String -> String
nl = Char -> String -> String
char Char
'\n'
paren :: (String -> String) -> String -> String
paren :: (String -> String) -> String -> String
paren String -> String
s = Char -> String -> String
char Char
'(' (String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
s (String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> String -> String
char Char
')'
brack :: (String -> String) -> String -> String
brack :: (String -> String) -> String -> String
brack String -> String
s = Char -> String -> String
char Char
'[' (String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
s (String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> String -> String
char Char
']'
interleave_shows :: (String -> String) -> [String -> String] -> String -> String
interleave_shows :: (String -> String) -> [String -> String] -> String -> String
interleave_shows String -> String
_ [] = String -> String
forall a. a -> a
id
interleave_shows String -> String
s [String -> String]
xs = ((String -> String) -> (String -> String) -> String -> String)
-> [String -> String] -> String -> String
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldr1 (\String -> String
a String -> String
b -> String -> String
a (String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
s (String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
b) [String -> String]
xs
space :: String -> String
space :: String -> String
space = Char -> String -> String
char Char
' '
cjustify, ljustify, rjustify :: Int -> String -> String
cjustify :: Int -> String -> String
cjustify Int
n String
s = Int -> String
spaces Int
halfm String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
s String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
spaces (Int
m Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
halfm)
where m :: Int
m = Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- String -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
s
halfm :: Int
halfm = Int
m Int -> Int -> Int
forall a. Integral a => a -> a -> a
`div` Int
2
ljustify :: Int -> String -> String
ljustify Int
n String
s = String
s String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
spaces (Int -> Int -> Int
forall a. Ord a => a -> a -> a
max Int
0 (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- String -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
s))
rjustify :: Int -> String -> String
rjustify Int
n String
s = Int -> String
spaces (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- String -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
s) String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
s
spaces :: Int -> String
spaces :: Int -> String
spaces Int
n = Int -> Char -> String
forall a. Int -> a -> [a]
replicate Int
n Char
' '
hline :: String
hline :: String
hline = Int -> Char -> String
forall a. Int -> a -> [a]
replicate Int
77 Char
'-'