Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing explicit ShortName with Label in Chunk types #695

Open
13 of 14 tasks
elwazana opened this issue Jun 21, 2018 · 31 comments
Open
13 of 14 tasks

Replacing explicit ShortName with Label in Chunk types #695

elwazana opened this issue Jun 21, 2018 · 31 comments

Comments

@elwazana
Copy link
Collaborator

elwazana commented Jun 21, 2018

Chunk

  • AssumpChunk
  • Change
  • Concept/Core !
  • Citation !
  • Eq
  • GenDefn
  • Goal !
  • InstanceModel
  • PhysSystDesc !
  • Relation !
  • ReqChunk
  • Theory

Document

  • Section
  • Contents

In PR #693 @JacquesCarette and I discussed replacing the explicit shortname in some Chunk types with a Label, I've created this issue just to keep track of which ones need to be replaced.

Also as a note the (!) next to some are due to them having an instance of HasShortName but posses no ShortName, i.e:
image
@JacquesCarette Should I add a Label to these as well?

@elwazana elwazana self-assigned this Jun 21, 2018
@JacquesCarette
Copy link
Owner

Goal and PhysSystDesc should definitely have labels.

Relation is a horrible hack. But that is a separate thing. The way it is abused right now means that it should likely have a label as well.

If a Citation is a bibliography entry, then yes, that too should have a label.

@elwazana
Copy link
Collaborator Author

@JacquesCarette Hello Dr. Carette, I missed Concept/Core.hs when I was creating the task list above. Does that need a Label as well? It currently has a Maybe Shortname.

@JacquesCarette
Copy link
Owner

Can you figure out when the shortname of a Concept is used? I mean, when is it set (in examples). I think that will help me understand its usage, which I think will guide the design.

@Mornix
Copy link
Collaborator

Mornix commented Jun 21, 2018

ConceptChunk gained the Maybe ShortName last week as part of the work to de-embed ALUR (and make ConceptChunk referable.
It is currently unused. All constructors at the moment simply set it as Nothing.

@JacquesCarette
Copy link
Owner

Right. That should be upgraded to a Maybe Label. We can refine later, but at least that should allow both @elwazana and @Mornix to proceed.

@elwazana
Copy link
Collaborator Author

@JacquesCarette Hello Dr. Carette, I've tried incorporating Maybe Label but whenever I get to the instance of HasLabel I can't figure out how to use a Lens' to unwrap the Maybe from the Maybe Label.

I've looked through the other types to see if a Lens was used over a Maybe type and the only way around this I could find is to create a:

class HasMaybeLabel c where
  getMaybeLabel :: Lens' c (Maybe Label)

But this solution seems bit smelly to me, is there another solution? If not can I get a go ahead on this solution?

@JacquesCarette
Copy link
Owner

No, that's right, you have to create a Lens to a Maybe Label.

@elwazana
Copy link
Collaborator Author

@JacquesCarette I implemented the above to correct the Maybe Label error in the instance of HasLabel, after that, I tried to fix the HasShortName instance for ConceptChunk so that it retrieves the shortname from the Label. When I did that I got this error:
image

So to fix that I added an instance of HasShortName specifically for Maybe Label:
image

But this resulted in this error:
image

I've discussed possible solutions with @niazim3 but nothing we come up with seems to even change the error.

@JacquesCarette
Copy link
Owner

So you won't be able to build a proper instance of HasShortName for ConceptChunk out of getMaybeLabel. This is because it might be Nothing, which is not a valid shortname!

In other words, the handling of label/shortname for ConceptChunk is going to have to be coded differently. Right now, since it's not used, simply don't worry about it, we can let @Mornix deal with it later.

@niazim3
Copy link
Collaborator

niazim3 commented Jun 22, 2018

Is there an example of a time where a Label would not be desirable when building a ConceptChunk? If not, can Concept/Core.hs take a Label instead of a Maybe Label?

@Mornix
Copy link
Collaborator

Mornix commented Jun 22, 2018

From when I was looking at the currentConceptChunk uses, it looks like the type backs a lot of things in Data.Drasil and I believe more localized concepts in each individual example. These currently aren’t referable. (I’m not sure if they should be referable in the future /cc @JacquesCarette)

@JacquesCarette
Copy link
Owner

Right. ConceptChunk is very basic in our hierarchy, and often corresponds to purely internal knowledge that does not necessarily even appear in documents. Those do not need to be referable.

Eventually I think we will end up splitting our uses of ConceptChunk into more meaningful sub-categories, and then some of the sub-categories will have labels, and the others will not. But we're not quite ready for that yet.

@niazim3
Copy link
Collaborator

niazim3 commented Jun 25, 2018

Would it be a good idea to work on the other data types as discussed in previous issues and meetings in the meanwhile (ignoring the Maybe problem brought up by Concept/Core)?

Perhaps another issue can be made for that as this is commented out (to ensure the implementations for the other data types are correct)?

Or is this issue being in the midst of being worked on/close to being finished that we can wait on completion of this whole issue?

@JacquesCarette
Copy link
Owner

Yes, getting many of the data-types which need this work done now is a good idea.

ConceptChunk is not close enough to rely on. So it would be best if this could proceed independently.

@elwazana
Copy link
Collaborator Author

@JacquesCarette Since we will be removing the instance for Contents is it necessary to update the HasShortName instances of Contents to match shortname becoming a Lens instead of a getter?
image

@elwazana
Copy link
Collaborator Author

@JacquesCarette Also with regards to Section:
image
Would it make more sense to have Section as a record type? Or should it be kept as is for the design?

@JacquesCarette
Copy link
Owner

We discussed removing the instance for Concept yesterday. Not Contents.

Although grabbing a label from a Contents might eventually make more sense than directly getting the shortname.

Yes, it makes sense to make Section a record type, as that can make accessing parts easier.

@elwazana
Copy link
Collaborator Author

@JacquesCarette I was referring to issue #629 task 4 of @niazim3 checklist when I mentioned removing the instances of Contents, unless that has been changed?

@JacquesCarette
Copy link
Owner

Ah, that makes sense. Right, Content will be 'raw' and LabelledContent will have the Label and Content will not. I had forgotten - perfect.

@elwazana
Copy link
Collaborator Author

elwazana commented Jul 3, 2018

@JacquesCarette Hello Dr. Carette, I've removed the instances of Contents and I had a question about what should be done with the referencing functions in References.hs:
image

There are two issues here:

  1. acroTest and find' use makeRef to work, however, makeRef requires a type with a HasShortName and Referable instance which Contents doesn't have anymore.

  2. With regards to find' should it be changed to:

find' :: LabelledContent -> [LabelledContent] -> LabelledContent
find' = ~~~~~

Also, I realize that acroTest will be replaced alongside the other acro- functions but for now what should be done with it?

@niazim3
Copy link
Collaborator

niazim3 commented Jul 3, 2018

  1. Re: Since LabelledContent is now an instance of HasShortName and Referable, I think it can replace Contents.

@JacquesCarette
Copy link
Owner

I agree with @niazim3 , it does seem like LabelledContent should fit the bill.

@elwazana
Copy link
Collaborator Author

elwazana commented Jul 4, 2018

@JacquesCarette Hello Dr. Carette I was able to integrate LabelledContent in place of Contents for the referencing functions and that runs fine now. But I've run into this problem that I'm unsure how to solve.

image

The problem is that convertRel uses ec which is a constructor for Eq, this was adjusted to take in a Label instead of a ShortName, but fixing that here to take a Label causes the following to break:

image

I was able to fix the issue by doing this:
image

However, this seems a bit off to me. I'm not sure if this is becuase relToQD is a hack (issue #628), or its becuase of my fix. So I just wanted to get some feedback on it before getting too far ahead.

@JacquesCarette
Copy link
Owner

Both relToQD and convertRel are awful hacks. Your change is 'optimal' given the constraints.

The correct fix involves ripping out ExprRelat altogether and creating a proper class for 'definitions'. Right now, our definitions are done implicitly through the relational subset of Expr, and is super-fragile. However, it will be needed once we move to doing code generation for ODEs, for example.

It would be nice if we could get to at least fixing the relToQD hack this summer.

niazim3 added a commit that referenced this issue Jul 4, 2018
@niazim3
Copy link
Collaborator

niazim3 commented Jul 4, 2018

Note:

As of the most recent commit, build is breaking at the following error:

.\code\Data\Drasil\Utils.hs:139:18: error:
    • No instance for (HasShortName Contents)
        arising from a use of ‘makeRef’
    • In the first argument of ‘(.)’, namely ‘makeRef’
      In the expression: (makeRef . Definition . f)
      In an equation for ‘refFromType’:
          refFromType f = (makeRef . Definition . f)

. It originally looked like all that needs to be done is convert the Contents created with the call on Definition to a LabelledContent (may still be the case).

This refFromType is used in the examples on [QDefinitions] and [RelationConcept] (e.g.

traceability_matrices_and_graphs_theorysRef = map (refFromType Theory) tModels
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
) to tack on "DD" or "T" (depending on if the element Definition is a Theory or Data):
refAdd t = "T:" ++ t ^. uid

refAdd d = "DD:" ++ concatMap repUnd (d ^. uid)
, since all makeRef is expecting is anything that is an instance of HasShortName and Referable, which anything with a Label will be.

If RelationConcept becomes an instance of HasLabel, there will be no need for any conversion to a Contents or LabelledContent or for appending "T:" or "DD:" to any labels, which is something good to remove (seeing #734).

@niazim3
Copy link
Collaborator

niazim3 commented Jul 4, 2018

Question/Proposal

Having said that, #628 mentions that RelationConcept is too raw/unstable to be augmented; therefore, TMs, IMs, and GDs should build off of RelationConcept (which InstanceModel and GenDefn already does:

-- | An Instance Model is a RelationConcept that may have specific input/output
-- constraints. It also has attributes like derivation, source, etc.
data InstanceModel = IM { _rc :: RelationConcept
, _imInputs :: Inputs
, _inCons :: InputConstraints
, _imOutput :: Output
, _outCons :: OutputConstraints
, _ref :: References
, _deri :: Derivation
, _refName :: ShortName
, _notes :: Maybe [Sentence]
}
makeLenses ''InstanceModel

-- | A GenDefn is a RelationConcept that may have units
data GenDefn = GD { _relC :: RelationConcept
, gdUnit :: Maybe UnitDefn
, _deri :: Derivation
, _ref :: References
, _refName :: ShortName
}
makeLenses ''GenDefn
).
@szymczdm @JacquesCarette Is there a reason TheoryChunk doesn't
data TheoryChunk = TC { _tid :: UID
, _vctx :: [TheoryChunk]
, _spc :: [SpaceDefn]
, _quan :: [QuantityDict]
, _ops :: [ConceptChunk]
, _defq :: [QDefinition]
, _invs :: [TheoryConstraint]
, _dfun :: [QDefinition]
, _ref :: References
}
makeLenses ''TheoryChunk
? Should it first be reworked to build off of a RelationConcept before continuing the work on LabelledContent?

@JacquesCarette
Copy link
Owner

TheoryChunk is good at it is. It is a collection of lots of things.
GenDefn and InstanceModel are pretty good, but still a bit hacky. Mostly because RelationConcept is somewhat broken. It should really be a generalization of QDefinition. This hack is similar to the one afflicting relToQD.

@JacquesCarette
Copy link
Owner

Regarding the previous comment: even if RelationConcept is sub-optimal (but just in the 'fact' that it has a relation instead of a defining equation, which it usually has, but encoded as a relation), it is still the right 'base' on which to build lots of stuff. And thus adding a Label to it is a good idea.

@niazim3
Copy link
Collaborator

niazim3 commented Jul 4, 2018

If a Label is added to RelationConcept, would that Label be propagated to the InstanceModel and GenDefns that build off of the RelationConcept?
Or would those data instances have their own Label?
@szymczdm @JacquesCarette

@JacquesCarette
Copy link
Owner

I think that they would be separate labels. Hmm, I think I was assuming Maybe Label for RelationConcept, not just Label.

@niazim3 niazim3 mentioned this issue Jul 27, 2018
12 tasks
JacquesCarette pushed a commit that referenced this issue Aug 8, 2018
* Work In Progress

* Changes to previous commit as discussed in comments within the commit

* W.I.P Update with Section as record type and removal of HasShortName instance of Contents

* W.I.P adjusted relToQD and convertRel to take Label

* reduced errors in Utils.hs; still breaking (see #695 for error message and potential solutions)

* added Maybe Label field to RelationConcept

* update RefFromType temporarily to be the same as makeRef

* started adding labels to get past errors resulting from missing Labels

* continued work on adding labels to example

* made makeRA' and makeRA'' constructors; updated more examples to not break

* added labels to SSP references

* fixed typos (whoops)

* worked on getting past SSP when make is run for Label updates

* broken; added LabelledContent as a SecCons; started to implement datCon as LabelledContent instead of Contents

* updated some definitions to be of correct types; inlined labelled will need to be pulled out

* continued updating Contents use to LablledContent use

* made Label an instance of Referable class to allow use of just labels for referencing (removes some uses of missingP hack)

* updated SSP for PSD as labelledcontents

* continued work on DataConstraints section update; fixed some typos; added a crucial(?) fixme as a reminder

* created Labels.hs file for SWHS to avoid import cycles created from attempt to inter-reference TM and IM (removes another hack)

* continued work on labels/referencing for SWHS; new issues will be opened soon with regard to Fixmes

* removed use of refFromType that was causing errors from expecting Contents to have a Label

* work on SWHS continued; some errors removed that resulted from previous merge

* updated traceGIntro to not include text that is not related to SRS content

* WIP: clearing errors from SWHS

* finally breaks outside of SWHS (with uncomment of horrible swhsIMods' hack)

* started work on NoPCM; will be pausing work on this branch until yuzhi branch is merged in

* removed redundant imports; fixing up implementation to break where it was breaking before merge of master into this branch; adding labels to SSP

* removed decrepit code from SSP body; cleaned up import lists; working on getting make to run past SWHS

* removed duplicate function from SWHS; make now breaks in GamePhysics

* GamePhysics Tmods and References updated for labels

* GamePhysics Imodels updated for labels

* shortened lines of code in GamePhysics Body

* updating NoPCM and SWHS for label updates

* continuing work on label integration; breaking in GlassBR

* removed definition of ref from GlassBR TMods

* continued work on GlassBR

* continued work on getting examples to run through use of LabelledContent instead of Contents

* replaced testing1 function use with that of gbrIMods for referencing purposes

* GlassBR broken due to TheoryModels and referencing infrastructure

* temporarily commented out line causing error in GlassBR; cleaned up imports; moving onto SSP example

* cleaned up NoPCM asssumptions; Examples compile

* worked on rendering labels; still need to view if implementation works

* general definition implementation updated for LabelledContent type instead of Contents

* cleaned up some examples; updated some functions for Label updates

* running make now gets to logs after GlassBR is completely commented out in makefile

* removed appearance of fixmelabel0 in all logs; hardcoded missing "Table:" so that logs reduce slightly

* created DataDefinitions for HGHC example; no more occurrences of "fixmelabel4" in logs

* updated Tiny stable for changes made in previous commit

* updated Assumptions section to expect [LabelledContent] instead of [Contents]; need to determine why lay is being used instead of lay prime

* removed find' and acroTest

* reset makefile to not have commented out code

* updated examples for change made to assumpF; "fixmelabel8" no longer shows up in logs

* dataDefnF now expects [LabelledContent] instead of [Contents]; attempting to determine how to remove presence of "fixmelabel3" from logs

* removed hardcoded "LC"s as discussed in previous commit comment discussions; made IOrgSec accept a label instead of a section for referencing; removed accidentally added wreq.png file

* merge issue321 branch into addLabels

* removed errors and warnings so that original errors show up

* updated accessContents definitions as suggested

* started use of HasMaybeLabel instead of HasLabel for LabelledContent; broken

* made updates in files (some makeRef -> makeRefSec)

* updated definition of ModRow to use LabelledContent instead of Contents; mkIMField updated for these changes

* finished updated functions for new ModRow definition; occurrences of "fixmelabel3" in logs has reduced

* makefile revert

* updated inModel section generation to use LabelledContents; further reduces appearance of "fixmelabel3" in logs

* removed all appearances of "fixmelabel3" in logs

* removed missingP hack; relates to #374

* Fix the bug in symbol collecting.

* fixing errors that resulted from mrege; currently breaking in GlassBR

* GlassBR updated for merged implementation; working on compiling SWHS successfully

* multiple fixmes and some obsolete code removed from SWHS; SWHS now compiles; working on NoPCM

* NoPCM fixed; few fixmes worked on; working on Tiny example

* tiny example compiles; moving onto fixing SSP

* SSP example compiles; working on GamePhysics updates

* examples now compile

* removed datadefn from Drasil

* updated stable to be the same as it was before the merge of PR #962; removed some mkEmptyLabels from implementation

* small implementation fixes suggested in pr #962

* removed some mkEmptyLabel instances

* W.I.P. correcting generated

* removed some more mkEmptyLabel instances from implementation

* mkEmptyLabel removed from reldefn

* [Small PR] Improved GlassBR Code (#965)

* Moved functional_requirements_req6_pulledList as per #902

* Changed underscores in function names to camelCase in Body

* Changed is_safe1 and is_safe2 to is_safePb and is_safeLR

* removed a series of warnings in Drasil

* Attempt at assumption referencing in Chipmunk and make Glass compile

* replaced some empty labels with an UnlabelledContent where appropriate

* removed enumitem from stable that was accidentally reinserted (originally removed in PR #958)

* Creating mkRawLC to append prefixes to labels

* Finished mkRawLC

* removed decrepit RefAdd fields from RawContents

* fixed error; replaced one more instance of mkEmptyLabel

* Implementing mkRawLC for LikelyChanges

* Update stable?

* Removed '_Label' from labels in SWHS

* updated tiny stable equation labels, removed another mkEmptyLabel

* made labels of sections not have the same refadd and shortname; reduces "Sec:"-related discrepancies in the logs; reintroduced repUnd hack since its removal was causing unrelated discrepancies

* updated definition of ddefn' and mkRawLC; tiny log now empty

* updated Definitions.hs to use mkRawLC more; updated intro in CP to match that of manual version

* updated stable GamePhysics Assumptions to remove redundant 'A's in labels of some assumptions

* updated labels in TMods and IMods for GamePhysics to match stable

* slightly cleaned up implementation of mkRawLC

* Fixed Chipmunk Assumption links

* updated stable SSP netforce labels to match generated; fixed error from merge and removed some duplication from chipmunk

* W.I.P. reintroducing repUnd

* displays updated in stable to the desired output as mentioned in #970

* more updates in stable SSP for changes in label display

* reduced discrepancies in SSP_log

* Reduced Chipmunk log significantly

* Removed space in stable

* trivial updates to NoPCM SRS

* some trivial updates to stable; removal of the use of UID for labels for Requirement and Change LabelledContents

* Fix the symptom of #891. It does not fix the issue of ExprRelat itself, but may result in more relToQD being removed, so that the issue may become less important.

* updated stable for trivial updates in NoPCM stable

* Finished emptying Chipmunk log

* Updated SSP stable with equation labels

* more trivial updates to stable for NoPCM

* removed reldefn from Drasil completely; insuccessfully attempted to run GlassBR

* 1. improve error message for when things fail. 2. add defined_fun to definition too, just in case.

* Fixing SWSW log

* Make RelationConcept have a full Label (this is a bit of a hack, but since RelationConcept is likely to disappear, not so bad). Propagate this change throughout the code and the examples. Still not quite right, but it feels closer.

* some comments as to next steps

* cleaned up implementation of mkRawLC by creating setLabel function; implemented a function's use from makeRef; removes discrepancies occurring from underscores that were not being replaced with periods upon makeRef use

* removed refAdd field from Goal and PSD

* moved DType and makePairs for use in shortname setting hack; removed Data, Data', Theory that were causing import cycles with move (#926)

* implemented extra space after some shortname acronyms as mentioned in #970; logs need cleaning

* Corrected melfFrac issue in SWHS

* Updated Chipmunk stable

* Updated SSP stable

* Updated NoPCM stable except for 'Sec:' issue

* Generating different prefixes for Functional/Non-Functional requirements

* no longer exports lbl field for Goal or PhysSystDesc

* NoPCM stable updated for trivial fixes; refaddresses now no longer depend on UIDs of chunks for refaddresses

* minor typo fix

* Correcting SWHS log

* GlassBR compiles - updated Makefile and added missing quantities to gbInputs

* added RefType as a field to Label; feels like a very roundabout and messy implementation that I'd like some feedback on before propagating changes to remaining chunks

* Started clearing GlassBR log

* Fixed trivial diffs in GlassBR log

* label constructor created for AssumpChunk Labels; generated HTML list of assumptions currently has prepended A: that was asked about in issue #970

* SWHS log fixed

* reverted changes that caused A: to be appended to the shortname upon creation of label; fixed typo in NoPCM

* replaced mkLabelRA'' with mkLabelSame as suggested

* Updating stable for NoPCM log

* NoPCM stable update

* Completed NoPCM stable update

* implemented newer design implementation; <<loop>> error is back; looking into it

* replaced mkLabelRA'' with mkLabelSame as suggested

* implemented newer design implementation; <<loop>> error is back; looking into it

* Fix #961 loop issue (again). This had a different cause

* Remove tab characters and fix whitespace

* updated package version numbers and dependencies; working on logs

* removed obsolete mkLabelRA

* removed duplicate tags that were being printed with some refaddresses; continue to clear log

* removed unitToEmptyS function accidentally added

* workaround for traceability infrmation in reference addresses

* shortnames displayed with acronyms and spaces when appropriate (#970)

* GlassBR DDs' shortnames now appear in traceability matrices

* trivial updates made to stable versions of examples

* GlassBR now generates

* Fixed some referencing in SWHS and NoPCM

* Removed warnings

* R6 in glassbr now displayed in output; has a working link to it as well

* Removed warnings

* added reftype as a field to Label as a hack; clears logs; ready for merge to master

* Fixed GlassBR inputs hack

* Minor updates to Makefile
@JacquesCarette
Copy link
Owner

Just a note for @Nathaniel-Hu and @muhammadaliog3 that your work of finding all the data, classes and instances will have an impact on this issue. The underlying reason it's still not fixed is that our concept matrix isn't quite "right".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To do
Development

No branches or pull requests

5 participants