{-# Language TemplateHaskell #-}
module Language.Drasil.Chunk.CommonIdea (
CI,
commonIdea, commonIdeaWithDict,
getAcc, prependAbrv) where
import Language.Drasil.Chunk.NamedIdea (IdeaDict, nc)
import Language.Drasil.Classes (NamedIdea(term), Idea(getA),
CommonIdea(abrv), ConceptDomain(cdom))
import Language.Drasil.Misc (repUnd)
import Language.Drasil.NounPhrase.Core (NP)
import Language.Drasil.Sentence (Sentence(S))
import Language.Drasil.UID (UID, HasUID(uid))
import Control.Lens (makeLenses, (^.), view)
data CI = CI { CI -> IdeaDict
_nc' :: IdeaDict, CI -> String
_ab :: String, CI -> [UID]
cdom' :: [UID]}
makeLenses ''CI
instance HasUID CI where uid :: Lens' CI UID
uid = Lens' CI IdeaDict
nc' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. HasUID c => Lens' c UID
uid
instance NamedIdea CI where term :: Lens' CI NP
term = Lens' CI IdeaDict
nc' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. NamedIdea c => Lens' c NP
term
instance Idea CI where getA :: CI -> Maybe String
getA = forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Lens' CI String
ab
instance CommonIdea CI where abrv :: CI -> String
abrv = forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Lens' CI String
ab
instance ConceptDomain CI where cdom :: CI -> [UID]
cdom = CI -> [UID]
cdom'
commonIdea :: String -> NP -> String -> [UID] -> CI
commonIdea :: String -> NP -> String -> [UID] -> CI
commonIdea String
s NP
np = IdeaDict -> String -> [UID] -> CI
CI (String -> NP -> IdeaDict
nc String
s NP
np)
commonIdeaWithDict :: String -> NP -> String -> [IdeaDict] -> CI
commonIdeaWithDict :: String -> NP -> String -> [IdeaDict] -> CI
commonIdeaWithDict String
x NP
y String
z = String -> NP -> String -> [UID] -> CI
commonIdea String
x NP
y String
z forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map (forall s a. s -> Getting a s a -> a
^.forall c. HasUID c => Lens' c UID
uid)
getAcc :: CI -> Sentence
getAcc :: CI -> Sentence
getAcc = String -> Sentence
S forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. CommonIdea c => c -> String
abrv
prependAbrv :: CommonIdea c => c -> String -> String
prependAbrv :: forall c. CommonIdea c => c -> String -> String
prependAbrv c
c String
s = forall c. CommonIdea c => c -> String
abrv c
c forall a. [a] -> [a] -> [a]
++ (Char
':' forall a. a -> [a] -> [a]
: String -> String
repUnd String
s)