From b499befeb774a377e306bd65793f9eb6c9044377 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Fri, 19 Feb 2021 15:13:30 -0500 Subject: Factor out panics --- Alpha.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'Alpha.hs') 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 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 -- cgit v1.2.3