module Ribosome.Data.Text where

import Data.Char (toUpper)
import qualified Data.Text as Text (concatMap, cons, singleton, uncons)

escapeQuote :: Char -> Text
escapeQuote :: Char -> Text
escapeQuote Char
'\'' = Text
"''"
escapeQuote Char
a = Char -> Text
Text.singleton Char
a

escapeQuotes :: Text -> Text
escapeQuotes :: Text -> Text
escapeQuotes = (Char -> Text) -> Text -> Text
Text.concatMap Char -> Text
escapeQuote

capitalize :: Text -> Text
capitalize :: Text -> Text
capitalize Text
a =
  Text -> ((Char, Text) -> Text) -> Maybe (Char, Text) -> Text
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Text
"" (Char, Text) -> Text
run (Text -> Maybe (Char, Text)
Text.uncons Text
a)
  where
    run :: (Char, Text) -> Text
run (Char
h, Text
t) = Char -> Text -> Text
Text.cons (Char -> Char
toUpper Char
h) Text
t