--------------------------------------------------------------------
-- |
-- Module    : Utils.Data.String
-- Copyright : (c) Sigbjorn Finne, 2009
-- License   : BSD3
--
-- Maintainer: Sigbjorn Finne <sof@forkIO.com>
-- Stability : provisional
-- Portability:
--
--------------------------------------------------------------------
module Utils.Data.String
       ( capitalize  -- :: String -> String
       , unwordsWith -- :: String -> [String] -> String
       ) where


import Data.Char

capitalize :: String -> String
capitalize "" = ""
capitalize ls@(x:xs)
 | isAlpha x && isLower x = toUpper x : xs
 | otherwise = ls

unwordsWith :: String -> [String] -> String
unwordsWith sep [] = ""
unwordsWith sep [x] = x
unwordsWith sep (x:y:xs) = x ++ sep ++ unwordsWith sep (y:xs)