module Test.Speculate.Utils.String
( module Data.String
, module Data.Char
, unquote
, indent
, alignRight
, alignLeft
, splitAtCommas
)
where
import Data.String
import Data.Char
import Data.Express.Utils.String
alignRight :: Int -> String -> String
alignRight :: Int -> String -> String
alignRight Int
n String
cs = Int -> Char -> String
forall a. Int -> a -> [a]
replicate (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- String -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
cs) Char
' ' String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
cs
alignLeft :: Int -> String -> String
alignLeft :: Int -> String -> String
alignLeft Int
n String
cs = String
cs String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> Char -> String
forall a. Int -> a -> [a]
replicate (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- String -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
cs) Char
' '
indent :: Int -> String -> String
indent :: Int -> String -> String
indent Int
n = [String] -> String
unlines ([String] -> String) -> (String -> [String]) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> String) -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (Int -> Char -> String
forall a. Int -> a -> [a]
replicate Int
n Char
' ' String -> String -> String
forall a. [a] -> [a] -> [a]
++) ([String] -> [String])
-> (String -> [String]) -> String -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [String]
lines
splitAtCommas :: String -> [String]
splitAtCommas :: String -> [String]
splitAtCommas = String -> [String]
words (String -> [String]) -> (String -> String) -> String -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Char) -> String -> String
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
commaToSpace
where
commaToSpace :: Char -> Char
commaToSpace Char
',' = Char
' '
commaToSpace Char
c = Char
c