{-# OPTIONS_GHC -Wno-redundant-constraints #-}
-- | Various helpers for building Sentences from other bits.
-- Really ought to be moved out to (likely) docLang, but is here for now.
module Language.Drasil.Development.Sentence (
  -- * All Lowercase
  phrase, plural, phrasePoss, pluralPoss,
  -- * Capitalize First Word
  atStart, atStart',
  -- * Capitalize All Words
  titleize, titleize',
  -- * Short Form (lowercase)
  short, introduceAbb) where

import Control.Lens ((^.))

import Language.Drasil.Classes (NamedIdea(term), Idea)
import Language.Drasil.Sentence ((+:+), Sentence((:+:), S), sParen, sentenceTerm,
  sentencePlural, sentenceShort)
import qualified Language.Drasil.NounPhrase as NP
import Language.Drasil.UID (HasUID(..))

-- | Get short form (if it exists), else get term of an 'Idea'.
short :: Idea c => c -> Sentence
short :: forall c. Idea c => c -> Sentence
short c
c = UID -> Sentence
sentenceShort (c
c c -> Getting UID c UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID c UID
forall c. HasUID c => Getter c UID
Getter c UID
uid)

-- | Helper for common pattern of introducing the title-case version of a 
-- noun phrase (from an Idea)
-- followed by its abbreviation in parentheses.
introduceAbb :: Idea n => n -> Sentence
introduceAbb :: forall c. Idea c => c -> Sentence
introduceAbb n
n = NP -> Sentence
forall n. NounPhrase n => n -> Sentence
NP.titleizeNP (n
n n -> Getting NP n NP -> NP
forall s a. s -> Getting a s a -> a
^. Getting NP n NP
forall c. NamedIdea c => Lens' c NP
Lens' n NP
term) Sentence -> Sentence -> Sentence
+:+ Sentence -> Sentence
sParen (n -> Sentence
forall c. Idea c => c -> Sentence
short n
n)

-- | Helper function for getting the sentence case of a noun phrase from a 
-- 'NamedIdea'.
atStart, atStart' :: NamedIdea n => n -> Sentence
-- | Singular sentence case.
atStart :: forall n. NamedIdea n => n -> Sentence
atStart  n
n = NP -> Sentence
forall n. NounPhrase n => n -> Sentence
NP.atStartNP (n
n n -> Getting NP n NP -> NP
forall s a. s -> Getting a s a -> a
^. Getting NP n NP
forall c. NamedIdea c => Lens' c NP
Lens' n NP
term)
-- | Plural sentence case.
atStart' :: forall n. NamedIdea n => n -> Sentence
atStart' n
n = NP -> Sentence
forall n. NounPhrase n => n -> Sentence
NP.atStartNP' (n
n n -> Getting NP n NP -> NP
forall s a. s -> Getting a s a -> a
^. Getting NP n NP
forall c. NamedIdea c => Lens' c NP
Lens' n NP
term)

-- | Helper function for getting the title case of a noun phrase from a 
-- 'NamedIdea'.
titleize, titleize' :: NamedIdea n => n -> Sentence
-- | Singular title case.
titleize :: forall n. NamedIdea n => n -> Sentence
titleize  n
n = NP -> Sentence
forall n. NounPhrase n => n -> Sentence
NP.titleizeNP (n
n n -> Getting NP n NP -> NP
forall s a. s -> Getting a s a -> a
^. Getting NP n NP
forall c. NamedIdea c => Lens' c NP
Lens' n NP
term)
-- | Plural title case.
titleize' :: forall n. NamedIdea n => n -> Sentence
titleize' n
n = NP -> Sentence
forall n. NounPhrase n => n -> Sentence
NP.titleizeNP' (n
n n -> Getting NP n NP -> NP
forall s a. s -> Getting a s a -> a
^. Getting NP n NP
forall c. NamedIdea c => Lens' c NP
Lens' n NP
term)

-- | Helper for getting the phrase from a 'NamedIdea' using it's UID.
phrase :: NamedIdea n => n -> Sentence
phrase :: forall n. NamedIdea n => n -> Sentence
phrase n
n = UID -> Sentence
sentenceTerm (n
n n -> Getting UID n UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID n UID
forall c. HasUID c => Getter c UID
Getter n UID
uid)

-- | Helper for getting the plural of a phrase from a 'NamedIdea'.
plural :: NamedIdea n => n -> Sentence
plural :: forall n. NamedIdea n => n -> Sentence
plural n
n = UID -> Sentence
sentencePlural (n
n n -> Getting UID n UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID n UID
forall c. HasUID c => Getter c UID
Getter n UID
uid)
--plural n = NP.plural (n ^. term)

-- | Helper for getting the possesive cases from the term of a 'NamedIdea'.
phrasePoss, pluralPoss :: NamedIdea n => n -> Sentence
-- | Singular possesive function
phrasePoss :: forall n. NamedIdea n => n -> Sentence
phrasePoss n
a = n -> Sentence
forall n. NamedIdea n => n -> Sentence
phrase n
a Sentence -> Sentence -> Sentence
:+: String -> Sentence
S String
"'s"
-- | Plural possesive function
pluralPoss :: forall n. NamedIdea n => n -> Sentence
pluralPoss n
a = n -> Sentence
forall n. NamedIdea n => n -> Sentence
plural n
a Sentence -> Sentence -> Sentence
:+: String -> Sentence
S String
"'"