diff options
Diffstat (limited to 'Alpha.hs')
-rw-r--r-- | Alpha.hs | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -40,11 +40,16 @@ module Alpha joinWith, CanSnakeCase (snake), + -- * String + capitalize, + -- * Debugging tools say, ) where +import qualified Data.Char as Char +import qualified Data.List as List import Data.String import Data.Text (Text) import qualified Data.Text as Text @@ -68,14 +73,14 @@ f </ g = fmap f g -- | Normal function application. Do the right side, then pass the -- return value to the function on the left side. (<|) :: (a -> b) -> a -> b -f <| g = f (g) +f <| g = f g infixr 0 <| -- | Reverse function application. Do the left side, then pass the -- return value to the function on the right side. (|>) :: a -> (a -> b) -> b -f |> g = g (f) +f |> g = g f -- | Alias for <&>. Can be read as "and then". Basically does into a -- functor, does some computation, then returns the same kind of @@ -106,3 +111,7 @@ class CanSnakeCase str where instance CanSnakeCase Text where snake = Text.replace " " "-" . Text.toLower + +capitalize :: String -> String +capitalize [] = [] +capitalize str = (Char.toUpper <| List.head str) : (Char.toLower </ List.tail str) |