{-# LANGUAGE OverloadedStrings #-}
module Tophat.Text
(
literalNewlines,
stripNewlines,
stripAroundNewlines
) where
import Data.Text (Text)
import qualified Data.Text as T
literalNewlines :: Text -> Text
literalNewlines :: Text -> Text
literalNewlines = Text -> Text -> Text -> Text
T.replace Text
"\\n" Text
"\n"
stripNewlines :: Text -> Text
stripNewlines :: Text -> Text
stripNewlines = Text -> Text -> Text -> Text
T.replace Text
"\n" Text
""
stripAroundNewlines :: Text -> Text
stripAroundNewlines :: Text -> Text
stripAroundNewlines = [Text] -> Text
T.concat ([Text] -> Text) -> (Text -> [Text]) -> Text -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Text -> Text) -> [Text] -> [Text]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> Text
T.strip ([Text] -> [Text]) -> (Text -> [Text]) -> Text -> [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> [Text]
T.lines