module Language.Haskell.Stylish.Step.TrailingWhitespace
( step
) where
import Data.Char (isSpace)
import Language.Haskell.Stylish.Step
dropTrailingWhitespace :: String -> String
dropTrailingWhitespace :: String -> String
dropTrailingWhitespace = forall a. [a] -> [a]
reverse forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Bool) -> [a] -> [a]
dropWhile Char -> Bool
isSpace forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [a] -> [a]
reverse
step :: Step
step :: Step
step = String -> (Lines -> Module -> Lines) -> Step
makeStep String
"TrailingWhitespace" forall a b. (a -> b) -> a -> b
$ \Lines
ls Module
_ -> forall a b. (a -> b) -> [a] -> [b]
map String -> String
dropTrailingWhitespace' Lines
ls
where
dropTrailingWhitespace' :: String -> String
dropTrailingWhitespace' String
l = case String
l of
String
"\12" -> String
l
String
_ -> String -> String
dropTrailingWhitespace String
l