summaryrefslogtreecommitdiff
path: root/Alpha.hs
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2020-07-12 09:13:24 -0700
committerBen Sima <ben@bsima.me>2020-07-12 09:25:10 -0700
commita76870b7f3dda5b564185cfd652e11998d7ff88d (patch)
tree22f273265d31f08e70457f0e91a681022c8d35b6 /Alpha.hs
parent40d9f9e057191ad1c89a9e2c7b9088d2fde643e1 (diff)
hero: move CanSnakeCase to Alpha
Diffstat (limited to 'Alpha.hs')
-rw-r--r--Alpha.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/Alpha.hs b/Alpha.hs
index 98c161b..e96089f 100644
--- a/Alpha.hs
+++ b/Alpha.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE NoImplicitPrelude #-}
+{-# LANGUAGE OverloadedStrings #-}
-- | Commonly useful functions, a Prelude replacement.
--
@@ -37,6 +38,8 @@ module Alpha
lchomp,
joinWith,
+ CanSnakeCase(snake),
+
-- * Debugging tools
say,
)
@@ -98,3 +101,10 @@ joinWith = intercalate
don't :: Bool -> Bool
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
+
+instance CanSnakeCase Text where
+ snake = Text.replace " " "-" . Text.toLower