Skip to content

Commit

Permalink
broken; attempted to replace calls to [QDefinition] with calls to [Da…
Browse files Browse the repository at this point in the history
…taDefinition]
  • Loading branch information
niazim3 committed Jul 5, 2018
1 parent 5fa47d1 commit e858149
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 12 deletions.
8 changes: 7 additions & 1 deletion code/Example/Drasil/DocumentLanguage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ^
Expand Down Expand Up @@ -429,14 +430,19 @@ 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)
mkSubSCS si' (DDs fields dds ShowDerivation) = --FIXME: need to keep track of DD intro.
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' _) =
Expand Down
6 changes: 5 additions & 1 deletion code/Example/Drasil/DocumentLanguage/Definitions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions code/Example/Drasil/GlassBR/Body.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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) ++

This comment has been minimized.

Copy link
@niazim3

niazim3 Jul 5, 2018

Author Collaborator

probably shouldn't be doing this since relToQD is a hack (#628)... should the original list of QDefinitions just be passed in here? should that list even be available to the Body or should it be using the list of DataDefinitions?

This comment has been minimized.

Copy link
@JacquesCarette

JacquesCarette Jul 5, 2018

Owner

Try not to keep each set of changes as small as possible. If you can make things work via using relToQD for now, that's fine. Then we can investigate what should really be going on here, and do a proper design.

(map (relToQD gbSymbMap) iModels {-[RelationConcept]-}) ++
(map (relToQD gbSymbMap) tModels {-[RelationConcept]-}) ++
[wtntWithEqn, sdWithEqn], -- wtntWithEqn is defined in Unitals but only appears
Expand Down Expand Up @@ -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 [])]
Expand Down
9 changes: 3 additions & 6 deletions code/Example/Drasil/GlassBR/DataDefs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion code/Language/Drasil.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module Language.Drasil (
, UID
-- Classes
, HasUID(uid)
, HasLabel(getLabel)
, NamedIdea(term)
, HasAdditionalNotes(getNotes)
, Idea(getA)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions code/Language/Drasil/Document.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

This comment has been minimized.

Copy link
@niazim3

niazim3 Jul 5, 2018

Author Collaborator

I did a lot of this duplication (i.e. Data', DDs', ddefn', etc.). Was this a proper approach to migrating from depending on the raw QDefinition to the "complete" DataDefinition?

This comment has been minimized.

Copy link
@JacquesCarette

JacquesCarette Jul 5, 2018

Owner

As a first step, yes. And then we should try to deprecate Data (and then rename Data' to Data).

| General
| Theory RelationConcept -- ^ Theoretical models use a relation as
-- their definition
Expand Down
5 changes: 5 additions & 0 deletions code/Language/Drasil/Reference.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)

This comment has been minimized.

Copy link
@niazim3

niazim3 Jul 5, 2018

Author Collaborator

If this is correct, this is a problem that'll eventually need to be investigated for #734.

This comment has been minimized.

Copy link
@JacquesCarette

JacquesCarette Jul 5, 2018

Owner

Both the DD and use of uid are suspicious. The later should use Label, somehow.

rType _ = Def

instance Referable InstanceModel where
refAdd i = "IM:" ++ i^.uid
rType _ = Def
Expand Down

2 comments on commit e858149

@niazim3
Copy link
Collaborator Author

@niazim3 niazim3 commented on e858149 Jul 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code currently breaks here:

code\Example\Drasil\DocumentLanguage\Definitions.hs:108:69: error:
    • Couldn't match type ‘d’ with ‘QDefinition’
      ‘d’ is a rigid type variable bound by
        the type signature for:
          mkQField :: forall d ctx.
                      (HasUID d, HasShortName d, HasSymbol d, HasAdditionalNotes d,
                       ExprRelat d, HasSymbolTable ctx) =>
                      d -> ctx -> Field -> ModRow -> ModRow
        at Example\Drasil\DocumentLanguage\Definitions.hs:103:13
      Expected type: Control.Lens.Getter.Getting Expr d Expr
        Actual type: (Expr -> Data.Functor.Const.Const Expr Expr)
                     -> QDefinition -> Data.Functor.Const.Const Expr QDefinition
    • In the second argument of ‘(^.)’, namely ‘equat’
      In the second argument of ‘($=)’, namely ‘d ^. equat’
      In the second argument of ‘($)’, namely ‘sy d $= d ^. equat’
    • Relevant bindings include
        d :: d
          (bound at Example\Drasil\DocumentLanguage\Definitions.hs:108:10)
        mkQField :: d -> ctx -> Field -> ModRow -> ModRow
          (bound at Example\Drasil\DocumentLanguage\Definitions.hs:105:1)

and I'm not sure why... the passed in d that it's saying isn't the right type is supposed to be an instance of class ExprRelat, which both QDefinition and DataDefinition are; so why is it expecting a QDefinition explicitly? @szymczdm

@JacquesCarette
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This usually happens when a later case is "bad" and is inferred to have the more restrictive type. And then the error shows up a few lines above. [Haskell seems to infer the types of cases from the bottom up]. So the true bug is elsewhere in the same function.

Please sign in to comment.