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