{-# 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> Text
T.strip forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> [Text]
T.lines