module Data.String.HT where import qualified Data.List.Reverse.StrictSpine as Rev import Data.Char (isSpace, ) {- | Remove leading and trailing spaces. We use spine strict 'Rev.dropWhile' instead of the element strict version. This is more efficient for finite 'String's because 'isSpace' is expensive. The downside is that 'trim' does not work for infinite 'String's. -} trim :: String -> String trim :: String -> String trim = (Char -> Bool) -> String -> String forall a. (a -> Bool) -> [a] -> [a] Rev.dropWhile Char -> Bool isSpace (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