From e858149662f74e29098af7585de233691541abcc Mon Sep 17 00:00:00 2001 From: Maryyam Niazi Date: Thu, 5 Jul 2018 15:27:27 -0400 Subject: [PATCH] broken; attempted to replace calls to [QDefinition] with calls to [DataDefinition] --- code/Example/Drasil/DocumentLanguage.hs | 8 +++++++- code/Example/Drasil/DocumentLanguage/Definitions.hs | 6 +++++- code/Example/Drasil/GlassBR/Body.hs | 6 +++--- code/Example/Drasil/GlassBR/DataDefs.hs | 9 +++------ code/Language/Drasil.hs | 3 ++- code/Language/Drasil/Document.hs | 2 ++ code/Language/Drasil/Reference.hs | 5 +++++ 7 files changed, 27 insertions(+), 12 deletions(-) diff --git a/code/Example/Drasil/DocumentLanguage.hs b/code/Example/Drasil/DocumentLanguage.hs index 4c572c63ba..5882a82c45 100644 --- a/code/Example/Drasil/DocumentLanguage.hs +++ b/code/Example/Drasil/DocumentLanguage.hs @@ -192,6 +192,7 @@ data SCSSub where TMs :: Fields -> [TheoryModel] -> SCSSub GDs :: Fields -> [GenDefn] -> DerivationDisplay -> SCSSub DDs :: Fields -> [QDefinition] -> DerivationDisplay -> SCSSub --FIXME: Need DD intro + DDs' :: Fields -> [DataDefinition] -> DerivationDisplay -> SCSSub --FIXME: Need DD intro -- should eventually replace and be renamed to DDs IMs :: Fields -> [InstanceModel] -> DerivationDisplay -> SCSSub Constraints :: Sentence -> Sentence -> Sentence -> [Contents] {-Fields -> [UncertainWrapper] -> [ConstrainedChunk]-} -> SCSSub --FIXME: temporary definition? --FIXME: Work in Progress ^ @@ -429,7 +430,8 @@ mkSolChSpec si (SCSProg l) = mkSubSCS _ (SCSSubVerb s) = s mkSubSCS _ (TMs _ []) = error "There are no Theoretical Models" mkSubSCS _ (GDs _ [] _) = SSD.genDefnF [] - mkSubSCS _ (DDs _ [] _) = error "There are no Data Definitions" + mkSubSCS _ (DDs _ [] _) = error "There are no Data Definitions" + mkSubSCS _ (DDs' _ [] _) = error "There are no Data Definitions" --FIXME: temporary duplicate mkSubSCS _ (IMs _ [] _) = error "There are no Instance Models" mkSubSCS si' (TMs fields ts) = SSD.thModF (siSys si') (map (tmodel fields (_sysinfodb si')) ts) @@ -437,6 +439,10 @@ mkSolChSpec si (SCSProg l) = SSD.dataDefnF EmptyS (concatMap (\x -> ddefn fields (_sysinfodb si') x : derivation x) dds) mkSubSCS si' (DDs fields dds _) = SSD.dataDefnF EmptyS (map (ddefn fields (_sysinfodb si')) dds) + mkSubSCS si' (DDs' fields dds ShowDerivation) = --FIXME: need to keep track of DD intro. --FIXME: temporary duplicate + SSD.dataDefnF EmptyS (concatMap (\x -> ddefn fields (_sysinfodb si') x : derivation x) dds) + mkSubSCS si' (DDs' fields dds _) = --FIXME: temporary duplicate + SSD.dataDefnF EmptyS (map (ddefn fields (_sysinfodb si')) dds) mkSubSCS si' (GDs fields gs' ShowDerivation) = SSD.genDefnF (concatMap (\x -> gdefn fields (_sysinfodb si') x : derivation x) gs') mkSubSCS si' (GDs fields gs' _) = diff --git a/code/Example/Drasil/DocumentLanguage/Definitions.hs b/code/Example/Drasil/DocumentLanguage/Definitions.hs index 8c77d65da8..3149c142c2 100644 --- a/code/Example/Drasil/DocumentLanguage/Definitions.hs +++ b/code/Example/Drasil/DocumentLanguage/Definitions.hs @@ -50,6 +50,9 @@ tmodel fs m t = Defnt TM (foldr (mkTMField t m) [] fs) (refAdd t) ddefn :: HasSymbolTable ctx => Fields -> ctx -> QDefinition -> Contents ddefn fs m d = Defnt DD (foldr (mkQField d m) [] fs) (refAdd d) +ddefn' :: HasSymbolTable ctx => Fields -> ctx -> DataDefinition -> Contents +ddefn' fs m d = Defnt DD (foldr (mkQField d m) [] fs) (refAdd d) + -- | Create a general definition using a list of fields, database of symbols, -- and a 'GenDefn' (general definition) chunk (called automatically by 'SCSSub' -- program) @@ -97,7 +100,8 @@ tConToExpr (TCon AssumedCon x) = x -- TODO: buildDescription gets list of constraints to expr and ignores 't'. -- | Create the fields for a definition from a QDefinition (used by ddefn) -mkQField :: HasSymbolTable ctx => QDefinition -> ctx -> Field -> ModRow -> ModRow +mkQField :: (HasUID d, HasShortName d, HasSymbol d, HasAdditionalNotes d, ExprRelat d, HasSymbolTable ctx) => + d -> ctx -> Field -> ModRow -> ModRow mkQField d _ l@Label fs = (show l, (Paragraph $ at_start d):[]) : fs mkQField d _ l@Symbol fs = (show l, (Paragraph $ (P $ eqSymb d)):[]) : fs mkQField d _ l@Units fs = (show l, (Paragraph $ (unit'2Contents d)):[]) : fs diff --git a/code/Example/Drasil/GlassBR/Body.hs b/code/Example/Drasil/GlassBR/Body.hs index bd2afb84b9..8c1de6b065 100644 --- a/code/Example/Drasil/GlassBR/Body.hs +++ b/code/Example/Drasil/GlassBR/Body.hs @@ -123,7 +123,7 @@ mkSRS = RefSec (RefProg intro [TUnits, tsymb [TSPurpose, SymbOrder], TAandA]) : [ Assumptions , TMs ([Label] ++ stdFields) [t1IsSafe, t2IsSafe] , GDs [] [] HideDerivation -- No Gen Defs for GlassBR - , DDs ([Label, Symbol, Units] ++ stdFields) dataDefns ShowDerivation + , DDs' ([Label, Symbol, Units] ++ stdFields) dataDefns ShowDerivation , IMs ([Label, Input, Output, InConstraints, OutConstraints] ++ stdFields) [probOfBreak, calofCapacity, calofDemand, testIMFromQD] HideDerivation , Constraints (EmptyS) (dataConstraintUncertainty) (foldlSent [(makeRef (SRS.valsOfAuxCons SRS.missingP [])), S "gives", (plural value `ofThe` S "specification"), @@ -159,7 +159,7 @@ glassSystInfo = SI { _units = map unitWrapper [metre, second, kilogram] ++ map unitWrapper [pascal, newton], _quants = this_symbols, _concepts = [] :: [DefinedQuantityDict], - _definitions = dataDefns ++ + _definitions = (map (relToQD gbSymbMap) dataDefns) ++ (map (relToQD gbSymbMap) iModels {-[RelationConcept]-}) ++ (map (relToQD gbSymbMap) tModels {-[RelationConcept]-}) ++ [wtntWithEqn, sdWithEqn], -- wtntWithEqn is defined in Unitals but only appears @@ -620,7 +620,7 @@ traceability_matrices_and_graphs_instaModel = ["IM1", "IM2", "IM3"] traceability_matrices_and_graphs_instaModelRef = map (refFromType Theory) iModels traceability_matrices_and_graphs_dataDef = ["DD1", "DD2", "DD3", "DD4", "DD5", "DD6", "DD7", "DD8"] -traceability_matrices_and_graphs_dataDefRef = map (refFromType Data) dataDefns +traceability_matrices_and_graphs_dataDefRef = map (refFromType Data') dataDefns traceability_matrices_and_graphs_data = ["Data Constraints"] traceability_matrices_and_graphs_dataRef = [makeRef (SRS.datCon SRS.missingP [])] diff --git a/code/Example/Drasil/GlassBR/DataDefs.hs b/code/Example/Drasil/GlassBR/DataDefs.hs index 1933e74c1d..220f36cabd 100644 --- a/code/Example/Drasil/GlassBR/DataDefs.hs +++ b/code/Example/Drasil/GlassBR/DataDefs.hs @@ -22,12 +22,9 @@ import Control.Lens ((^.)) -- DATA DEFINITIONS -- ---------------------- ---dataDefns :: [DataDefinition] ---dataDefns = [riskDD, hFromtDD, strDisFacDD, nonFLDD, glaTyFacDD, dimLLDD, --- tolPreDD, tolStrDisFacDD] -dataDefns :: [QDefinition] -dataDefns = [risk, hFromt, strDisFac, nonFL, glaTyFac, dimLL, tolPre, - tolStrDisFac] +dataDefns :: [DataDefinition] +dataDefns = [riskDD, hFromtDD, strDisFacDD, nonFLDD, glaTyFacDD, dimLLDD, + tolPreDD, tolStrDisFacDD] gbQDefns :: [Block QDefinition] gbQDefns = [Parallel hFromt {-DD2-} [glaTyFac {-DD6-}]] ++ --can be calculated on their own diff --git a/code/Language/Drasil.hs b/code/Language/Drasil.hs index 317e18412d..5a12477613 100644 --- a/code/Language/Drasil.hs +++ b/code/Language/Drasil.hs @@ -29,6 +29,7 @@ module Language.Drasil ( , UID -- Classes , HasUID(uid) + , HasLabel(getLabel) , NamedIdea(term) , HasAdditionalNotes(getNotes) , Idea(getA) @@ -223,7 +224,7 @@ import Language.Drasil.Classes (HasUID(uid), NamedIdea(term), Idea(getA), Definition(defn), ConceptDomain(cdom), Concept, HasSymbol(symbol), HasUnitSymbol(usymb), IsUnit, CommonIdea(abrv), HasAdditionalNotes(getNotes), Constrained(constraints), HasReasVal(reasVal), ExprRelat(relat), HasDerivation(derivations), - HasReference(getReferences)) + HasReference(getReferences), HasLabel(getLabel)) import Language.Drasil.Chunk.AssumpChunk import Language.Drasil.Chunk.Attribute import Language.Drasil.Chunk.Derivation (Derivation) diff --git a/code/Language/Drasil/Document.hs b/code/Language/Drasil/Document.hs index e8e788e175..45b3ff41aa 100644 --- a/code/Language/Drasil/Document.hs +++ b/code/Language/Drasil/Document.hs @@ -6,6 +6,7 @@ import Language.Drasil.Chunk.AssumpChunk (AssumpChunk) import Language.Drasil.Chunk.Change (Change) import Language.Drasil.Chunk.Citation (BibRef) import Language.Drasil.Chunk.Eq (QDefinition) +import Language.Drasil.Chunk.DataDefinition (DataDefinition) import Language.Drasil.Chunk.Relation (RelationConcept) import Language.Drasil.Chunk.ReqChunk (ReqChunk) import Language.Drasil.Chunk.ShortName (HasShortName(shortname), ShortName, @@ -55,6 +56,7 @@ data Document = Document Title Author [Section] -- | Types of definitions data DType = Data QDefinition -- ^ QDefinition is the chunk with the defining -- equation used to generate the Data Definition + | Data' DataDefinition | General | Theory RelationConcept -- ^ Theoretical models use a relation as -- their definition diff --git a/code/Language/Drasil/Reference.hs b/code/Language/Drasil/Reference.hs index 9d488d25fc..4b96106168 100644 --- a/code/Language/Drasil/Reference.hs +++ b/code/Language/Drasil/Reference.hs @@ -24,6 +24,7 @@ import Language.Drasil.Document (Contents(..), DType(Data, Theory), import Language.Drasil.RefTypes (RefType(..)) import Language.Drasil.Spec (Sentence(..)) import Language.Drasil.UID (UID) +import Language.Drasil.Chunk.DataDefinition (DataDefinition) -- | Database for maintaining references. -- The Int is that reference's number. @@ -230,6 +231,10 @@ instance Referable QDefinition where -- FIXME: This could lead to trouble; need refAdd d = "DD:" ++ concatMap repUnd (d ^. uid) rType _ = Def +instance Referable DataDefinition where + refAdd d = "DD:" ++ concatMap repUnd (d ^. uid) + rType _ = Def + instance Referable InstanceModel where refAdd i = "IM:" ++ i^.uid rType _ = Def