diff options
author | Ben Sima <ben@bsima.me> | 2021-02-19 15:13:30 -0500 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2021-02-19 15:13:30 -0500 |
commit | b499befeb774a377e306bd65793f9eb6c9044377 (patch) | |
tree | 6073d3aeef70ca6fd458bb2fd6976795986e74f6 /Alpha.hs | |
parent | bf9a684d725614a48fc68cd50e79138f1f2648c7 (diff) |
Factor out panics
Diffstat (limited to 'Alpha.hs')
-rw-r--r-- | Alpha.hs | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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 |