module Test.DocTest.Internal.Util where
import Data.Char
convertDosLineEndings :: String -> String
convertDosLineEndings :: String -> String
convertDosLineEndings = String -> String
go
where
go :: String -> String
go String
input = case String
input of
Char
'\r':Char
'\n':String
xs -> Char
'\n' Char -> String -> String
forall a. a -> [a] -> [a]
: String -> String
go String
xs
String
"\r" -> String
""
Char
x:String
xs -> Char
x Char -> String -> String
forall a. a -> [a] -> [a]
: String -> String
go String
xs
String
"" -> String
""
takeWhileEnd :: (a -> Bool) -> [a] -> [a]
takeWhileEnd :: (a -> Bool) -> [a] -> [a]
takeWhileEnd a -> Bool
p = [a] -> [a]
forall a. [a] -> [a]
reverse ([a] -> [a]) -> ([a] -> [a]) -> [a] -> [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Bool) -> [a] -> [a]
forall a. (a -> Bool) -> [a] -> [a]
takeWhile a -> Bool
p ([a] -> [a]) -> ([a] -> [a]) -> [a] -> [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> [a]
forall a. [a] -> [a]
reverse
stripEnd :: String -> String
stripEnd :: String -> String
stripEnd = String -> String
forall a. [a] -> [a]
reverse (String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> String -> String
forall a. (a -> Bool) -> [a] -> [a]
dropWhile Char -> Bool
isSpace (String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
forall a. [a] -> [a]
reverse