Skip to content

Commit

Permalink
Sorting in GlassBR (#899)
Browse files Browse the repository at this point in the history
* Sorted Table of Aux Constants in Glass and SWHS as per #886

* Moved compareBySymbol to docLang to be reused; sorted Input Data Constraints - closes #864

* Moved sortBy in GlassBR to sortBySymbol in Misc to be used in docLang for all examples
  • Loading branch information
samm82 authored and JacquesCarette committed Jul 23, 2018
1 parent f08608d commit df9f936
Show file tree
Hide file tree
Showing 24 changed files with 417 additions and 403 deletions.
2 changes: 1 addition & 1 deletion code/drasil-code/drasil-code.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ library
split >= 0.2.3.1,
MissingH >= 1.4.0.1,
parsec >= 3.1.9,
drasil-lang >= 0.1.5
drasil-lang >= 0.1.6
default-language: Haskell2010
ghc-options: -Wall -O2

Expand Down
2 changes: 1 addition & 1 deletion code/drasil-data/drasil-data.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ library
MissingH >= 1.4.0.1,
parsec >= 3.1.9,
data-fix (>= 0.0.4 && <= 1.0),
drasil-lang >= 0.1.5
drasil-lang >= 0.1.6
default-language: Haskell2010
ghc-options: -Wall

Expand Down
20 changes: 10 additions & 10 deletions code/drasil-docLang/Drasil/DocLang.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ module Drasil.DocLang (
SCSSub(..), SSDSec(..), SSDSub(..), SolChSpec(..), ExistingSolnSec(..),
StkhldrSec(StkhldrProg2),
StkhldrSub(Client, Cstmr), TConvention(..), TraceabilitySec(TraceabilityProg),
TSIntro(..), UCsSec(..), mkDoc, mkLklyChnk, mkRequirement, mkUnLklyChnk,
tsymb, tsymb'',
TSIntro(..), UCsSec(..), mkDoc, mkLklyChnk, mkRequirement,
mkUnLklyChnk, tsymb, tsymb'',
-- DocumentLanguage.Definitions
Field(..), Fields, InclUnits(IncludeUnits), Verbosity(Verbose),
-- DocumentLanguage.RefHelpers
Expand Down Expand Up @@ -40,14 +40,14 @@ module Drasil.DocLang (
) where

import Drasil.DocumentLanguage (AppndxSec(..), AuxConstntSec(..),
DerivationDisplay(..), DocDesc, DocSection(..), Emphasis(..), GSDSec(GSDProg2),
GSDSub(UsrChars, SystCons, SysCntxt), IntroSec(..), IntroSub(..), LCsSec(..), LFunc(..),
Literature(Doc', Lit, Manual), ProblemDescription(..), RefSec(..), RefTab(..),
ReqrmntSec(..), ReqsSub(FReqsSub, NonFReqsSub), ScpOfProjSec(ScpOfProjProg),
SCSSub(..), SSDSec(..), SSDSub(..), SolChSpec(..), StkhldrSec(StkhldrProg2),
StkhldrSub(Client, Cstmr), TConvention(..), TraceabilitySec(TraceabilityProg),
TSIntro(..), UCsSec(..), mkDoc, mkLklyChnk, mkRequirement, mkUnLklyChnk,
tsymb, tsymb'', ExistingSolnSec(..))
DerivationDisplay(..), DocDesc, DocSection(..), Emphasis(..), ExistingSolnSec(..),
GSDSec(GSDProg2), GSDSub(UsrChars, SystCons, SysCntxt), IntroSec(..), IntroSub(..),
LCsSec(..), LFunc(..), Literature(Doc', Lit, Manual), ProblemDescription(..),
RefSec(..), RefTab(..), ReqrmntSec(..), ReqsSub(FReqsSub, NonFReqsSub),
ScpOfProjSec(ScpOfProjProg), SCSSub(..), SSDSec(..), SSDSub(..), SolChSpec(..),
StkhldrSec(StkhldrProg2), StkhldrSub(Client, Cstmr), TConvention(..),
TraceabilitySec(TraceabilityProg), TSIntro(..), UCsSec(..), mkDoc,
mkLklyChnk, mkRequirement, mkUnLklyChnk, tsymb, tsymb'')
import Drasil.DocumentLanguage.Definitions (Field(..), Fields,
InclUnits(IncludeUnits), Verbosity(Verbose))
import Drasil.DocumentLanguage.RefHelpers (ModelDB, cite, ddRefDB, mdb, refA,
Expand Down
5 changes: 3 additions & 2 deletions code/drasil-docLang/Drasil/DocumentLanguage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import Data.Drasil.Concepts.Documentation (refmat)

import Data.Function (on)
import Data.List (nub, sortBy)
import Data.Ord (comparing)

type System = Sentence
type DocKind = Sentence
Expand Down Expand Up @@ -254,7 +255,7 @@ mkSections si l = map doit l
doit (IntroSec is) = mkIntroSec si is
doit (StkhldrSec sts) = mkStkhldrSec sts
doit (SSDSec ss) = mkSSDSec si ss
doit (AuxConstntSec acs) = mkAuxConsSec acs
doit (AuxConstntSec acs) = mkAuxConsSec acs
doit Bibliography = mkBib (citeDB si)
doit (GSDSec gs') = mkGSDSec gs'
doit (ScpOfProjSec sop) = mkScpOfProjSec sop
Expand Down Expand Up @@ -533,7 +534,7 @@ mkExistingSolnSec (ExistSolnProg cs) = SRS.offShelfSol cs []
-- | Helper for making the 'Values of Auxiliary Constants' section
mkAuxConsSec :: AuxConstntSec -> Section
mkAuxConsSec (AuxConsVerb s) = s
mkAuxConsSec (AuxConsProg key listOfCons) = AC.valsOfAuxConstantsF key listOfCons
mkAuxConsSec (AuxConsProg key listOfCons) = AC.valsOfAuxConstantsF key $ sortBySymbol listOfCons

{--}

Expand Down
4 changes: 2 additions & 2 deletions code/drasil-docLang/Drasil/Sections/SolutionCharacterSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import Data.Drasil.SentenceStructures (ofThe, foldlSP, foldlSent, foldlList, sAn
import qualified Data.Drasil.Concepts.Documentation as Doc
import Data.List (find)
import Control.Lens ((^.))
import Drasil.Sections.SpecificSystemDescription (inDataConstTbl, outDataConstTbl,
listofTablesToRefs)

import Drasil.Sections.GeneralSystDesc(genSysIntro)
import Drasil.Sections.SpecificSystemDescription (inDataConstTbl, outDataConstTbl,
listofTablesToRefs)

import qualified Drasil.DocLang.SRS as SRS

Expand Down
12 changes: 7 additions & 5 deletions code/drasil-docLang/Drasil/Sections/SpecificSystemDescription.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import Data.Drasil.Concepts.Software (program)
import Data.Drasil.Utils (foldle, fmtU, getRVal)
import Data.Drasil.SentenceStructures (fmtPhys, fmtSfwr, mkTableFromColumns, foldlSent,
foldlSP, typUncr, ofThe, foldlList)
import Data.List (sortBy)

import qualified Drasil.DocLang.SRS as SRS


Expand Down Expand Up @@ -208,11 +210,11 @@ dataConstraintUncertainty = foldlSent [S "The", phrase uncertainty, phrase colum
inDataConstTbl :: (UncertainQuantity c, Constrained c, HasReasVal c) => [c] -> Contents
inDataConstTbl qlst = Table titl cts (S "Input Data Constraints") True "InDataConstraints"
where
columns = [(S "Var", map ch qlst),
(titleize' physicalConstraint, map fmtPhys qlst),
(titleize' softwareConstraint, map fmtSfwr qlst),
(S "Typical Value", map (\q -> fmtU (E $ getRVal q) q) qlst),
(short typUnc, map typUncr qlst)]
columns = [(S "Var", map ch $ sortBySymbol qlst),
(titleize' physicalConstraint, map fmtPhys $ sortBySymbol qlst),
(titleize' softwareConstraint, map fmtSfwr $ sortBySymbol qlst),
(S "Typical Value", map (\q -> fmtU (E $ getRVal q) q) $ sortBySymbol qlst),
(short typUnc, map typUncr $ sortBySymbol qlst)]
tbl = mkTableFromColumns columns
titl = fst tbl
cts = snd tbl
Expand Down
2 changes: 1 addition & 1 deletion code/drasil-docLang/drasil-docLang.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ library
MissingH >= 1.4.0.1,
parsec >= 3.1.9,
data-fix (>= 0.0.4 && <= 1.0),
drasil-lang >= 0.1.5,
drasil-lang >= 0.1.6,
drasil-data >= 0.1.1
default-language: Haskell2010
ghc-options: -Wall
Expand Down
4 changes: 2 additions & 2 deletions code/drasil-example/Drasil/GlassBR/Body.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import Drasil.DocLang (AppndxSec(..), AuxConstntSec(..), DerivationDisplay(..),
ReqsSub(FReqsSub, NonFReqsSub), ScpOfProjSec(ScpOfProjProg), SCSSub(..),
SSDSec(..), SSDSub(..), SolChSpec(..), StkhldrSec(StkhldrProg2),
StkhldrSub(Client, Cstmr), TraceabilitySec(TraceabilityProg),
TSIntro(SymbOrder, TSPurpose), UCsSec(..), Verbosity(Verbose), cite,
dataConstraintUncertainty, goalStmtF, inDataConstTbl, intro, mkDoc,
TSIntro(SymbOrder, TSPurpose), UCsSec(..), Verbosity(Verbose),
cite, dataConstraintUncertainty, goalStmtF, inDataConstTbl, intro, mkDoc,
mkRequirement, outDataConstTbl, physSystDesc, probDescF, termDefnF,
traceGIntro, tsymb)

Expand Down
12 changes: 6 additions & 6 deletions code/drasil-example/drasil-example.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ executable tiny
mtl >= 2.2.1,
directory >= 1.2.6.2,
split >= 0.2.3.1,
drasil-lang >= 0.1.5,
drasil-lang >= 0.1.6,
drasil-data >= 0.1.1,
drasil-code >= 0.1.1,
drasil-printers >= 0.1.0,
Expand Down Expand Up @@ -58,7 +58,7 @@ executable nopcm
mtl >= 2.2.1,
directory >= 1.2.6.2,
split >= 0.2.3.1,
drasil-lang >= 0.1.5,
drasil-lang >= 0.1.6,
drasil-data >= 0.1.1,
drasil-code >= 0.1.1,
drasil-printers >= 0.1.0,
Expand Down Expand Up @@ -93,7 +93,7 @@ executable ssp
mtl >= 2.2.1,
directory >= 1.2.6.2,
split >= 0.2.3.1,
drasil-lang >= 0.1.5,
drasil-lang >= 0.1.6,
drasil-data >= 0.1.1,
drasil-code >= 0.1.1,
drasil-printers >= 0.1.0,
Expand Down Expand Up @@ -126,7 +126,7 @@ executable glassbr
mtl >= 2.2.1,
directory >= 1.2.6.2,
split >= 0.2.3.1,
drasil-lang >= 0.1.5,
drasil-lang >= 0.1.6,
drasil-data >= 0.1.1,
drasil-code >= 0.1.1,
drasil-printers >= 0.1.0,
Expand Down Expand Up @@ -155,7 +155,7 @@ executable chipmunkdocs
mtl >= 2.2.1,
directory >= 1.2.6.2,
split >= 0.2.3.1,
drasil-lang >= 0.1.5,
drasil-lang >= 0.1.6,
drasil-data >= 0.1.1,
drasil-code >= 0.1.1,
drasil-printers >= 0.1.0,
Expand Down Expand Up @@ -188,7 +188,7 @@ executable swhs
pretty >= 1.1.1.1,
mtl >= 2.2.1,
directory >= 1.2.6.2,
drasil-lang >= 0.1.5,
drasil-lang >= 0.1.6,
drasil-data >= 0.1.1,
drasil-code >= 0.1.1,
drasil-printers >= 0.1.0,
Expand Down
2 changes: 1 addition & 1 deletion code/drasil-gen/drasil-gen.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ library
split >= 0.2.3.1,
MissingH >= 1.4.0.1,
parsec >= 3.1.9,
drasil-lang >= 0.1.5,
drasil-lang >= 0.1.6,
drasil-code >= 0.1.3,
drasil-printers >= 0.1.0
default-language: Haskell2010
Expand Down
2 changes: 1 addition & 1 deletion code/drasil-lang/Language/Drasil.hs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ module Language.Drasil (
-- Misc
, mkTable, unit_symb, introduceAbb, phrase, plural, phrase's
, plural's, at_start, at_start'
, unitToSentence, unitToSentenceUnitless
, unitToSentence, unitToSentenceUnitless, sortBySymbol
-- Generate
--, gen, genCode
-- People
Expand Down
13 changes: 12 additions & 1 deletion code/drasil-lang/Language/Drasil/Misc.hs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
module Language.Drasil.Misc where

import Language.Drasil.Classes (HasUnitSymbol(usymb), NamedIdea(term), Idea)
import Language.Drasil.Classes (HasSymbol(symbol), HasUnitSymbol(usymb),
NamedIdea(term), Idea)
import Language.Drasil.Chunk.NamedIdea (short)
import Language.Drasil.Chunk.Quantity (Quantity, getUnit)
import Language.Drasil.Chunk.Unitary (Unitary, unit)
import Language.Drasil.Spec ((+:+), Sentence((:+:), S, Sy), sParen)
import Language.Drasil.Symbol (Stage(Implementation), compsy)
import Language.Drasil.Development.UnitLang (USymb)

import Data.List (sortBy)

import qualified Language.Drasil.NounPhrase as NP

import Control.Lens ((^.))
Expand Down Expand Up @@ -85,6 +89,13 @@ noSpaces s
| not (' ' `elem` s) = s
| otherwise = error "String has at least one space in it."

-- Sorts a list of HasSymbols by Symbol
sortBySymbol :: (HasSymbol a) => [a] -> [a]
sortBySymbol = sortBy compareBySymbol
where
compareBySymbol :: (HasSymbol a) => a -> a -> Ordering
compareBySymbol a b = compsy (symbol a Implementation) (symbol b Implementation)

{-
--------------------- WIP ---------------------
Function used to derive the unit of an equation. Takes a Relation, sorts the
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.5
Version: 0.1.6
Cabal-Version: >= 1.18
Author: Dan Szymczak, Steven Palmer, Jacques Carette, Spencer Smith
build-type: Simple
Expand Down
2 changes: 1 addition & 1 deletion code/drasil-printers/drasil-printers.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ library
MissingH >= 1.4.0.1,
parsec >= 3.1.9,
data-fix (>= 0.0.4 && <= 1.0),
drasil-lang >= 0.1.4
drasil-lang >= 0.1.6
default-language: Haskell2010
ghc-options: -Wall

Expand Down
20 changes: 10 additions & 10 deletions code/stable/gamephys/SRS/Chipmunk_SRS.tex
Original file line number Diff line number Diff line change
Expand Up @@ -848,27 +848,27 @@ \subsubsection{Data Constraints}
Var & Physical Constraints & Typical Value & Uncert.
\\
\midrule
$L$ & $L\geq{}0$ & $44.2$ m & 10.0\%
\\
$m$ & $m\geq{}0$ & $56.2$ kg & 10.0\%
${C_{R}}$ & $0\leq{}{C_{R}}\leq{}1$ & $0.8$ & 10.0\%
\\
$\mathbf{I}$ & $\mathbf{I}\geq{}0$ & $74.5$ kg$\text{m}^{2}$ & 10.0\%
$\mathbf{F}$ & -- & $98.1$ N & 10.0\%
\\
$G$ & -- & $9.8$ $\frac{\text{m}^{3}}{(\text{kg}\text{s}^{2})}$ & 10.0\%
\\
$\mathbf{p}$ & -- & $0.412$ m & 10.0\%
$\mathbf{I}$ & $\mathbf{I}\geq{}0$ & $74.5$ kg$\text{m}^{2}$ & 10.0\%
\\
$ϕ$ & -- & $\frac{π}{2}$ rad & 10.0\%
$L$ & $L\geq{}0$ & $44.2$ m & 10.0\%
\\
$\mathbf{v}$ & -- & $2.51$ $\frac{\text{m}}{\text{s}}$ & 10.0\%
$m$ & $m\geq{}0$ & $56.2$ kg & 10.0\%
\\
$ω$ & -- & $2.1$ $\frac{\text{rad}}{\text{s}}$ & 10.0\%
$\mathbf{p}$ & -- & $0.412$ m & 10.0\%
\\
$\mathbf{F}$ & -- & $98.1$ N & 10.0\%
$\mathbf{v}$ & -- & $2.51$ $\frac{\text{m}}{\text{s}}$ & 10.0\%
\\
$τ$ & -- & $200.0$ Nm & 10.0\%
\\
${C_{R}}$ & $0\leq{}{C_{R}}\leq{}1$ & $0.8$ & 10.0\%
$ω$ & -- & $2.1$ $\frac{\text{rad}}{\text{s}}$ & 10.0\%
\\
$ϕ$ & -- & $\frac{π}{2}$ rad & 10.0\%
\\
\bottomrule
\caption{Input Data Constraints}
Expand Down
Loading

0 comments on commit df9f936

Please sign in to comment.