{-# Language TemplateHaskell #-}
module Language.Drasil.Chunk.UncertainQuantity (
UncertQ, UncertainChunk(..),
uq, uqc,
uqcND, uncrtnChunk, uvc, uncrtnw) where
import Language.Drasil.Chunk.DefinedQuantity (dqdWr)
import Language.Drasil.Chunk.Constrained (ConstrConcept(..), ConstrainedChunk, cuc', cnstrw, cvc)
import Language.Drasil.Symbol
import Language.Drasil.Classes (NamedIdea(term), Idea(getA), Express(express),
Definition(defn), ConceptDomain(cdom), Concept, Quantity,
IsUnit, Constrained(constraints), HasReasVal(reasVal))
import Language.Drasil.Constraint (ConstraintE)
import Language.Drasil.Chunk.UnitDefn (MayHaveUnit(getUnit))
import Language.Drasil.Expr.Lang (Expr)
import Language.Drasil.Expr.Class (sy)
import Language.Drasil.NounPhrase.Core (NP)
import Language.Drasil.Space (Space, HasSpace(..))
import Language.Drasil.Uncertainty
import Language.Drasil.UID (HasUID(..))
import Control.Lens ((^.), makeLenses, view)
data UncertainChunk = UCh { UncertainChunk -> ConstrainedChunk
_conc :: ConstrainedChunk , UncertainChunk -> Uncertainty
_unc' :: Uncertainty }
makeLenses ''UncertainChunk
instance HasUID UncertainChunk where uid :: Lens' UncertainChunk UID
uid = Lens' UncertainChunk ConstrainedChunk
conc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. HasUID c => Lens' c UID
uid
instance Eq UncertainChunk where UncertainChunk
c1 == :: UncertainChunk -> UncertainChunk -> Bool
== UncertainChunk
c2 = (UncertainChunk
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
== (UncertainChunk
c2 forall s a. s -> Getting a s a -> a
^. forall c. HasUID c => Lens' c UID
uid)
instance NamedIdea UncertainChunk where term :: Lens' UncertainChunk NP
term = Lens' UncertainChunk ConstrainedChunk
conc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. NamedIdea c => Lens' c NP
term
instance Idea UncertainChunk where getA :: UncertainChunk -> Maybe String
getA (UCh ConstrainedChunk
n Uncertainty
_) = forall c. Idea c => c -> Maybe String
getA ConstrainedChunk
n
instance HasSpace UncertainChunk where typ :: Getter UncertainChunk Space
typ = Lens' UncertainChunk ConstrainedChunk
conc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. HasSpace c => Getter c Space
typ
instance HasSymbol UncertainChunk where symbol :: UncertainChunk -> Stage -> Symbol
symbol UncertainChunk
c = forall c. HasSymbol c => c -> Stage -> Symbol
symbol (UncertainChunk
cforall s a. s -> Getting a s a -> a
^.Lens' UncertainChunk ConstrainedChunk
conc)
instance Quantity UncertainChunk where
instance Constrained UncertainChunk where constraints :: Lens' UncertainChunk [ConstraintE]
constraints = Lens' UncertainChunk ConstrainedChunk
conc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. Constrained c => Lens' c [ConstraintE]
constraints
instance HasReasVal UncertainChunk where reasVal :: Lens' UncertainChunk (Maybe Expr)
reasVal = Lens' UncertainChunk ConstrainedChunk
conc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. HasReasVal c => Lens' c (Maybe Expr)
reasVal
instance HasUncertainty UncertainChunk where unc :: Lens' UncertainChunk Uncertainty
unc = Lens' UncertainChunk Uncertainty
unc'
instance MayHaveUnit UncertainChunk where getUnit :: UncertainChunk -> Maybe UnitDefn
getUnit = forall u. MayHaveUnit u => u -> Maybe UnitDefn
getUnit 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' UncertainChunk ConstrainedChunk
conc
uncrtnChunk :: (Quantity c, Constrained c, HasReasVal c, MayHaveUnit c) =>
c -> Uncertainty -> UncertainChunk
uncrtnChunk :: forall c.
(Quantity c, Constrained c, HasReasVal c, MayHaveUnit c) =>
c -> Uncertainty -> UncertainChunk
uncrtnChunk c
q = ConstrainedChunk -> Uncertainty -> UncertainChunk
UCh (forall c.
(Quantity c, Constrained c, HasReasVal c, MayHaveUnit c) =>
c -> ConstrainedChunk
cnstrw c
q)
uvc :: String -> NP -> Symbol -> Space -> [ConstraintE] -> Expr -> Uncertainty -> UncertainChunk
uvc :: String
-> NP
-> Symbol
-> Space
-> [ConstraintE]
-> Expr
-> Uncertainty
-> UncertainChunk
uvc String
nam NP
trm Symbol
sym Space
space [ConstraintE]
cs Expr
val = forall c.
(Quantity c, Constrained c, HasReasVal c, MayHaveUnit c) =>
c -> Uncertainty -> UncertainChunk
uncrtnChunk (String
-> NP
-> Symbol
-> Space
-> [ConstraintE]
-> Maybe Expr
-> ConstrainedChunk
cvc String
nam NP
trm Symbol
sym Space
space [ConstraintE]
cs (forall a. a -> Maybe a
Just Expr
val))
uncrtnw :: (HasUncertainty c, Quantity c, Constrained c, HasReasVal c, MayHaveUnit c) => c -> UncertainChunk
uncrtnw :: forall c.
(HasUncertainty c, Quantity c, Constrained c, HasReasVal c,
MayHaveUnit c) =>
c -> UncertainChunk
uncrtnw c
c = ConstrainedChunk -> Uncertainty -> UncertainChunk
UCh (forall c.
(Quantity c, Constrained c, HasReasVal c, MayHaveUnit c) =>
c -> ConstrainedChunk
cnstrw c
c) (c
c forall s a. s -> Getting a s a -> a
^. forall c. HasUncertainty c => Lens' c Uncertainty
unc)
data UncertQ = UQ { UncertQ -> ConstrConcept
_coco :: ConstrConcept , UncertQ -> Uncertainty
_unc'' :: Uncertainty }
makeLenses ''UncertQ
instance Eq UncertQ where UncertQ
a == :: UncertQ -> UncertQ -> Bool
== UncertQ
b = (UncertQ
a forall s a. s -> Getting a s a -> a
^. forall c. HasUID c => Lens' c UID
uid) forall a. Eq a => a -> a -> Bool
== (UncertQ
b forall s a. s -> Getting a s a -> a
^. forall c. HasUID c => Lens' c UID
uid)
instance HasUID UncertQ where uid :: Lens' UncertQ UID
uid = Lens' UncertQ ConstrConcept
coco forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. HasUID c => Lens' c UID
uid
instance NamedIdea UncertQ where term :: Lens' UncertQ NP
term = Lens' UncertQ ConstrConcept
coco forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. NamedIdea c => Lens' c NP
term
instance Idea UncertQ where getA :: UncertQ -> Maybe String
getA (UQ ConstrConcept
q Uncertainty
_) = forall c. Idea c => c -> Maybe String
getA ConstrConcept
q
instance HasSpace UncertQ where typ :: Getter UncertQ Space
typ = Lens' UncertQ ConstrConcept
coco forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. HasSpace c => Getter c Space
typ
instance HasSymbol UncertQ where symbol :: UncertQ -> Stage -> Symbol
symbol UncertQ
c = forall c. HasSymbol c => c -> Stage -> Symbol
symbol (UncertQ
cforall s a. s -> Getting a s a -> a
^.Lens' UncertQ ConstrConcept
coco)
instance Quantity UncertQ where
instance HasUncertainty UncertQ where unc :: Lens' UncertQ Uncertainty
unc = Lens' UncertQ Uncertainty
unc''
instance Constrained UncertQ where constraints :: Lens' UncertQ [ConstraintE]
constraints = Lens' UncertQ ConstrConcept
coco forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. Constrained c => Lens' c [ConstraintE]
constraints
instance HasReasVal UncertQ where reasVal :: Lens' UncertQ (Maybe Expr)
reasVal = Lens' UncertQ ConstrConcept
coco forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. HasReasVal c => Lens' c (Maybe Expr)
reasVal
instance Definition UncertQ where defn :: Lens' UncertQ Sentence
defn = Lens' UncertQ ConstrConcept
coco forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. Definition c => Lens' c Sentence
defn
instance ConceptDomain UncertQ where cdom :: UncertQ -> [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' UncertQ ConstrConcept
coco
instance MayHaveUnit UncertQ where getUnit :: UncertQ -> Maybe UnitDefn
getUnit = forall u. MayHaveUnit u => u -> Maybe UnitDefn
getUnit 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' UncertQ ConstrConcept
coco
instance Express UncertQ where express :: UncertQ -> ModelExpr
express = forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy
uq :: (Quantity c, Constrained c, Concept c, HasReasVal c, MayHaveUnit c) =>
c -> Uncertainty -> UncertQ
uq :: forall c.
(Quantity c, Constrained c, Concept c, HasReasVal c,
MayHaveUnit c) =>
c -> Uncertainty -> UncertQ
uq c
q = ConstrConcept -> Uncertainty -> UncertQ
UQ (DefinedQuantityDict -> [ConstraintE] -> Maybe Expr -> ConstrConcept
ConstrConcept (forall c.
(Quantity c, Concept c, MayHaveUnit c) =>
c -> DefinedQuantityDict
dqdWr c
q) (c
q forall s a. s -> Getting a s a -> a
^. forall c. Constrained c => Lens' c [ConstraintE]
constraints) (c
q forall s a. s -> Getting a s a -> a
^. forall c. HasReasVal c => Lens' c (Maybe Expr)
reasVal))
uqc :: (IsUnit u) => String -> NP -> String -> Symbol -> u -> Space
-> [ConstraintE] -> Expr -> Uncertainty -> UncertQ
uqc :: forall u.
IsUnit u =>
String
-> NP
-> String
-> Symbol
-> u
-> Space
-> [ConstraintE]
-> Expr
-> Uncertainty
-> UncertQ
uqc String
nam NP
trm String
desc Symbol
sym u
un Space
space [ConstraintE]
cs Expr
val = forall c.
(Quantity c, Constrained c, Concept c, HasReasVal c,
MayHaveUnit c) =>
c -> Uncertainty -> UncertQ
uq (forall u.
IsUnit u =>
String
-> NP
-> String
-> Symbol
-> u
-> Space
-> [ConstraintE]
-> Expr
-> ConstrConcept
cuc' String
nam NP
trm String
desc Symbol
sym u
un Space
space [ConstraintE]
cs Expr
val)
uqcND :: (IsUnit u) => String -> NP -> Symbol -> u -> Space -> [ConstraintE]
-> Expr -> Uncertainty -> UncertQ
uqcND :: forall u.
IsUnit u =>
String
-> NP
-> Symbol
-> u
-> Space
-> [ConstraintE]
-> Expr
-> Uncertainty
-> UncertQ
uqcND String
nam NP
trm Symbol
sym u
un Space
space [ConstraintE]
cs Expr
val = forall c.
(Quantity c, Constrained c, Concept c, HasReasVal c,
MayHaveUnit c) =>
c -> Uncertainty -> UncertQ
uq (forall u.
IsUnit u =>
String
-> NP
-> String
-> Symbol
-> u
-> Space
-> [ConstraintE]
-> Expr
-> ConstrConcept
cuc' String
nam NP
trm String
"" Symbol
sym u
un Space
space [ConstraintE]
cs Expr
val)