summaryrefslogtreecommitdiff
path: root/Alpha.hs
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2021-02-19 15:13:30 -0500
committerBen Sima <ben@bsima.me>2021-02-19 15:13:30 -0500
commitb499befeb774a377e306bd65793f9eb6c9044377 (patch)
tree6073d3aeef70ca6fd458bb2fd6976795986e74f6 /Alpha.hs
parentbf9a684d725614a48fc68cd50e79138f1f2648c7 (diff)
Factor out panics
Diffstat (limited to 'Alpha.hs')
-rw-r--r--Alpha.hs12
1 files changed, 8 insertions, 4 deletions
diff --git a/Alpha.hs b/Alpha.hs
index 9feb123..71ceef6 100644
--- a/Alpha.hs
+++ b/Alpha.hs
@@ -55,6 +55,7 @@ module Alpha
(?+),
-- * Text
+ str,
tshow,
chomp,
lchomp,
@@ -200,18 +201,18 @@ don't = do not
{-# ANN don't ("HLint: ignore Redundant do" :: String) #-}
-- | Class for turning different string types to snakeCase.
-class CanSnakeCase str where
- snake :: str -> str
+class CanSnakeCase s where
+ snake :: s -> s
instance CanSnakeCase Text where
snake = Text.toLower .> Text.replace " " "-"
capitalize :: String -> String
capitalize [] = []
-capitalize str = (Char.toUpper <| List.head str) : (Char.toLower </ List.tail str)
+capitalize s = (Char.toUpper <| List.head s) : (Char.toLower </ List.tail s)
lowercase :: String -> String
-lowercase str = [Char.toLower c | c <- str]
+lowercase s = [Char.toLower c | c <- s]
{-# WARNING require "'require' remains in code" #-}
require :: Text -> Maybe a -> a
@@ -231,5 +232,8 @@ wrap lim = Text.words .> wrap_ 0 .> Text.unwords
where
lw = Text.length w
+str :: StringConv a b => a -> b
+str = toS
+
tshow :: Show a => a -> Text
tshow = show