{-# Language TemplateHaskell #-}
module Language.Drasil.Chunk.Concept.Core(
ConceptChunk(ConDict)
, sDom
) where
import Control.Lens (makeLenses, (^.),)
import Drasil.Database (UID, HasUID(..), declareHasChunkRefs, Generically(..))
import Language.Drasil.Classes (NamedIdea(term), Idea(getA),
Definition(defn), ConceptDomain(cdom))
import Language.Drasil.NaturalLanguage.English.NounPhrase.Core (NP)
import Language.Drasil.Sentence (Sentence)
sDom :: [UID] -> UID
sDom :: [UID] -> UID
sDom [UID
d] = UID
d
sDom [UID]
d = [Char] -> UID
forall a. HasCallStack => [Char] -> a
error ([Char] -> UID) -> [Char] -> UID
forall a b. (a -> b) -> a -> b
$ [Char]
"Expected ConceptDomain to have a single domain, found " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++
Int -> [Char]
forall a. Show a => a -> [Char]
show ([UID] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [UID]
d) [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
" instead."
data ConceptChunk = ConDict { ConceptChunk -> UID
_uu :: UID
, ConceptChunk -> NP
_np :: NP
, ConceptChunk -> Maybe [Char]
mabbr :: Maybe String
, ConceptChunk -> Sentence
_defn' :: Sentence
, ConceptChunk -> [UID]
cdom' :: [UID]
}
makeLenses ''ConceptChunk
declareHasChunkRefs ''ConceptChunk
instance Eq ConceptChunk where ConceptChunk
c1 == :: ConceptChunk -> ConceptChunk -> Bool
== ConceptChunk
c2 = (ConceptChunk
c1 ConceptChunk -> Getting UID ConceptChunk UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID ConceptChunk UID
forall c. HasUID c => Getter c UID
Getter ConceptChunk UID
uid) UID -> UID -> Bool
forall a. Eq a => a -> a -> Bool
== (ConceptChunk
c2 ConceptChunk -> Getting UID ConceptChunk UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID ConceptChunk UID
forall c. HasUID c => Getter c UID
Getter ConceptChunk UID
uid)
instance HasUID ConceptChunk where uid :: Getter ConceptChunk UID
uid = (UID -> f UID) -> ConceptChunk -> f ConceptChunk
Lens' ConceptChunk UID
uu
instance NamedIdea ConceptChunk where term :: Lens' ConceptChunk NP
term = (NP -> f NP) -> ConceptChunk -> f ConceptChunk
Lens' ConceptChunk NP
np
instance Idea ConceptChunk where getA :: ConceptChunk -> Maybe [Char]
getA = ConceptChunk -> Maybe [Char]
mabbr
instance Definition ConceptChunk where defn :: Lens' ConceptChunk Sentence
defn = (Sentence -> f Sentence) -> ConceptChunk -> f ConceptChunk
Lens' ConceptChunk Sentence
defn'
instance ConceptDomain ConceptChunk where cdom :: ConceptChunk -> [UID]
cdom = ConceptChunk -> [UID]
cdom'