Skip to content

Commit

Permalink
added Scope field to DataDefinition
Browse files Browse the repository at this point in the history
  • Loading branch information
niazim3 committed Jul 10, 2018
1 parent c79b4b2 commit 6c6e48a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions code/drasil-lang/Language/Drasil/Chunk/DataDefinition.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ import Control.Lens(makeLenses, (^.), view)

import Language.Drasil.Chunk.Eq(fromEqn, fromEqn')

data Scope = Local {-only visible within a limited scope-} | Global {-visible everywhere-}

-- A data definition is a QDefinition that may have additional notes.
-- It also has attributes like derivation, source, etc.
data DataDefinition = DD { _qd :: QDefinition
, _ref :: References
, _deri :: Derivation
, _scp :: Scope
, _ref :: References
, _deri :: Derivation
, _lbl :: ShortName {-FIXME: Upgrade to Label-}
, _notes :: Maybe [Sentence]
}
Expand All @@ -33,7 +36,7 @@ instance NamedIdea DataDefinition where term = qd . term
instance Idea DataDefinition where getA c = getA $ c ^. qd
instance HasSpace DataDefinition where typ = qd . typ
instance HasSymbol DataDefinition where symbol e st = symbol (e^.qd) st
instance Quantity DataDefinition where getUnit (DD a _ _ _ _) = getUnit a
instance Quantity DataDefinition where getUnit (DD a _ _ _ _ _) = getUnit a
instance ExprRelat DataDefinition where relat = qd . relat
instance HasReference DataDefinition where getReferences = ref
instance Eq DataDefinition where a == b = (a ^. uid) == (b ^. uid)
Expand All @@ -51,4 +54,4 @@ mkDataDef cncpt equation = datadef $ getUnit cncpt --should references be passed

-- | Smart constructor for data definitions
mkDD :: QDefinition -> References -> Derivation -> String{-Label-} -> Maybe [Sentence] -> DataDefinition
mkDD a b c _ e = DD a b c (shortname' $ a ^. uid {-shortname' d-}) e -- FIXME: should the shortname be passed in or derived?
mkDD a b c _ e = DD a Global b c (shortname' $ a ^. uid {-shortname' d-}) e -- FIXME: should the shortname be passed in or derived?

3 comments on commit 6c6e48a

@JacquesCarette
Copy link
Owner

Choose a reason for hiding this comment

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

So the problem with this definition is that we really ought to first define the notion of 'scope', and then the Local scope should take a scope as a parameter.

For now, we can probably make a scope be specified via an indirect reference, i.e. a Label. We can later decide which things define new scopes (such as DataDefinitions), and make it an error to scope something to an element which does not in fact define a scope.

@niazim3
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Shall I make a design issue for your point "We can later decide which things define new scopes (such as DataDefinitions), and make it an error to scope something to an element which does not in fact define a scope."?


Also, was something similar to the following more close to what you're looking for : 195abfc?

@JacquesCarette
Copy link
Owner

Choose a reason for hiding this comment

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

Yes and yes.

Please sign in to comment.