module Util.Text
( headToLower
, surround
) where
import Data.Char (toLower)
import qualified Data.Text as T
headToLower :: HasCallStack => Text -> Text
headToLower :: Text -> Text
headToLower txt :: Text
txt = case Text -> Maybe (Char, Text)
T.uncons Text
txt of
Nothing -> Text -> Text
forall a. HasCallStack => Text -> a
error "Empty text"
Just (c :: Char
c, cs :: Text
cs) -> Char -> Text -> Text
T.cons (Char -> Char
toLower Char
c) Text
cs
surround :: Semigroup a => a -> a -> a -> a
surround :: a -> a -> a -> a
surround pre :: a
pre post :: a
post content :: a
content = a
pre a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
content a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
post