Skip to content

Commit

Permalink
made makeRA' and makeRA'' constructors; updated more examples to not …
Browse files Browse the repository at this point in the history
…break
  • Loading branch information
niazim3 committed Jul 6, 2018
1 parent 21b0c88 commit 7bb8954
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 46 deletions.
19 changes: 0 additions & 19 deletions code/drasil-data/Data/Drasil/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -175,25 +175,6 @@ unwrap :: (Maybe UnitDefn) -> Sentence
unwrap (Just a) = Sy (a ^. usymb)
unwrap Nothing = EmptyS

<<<<<<< HEAD
-- Used to help make Qdefinitions when uid, term, and symbol come from the same source
mkDataDef :: (Quantity c) => c -> Expr -> Label -> QDefinition
mkDataDef cncpt equation lbl = datadef (getUnit cncpt) lbl
where datadef (Just a) lbl = fromEqn (cncpt ^. uid) (cncpt ^. term) EmptyS
(eqSymb cncpt) a equation [] lbl
datadef Nothing lbl = fromEqn' (cncpt ^. uid) (cncpt ^. term) EmptyS
(eqSymb cncpt) equation [] lbl

-- Same as 'mkDataDef', but with an additional Sentence that can be taken as "extra information"; issue #350
mkDataDef' :: (Quantity c) => c -> Expr -> Sentence -> References -> Label -> QDefinition
mkDataDef' cncpt equation extraInfo refs lbl = datadef (getUnit cncpt) lbl
where datadef (Just a) lbl = fromEqn (cncpt ^. uid) (cncpt ^. term) extraInfo
(eqSymb cncpt) a equation refs lbl
datadef Nothing lbl = fromEqn' (cncpt ^. uid) (cncpt ^. term) extraInfo
(eqSymb cncpt) equation refs lbl

=======
>>>>>>> master
prodUCTbl :: [[Sentence]] -> Contents
prodUCTbl cases = Table [S "Actor", titleize input_ +:+ S "and" +:+ titleize output_]
cases
Expand Down
16 changes: 8 additions & 8 deletions code/drasil-example/Drasil/GlassBR/Assumptions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ newAssumptions :: [AssumpChunk] -- For testing
newAssumptions = [newA1, newA2, newA3, newA4, newA5, newA6, newA7, newA8]

newA1, newA2, newA3, newA4, newA5, newA6, newA7, newA8 :: AssumpChunk
newA1 = assump "glassTyA" a1Desc "glassTy"
newA2 = assump "glassConditionA" a2Desc "glassCondition"
newA3 = assump "explsnScenarioA"a3Desc "explainScenario"
newA4 = assump "standardValuesA" (a4Desc load_dur) "StandardValues"
newA5 = assump "glassLiteA" a5Desc "glassLite"
newA6 = assump "bndryConditionsA" a6Desc "boundaryConditions"
newA7 = assump "responseTyA" a7Desc "responseType"
newA8 = assump "ldfConstantA" (a8Desc constant_LoadDF) "ldfConstant"
newA1 = assump "glassTyA" a1Desc (makeRA'' "glassTy")
newA2 = assump "glassConditionA" a2Desc (makeRA'' "glassCondition" )
newA3 = assump "explsnScenarioA"a3Desc (makeRA'' "explainScenario")
newA4 = assump "standardValuesA" (a4Desc load_dur) (makeRA'' "StandardValues")
newA5 = assump "glassLiteA" a5Desc (makeRA'' "glassLite")
newA6 = assump "bndryConditionsA" a6Desc (makeRA'' "boundaryConditions")
newA7 = assump "responseTyA" a7Desc (makeRA'' "responseType" )
newA8 = assump "ldfConstantA" (a8Desc constant_LoadDF) (makeRA'' "ldfConstant")

assumptionDescs :: [Sentence]
assumptionDescs = [a1Desc, a2Desc, a3Desc, a4Desc load_dur, a5Desc, a6Desc, a7Desc, a8Desc constant_LoadDF]
Expand Down
4 changes: 2 additions & 2 deletions code/drasil-example/Drasil/HGHC/HeatTransfer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ htTransCladCool = fromEqn "htTransCladCool" (nounPhraseSP
"convective heat transfer coefficient between clad and coolant")
EmptyS
(lH `sub` lC) heat_transfer_coef htTransCladCool_eq []
"htTransCladCool" --shortname
(makeRA'' "htTransCladCool")

htTransCladCool_eq =
(2 * (sy cladCond) * (sy coolFilmCond) / (2 * (sy cladCond) + (sy cladThick)
Expand All @@ -45,7 +45,7 @@ htTransCladFuel = fromEqn "htTransCladFuel" (nounPhraseSP
"effective heat transfer coefficient between clad and fuel surface")
EmptyS
(lH `sub` lG) heat_transfer_coef htTransCladFuel_eq []
"htTransCladFuel" --shortname
(makeRA'' "htTransCladFuel")

htTransCladFuel_eq = (2 * (sy cladCond) * (sy gapFilmCond)) / (2 * (sy cladCond)
+ ((sy cladThick) * (sy gapFilmCond)))
Expand Down
4 changes: 2 additions & 2 deletions code/drasil-example/Drasil/SRS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ tOfSymb cs ss = section' (titleize Doc.tOfSymb) cs ss "ToS"

--function that sets the shortname of each section to be the reference address
section' :: Sentence -> [Contents] -> [Section] -> RefAdd -> Section
section' a b c d = section a b c d (shortname' $ getStr a) --FIXME: getStr hack
section' a b c d = section a b c (mkLabelRA' (d ++ "Label") d)
where
getStr :: Sentence -> String
getStr (S s) = s
Expand All @@ -108,4 +108,4 @@ section' a b c d = section a b c d (shortname' $ getStr a) --FIXME: getStr hack

--
missingP :: [Contents]
missingP = [Paragraph $ S "..."]
missingP = [Paragraph $ S "..."]
3 changes: 3 additions & 0 deletions code/drasil-example/Drasil/SWHS/References.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ ref1 = cBookA "bueche1986" [jBueche]
(S "Introduction to Physics for Scientists")
(S "McGraw Hill") 1986
[edition 4, address (S "New York City, New York")]
(makeRA'' "bueche1986")

ref2 = cBookA "incroperaEtAl2007" [fIncropera, dDewitt, tBergman, aLavine]
(S "Fundamentals of Heat and Mass Transfer")
(S "John Wiley and Sons") 2007
[edition 6, address (S "Hoboken, New Jersey")]
(makeRA'' "incroperaEtAl2007")

ref3 = koothoor2013

Expand All @@ -33,6 +35,7 @@ ref4 = cMisc "lightstone2012" [
title (S "Derivation of tank/pcm model"),
year 2012,
note (S "From Marilyn Lightstone's Personal Notes")]
(makeRA'' "lightstone2012")

ref5 = parnasClements1986

Expand Down
2 changes: 1 addition & 1 deletion code/drasil-example/drasil-example.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: drasil-example
Version: 0.1.1
Version: 0.1.4
Cabal-Version: >= 1.18
Author: Dan Szymczak, Steven Palmer, Jacques Carette, Spencer Smith
build-type: Simple
Expand Down
7 changes: 2 additions & 5 deletions code/drasil-lang/Language/Drasil.hs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ module Language.Drasil (
, RefAdd
-- Label
, Label
, mkLabelRA, mkLabelRA'
, mkLabelRA, mkLabelRA', mkLabelRA''
) where

import Prelude hiding (log, sin, cos, tan, sqrt, id, return, print, break, exp, product)
Expand Down Expand Up @@ -244,17 +244,14 @@ import Language.Drasil.Classes (HasUID(uid), NamedIdea(term), Idea(getA),
HasUnitSymbol(usymb), IsUnit, CommonIdea(abrv), HasAdditionalNotes(getNotes),
Constrained(constraints), HasReasVal(reasVal), ExprRelat(relat), HasDerivation(derivations),
HasReference(getReferences), HasLabel(getLabel))
<<<<<<< HEAD
import Language.Drasil.Label.Core (Label)
=======
>>>>>>> master
import Language.Drasil.Chunk.AssumpChunk
import Language.Drasil.Chunk.Attribute
import Language.Drasil.Chunk.Derivation (Derivation)
import Language.Drasil.Chunk.References (References)
import Language.Drasil.Chunk.ShortName (ShortName, shortname', HasShortName(shortname))
import Language.Drasil.Chunk.Change
import Language.Drasil.Label (mkLabelRA, mkLabelRA')
import Language.Drasil.Label (mkLabelRA, mkLabelRA', mkLabelRA'')
import Language.Drasil.Chunk.Citation (
-- Types
Citation, BibRef, CiteField, Month(..), HP, CitationKind(..)
Expand Down
17 changes: 11 additions & 6 deletions code/drasil-lang/Language/Drasil/Chunk/DataDefinition.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,23 @@ import Language.Drasil.Chunk.Quantity (Quantity(getUnit), HasSpace(typ), Quantit
mkQuant, qw)
import Language.Drasil.Classes (HasUID(uid), NamedIdea(term), Idea(getA),
HasSymbol(symbol), IsUnit, ExprRelat(relat), HasDerivation(derivations),
HasReference(getReferences), ConceptDomain, HasAdditionalNotes(getNotes))
HasReference(getReferences), ConceptDomain, HasAdditionalNotes(getNotes),
HasLabel(getLabel))
import Language.Drasil.Chunk.SymbolForm (eqSymb)
import Language.Drasil.Chunk.ShortName (ShortName, HasShortName(shortname), shortname')

import Control.Lens(makeLenses, (^.), view)

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

import Language.Drasil.Label (mkLabelRA')

-- 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
, _lbl :: ShortName {-FIXME: Upgrade to Label-}
, _lbl :: Label
, _notes :: Maybe [Sentence]
}
makeLenses ''DataDefinition
Expand All @@ -41,16 +44,18 @@ instance HasReference DataDefinition where getReferences = ref
instance Eq DataDefinition where a == b = (a ^. uid) == (b ^. uid)
instance HasDerivation DataDefinition where derivations = deri
instance HasAdditionalNotes DataDefinition where getNotes = notes
instance HasShortName DataDefinition where shortname = view lbl
instance HasLabel DataDefinition where getLabel = qd . getLabel --FIXME: will eventually just be viewed from here
instance HasShortName DataDefinition where shortname = lbl . shortname


-- Used to help make Qdefinitions when uid, term, and symbol come from the same source
mkDataDef :: (Quantity c) => c -> Expr -> QDefinition
mkDataDef cncpt equation = datadef $ getUnit cncpt --should references be passed in at this point?
where datadef (Just a) = fromEqn (cncpt ^. uid) (cncpt ^. term) EmptyS
(eqSymb cncpt) a equation [] (cncpt ^. uid) --shortname
(eqSymb cncpt) a equation [] (mkLabelRA' ((cncpt ^. uid) ++ "Label") (cncpt ^. uid))
datadef Nothing = fromEqn' (cncpt ^. uid) (cncpt ^. term) EmptyS
(eqSymb cncpt) equation [] (cncpt ^. uid) --shortname
(eqSymb cncpt) equation [] (mkLabelRA' ((cncpt ^. uid) ++ "Label") (cncpt ^. uid))

-- | 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 b c (mkLabelRA' ((a ^. uid) ++ "Label") (a ^. uid)) e -- FIXME: should the Label be passed in or derived?
2 changes: 1 addition & 1 deletion code/drasil-lang/Language/Drasil/Chunk/Eq.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ data QDefinition = EC
, _equat :: Expr
, _ref :: References -- FIXME: to be removed
, _deri :: Derivation -- FIXME: to be removed
, _refName :: ShortName -- FIXME: to be removed
, _lb :: Label -- FIXME: to be removed
, _notes :: Maybe [Sentence] -- FIXME: to be removed
}
makeLenses ''QDefinition
Expand Down
7 changes: 6 additions & 1 deletion code/drasil-lang/Language/Drasil/Label.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Language.Drasil.Label (Label, mkLabelRA, mkLabelRA') where
module Language.Drasil.Label (Label, mkLabelRA, mkLabelRA', mkLabelRA'') where

import Language.Drasil.Label.Core
import Language.Drasil.Classes (HasUID(uid), HasRefAddress(getRefAdd))
Expand All @@ -19,6 +19,11 @@ mkLabelRA i ref shortn = Lbl i (RefAdd $ ensureASCII ref) (shortname' shortn)
mkLabelRA' :: String -> String -> Label
mkLabelRA' i refAndshortn = Lbl i (RefAdd $ ensureASCII refAndshortn) (shortname' refAndshortn)

-- for when reference address and the display should be the same
mkLabelRA'' :: String -> Label
mkLabelRA'' iAndRefAndshortn = Lbl (iAndRefAndshortn ++ "Label")
(RefAdd $ ensureASCII iAndRefAndshortn) (shortname' iAndRefAndshortn)

mkLabelML :: String -> String -> String -> Label
mkLabelML i ref shortn = Lbl i (MetaLink $ ensureASCII ref) (shortname' shortn)

Expand Down
2 changes: 1 addition & 1 deletion code/drasil-lang/drasil-lang.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: drasil-lang
Version: 0.1.3
Version: 0.1.8
Cabal-Version: >= 1.18
Author: Dan Szymczak, Steven Palmer, Jacques Carette, Spencer Smith
build-type: Simple
Expand Down

4 comments on commit 7bb8954

@niazim3

This comment was marked as resolved.

@JacquesCarette
Copy link
Owner

Choose a reason for hiding this comment

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

You should bump up the version number only by +0.0.1 in most circumstances.

You should bump it up whenever you make a change to interfaces, such as any change to Language.Drasil.hs, or a change to the signature of any function that is exported there.

You then also need to bump up the dependencies of the other packages, so that they will pick up the new version.

@niazim3

This comment was marked as resolved.

@JacquesCarette

This comment was marked as resolved.

Please sign in to comment.