{-# LANGUAGE TemplateHaskell #-}
module Language.Drasil.Chunk.Unital (
UnitalChunk(..),
uc, uc', ucStaged, ucStaged', ucuc, ucw) where
import Control.Lens (makeLenses, view, (^.))
import Language.Drasil.Chunk.Concept (dccWDS,cw)
import Language.Drasil.Chunk.DefinedQuantity (DefinedQuantityDict, dqd, dqd', tempdqdWr')
import Language.Drasil.Chunk.Unitary (Unitary(..))
import Language.Drasil.Symbol
import Language.Drasil.Classes (NamedIdea(term), Idea(getA), Express(express),
Definition(defn), ConceptDomain(cdom), Concept, IsUnit, Quantity)
import Language.Drasil.Chunk.UnitDefn (MayHaveUnit(getUnit), TempHasUnit(findUnit), UnitDefn, unitWrapper)
import Language.Drasil.Expr.Class (sy)
import Language.Drasil.NounPhrase.Core (NP)
import Language.Drasil.Space (Space(..), HasSpace(..))
import Language.Drasil.Sentence (Sentence)
import Language.Drasil.Stages (Stage)
import Language.Drasil.UID (HasUID(..))
data UnitalChunk = UC { UnitalChunk -> DefinedQuantityDict
_defq' :: DefinedQuantityDict
, UnitalChunk -> UnitDefn
_uni :: UnitDefn
}
makeLenses ''UnitalChunk
instance HasUID UnitalChunk where uid :: Lens' UnitalChunk UID
uid = Lens' UnitalChunk DefinedQuantityDict
defq' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. HasUID c => Lens' c UID
uid
instance NamedIdea UnitalChunk where term :: Lens' UnitalChunk NP
term = Lens' UnitalChunk DefinedQuantityDict
defq' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. NamedIdea c => Lens' c NP
term
instance Idea UnitalChunk where getA :: UnitalChunk -> Maybe String
getA (UC DefinedQuantityDict
qc UnitDefn
_) = forall c. Idea c => c -> Maybe String
getA DefinedQuantityDict
qc
instance Definition UnitalChunk where defn :: Lens' UnitalChunk Sentence
defn = Lens' UnitalChunk DefinedQuantityDict
defq' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. Definition c => Lens' c Sentence
defn
instance ConceptDomain UnitalChunk where cdom :: UnitalChunk -> [UID]
cdom = forall c. ConceptDomain c => c -> [UID]
cdom 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' UnitalChunk DefinedQuantityDict
defq'
instance HasSpace UnitalChunk where typ :: Getter UnitalChunk Space
typ = Lens' UnitalChunk DefinedQuantityDict
defq' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. HasSpace c => Getter c Space
typ
instance HasSymbol UnitalChunk where symbol :: UnitalChunk -> Stage -> Symbol
symbol UnitalChunk
c = forall c. HasSymbol c => c -> Stage -> Symbol
symbol (UnitalChunk
cforall s a. s -> Getting a s a -> a
^.Lens' UnitalChunk DefinedQuantityDict
defq')
instance Quantity UnitalChunk where
instance Unitary UnitalChunk where unit :: UnitalChunk -> UnitDefn
unit = forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Lens' UnitalChunk UnitDefn
uni
instance MayHaveUnit UnitalChunk where getUnit :: UnitalChunk -> Maybe UnitDefn
getUnit = 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' UnitalChunk UnitDefn
uni
instance TempHasUnit UnitalChunk where findUnit :: UnitalChunk -> UnitDefn
findUnit = forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Lens' UnitalChunk UnitDefn
uni
instance Eq UnitalChunk where UnitalChunk
c1 == :: UnitalChunk -> UnitalChunk -> Bool
== UnitalChunk
c2 = (UnitalChunk
c1 forall s a. s -> Getting a s a -> a
^. forall c. HasUID c => Lens' c UID
uid) forall a. Eq a => a -> a -> Bool
== (UnitalChunk
c2 forall s a. s -> Getting a s a -> a
^. forall c. HasUID c => Lens' c UID
uid)
instance Express UnitalChunk where express :: UnitalChunk -> ModelExpr
express = forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy
uc :: (Concept c, IsUnit u) => c -> Symbol -> Space -> u -> UnitalChunk
uc :: forall c u.
(Concept c, IsUnit u) =>
c -> Symbol -> Space -> u -> UnitalChunk
uc c
a Symbol
sym Space
space u
c = DefinedQuantityDict -> UnitDefn -> UnitalChunk
UC (forall u.
IsUnit u =>
ConceptChunk -> Symbol -> Space -> u -> DefinedQuantityDict
dqd (forall c. Concept c => c -> ConceptChunk
cw c
a) Symbol
sym Space
space UnitDefn
un) UnitDefn
un
where un :: UnitDefn
un = forall u. IsUnit u => u -> UnitDefn
unitWrapper u
c
uc' :: (IsUnit u) => String -> NP -> Sentence -> Symbol -> Space -> u -> UnitalChunk
uc' :: forall u.
IsUnit u =>
String -> NP -> Sentence -> Symbol -> Space -> u -> UnitalChunk
uc' String
i NP
t Sentence
d Symbol
sym Space
space u
u = DefinedQuantityDict -> UnitDefn -> UnitalChunk
UC (forall u.
IsUnit u =>
ConceptChunk -> Symbol -> Space -> u -> DefinedQuantityDict
dqd (String -> NP -> Sentence -> ConceptChunk
dccWDS String
i NP
t Sentence
d) Symbol
sym Space
space UnitDefn
un) UnitDefn
un
where un :: UnitDefn
un = forall u. IsUnit u => u -> UnitDefn
unitWrapper u
u
ucStaged :: (Concept c, IsUnit u) => c -> (Stage -> Symbol) ->
Space -> u -> UnitalChunk
ucStaged :: forall c u.
(Concept c, IsUnit u) =>
c -> (Stage -> Symbol) -> Space -> u -> UnitalChunk
ucStaged c
a Stage -> Symbol
sym Space
space u
u = DefinedQuantityDict -> UnitDefn -> UnitalChunk
UC (ConceptChunk
-> (Stage -> Symbol)
-> Space
-> Maybe UnitDefn
-> DefinedQuantityDict
dqd' (forall c. Concept c => c -> ConceptChunk
cw c
a) Stage -> Symbol
sym Space
space (forall a. a -> Maybe a
Just UnitDefn
un)) UnitDefn
un
where un :: UnitDefn
un = forall u. IsUnit u => u -> UnitDefn
unitWrapper u
u
ucStaged' :: (IsUnit u) => String -> NP -> Sentence -> (Stage -> Symbol) ->
Space -> u -> UnitalChunk
ucStaged' :: forall u.
IsUnit u =>
String
-> NP -> Sentence -> (Stage -> Symbol) -> Space -> u -> UnitalChunk
ucStaged' String
i NP
t Sentence
d Stage -> Symbol
sym Space
space u
u = DefinedQuantityDict -> UnitDefn -> UnitalChunk
UC (ConceptChunk
-> (Stage -> Symbol)
-> Space
-> Maybe UnitDefn
-> DefinedQuantityDict
dqd' (String -> NP -> Sentence -> ConceptChunk
dccWDS String
i NP
t Sentence
d) Stage -> Symbol
sym Space
space (forall a. a -> Maybe a
Just UnitDefn
un)) UnitDefn
un
where un :: UnitDefn
un = forall u. IsUnit u => u -> UnitDefn
unitWrapper u
u
ucuc :: (Quantity c, Concept c, MayHaveUnit c) => c -> UnitDefn -> UnitalChunk
ucuc :: forall c.
(Quantity c, Concept c, MayHaveUnit c) =>
c -> UnitDefn -> UnitalChunk
ucuc c
c = DefinedQuantityDict -> UnitDefn -> UnitalChunk
UC (forall c.
(Quantity c, Concept c, MayHaveUnit c) =>
c -> DefinedQuantityDict
tempdqdWr' c
c)
ucw :: (Unitary c, Concept c, MayHaveUnit c) => c -> UnitalChunk
ucw :: forall c. (Unitary c, Concept c, MayHaveUnit c) => c -> UnitalChunk
ucw c
c = forall c.
(Quantity c, Concept c, MayHaveUnit c) =>
c -> UnitDefn -> UnitalChunk
ucuc c
c (forall c. Unitary c => c -> UnitDefn
unit c
c)