From a76870b7f3dda5b564185cfd652e11998d7ff88d Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sun, 12 Jul 2020 09:13:24 -0700 Subject: hero: move CanSnakeCase to Alpha --- Alpha.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Alpha.hs') 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 -- cgit v1.2.3