-- |
-- Module      :  Text.Inflections.Dasherize
-- Copyright   :  © 2016 Justin Leitgeb
-- License     :  MIT
--
-- Maintainer  :  Justin Leitgeb <justin@stackbuilders.com>
-- Stability   :  experimental
-- Portability :  portable
--
-- Conversion to dasherized phrases.

{-# LANGUAGE OverloadedStrings #-}

module Text.Inflections.Dasherize
  ( dasherize )
where

import Data.Text (Text)
import Text.Inflections.Types
import qualified Data.Text as T

-- | Produce a string with words separated by dashes (hyphens).
--
-- >>> foo  <- SomeWord <$> mkWord "foo"
-- >>> bar  <- SomeWord <$> mkAcronym "bar"
-- >>> bazz <- SomeWord <$> mkWord "bazz"
-- >>> dasherize [foo,bar,bazz]
-- "foo-bar-bazz"
dasherize
  :: [SomeWord] -- ^ Input words to separate with dashes
  -> Text       -- ^ The dasherized 'Text'
dasherize :: [SomeWord] -> Text
dasherize = Text -> [Text] -> Text
T.intercalate Text
"-" forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Text -> Text) -> SomeWord -> Text
unSomeWord Text -> Text
T.toLower)