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 = forall a. (a -> Bool) -> [a] -> [a] Rev.dropWhile Char -> Bool isSpace forall b c a. (b -> c) -> (a -> b) -> a -> c . forall a. (a -> Bool) -> [a] -> [a] dropWhile Char -> Bool isSpace