Drasil: Data Definition auxiliary functions?

Created on 19 Jul 2018  路  2Comments  路  Source: JacquesCarette/Drasil

@szymczdm @JacquesCarette
As of issue #747, Data Definitions have there own designated data type DataDefintion instead of QDefinition.

Should these be changed to take a DataDefinition?
image

question

Most helpful comment

@niazim3 you are entirely correct. Definition is archaic and should be removed. Defnt is the placeholder for the better way of doing things which (once Definition is removed) should be renamed to Definition.

It will be a two-step process to fix, since we'll need to ensure the removal of Definition goes smoothly, then the name change should be easy.

All 2 comments

After a discussion with @elwazana, the reason why this question was brought up was because makePairs didn't have a matching-pattern for all the DTypes (missing Data'): https://github.com/JacquesCarette/Drasil/blob/fd0423c7339b6001aabdf56e19dac85803d5f457/code/drasil-lang/Language/Drasil/Document.hs#L53-L63


The reason why the current implementation is as follows. ddefn' is currently used to transform DataDefinitions to Contents for rendering
https://github.com/JacquesCarette/Drasil/blob/fd0423c7339b6001aabdf56e19dac85803d5f457/code/drasil-docLang/Drasil/DocumentLanguage/Definitions.hs#L53-L54, which shows that the DType that's being used is DD, not Data' from the kinds of DType and shows why the Contents being pattern-matched in the lay function is actually the DefnT, not the Definition kind: https://github.com/JacquesCarette/Drasil/blob/fd0423c7339b6001aabdf56e19dac85803d5f457/code/drasil-lang/Language/Drasil/Printing/Import.hs#L298-L299. Since makePairs isn't called by the only implementation of DataDefinitions (i.e. from GlassBR), no error is thrown since the Data' isn't matched in any case; that is, there is no implementation for Data').

Looking at the fixme in line 53 of Document.hs (see permalink above), it seems that this is actually desirable, since Data and Theory should eventually be removed, which I believe will be removed once DataDefinitions replace the use of QDefinitions in the examples. (Another to do after #747 implementation).

According to the fixmes it seems that the use of Defnt DD instead of Data' DataDefinition or Definition DType is better.

--FIXME: Remove Data and Theory from below.
-- | Types of definitions
data DType = Data QDefinition -- ^ QDefinition is the chunk with the defining 
                              -- equation used to generate the Data Definition
           | Data' DataDefinition
....
           | DD
-------------------------------------------------------------------------
-- | Types of layout objects we deal with explicitly
data Contents = ...       | Definition DType
               ...
               ---- FIXME: The above Definition will need to be removed ----
               | Defnt DType [(Identifier, [Contents])] RefAdd

@elwazana I don't think buildEqn/buildDDDescription functions for DataDefinition are necessary since they're used only by makePairs, which is used in the pattern for Definition, which will eventually be removed.

I think this issue can be closed. If @JacquesCarette or @szymczdm want to add or correct anything (in case I'm on the wrong track), this issue can be reopened.

@niazim3 you are entirely correct. Definition is archaic and should be removed. Defnt is the placeholder for the better way of doing things which (once Definition is removed) should be renamed to Definition.

It will be a two-step process to fix, since we'll need to ensure the removal of Definition goes smoothly, then the name change should be easy.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

smiths picture smiths  路  11Comments

smiths picture smiths  路  12Comments

Mornix picture Mornix  路  4Comments

samm82 picture samm82  路  12Comments

samm82 picture samm82  路  4Comments