diff --git a/.gitattributes b/.gitattributes index 70644e3e4a..cae8bd96be 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,6 +6,7 @@ People/** linguist-documentation Presentations/** linguist-documentation WindowsFix/** linguist-vendored code/stable/** linguist-generated +code/stable-website/** linguist-generated code/datafiles/** linguist-vendored doc/** linguist-documentation notes/** linguist-documentation diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 2b78499bfd..9ebead8523 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -6,7 +6,7 @@ # Examples -code/drasil-example/dblpendulum/ @JacquesCarette @cd155 +code/drasil-example/dblpend/ @JacquesCarette @cd155 code/drasil-example/glassbr/ @JacquesCarette @samm82 code/drasil-example/projectile/ @JacquesCarette @samm82 @bmaclach code/drasil-example/template/ @JacquesCarette @samm82 @@ -16,7 +16,7 @@ code/drasil-example/template/ @JacquesCarette @samm82 # Note that @JacquesCarette and @smiths have to be added to each rule because of how CODEOWNERS files work code/stable/ @JacquesCarette @smiths -code/stable/dblpendulum/ @JacquesCarette @smiths @cd155 +code/stable/dblpend/ @JacquesCarette @smiths @cd155 code/stable/glassbr/ @JacquesCarette @smiths @samm82 code/stable/gooltest/ @JacquesCarette @smiths @bmaclach code/stable/projectile/ @JacquesCarette @smiths @samm82 @bmaclach diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml index d40daa320b..98b6cadfba 100644 --- a/.github/workflows/Build.yaml +++ b/.github/workflows/Build.yaml @@ -27,4 +27,75 @@ jobs: name: "Build & Deploy" runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - name: "Update apt package list" + run: | + sudo apt-get update + - name: "Install system requirements" + run: sudo apt-get install -y --fix-missing libgmp-dev python3 graphviz doxygen fonts-lmodern texlive-bibtex-extra texlive-latex-extra texlive-science texlive-xetex texlive-luatex g++ default-jdk mono-devel inkscape + - name: "Install Stack" + uses: haskell/actions/setup@v2 + with: + enable-stack: true + stack-no-global: true + stack-version: 'latest' + - name: "Cache dependencies" + uses: actions/cache@v3.3.2 + with: + path: | + ~/.stack + ~/.cabal/packages + ~/.cabal/store + code/.stack-work/ + code/website/.stack-work/ + ~/.local/bin/graphmod + key: ${{ runner.os }}-store-${{ hashFiles('code/stack.yaml') }} + - name: "Clean previous run" + run: make clean + - name: "Update PATH" + run: | + echo "$HOME/.local/bin" >> $GITHUB_PATH + echo "$HOME/.swift/usr/bin" >> $GITHUB_PATH + - name: "Install dependencies" + run: make stackArgs="--no-terminal" deps + - name: "Build" + run: make code stackArgs="--no-terminal" GHCFLAGS="-Werror" + - name: "Test built artifacts against stable" + run: make stackArgs="--no-terminal" GHCFLAGS="-Werror" NOISY=yes + - name: "Compile GOOL examples" + run: make codegenTest + - name: "Compile generated TeX artifacts" + run: make tex SUMMARIZE_TEX=yes + - name: "Compile generated software artifacts" + run: make gool + - name: "Create Doxygen for generated software artifacts" + run: make doxygen + - name: "Generate Haddock docs (as test)" + run: make docs + if: ${{ !fromJSON(env.is_deployment) }} + - name: "Generate Haddock docs (full + std)" + run: FULL=1 make docs + if: ${{ fromJSON(env.is_deployment) }} + - name: "Generate module dependency graphs" + run: make graphs + - name: "Analyze Drasil code" + run: make analysis + - name: "Convert analysis graphs into dot and circo SVGs" # only needed in deployments, not required for tests + run: make convertAnalyzed + if: ${{ fromJSON(env.is_deployment) }} + - name: "Build website generator" + run: make website + - name: "Test Built Website against Stable Version" + run: make test_website NOISY=yes + - name: "Prepare full website deployment environment" + run: make deploy_lite + - name: "Deploy 🚀" + if: ${{ fromJSON(env.is_deployment) }} + uses: JamesIves/github-pages-deploy-action@v4.4.3 + with: + git-config-name: ${{ secrets.BOT_NAME }} + git-config-email: ${{ secrets.BOT_EMAIL }} + token: ${{ secrets.BOT_TOKEN }} + branch: gh-pages + folder: code/deploy + commit-message: "${{ secrets.BOT_NAME }} deploy of master@${{ github.sha }}" diff --git a/.github/workflows/Lint.yaml b/.github/workflows/Lint.yaml index e0ec8d02ef..8bd9f4e60c 100644 --- a/.github/workflows/Lint.yaml +++ b/.github/workflows/Lint.yaml @@ -1,7 +1,7 @@ on: pull_request: branches: master - paths: 'code/drasil-*' + paths: 'code/drasil-**' name: Linter concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -15,6 +15,6 @@ jobs: name: "HLint" runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "HLint" run: make hot_hlint diff --git a/.gitignore b/.gitignore index 4aad51d00e..8d26f98eb1 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ dist .drasil-min-stack-ver stack.yaml.lock .hlint* +.envrc # Drasil supported programming languages __pycache__ diff --git a/People/Harmanpreet/HarmanpreetSingh_Sagar_2023_Poster.pdf b/People/Harmanpreet/HarmanpreetSingh_Sagar_2023_Poster.pdf new file mode 100644 index 0000000000..fdfc2d46c7 Binary files /dev/null and b/People/Harmanpreet/HarmanpreetSingh_Sagar_2023_Poster.pdf differ diff --git a/People/Harmanpreet/HarmanpreetSingh_Sagar_2023_Poster.pptx b/People/Harmanpreet/HarmanpreetSingh_Sagar_2023_Poster.pptx new file mode 100644 index 0000000000..f5ad15e244 Binary files /dev/null and b/People/Harmanpreet/HarmanpreetSingh_Sagar_2023_Poster.pptx differ diff --git a/README.md b/README.md index 9873da5bbe..4e5a6a75ac 100644 --- a/README.md +++ b/README.md @@ -70,11 +70,11 @@ swhs_diff | Solar Water Heating System with Phase Change Material glassbr_diff | Glass-BR hghc_diff | HGHC Toy Example ssp_diff | Slope Stability Analysis -nopcm_diff | Minimal SWHS Example, with PCM Removed +swhsnopcm_diff | Minimal SWHS Example, with PCM Removed projectile_diff | Projectile Motion Analysis pdcontroller_diff | Proportional Derivative Controller -dblpendulum_diff | Double Pendulum -sglpendulum_diff | Single Pendulum +dblpend_diff | Double Pendulum +sglpend_diff | Single Pendulum For more commands related to Drasil, use `make help` or check out the [Makefile documentation](https://github.com/JacquesCarette/Drasil/wiki/Makefile). @@ -92,11 +92,11 @@ swhs | Solar Water Heating System with PCM (SWHS) glassbr | Glass-BR hghc | HGHC toy example ssp | Slope Stability Analysis (SSP) -nopcm | SWHS without PCM (NoPCM) +swhsnopcm | SWHS without PCM (SWHSNoPCM) projectile | Projectile motion analysis pdcontroller | Proportional Derivative Controller -dblpendulum | Double Pendulum -sglpendulum | Single Pendulum +dblpend | Double Pendulum +sglpend | Single Pendulum This runs the examples manually from the .stack-work folder after building, and the generated docs will appear in this folder (i.e. in the SRS folders). Due to this placement, these generated diff --git a/code/Makefile b/code/Makefile index 53333934e8..fdcbe15276 100644 --- a/code/Makefile +++ b/code/Makefile @@ -27,44 +27,44 @@ PACKAGE_GEN_TARGET = BUILD DOC GRAPH #--------------------------------------------# # Current list of examples -SRC_EXAMPLES = glassbr nopcm projectile pdcontroller dblpendulum -EXAMPLES = $(SRC_EXAMPLES) hghc swhs ssp gamephysics template sglpendulum +SRC_EXAMPLES = glassbr swhsnopcm projectile pdcontroller dblpend +EXAMPLES = $(SRC_EXAMPLES) hghc swhs ssp gamephysics template sglpend GOOLTEST = codegenTest # where they live HGHC_DIR = hghc GLASSBR_DIR = glassbr -NOPCM_DIR = nopcm +SWHSNOPCM_DIR = swhsnopcm SWHS_DIR = swhs SSP_DIR = ssp GAMEPHYSICS_DIR = gamephysics PROJECTILE_DIR = projectile TEMPLATE_DIR = template GOOLTEST_DIR = gooltest -DBLPENDULUM_DIR = dblpendulum -SGLPENDULUM_DIR = sglpendulum +DBLPEND_DIR = dblpend +SGLPEND_DIR = sglpend PDCONTROLLER_DIR = pdcontroller # Directories for examples with multiple src versions MULTI_SRC_DIRS = $(PROJECTILE_DIR) # All example directories -EXAMPLE_DIRS = $(MULTI_SRC_DIRS) $(HGHC_DIR) $(GLASSBR_DIR) $(NOPCM_DIR) \ - $(SWHS_DIR) $(SSP_DIR) $(GAMEPHYSICS_DIR) $(DBLPENDULUM_DIR) $(SGLPENDULUM_DIR)\ +EXAMPLE_DIRS = $(MULTI_SRC_DIRS) $(HGHC_DIR) $(GLASSBR_DIR) $(SWHSNOPCM_DIR) \ + $(SWHS_DIR) $(SSP_DIR) $(GAMEPHYSICS_DIR) $(DBLPEND_DIR) $(SGLPEND_DIR)\ $(PDCONTROLLER_DIR) # and the name of their executables HGHC_EXE = hghc GLASSBR_EXE = glassbr -NOPCM_EXE = nopcm +SWHSNOPCM_EXE = swhsnopcm SWHS_EXE = swhs SSP_EXE = ssp GAMEPHYSICS_EXE = gamephysics PROJECTILE_EXE = projectile TEMPLATE_EXE = template GOOLTEST_EXE = codegenTest -DBLPENDULUM_EXE = dblpendulum -SGLPENDULUM_EXE = sglpendulum +DBLPEND_EXE = dblpend +SGLPEND_EXE = sglpend PDCONTROLLER_EXE = pdcontroller # and the associated per-example information generated @@ -89,6 +89,11 @@ BC_EXAMPLES = $(addsuffix $(BC_E_SUFFIX), $(EXAMPLES)) TRACE_GRAPH_EXAMPLES = $(addsuffix $(TRACE_GRAPH_SUFFIX), $(EXAMPLES)) INSTALL_EXAMPLES = $(addsuffix $(INSTALL_E_SUFFIX), $(EXAMPLES)) +# Website names with appropriate suffixes. +TEST_WEBSITE = $(addsuffix $(TEST_E_SUFFIX), $(WEBSITE_FOLDER_NAME)) +STABILIZE_WEBSITE = $(addsuffix $(STABILIZE_E_SUFFIX), $(WEBSITE_FOLDER_NAME)) +BC_WEBSITE = $(addsuffix $(BC_E_SUFFIX), $(WEBSITE_FOLDER_NAME)) + EXAMPLE_GEN_TARGET = GEN TEST TEX CODE DCP # Folders generated by Drasil. @@ -112,6 +117,8 @@ BUILD_FOLDER_NAME = build BUILD_FOLDER = $(BUILD_FOLDER_NAME)/ STABLE_FOLDER_NAME = stable STABLE_FOLDER = $(STABLE_FOLDER_NAME)/ +STABLE_WEBSITE_FOLDER_NAME = stable-website +STABLE_WEBSITE_FOLDER = $(STABLE_WEBSITE_FOLDER_NAME)/ EXAMPLE_CODE_SUBFOLDER = src/ LOG_FOLDER_NAME = logs LOG_FOLDER = $(LOG_FOLDER_NAME)/ @@ -146,8 +153,8 @@ WEBSITE_FOLDER = $(WEBSITE_FOLDER_NAME)/HTML/ FULL ?= 0 # GHC debug options -PROFALL = --executable-profiling --library-profiling -PROFEXEC = +RTS -xc -P +PROFALL = --profile +PROFEXEC = --profile --rts-options '-xc -P' # GHC build options GHCTHREADS ?= 2 @@ -155,9 +162,13 @@ GHCTHREADS ?= 2 override GHCFLAGS += -Wall -j$(GHCTHREADS) override stackArgs += --ghc-options="$(GHCFLAGS)" +# When running 'stack exec', the following stack arguments should be passed. +STACK_EXEC_ARGS := --no-nix-pure +STACK_EXEC := stack exec $(STACK_EXEC_ARGS) + # Output amount control -NOISY=no -SUMMARIZE_TEX=no +NOISY ?= no +SUMMARIZE_TEX ?= no # Some commands now prefer to have TERM defined when things go awry # and since this is going to be run in batch, 'dumb' is best default. @@ -176,7 +187,7 @@ install: ##@Examples Install all example project binaries into your local binary stack install $(stackArgs) debug: stackArgs += $(PROFALL) -debug: EXECARGS += $(PROFEXEC) +debug: STACK_EXEC += $(PROFEXEC) debug: test ##@Examples Run test target with better debugging tools. pr_ready: all hot_hlint ##@General Check if your current work is ready to for a PR via `all` and `hot_hlint`. @@ -226,6 +237,14 @@ test: $(TEST_EXAMPLES) ##@Examples Run all examples and compare against the stab @echo ---------------------------- @LOG_FOLDER="$(LOG_FOLDER)" LOG_SUFFIX="$(LOG_SUFFIX)" NOISY=$(NOISY) "$(SHELL)" "$(SCRIPT_FOLDER)log_check.sh" +# First builds the website and then tests the generated contenst with those in +# the stable-website folder. +test_website: $(TEST_WEBSITE) + @echo --------------------------------------- + @echo Testing Website complete, checking logs + @echo --------------------------------------- + @LOG_FOLDER="$(LOG_FOLDER)" LOG_SUFFIX="$(LOG_SUFFIX)" NOISY=$(NOISY) "$(SHELL)" "$(SCRIPT_FOLDER)log_check.sh" + # First build all the Drasil packages, run all examples (no traceability graphs), # and then overwrite contents in the stable folder with currently generated ones. stabilize: $(STABILIZE_EXAMPLES) ##@Examples Overwrites the stable folder with up-to-date artifacts. @@ -233,6 +252,13 @@ stabilize: $(STABILIZE_EXAMPLES) ##@Examples Overwrites the stable folder with u @echo Stabilized all examples @echo ---------------------------- +# First build the website, and then overwrite the contents in the stable-website +# folder with currently generated ones. +website_stabilize: $(STABILIZE_WEBSITE) + @echo ---------------------------- + @echo Stabilized website artifacts + @echo ---------------------------- + # First builds all Drasil packages, runs examples with dot graphs, # then make pdfs from the generated TeX files. tex: $(TEX_EXAMPLES) ##@Examples Generate all example pdfs. Needs Graphviz to work. @@ -243,7 +269,7 @@ packagedeps: graphmod check_dot @echo ---------------------------- @echo Generating package dependency graph @echo ---------------------------- - @stack dot --prune dblpendulum,gamephysics,glassbr,hghc,nopcm,pdcontroller,projectile,sglpendulum,ssp,swhs,template,drasil-website | tred | dot -Tpng > "$(GRAPH_FOLDER)drasil-all-pkgs-deps".png + @stack dot --prune dblpend,gamephysics,glassbr,hghc,swhsnopcm,pdcontroller,projectile,sglpend,ssp,swhs,template,drasil-website | tred | dot -Tpng > "$(GRAPH_FOLDER)drasil-all-pkgs-deps".png #--------------------------------------------------------------# #--- Targets that are used for individual packages/examples ---# @@ -267,13 +293,13 @@ $(filter %$(BUILD_P_SUFFIX), $(BUILD_PACKAGES)): %$(BUILD_P_SUFFIX): check_stack $(filter %$(GEN_E_SUFFIX), $(GEN_EXAMPLES)): %$(GEN_E_SUFFIX): stack build $(stackArgs) "$(EEXE)" @mkdir -p "$(BUILD_FOLDER)$(EDIR)" - cd "$(BUILD_FOLDER)$(EDIR)" && stack exec -- "$(EEXE)" $(EXECARGS) + cd "$(BUILD_FOLDER)$(EDIR)" && $(STACK_EXEC) -- "$(EEXE)" # Compiles GOOL examples to concrete code (Java, C++, etc.) $(GOOLTEST)$(GEN_E_SUFFIX): stack build $(stackArgs) "drasil-code:exe:$(GOOLTEST_EXE)" @mkdir -p "$(BUILD_FOLDER)$(GOOLTEST_DIR)" - cd "$(BUILD_FOLDER)$(GOOLTEST_DIR)" && stack exec -- "$(GOOLTEST_EXE)" $(EXECARGS) + cd "$(BUILD_FOLDER)$(GOOLTEST_DIR)" && $(STACK_EXEC) -- "$(GOOLTEST_EXE)" # Install individual Drasil examples $(filter %$(INSTALL_E_SUFFIX), $(INSTALL_EXAMPLES)): %$(INSTALL_E_SUFFIX): @@ -285,7 +311,7 @@ $(filter %$(INSTALL_E_SUFFIX), $(INSTALL_EXAMPLES)): %$(INSTALL_E_SUFFIX): $(filter %$(TRACE_GRAPH_SUFFIX), $(TRACE_GRAPH_EXAMPLES)): %$(TRACE_GRAPH_SUFFIX): graphmod stack build $(stackArgs) "$(EEXE)" @mkdir -p "$(BUILD_FOLDER)$(EDIR)" - cd "$(BUILD_FOLDER)$(EDIR)" && stack exec -- "$(EEXE)" $(EXECARGS) + cd "$(BUILD_FOLDER)$(EDIR)" && $(STACK_EXEC) -- "$(EEXE)" @mkdir -p "$(TRACEY_GRAPHS_FOLDER)$(EDIR)" @echo Making traceability graphs for "$(EEXE)" @if [ -d "$(BUILD_FOLDER)$(EDIR)/$(TRACEY_GRAPH_FOLDER)" ]; then \ @@ -303,11 +329,23 @@ $(filter %$(TEST_E_SUFFIX), $(TEST_EXAMPLES)): %$(TEST_E_SUFFIX): $(CLEAN_GF_PRE @mkdir -p "$(LOG_FOLDER)" - $(DIFF) "$(STABLE_FOLDER)$*/" "$(BUILD_FOLDER)$(EDIR)/" > "$(LOG_FOLDER)$(EDIR)$(LOG_SUFFIX)" +# Website diff tests. First builds the website and then compares the generated +# contents in the Website folder to those in the stable-website folder. +# Target will have the form Website_diff. +$(filter %$(TEST_E_SUFFIX), $(TEST_WEBSITE)): %$(TEST_E_SUFFIX): $(CLEAN_GF_PREFIX)$(LOG_FOLDER_NAME) website + @mkdir -p "$(LOG_FOLDER)" + - $(DIFF) "$(STABLE_WEBSITE_FOLDER)" "$(WEBSITE_FOLDER)" > "$(LOG_FOLDER)$(WEBSITE_FOLDER_NAME)$(LOG_SUFFIX)" + # Individual example build cleans. Removes a specific example from the build folder. # Targets will have the form exampleName_build_clean. $(filter %$(BC_E_SUFFIX), $(BC_EXAMPLES)): %$(BC_E_SUFFIX): - rm -rf "$(BUILD_FOLDER)$(EDIR)" +# The website build cleans. +# Target will have the form Website_build_clean +$(filter %$(BC_E_SUFFIX), $(BC_WEBSITE)): %$(BC_E_SUFFIX): + - rm -rf "$(WEBSITE_FOLDER)" + # Individual example stabilization. First builds all Drasil packages, # runs all examples, and then copies contents from the build folder into stable. # Targets will have the form exampleName_stabilize. @@ -315,6 +353,13 @@ $(filter %$(STABILIZE_E_SUFFIX), $(STABILIZE_EXAMPLES)): %$(STABILIZE_E_SUFFIX): - rm -rf "$(STABLE_FOLDER)$*/" - cp -r "$(BUILD_FOLDER)$(EDIR)" "$(STABLE_FOLDER)$*/" +# The website stabilization. First builds the website, and then copies the +# contents from the website folder into stable-website. +# Target will have the form Website_stabilize. +$(filter %$(STABILIZE_E_SUFFIX), $(STABILIZE_WEBSITE)): %$(STABILIZE_E_SUFFIX): %$(BC_E_SUFFIX) website + - rm -rf "$(STABLE_WEBSITE_FOLDER)" + - cp -r "$(WEBSITE_FOLDER)" "$(STABLE_WEBSITE_FOLDER)" + # Generate individual example pdfs. Needs Graphviz to work. # First builds all Drasil packages, runs examples with dot graphs, # then make pdfs from the generated TeX files. @@ -342,8 +387,8 @@ $(filter %$(GRAPH_P_SUFFIX), $(GRAPH_PACKAGES)): %$(GRAPH_P_SUFFIX): graphmod ch analysis: graphmod ##@Analysis Generate a table and some graphs to analyze Drasil's class, datatype, and instance structures. - rm -rf "$(ANALYSIS_FOLDER)" @mkdir -p "$(ANALYSIS_FOLDER)" - cd $(SCRIPT_FOLDER) && stack exec -- runghc ClassInstDepGen.hs - cd $(SCRIPT_FOLDER) && stack exec -- runghc TypeDepGen.hs + cd $(SCRIPT_FOLDER) && stack ClassInstDepGen.hs + cd $(SCRIPT_FOLDER) && stack TypeDepGen.hs @echo "Analysis complete. Please see '$(ANALYSIS_FOLDER)' folder." convertAnalyzed: ##@Analysis Convert analyzed dot graphs into SVGs. @@ -414,7 +459,7 @@ deploy_code_path: $(DCP_EXAMPLES) ##@GOOL Find all code file paths for all examp website: ##@Deploy First builds all Drasil packages, and then executes the drasil-website. stack build $(stackArgs) "drasil-website" CUR_DIR="$(PWD)/" \ - DEPLOY_FOLDER="$(CUR_DIR)$(DEPLOY_FOLDER)" \ + DEPLOY_FOLDER="$(CUR_DIR)$(DEPLOY_FOLDER)" \ DOCS_FOLDER="$(DOCS_FOLDER)" \ DOX_FOLDER="doxygen/" \ EXAMPLES_FOLDER="examples/" \ @@ -424,27 +469,21 @@ website: ##@Deploy First builds all Drasil packages, and then executes the drasi PACKAGES="$(PACKAGES)" \ TYPEGRAPH_FOLDER="$(TYPEGRAPH_FOLDER)" \ CLASSINST_GRAPH_FOLDER="$(CLASSINST_GRAPH_FOLDER)" \ - stack exec -- "website" - -# Deploys the Drasil website. Called by the deploy target. -# If you have all the necessary generated targets listed -# in `deploy`, then this will skip the re-generation of -# those files. Currently, the deploy_stage.sh script does -# not work for Windows Git Bash users. -deploy_lite: ##@Deploy Deploy the Drasil website without regenerating artifacts. For local development. + $(STACK_EXEC) -- "website" + +# Prepares a website folder deployable to GitHub Pages using existing artifacts. +deploy_lite: website ##@Deploy Deploy the Drasil website without regenerating artifacts. For local development. @mkdir -p "$(DEPLOY_FOLDER)" @BUILD_FOLDER="$(BUILD_FOLDER)" DEPLOY_FOLDER="$(DEPLOY_FOLDER)" GRAPH_FOLDER="$(GRAPH_FOLDER)" \ EXAMPLE_DIRS="$(EXAMPLE_DIRS)" MULTI_SRC_DIRS="$(MULTI_SRC_DIRS)" ANALYSIS_FOLDER="$(ANALYSIS_FOLDER)" \ TRACEY_GRAPHS_FOLDER="$(TRACEY_GRAPHS_FOLDER)" DEPLOY_CODE_PATH_KV_SEP="$(DEPLOY_CODE_PATH_KV_SEP)" \ WEBSITE_FOLDER="$(WEBSITE_FOLDER)" \ - MAKE="$(MAKE)" "$(SHELL)" "$(SCRIPT_FOLDER)"deploy_stage.sh - -# This rule is for use with developing deployment layout locally. As part of it, it ensures all needed -# dependencies exist. One of the downsides is we ensure all files are re-generated which means the TeX -# files appear newer and thus PDF's are regenerated. If you want to "just generate the structure, -# everything exists," (or you've run `deploy` once already) then `deploy_lite` does just that and is -# what `deploy.bash` calls. -deploy: analysis graphs packagedeps docs tex doxygen website ##@Deploy Generates all artifacts and the Drasil website locally. + MAKE="$(MAKE)" "$(SHELL)" "$(SCRIPT_FOLDER)prepare_deployment.sh" + +# Prepares a website folder deployable to GitHub Pages using freshly generated +# artifacts. If you don't want to use freshly generated artifacts, consider +# using theg `deploy_lite` target instead. +deploy: analysis graphs convertAnalyzed packagedeps docs tex doxygen ##@Deploy Generates all artifacts and the Drasil website locally. "$(MAKE)" deploy_lite #-----------------------# @@ -496,6 +535,8 @@ help: ##@Help Show this help. @echo " X$(CODE_E_SUFFIX) Generate individual example code." @echo " X$(DCP_E_SUFFIX) Get all generated code file paths in the example." @echo "" + @echo "Set a 'DEBUG_ENV' environment variable to 'true' if you want to check out the list of chunks in a Drasil run." + @echo "" @echo "To get started with Drasil, try running \"make\"." help_examples: ##@Help Lists all examples. diff --git a/code/datafiles/README.md b/code/datafiles/README.md index 21dcd3b502..5e39e10e3e 100644 --- a/code/datafiles/README.md +++ b/code/datafiles/README.md @@ -4,13 +4,13 @@ Last updated: July 29, 2021 -------------------------------------------------- This folder contains helper files including (but not limited to) system figures or images, graphs, sample inputs, and generated code dependencies for these Drasil examples: -- **dblpendulum** +- **dblpend** - **gamephysics** - **glassbr** -- **nopcm** +- **swhsnopcm** - **pdcontroller** - **projectile** -- **sglpendulum** +- **sglpend** - **ssp** - **swhs** diff --git a/code/datafiles/dblpendulum/SystemContextFigure.png b/code/datafiles/dblpend/SystemContextFigure.png similarity index 100% rename from code/datafiles/dblpendulum/SystemContextFigure.png rename to code/datafiles/dblpend/SystemContextFigure.png diff --git a/code/datafiles/dblpendulum/cpp b/code/datafiles/dblpend/cpp similarity index 100% rename from code/datafiles/dblpendulum/cpp rename to code/datafiles/dblpend/cpp diff --git a/code/datafiles/dblpendulum/csharp b/code/datafiles/dblpend/csharp similarity index 100% rename from code/datafiles/dblpendulum/csharp rename to code/datafiles/dblpend/csharp diff --git a/code/datafiles/dblpendulum/dblpendulum.png b/code/datafiles/dblpend/dblpend.png similarity index 100% rename from code/datafiles/dblpendulum/dblpendulum.png rename to code/datafiles/dblpend/dblpend.png diff --git a/code/datafiles/dblpendulum/java b/code/datafiles/dblpend/java similarity index 100% rename from code/datafiles/dblpendulum/java rename to code/datafiles/dblpend/java diff --git a/code/datafiles/dblpendulum/sampleInput.txt b/code/datafiles/dblpend/sampleInput.txt similarity index 100% rename from code/datafiles/dblpendulum/sampleInput.txt rename to code/datafiles/dblpend/sampleInput.txt diff --git a/code/datafiles/nopcm/SystemContextFigure.png b/code/datafiles/nopcm/SystemContextFigure.png deleted file mode 100644 index 885da85700..0000000000 Binary files a/code/datafiles/nopcm/SystemContextFigure.png and /dev/null differ diff --git a/code/datafiles/sglpendulum/SystemContextFigure.png b/code/datafiles/sglpend/SystemContextFigure.png similarity index 100% rename from code/datafiles/sglpendulum/SystemContextFigure.png rename to code/datafiles/sglpend/SystemContextFigure.png diff --git a/code/datafiles/sglpendulum/sglpendulum.jpg b/code/datafiles/sglpend/sglpend.jpg similarity index 100% rename from code/datafiles/sglpendulum/sglpendulum.jpg rename to code/datafiles/sglpend/sglpend.jpg diff --git a/code/datafiles/swhsnopcm/SystemContextFigure.png b/code/datafiles/swhsnopcm/SystemContextFigure.png new file mode 100644 index 0000000000..99cb0b7989 Binary files /dev/null and b/code/datafiles/swhsnopcm/SystemContextFigure.png differ diff --git a/code/datafiles/nopcm/TankWaterOnly.png b/code/datafiles/swhsnopcm/TankWaterOnly.png similarity index 100% rename from code/datafiles/nopcm/TankWaterOnly.png rename to code/datafiles/swhsnopcm/TankWaterOnly.png diff --git a/code/datafiles/nopcm/cpp b/code/datafiles/swhsnopcm/cpp similarity index 100% rename from code/datafiles/nopcm/cpp rename to code/datafiles/swhsnopcm/cpp diff --git a/code/datafiles/nopcm/csharp b/code/datafiles/swhsnopcm/csharp similarity index 100% rename from code/datafiles/nopcm/csharp rename to code/datafiles/swhsnopcm/csharp diff --git a/code/datafiles/nopcm/java b/code/datafiles/swhsnopcm/java similarity index 100% rename from code/datafiles/nopcm/java rename to code/datafiles/swhsnopcm/java diff --git a/code/datafiles/nopcm/sampleInput.txt b/code/datafiles/swhsnopcm/sampleInput.txt similarity index 100% rename from code/datafiles/nopcm/sampleInput.txt rename to code/datafiles/swhsnopcm/sampleInput.txt diff --git a/code/drasil-build/lib/Build/Drasil.hs b/code/drasil-build/lib/Build/Drasil.hs index ca75f2bc05..3516b0d101 100644 --- a/code/drasil-build/lib/Build/Drasil.hs +++ b/code/drasil-build/lib/Build/Drasil.hs @@ -6,7 +6,8 @@ module Build.Drasil ( RuleTransformer(makeRule) -- ** Types and Functions -- AST - , Command, mkCheckedCommand, mkCommand, Dependencies, Rule, mkFile, mkRule + , Annotation, Command, mkCheckedCommand, mkCommand, Dependencies, Rule, + mkFile, mkRule -- MakeString , MakeString, (+:+), makeS, mkFreeVar, mkImplicitVar, mkWindowsVar, mkOSVar -- ** Printers @@ -14,7 +15,7 @@ module Build.Drasil ( ) where -import Build.Drasil.Make.AST (Command, Dependencies, mkCheckedCommand, +import Build.Drasil.Make.AST (Annotation, Command, Dependencies, mkCheckedCommand, mkCommand, mkFile, mkRule, Rule) import Build.Drasil.Make.Import (RuleTransformer(makeRule)) import Build.Drasil.Make.MakeString ((+:+), makeS, MakeString, mkFreeVar, diff --git a/code/drasil-code/lib/Data/Drasil/ExternalLibraries/ODELibraries.hs b/code/drasil-code/lib/Data/Drasil/ExternalLibraries/ODELibraries.hs index f392f5ed56..a2e71206e4 100644 --- a/code/drasil-code/lib/Data/Drasil/ExternalLibraries/ODELibraries.hs +++ b/code/drasil-code/lib/Data/Drasil/ExternalLibraries/ODELibraries.hs @@ -5,7 +5,7 @@ module Data.Drasil.ExternalLibraries.ODELibraries ( -- * Oslo Library (C#) osloPckg, osloSymbols, arrayVecDepVar, -- * Apache Commons (Java) - apacheODEPckg, apacheODESymbols, + apacheODEPckg, apacheODESymbols, -- * Odeint (C++) odeintPckg, odeintSymbols ) where @@ -33,7 +33,7 @@ import Language.Drasil.Code (Lang(..), ExternalLibrary, Step, Argument, customClassFill, implementationFill, constructorInfoFill, methodInfoFill, appendCurrSolFill, populateSolListFill, assignArrayIndexFill, assignSolFromObjFill, initSolListFromArrayFill, initSolListWithValFill, - solveAndPopulateWhileFill, returnExprListFill, fixedStatementFill', + solveAndPopulateWhileFill, returnExprListFill, fixedStatementFill', CodeVarChunk, CodeFuncChunk, quantvar, quantfunc, listToArray, ODEInfo(..), ODEOptions(..), ODEMethod(..), ODELibPckg, mkODELib, mkODELibNoPath, pubStateVar, privStateVar, @@ -130,7 +130,7 @@ ut = quantvar $ implVar "ut_scipy" numpyArrayT (label "u_t") transpose = quantvar $ implVar "transpose_numpy" (nounPhrase "Numpy Array Transpose" "Numpy Array Transpose") - (Array Real) (label "u_t.T") -- (ccObjVar ut transpose) does not seem to work. + (Array Real) (label "u_t.T") -- (ccObjVar ut transpose) does not seem to work. f, odefunc, setIntegrator, setInitVal, successful, @@ -266,7 +266,7 @@ vecDepVar info = quantvar $ implVarUID (dv ^. uid) (dv ^. term) vecT (sub (symbol dv Implementation) (label "vec")) where dv = depVar info --- Hack required because +-- Hack required because -- | Oslo's Vector type behaves like an array, so needs to -- be represented as one or else will hit type errors in GOOL. arrayVecDepVar :: ODEInfo -> CodeVarChunk diff --git a/code/drasil-code/lib/Language/Drasil/Choices.hs b/code/drasil-code/lib/Language/Drasil/Choices.hs index eb38ca9cfc..f4fc17db7c 100644 --- a/code/drasil-code/lib/Language/Drasil/Choices.hs +++ b/code/drasil-code/lib/Language/Drasil/Choices.hs @@ -1,8 +1,8 @@ -- | Defines the design language for SCS. module Language.Drasil.Choices ( - Choices(..), Architecture (..), makeArchit, DataInfo(..), makeData, Maps(..), - makeMaps, spaceToCodeType, Constraints(..), makeConstraints, ODE(..), makeODE, - DocConfig(..), makeDocConfig, LogConfig(..), makeLogConfig, OptionalFeatures(..), + Choices(..), Architecture (..), makeArchit, DataInfo(..), makeData, Maps(..), + makeMaps, spaceToCodeType, Constraints(..), makeConstraints, ODE(..), makeODE, + DocConfig(..), makeDocConfig, LogConfig(..), makeLogConfig, OptionalFeatures(..), makeOptFeats, ExtLib(..), Modularity(..), InputModule(..), inputModule, Structure(..), ConstantStructure(..), ConstantRepr(..), ConceptMatchMap, MatchedConceptMap, CodeConcept(..), matchConcepts, SpaceMatch, matchSpaces, ImplementationType(..), @@ -37,7 +37,7 @@ data Choices = Choices { optFeats :: OptionalFeatures, -- | Constraint violation behaviour. Exception or Warning. srsConstraints :: Constraints, - -- | List of external libraries what to utilize + -- | List of external libraries what to utilize extLibs :: [ExtLib], -- | Number of folders to go up in order to obtain the image folderVal :: Int @@ -47,6 +47,7 @@ data Choices = Choices { class RenderChoices a where showChs :: a -> Sentence showChsList :: [a] -> Sentence + showChsList [] = S "None" showChsList lst = foldlSent_ (map showChs lst) -- | Architecture of a program @@ -61,7 +62,7 @@ makeArchit :: Modularity -> ImplementationType -> Architecture makeArchit = Archt -- | Modularity of a program. -data Modularity = Modular InputModule -- ^ Different modules. For controller, +data Modularity = Modular InputModule -- ^ Different modules. For controller, -- input, calculations, output. | Unmodular -- ^ All generated code is in one module/file. @@ -75,8 +76,8 @@ instance RenderChoices Modularity where data InputModule = Combined -- ^ Input-related functions combined in one module. | Separated -- ^ Input-related functions each in own module. --- | Determines whether there is a 'Combined' input module or many 'Separated' input --- modules, based on a 'Choices' structure. An 'Unmodular' design implicitly means +-- | Determines whether there is a 'Combined' input module or many 'Separated' input +-- modules, based on a 'Choices' structure. An 'Unmodular' design implicitly means -- that input modules are 'Combined'. inputModule :: Choices -> InputModule inputModule c = inputModule' $ modularity $ architecture c @@ -117,7 +118,7 @@ instance RenderChoices Structure where -- | Constants options. data ConstantStructure = Inline -- ^ Inline values for constants. | WithInputs -- ^ Store constants with inputs. - | Store Structure -- ^ Store constants separately from + | Store Structure -- ^ Store constants separately from -- inputs, whether bundled or unbundled. -- | Renders the structure of constants in a program. @@ -136,7 +137,7 @@ instance RenderChoices ConstantRepr where showChs Var = S "Var" showChs Const = S "Const" --- | Maps for Concepts and Space +-- | Maps for Concepts and Space data Maps = Maps { -- | Map of 'UID's for Drasil concepts to code concepts. -- Matching a 'UID' to a code concept means the code concept should be used @@ -151,10 +152,10 @@ data Maps = Maps { makeMaps :: ConceptMatchMap -> SpaceMatch -> Maps makeMaps = Maps --- | Specifies matches between chunks and 'CodeConcept's, meaning the target --- language's pre-existing definition of the concept should be used instead of --- defining a new variable for the concept in the generated code. --- ['CodeConcept'] is preferentially-ordered, generator concretizes a +-- | Specifies matches between chunks and 'CodeConcept's, meaning the target +-- language's pre-existing definition of the concept should be used instead of +-- defining a new variable for the concept in the generated code. +-- ['CodeConcept'] is preferentially-ordered, generator concretizes a -- 'ConceptMatchMap' to a 'MatchedConceptMap' by checking user's other choices. type ConceptMatchMap = Map UID [CodeConcept] -- | Concrete version of ConceptMatchMap dependent on user choices. @@ -172,8 +173,8 @@ instance RenderChoices CodeConcept where matchConcepts :: (HasUID c) => [(c, [CodeConcept])] -> ConceptMatchMap matchConcepts = fromList . map (\(cnc,cdc) -> (cnc ^. uid, cdc)) --- | Specifies which 'CodeType' should be used to represent each mathematical --- 'Space'. ['CodeType'] is preferentially-ordered, first 'CodeType' that does not +-- | Specifies which 'CodeType' should be used to represent each mathematical +-- 'Space'. ['CodeType'] is preferentially-ordered, first 'CodeType' that does not -- conflict with other choices will be selected. type SpaceMatch = Space -> [CodeType] @@ -199,7 +200,7 @@ data OptionalFeatures = OptFeats{ makeOptFeats :: DocConfig -> LogConfig -> [AuxFile] -> OptionalFeatures makeOptFeats = OptFeats --- | Configuration for Doxygen documentation +-- | Configuration for Doxygen documentation data DocConfig = DocConfig { -- | Turns Doxygen comments for different code structures on or off. comments :: [Comments], @@ -253,7 +254,7 @@ makeLogConfig :: [Logging] -> FilePath -> LogConfig makeLogConfig = LogConfig -- | Logging options for function calls and variable assignments. --- Eq instances required for Logging and Comments because generator needs to +-- Eq instances required for Logging and Comments because generator needs to -- check membership of these elements in lists data Logging = LogFunc -- ^ Log messages generated for function calls. | LogVar -- ^ Log messages generated for variable assignments. @@ -276,7 +277,7 @@ instance RenderChoices AuxFile where showChs (SampleInput fp) = S "SampleInput" +:+ S fp showChs ReadME = S "ReadME" --- | Gets the file path to a sample input data set from a 'Choices' structure, if +-- | Gets the file path to a sample input data set from a 'Choices' structure, if -- the user chose to generate a sample input file. getSampleData :: Choices -> Maybe FilePath getSampleData chs = getSampleData' (auxFiles $ optFeats chs) @@ -311,9 +312,9 @@ instance RenderChoices ConstraintBehaviour where -- | External Library Options newtype ExtLib = Math ODE --- | All Information needed to solve an ODE +-- | All Information needed to solve an ODE data ODE = ODE{ - -- FIXME: ODEInfos should be automatically built from Instance models when + -- FIXME: ODEInfos should be automatically built from Instance models when -- needed, but we can't do that yet so I'm passing it through Choices instead. -- This choice should really just be for an ODEMethod -- | ODE information. @@ -325,19 +326,19 @@ data ODE = ODE{ makeODE :: [ODEInfo] -> [ODELibPckg] -> ODE makeODE = ODE --- | Default choices to be used as the base from which design specifications +-- | Default choices to be used as the base from which design specifications -- can be built. defaultChoices :: Choices defaultChoices = Choices { lang = [Python], architecture = makeArchit (Modular Combined) Program, dataInfo = makeData Bundled Inline Const, - maps = makeMaps - (matchConcepts ([] :: [(SimpleQDef, [CodeConcept])])) + maps = makeMaps + (matchConcepts ([] :: [(SimpleQDef, [CodeConcept])])) spaceToCodeType, - optFeats = makeOptFeats - (makeDocConfig [] Verbose Hide) - (makeLogConfig [] "log.txt") + optFeats = makeOptFeats + (makeDocConfig [] Verbose Hide) + (makeLogConfig [] "log.txt") [ReadME], srsConstraints = makeConstraints Exception Warning, extLibs = [], @@ -347,22 +348,22 @@ defaultChoices = Choices { -- | Renders 'Choices' as 'Sentence's. choicesSent :: Choices -> [Sentence] choicesSent chs = map chsFieldSent [ - (S "Languages", foldlSent_ $ map (S . show) $ lang chs), - (S "Modularity", showChs $ modularity $ architecture chs), - (S "Input Structure", showChs $ inputStructure $ dataInfo chs), - (S "Constant Structure", showChs $ constStructure $ dataInfo chs), - (S "Constant Representation", showChs $ constRepr $ dataInfo chs), - (S "Implementation Type", showChs $ impType $ architecture chs), - (S "Software Constraint Behaviour", showChs $ onSfwrConstraint $ srsConstraints chs), - (S "Physical Constraint Behaviour", showChs $ onPhysConstraint $ srsConstraints chs), - (S "Comments", showChsList $ comments $ docConfig $ optFeats chs), - (S "Dox Verbosity", showChs $ doxVerbosity $ docConfig $ optFeats chs), - (S "Dates", showChs $ dates $ docConfig $ optFeats chs), - (S "Log File Name", S $ logFile $ logConfig $ optFeats chs), - (S "Logging", showChsList $ logging $ logConfig $ optFeats chs), + (S "Languages", foldlSent_ $ map (S . show) $ lang chs), + (S "Modularity", showChs $ modularity $ architecture chs), + (S "Input Structure", showChs $ inputStructure $ dataInfo chs), + (S "Constant Structure", showChs $ constStructure $ dataInfo chs), + (S "Constant Representation", showChs $ constRepr $ dataInfo chs), + (S "Implementation Type", showChs $ impType $ architecture chs), + (S "Software Constraint Behaviour", showChs $ onSfwrConstraint $ srsConstraints chs), + (S "Physical Constraint Behaviour", showChs $ onPhysConstraint $ srsConstraints chs), + (S "Comments", showChsList $ comments $ docConfig $ optFeats chs), + (S "Dox Verbosity", showChs $ doxVerbosity $ docConfig $ optFeats chs), + (S "Dates", showChs $ dates $ docConfig $ optFeats chs), + (S "Log File Name", S $ logFile $ logConfig $ optFeats chs), + (S "Logging", showChsList $ logging $ logConfig $ optFeats chs), (S "Auxiliary Files", showChsList $ auxFiles $ optFeats chs) ] -- | Helper to combine pairs of 'Sentence's for rendering 'Choices'. chsFieldSent :: (Sentence, Sentence) -> Sentence -chsFieldSent (rec, chc) = rec +:+ S "selected as" +:+. chc \ No newline at end of file +chsFieldSent (rec, chc) = rec +:+ S "selected as" +:+. chc diff --git a/code/drasil-code/lib/Language/Drasil/Chunk/Code.hs b/code/drasil-code/lib/Language/Drasil/Chunk/Code.hs index 737ebb5398..9678badfb5 100644 --- a/code/drasil-code/lib/Language/Drasil/Chunk/Code.hs +++ b/code/drasil-code/lib/Language/Drasil/Chunk/Code.hs @@ -2,8 +2,8 @@ -- | Defines chunk types for use in code generation. module Language.Drasil.Chunk.Code ( - CodeIdea(..), CodeChunk(..), CodeVarChunk(..), CodeFuncChunk(..), - VarOrFunc(..), obv, quantvar, quantfunc, ccObjVar, codevars, codevars', + CodeIdea(..), CodeChunk(..), CodeVarChunk(..), CodeFuncChunk(..), + VarOrFunc(..), obv, quantvar, quantfunc, ccObjVar, codevars, codevars', funcResolve, varResolve, listToArray, programName, funcPrefix, DefiningCodeExpr(..) ) where @@ -22,16 +22,16 @@ instance CodeIdea CodeChunk where codeChunk = id -- | Finds the code name and 'CodeChunk' within a 'CodeVarChunk'. -instance CodeIdea CodeVarChunk where +instance CodeIdea CodeVarChunk where codeName = codeName . view ccv codeChunk c = CodeC (view qc $ view ccv c) Var -- | Finds the code name and 'CodeChunk' within a 'CodeFuncChunk'. -instance CodeIdea CodeFuncChunk where +instance CodeIdea CodeFuncChunk where codeName = codeName . view ccf codeChunk c = CodeC (view qc $ view ccf c) Func --- | Combine an Object-type 'CodeChunk' with another 'CodeChunk' to create a new +-- | Combine an Object-type 'CodeChunk' with another 'CodeChunk' to create a new -- 'CodeChunk' which represents a field of the first. ex. @ccObjVar obj f = obj.f@. ccObjVar :: CodeVarChunk -> CodeVarChunk -> CodeVarChunk ccObjVar c1 c2 = checkObj (c1 ^. typ) diff --git a/code/drasil-code/lib/Language/Drasil/Chunk/CodeDefinition.hs b/code/drasil-code/lib/Language/Drasil/Chunk/CodeDefinition.hs index 5ef479fb69..e6fdf7ccbe 100644 --- a/code/drasil-code/lib/Language/Drasil/Chunk/CodeDefinition.hs +++ b/code/drasil-code/lib/Language/Drasil/Chunk/CodeDefinition.hs @@ -3,7 +3,7 @@ module Language.Drasil.Chunk.CodeDefinition ( CodeDefinition, DefinitionType(..), qtoc, qtov, odeDef, auxExprs, defType, ) where -import Language.Drasil +import Language.Drasil import Language.Drasil.Chunk.Code (quantvar, quantfunc) import Language.Drasil.CodeExpr.Development (expr, CanGenCode(..)) import Language.Drasil.Data.ODEInfo (ODEInfo(..), ODEOptions(..)) @@ -34,7 +34,7 @@ instance HasSymbol CodeDefinition where symbol c = symbol (c ^. cchunk) -- | 'CodeDefinition's have a 'Quantity'. instance Quantity CodeDefinition -- | Finds the code name of a 'CodeDefinition'. --- 'Function' 'CodeDefinition's are named with the function prefix to distinguish +-- 'Function' 'CodeDefinition's are named with the function prefix to distinguish -- them from the corresponding variable version. instance CodeIdea CodeDefinition where codeName (CD c@(CodeC _ Var) _ _ _) = codeName c @@ -63,7 +63,7 @@ qtov q = CD (codeChunk $ quantvar q) (toCodeExpr $ q ^. defnExpr) [] Definition -- | Constructs a 'CodeDefinition' for an ODE. odeDef :: ODEInfo -> CodeDefinition -odeDef info = CD +odeDef info = CD (codeChunk $ quantfunc $ depVar info) (matrix [odeSyst info]) (matrix [initVal info]: diff --git a/code/drasil-code/lib/Language/Drasil/Chunk/NamedArgument.hs b/code/drasil-code/lib/Language/Drasil/Chunk/NamedArgument.hs index 0305cacf79..bad1b37434 100644 --- a/code/drasil-code/lib/Language/Drasil/Chunk/NamedArgument.hs +++ b/code/drasil-code/lib/Language/Drasil/Chunk/NamedArgument.hs @@ -34,7 +34,7 @@ instance IsArgumentName NamedArgument where instance Eq NamedArgument where a == b = (a ^. uid) == (b ^. uid) -- | Finds the units of the 'QuantityDict' used to make the 'NamedArgument'. instance MayHaveUnit NamedArgument where getUnit = getUnit . view qtd - + -- | Smart constructor for 'NamedArgument' . narg :: (Quantity q, MayHaveUnit q) => q -> NamedArgument narg = NA . qw diff --git a/code/drasil-code/lib/Language/Drasil/Code.hs b/code/drasil-code/lib/Language/Drasil/Code.hs index 6d62b84279..e9e2e0be53 100644 --- a/code/drasil-code/lib/Language/Drasil/Code.hs +++ b/code/drasil-code/lib/Language/Drasil/Code.hs @@ -1,43 +1,43 @@ -- | Re-export code-related smart constructors for external code writing and generation. module Language.Drasil.Code ( - makeCode, createCodeFiles, + makeCode, createCodeFiles, generator, generateCode, readWithDataDesc, sampleInputDD, Choices(..), Comments(..), Verbosity(..), ConstraintBehaviour(..), makeArchit, Architecture(..), DataInfo(..), makeData, Maps(..), makeMaps, spaceToCodeType, - makeConstraints, makeODE, makeDocConfig, makeLogConfig, LogConfig(..), - OptionalFeatures(..), makeOptFeats, ExtLib(..), ImplementationType(..), Logging(..), - Modularity(..), Structure(..), ConstantStructure(..), ConstantRepr(..), - InputModule(..), CodeConcept(..), matchConcepts, SpaceMatch, matchSpaces, - AuxFile(..), getSampleData, Visibility(..), defaultChoices, + makeConstraints, makeODE, makeDocConfig, makeLogConfig, LogConfig(..), + OptionalFeatures(..), makeOptFeats, ExtLib(..), ImplementationType(..), Logging(..), + Modularity(..), Structure(..), ConstantStructure(..), ConstantRepr(..), + InputModule(..), CodeConcept(..), matchConcepts, SpaceMatch, matchSpaces, + AuxFile(..), getSampleData, Visibility(..), defaultChoices, CodeSpec(..), funcUID, asVC, codeSpec, - ($:=), Mod(Mod), StateVariable, Func, FuncStmt(..), pubStateVar, + ($:=), Mod(Mod), StateVariable, Func, FuncStmt(..), pubStateVar, privStateVar, fDecDef, ffor, fforRange, funcData, funcDef, packmod, junkLine, multiLine, repeated, singleLine, singleton, - ExternalLibrary, Step, FunctionInterface, Argument, externalLib, choiceSteps, - choiceStep, mandatoryStep, mandatorySteps, callStep, libFunction, libMethod, - libFunctionWithResult, libMethodWithResult, libConstructor, - libConstructorMultiReqs, constructAndReturn, lockedArg, lockedNamedArg, - inlineArg, inlineNamedArg, preDefinedArg, preDefinedNamedArg, functionArg, - customObjArg, recordArg, lockedParam, unnamedParam, customClass, - implementation, constructorInfo, methodInfo, methodInfoNoReturn, - appendCurrSol, populateSolList, assignArrayIndex, assignSolFromObj, - initSolListFromArray, initSolListWithVal, solveAndPopulateWhile, + ExternalLibrary, Step, FunctionInterface, Argument, externalLib, choiceSteps, + choiceStep, mandatoryStep, mandatorySteps, callStep, libFunction, libMethod, + libFunctionWithResult, libMethodWithResult, libConstructor, + libConstructorMultiReqs, constructAndReturn, lockedArg, lockedNamedArg, + inlineArg, inlineNamedArg, preDefinedArg, preDefinedNamedArg, functionArg, + customObjArg, recordArg, lockedParam, unnamedParam, customClass, + implementation, constructorInfo, methodInfo, methodInfoNoReturn, + appendCurrSol, populateSolList, assignArrayIndex, assignSolFromObj, + initSolListFromArray, initSolListWithVal, solveAndPopulateWhile, returnExprList, fixedReturn, fixedReturn', initSolWithVal, - ExternalLibraryCall, StepGroupFill(..), StepFill(..), FunctionIntFill(..), + ExternalLibraryCall, StepGroupFill(..), StepFill(..), FunctionIntFill(..), ArgumentFill(..), ParameterFill(..), ClassInfoFill(..), MethodInfoFill(..), - externalLibCall, choiceStepsFill, choiceStepFill, mandatoryStepFill, - mandatoryStepsFill, callStepFill, libCallFill, userDefinedArgFill, - basicArgFill, functionArgFill, customObjArgFill, recordArgFill, - unnamedParamFill, unnamedParamPBVFill, userDefinedParamFill, customClassFill, - implementationFill, constructorInfoFill, methodInfoFill, appendCurrSolFill, - populateSolListFill, assignArrayIndexFill, assignSolFromObjFill, - initSolListFromArrayFill, initSolListWithValFill, solveAndPopulateWhileFill, + externalLibCall, choiceStepsFill, choiceStepFill, mandatoryStepFill, + mandatoryStepsFill, callStepFill, libCallFill, userDefinedArgFill, + basicArgFill, functionArgFill, customObjArgFill, recordArgFill, + unnamedParamFill, unnamedParamPBVFill, userDefinedParamFill, customClassFill, + implementationFill, constructorInfoFill, methodInfoFill, appendCurrSolFill, + populateSolListFill, assignArrayIndexFill, assignSolFromObjFill, + initSolListFromArrayFill, initSolListWithValFill, solveAndPopulateWhileFill, returnExprListFill, fixedStatementFill, fixedStatementFill', initSolWithValFill, Lang(..), PackageSym(..), AuxiliarySym(..), AuxData(..), PackData(..), - CodeChunk, CodeVarChunk, CodeFuncChunk, quantvar, quantfunc, ccObjVar, + CodeChunk, CodeVarChunk, CodeFuncChunk, quantvar, quantfunc, ccObjVar, listToArray, field, ODEInfo(..), odeInfo, odeInfo', ODEOptions(..), odeOptions, ODEMethod(..), @@ -51,7 +51,7 @@ import Prelude hiding (break, print, return, log, exp) import Language.Drasil.Code.Imperative.Generator (generator, generateCode) -import Language.Drasil.Code.Imperative.ReadInput (readWithDataDesc, +import Language.Drasil.Code.Imperative.ReadInput (readWithDataDesc, sampleInputDD) import Language.Drasil.Code.CodeGeneration (makeCode, createCodeFiles) @@ -60,59 +60,59 @@ import Language.Drasil.Code.DataDesc (junkLine, multiLine, repeated, singleLine, singleton) import Language.Drasil.Code.ExternalLibrary (ExternalLibrary, Step, - FunctionInterface, Argument, externalLib, choiceSteps, choiceStep, - mandatoryStep, mandatorySteps, callStep, libFunction, libMethod, - libFunctionWithResult, libMethodWithResult, libConstructor, - libConstructorMultiReqs, constructAndReturn, lockedArg, lockedNamedArg, - inlineArg, inlineNamedArg, preDefinedArg, preDefinedNamedArg, functionArg, - customObjArg, recordArg, lockedParam, unnamedParam, customClass, - implementation, constructorInfo, methodInfo, methodInfoNoReturn, - appendCurrSol, populateSolList, assignArrayIndex, assignSolFromObj, - initSolListFromArray, initSolListWithVal, solveAndPopulateWhile, + FunctionInterface, Argument, externalLib, choiceSteps, choiceStep, + mandatoryStep, mandatorySteps, callStep, libFunction, libMethod, + libFunctionWithResult, libMethodWithResult, libConstructor, + libConstructorMultiReqs, constructAndReturn, lockedArg, lockedNamedArg, + inlineArg, inlineNamedArg, preDefinedArg, preDefinedNamedArg, functionArg, + customObjArg, recordArg, lockedParam, unnamedParam, customClass, + implementation, constructorInfo, methodInfo, methodInfoNoReturn, + appendCurrSol, populateSolList, assignArrayIndex, assignSolFromObj, + initSolListFromArray, initSolListWithVal, solveAndPopulateWhile, returnExprList, fixedReturn, fixedReturn', initSolWithVal) import Language.Drasil.Code.ExternalLibraryCall (ExternalLibraryCall, StepGroupFill(..), StepFill(..), FunctionIntFill(..), ArgumentFill(..), - ParameterFill(..), ClassInfoFill(..), MethodInfoFill(..), externalLibCall, - choiceStepsFill, choiceStepFill, mandatoryStepFill, mandatoryStepsFill, - callStepFill, libCallFill, userDefinedArgFill, basicArgFill, functionArgFill, - customObjArgFill, recordArgFill, unnamedParamFill, unnamedParamPBVFill, - userDefinedParamFill, customClassFill, implementationFill, - constructorInfoFill, methodInfoFill, appendCurrSolFill, populateSolListFill, - assignArrayIndexFill, assignSolFromObjFill, initSolListFromArrayFill, - initSolListWithValFill, solveAndPopulateWhileFill, returnExprListFill, + ParameterFill(..), ClassInfoFill(..), MethodInfoFill(..), externalLibCall, + choiceStepsFill, choiceStepFill, mandatoryStepFill, mandatoryStepsFill, + callStepFill, libCallFill, userDefinedArgFill, basicArgFill, functionArgFill, + customObjArgFill, recordArgFill, unnamedParamFill, unnamedParamPBVFill, + userDefinedParamFill, customClassFill, implementationFill, + constructorInfoFill, methodInfoFill, appendCurrSolFill, populateSolListFill, + assignArrayIndexFill, assignSolFromObjFill, initSolListFromArrayFill, + initSolListWithValFill, solveAndPopulateWhileFill, returnExprListFill, fixedStatementFill, fixedStatementFill', initSolWithValFill) import Language.Drasil.Code.Lang (Lang(..)) -import Language.Drasil.Choices (Choices(..), Comments(..), Verbosity(..), - ConstraintBehaviour(..), ImplementationType(..), Logging(..), Modularity(..), - Structure(..), ConstantStructure(..), ConstantRepr(..), InputModule(..), - CodeConcept(..), matchConcepts, SpaceMatch, matchSpaces, AuxFile(..), +import Language.Drasil.Choices (Choices(..), Comments(..), Verbosity(..), + ConstraintBehaviour(..), ImplementationType(..), Logging(..), Modularity(..), + Structure(..), ConstantStructure(..), ConstantRepr(..), InputModule(..), + CodeConcept(..), matchConcepts, SpaceMatch, matchSpaces, AuxFile(..), getSampleData, Visibility(..), defaultChoices, makeArchit, Architecture(..), DataInfo(..), makeData, Maps(..), makeMaps, spaceToCodeType, makeConstraints, - makeODE, makeDocConfig, makeLogConfig, LogConfig(..), OptionalFeatures(..), + makeODE, makeDocConfig, makeLogConfig, LogConfig(..), OptionalFeatures(..), makeOptFeats, ExtLib(..)) - + import Language.Drasil.CodeSpec (CodeSpec(..), funcUID, asVC, codeSpec) -import Language.Drasil.Mod (($:=), Mod(Mod), StateVariable, Func, FuncStmt(..), +import Language.Drasil.Mod (($:=), Mod(Mod), StateVariable, Func, FuncStmt(..), pubStateVar, privStateVar, fDecDef, ffor, fforRange, funcData, funcDef, packmod) -import Language.Drasil.Code.Imperative.GOOL.ClassInterface (PackageSym(..), +import Language.Drasil.Code.Imperative.GOOL.ClassInterface (PackageSym(..), AuxiliarySym(..)) import Language.Drasil.Code.Imperative.GOOL.Data (AuxData(..), PackData(..)) -import Language.Drasil.Chunk.Code (CodeChunk, CodeVarChunk, CodeFuncChunk, +import Language.Drasil.Chunk.Code (CodeChunk, CodeVarChunk, CodeFuncChunk, quantvar, quantfunc, ccObjVar, listToArray) import Language.Drasil.Chunk.NamedArgument (NamedArgument, narg) import Language.Drasil.CodeExpr (field) -import Language.Drasil.Data.ODEInfo (ODEInfo(..), odeInfo, odeInfo', ODEOptions(..), +import Language.Drasil.Data.ODEInfo (ODEInfo(..), odeInfo, odeInfo', ODEOptions(..), odeOptions, ODEMethod(..)) -import Language.Drasil.Data.ODELibPckg (ODELibPckg(..), mkODELib, +import Language.Drasil.Data.ODELibPckg (ODELibPckg(..), mkODELib, mkODELibNoPath) import Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.PythonRenderer (unPP) diff --git a/code/drasil-code/lib/Language/Drasil/Code/CodeGeneration.hs b/code/drasil-code/lib/Language/Drasil/Code/CodeGeneration.hs index 0c30b64d96..e52d74464a 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/CodeGeneration.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/CodeGeneration.hs @@ -7,7 +7,7 @@ module Language.Drasil.Code.CodeGeneration ( ) where import Language.Drasil.Code.Code (Code(..)) -import Language.Drasil.Code.Imperative.GOOL.Data (AuxData(..)) +import Language.Drasil.Code.Imperative.GOOL.Data (AuxData(..)) import GOOL.Drasil (FileData(..), ModData(modDoc)) diff --git a/code/drasil-code/lib/Language/Drasil/Code/CodeQuantityDicts.hs b/code/drasil-code/lib/Language/Drasil/Code/CodeQuantityDicts.hs index 3f536572aa..d6826455d9 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/CodeQuantityDicts.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/CodeQuantityDicts.hs @@ -5,19 +5,19 @@ import Language.Drasil -- | Variable for the input file's name. inFileName :: QuantityDict -inFileName = implVar "inFileName" +inFileName = implVar "inFileName" (nounPhrase "name of the input file" "names of the input files") String (label "filename") -- | Variable for an object of the InputParameters class. inParams :: QuantityDict -inParams = implVar "inParams" (nounPhrase +inParams = implVar "inParams" (nounPhrase "structure holding the input values" "structures holding the input values") (Actor "InputParameters") (label "inParams") -- | Variable for an object of the Constants class. consts :: QuantityDict -consts = implVar "consts" (nounPhrase - "structure holding the constant values" - "structures holding the constant values") +consts = implVar "consts" (nounPhrase + "structure holding the constant values" + "structures holding the constant values") (Actor "Constants") (label "consts") diff --git a/code/drasil-code/lib/Language/Drasil/Code/DataDesc.hs b/code/drasil-code/lib/Language/Drasil/Code/DataDesc.hs index 8145a42abb..7399348fcf 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/DataDesc.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/DataDesc.hs @@ -14,16 +14,16 @@ data DataDesc' = DD Data' Delimiter DataDesc' | End Data' -- Data can either contain a single 'DataItem'', 'Data', or 'Junk'. See @source@ for more details on each constructor. data Data' = Datum DataItem' -- ^ Single data item. - -- | To be used in cases where multiple list-type data have their + -- | To be used in cases where multiple list-type data have their -- elements intermixed, and thus need to be described together. - | Data - (NonEmpty DataItem') -- The DataItems being simultaneously described. - -- The intra-list delimiters for any shared dimensions should - -- be the same between the DataItems. For example, if mixing 2 - -- lists of same dimension, the intra-list delimiters must be - -- the same between the two lists. If mixing a 1-D list with a - -- 2-D list, the first delimiter must be the same, but the 2nd - -- delimiter for the 2-D list is not constrained because there + | Data + (NonEmpty DataItem') -- The DataItems being simultaneously described. + -- The intra-list delimiters for any shared dimensions should + -- be the same between the DataItems. For example, if mixing 2 + -- lists of same dimension, the intra-list delimiters must be + -- the same between the two lists. If mixing a 1-D list with a + -- 2-D list, the first delimiter must be the same, but the 2nd + -- delimiter for the 2-D list is not constrained because there -- is no corresponding delimiter for the 1-D list. Integer -- Degree of intermixing -- 0 <= degree of intermixing <= minimum dimension of the DataItems @@ -34,12 +34,12 @@ data Data' = Datum DataItem' -- ^ Single data item. Delimiter -- Delimiter between elements from different lists | Junk -- ^ Data that can be ignored/skipped over. --- | A piece of data that contains the datum described and delimeters between elements. +-- | A piece of data that contains the datum described and delimeters between elements. -- The size of the list of delimiters should be equal to the dimension of datum. -data DataItem' = DI +data DataItem' = DI CodeVarChunk -- The datum being described - [Delimiter] -- Delimiters between list elements. - -- Size of list should equal dimension of datum + [Delimiter] -- Delimiters between list elements. + -- Size of list should equal dimension of datum -- Ex. a 1-D list needs 1 delimiter, a 2-D list needs 2 delimiters -- Outermost delimiter first, innermost last @@ -51,7 +51,7 @@ type Delimiter = String -- | Organize a list of data with a given 'Delimiter' into a 'DataDesc''. dataDesc :: [Data'] -> Delimiter -> DataDesc' dataDesc [d] _ = End d -dataDesc (d:ds) dlm = DD d dlm (dataDesc ds dlm) +dataDesc (d:ds) dlm = DD d dlm (dataDesc ds dlm) dataDesc [] _ = error "DataDesc must have at least one data item" -- | Constructor for creating a single datum. @@ -82,7 +82,7 @@ type Delim = Char -- delimiter data Data = Singleton DataItem -- ^ Single datum. | JunkData -- ^ Junk data (can be skipped). | Line LinePattern Delim -- ^ Single-line pattern of data with a delimiter. - | Lines LinePattern (Maybe Integer) Delim -- ^ Multi-line data. + | Lines LinePattern (Maybe Integer) Delim -- ^ Multi-line data. -- @Maybe Int@ determines the number of lines. -- If it is Nothing, then it is unknown so go to end of file. -- | Determines the pattern of data. @@ -101,7 +101,7 @@ junkLine = JunkData -- | Constructor for a single line of data. singleLine :: LinePattern -> Delim -> Data -singleLine = Line +singleLine = Line -- | Constructor for an unknown amount of lines of data. multiLine :: LinePattern -> Delim -> Data diff --git a/code/drasil-code/lib/Language/Drasil/Code/ExtLibImport.hs b/code/drasil-code/lib/Language/Drasil/Code/ExtLibImport.hs index eab83c344c..e17f25d2f3 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/ExtLibImport.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/ExtLibImport.hs @@ -1,22 +1,22 @@ {-# LANGUAGE TemplateHaskell, TupleSections #-} --- | Defines functions for simultaneous interpretation of ExternalLibrary and +-- | Defines functions for simultaneous interpretation of ExternalLibrary and -- ExternalLibraryCall. -module Language.Drasil.Code.ExtLibImport (ExtLibState(..), auxMods, defs, +module Language.Drasil.Code.ExtLibImport (ExtLibState(..), auxMods, defs, imports, modExports, steps, genExternalLibraryCall) where import Language.Drasil (HasSpace(typ), getActorName) -import Language.Drasil.Chunk.Code (CodeVarChunk, CodeFuncChunk, codeName, +import Language.Drasil.Chunk.Code (CodeVarChunk, CodeFuncChunk, codeName, ccObjVar) import Language.Drasil.Chunk.Parameter (ParameterChunk) import Language.Drasil.Chunk.NamedArgument (NamedArgument) import Language.Drasil.CodeExpr (CodeExpr, ($&&), applyWithNamedArgs, msgWithNamedArgs, new, newWithNamedArgs, sy) -import Language.Drasil.Mod (Class, StateVariable, Func(..), Mod, Name, - Description, packmodRequires, classDef, classImplements, FuncStmt(..), +import Language.Drasil.Mod (Class, StateVariable, Func(..), Mod, Name, + Description, packmodRequires, classDef, classImplements, FuncStmt(..), funcDefParams, ctorDef) -import Language.Drasil.Code.ExternalLibrary (ExternalLibrary, Step(..), - FunctionInterface(..), Result(..), Argument(..), ArgumentInfo(..), +import Language.Drasil.Code.ExternalLibrary (ExternalLibrary, Step(..), + FunctionInterface(..), Result(..), Argument(..), ArgumentInfo(..), Parameter(..), ClassInfo(..), MethodInfo(..), FuncType(..)) import Language.Drasil.Code.ExternalLibraryCall (ExternalLibraryCall, StepGroupFill(..), StepFill(..), FunctionIntFill(..), ArgumentFill(..), @@ -30,22 +30,22 @@ import Data.List.NonEmpty (NonEmpty(..), (!!), toList) import Data.Maybe (isJust) import Prelude hiding ((!!)) --- | State object used during interpretation of an 'ExternalLibrary' and +-- | State object used during interpretation of an 'ExternalLibrary' and -- 'ExternalLibraryCall'. data ExtLibState = ELS { -- | Additional modules that must be generated to use the library. - _auxMods :: [Mod], - -- | The defining statements for variables that must be pre-defined before + _auxMods :: [Mod], + -- | The defining statements for variables that must be pre-defined before -- being passed as arguments in an external library call. _defs :: [FuncStmt], - -- | The names of variables for which a defining statement has already been - -- generated. - _defined :: [Name], + -- | The names of variables for which a defining statement has already been + -- generated. + _defined :: [Name], -- | The statements corresponding to the external library use case. _steps :: [FuncStmt], -- | The imports required to use the external library. _imports :: [String], - -- | An association list between library method/function names and the external + -- | An association list between library method/function names and the external -- library module that exports them. _modExports :: [(Name, Name)] } @@ -68,29 +68,29 @@ initELS = ELS { addMod :: Mod -> ExtLibState -> ExtLibState addMod m = over auxMods (m:) --- | Adds a defining statement for the given 'CodeVarChunk' and 'CodeExpr' to the --- 'ExtLibState' and adds the 'CodeVarChunk''s name to the defined field of the --- state, but only if it was not already in the defined field. +-- | Adds a defining statement for the given 'CodeVarChunk' and 'CodeExpr' to the +-- 'ExtLibState' and adds the 'CodeVarChunk''s name to the defined field of the +-- state, but only if it was not already in the defined field. addDef :: CodeExpr -> CodeVarChunk -> ExtLibState -> ExtLibState addDef e c s = if n `elem` (s ^. defined) then s else over defs (++ [FDecDef c e]) (addDefined n s) where n = codeName c --- | Adds a defining statement for a local function, represented by the given +-- | Adds a defining statement for a local function, represented by the given -- 'CodeFuncChunk', 'ParameterChunk's, and 'FuncStmt's, to the 'ExtLibState', and adds -- the function's name to the defined field, but only if it was not already in -- the defined field. -addFuncDef :: CodeFuncChunk -> [ParameterChunk] -> [FuncStmt] -> ExtLibState -> +addFuncDef :: CodeFuncChunk -> [ParameterChunk] -> [FuncStmt] -> ExtLibState -> ExtLibState -addFuncDef c ps b s = if n `elem` (s ^. defined) then s else over defs +addFuncDef c ps b s = if n `elem` (s ^. defined) then s else over defs (++ [FFuncDef c ps b]) (addDefined n s) where n = codeName c --- | Adds to the 'ExtLibState' statements for initializing fields, represented by --- the list of 'CodeVarChunk', of a record, represented by the 'CodeVarChunk', with +-- | Adds to the 'ExtLibState' statements for initializing fields, represented by +-- the list of 'CodeVarChunk', of a record, represented by the 'CodeVarChunk', with -- values, represented by the list of 'CodeExpr'. -addFieldAsgs :: CodeVarChunk -> [CodeVarChunk] -> [CodeExpr] -> ExtLibState -> +addFieldAsgs :: CodeVarChunk -> [CodeVarChunk] -> [CodeExpr] -> ExtLibState -> ExtLibState addFieldAsgs o cs es = over defs (++ zipWith FAsg (map (ccObjVar o) cs) es) @@ -102,7 +102,7 @@ addDefined n = over defined (n:) addImports :: [String] -> ExtLibState -> ExtLibState addImports is = over imports (\l -> nub $ l ++ is) --- | Adds to the 'ExtLibState' an association between a library function/method and +-- | Adds to the 'ExtLibState' an association between a library function/method and -- the library's module that exports it. addModExport :: (Name, Name) -> ExtLibState -> ExtLibState addModExport e = over modExports (e:) @@ -117,15 +117,15 @@ refreshLocal s = s {_defs = [], _defined = [], _imports = []} -- | Returns fields of 'ExtLibState' that are local to each module to a previous state. returnLocal :: ExtLibState -> ExtLibState -> ExtLibState -returnLocal oldS newS = newS {_defs = oldS ^. defs, - _defined = oldS ^. defined, +returnLocal oldS newS = newS {_defs = oldS ^. defs, + _defined = oldS ^. defined, _imports = oldS ^. imports} -- Generators --- | Interprets an 'ExternalLibrary' and 'ExternalLibraryCall' and returns the +-- | Interprets an 'ExternalLibrary' and 'ExternalLibraryCall' and returns the -- resulting 'ExtLibState'. -genExternalLibraryCall :: ExternalLibrary -> ExternalLibraryCall -> +genExternalLibraryCall :: ExternalLibrary -> ExternalLibraryCall -> ExtLibState genExternalLibraryCall el elc = execState (genExtLibCall el elc) initELS @@ -134,7 +134,7 @@ genExternalLibraryCall el elc = execState (genExtLibCall el elc) initELS genExtLibCall :: ExternalLibrary -> ExternalLibraryCall -> State ExtLibState () genExtLibCall [] [] = return () -genExtLibCall (sg:el) (SGF n sgf:elc) = let s = sg!!n in +genExtLibCall (sg:el) (SGF n sgf:elc) = let s = sg!!n in if length s /= length sgf then error stepNumberMismatch else do fs <- zipWithM genStep s sgf modify (addSteps fs) @@ -151,9 +151,9 @@ genStep (Loop fis f ss) (LoopF fifs ccList sfs) = do genStep (Statement f) (StatementF ccList exList) = return $ f ccList exList genStep _ _ = error stepTypeMismatch --- | Interprets a 'FunctionInterface' and 'FunctionIntFill', resulting in a 'CodeExpr' --- representing a call to the library. Imports required for the call are added --- to the 'ExtLibState', and the called function/method is added to the library +-- | Interprets a 'FunctionInterface' and 'FunctionIntFill', resulting in a 'CodeExpr' +-- representing a call to the library. Imports required for the call are added +-- to the 'ExtLibState', and the called function/method is added to the library -- export association list in the 'ExtLibState'. genFIVal :: FunctionInterface -> FunctionIntFill -> State ExtLibState CodeExpr genFIVal (FI (r:|rs) ft f as _) (FIF afs) = do @@ -161,26 +161,26 @@ genFIVal (FI (r:|rs) ft f as _) (FIF afs) = do let isNamed = isJust . fst (nas, ars) = partition isNamed args modify (addImports rs . addModExport (codeName f, r)) - return $ getCallFunc ft f (map snd ars) (map (\(n, e) -> - maybe (error "defective isNamed") (,e) n) nas) - where getCallFunc Function = applyWithNamedArgs - getCallFunc (Method o) = msgWithNamedArgs o + return $ getCallFunc ft f (map snd ars) (map (\(n, e) -> + maybe (error "defective isNamed") (,e) n) nas) + where getCallFunc Function = applyWithNamedArgs + getCallFunc (Method o) = msgWithNamedArgs o getCallFunc Constructor = newWithNamedArgs --- | Interprets a 'FunctionInterface' and 'FunctionIntFill', resulting in a 'FuncStmt' +-- | Interprets a 'FunctionInterface' and 'FunctionIntFill', resulting in a 'FuncStmt' -- for the function/method call. genFI :: FunctionInterface -> FunctionIntFill -> State ExtLibState FuncStmt genFI fi@(FI _ _ _ _ r) fif = do fiEx <- genFIVal fi fif - return $ maybeGenAssg r fiEx + return $ maybeGenAssg r fiEx --- | Interprets a list of 'Argument' and list of 'ArgumentFill', returning the 'CodeExpr' +-- | Interprets a list of 'Argument' and list of 'ArgumentFill', returning the 'CodeExpr' -- for each argument and the 'NamedArgument' chunk for arguments that are named. -genArguments :: [Argument] -> [ArgumentFill] -> +genArguments :: [Argument] -> [ArgumentFill] -> State ExtLibState [(Maybe NamedArgument, CodeExpr)] genArguments (Arg n (LockedArg e):as) afs = fmap ((n,e):) (genArguments as afs) genArguments as (UserDefinedArgF n e:afs) = fmap ((n,e):) (genArguments as afs) -genArguments (Arg n (Basic _ Nothing):as) (BasicF e:afs) = fmap ((n,e):) +genArguments (Arg n (Basic _ Nothing):as) (BasicF e:afs) = fmap ((n,e):) (genArguments as afs) genArguments (Arg n (Basic _ (Just v)):as) (BasicF e:afs) = do modify (addDef e v) @@ -195,43 +195,43 @@ genArguments (Arg n (Class rs desc o ctor ci):as) (ClassF svs cif:afs) = do modify (addMod (packmodRequires an desc (rs ++ is) [c] [])) fmap ((n, sy o):) (genArguments as afs) where an = getActorName (o ^. typ) -genArguments (Arg n (Record (rq:|rqs) rn r fs):as) (RecordF es:afs) = +genArguments (Arg n (Record (rq:|rqs) rn r fs):as) (RecordF es:afs) = if length fs /= length es then error recordFieldsMismatch else do - modify (addFieldAsgs r fs es . addDef (new rn []) r . + modify (addFieldAsgs r fs es . addDef (new rn []) r . addModExport (codeName rn, rq) . addImports rqs) fmap ((n, sy r):) (genArguments as afs) genArguments [] [] = return [] genArguments _ _ = error argumentMismatch - --- | Interprets a 'ClassInfo' and 'ClassInfoFill'. These are required when a --- 'customObjArg' is needed for an external library call, so the 'CodeVarChunk' --- parameter represents the object of the class. The 'CodeFuncChunk' represents --- the class's constructor. Other parameters are the name, description, and + +-- | Interprets a 'ClassInfo' and 'ClassInfoFill'. These are required when a +-- 'customObjArg' is needed for an external library call, so the 'CodeVarChunk' +-- parameter represents the object of the class. The 'CodeFuncChunk' represents +-- the class's constructor. Other parameters are the name, description, and -- state variables for the class. -genClassInfo :: CodeVarChunk -> CodeFuncChunk -> Name -> Description -> - [StateVariable] -> ClassInfo -> ClassInfoFill -> +genClassInfo :: CodeVarChunk -> CodeFuncChunk -> Name -> Description -> + [StateVariable] -> ClassInfo -> ClassInfoFill -> State ExtLibState (Class, [String]) -genClassInfo o c n desc svs ci cif = let (mis, mifs, f) = genCI ci cif in +genClassInfo o c n desc svs ci cif = let (mis, mifs, f) = genCI ci cif in if length mis /= length mifs then error methodInfoNumberMismatch else do ms <- zipWithM (genMethodInfo o c) mis mifs modify (if any isConstructor mis then id else addDef (new c []) o) return (f desc svs (map fst ms), concatMap snd ms) where genCI (Regular mis') (RegularF mifs') = (mis', mifs', classDef n) - genCI (Implements intn mis') (ImplementsF mifs') = (mis', mifs', + genCI (Implements intn mis') (ImplementsF mifs') = (mis', mifs', classImplements n intn) genCI _ _ = error classInfoMismatch --- | Interprets a 'MethodInfo' and 'MethodInfoFill'. These are required when a --- 'customObjArg' is needed for an external library call, so the 'CodeVarChunk' --- parameter represents the object of the class. The 'CodeFuncChunk' represents +-- | Interprets a 'MethodInfo' and 'MethodInfoFill'. These are required when a +-- 'customObjArg' is needed for an external library call, so the 'CodeVarChunk' +-- parameter represents the object of the class. The 'CodeFuncChunk' represents -- the class's constructor. -genMethodInfo :: CodeVarChunk -> CodeFuncChunk -> MethodInfo -> +genMethodInfo :: CodeVarChunk -> CodeFuncChunk -> MethodInfo -> MethodInfoFill -> State ExtLibState (Func, [String]) genMethodInfo o c (CI desc ps ss) (CIF pfs is sfs) = do let prms = genParameters ps pfs (fs, newS) <- withLocalState $ zipWithM genStep ss sfs modify (addDef (new c (map sy prms)) o) - return (ctorDef (codeName c) desc prms is (newS ^. defs ++ fs), + return (ctorDef (codeName c) desc prms is (newS ^. defs ++ fs), newS ^. imports) genMethodInfo _ _ (MI m desc ps rDesc ss) (MIF pfs sfs) = do let prms = genParameters ps pfs @@ -240,19 +240,19 @@ genMethodInfo _ _ (MI m desc ps rDesc ss) (MIF pfs sfs) = do newS ^. defs ++ fs), newS ^. imports) genMethodInfo _ _ _ _ = error methodInfoMismatch --- | Interprets a list of 'Parameter' and a list of 'ParameterFill', resulting in +-- | Interprets a list of 'Parameter' and a list of 'ParameterFill', resulting in -- 'ParameterChunk's. genParameters :: [Parameter] -> [ParameterFill] -> [ParameterChunk] genParameters (LockedParam c:ps) pfs = c : genParameters ps pfs genParameters ps (UserDefined c:pfs) = c : genParameters ps pfs -genParameters (NameableParam _:ps) (NameableParamF c:pfs) = c : +genParameters (NameableParam _:ps) (NameableParamF c:pfs) = c : genParameters ps pfs genParameters [] [] = [] genParameters _ _ = error paramMismatch --- | Interprets a 'Result', which determines which 'FuncStmt' constructor should be --- used for a defining statement. If no result, the statement is just the value --- for the function call. If result is assigned, the statement is an +-- | Interprets a 'Result', which determines which 'FuncStmt' constructor should be +-- used for a defining statement. If no result, the statement is just the value +-- for the function call. If result is assigned, the statement is an -- assignment. If the result is returned, the statement is a return statement. maybeGenAssg :: Maybe Result -> (CodeExpr -> FuncStmt) maybeGenAssg Nothing = FVal @@ -278,8 +278,8 @@ isConstructor _ = False -- Error messages -- | Various error messages. -elAndElc, stepNumberMismatch, stepTypeMismatch, argumentMismatch, - paramMismatch, recordFieldsMismatch, ciAndCif, classInfoMismatch, +elAndElc, stepNumberMismatch, stepTypeMismatch, argumentMismatch, + paramMismatch, recordFieldsMismatch, ciAndCif, classInfoMismatch, methodInfoNumberMismatch, methodInfoMismatch :: String elAndElc = "ExternalLibrary and ExternalLibraryCall have different " stepNumberMismatch = elAndElc ++ "number of steps" @@ -290,4 +290,4 @@ recordFieldsMismatch = "Different number of record fields than field values" ciAndCif = "ClassInfo and ClassInfoFill have different " classInfoMismatch = ciAndCif ++ "class types" methodInfoNumberMismatch = ciAndCif ++ "number of MethodInfos/MethodInfoFills" -methodInfoMismatch = "MethodInfo and MethodInfoFill have different method types" \ No newline at end of file +methodInfoMismatch = "MethodInfo and MethodInfoFill have different method types" diff --git a/code/drasil-code/lib/Language/Drasil/Code/ExternalLibrary.hs b/code/drasil-code/lib/Language/Drasil/Code/ExternalLibrary.hs index 6a38c77136..d125d6cad5 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/ExternalLibrary.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/ExternalLibrary.hs @@ -1,16 +1,16 @@ {-# LANGUAGE LambdaCase #-} -- | Defines a language for specifying external library use scenarios -module Language.Drasil.Code.ExternalLibrary (ExternalLibrary, Step(..), - FunctionInterface(..), Result(..), Argument(..), ArgumentInfo(..), - Parameter(..), ClassInfo(..), MethodInfo(..), FuncType(..), externalLib, - choiceSteps, choiceStep, mandatoryStep, mandatorySteps, callStep, - libFunction, libMethod, libFunctionWithResult, libMethodWithResult, - libConstructor, libConstructorMultiReqs, constructAndReturn, lockedArg, - lockedNamedArg, inlineArg, inlineNamedArg, preDefinedArg, preDefinedNamedArg, - functionArg, customObjArg, recordArg, lockedParam, unnamedParam, customClass, - implementation, constructorInfo, methodInfo, methodInfoNoReturn, - appendCurrSol, populateSolList, assignArrayIndex, assignSolFromObj, - initSolListFromArray, initSolListWithVal, solveAndPopulateWhile, +module Language.Drasil.Code.ExternalLibrary (ExternalLibrary, Step(..), + FunctionInterface(..), Result(..), Argument(..), ArgumentInfo(..), + Parameter(..), ClassInfo(..), MethodInfo(..), FuncType(..), externalLib, + choiceSteps, choiceStep, mandatoryStep, mandatorySteps, callStep, + libFunction, libMethod, libFunctionWithResult, libMethodWithResult, + libConstructor, libConstructorMultiReqs, constructAndReturn, lockedArg, + lockedNamedArg, inlineArg, inlineNamedArg, preDefinedArg, preDefinedNamedArg, + functionArg, customObjArg, recordArg, lockedParam, unnamedParam, customClass, + implementation, constructorInfo, methodInfo, methodInfoNoReturn, + appendCurrSol, populateSolList, assignArrayIndex, assignSolFromObj, + initSolListFromArray, initSolListWithVal, solveAndPopulateWhile, returnExprList, fixedReturn, fixedReturn', initSolWithVal ) where @@ -38,7 +38,7 @@ type ExternalLibrary = [StepGroup] type StepGroup = NonEmpty [Step] -- | A step can be a call to an external library function or method. -data Step = Call FunctionInterface +data Step = Call FunctionInterface -- | A while loop. -- The function calls in the condition, other conditions, and steps for the body of the loop. | Loop (NonEmpty FunctionInterface) ([CodeExpr] -> Condition) (NonEmpty Step) @@ -55,21 +55,21 @@ data Result = Assign CodeVarChunk | Return data Argument = Arg (Maybe NamedArgument) ArgumentInfo -- Maybe named argument -- | Determines the context needed for an argument to work. -data ArgumentInfo = +data ArgumentInfo = -- | An argument not dependent on use case. - LockedArg CodeExpr + LockedArg CodeExpr -- | An argument dependent on the use case. Maybe is the variable if it needs -- to be declared and defined prior to calling. - | Basic Space (Maybe CodeVarChunk) + | Basic Space (Maybe CodeVarChunk) -- | A function-type argument, with a single 'Step' for the body. | Fn CodeFuncChunk [Parameter] Step - -- | An argument that is an object of a class that must be implemented in the + -- | An argument that is an object of a class that must be implemented in the -- calling program. -- Parameters: Requires, description, object, constructor, class info. | Class [Requires] Description CodeVarChunk CodeFuncChunk ClassInfo -- | An argument that is an object of a record class defined by the external -- library, where some fields need to be set by the calling program. - -- Parameters: Requires, constructor, object, fields. + -- Parameters: Requires, constructor, object, fields. -- First Require should be where the record type is defined. | Record (NonEmpty Requires) CodeFuncChunk CodeVarChunk [CodeVarChunk] @@ -93,13 +93,13 @@ data FuncType = Function | Method CodeVarChunk | Constructor externalLib :: [StepGroup] -> ExternalLibrary externalLib = id --- | To be used when there are multiple options for a group of consecutive steps, +-- | To be used when there are multiple options for a group of consecutive steps, -- where a single use-case-specific factor decides which step group to use. choiceSteps :: [[Step]] -> StepGroup choiceSteps [] = error "choiceSteps should be called with a non-empty list" choiceSteps sg = fromList sg --- | To be used when there are multiple options for a single step, where a +-- | To be used when there are multiple options for a single step, where a -- use-case-specific factor decides which step to use. choiceStep :: [Step] -> StepGroup choiceStep [] = error "choiceStep should be called with a non-empty list" @@ -109,7 +109,7 @@ choiceStep ss = fromList $ map (: []) ss mandatoryStep :: Step -> StepGroup mandatoryStep f = [f] :| [] --- | Specifies multiple consecutive steps that all must exist in some form in +-- | Specifies multiple consecutive steps that all must exist in some form in -- every use case. mandatorySteps :: [Step] -> StepGroup mandatorySteps fs = fs :| [] @@ -118,7 +118,7 @@ mandatorySteps fs = fs :| [] callStep :: FunctionInterface -> Step callStep = Call --- | Specifies a step where an external library function or method is called in a +-- | Specifies a step where an external library function or method is called in a -- while-loop condition and in the loop body. loopStep :: [FunctionInterface] -> ([CodeExpr] -> Condition) -> [Step] -> Step loopStep [] _ _ = error "loopStep should be called with a non-empty list of FunctionInterface" @@ -130,39 +130,39 @@ libFunction :: Requires -> CodeFuncChunk -> [Argument] -> FunctionInterface libFunction rq f ps = FI (rq :| []) Function f ps Nothing -- | Specifies a call to an external library method. -libMethod :: Requires -> CodeVarChunk -> CodeFuncChunk -> [Argument] -> +libMethod :: Requires -> CodeVarChunk -> CodeFuncChunk -> [Argument] -> FunctionInterface libMethod rq o m ps = FI (rq :| []) (Method o) m ps Nothing --- | Specifies a call to an external library function, where the result is +-- | Specifies a call to an external library function, where the result is -- assigned to a variable. -libFunctionWithResult :: Requires -> CodeFuncChunk -> [Argument] -> +libFunctionWithResult :: Requires -> CodeFuncChunk -> [Argument] -> CodeVarChunk -> FunctionInterface libFunctionWithResult rq f ps r = FI (rq :| []) Function f ps (Just $ Assign r) --- | Specifies a call to an external library method, where the result is +-- | Specifies a call to an external library method, where the result is -- assigned to a variable. -libMethodWithResult :: Requires -> CodeVarChunk -> CodeFuncChunk -> [Argument] +libMethodWithResult :: Requires -> CodeVarChunk -> CodeFuncChunk -> [Argument] -> CodeVarChunk -> FunctionInterface libMethodWithResult rq o m ps r = FI (rq :| []) (Method o) m ps (Just $ Assign r) --- | Specifies a call to an external library constructor, where the result is +-- | Specifies a call to an external library constructor, where the result is -- assigned to a variable. -libConstructor :: Requires -> CodeFuncChunk -> [Argument] -> CodeVarChunk -> +libConstructor :: Requires -> CodeFuncChunk -> [Argument] -> CodeVarChunk -> FunctionInterface libConstructor rq c as r = FI (rq :| []) Constructor c as (Just $ Assign r) -- | Specifies a call to an external library function, where multiple modules from -- the external library are required, and the result is assigned to a variable. -libConstructorMultiReqs :: [Requires] -> CodeFuncChunk -> [Argument] -> +libConstructorMultiReqs :: [Requires] -> CodeFuncChunk -> [Argument] -> CodeVarChunk -> FunctionInterface libConstructorMultiReqs [] _ _ _ = error $ "libConstructorMultiReqs should" ++ " be called with a non-empty list of Requires" -libConstructorMultiReqs rqs c as r = FI (fromList rqs) Constructor c as +libConstructorMultiReqs rqs c as r = FI (fromList rqs) Constructor c as (Just $ Assign r) -- | Specifies a call to an external library constructor, where the result is returned. -constructAndReturn :: Requires -> CodeFuncChunk -> [Argument] -> +constructAndReturn :: Requires -> CodeFuncChunk -> [Argument] -> FunctionInterface constructAndReturn rq c as = FI (rq :| []) Constructor c as (Just Return) @@ -174,22 +174,22 @@ lockedArg = Arg Nothing . LockedArg lockedNamedArg :: NamedArgument -> CodeExpr -> Argument lockedNamedArg n = Arg (Just n) . LockedArg --- | Specifies a use-case-dependent argument whose value can be inlined in the +-- | Specifies a use-case-dependent argument whose value can be inlined in the -- call. inlineArg :: Space -> Argument inlineArg t = Arg Nothing $ Basic t Nothing --- | Specifies a use-case-dependent named argument whose value can be inlined in +-- | Specifies a use-case-dependent named argument whose value can be inlined in -- the call. inlineNamedArg :: NamedArgument -> Space -> Argument inlineNamedArg n t = Arg (Just n) $ Basic t Nothing --- | Specifies use-case-dependent argument whose value must be assigned to a +-- | Specifies use-case-dependent argument whose value must be assigned to a -- variable before being passed in the call. preDefinedArg :: CodeVarChunk -> Argument preDefinedArg v = Arg Nothing $ Basic (v ^. typ) (Just v) --- | Specifies use-case-dependent named argument whose value must be assigned to +-- | Specifies use-case-dependent named argument whose value must be assigned to -- a variable before being passed in the call. preDefinedNamedArg :: NamedArgument -> CodeVarChunk -> Argument preDefinedNamedArg n v = Arg (Just n) $ Basic (v ^. typ) (Just v) @@ -198,16 +198,16 @@ preDefinedNamedArg n v = Arg (Just n) $ Basic (v ^. typ) (Just v) functionArg :: CodeFuncChunk -> [Parameter] -> Step -> Argument functionArg f ps b = Arg Nothing (Fn f ps b) --- | Specifies an argument that is an object of a class that must be defined in +-- | Specifies an argument that is an object of a class that must be defined in -- the calling program. -customObjArg :: [Requires] -> Description -> CodeVarChunk -> CodeFuncChunk -> +customObjArg :: [Requires] -> Description -> CodeVarChunk -> CodeFuncChunk -> ClassInfo -> Argument customObjArg rs d o c ci = Arg Nothing (Class rs d o c ci) -- | Specifies an argument that is an object of a class from the external library. --- The list of [CodeVarChunk] represents fields of the object that must be set +-- The list of [CodeVarChunk] represents fields of the object that must be set -- in the calling program. -recordArg :: Requires -> CodeFuncChunk -> CodeVarChunk -> [CodeVarChunk] -> +recordArg :: Requires -> CodeFuncChunk -> CodeVarChunk -> [CodeVarChunk] -> Argument recordArg rq c o fs = Arg Nothing (Record (rq :| []) c o fs) @@ -232,13 +232,13 @@ constructorInfo :: CodeFuncChunk -> [Parameter] -> [Step] -> MethodInfo constructorInfo c = CI ("Constructor for " ++ codeName c ++ " objects") -- | Specifies a method. -methodInfo :: CodeFuncChunk -> Description -> [Parameter] -> Description -> +methodInfo :: CodeFuncChunk -> Description -> [Parameter] -> Description -> [Step] -> MethodInfo methodInfo _ _ _ _ [] = error "methodInfo should be called with a non-empty list of Step" methodInfo m d ps rd ss = MI m d ps (Just rd) (fromList ss) -- | Specifies a method that does not return anything. -methodInfoNoReturn :: CodeFuncChunk -> Description -> [Parameter] -> [Step] -> +methodInfoNoReturn :: CodeFuncChunk -> Description -> [Parameter] -> [Step] -> MethodInfo methodInfoNoReturn _ _ _ [] = error "methodInfoNoReturn should be called with a non-empty list of Step" methodInfoNoReturn m d ps ss = MI m d ps Nothing (fromList ss) @@ -249,7 +249,7 @@ appendCurrSol curr = statementStep (\cdchs es -> case (cdchs, es) of ([s], []) -> appendCurrSolFS curr s (_,_) -> error "Fill for appendCurrSol should provide one CodeChunk and no Exprs") --- | Specifies a statement where a solution list is populated by iterating +-- | Specifies a statement where a solution list is populated by iterating -- through a solution array. populateSolList :: CodeVarChunk -> CodeVarChunk -> CodeVarChunk -> [Step] populateSolList arr el fld = [statementStep (\cdchs es -> case (cdchs, es) of @@ -266,14 +266,14 @@ assignArrayIndex = statementStep (\cdchs es -> case (cdchs, es) of ([a],vs) -> FMulti $ zipWith (FAsgIndex a) [0..] vs (_,_) -> error "Fill for assignArrayIndex should provide one CodeChunk") --- | Specifies a statement where a solution is assigned from the field of an +-- | Specifies a statement where a solution is assigned from the field of an -- object. assignSolFromObj :: CodeVarChunk -> Step assignSolFromObj o = statementStep (\cdchs es -> case (cdchs, es) of ([s],[]) -> FAsg s (field o s) (_,_) -> error "Fill for assignSolFromObj should provide one CodeChunk and no Exprs") --- | Specifies a statement where a solution list is initialized with the first +-- | Specifies a statement where a solution list is initialized with the first -- element of an array. initSolListFromArray :: CodeVarChunk -> Step initSolListFromArray a = statementStep (\cdchs es -> case (cdchs, es) of @@ -286,14 +286,14 @@ initSolListWithVal = statementStep (\cdchs es -> case (cdchs, es) of ([s],[v]) -> FDecDef s (matrix [[idx v (int 0)]]) (_,_) -> error "Fill for initSolListWithVal should provide one CodeChunk and one Expr") --- | A solve and populate loop. 'FunctionInterface' for loop condition, 'CodeChunk' for solution object, --- 'CodeChunk' for independent var, 'FunctionInterface' for solving, +-- | A solve and populate loop. 'FunctionInterface' for loop condition, 'CodeChunk' for solution object, +-- 'CodeChunk' for independent var, 'FunctionInterface' for solving, -- 'CodeChunk' for soln array to populate with. -solveAndPopulateWhile :: FunctionInterface -> CodeVarChunk -> CodeVarChunk -> +solveAndPopulateWhile :: FunctionInterface -> CodeVarChunk -> CodeVarChunk -> FunctionInterface -> CodeVarChunk -> Step -solveAndPopulateWhile lc ob iv slv popArr = loopStep [lc] (\case +solveAndPopulateWhile lc ob iv slv popArr = loopStep [lc] (\case [ub] -> field ob iv $< ub - _ -> error "Fill for solveAndPopulateWhile should provide one Expr") + _ -> error "Fill for solveAndPopulateWhile should provide one Expr") [callStep slv, appendCurrSol (field ob popArr)] -- | Specifies a statement where a list is returned, where each value of the list diff --git a/code/drasil-code/lib/Language/Drasil/Code/ExternalLibraryCall.hs b/code/drasil-code/lib/Language/Drasil/Code/ExternalLibraryCall.hs index de9a48a1df..7816cdf823 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/ExternalLibraryCall.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/ExternalLibraryCall.hs @@ -1,14 +1,14 @@ -- | Defines an AST to be paired with an ExternalLibrary for a specific use-case module Language.Drasil.Code.ExternalLibraryCall (ExternalLibraryCall, StepGroupFill(..), StepFill(..), FunctionIntFill(..), ArgumentFill(..), - ParameterFill(..), ClassInfoFill(..), MethodInfoFill(..), externalLibCall, - choiceStepsFill, choiceStepFill, mandatoryStepFill, mandatoryStepsFill, - callStepFill, libCallFill, userDefinedArgFill, basicArgFill, functionArgFill, - customObjArgFill, recordArgFill, unnamedParamFill, unnamedParamPBVFill, - userDefinedParamFill, customClassFill, implementationFill, - constructorInfoFill, methodInfoFill, appendCurrSolFill, populateSolListFill, - assignArrayIndexFill, assignSolFromObjFill, initSolListFromArrayFill, - initSolListWithValFill, solveAndPopulateWhileFill, returnExprListFill, + ParameterFill(..), ClassInfoFill(..), MethodInfoFill(..), externalLibCall, + choiceStepsFill, choiceStepFill, mandatoryStepFill, mandatoryStepsFill, + callStepFill, libCallFill, userDefinedArgFill, basicArgFill, functionArgFill, + customObjArgFill, recordArgFill, unnamedParamFill, unnamedParamPBVFill, + userDefinedParamFill, customClassFill, implementationFill, + constructorInfoFill, methodInfoFill, appendCurrSolFill, populateSolListFill, + assignArrayIndexFill, assignSolFromObjFill, initSolListFromArrayFill, + initSolListWithValFill, solveAndPopulateWhileFill, returnExprListFill, fixedStatementFill, fixedStatementFill', initSolWithValFill ) where @@ -23,13 +23,13 @@ import Data.List.NonEmpty (NonEmpty(..), fromList) -- | External library call holds a group of step groups. type ExternalLibraryCall = [StepGroupFill] --- Convention is to end types with "Fill" because they fill in the use-case +-- Convention is to end types with "Fill" because they fill in the use-case -- specific information for an ExternalLibrary -- This AST mirrors the ExternalLibrary AST by intention. -- | Holds a group of steps ('StepFill's). The -- Int is to "choose" from the options in 'ExternalLibrary'. -data StepGroupFill = SGF Int [StepFill] +data StepGroupFill = SGF Int [StepFill] -- | Mirrors ExternalLibrary's 'Step'. A StepFill can be a call to an external library function or method. data StepFill = CallF FunctionIntFill @@ -59,12 +59,12 @@ data MethodInfoFill = CIF [ParameterFill] [Initializer] [StepFill] externalLibCall :: [StepGroupFill] -> ExternalLibraryCall externalLibCall = id --- | Corresponds to ExternalLibrary's 'choiceSteps'. Provides the index of the +-- | Corresponds to ExternalLibrary's 'choiceSteps'. Provides the index of the -- steps that should be used for the current use case. choiceStepsFill :: Int -> [StepFill] -> StepGroupFill choiceStepsFill = SGF --- | Corresponds to ExternalLibrary's 'choiceStep'. Provides the index of the +-- | Corresponds to ExternalLibrary's 'choiceStep'. Provides the index of the -- step that should be used for the current use case. choiceStepFill :: Int -> StepFill -> StepGroupFill choiceStepFill i s = SGF i [s] @@ -91,41 +91,41 @@ loopStepFill fifs cdchs sfs = LoopF (fromList fifs) cdchs (fromList sfs) libCallFill :: [ArgumentFill] -> FunctionIntFill libCallFill = FIF --- | Does not correspond to anything in ExternalLibrary. To be used when the +-- | Does not correspond to anything in ExternalLibrary. To be used when the -- presence of an argument is only a consequence of the use case. userDefinedArgFill :: CodeExpr -> ArgumentFill userDefinedArgFill = UserDefinedArgF Nothing --- | Corresponds to ExternalLibrary's 'inlineArg', 'inlineNamedArg', 'preDefinedArg', +-- | Corresponds to ExternalLibrary's 'inlineArg', 'inlineNamedArg', 'preDefinedArg', -- and 'preDefinedNamedArg'. Provides the 'CodeExpr' for the argument's value. basicArgFill :: CodeExpr -> ArgumentFill basicArgFill = BasicF --- | Corresponds to ExternalLibrary's 'functionArg'. +-- | Corresponds to ExternalLibrary's 'functionArg'. functionArgFill :: [ParameterFill] -> StepFill -> ArgumentFill functionArgFill = FnF --- | Corresponds to ExternalLibrary's 'customObjArg'. Provides the list of state +-- | Corresponds to ExternalLibrary's 'customObjArg'. Provides the list of state -- variables for the class that must be written in the calling program. customObjArgFill :: [StateVariable] -> ClassInfoFill -> ArgumentFill customObjArgFill = ClassF --- | Corresponds to ExternalLibrary's 'recordArg'. Provides the list of 'CodeExpr's for +-- | Corresponds to ExternalLibrary's 'recordArg'. Provides the list of 'CodeExpr's for -- the values of the fields that must be set by the calling program. recordArgFill :: [CodeExpr] -> ArgumentFill recordArgFill = RecordF --- | Corresponds to ExternalLibrary's 'unnamedParam'. Provides the 'CodeVarChunk' +-- | Corresponds to ExternalLibrary's 'unnamedParam'. Provides the 'CodeVarChunk' -- representing the parameter. unnamedParamFill :: CodeVarChunk -> ParameterFill unnamedParamFill = NameableParamF . pcAuto --- | Corresponds to ExternalLibrary's 'unnamedParam'. Provides the 'CodeVarChunk' +-- | Corresponds to ExternalLibrary's 'unnamedParam'. Provides the 'CodeVarChunk' -- representing the parameter. Specifies that the parameter is passed by value. unnamedParamPBVFill :: CodeVarChunk -> ParameterFill unnamedParamPBVFill = NameableParamF . pcVal --- | Does not correspond to anything in ExternalLibrary. To be used when the +-- | Does not correspond to anything in ExternalLibrary. To be used when the -- presence of a parameter is only a consequence of the use case. userDefinedParamFill :: CodeVarChunk -> ParameterFill userDefinedParamFill = UserDefined . pcAuto @@ -138,9 +138,9 @@ customClassFill = RegularF implementationFill :: [MethodInfoFill] -> ClassInfoFill implementationFill = ImplementsF --- | Corresponds to ExternalLibrary's 'constructorInfo'. Provides Variable-Value +-- | Corresponds to ExternalLibrary's 'constructorInfo'. Provides Variable-Value -- pairs for variables initialized by the constructor. -constructorInfoFill :: [ParameterFill] -> [Initializer] -> [StepFill] -> +constructorInfoFill :: [ParameterFill] -> [Initializer] -> [StepFill] -> MethodInfoFill constructorInfoFill = CIF @@ -149,7 +149,7 @@ methodInfoFill :: [ParameterFill] -> [StepFill] -> MethodInfoFill methodInfoFill _ [] = error "methodInfoFill should be called with non-empty list of StepFill" methodInfoFill pfs sfs = MIF pfs (fromList sfs) --- | Corresponds to ExternalLibrary's 'appendCurrSol'. Provides the 'CodeVarChunk' +-- | Corresponds to ExternalLibrary's 'appendCurrSol'. Provides the 'CodeVarChunk' -- for the solution list. appendCurrSolFill :: CodeVarChunk -> StepFill appendCurrSolFill s = statementStepFill [s] [] @@ -160,7 +160,7 @@ populateSolListFill :: CodeVarChunk -> [StepFill] populateSolListFill s = replicate 2 (statementStepFill [s] []) -- | Corresponds to ExternalLibrary's 'assignArrayIndex'. Provides the 'CodeVarChunk' --- for the array variable. Provides the 'CodeExpr's for the values to assign to each +-- for the array variable. Provides the 'CodeExpr's for the values to assign to each -- array index. assignArrayIndexFill :: CodeVarChunk-> [CodeExpr] -> StepFill assignArrayIndexFill a = statementStepFill [a] @@ -170,31 +170,31 @@ assignArrayIndexFill a = statementStepFill [a] assignSolFromObjFill :: CodeVarChunk -> StepFill assignSolFromObjFill s = statementStepFill [s] [] --- | Corresponds to ExternalLibrary's 'initSolListFromArray'. Provides the +-- | Corresponds to ExternalLibrary's 'initSolListFromArray'. Provides the -- 'CodeVarChunk' for the solution list. initSolListFromArrayFill :: CodeVarChunk -> StepFill initSolListFromArrayFill s = statementStepFill [s] [] --- | Corresponds to ExternalLibrary's 'initSolListWithVal'. Provides the --- 'CodeVarChunk' for the solution list and the 'CodeExpr' for the initial element of +-- | Corresponds to ExternalLibrary's 'initSolListWithVal'. Provides the +-- 'CodeVarChunk' for the solution list and the 'CodeExpr' for the initial element of -- the solution list initSolListWithValFill :: CodeVarChunk -> CodeExpr -> StepFill initSolListWithValFill s v = statementStepFill [s] [v] --- | Corresponds to ExternalLibrary's 'solveAndPopulateWhile'. Provides the 'CodeExpr' --- for the upper bound in the while loop condition and the 'CodeVarChunk' for the +-- | Corresponds to ExternalLibrary's 'solveAndPopulateWhile'. Provides the 'CodeExpr' +-- for the upper bound in the while loop condition and the 'CodeVarChunk' for the -- solution list. -solveAndPopulateWhileFill :: FunctionIntFill -> CodeExpr -> FunctionIntFill -> +solveAndPopulateWhileFill :: FunctionIntFill -> CodeExpr -> FunctionIntFill -> CodeVarChunk -> StepFill -solveAndPopulateWhileFill lcf ub slvf s = loopStepFill [lcf] [ub] +solveAndPopulateWhileFill lcf ub slvf s = loopStepFill [lcf] [ub] [callStepFill slvf, appendCurrSolFill s] --- | Corresponds to ExternalLibrary's 'returnExprList'. Provides the list of 'CodeExpr's +-- | Corresponds to ExternalLibrary's 'returnExprList'. Provides the list of 'CodeExpr's -- to return. returnExprListFill :: [CodeExpr] -> StepFill returnExprListFill = statementStepFill [] --- | Corresponds to ExternalLibrary's 'statementStep'. Provides the +-- | Corresponds to ExternalLibrary's 'statementStep'. Provides the -- use-case-specific 'CodeVarChunk's and 'CodeExpr's that parameterize the statement. statementStepFill :: [CodeVarChunk] -> [CodeExpr] -> StepFill statementStepFill = StatementF @@ -209,8 +209,8 @@ fixedStatementFill = StatementF [] [] fixedStatementFill' :: CodeExpr -> StepFill fixedStatementFill' a = StatementF [] [a] --- | Corresponds to ExternalLibrary's 'initSolWithVal'. Provides the --- 'CodeVarChunk' for one solution and one 'CodeExpr' for the initial element of +-- | Corresponds to ExternalLibrary's 'initSolWithVal'. Provides the +-- 'CodeVarChunk' for one solution and one 'CodeExpr' for the initial element of -- the solution list initSolWithValFill :: CodeVarChunk -> CodeExpr -> StepFill -initSolWithValFill s v = statementStepFill [s] [v] \ No newline at end of file +initSolWithValFill s v = statementStepFill [s] [v] diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Build/AST.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Build/AST.hs index 73be8efac3..bfdf4b2f8d 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Build/AST.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Build/AST.hs @@ -20,11 +20,11 @@ data BuildDependencies = BcSource | BcSingle BuildName -- | Build configuration. In the function parameter, the first parameter is the list of inputs, --- 2nd parameter is the output file, 3rd parameter is additional name if needed. +-- 2nd parameter is the output file, 3rd parameter is additional name if needed. -- The two 'Maybe' 'BuildName's are the output file and the additional name. -- Also holds the build dependencies. -data BuildConfig = BuildConfig - ([CommandFragment] -> CommandFragment -> CommandFragment -> [BuildCommand]) +data BuildConfig = BuildConfig + ([CommandFragment] -> CommandFragment -> CommandFragment -> [BuildCommand]) (Maybe BuildName) (Maybe BuildName) BuildDependencies -- | Run commands as they are or through an interpreter. @@ -66,30 +66,30 @@ osClassDefault :: String -> String -> String -> CommandFragment osClassDefault = mkWindowsVar -- | Constructor for a build configuration. No additional name included. -buildAll :: ([CommandFragment] -> CommandFragment -> [BuildCommand]) -> +buildAll :: ([CommandFragment] -> CommandFragment -> [BuildCommand]) -> BuildName -> Maybe BuildConfig buildAll f n = Just $ BuildConfig (\i o _ -> f i o) (Just n) Nothing BcSource -- | Constructor for a build configuration with an additional name included. -buildAllAdditionalName :: ([CommandFragment] -> CommandFragment -> - CommandFragment -> [BuildCommand]) -> BuildName -> BuildName -> +buildAllAdditionalName :: ([CommandFragment] -> CommandFragment -> + CommandFragment -> [BuildCommand]) -> BuildName -> BuildName -> Maybe BuildConfig buildAllAdditionalName f n a = Just $ BuildConfig f (Just n) (Just a) BcSource -- | Constructor for a build configuration. -- No additional name included, but takes in a single dependency. -buildSingle :: ([CommandFragment] -> CommandFragment -> [BuildCommand]) -> +buildSingle :: ([CommandFragment] -> CommandFragment -> [BuildCommand]) -> BuildName -> BuildName -> Maybe BuildConfig -buildSingle f n = Just . BuildConfig (\i o _ -> f i o) (Just n) Nothing . +buildSingle f n = Just . BuildConfig (\i o _ -> f i o) (Just n) Nothing . BcSingle --- | Default runnable information. +-- | Default runnable information. nativeBinary :: Maybe Runnable nativeBinary = Just $ Runnable executable nameOpts Standalone -- | Default target extension is ".exe". -executable :: BuildName -executable = BWithExt BPackName $ OtherExt $ +executable :: BuildName +executable = BWithExt BPackName $ OtherExt $ osClassDefault "TARGET_EXTENSION" ".exe" "" -- | Default library has the extentions ".dll, .dylib, .so". @@ -132,5 +132,5 @@ cppCompiler = mkImplicitVar "CXX" -- | Helper for configuring doxygen documentation. doxygenDocConfig :: FilePath -> DocConfig -doxygenDocConfig fp = DocConfig [makeS fp] - [mkCheckedCommand $ makeS $ "doxygen " ++ fp] \ No newline at end of file +doxygenDocConfig fp = DocConfig [makeS fp] + [mkCheckedCommand $ makeS $ "doxygen " ++ fp] diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Build/Import.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Build/Import.hs index 7976315594..8a2aef461e 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Build/Import.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Build/Import.hs @@ -9,7 +9,7 @@ import Language.Drasil.Code.Imperative.Build.AST (asFragment, DocConfig(..), import GOOL.Drasil (FileData(..), ProgData(..), GOOLState(..), headers, sources, mainMod) -import Build.Drasil ((+:+), genMake, makeS, MakeString, mkFile, mkRule, +import Build.Drasil (Annotation, (+:+), genMake, makeS, MakeString, mkFile, mkRule, mkCheckedCommand, mkFreeVar, RuleTransformer(makeRule)) import Control.Lens ((^.)) @@ -18,6 +18,7 @@ import Data.List (nub) import System.FilePath.Posix (takeExtension, takeBaseName) import Text.PrettyPrint.HughesPJ (Doc) import Utils.Drasil (capitalize) +import Metadata.Drasil.DrasilMetaCall (drasilMeta, DrasilMeta(..), watermark) -- | Holds all the needed information to run a program. data CodeHarness = Ch { @@ -29,14 +30,12 @@ data CodeHarness = Ch { -- | Transforms information in 'CodeHarness' into a list of Makefile rules. instance RuleTransformer CodeHarness where - makeRule (Ch b r s m d) = maybe [mkRule ["Project Name: " ++ progName m, - progPurpAdd m] buildTarget [] []] + makeRule (Ch b r s m d) = maybe [mkRule (openingComments m) buildTarget [] []] (\(BuildConfig comp onm anm bt) -> let outnm = maybe (asFragment "") (renderBuildName s m nameOpts) onm addnm = maybe (asFragment "") (renderBuildName s m nameOpts) anm in [ - mkRule ["Project Name: " ++ progName m, progPurpAdd m] - buildTarget [outnm] [], + mkRule (openingComments m) buildTarget [outnm] [], mkFile [] outnm (map (makeS . filePath) (progMods m)) $ map (mkCheckedCommand . foldr (+:+) mempty) $ comp (getCompilerInput bt s m) outnm addnm @@ -50,9 +49,12 @@ instance RuleTransformer CodeHarness where ]) d where buildTarget = makeS "build" +openingComments :: ProgData -> Annotation +openingComments m = [watermark ++ version drasilMeta,"Project Name: " ++ progName m, progPurpAdd m] + -- | Helper that renders project purpose into a string if there is one. progPurpAdd :: ProgData -> String -progPurpAdd m = if progPurp m /= [] then "Project Purpose: " ++ +progPurpAdd m = if progPurp m /= [] then "Project Purpose: " ++ capitalize (progPurp m) else [] diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Comments.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Comments.hs index 790767bc40..de5dbefd7a 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Comments.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Comments.hs @@ -21,23 +21,23 @@ getTermDoc c = do let db = sysinfodb $ codeSpec g return $ sentenceDoc db Implementation Linear $ phraseNP $ codeChunk c ^. term --- | Gets a plain rendering of the definition of a chunk, preceded by a colon --- as it is intended to follow the term for the chunk. Returns empty if the +-- | Gets a plain rendering of the definition of a chunk, preceded by a colon +-- as it is intended to follow the term for the chunk. Returns empty if the -- chunk has no definition. getDefnDoc :: (CodeIdea c) => c -> GenState Doc getDefnDoc c = do g <- get let db = sysinfodb $ codeSpec g - return $ maybe empty ((<+>) colon . sentenceDoc db Implementation Linear . + return $ maybe empty ((<+>) colon . sentenceDoc db Implementation Linear . (^. defn) . fst) (Map.lookup (codeChunk c ^. uid) $ defTable db) --- | Gets a plain rendering of the unit of a chunk in parentheses, +-- | Gets a plain rendering of the unit of a chunk in parentheses, -- or empty if it has no unit. getUnitsDoc :: (CodeIdea c) => c -> Doc -getUnitsDoc c = maybe empty (parens . unitDoc Linear . usymb) +getUnitsDoc c = maybe empty (parens . unitDoc Linear . usymb) (getUnit $ codeChunk c) --- | Generates a comment string for a chunk, including the term, +-- | Generates a comment string for a chunk, including the term, -- definition (if applicable), and unit (if applicable). getComment :: (CodeIdea c) => c -> GenState String getComment l = do diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/ConceptMatch.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/ConceptMatch.hs index 479ccdca0c..20a76a9261 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/ConceptMatch.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/ConceptMatch.hs @@ -5,7 +5,7 @@ module Language.Drasil.Code.Imperative.ConceptMatch ( import Language.Drasil (UID, Sentence(S), (+:+), (+:+.)) -import Language.Drasil.Choices (Choices(..), CodeConcept(..), +import Language.Drasil.Choices (Choices(..), CodeConcept(..), MatchedConceptMap, showChs, Maps(..)) import GOOL.Drasil (SValue, OOProg, MathConstant(..)) @@ -15,16 +15,16 @@ import qualified Data.Map as Map (mapWithKey) import Control.Monad.State (State, modify) -- | Concretizes the ConceptMatchMap in Choices to a 'MatchedConceptMap'. --- Currently we don't have any Choices that would prevent a 'CodeConcept' from +-- Currently we don't have any Choices that would prevent a 'CodeConcept' from -- being mapped, so we just take the head of the list of 'CodeConcept's -- The ConceptMatchMap from choices is passed to chooseConcept' internally, this way -- any 'CodeConcept' list can be matched to its appropiate 'UID'. chooseConcept :: Choices -> State [Sentence] MatchedConceptMap chooseConcept chs = sequence $ Map.mapWithKey chooseConcept' (conceptMatch $ maps chs) where chooseConcept' :: UID -> [CodeConcept] -> State [Sentence] CodeConcept - chooseConcept' _ [] = error $ "Empty list of CodeConcepts in the " ++ + chooseConcept' _ [] = error $ "Empty list of CodeConcepts in the " ++ "ConceptMatchMap" - chooseConcept' uid (c:_) = do + chooseConcept' uid (c:_) = do modify (++ [S "Code Concept" +:+ S (show uid) +:+ S "selected as" +:+. showChs c]) return c diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Descriptions.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Descriptions.hs index ae302f9deb..21ebbb8710 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Descriptions.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Descriptions.hs @@ -1,9 +1,9 @@ --- | Defines description generators for common SCS functions, classes, and +-- | Defines description generators for common SCS functions, classes, and -- modules. module Language.Drasil.Code.Imperative.Descriptions ( - modDesc, unmodularDesc, inputParametersDesc, inputConstructorDesc, - inputFormatDesc, derivedValuesDesc, inputConstraintsDesc, constModDesc, - outputFormatDesc, inputClassDesc, constClassDesc, inFmtFuncDesc, + modDesc, unmodularDesc, inputParametersDesc, inputConstructorDesc, + inputFormatDesc, derivedValuesDesc, inputConstraintsDesc, constModDesc, + outputFormatDesc, inputClassDesc, constClassDesc, inFmtFuncDesc, inConsFuncDesc, dvFuncDesc, calcModDesc, woFuncDesc ) where @@ -11,9 +11,9 @@ import Utils.Drasil (stringList) import Language.Drasil import Language.Drasil.Chunk.CodeBase -import Language.Drasil.Code.Imperative.DrasilState (GenState, DrasilState(..), +import Language.Drasil.Code.Imperative.DrasilState (GenState, DrasilState(..), inMod) -import Language.Drasil.Choices (ImplementationType(..), InputModule(..), +import Language.Drasil.Choices (ImplementationType(..), InputModule(..), Structure(..)) import Language.Drasil.CodeSpec (CodeSpec(..)) import Language.Drasil.Mod (Description) @@ -43,7 +43,7 @@ unmodularDesc = do foldlSent ([S "a", S (implTypeStr (implType g)), S "to"] ++ purpose spec) -- | Returns description of what is contained in the Input Parameters module. --- If user chooses the 'Bundled' input parameter, this module will include the structure for holding the +-- If user chooses the 'Bundled' input parameter, this module will include the structure for holding the -- input values. Does not include the structure if they choose 'Unbundled'. -- If the user chooses the 'Combined' input parameter, this module includes the input-related functions. -- Does not inlcude those functions if they choose 'Separated'. @@ -61,8 +61,8 @@ inputParametersDesc = do inDesc Unbundled = [""] return $ ipDesc im --- | Returns a description of the input constructor, checking whether each --- possible method that may be called by the constructor is defined, and +-- | Returns a description of the input constructor, checking whether each +-- possible method that may be called by the constructor is defined, and -- including it in the description if so. inputConstructorDesc :: GenState Description inputConstructorDesc = do @@ -75,7 +75,7 @@ inputConstructorDesc = do icDesc False = "" icDesc True = "checking " ++ pAndS ++ " on the input" dl = defList g - return $ "Initializes input object by " ++ stringList [ + return $ "Initializes input object by " ++ stringList [ ifDesc ("get_input" `elem` dl), idDesc ("derived_values" `elem` dl), icDesc ("input_constraints" `elem` dl)] @@ -105,7 +105,7 @@ inputConstraintsDesc = do g <- get pAndS <- physAndSfwrCons let icDesc False = "" - icDesc _ = "the function for checking the " ++ pAndS ++ + icDesc _ = "the function for checking the " ++ pAndS ++ " on the input" return $ icDesc $ "input_constraints" `elem` defList g @@ -117,10 +117,10 @@ constModDesc = do let cname = "Constants" cDesc [] = "" cDesc _ = "the structure for holding constant values" - return $ cDesc $ filter (flip member (Map.filter (cname ==) + return $ cDesc $ filter (flip member (Map.filter (cname ==) (clsMap g)) . codeName) (constants $ codeSpec g) --- | Returns a description of what is contained in the Output Format module, +-- | Returns a description of what is contained in the Output Format module, -- if it exists. outputFormatDesc :: GenState Description outputFormatDesc = do @@ -130,8 +130,8 @@ outputFormatDesc = do return $ ofDesc $ "write_output" `elem` defList g -- | Returns a description for the generated function that stores inputs, --- if it exists. Checks whether explicit inputs, derived inputs, and constants --- are defined in the InputParameters class and includes each in the +-- if it exists. Checks whether explicit inputs, derived inputs, and constants +-- are defined in the InputParameters class and includes each in the -- description if so. inputClassDesc :: GenState Description inputClassDesc = do @@ -153,7 +153,7 @@ inputClassDesc = do return $ inClassD $ Map.null ipMap -- | Returns a description for the generated class that stores constants, --- if it exists. If no constants are defined in the Constants class, then it +-- if it exists. If no constants are defined in the Constants class, then it -- does not exist and an empty description is returned. constClassDesc :: GenState Description constClassDesc = do @@ -161,7 +161,7 @@ constClassDesc = do let cname = "Constants" ccDesc [] = "" ccDesc _ = "Structure for holding the constant values" - return $ ccDesc $ filter (flip member (Map.filter (cname ==) + return $ ccDesc $ filter (flip member (Map.filter (cname ==) (clsMap g)) . codeName) (constants $ codeSpec g) -- | Returns a description for the generated function that reads input from a file, @@ -205,14 +205,14 @@ woFuncDesc = do woDesc _ = "Writes the output values to output.txt" return $ woDesc $ "write_output" `elem` defList g --- | Returns the phrase "physical constraints" if there are any physical --- constraints on the input and "software constraints" if there are any --- software constraints on the input. If there are both, +-- | Returns the phrase "physical constraints" if there are any physical +-- constraints on the input and "software constraints" if there are any +-- software constraints on the input. If there are both, -- "physical constraints and software constraints" is returned. physAndSfwrCons :: GenState Description physAndSfwrCons = do g <- get - let cns = concat $ mapMaybe ((`Map.lookup` (cMap $ codeSpec g)) . (^. uid)) + let cns = concat $ mapMaybe ((`Map.lookup` (cMap $ codeSpec g)) . (^. uid)) (inputs $ codeSpec g) return $ stringList [ if not (any isPhysC cns) then "" else "physical constraints", diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Doxygen/Import.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Doxygen/Import.hs index c10393e6c1..1396534d09 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Doxygen/Import.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Doxygen/Import.hs @@ -12,7 +12,6 @@ import Data.List (intersperse, nub) import Data.Maybe (maybeToList) import Control.Lens ((^.)) import Text.PrettyPrint.HughesPJ (Doc, (<+>), text, hcat, vcat) -import Utils.Drasil.Document ((+:+.)) -- | A 'Doc' that holds optimized choices for configuring doxygen files. type OptimizeChoice = Doc @@ -31,11 +30,14 @@ verbosityToDoc :: Verbosity -> Doc verbosityToDoc Verbose = no verbosityToDoc Quiet = yes --- | Renderings of comments regarding the default tag values for various Doxygen settings. +-- | Renderings of comments regarding the default tag values for various Doxygen +-- settings. +-- +-- TODO: `makeDoxConfig` needs access to a `ChunkDB` so that we can re-write +-- these `Doc`s as `Sentence`s and render them back into `Doc`s appropriately. defNo, defYes :: Doc -defNo = defaultValSentence +:+. no -defYes = defaultValSentence +:+. yes - +defNo = defaultValSentence <> no <> text "." +defYes = defaultValSentence <> yes <> text "." -- | Renders a Doxygen configuration file. -- @@ -44,7 +46,7 @@ defYes = defaultValSentence +:+. yes -- * Sets the OPTIMIZE_OUTPUT_JAVA field according to the OptimizeChoice parameter. -- * Sets the QUIET field according to the given Verbosity. makeDoxConfig :: ProjName -> GOOLState -> OptimizeChoice -> Verbosity -> Doc -makeDoxConfig prog s opt v = +makeDoxConfig prog s opt v = let fs = nub (s ^. headers ++ maybeToList (s ^. mainMod)) in vcat [ text "# Doxyfile 1.8.15", @@ -142,14 +144,15 @@ makeDoxConfig prog s opt v = blank, text "OUTPUT_LANGUAGE = English", blank, - text "# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all", - text "# documentation generated by doxygen is written. Doxygen will use this", - text "# information to generate all generated output in the proper direction.", - text "# Possible values are: None, LTR, RTL and Context.", - text "# The default value is: None.", - blank, - text "OUTPUT_TEXT_DIRECTION = None", - blank, + -- | To Be Fixed: This is not being used by Doxygen + -- text "# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all", + -- text "# documentation generated by doxygen is written. Doxygen will use this", + -- text "# information to generate all generated output in the proper direction.", + -- text "# Possible values are: None, LTR, RTL and Context.", + -- text "# The default value is: None.", + -- blank, + -- text "OUTPUT_TEXT_DIRECTION = None", + -- blank, text "# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member", text "# descriptions after the members that are listed in the file and class", text "# documentation (similar to Javadoc). Set to NO to disable this.", @@ -302,12 +305,13 @@ makeDoxConfig prog s opt v = blank, text "ALIASES =", blank, - text "# This tag can be used to specify a number of word-keyword mappings (TCL only).", - text "# A mapping has the form \"name=value\". For example adding \"class=itcl::class\"", - text "# will allow you to use the command class in the itcl::class meaning.", - blank, - text "TCL_SUBST =", - blank, + -- | To Be Fixed: This is not being used by Doxygen + -- text "# This tag can be used to specify a number of word-keyword mappings (TCL only).", + -- text "# A mapping has the form \"name=value\". For example adding \"class=itcl::class\"", + -- text "# will allow you to use the command class in the itcl::class meaning.", + -- blank, + -- text "TCL_SUBST =", + -- blank, text "# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources", text "# only. Doxygen will then generate output that is more tailored for C. For", text "# instance, some of the names that are used will be different. The list of all", @@ -1183,13 +1187,14 @@ makeDoxConfig prog s opt v = blank, text "ALPHABETICAL_INDEX = YES", blank, - text "# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in", - text "# which the alphabetical index list will be split.", - text "# Minimum value: 1, maximum value: 20, default value: 5.", - text "# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.", - blank, - text "COLS_IN_ALPHA_INDEX = 5", - blank, + -- | To Be Fixed: This is not being used by Doxygen + -- text "# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in", + -- text "# which the alphabetical index list will be split.", + -- text "# Minimum value: 1, maximum value: 20, default value: 5.", + -- text "# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.", + -- blank, + -- text "COLS_IN_ALPHA_INDEX = 5", + -- blank, text "# In case all classes in a project start with a common prefix, all classes will", text "# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag", text "# can be used to specify a prefix (or a list of prefixes) that should be ignored", @@ -1317,15 +1322,16 @@ makeDoxConfig prog s opt v = blank, text "HTML_COLORSTYLE_GAMMA = 80", blank, - text "# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML", - text "# page will contain the date and time when the page was generated. Setting this", - text "# to YES can help to show when doxygen was last run and thus if the", - text "# documentation is up to date.", - defNo, - text "# This tag requires that the tag GENERATE_HTML is set to YES.", - blank, - text "HTML_TIMESTAMP = NO", - blank, + -- | To Be Fixed: This is not being used by Doxygen + -- text "# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML", + -- text "# page will contain the date and time when the page was generated. Setting this", + -- text "# to YES can help to show when doxygen was last run and thus if the", + -- text "# documentation is up to date.", + -- defNo, + -- text "# This tag requires that the tag GENERATE_HTML is set to YES.", + -- blank, + -- text "HTML_TIMESTAMP = NO", + -- blank, text "# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML", text "# documentation will contain a main index with vertical navigation menus that", text "# are dynamically created via Javascript. If disabled, the navigation index will", @@ -1614,10 +1620,11 @@ makeDoxConfig prog s opt v = text "# Note that when changing this option you need to delete any form_*.png files in", text "# the HTML output directory before the changes have effect.", defYes, - text "# This tag requires that the tag GENERATE_HTML is set to YES.", - blank, - text "FORMULA_TRANSPARENT = YES", - blank, + -- | To Be Fixed: This is not being used by Doxygen + -- text "# This tag requires that the tag GENERATE_HTML is set to YES.", + -- blank, + -- text "FORMULA_TRANSPARENT = YES", + -- blank, text "# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see", text "# https://www.mathjax.org) which uses client side Javascript for the rendering", text "# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX", @@ -1915,10 +1922,11 @@ makeDoxConfig prog s opt v = text "# Note that which sources are shown also depends on other settings such as", text "# SOURCE_BROWSER.", defNo, - text "# This tag requires that the tag GENERATE_LATEX is set to YES.", - blank, - text "LATEX_SOURCE_CODE = NO", - blank, + -- | To Be Fixed: This is not being used by Doxygen + -- text "# This tag requires that the tag GENERATE_LATEX is set to YES.", + -- blank, + -- text "LATEX_SOURCE_CODE = NO", + -- blank, text "# The LATEX_BIB_STYLE tag can be used to specify the style to use for the", text "# bibliography, e.g. plainnat, or ieeetr. See", text "# https://en.wikipedia.org/wiki/BibTeX and \\cite for more info.", @@ -1927,14 +1935,15 @@ makeDoxConfig prog s opt v = blank, text "LATEX_BIB_STYLE = plain", blank, - text "# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated", - text "# page will contain the date and time when the page was generated. Setting this", - text "# to NO can help when comparing the output of multiple runs.", - defNo, - text "# This tag requires that the tag GENERATE_LATEX is set to YES.", - blank, - text "LATEX_TIMESTAMP = NO", - blank, + -- | To Be Fixed: This is not being used by Doxygen + -- text "# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated", + -- text "# page will contain the date and time when the page was generated. Setting this", + -- text "# to NO can help when comparing the output of multiple runs.", + -- defNo, + -- text "# This tag requires that the tag GENERATE_LATEX is set to YES.", + -- blank, + -- text "LATEX_TIMESTAMP = NO", + -- blank, text "# The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute)", text "# path from which the emoji images will be read. If a relative path is entered,", text "# it will be relative to the LATEX_OUTPUT directory. If left blank the", @@ -2005,10 +2014,11 @@ makeDoxConfig prog s opt v = text "# Note that which sources are shown also depends on other settings such as", text "# SOURCE_BROWSER.", defNo, - text "# This tag requires that the tag GENERATE_RTF is set to YES.", - blank, - text "RTF_SOURCE_CODE = NO", - blank, + -- | To Be Fixed: This is not being used by Doxygen + -- text "# This tag requires that the tag GENERATE_RTF is set to YES.", + -- blank, + -- text "RTF_SOURCE_CODE = NO", + -- blank, text "#---------------------------------------------------------------------------", text "# Configuration options related to the man page output", text "#---------------------------------------------------------------------------", @@ -2110,10 +2120,11 @@ makeDoxConfig prog s opt v = text "# information) to the DOCBOOK output. Note that enabling this will significantly", text "# increase the size of the DOCBOOK output.", defNo, - text "# This tag requires that the tag GENERATE_DOCBOOK is set to YES.", - blank, - text "DOCBOOK_PROGRAMLISTING = NO", - blank, + -- | To Be Fixed: This is not being used by Doxygen + -- text "# This tag requires that the tag GENERATE_DOCBOOK is set to YES.", + -- blank, + -- text "DOCBOOK_PROGRAMLISTING = NO", + -- blank, text "#---------------------------------------------------------------------------", text "# Configuration options for the AutoGen Definitions output", text "#---------------------------------------------------------------------------", @@ -2288,34 +2299,36 @@ makeDoxConfig prog s opt v = blank, text "EXTERNAL_PAGES = YES", blank, - text "# The PERL_PATH should be the absolute path and name of the perl script", - text "# interpreter (i.e. the result of 'which perl').", - text "# The default file (with absolute path) is: /usr/bin/perl.", - blank, - text "PERL_PATH = /usr/bin/perl", - blank, + -- | To Be Fixed: This is not being used by Doxygen + -- text "# The PERL_PATH should be the absolute path and name of the perl script", + -- text "# interpreter (i.e. the result of 'which perl').", + -- text "# The default file (with absolute path) is: /usr/bin/perl.", + -- blank, + -- text "PERL_PATH = /usr/bin/perl", + -- blank, text "#---------------------------------------------------------------------------", text "# Configuration options related to the dot tool", text "#---------------------------------------------------------------------------", blank, - text "# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram", - text "# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to", - text "# NO turns the diagrams off. Note that this option also works with HAVE_DOT", - text "# disabled, but it is recommended to install and use dot, since it yields more", - text "# powerful graphs.", - defYes, - blank, - text "CLASS_DIAGRAMS = YES", - blank, - text "# You can define message sequence charts within doxygen comments using the \\msc", - text "# command. Doxygen will then run the mscgen tool (see:", - text "# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the", - text "# documentation. The MSCGEN_PATH tag allows you to specify the directory where", - text "# the mscgen tool resides. If left empty the tool is assumed to be found in the", - text "# default search path.", - blank, - text "MSCGEN_PATH =", - blank, + -- | To Be Fixed: This is not being used by Doxygen + -- text "# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram", + -- text "# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to", + -- text "# NO turns the diagrams off. Note that this option also works with HAVE_DOT", + -- text "# disabled, but it is recommended to install and use dot, since it yields more", + -- text "# powerful graphs.", + -- defYes, + -- blank, + -- text "CLASS_DIAGRAMS = YES", + -- blank, + -- text "# You can define message sequence charts within doxygen comments using the \\msc", + -- text "# command. Doxygen will then run the mscgen tool (see:", + -- text "# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the", + -- text "# documentation. The MSCGEN_PATH tag allows you to specify the directory where", + -- text "# the mscgen tool resides. If left empty the tool is assumed to be found in the", + -- text "# default search path.", + -- blank, + -- text "MSCGEN_PATH =", + -- blank, text "# You can include diagrams made with dia in doxygen documentation. Doxygen will", text "# then run dia to produce the diagram and insert it in the documentation. The", text "# DIA_PATH tag allows you to specify the directory where the dia binary resides.", @@ -2348,23 +2361,24 @@ makeDoxConfig prog s opt v = blank, text "DOT_NUM_THREADS = 0", blank, - text "# When you want a differently looking font in the dot files that doxygen", - text "# generates you can specify the font name using DOT_FONTNAME. You need to make", - text "# sure dot is able to find the font, which can be done by putting it in a", - text "# standard location or by setting the DOTFONTPATH environment variable or by", - text "# setting DOT_FONTPATH to the directory containing the font.", - text "# The default value is: Helvetica.", - text "# This tag requires that the tag HAVE_DOT is set to YES.", - blank, - text "DOT_FONTNAME = Helvetica", - blank, - text "# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of", - text "# dot graphs.", - text "# Minimum value: 4, maximum value: 24, default value: 10.", - text "# This tag requires that the tag HAVE_DOT is set to YES.", - blank, - text "DOT_FONTSIZE = 10", - blank, + -- | To Be Fixed: This is not being used by Doxygen + -- text "# When you want a differently looking font in the dot files that doxygen", + -- text "# generates you can specify the font name using DOT_FONTNAME. You need to make", + -- text "# sure dot is able to find the font, which can be done by putting it in a", + -- text "# standard location or by setting the DOTFONTPATH environment variable or by", + -- text "# setting DOT_FONTPATH to the directory containing the font.", + -- text "# The default value is: Helvetica.", + -- text "# This tag requires that the tag HAVE_DOT is set to YES.", + -- blank, + -- text "DOT_FONTNAME = Helvetica", + -- blank, + -- text "# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of", + -- text "# dot graphs.", + -- text "# Minimum value: 4, maximum value: 24, default value: 10.", + -- text "# This tag requires that the tag HAVE_DOT is set to YES.", + -- blank, + -- text "DOT_FONTSIZE = 10", + -- blank, text "# By default doxygen will tell dot to use the default font as specified with", text "# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set", text "# the path where dot can find it using this tag.", @@ -2577,18 +2591,19 @@ makeDoxConfig prog s opt v = blank, text "MAX_DOT_GRAPH_DEPTH = 0", blank, - text "# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent", - text "# background. This is disabled by default, because dot on Windows does not seem", - text "# to support this out of the box.", - text "#", - text "# Warning: Depending on the platform used, enabling this option may lead to", - text "# badly anti-aliased labels on the edges of a graph (i.e. they become hard to", - text "# read).", - defNo, - text "# This tag requires that the tag HAVE_DOT is set to YES.", - blank, - text "DOT_TRANSPARENT = NO", - blank, + -- | To Be Fixed: This is not being used by Doxygen + -- text "# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent", + -- text "# background. This is disabled by default, because dot on Windows does not seem", + -- text "# to support this out of the box.", + -- text "#", + -- text "# Warning: Depending on the platform used, enabling this option may lead to", + -- text "# badly anti-aliased labels on the edges of a graph (i.e. they become hard to", + -- text "# read).", + -- defNo, + -- text "# This tag requires that the tag HAVE_DOT is set to YES.", + -- blank, + -- text "DOT_TRANSPARENT = NO", + -- blank, text "# Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output", text "# files in one run (i.e. multiple -o and -T options on the command line). This", text "# makes dot run faster, but since only newer versions of dot (>1.8.10) support", diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/DrasilState.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/DrasilState.hs index 5fe8377743..9200b14116 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/DrasilState.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/DrasilState.hs @@ -1,6 +1,6 @@ {-# LANGUAGE TemplateHaskell, TupleSections #-} module Language.Drasil.Code.Imperative.DrasilState ( - GenState, DrasilState(..), designLog, inMod, MatchedSpaces, ModExportMap, + GenState, DrasilState(..), designLog, inMod, MatchedSpaces, ModExportMap, ClassDefinitionMap, modExportMap, clsDefMap, addToDesignLog, addLoggedSpace ) where @@ -10,13 +10,13 @@ import GOOL.Drasil (ScopeTag(..), CodeType) import Language.Drasil.Chunk.ConstraintMap (ConstraintCE) import Language.Drasil.Code.ExtLibImport (ExtLibState) import Language.Drasil.Choices (Choices(..), Architecture (..), DataInfo(..), - AuxFile, Modularity(..), - ImplementationType(..), Comments, Verbosity, MatchedConceptMap, - ConstantRepr, ConstantStructure(..), ConstraintBehaviour, + AuxFile, Modularity(..), + ImplementationType(..), Comments, Verbosity, MatchedConceptMap, + ConstantRepr, ConstantStructure(..), ConstraintBehaviour, InputModule(..), Logging, Structure(..), inputModule) -import Language.Drasil.CodeSpec (Input, Const, Derived, Output, Def, +import Language.Drasil.CodeSpec (Input, Const, Derived, Output, Def, CodeSpec(..), getConstraints) -import Language.Drasil.Mod (Mod(..), Name, Version, Class(..), +import Language.Drasil.Mod (Mod(..), Name, Version, Class(..), StateVariable(..), fname) import Control.Lens ((^.), makeLenses, over) @@ -66,10 +66,11 @@ data DrasilState = DrasilState { extLibMap :: ExtLibMap, libPaths :: [FilePath], eMap :: ModExportMap, - libEMap :: ModExportMap, + libEMap :: ModExportMap, clsMap :: ClassDefinitionMap, defList :: [Name], getVal :: Int, + -- Stateful currentModule :: String, currentClass :: String, @@ -88,15 +89,15 @@ inMod ds = inMod' $ modular ds -- | Adds a message to the design log if the given 'Space'-'CodeType' match has not -- already been logged. addToDesignLog :: Space -> CodeType -> Doc -> DrasilState -> DrasilState -addToDesignLog s t l ds = if (s,t) `elem` (ds ^. loggedSpaces) then ds +addToDesignLog s t l ds = if (s,t) `elem` (ds ^. loggedSpaces) then ds else over designLog ($$ l) ds --- | Adds a 'Space'-'CodeType' pair to the loggedSpaces list in 'DrasilState' to prevent a duplicate +-- | Adds a 'Space'-'CodeType' pair to the loggedSpaces list in 'DrasilState' to prevent a duplicate -- log from being generated for that 'Space'-'CodeType' pair. addLoggedSpace :: Space -> CodeType -> DrasilState -> DrasilState -addLoggedSpace s t = over loggedSpaces ((s,t):) +addLoggedSpace s t = over loggedSpaces ((s,t):) --- | Builds the module export map, mapping each function and state variable name +-- | Builds the module export map, mapping each function and state variable name -- in the generated code to the name of the generated module that exports it. modExportMap :: CodeSpec -> Choices -> [Mod] -> ModExportMap modExportMap cs@CodeSpec { @@ -123,7 +124,7 @@ modExportMap cs@CodeSpec { defModName Unmodular _ = prn defModName _ nm = nm --- | Builds the class definition map, mapping each generated method and state +-- | Builds the class definition map, mapping each generated method and state -- variable name to the name of the generated class where it is defined. clsDefMap :: CodeSpec -> Choices -> [Mod] -> ClassDefinitionMap clsDefMap cs@CodeSpec { @@ -137,9 +138,9 @@ clsDefMap cs@CodeSpec { ++ getDerivedCls chs ds ++ getConstraintsCls chs (getConstraints (cMap cs) ins) ++ getInputFormatCls chs extIns - where modClasses (Mod _ _ _ cls _) = concatMap (\cl -> + where modClasses (Mod _ _ _ cls _) = concatMap (\cl -> let cln = className cl in - (cln, cln) : map (\sv -> (codeName (stVar sv), cln)) (stateVars cl) + (cln, cln) : map (\sv -> (codeName (stVar sv), cln)) (stateVars cl) ++ map (\m -> (fname m, cln)) (methods cl)) cls -- | Module exports. @@ -156,7 +157,7 @@ type ClassDef = (String, String) -- constructor is generated, thus "InputParameters" is added to map. getExpInput :: Name -> Choices -> [Input] -> [ModExp] getExpInput _ _ [] = [] -getExpInput prn chs ins = inExp (modularity $ architecture chs) (inputStructure $ dataInfo chs) +getExpInput prn chs ins = inExp (modularity $ architecture chs) (inputStructure $ dataInfo chs) where inExp _ Unbundled = [] inExp Unmodular Bundled = (ipName, prn) : inVarDefs prn inExp (Modular Separated) Bundled = inVarDefs ipName @@ -164,14 +165,14 @@ getExpInput prn chs ins = inExp (modularity $ architecture chs) (inputStructure inVarDefs n = map ((, n) . codeName) ins ipName = "InputParameters" --- | Gets input variables for classes for InputParameters module. +-- | Gets input variables for classes for InputParameters module. -- If no inputs, input variables will not be defined in any class. -- If 'Unbundled', input variables will not be defined in any class. -- If 'Bundled' and input modules are 'Combined', input variables and input constructor are defined in InputParameters. -- If 'Bundled' and input modules are 'Separated', input variables are defined in InputParameters but no constructor is generated. getInputCls :: Choices -> [Input] -> [ClassDef] getInputCls _ [] = [] -getInputCls chs ins = inCls (inputModule chs) (inputStructure $ dataInfo chs) +getInputCls chs ins = inCls (inputModule chs) (inputStructure $ dataInfo chs) where inCls _ Unbundled = [] inCls Combined Bundled = (ipName, ipName) : inVarDefs inCls Separated Bundled = inVarDefs @@ -186,7 +187,7 @@ getInputCls chs ins = inCls (inputModule chs) (inputStructure $ dataInfo chs) -- If 'Unbundled', constants are not exported by any module. getExpConstants :: Name -> Choices -> [Const] -> [ModExp] getExpConstants _ _ [] = [] -getExpConstants n chs cs = cExp (modularity $ architecture chs) (constStructure $ dataInfo chs) +getExpConstants n chs cs = cExp (modularity $ architecture chs) (constStructure $ dataInfo chs) (inputStructure $ dataInfo chs) where cExp Unmodular (Store Bundled) _ = zipCs $ repeat n cExp Unmodular WithInputs Bundled = zipCs $ repeat n diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/FunctionCalls.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/FunctionCalls.hs index fde20dff71..e1ed842bb6 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/FunctionCalls.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/FunctionCalls.hs @@ -1,20 +1,20 @@ module Language.Drasil.Code.Imperative.FunctionCalls ( - getAllInputCalls, getInputCall, getDerivedCall, getConstraintCall, + getAllInputCalls, getInputCall, getDerivedCall, getConstraintCall, getCalcCall, getOutputCall ) where import Language.Drasil.Code.Imperative.GenerateGOOL (fApp, fAppInOut) import Language.Drasil.Code.Imperative.Import (codeType, mkVal, mkVar) import Language.Drasil.Code.Imperative.Logging (maybeLog) -import Language.Drasil.Code.Imperative.Parameters (getCalcParams, - getConstraintParams, getDerivedIns, getDerivedOuts, getInputFormatIns, +import Language.Drasil.Code.Imperative.Parameters (getCalcParams, + getConstraintParams, getDerivedIns, getDerivedOuts, getInputFormatIns, getInputFormatOuts, getOutputParams) import Language.Drasil.Code.Imperative.DrasilState (GenState, DrasilState(..)) import Language.Drasil.Chunk.Code (CodeIdea(codeName), CodeVarChunk, quantvar) import Language.Drasil.Chunk.CodeDefinition (CodeDefinition) import Language.Drasil.Mod (Name) -import GOOL.Drasil (VSType, SValue, MSStatement, OOProg, TypeSym(..), +import GOOL.Drasil (VSType, SValue, MSStatement, OOProg, TypeSym(..), VariableValue(..), StatementSym(..), DeclStatement(..), convType) import Data.List ((\\), intersect) @@ -23,8 +23,8 @@ import Data.Maybe (catMaybes) import Control.Applicative ((<|>)) import Control.Monad.State (get) --- | Generates calls to all of the input-related functions. First is the call to --- the function for reading inputs, then the function for calculating derived +-- | Generates calls to all of the input-related functions. First is the call to +-- the function for reading inputs, then the function for calculating derived -- inputs, then the function for checking input constraints. getAllInputCalls :: (OOProg r) => GenState [MSStatement r] getAllInputCalls = do @@ -47,7 +47,7 @@ getConstraintCall = do val <- getFuncCall "input_constraints" void getConstraintParams return $ fmap valStmt val --- | Generates a call to a calculation function, given the 'CodeDefinition' for the +-- | Generates a call to a calculation function, given the 'CodeDefinition' for the -- value being calculated. getCalcCall :: (OOProg r) => CodeDefinition -> GenState (Maybe (MSStatement r)) getCalcCall c = do @@ -63,9 +63,9 @@ getOutputCall = do val <- getFuncCall "write_output" void getOutputParams return $ fmap valStmt val --- | Generates a function call given the name, return type, and arguments to +-- | Generates a function call given the name, return type, and arguments to -- the function. -getFuncCall :: (OOProg r) => Name -> VSType r -> +getFuncCall :: (OOProg r) => Name -> VSType r -> GenState [CodeVarChunk] -> GenState (Maybe (SValue r)) getFuncCall n t funcPs = do mm <- getCall n @@ -79,7 +79,7 @@ getFuncCall n t funcPs = do -- | Generates a function call given the name, inputs, and outputs for the -- function. -getInOutCall :: (OOProg r) => Name -> GenState [CodeVarChunk] -> +getInOutCall :: (OOProg r) => Name -> GenState [CodeVarChunk] -> GenState [CodeVarChunk] -> GenState (Maybe (MSStatement r)) getInOutCall n inFunc outFunc = do mm <- getCall n @@ -93,12 +93,12 @@ getInOutCall n inFunc outFunc = do stmt <- fAppInOut m n (map valueOf ins) outs both return $ Just stmt getInOutCall' mm - + -- | Gets the name of the module containing the function being called. --- If the function is not in either the module export map or class definition map, +-- If the function is not in either the module export map or class definition map, -- return 'Nothing'. --- If the function is not in module export map but is in the class definition map, --- that means it is a private function, so return 'Nothing' unless it is in the +-- If the function is not in module export map but is in the class definition map, +-- that means it is a private function, so return 'Nothing' unless it is in the -- current class. getCall :: Name -> GenState (Maybe Name) getCall n = do @@ -107,7 +107,7 @@ getCall n = do getCallExported Nothing = getCallInClass (Map.lookup n $ clsMap g) getCallExported m = return m getCallInClass Nothing = return Nothing - getCallInClass (Just c) = if c == currc then return $ Map.lookup c (eMap + getCallInClass (Just c) = if c == currc then return $ Map.lookup c (eMap g) <|> error (c ++ " class missing from export map") else return Nothing getCallExported $ Map.lookup n (eMap g) diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/ClassInterface.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/ClassInterface.hs index d4af222d32..30486606c4 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/ClassInterface.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/ClassInterface.hs @@ -1,6 +1,6 @@ {-# LANGUAGE TypeFamilies #-} --- | Defines a package extension for GOOL, with functions for pairing a GOOL +-- | Defines a package extension for GOOL, with functions for pairing a GOOL -- program with auxiliary, non-source-code files. module Language.Drasil.Code.Imperative.GOOL.ClassInterface ( ReadMeInfo(..), @@ -21,7 +21,7 @@ import Text.PrettyPrint.HughesPJ (Doc) -- | Members of this class must have all the information necessary for -- the 'AuxiliarySym' in addition to information necessary to create a package. class (AuxiliarySym r) => PackageSym r where - type Package r + type Package r package :: ProgData -> [r (Auxiliary r)] -> r (Package r) -- | Members of this class must have a doxygen configuration, ReadMe file, @@ -36,7 +36,7 @@ class AuxiliarySym r where optimizeDox :: r (AuxHelper r) - makefile :: [FilePath] -> ImplementationType -> [Comments] -> GOOLState -> + makefile :: [FilePath] -> ImplementationType -> [Comments] -> GOOLState -> ProgData -> r (Auxiliary r) auxHelperDoc :: r (AuxHelper r) -> Doc @@ -66,7 +66,7 @@ data ReadMeInfo = ReadMeInfo { implementType :: ImplementationType, extLibNV :: [(Name,Version)], extLibFP :: [FilePath], - contributors :: [Contributor], + contributors :: [Contributor], configFP :: [FilePath], caseName :: CaseName, examplePurpose :: ExamplePurpose, diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/Data.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/Data.hs index a9cedd5f7b..33eed75eb6 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/Data.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/Data.hs @@ -1,5 +1,5 @@ -- | Defines the underlying data types used in the package extension. -module Language.Drasil.Code.Imperative.GOOL.Data (AuxData(auxFilePath, auxDoc), +module Language.Drasil.Code.Imperative.GOOL.Data (AuxData(auxFilePath, auxDoc), ad, PackData(packProg, packAux), packD ) where diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/CSharpRenderer.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/CSharpRenderer.hs index 88ad3efea3..fbd8b201c5 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/CSharpRenderer.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/CSharpRenderer.hs @@ -9,13 +9,13 @@ module Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.CSharpRenderer ( import Language.Drasil.Choices (ImplementationType(..)) import Language.Drasil.Code.Imperative.GOOL.ClassInterface (ReadMeInfo(..), PackageSym(..), AuxiliarySym(..)) -import qualified - Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.LanguagePolymorphic as - G (doxConfig, readMe, sampleInput, makefile, noRunIfLib, doxDocConfig, +import qualified + Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.LanguagePolymorphic as + G (doxConfig, readMe, sampleInput, makefile, noRunIfLib, doxDocConfig, docIfEnabled) import Language.Drasil.Code.Imperative.GOOL.Data (AuxData(..), ad, PackData(..), packD) -import Language.Drasil.Code.Imperative.Build.AST (BuildConfig, Runnable, +import Language.Drasil.Code.Imperative.Build.AST (BuildConfig, Runnable, asFragment, buildAll, nativeBinary, osClassDefault, executable, sharedLibrary) import Language.Drasil.Code.Imperative.Doxygen.Import (no) @@ -55,7 +55,7 @@ instance AuxiliarySym CSharpProject where optimizeDox = pure no - makefile fs it cms = G.makefile (csBuildConfig fs it) + makefile fs it cms = G.makefile (csBuildConfig fs it) (G.noRunIfLib it csRunnable) (G.docIfEnabled cms G.doxDocConfig) auxHelperDoc = unCSP @@ -63,7 +63,7 @@ instance AuxiliarySym CSharpProject where -- | Create a build configuration for C# files. Takes in 'FilePath's and the type of implementation. csBuildConfig :: [FilePath] -> ImplementationType -> Maybe BuildConfig -csBuildConfig fs it = buildAll (\i o -> [osClassDefault "CSC" "csc" "mcs" +csBuildConfig fs it = buildAll (\i o -> [osClassDefault "CSC" "csc" "mcs" : target it ++ [asFragment "-out:" P.<> o] ++ map (asFragment . ("-r:" ++)) fs ++ i]) (outName it) where target Library = [asFragment "-t:library"] @@ -73,4 +73,4 @@ csBuildConfig fs it = buildAll (\i o -> [osClassDefault "CSC" "csc" "mcs" -- | Default runnable information for C# files. csRunnable :: Maybe Runnable -csRunnable = nativeBinary \ No newline at end of file +csRunnable = nativeBinary diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/CppRenderer.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/CppRenderer.hs index 5f59bd90eb..8910787ef4 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/CppRenderer.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/CppRenderer.hs @@ -10,13 +10,13 @@ module Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.CppRenderer ( import Language.Drasil.Choices (ImplementationType(..)) import Language.Drasil.Code.Imperative.GOOL.ClassInterface (ReadMeInfo(..), PackageSym(..), AuxiliarySym(..)) -import qualified - Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.LanguagePolymorphic as - G (doxConfig, readMe, sampleInput, makefile, noRunIfLib, doxDocConfig, +import qualified + Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.LanguagePolymorphic as + G (doxConfig, readMe, sampleInput, makefile, noRunIfLib, doxDocConfig, docIfEnabled) -import Language.Drasil.Code.Imperative.GOOL.Data (AuxData(..), ad, +import Language.Drasil.Code.Imperative.GOOL.Data (AuxData(..), ad, PackData(..), packD) -import Language.Drasil.Code.Imperative.Build.AST (BuildConfig, Runnable, +import Language.Drasil.Code.Imperative.Build.AST (BuildConfig, Runnable, asFragment, buildAll, cppCompiler, nativeBinary, executable, sharedLibrary) import Language.Drasil.Code.Imperative.Doxygen.Import (no) @@ -53,9 +53,9 @@ instance AuxiliarySym CppProject where sampleInput = G.sampleInput optimizeDox = pure no - + makefile fs it cms = G.makefile (cppBuildConfig fs it) (G.noRunIfLib it cppRunnable) (G.docIfEnabled cms G.doxDocConfig) - + auxHelperDoc = unCPPP auxFromData fp d = pure $ ad fp d @@ -63,7 +63,7 @@ instance AuxiliarySym CppProject where -- | Create a build configuration for C++ files. Takes in 'FilePath's and the type of implementation. cppBuildConfig :: [FilePath] -> ImplementationType -> Maybe BuildConfig cppBuildConfig fs it = buildAll (\i o -> [cppCompiler : i ++ map asFragment - ("--std=c++11" : target it ++ ["-o"]) ++ [o] ++ concatMap (\f -> map + ("--std=c++11" : target it ++ ["-o"]) ++ [o] ++ concatMap (\f -> map asFragment ["-I", f]) fs]) (outName it) where target Library = ["-shared", "-fPIC"] target Program = [] @@ -72,4 +72,4 @@ cppBuildConfig fs it = buildAll (\i o -> [cppCompiler : i ++ map asFragment -- | Default runnable information for C++ files. cppRunnable :: Maybe Runnable -cppRunnable = nativeBinary \ No newline at end of file +cppRunnable = nativeBinary diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/JavaRenderer.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/JavaRenderer.hs index c64ba17844..9638012a32 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/JavaRenderer.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/JavaRenderer.hs @@ -9,14 +9,14 @@ module Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.JavaRenderer ( import Language.Drasil.Choices (ImplementationType(..)) import Language.Drasil.Code.Imperative.GOOL.ClassInterface (ReadMeInfo(..), PackageSym(..), AuxiliarySym(..)) -import qualified - Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.LanguagePolymorphic as +import qualified + Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.LanguagePolymorphic as G (doxConfig, readMe, sampleInput, makefile, noRunIfLib, doxDocConfig, docIfEnabled) import Language.Drasil.Code.Imperative.GOOL.Data (AuxData(..), ad, PackData(..), packD) -import Language.Drasil.Code.Imperative.Build.AST (BuildConfig, BuildName(..), - Ext(..), Runnable, NameOpts(NameOpts), asFragment, buildSingle, - buildAllAdditionalName, includeExt, inCodePackage, interp, mainModule, +import Language.Drasil.Code.Imperative.Build.AST (BuildConfig, BuildName(..), + Ext(..), Runnable, NameOpts(NameOpts), asFragment, buildSingle, + buildAllAdditionalName, includeExt, inCodePackage, interp, mainModule, mainModuleFile, packSep, withExt) import Language.Drasil.Code.Imperative.Doxygen.Import (yes) @@ -62,7 +62,7 @@ instance AuxiliarySym JavaProject where optimizeDox = pure yes - makefile fs it cms = G.makefile (jBuildConfig fs it) + makefile fs it cms = G.makefile (jBuildConfig fs it) (G.noRunIfLib it (jRunnable fs)) (G.docIfEnabled cms G.doxDocConfig) auxHelperDoc = unJP @@ -70,20 +70,20 @@ instance AuxiliarySym JavaProject where -- | Create a build configuration for Java files. Takes in 'FilePath's and the type of implementation. jBuildConfig :: [FilePath] -> ImplementationType -> Maybe BuildConfig -jBuildConfig fs Program = buildSingle (\i _ -> [asFragment "javac" : map - asFragment (classPath fs) ++ i]) (withExt (inCodePackage mainModule) +jBuildConfig fs Program = buildSingle (\i _ -> [asFragment "javac" : map + asFragment (classPath fs) ++ i]) (withExt (inCodePackage mainModule) ".class") $ inCodePackage mainModuleFile -jBuildConfig fs Library = buildAllAdditionalName (\i o a -> +jBuildConfig fs Library = buildAllAdditionalName (\i o a -> [asFragment "javac" : map asFragment (classPath fs) ++ i, - map asFragment ["jar", "-cvf"] ++ [o, a]]) + map asFragment ["jar", "-cvf"] ++ [o, a]]) (BWithExt BPackName $ OtherExt $ asFragment ".jar") BPackName -- | Default runnable information for Java files. jRunnable :: [FilePath] -> Maybe Runnable -jRunnable fs = interp (flip withExt ".class" $ inCodePackage mainModule) +jRunnable fs = interp (flip withExt ".class" $ inCodePackage mainModule) jNameOpts "java" (classPath fs) -- | Helper for formating file paths for use in 'jBuildConfig'. classPath :: [FilePath] -> [String] -classPath fs = if null fs then [] else +classPath fs = if null fs then [] else ["-cp", "\"" ++ intercalate ":" (fs ++ ["."]) ++ "\""] diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/LanguagePolymorphic.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/LanguagePolymorphic.hs index 34b71ee3a1..4afbd6cb9c 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/LanguagePolymorphic.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/LanguagePolymorphic.hs @@ -1,6 +1,6 @@ module Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.LanguagePolymorphic ( -- * Common Syntax - doxConfig, readMe,sampleInput, makefile, noRunIfLib, doxDocConfig, + doxConfig, readMe,sampleInput, makefile, noRunIfLib, doxDocConfig, docIfEnabled ) where @@ -13,21 +13,21 @@ import GOOL.Drasil (ProgData, GOOLState) import Language.Drasil.Choices (Comments, ImplementationType(..), Verbosity) import Language.Drasil.Code.DataDesc (DataDesc) import Language.Drasil.Code.Imperative.Doxygen.Import (makeDoxConfig) -import Language.Drasil.Code.Imperative.Build.AST (BuildConfig, Runnable, +import Language.Drasil.Code.Imperative.Build.AST (BuildConfig, Runnable, DocConfig, doxygenDocConfig) import Language.Drasil.Code.Imperative.Build.Import (makeBuild) import Language.Drasil.Code.Imperative.WriteInput (makeInputFile) import Language.Drasil.Code.Imperative.WriteReadMe (makeReadMe) -import Language.Drasil.Code.Imperative.GOOL.LanguageRenderer (doxConfigName, +import Language.Drasil.Code.Imperative.GOOL.LanguageRenderer (doxConfigName, makefileName, sampleInputName, readMeName) import Language.Drasil.Code.Imperative.GOOL.ClassInterface ( ReadMeInfo(..), AuxiliarySym(Auxiliary, AuxHelper, auxHelperDoc, auxFromData)) -- | Defines a Doxygen configuration file. -doxConfig :: (AuxiliarySym r) => r (AuxHelper r) -> String -> +doxConfig :: (AuxiliarySym r) => r (AuxHelper r) -> String -> GOOLState -> Verbosity -> r (Auxiliary r) -doxConfig opt pName s v = auxFromData doxConfigName (makeDoxConfig pName s +doxConfig opt pName s v = auxFromData doxConfigName (makeDoxConfig pName s (auxHelperDoc opt) v) -- | Defines a markdown file. @@ -35,14 +35,14 @@ readMe :: (AuxiliarySym r) => ReadMeInfo -> r (Auxiliary r) readMe rmi= auxFromData readMeName (makeReadMe rmi) -- | Defines a sample input file. -sampleInput :: (AuxiliarySym r) => ChunkDB -> DataDesc -> [Expr] -> +sampleInput :: (AuxiliarySym r) => ChunkDB -> DataDesc -> [Expr] -> r (Auxiliary r) sampleInput db d sd = auxFromData sampleInputName (makeInputFile db d sd) -- | Defines a Makefile. -makefile :: (AuxiliarySym r) => Maybe BuildConfig -> Maybe Runnable -> +makefile :: (AuxiliarySym r) => Maybe BuildConfig -> Maybe Runnable -> Maybe DocConfig -> GOOLState -> ProgData -> r (Auxiliary r) -makefile bc r dc s p = auxFromData makefileName (makeBuild dc bc r s p) +makefile bc r d s p = auxFromData makefileName (makeBuild d bc r s p) -- | Changes a 'Runnable' to 'Nothing' if the user chose 'Library' for the 'ImplementationType'. noRunIfLib :: ImplementationType -> Maybe Runnable -> Maybe Runnable diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/PythonRenderer.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/PythonRenderer.hs index eef9a93921..65f92d889a 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/PythonRenderer.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/PythonRenderer.hs @@ -5,11 +5,11 @@ module Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.PythonRenderer ( PythonProject(..) ) where -import Language.Drasil.Code.Imperative.GOOL.ClassInterface (ReadMeInfo(..),PackageSym(..), +import Language.Drasil.Code.Imperative.GOOL.ClassInterface (ReadMeInfo(..),PackageSym(..), AuxiliarySym(..)) -import qualified - Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.LanguagePolymorphic as - G (doxConfig, readMe, sampleInput, makefile, noRunIfLib, doxDocConfig, +import qualified + Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.LanguagePolymorphic as + G (doxConfig, readMe, sampleInput, makefile, noRunIfLib, doxDocConfig, docIfEnabled) import Language.Drasil.Code.Imperative.GOOL.Data (AuxData(..), ad, PackData(..), packD) diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/SwiftRenderer.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/SwiftRenderer.hs index 43cdeaa299..15504c381e 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/SwiftRenderer.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/GOOL/LanguageRenderer/SwiftRenderer.hs @@ -8,12 +8,12 @@ module Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.SwiftRenderer ( import Language.Drasil.Choices (ImplementationType(..)) import Language.Drasil.Code.Imperative.GOOL.ClassInterface (ReadMeInfo(..), PackageSym(..), AuxiliarySym(..)) -import qualified - Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.LanguagePolymorphic as +import qualified + Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.LanguagePolymorphic as G (sampleInput, readMe, makefile, noRunIfLib, docIfEnabled) import Language.Drasil.Code.Imperative.GOOL.Data (AuxData(..), ad, PackData(..), packD) -import Language.Drasil.Code.Imperative.Build.AST (BuildConfig, Runnable, +import Language.Drasil.Code.Imperative.Build.AST (BuildConfig, Runnable, DocConfig(..), asFragment, buildAll, nativeBinary, executable, sharedLibrary) import GOOL.Drasil (onCodeList, swiftName, swiftVersion) @@ -70,4 +70,4 @@ swiftRunnable = nativeBinary -- | Swift is not compatible with Doxygen, so raise an error if trying to compile Doxygen documentation. doxError :: String -doxError = swiftName ++ " is not compatible with Doxygen." \ No newline at end of file +doxError = swiftName ++ " is not compatible with Doxygen." diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/GenODE.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/GenODE.hs index 3fe4575321..83202993cd 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/GenODE.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/GenODE.hs @@ -3,7 +3,7 @@ module Language.Drasil.Code.Imperative.GenODE ( ) where import Language.Drasil (Sentence(..), (+:+.)) -import Language.Drasil.Code.ExtLibImport (ExtLibState(..), +import Language.Drasil.Code.ExtLibImport (ExtLibState(..), genExternalLibraryCall) import Language.Drasil.Code.Lang (Lang(..)) import Language.Drasil.Chunk.Code (codeName) @@ -27,25 +27,25 @@ chooseODELib :: Lang -> Maybe ODE -> State [Sentence] ODEGenInfo chooseODELib _ Nothing = return (Nothing, [], ("","")) chooseODELib l (Just ode) = chooseODELib' (odeLib ode) (odeLib ode) where chooseODELib' :: [ODELibPckg] -> [ODELibPckg] -> State [Sentence] ODEGenInfo - chooseODELib' _ [] = error $ "None of the chosen ODE libraries are " ++ + chooseODELib' _ [] = error $ "None of the chosen ODE libraries are " ++ "compatible with " ++ show l - chooseODELib' prefLibList (o:os) = if l `elem` compatibleLangs o - then do + chooseODELib' prefLibList (o:os) = if l `elem` compatibleLangs o + then do modify (++ [firstChoiceODELib prefLibList o]) - return (libPath o, map (\ode' -> (codeName $ odeDef ode', - genExternalLibraryCall (libSpec o) $ libCall o ode')) $ odeInfo ode, - (libName o, libVers o)) + return (libPath o, map (\ode' -> (codeName $ odeDef ode', + genExternalLibraryCall (libSpec o) $ libCall o ode')) $ odeInfo ode, + (libName o, libVers o)) else modify (++ [incompatibleLib l o]) >> chooseODELib' prefLibList os --- | Defines a design log message based on an incompatibility between the given +-- | Defines a design log message based on an incompatibility between the given -- 'Lang' and chosen 'ODELibPckg'. incompatibleLib :: Lang -> ODELibPckg -> Sentence -incompatibleLib lng lib = S $ "Language " ++ show lng ++ " is not " ++ - "compatible with chosen library " ++ libName lib ++ ", trying next choice." +incompatibleLib lng lib = S $ "Language " ++ show lng ++ " is not " ++ + "compatible with chosen library " ++ libName lib ++ ", trying next choice." -- | Defines a design log message if the first choice ODE Library, which is the head of -- the preference list that the user selected, is compatible with the given 'Lang'. firstChoiceODELib :: [ODELibPckg] -> ODELibPckg -> Sentence -firstChoiceODELib prefer olp = if libName (head prefer) == libName olp then - S "Successfully selected first choice ODE Library package" +:+. S (libName olp) - else S "ODE Library package selected as" +:+. S (libName olp) \ No newline at end of file +firstChoiceODELib prefer olp = if libName (head prefer) == libName olp then + S "Successfully selected first choice ODE Library package" +:+. S (libName olp) + else S "ODE Library package selected as" +:+. S (libName olp) diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/GenerateGOOL.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/GenerateGOOL.hs index 535da3cbc5..245c201b38 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/GenerateGOOL.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/GenerateGOOL.hs @@ -1,5 +1,5 @@ module Language.Drasil.Code.Imperative.GenerateGOOL (ClassType(..), - genModuleWithImports, genModule, genDoxConfig, genReadMe, + genModuleWithImports, genModule, genDoxConfig, genReadMe, primaryClass, auxClass, fApp, ctorCall, fAppInOut ) where @@ -10,10 +10,10 @@ import Language.Drasil.Code.Imperative.GOOL.ClassInterface (ReadMeInfo(..), import Language.Drasil.Choices (Comments(..), AuxFile(..)) import Language.Drasil.CodeSpec (CodeSpec(..)) import Language.Drasil.Mod (Name, Description, Import) - -import GOOL.Drasil (SFile, VSType, SVariable, SValue, MSStatement, SMethod, - CSStateVar, SClass, NamedArgs, OOProg, FileSym(..), TypeElim(..), - ValueSym(..), Argument(..), ValueExpression(..), FuncAppStatement(..), + +import GOOL.Drasil (SFile, VSType, SVariable, SValue, MSStatement, SMethod, + CSStateVar, SClass, NamedArgs, OOProg, FileSym(..), TypeElim(..), + ValueSym(..), Argument(..), ValueExpression(..), FuncAppStatement(..), ClassSym(..), ModuleSym(..), CodeType(..), GOOLState) import Data.Bifunctor (second) @@ -26,8 +26,8 @@ import Control.Monad.State (get, modify) -- 'CommentFunc', a module-level Doxygen comment is still created, though it only -- documents the file name, because without this Doxygen will not find the -- function-level comments in the file. -genModuleWithImports :: (OOProg r) => Name -> Description -> [Import] -> - [GenState (Maybe (SMethod r))] -> +genModuleWithImports :: (OOProg r) => Name -> Description -> [Import] -> + [GenState (Maybe (SMethod r))] -> [GenState (Maybe (SClass r))] -> GenState (SFile r) genModuleWithImports n desc is maybeMs maybeCs = do g <- get @@ -36,16 +36,16 @@ genModuleWithImports n desc is maybeMs maybeCs = do let as = case codeSpec g of CodeSpec {authors = a} -> map name a cs <- sequence maybeCs ms <- sequence maybeMs - let commMod | CommentMod `elem` commented g = docMod desc + let commMod | CommentMod `elem` commented g = docMod desc as (date g) - | CommentFunc `elem` commented g && not (null ms) = docMod "" [] + | CommentFunc `elem` commented g && not (null ms) = docMod "" [] "" | otherwise = id return $ commMod $ fileDoc $ buildModule n is (catMaybes ms) (catMaybes cs) -- | Generates a module for when imports do not need to be explicitly stated. -genModule :: (OOProg r) => Name -> Description -> - [GenState (Maybe (SMethod r))] -> +genModule :: (OOProg r) => Name -> Description -> + [GenState (Maybe (SMethod r))] -> [GenState (Maybe (SClass r))] -> GenState (SFile r) genModule n desc = genModuleWithImports n desc [] @@ -60,7 +60,7 @@ genDoxConfig s = do -- | Generates a README file. genReadMe :: (AuxiliarySym r) => ReadMeInfo -> GenState (Maybe (r (Auxiliary r))) -genReadMe rmi = do +genReadMe rmi = do g <- get let n = pName $ codeSpec g return $ getReadMe (auxiliaries g) rmi {caseName = n} @@ -71,10 +71,10 @@ getReadMe auxl rmi = if ReadME `elem` auxl then Just (readMe rmi) else Nothing data ClassType = Primary | Auxiliary --- | Generates a primary or auxiliary class with the given name, description, --- state variables, and methods. The 'Maybe' 'Name' parameter is the name of the +-- | Generates a primary or auxiliary class with the given name, description, +-- state variables, and methods. The 'Maybe' 'Name' parameter is the name of the -- interface the class implements, if applicable. -mkClass :: (OOProg r) => ClassType -> Name -> Maybe Name -> Description -> +mkClass :: (OOProg r) => ClassType -> Name -> Maybe Name -> Description -> [CSStateVar r] -> GenState [SMethod r] -> GenState (SClass r) mkClass s n l desc vs mths = do @@ -87,23 +87,23 @@ mkClass s n l desc vs mths = do getFunc' Nothing = buildClass Nothing getFunc' (Just intfc) = implementingClass n [intfc] c = getFunc s vs ms - return $ if CommentClass `elem` commented g + return $ if CommentClass `elem` commented g then docClass desc c else c -- | Generates a primary class. -primaryClass :: (OOProg r) => Name -> Maybe Name -> Description -> - [CSStateVar r] -> GenState [SMethod r] -> +primaryClass :: (OOProg r) => Name -> Maybe Name -> Description -> + [CSStateVar r] -> GenState [SMethod r] -> GenState (SClass r) primaryClass = mkClass Primary -- | Generates an auxiliary class (for when a module contains multiple classes). -auxClass :: (OOProg r) => Name -> Maybe Name -> Description -> - [CSStateVar r] -> GenState [SMethod r] -> +auxClass :: (OOProg r) => Name -> Maybe Name -> Description -> + [CSStateVar r] -> GenState [SMethod r] -> GenState (SClass r) auxClass = mkClass Auxiliary --- | Converts lists or objects to pointer arguments, since we use pointerParam +-- | Converts lists or objects to pointer arguments, since we use pointerParam -- for list or object-type parameters. mkArg :: (OOProg r) => SValue r -> SValue r mkArg v = do @@ -127,35 +127,35 @@ fCall f vl ns = do -- | Function call generator. -- The first parameter (@m@) is the module where the function is defined. --- If @m@ is not the current module, use GOOL's function for calling functions from +-- If @m@ is not the current module, use GOOL's function for calling functions from -- external modules. --- If @m@ is the current module and the function is in export map, use GOOL's basic +-- If @m@ is the current module and the function is in export map, use GOOL's basic -- function for function applications. --- If @m@ is the current module and function is not exported, use GOOL's function for --- calling a method on self. This assumes all private methods are dynamic, +-- If @m@ is the current module and function is not exported, use GOOL's function for +-- calling a method on self. This assumes all private methods are dynamic, -- which is true for this generator. -fApp :: (OOProg r) => Name -> Name -> VSType r -> [SValue r] -> +fApp :: (OOProg r) => Name -> Name -> VSType r -> [SValue r] -> NamedArgs r -> GenState (SValue r) fApp m s t vl ns = do g <- get - fCall (\cm args nargs -> - if m /= cm then extFuncAppMixedArgs m s t args nargs else + fCall (\cm args nargs -> + if m /= cm then extFuncAppMixedArgs m s t args nargs else if Map.lookup s (eMap g) == Just cm then funcAppMixedArgs s t args nargs else selfFuncAppMixedArgs s t args nargs) vl ns --- | Logic similar to 'fApp', but the self case is not required here +-- | Logic similar to 'fApp', but the self case is not required here -- (because constructor will never be private). Calls 'newObjMixedArgs'. -ctorCall :: (OOProg r) => Name -> VSType r -> [SValue r] -> NamedArgs r +ctorCall :: (OOProg r) => Name -> VSType r -> [SValue r] -> NamedArgs r -> GenState (SValue r) -ctorCall m t = fCall (\cm args nargs -> if m /= cm then +ctorCall m t = fCall (\cm args nargs -> if m /= cm then extNewObjMixedArgs m t args nargs else newObjMixedArgs t args nargs) -- | Logic similar to 'fApp', but for In/Out calls. -fAppInOut :: (OOProg r) => Name -> Name -> [SValue r] -> +fAppInOut :: (OOProg r) => Name -> Name -> [SValue r] -> [SVariable r] -> [SVariable r] -> GenState (MSStatement r) fAppInOut m n ins outs both = do g <- get let cm = currentModule g return $ if m /= cm then extInOutCall m n ins outs both else if Map.lookup n - (eMap g) == Just cm then inOutCall n ins outs both else + (eMap g) == Just cm then inOutCall n ins outs both else selfInOutCall n ins outs both diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Generator.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Generator.hs index 21efb2b7cf..4dbe969aee 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Generator.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Generator.hs @@ -76,7 +76,6 @@ generator l dt sd chs spec = DrasilState { clsMap = cdm, defList = nub $ keys mem ++ keys cdm, getVal = folderVal chs, - -- stateful currentModule = "", currentClass = "", @@ -98,7 +97,7 @@ generator l dt sd chs spec = DrasilState { (nonPrefChs ++ concLog ++ libLog) -- | Generates a package with the given 'DrasilState'. The passed --- un-representation functions determine which target language the package will +-- un-representation functions determine which target language the package will -- be generated in. generateCode :: (OOProg progRepr, PackageSym packRepr) => Lang -> (progRepr (Program progRepr) -> ProgData) -> (packRepr (Package packRepr) -> @@ -117,11 +116,11 @@ generateCode l unReprProg unReprPack g = do createCodeFiles code setCurrentDirectory workingDir --- | Generates a package, including a Makefile, sample input file, and Doxygen --- configuration file (all subject to the user's choices). --- The passed un-representation function determines which target language the +-- | Generates a package, including a Makefile, sample input file, and Doxygen +-- configuration file (all subject to the user's choices). +-- The passed un-representation function determines which target language the -- package will be generated in. --- GOOL's static code analysis interpreter is called to initialize the state +-- GOOL's static code analysis interpreter is called to initialize the state -- used by the language renderer. genPackage :: (OOProg progRepr, PackageSym packRepr) => (progRepr (Program progRepr) -> ProgData) -> @@ -137,10 +136,10 @@ genPackage unRepr = do as = case codeSpec g of CodeSpec {authors = a} -> map name a cfp = configFiles $ codeSpec g db = sysinfodb $ codeSpec g - prps = show $ sentenceDoc db Implementation Linear + prps = show $ sentenceDoc db Implementation Linear (foldlSent $ purpose $ codeSpec g) - bckgrnd = show $ sentenceDoc db Implementation Linear - (foldlSent $ background $ codeSpec g) + bckgrnd = show $ sentenceDoc db Implementation Linear + (foldlSent $ background $ codeSpec g) i <- genSampleInput d <- genDoxConfig s rm <- genReadMe ReadMeInfo { @@ -168,7 +167,7 @@ genProgram = do let p = show $ sentenceDoc (sysinfodb $ codeSpec g) Implementation Linear $ foldlSent $ purpose $ codeSpec g return $ prog n p ms --- | Generates either a single module or many modules, based on the users choice +-- | Generates either a single module or many modules, based on the users choice -- of modularity. chooseModules :: (OOProg r) => Modularity -> GenState [SFile r] chooseModules Unmodular = liftS genUnmodular @@ -209,4 +208,4 @@ getDir Cpp = "cpp" getDir CSharp = "csharp" getDir Java = "java" getDir Python = "python" -getDir Swift = "swift" \ No newline at end of file +getDir Swift = "swift" diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Import.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Import.hs index f09507dd6c..f35f9ac9b2 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Import.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Import.hs @@ -1,8 +1,8 @@ {-# LANGUAGE PostfixOperators, Rank2Types #-} {-# OPTIONS_GHC -Wno-redundant-constraints #-} -module Language.Drasil.Code.Imperative.Import (codeType, spaceCodeType, - publicFunc, privateMethod, publicInOutFunc, privateInOutMethod, - genConstructor, mkVar, mkVal, convExpr, convStmt, genModDef, genModFuncs, +module Language.Drasil.Code.Imperative.Import (codeType, spaceCodeType, + publicFunc, privateMethod, publicInOutFunc, privateInOutMethod, + genConstructor, mkVar, mkVal, convExpr, convStmt, genModDef, genModFuncs, genModClasses, readData, renderC ) where @@ -21,31 +21,31 @@ import Language.Drasil.Code.Imperative.GenerateGOOL (auxClass, fApp, ctorCall, import Language.Drasil.Code.Imperative.Helpers (lookupC) import Language.Drasil.Code.Imperative.Logging (maybeLog, logBody) import Language.Drasil.Code.Imperative.DrasilState (GenState, DrasilState(..)) -import Language.Drasil.Chunk.Code (CodeIdea(codeName), CodeVarChunk, obv, +import Language.Drasil.Chunk.Code (CodeIdea(codeName), CodeVarChunk, obv, quantvar, quantfunc, ccObjVar, DefiningCodeExpr(..)) import Language.Drasil.Chunk.Parameter (ParameterChunk(..), PassBy(..), pcAuto) import Language.Drasil.Code.CodeQuantityDicts (inFileName, inParams, consts) import Language.Drasil.Choices (Comments(..), ConstantRepr(..), ConstantStructure(..), Structure(..)) import Language.Drasil.CodeSpec (CodeSpec(..)) -import Language.Drasil.Code.DataDesc (DataItem, LinePattern(Repeat, Straight), +import Language.Drasil.Code.DataDesc (DataItem, LinePattern(Repeat, Straight), Data(Line, Lines, JunkData, Singleton), DataDesc, isLine, isLines, getInputs, getPatternInputs) import Language.Drasil.Literal.Development -import Language.Drasil.Mod (Func(..), FuncData(..), FuncDef(..), FuncStmt(..), +import Language.Drasil.Mod (Func(..), FuncData(..), FuncDef(..), FuncStmt(..), Mod(..), Name, Description, StateVariable(..), fstdecl) import qualified Language.Drasil.Mod as M (Class(..)) -import GOOL.Drasil (Label, SFile, MSBody, MSBlock, VSType, SVariable, SValue, - MSStatement, MSParameter, SMethod, CSStateVar, SClass, NamedArgs, - Initializers, OOProg, PermanenceSym(..), bodyStatements, BlockSym(..), - TypeSym(..), VariableSym(..), VariableElim(..), ($->), ValueSym(..), - Literal(..), VariableValue(..), NumericExpression(..), BooleanExpression(..), - Comparison(..), ValueExpression(..), objMethodCallMixedArgs, List(..), +import GOOL.Drasil (Label, SFile, MSBody, MSBlock, VSType, SVariable, SValue, + MSStatement, MSParameter, SMethod, CSStateVar, SClass, NamedArgs, + Initializers, OOProg, PermanenceSym(..), bodyStatements, BlockSym(..), + TypeSym(..), VariableSym(..), VariableElim(..), ($->), ValueSym(..), + Literal(..), VariableValue(..), NumericExpression(..), BooleanExpression(..), + Comparison(..), ValueExpression(..), objMethodCallMixedArgs, List(..), StatementSym(..), AssignStatement(..), DeclStatement(..), IOStatement(..), - StringStatement(..), ControlStatement(..), ifNoElse, ScopeSym(..), - ParameterSym(..), MethodSym(..), pubDVar, privDVar, nonInitConstructor, - convType, ScopeTag(..), CodeType(..), onStateValue) + StringStatement(..), ControlStatement(..), ifNoElse, ScopeSym(..), + ParameterSym(..), MethodSym(..), pubDVar, privDVar, nonInitConstructor, + convType, ScopeTag(..), CodeType(..), onStateValue) import qualified GOOL.Drasil as C (CodeType(List, Array)) import Prelude hiding (sin, cos, tan, log, exp) @@ -55,7 +55,7 @@ import Control.Monad (liftM2,liftM3) import Control.Monad.State (get) import Control.Lens ((^.)) --- | Gets a chunk's 'CodeType', by checking which 'CodeType' the user has chosen to +-- | Gets a chunk's 'CodeType', by checking which 'CodeType' the user has chosen to -- match the chunk's 'Space' to. codeType :: (HasSpace c) => c -> GenState CodeType codeType c = spaceCodeType (c ^. typ) @@ -66,11 +66,11 @@ spaceCodeType s = do g <- get spaceMatches g s --- | If 'UID' for the variable is matched to a concept, call 'conceptToGOOL' to get +-- | If 'UID' for the variable is matched to a concept, call 'conceptToGOOL' to get -- the GOOL code for the concept, and return. --- If 'UID' is for a constant and user has chosen 'Inline', convert the constant's +-- If 'UID' is for a constant and user has chosen 'Inline', convert the constant's -- defining 'Expr' to a value with 'convExpr'. --- Otherwise, just a regular variable: construct it by calling the variable, then +-- Otherwise, just a regular variable: construct it by calling the variable, then -- call 'valueOf' to reference its value. value :: (OOProg r) => UID -> Name -> VSType r -> GenState (SValue r) value u s t = do @@ -99,20 +99,20 @@ variable s t = do let cs = codeSpec g defFunc Var = var defFunc Const = staticVar - if s `elem` map codeName (inputs cs) + if s `elem` map codeName (inputs cs) then inputVariable (inStruct g) Var (var s t) else if s `elem` map codeName (constants $ codeSpec g) then constVariable (conStruct g) (conRepr g) ((defFunc $ conRepr g) s t) else return $ var s t - + -- | If 'Unbundled' inputs, just return variable as-is. --- If 'Bundled' inputs, access variable through object, where the object is self +-- If 'Bundled' inputs, access variable through object, where the object is self -- if current module is InputParameters, 'inParams' otherwise. --- Final case is for when 'constVariable' calls inputVariable, when user chooses +-- Final case is for when 'constVariable' calls inputVariable, when user chooses -- WithInputs for constant structure, inputs are 'Bundled', and constant --- representation is 'Const'. Variable should be accessed through class, so +-- representation is 'Const'. Variable should be accessed through class, so -- 'classVariable' is called. -inputVariable :: (OOProg r) => Structure -> ConstantRepr -> SVariable r -> +inputVariable :: (OOProg r) => Structure -> ConstantRepr -> SVariable r -> GenState (SVariable r) inputVariable Unbundled _ v = return v inputVariable Bundled Var v = do @@ -125,14 +125,14 @@ inputVariable Bundled Const v = do classVariable ip v -- | If 'Unbundled' constants, just return variable as-is. --- If 'Bundled' constants and 'Var' constant representation, access variable +-- If 'Bundled' constants and 'Var' constant representation, access variable -- through 'consts' object. --- If 'Bundled' constants and 'Const' constant representation, access variable +-- If 'Bundled' constants and 'Const' constant representation, access variable -- through class, so call 'classVariable'. -- If constants stored 'WithInputs', call 'inputVariable'. --- If constants are 'Inline'd, the generator should not be attempting to make a +-- If constants are 'Inline'd, the generator should not be attempting to make a -- variable for one of the constants. -constVariable :: (OOProg r) => ConstantStructure -> ConstantRepr -> +constVariable :: (OOProg r) => ConstantStructure -> ConstantRepr -> SVariable r -> GenState (SVariable r) constVariable (Store Unbundled) _ v = return v constVariable (Store Bundled) Var v = do @@ -148,11 +148,11 @@ constVariable Inline _ _ = error $ "mkVar called on a constant, but user " ++ "chose to Inline constants. Generator has a bug." -- | For generating GOOL for a variable that is accessed through a class. --- If the variable is not in the export map, then it is not a public class variable +-- If the variable is not in the export map, then it is not a public class variable -- and cannot be accessed, so throw an error. -- If the variable is exported by the current module, use 'classVar'. -- If the variable is exported by a different module, use 'extClassVar'. -classVariable :: (OOProg r) => SVariable r -> SVariable r -> +classVariable :: (OOProg r) => SVariable r -> SVariable r -> GenState (SVariable r) classVariable c v = do g <- get @@ -160,7 +160,7 @@ classVariable c v = do return $ do v' <- v let nm = variableName v' - maybe (error $ "Variable " ++ nm ++ " missing from export map") + maybe (error $ "Variable " ++ nm ++ " missing from export map") checkCurrent (Map.lookup nm (eMap g)) (onStateValue variableType c) v -- | Generates a GOOL Value for a variable represented by a 'CodeVarChunk'. @@ -170,7 +170,7 @@ mkVal v = do let toGOOLVal Nothing = value (v ^. uid) (codeName v) (convType t) toGOOLVal (Just o) = do ot <- codeType o - return $ valueOf $ objVar (var (codeName o) (convType ot)) + return $ valueOf $ objVar (var (codeName o) (convType ot)) (var (codeName v) (convType t)) toGOOLVal (v ^. obv) @@ -181,7 +181,7 @@ mkVar v = do let toGOOLVar Nothing = variable (codeName v) (convType t) toGOOLVar (Just o) = do ot <- codeType o - return $ objVar (var (codeName o) (convType ot)) + return $ objVar (var (codeName o) (convType ot)) (var (codeName v) (convType t)) toGOOLVar (v ^. obv) @@ -194,49 +194,49 @@ mkParam p = do paramFunc Val = param -- | Generates a public function. -publicFunc :: (OOProg r) => Label -> VSType r -> Description -> - [ParameterChunk] -> Maybe Description -> [MSBlock r] -> +publicFunc :: (OOProg r) => Label -> VSType r -> Description -> + [ParameterChunk] -> Maybe Description -> [MSBlock r] -> GenState (SMethod r) publicFunc n t = genMethod (function n public t) n -- | Generates a public method. -publicMethod :: (OOProg r) => Label -> VSType r -> Description -> - [ParameterChunk] -> Maybe Description -> [MSBlock r] -> +publicMethod :: (OOProg r) => Label -> VSType r -> Description -> + [ParameterChunk] -> Maybe Description -> [MSBlock r] -> GenState (SMethod r) publicMethod n t = genMethod (method n public dynamic t) n -- | Generates a private method. -privateMethod :: (OOProg r) => Label -> VSType r -> Description -> - [ParameterChunk] -> Maybe Description -> [MSBlock r] -> +privateMethod :: (OOProg r) => Label -> VSType r -> Description -> + [ParameterChunk] -> Maybe Description -> [MSBlock r] -> GenState (SMethod r) privateMethod n t = genMethod (method n private dynamic t) n -- | Generates a public function, defined by its inputs and outputs. -publicInOutFunc :: (OOProg r) => Label -> Description -> [CodeVarChunk] -> +publicInOutFunc :: (OOProg r) => Label -> Description -> [CodeVarChunk] -> [CodeVarChunk] -> [MSBlock r] -> GenState (SMethod r) publicInOutFunc n = genInOutFunc (inOutFunc n public) (docInOutFunc n public) n -- | Generates a private method, defined by its inputs and outputs. -privateInOutMethod :: (OOProg r) => Label -> Description -> [CodeVarChunk] -> +privateInOutMethod :: (OOProg r) => Label -> Description -> [CodeVarChunk] -> [CodeVarChunk] -> [MSBlock r] -> GenState (SMethod r) privateInOutMethod n = genInOutFunc (inOutMethod n private dynamic) (docInOutMethod n private dynamic) n -- | Generates a constructor. -genConstructor :: (OOProg r) => Label -> Description -> [ParameterChunk] -> +genConstructor :: (OOProg r) => Label -> Description -> [ParameterChunk] -> [MSBlock r] -> GenState (SMethod r) genConstructor n desc p = genMethod nonInitConstructor n desc p Nothing -- | Generates a constructor that includes initialization of variables. -genInitConstructor :: (OOProg r) => Label -> Description -> [ParameterChunk] +genInitConstructor :: (OOProg r) => Label -> Description -> [ParameterChunk] -> Initializers r -> [MSBlock r] -> GenState (SMethod r) -genInitConstructor n desc p is = genMethod (`constructor` is) n desc p +genInitConstructor n desc p is = genMethod (`constructor` is) n desc p Nothing --- | Generates a function or method using the passed GOOL constructor. Other --- parameters are the method's name, description, list of parameters, +-- | Generates a function or method using the passed GOOL constructor. Other +-- parameters are the method's name, description, list of parameters, -- description of what is returned (if applicable), and body. -genMethod :: (OOProg r) => ([MSParameter r] -> MSBody r -> SMethod r) -> - Label -> Description -> [ParameterChunk] -> Maybe Description -> [MSBlock r] +genMethod :: (OOProg r) => ([MSParameter r] -> MSBody r -> SMethod r) -> + Label -> Description -> [ParameterChunk] -> Maybe Description -> [MSBlock r] -> GenState (SMethod r) genMethod f n desc p r b = do g <- get @@ -248,15 +248,15 @@ genMethod f n desc p r b = do return $ if CommentFunc `elem` commented g then docFunc desc pComms r fn else fn --- | Generates a function or method defined by its inputs and outputs. --- Parameters are: the GOOL constructor to use, the equivalent GOOL constructor --- for a documented function/method, the scope, permanence, name, description, +-- | Generates a function or method defined by its inputs and outputs. +-- Parameters are: the GOOL constructor to use, the equivalent GOOL constructor +-- for a documented function/method, the scope, permanence, name, description, -- list of inputs, list of outputs, and body. -genInOutFunc :: (OOProg r) => ([SVariable r] -> [SVariable r] -> - [SVariable r] -> MSBody r -> SMethod r) -> - (String -> [(String, SVariable r)] -> [(String, SVariable r)] -> +genInOutFunc :: (OOProg r) => ([SVariable r] -> [SVariable r] -> + [SVariable r] -> MSBody r -> SMethod r) -> + (String -> [(String, SVariable r)] -> [(String, SVariable r)] -> [(String, SVariable r)] -> MSBody r -> SMethod r) - -> Label -> Description -> [CodeVarChunk] -> [CodeVarChunk] -> + -> Label -> Description -> [CodeVarChunk] -> [CodeVarChunk] -> [MSBlock r] -> GenState (SMethod r) genInOutFunc f docf n desc ins' outs' b = do g <- get @@ -270,8 +270,8 @@ genInOutFunc f docf n desc ins' outs' b = do pComms <- mapM getComment ins oComms <- mapM getComment outs bComms <- mapM getComment both - return $ if CommentFunc `elem` commented g - then docf desc (zip pComms inVs) (zip oComms outVs) (zip + return $ if CommentFunc `elem` commented g + then docf desc (zip pComms inVs) (zip oComms outVs) (zip bComms bothVs) bod else f inVs outVs bothVs bod -- | Converts an 'Expr' to a GOOL Value. @@ -302,15 +302,15 @@ convExpr (C c) = do let v = quantvar (lookupC g c) mkVal v convExpr (FCall c x ns) = convCall c x ns fApp libFuncAppMixedArgs -convExpr (New c x ns) = convCall c x ns (\m _ -> ctorCall m) +convExpr (New c x ns) = convCall c x ns (\m _ -> ctorCall m) (\m _ -> libNewObjMixedArgs m) convExpr (Message a m x ns) = do g <- get let info = sysinfodb $ codeSpec g objCd = quantvar (symbResolve info a) o <- mkVal objCd - convCall m x ns - (\_ n t ps nas -> return (objMethodCallMixedArgs t o n ps nas)) + convCall m x ns + (\_ n t ps nas -> return (objMethodCallMixedArgs t o n ps nas)) (\_ n t -> objMethodCallMixedArgs t o n) convExpr (Field o f) = do g <- get @@ -340,7 +340,7 @@ convExpr (Case c l) = doit l -- FIXME this is sub-optimal where doit [] = error "should never happen" -- TODO: change error message? doit [(e,_)] = convExpr e -- should always be the else clause - doit ((e,cond):xs) = liftM3 inlineIf (convExpr cond) (convExpr e) + doit ((e,cond):xs) = liftM3 inlineIf (convExpr cond) (convExpr e) (convExpr (Case c xs)) convExpr (Matrix [l]) = do ar <- mapM convExpr l @@ -356,9 +356,9 @@ convExpr (RealI c ri) = do -- the function, the list of argument 'Expr's, the list of named argument 'Expr's, -- the function call generator to use, and the library version of the function -- call generator (used if the function is in the library export map). -convCall :: (OOProg r) => UID -> [CodeExpr] -> [(UID, CodeExpr)] -> - (Name -> Name -> VSType r -> [SValue r] -> NamedArgs r -> - GenState (SValue r)) -> (Name -> Name -> VSType r -> [SValue r] +convCall :: (OOProg r) => UID -> [CodeExpr] -> [(UID, CodeExpr)] -> + (Name -> Name -> VSType r -> [SValue r] -> NamedArgs r -> + GenState (SValue r)) -> (Name -> Name -> VSType r -> [SValue r] -> NamedArgs r -> SValue r) -> GenState (SValue r) convCall c x ns f libf = do g <- get @@ -369,14 +369,14 @@ convCall c x ns f libf = do funcNm = codeName funcCd funcTp <- codeType funcCd args <- mapM convExpr x - nms <- mapM (mkVar . quantvar . symbResolve info . fst) ns + nms <- mapM (mkVar . quantvar . symbResolve info . fst) ns nargs <- mapM (convExpr . snd) ns - maybe (maybe (error $ "Call to non-existent function " ++ funcNm) - (\m -> return $ libf m funcNm (convType funcTp) args (zip nms nargs)) + maybe (maybe (error $ "Call to non-existent function " ++ funcNm) + (\m -> return $ libf m funcNm (convType funcTp) args (zip nms nargs)) (Map.lookup funcNm lem)) - (\m -> f m funcNm (convType funcTp) args (zip nms nargs)) + (\m -> f m funcNm (convType funcTp) args (zip nms nargs)) (Map.lookup funcNm mem) - + -- | Converts a 'Constraint' to a 'CodeExpr'. renderC :: (HasUID c, HasSymbol c) => c -> Constraint CodeExpr -> CodeExpr renderC s (Range _ rr) = renderRealInt s rr @@ -468,10 +468,10 @@ numVecVecBfunc Scale = error "convExpr Scaling of Vectors" -- | Converts a 'Mod' to GOOL. genModDef :: (OOProg r) => Mod -> GenState (SFile r) -genModDef (Mod n desc is cs fs) = genModuleWithImports n desc is (map (fmap - Just . genFunc publicFunc []) fs) +genModDef (Mod n desc is cs fs) = genModuleWithImports n desc is (map (fmap + Just . genFunc publicFunc []) fs) (case cs of [] -> [] - (cl:cls) -> fmap Just (genClass primaryClass cl) : + (cl:cls) -> fmap Just (genClass primaryClass cl) : map (fmap Just . genClass auxClass) cls) -- | Converts a 'Mod'\'s functions to GOOL. @@ -482,30 +482,30 @@ genModFuncs (Mod _ _ _ _ fs) = map (genFunc publicFunc []) fs genModClasses :: (OOProg r) => Mod -> [GenState (SClass r)] genModClasses (Mod _ _ _ cs _) = map (genClass auxClass) cs --- | Converts a Class (from the Mod AST) to GOOL. +-- | Converts a Class (from the Mod AST) to GOOL. -- The class generator to use is passed as a parameter. -genClass :: (OOProg r) => (Name -> Maybe Name -> Description -> [CSStateVar r] - -> GenState [SMethod r] -> GenState (SClass r)) -> +genClass :: (OOProg r) => (Name -> Maybe Name -> Description -> [CSStateVar r] + -> GenState [SMethod r] -> GenState (SClass r)) -> M.Class -> GenState (SClass r) genClass f (M.ClassDef n i desc svs ms) = let svar Pub = pubDVar - svar Priv = privDVar + svar Priv = privDVar in do - svrs <- mapM (\(SV s v) -> fmap (svar s . var (codeName v) . convType) + svrs <- mapM (\(SV s v) -> fmap (svar s . var (codeName v) . convType) (codeType v)) svs f n i desc svrs (mapM (genFunc publicMethod svs) ms) -- | Converts a 'Func' (from the Mod AST) to GOOL. --- The function generator to use is passed as a parameter. Automatically adds --- variable declaration statements for any undeclared variables. For methods, --- the list of StateVariables is needed so they can be included in the list of +-- The function generator to use is passed as a parameter. Automatically adds +-- variable declaration statements for any undeclared variables. For methods, +-- the list of StateVariables is needed so they can be included in the list of -- declared variables. -genFunc :: (OOProg r) => (Name -> VSType r -> Description -> [ParameterChunk] - -> Maybe Description -> [MSBlock r] -> GenState (SMethod r)) -> +genFunc :: (OOProg r) => (Name -> VSType r -> Description -> [ParameterChunk] + -> Maybe Description -> [MSBlock r] -> GenState (SMethod r)) -> [StateVariable] -> Func -> GenState (SMethod r) genFunc f svs (FDef (FuncDef n desc parms o rd s)) = do g <- get stmts <- mapM convStmt s - vars <- mapM mkVar (fstdecl (sysinfodb $ codeSpec g) s + vars <- mapM mkVar (fstdecl (sysinfodb $ codeSpec g) s \\ (map quantvar parms ++ map stVar svs)) t <- spaceCodeType o f n (convType t) desc parms rd [block $ map varDec vars, block stmts] @@ -515,9 +515,9 @@ genFunc _ svs (FDef (CtorDef n desc parms i s)) = do initvars <- mapM ((\iv -> fmap (var (codeName iv) . convType) (codeType iv)) . fst) i stmts <- mapM convStmt s - vars <- mapM mkVar (fstdecl (sysinfodb $ codeSpec g) s + vars <- mapM mkVar (fstdecl (sysinfodb $ codeSpec g) s \\ (map quantvar parms ++ map stVar svs)) - genInitConstructor n desc parms (zip initvars inits) + genInitConstructor n desc parms (zip initvars inits) [block $ map varDec vars, block stmts] genFunc _ _ (FData (FuncData n desc ddef)) = genDataFunc n desc ddef @@ -531,7 +531,7 @@ convStmt (FAsg v (Matrix [es])) = do listFunc (C.Array _) = litArray listFunc _ = error "Type mismatch between variable and value in assignment FuncStmt" l <- maybeLog v' - return $ multi $ assign v' (listFunc t (listInnerType $ fmap variableType v') + return $ multi $ assign v' (listFunc t (listInnerType $ fmap variableType v') els) : l convStmt (FAsg v e) = do e' <- convExpr e @@ -587,7 +587,7 @@ convStmt (FDecDef v (Matrix [[]])) = do let convDec (C.List _) = listDec 0 vari convDec (C.Array _) = arrayDec 0 vari convDec _ = varDec vari - fmap convDec (codeType v) + fmap convDec (codeType v) convStmt (FDecDef v e) = do v' <- mkVar v l <- maybeLog v' @@ -619,14 +619,14 @@ convStmt (FAppend a b) = do b' <- convExpr b return $ valStmt $ listAppend a' b' --- | Generates a function that reads a file whose format is based on the passed +-- | Generates a function that reads a file whose format is based on the passed -- 'DataDesc'. -genDataFunc :: (OOProg r) => Name -> Description -> DataDesc -> +genDataFunc :: (OOProg r) => Name -> Description -> DataDesc -> GenState (SMethod r) genDataFunc nameTitle desc ddef = do let parms = getInputs ddef bod <- readData ddef - publicFunc nameTitle void desc (map pcAuto $ quantvar inFileName : parms) + publicFunc nameTitle void desc (map pcAuto $ quantvar inFileName : parms) Nothing bod -- this is really ugly!! @@ -635,7 +635,7 @@ readData :: (OOProg r) => DataDesc -> GenState [MSBlock r] readData ddef = do inD <- mapM inData ddef v_filename <- mkVal $ quantvar inFileName - return [block $ + return [block $ varDec var_infile : (if any (\d -> isLine d || isLines d) ddef then [varDec var_line, listDec 0 var_linetokens] else []) ++ [listDec 0 var_lines | any isLines ddef] ++ @@ -651,7 +651,7 @@ readData ddef = do inData (Line lp d) = do lnI <- lineData Nothing lp logs <- getEntryVarLogs lp - return $ [getFileInputLine v_infile var_line, + return $ [getFileInputLine v_infile var_line, stringSplit d var_linetokens v_line] ++ lnI ++ logs inData (Lines lp ls d) = do lnV <- lineData (Just "_temp") lp @@ -660,7 +660,7 @@ readData ddef = do forRange var_i (litInt 0) (listSize v_lines) (litInt 1) (bodyStatements $ stringSplit d var_linetokens ( listAccess v_lines v_i) : lnV)] - readLines (Just numLines) = [forRange var_i (litInt 0) + readLines (Just numLines) = [forRange var_i (litInt 0) (litInt numLines) (litInt 1) (bodyStatements $ [getFileInputLine v_infile var_line, @@ -668,7 +668,7 @@ readData ddef = do ] ++ lnV)] return $ readLines ls ++ logs --------------- - lineData :: (OOProg r) => Maybe String -> LinePattern -> + lineData :: (OOProg r) => Maybe String -> LinePattern -> GenState [MSStatement r] lineData s p@(Straight _) = do vs <- getEntryVars s p @@ -678,29 +678,29 @@ readData ddef = do sequence $ clearTemps s ds ++ return (stringListLists vs v_linetokens) : appendTemps s ds --------------- - clearTemps :: (OOProg r) => Maybe String -> [DataItem] -> + clearTemps :: (OOProg r) => Maybe String -> [DataItem] -> [GenState (MSStatement r)] clearTemps Nothing _ = [] clearTemps (Just sfx) es = map (clearTemp sfx) es --------------- - clearTemp :: (OOProg r) => String -> DataItem -> + clearTemp :: (OOProg r) => String -> DataItem -> GenState (MSStatement r) - clearTemp sfx v = fmap (\t -> listDecDef (var (codeName v ++ sfx) + clearTemp sfx v = fmap (\t -> listDecDef (var (codeName v ++ sfx) (listInnerType $ convType t)) []) (codeType v) --------------- - appendTemps :: (OOProg r) => Maybe String -> [DataItem] -> + appendTemps :: (OOProg r) => Maybe String -> [DataItem] -> [GenState (MSStatement r)] appendTemps Nothing _ = [] appendTemps (Just sfx) es = map (appendTemp sfx) es --------------- - appendTemp :: (OOProg r) => String -> DataItem -> + appendTemp :: (OOProg r) => String -> DataItem -> GenState (MSStatement r) - appendTemp sfx v = fmap (\t -> valStmt $ listAppend - (valueOf $ var (codeName v) (convType t)) + appendTemp sfx v = fmap (\t -> valStmt $ listAppend + (valueOf $ var (codeName v) (convType t)) (valueOf $ var (codeName v ++ sfx) (convType t))) (codeType v) --------------- l_line, l_lines, l_linetokens, l_infile, l_i :: Label - var_line, var_lines, var_linetokens, var_infile, var_i :: + var_line, var_lines, var_linetokens, var_infile, var_i :: (OOProg r) => SVariable r v_line, v_lines, v_linetokens, v_infile, v_i :: (OOProg r) => SValue r @@ -721,13 +721,13 @@ readData ddef = do v_i = valueOf var_i -- | Get entry variables. -getEntryVars :: (OOProg r) => Maybe String -> LinePattern -> +getEntryVars :: (OOProg r) => Maybe String -> LinePattern -> GenState [SVariable r] -getEntryVars s lp = mapM (maybe mkVar (\st v -> codeType v >>= (variable +getEntryVars s lp = mapM (maybe mkVar (\st v -> codeType v >>= (variable (codeName v ++ st) . listInnerType . convType)) s) (getPatternInputs lp) -- | Get entry variable logs. -getEntryVarLogs :: (OOProg r) => LinePattern -> +getEntryVarLogs :: (OOProg r) => LinePattern -> GenState [MSStatement r] getEntryVarLogs lp = do vs <- getEntryVars Nothing lp diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Logging.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Logging.hs index c7491b7c1d..a13301019c 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Logging.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Logging.hs @@ -5,47 +5,47 @@ module Language.Drasil.Code.Imperative.Logging ( import Language.Drasil.Code.Imperative.DrasilState (GenState, DrasilState(..)) import Language.Drasil.Choices (Logging(..)) -import GOOL.Drasil (Label, MSBody, MSBlock, SVariable, SValue, MSStatement, - OOProg, BodySym(..), BlockSym(..), TypeSym(..), VariableSym(..), - VariableElim(..), Literal(..), VariableValue(..), StatementSym(..), +import GOOL.Drasil (Label, MSBody, MSBlock, SVariable, SValue, MSStatement, + OOProg, BodySym(..), BlockSym(..), TypeSym(..), VariableSym(..), + VariableElim(..), Literal(..), VariableValue(..), StatementSym(..), DeclStatement(..), IOStatement(..), lensMStoVS) import Control.Lens.Zoom (zoom) import Control.Monad.State (get) --- | Generates a statement that logs the given variable's value, if the user +-- | Generates a statement that logs the given variable's value, if the user -- chose to turn on logging of variable assignments. maybeLog :: (OOProg r) => SVariable r -> GenState [MSStatement r] maybeLog v = do g <- get sequence [loggedVar v | LogVar `elem` logKind g] --- | Generates a statement that logs the name of the given variable, its current +-- | Generates a statement that logs the name of the given variable, its current -- value, and the current module name. loggedVar :: (OOProg r) => SVariable r -> GenState (MSStatement r) loggedVar v = do g <- get return $ multi [ openFileA varLogFile (litString $ logName g), - zoom lensMStoVS v >>= (\v' -> printFileStr valLogFile ("var '" ++ + zoom lensMStoVS v >>= (\v' -> printFileStr valLogFile ("var '" ++ variableName v' ++ "' assigned ")), printFile valLogFile (valueOf v), printFileStrLn valLogFile (" in module " ++ currentModule g), closeFile valLogFile ] --- | Generates the body of a function with the given name, list of parameters, --- and blocks to include in the body. If the user chose to turn on logging of --- function calls, statements that log how the function was called are added to +-- | Generates the body of a function with the given name, list of parameters, +-- and blocks to include in the body. If the user chose to turn on logging of +-- function calls, statements that log how the function was called are added to -- the beginning of the body. -logBody :: (OOProg r) => Label -> [SVariable r] -> [MSBlock r] -> +logBody :: (OOProg r) => Label -> [SVariable r] -> [MSBlock r] -> GenState (MSBody r) logBody n vars b = do - g <- get + g <- get return $ body $ [loggedMethod (logName g) n vars | LogFunc `elem` logKind g] ++ b --- | Generates a block that logs, to the given 'FilePath', the name of a function, --- and the names and values of the passed list of variables. Intended to be --- used as the first block in the function, to log that it was called and what +-- | Generates a block that logs, to the given 'FilePath', the name of a function, +-- and the names and values of the passed list of variables. Intended to be +-- used as the first block in the function, to log that it was called and what -- inputs it was called with. loggedMethod :: (OOProg r) => FilePath -> Label -> [SVariable r] -> MSBlock r loggedMethod lName n vars = block [ @@ -58,13 +58,13 @@ loggedMethod lName n vars = block [ where printInputs [] = [] printInputs [v] = [ - zoom lensMStoVS v >>= (\v' -> printFileStr valLogFile (" " ++ + zoom lensMStoVS v >>= (\v' -> printFileStr valLogFile (" " ++ variableName v' ++ " = ")), printFileLn valLogFile (valueOf v)] printInputs (v:vs) = [ - zoom lensMStoVS v >>= (\v' -> printFileStr valLogFile (" " ++ + zoom lensMStoVS v >>= (\v' -> printFileStr valLogFile (" " ++ variableName v' ++ " = ")), - printFile valLogFile (valueOf v), + printFile valLogFile (valueOf v), printFileStrLn valLogFile ", "] ++ printInputs vs -- | The variable representing the log file in write mode. @@ -73,4 +73,4 @@ varLogFile = var "outfile" outfile -- | The value of the variable representing the log file in write mode. valLogFile :: (OOProg r) => SValue r -valLogFile = valueOf varLogFile \ No newline at end of file +valLogFile = valueOf varLogFile diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Modules.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Modules.hs index c38ea7ff00..3c39850c7f 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Modules.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Modules.hs @@ -1,6 +1,6 @@ module Language.Drasil.Code.Imperative.Modules ( - genMain, genMainFunc, chooseInModule, genInputClass, genInputDerived, - genInputConstraints, genInputFormat, genConstMod, genConstClass, genCalcMod, + genMain, genMainFunc, chooseInModule, genInputClass, genInputDerived, + genInputConstraints, genInputFormat, genConstMod, genConstClass, genCalcMod, genCalcFunc, genOutputMod, genOutputFormat, genSampleInput ) where @@ -9,25 +9,25 @@ import Language.Drasil (Constraint(..), RealInterval(..), import Database.Drasil (ChunkDB) import Language.Drasil.CodeExpr.Development import Language.Drasil.Code.Imperative.Comments (getComment) -import Language.Drasil.Code.Imperative.Descriptions (constClassDesc, - constModDesc, derivedValuesDesc, dvFuncDesc, inConsFuncDesc, inFmtFuncDesc, - inputClassDesc, inputConstraintsDesc, inputConstructorDesc, inputFormatDesc, +import Language.Drasil.Code.Imperative.Descriptions (constClassDesc, + constModDesc, derivedValuesDesc, dvFuncDesc, inConsFuncDesc, inFmtFuncDesc, + inputClassDesc, inputConstraintsDesc, inputConstructorDesc, inputFormatDesc, inputParametersDesc, modDesc, outputFormatDesc, woFuncDesc, calcModDesc) import Language.Drasil.Code.Imperative.FunctionCalls (getCalcCall, getAllInputCalls, getOutputCall) -import Language.Drasil.Code.Imperative.GenerateGOOL (ClassType(..), genModule, +import Language.Drasil.Code.Imperative.GenerateGOOL (ClassType(..), genModule, genModuleWithImports, primaryClass, auxClass) import Language.Drasil.Code.Imperative.Helpers (liftS) import Language.Drasil.Code.Imperative.Import (codeType, convExpr, convStmt, - genConstructor, mkVal, mkVar, privateInOutMethod, privateMethod, publicFunc, + genConstructor, mkVal, mkVar, privateInOutMethod, privateMethod, publicFunc, publicInOutFunc, readData, renderC) import Language.Drasil.Code.Imperative.Logging (maybeLog, varLogFile) -import Language.Drasil.Code.Imperative.Parameters (getConstraintParams, - getDerivedIns, getDerivedOuts, getInConstructorParams, getInputFormatIns, +import Language.Drasil.Code.Imperative.Parameters (getConstraintParams, + getDerivedIns, getDerivedOuts, getInConstructorParams, getInputFormatIns, getInputFormatOuts, getCalcParams, getOutputParams) import Language.Drasil.Code.Imperative.DrasilState (GenState, DrasilState(..)) import Language.Drasil.Code.Imperative.GOOL.ClassInterface (AuxiliarySym(..)) -import Language.Drasil.Chunk.Code (CodeIdea(codeName), CodeVarChunk, quantvar, +import Language.Drasil.Chunk.Code (CodeIdea(codeName), CodeVarChunk, quantvar, DefiningCodeExpr(..)) import Language.Drasil.Chunk.CodeDefinition (CodeDefinition, DefinitionType(..), defType) @@ -36,19 +36,19 @@ import Language.Drasil.Chunk.Parameter (pcAuto) import Language.Drasil.Code.CodeQuantityDicts (inFileName, inParams, consts) import Language.Drasil.Code.DataDesc (DataDesc, junkLine, singleton) import Language.Drasil.Code.ExtLibImport (defs, imports, steps) -import Language.Drasil.Choices (Comments(..), ConstantStructure(..), - ConstantRepr(..), ConstraintBehaviour(..), ImplementationType(..), +import Language.Drasil.Choices (Comments(..), ConstantStructure(..), + ConstantRepr(..), ConstraintBehaviour(..), ImplementationType(..), InputModule(..), Logging(..), Structure(..), hasSampleInput) import Language.Drasil.CodeSpec (CodeSpec(..)) import Language.Drasil.Expr.Development (Completeness(..)) import Language.Drasil.Printers (Linearity(Linear), codeExprDoc) -import GOOL.Drasil (SFile, MSBody, MSBlock, SVariable, SValue, MSStatement, - SMethod, CSStateVar, SClass, OOProg, BodySym(..), bodyStatements, oneLiner, - BlockSym(..), PermanenceSym(..), TypeSym(..), VariableSym(..), Literal(..), - VariableValue(..), CommandLineArgs(..), BooleanExpression(..), - StatementSym(..), AssignStatement(..), DeclStatement(..), objDecNewNoParams, - extObjDecNewNoParams, IOStatement(..), ControlStatement(..), ifNoElse, +import GOOL.Drasil (SFile, MSBody, MSBlock, SVariable, SValue, MSStatement, + SMethod, CSStateVar, SClass, OOProg, BodySym(..), bodyStatements, oneLiner, + BlockSym(..), PermanenceSym(..), TypeSym(..), VariableSym(..), Literal(..), + VariableValue(..), CommandLineArgs(..), BooleanExpression(..), + StatementSym(..), AssignStatement(..), DeclStatement(..), objDecNewNoParams, + extObjDecNewNoParams, IOStatement(..), ControlStatement(..), ifNoElse, ScopeSym(..), MethodSym(..), StateVarSym(..), pubDVar, convType, ScopeTag(..)) import Prelude hiding (print) @@ -67,12 +67,12 @@ type ConstraintCE = Constraint CodeExpr -- | Generates a controller module. genMain :: (OOProg r) => GenState (SFile r) -genMain = genModule "Control" "Controls the flow of the program" +genMain = genModule "Control" "Controls the flow of the program" [genMainFunc] [] -- | Generates a main function, to act as the controller for an SCS program. --- The controller declares input and constant variables, then calls the --- functions for reading input values, calculating derived inputs, checking +-- The controller declares input and constant variables, then calls the +-- functions for reading input values, calculating derived inputs, checking -- constraints, calculating outputs, and printing outputs. -- Returns Nothing if the user chose to generate a library. genMainFunc :: (OOProg r) => GenState (Maybe (SMethod r)) @@ -87,56 +87,56 @@ genMainFunc = do ics <- getAllInputCalls varDef <- mapM getCalcCall (execOrder $ codeSpec g) wo <- getOutputCall - return $ Just $ (if CommentFunc `elem` commented g then docMain else - mainFunction) $ bodyStatements $ initLogFileVar (logKind g) - ++ varDecDef v_filename (arg 0) - : logInFile - -- Constants must be declared before inputs because some derived + return $ Just $ (if CommentFunc `elem` commented g then docMain else + mainFunction) $ bodyStatements $ initLogFileVar (logKind g) + ++ varDecDef v_filename (arg 0) + : logInFile + -- Constants must be declared before inputs because some derived -- input definitions or input constraints may use the constants ++ catMaybes [co, ip] ++ ics ++ catMaybes (varDef ++ [wo]) mainFunc $ implType g --- | If there are no inputs, the 'inParams' object still needs to be declared --- if inputs are 'Bundled', constants are stored 'WithInputs', and constant +-- | If there are no inputs, the 'inParams' object still needs to be declared +-- if inputs are 'Bundled', constants are stored 'WithInputs', and constant -- representation is 'Var'. --- If there are inputs and they are not exported by any module, then they are +-- If there are inputs and they are not exported by any module, then they are -- 'Unbundled' and are declared individually using 'varDec'. -- If there are inputs and they are exported by a module, they are 'Bundled' in -- the InputParameters class, so 'inParams' should be declared and constructed, --- using 'objDecNew' if the inputs are exported by the current module, and +-- using 'objDecNew' if the inputs are exported by the current module, and -- 'extObjDecNew' if they are exported by a different module. getInputDecl :: (OOProg r) => GenState (Maybe (MSStatement r)) getInputDecl = do g <- get v_params <- mkVar (quantvar inParams) - constrParams <- getInConstructorParams + constrParams <- getInConstructorParams cps <- mapM mkVal constrParams let cname = "InputParameters" - getDecl ([],[]) = constIns (partition (flip member (eMap g) . - codeName) (map quantvar $ constants $ codeSpec g)) (conRepr g) + getDecl ([],[]) = constIns (partition (flip member (eMap g) . + codeName) (map quantvar $ constants $ codeSpec g)) (conRepr g) (conStruct g) getDecl ([],ins) = do vars <- mapM mkVar ins return $ Just $ multi $ map varDec vars - getDecl (i:_,[]) = return $ Just $ (if currentModule g == - eMap g ! codeName i then objDecNew + getDecl (i:_,[]) = return $ Just $ (if currentModule g == + eMap g ! codeName i then objDecNew else extObjDecNew cname) v_params cps - getDecl _ = error ("Inputs or constants are only partially contained in " + getDecl _ = error ("Inputs or constants are only partially contained in " ++ "a class") constIns ([],[]) _ _ = return Nothing -- If Const is chosen, don't declare an object because constants are static and accessed through class constIns cs Var WithInputs = getDecl cs - constIns _ _ _ = return Nothing - getDecl (partition (flip member (eMap g) . codeName) + constIns _ _ _ = return Nothing + getDecl (partition (flip member (eMap g) . codeName) (inputs $ codeSpec g)) --- | If constants are 'Unbundled', declare them individually using 'varDecDef' if +-- | If constants are 'Unbundled', declare them individually using 'varDecDef' if -- representation is 'Var' and 'constDecDef' if representation is 'Const'. --- If constants are 'Bundled' independently and representation is 'Var', declare --- the consts object. If representation is 'Const', no object needs to be --- declared because the constants will be accessed directly through the +-- If constants are 'Bundled' independently and representation is 'Var', declare +-- the consts object. If representation is 'Const', no object needs to be +-- declared because the constants will be accessed directly through the -- Constants class. --- If constants are 'Bundled' 'WithInputs', do 'Nothing'; declaration of the 'inParams' +-- If constants are 'Bundled' 'WithInputs', do 'Nothing'; declaration of the 'inParams' -- object is handled by 'getInputDecl'. -- If constants are 'Inlined', nothing needs to be declared. initConsts :: (OOProg r) => GenState (Maybe (MSStatement r)) @@ -144,35 +144,35 @@ initConsts = do g <- get v_consts <- mkVar (quantvar consts) let cname = "Constants" - cs = constants $ codeSpec g + cs = constants $ codeSpec g getDecl (Store Unbundled) _ = declVars getDecl (Store Bundled) _ = gets (declObj cs . conRepr) getDecl WithInputs Unbundled = declVars getDecl WithInputs Bundled = return Nothing getDecl Inline _ = return Nothing - declVars = do + declVars = do vars <- mapM (mkVar . quantvar) cs vals <- mapM (convExpr . (^. codeExpr)) cs logs <- mapM maybeLog vars - return $ Just $ multi $ zipWith (defFunc $ conRepr g) vars vals ++ + return $ Just $ multi $ zipWith (defFunc $ conRepr g) vars vals ++ concat logs defFunc Var = varDecDef defFunc Const = constDecDef declObj [] _ = Nothing - declObj (c:_) Var = Just $ (if currentModule g == eMap g ! codeName c + declObj (c:_) Var = Just $ (if currentModule g == eMap g ! codeName c then objDecNewNoParams else extObjDecNewNoParams cname) v_consts declObj _ Const = Nothing getDecl (conStruct g) (inStruct g) --- | Generates a statement to declare the variable representing the log file, +-- | Generates a statement to declare the variable representing the log file, -- if the user chose to turn on logs for variable assignments. initLogFileVar :: (OOProg r) => [Logging] -> [MSStatement r] initLogFileVar l = [varDec varLogFile | LogVar `elem` l] ------- INPUT ---------- --- | Generates either a single module containing all input-related components, or --- separate modules for each input-related component, depending on the user's +-- | Generates either a single module containing all input-related components, or +-- separate modules for each input-related component, depending on the user's -- modularity choice. chooseInModule :: (OOProg r) => InputModule -> GenState [SFile r] chooseInModule Combined = genInputModCombined @@ -185,7 +185,7 @@ genInputModSeparated = do ifDesc <- modDesc (liftS inputFormatDesc) dvDesc <- modDesc (liftS derivedValuesDesc) icDesc <- modDesc (liftS inputConstraintsDesc) - sequence + sequence [genModule "InputParameters" ipDesc [] [genInputClass Primary], genModule "InputFormat" ifDesc [genInputFormat Pub] [], genModule "DerivedValues" dvDesc [genInputDerived Pub] [], @@ -198,7 +198,7 @@ genInputModCombined = do let cname = "InputParameters" genMod :: (OOProg r) => Maybe (SClass r) -> GenState (SFile r) - genMod Nothing = genModule cname ipDesc [genInputFormat Pub, + genMod Nothing = genModule cname ipDesc [genInputFormat Pub, genInputDerived Pub, genInputConstraints Pub] [] genMod _ = genModule cname ipDesc [] [genInputClass Primary] ic <- genInputClass Primary @@ -213,13 +213,13 @@ constVarFunc :: (OOProg r) => ConstantRepr -> constVarFunc Var = stateVarDef public dynamic constVarFunc Const = constVar public --- | Returns 'Nothing' if no inputs or constants are mapped to InputParameters in +-- | Returns 'Nothing' if no inputs or constants are mapped to InputParameters in -- the class definition map. --- If any inputs or constants are defined in InputParameters, this generates --- the InputParameters class containing the inputs and constants as state +-- If any inputs or constants are defined in InputParameters, this generates +-- the InputParameters class containing the inputs and constants as state -- variables. If the InputParameters constructor is also exported, then the -- generated class also contains the input-related functions as private methods. -genInputClass :: (OOProg r) => ClassType -> +genInputClass :: (OOProg r) => ClassType -> GenState (Maybe (SClass r)) genInputClass scp = do g <- get @@ -228,19 +228,19 @@ genInputClass scp = do filt :: (CodeIdea c) => [c] -> [c] filt = filter ((Just cname ==) . flip Map.lookup (clsMap g) . codeName) methods :: (OOProg r) => GenState [SMethod r] - methods = if cname `elem` defList g - then concat <$> mapM (fmap maybeToList) [genInputConstructor, - genInputFormat Priv, genInputDerived Priv, genInputConstraints Priv] + methods = if cname `elem` defList g + then concat <$> mapM (fmap maybeToList) [genInputConstructor, + genInputFormat Priv, genInputDerived Priv, genInputConstraints Priv] else return [] - genClass :: (OOProg r) => [CodeVarChunk] -> [CodeDefinition] -> + genClass :: (OOProg r) => [CodeVarChunk] -> [CodeDefinition] -> GenState (Maybe (SClass r)) genClass [] [] = return Nothing genClass inps csts = do vals <- mapM (convExpr . (^. codeExpr)) csts - inputVars <- mapM (\x -> fmap (pubDVar . var (codeName x) . convType) + inputVars <- mapM (\x -> fmap (pubDVar . var (codeName x) . convType) (codeType x)) inps - constVars <- zipWithM (\c vl -> fmap (\t -> constVarFunc (conRepr g) - (var (codeName c) (convType t)) vl) (codeType c)) + constVars <- zipWithM (\c vl -> fmap (\t -> constVarFunc (conRepr g) + (var (codeName c) (convType t)) vl) (codeType c)) csts vals let getFunc Primary = primaryClass getFunc Auxiliary = auxClass @@ -251,7 +251,7 @@ genInputClass scp = do genClass (filt ins) (filt cs) where cname = "InputParameters" --- | Generates a constructor for the input class, where the constructor calls the +-- | Generates a constructor for the input class, where the constructor calls the -- input-related functions. Returns 'Nothing' if no input-related functions are -- generated. genInputConstructor :: (OOProg r) => GenState (Maybe (SMethod r)) @@ -259,14 +259,14 @@ genInputConstructor = do g <- get let dl = defList g genCtor False = return Nothing - genCtor True = do + genCtor True = do cdesc <- inputConstructorDesc - cparams <- getInConstructorParams + cparams <- getInConstructorParams ics <- getAllInputCalls ctor <- genConstructor "InputParameters" cdesc (map pcAuto cparams) [block ics] return $ Just ctor - genCtor $ any (`elem` dl) ["get_input", "derived_values", + genCtor $ any (`elem` dl) ["get_input", "derived_values", "input_constraints"] -- | Generates a function for calculating derived inputs. @@ -277,7 +277,7 @@ genInputDerived s = do let dvals = derivedInputs $ codeSpec g getFunc Pub = publicInOutFunc getFunc Priv = privateInOutMethod - genDerived :: (OOProg r) => Bool -> GenState + genDerived :: (OOProg r) => Bool -> GenState (Maybe (SMethod r)) genDerived False = return Nothing genDerived _ = do @@ -297,7 +297,7 @@ genInputConstraints s = do let cm = cMap $ codeSpec g getFunc Pub = publicFunc getFunc Priv = privateMethod - genConstraints :: (OOProg r) => Bool -> GenState + genConstraints :: (OOProg r) => Bool -> GenState (Maybe (SMethod r)) genConstraints False = return Nothing genConstraints _ = do @@ -308,13 +308,13 @@ genInputConstraints s = do sf <- sfwrCBody sfwrCs ph <- physCBody physCs desc <- inConsFuncDesc - mthd <- getFunc s "input_constraints" void desc (map pcAuto parms) + mthd <- getFunc s "input_constraints" void desc (map pcAuto parms) Nothing [block sf, block ph] return $ Just mthd genConstraints $ "input_constraints" `elem` defList g -- | Generates input constraints code block for checking software constraints. -sfwrCBody :: (OOProg r) => [(CodeVarChunk, [ConstraintCE])] -> +sfwrCBody :: (OOProg r) => [(CodeVarChunk, [ConstraintCE])] -> GenState [MSStatement r] sfwrCBody cs = do g <- get @@ -322,16 +322,16 @@ sfwrCBody cs = do chooseConstr cb cs -- | Generates input constraints code block for checking physical constraints. -physCBody :: (OOProg r) => [(CodeVarChunk, [ConstraintCE])] -> +physCBody :: (OOProg r) => [(CodeVarChunk, [ConstraintCE])] -> GenState [MSStatement r] physCBody cs = do g <- get let cb = onPhysC g chooseConstr cb cs --- | Generates conditional statements for checking constraints, where the +-- | Generates conditional statements for checking constraints, where the -- bodies depend on user's choice of constraint violation behaviour. -chooseConstr :: (OOProg r) => ConstraintBehaviour -> +chooseConstr :: (OOProg r) => ConstraintBehaviour -> [(CodeVarChunk, [ConstraintCE])] -> GenState [MSStatement r] chooseConstr cb cs = do conds <- mapM (\(q,cns) -> mapM (convExpr . renderC q) cns) cs @@ -339,12 +339,12 @@ chooseConstr cb cs = do return $ concat $ zipWith (zipWith (\cond bod -> ifNoElse [((?!) cond, bod)])) conds bods where chooseCB Warning = constrWarn - chooseCB Exception = constrExc + chooseCB Exception = constrExc -- | Generates body defining constraint violation behaviour if Warning chosen from 'chooseConstr'. -- Prints a \"Warning\" message followed by a message that says -- what value was \"suggested\". -constrWarn :: (OOProg r) => (CodeVarChunk, [ConstraintCE]) -> +constrWarn :: (OOProg r) => (CodeVarChunk, [ConstraintCE]) -> GenState [MSBody r] constrWarn c = do let q = fst c @@ -355,7 +355,7 @@ constrWarn c = do -- | Generates body defining constraint violation behaviour if Exception chosen from 'chooseConstr'. -- Prints a message that says what value was \"expected\", -- followed by throwing an exception. -constrExc :: (OOProg r) => (CodeVarChunk, [ConstraintCE]) -> +constrExc :: (OOProg r) => (CodeVarChunk, [ConstraintCE]) -> GenState [MSBody r] constrExc c = do let q = fst c @@ -366,24 +366,24 @@ constrExc c = do -- | Generates statements that print a message for when a constraint is violated. -- Message includes the name of the cosntraint quantity, its value, and a -- description of the constraint that is violated. -constraintViolatedMsg :: (OOProg r) => CodeVarChunk -> String -> +constraintViolatedMsg :: (OOProg r) => CodeVarChunk -> String -> ConstraintCE -> GenState [MSStatement r] constraintViolatedMsg q s c = do - pc <- printConstraint c + pc <- printConstraint c v <- mkVal (quantvar q) return $ [printStr $ codeName q ++ " has value ", print v, printStr $ ", but is " ++ s ++ " to be "] ++ pc --- | Generates statements to print descriptions of constraints, using words and --- the constrained values. Constrained values are followed by printing the --- expression they originated from, using printExpr. +-- | Generates statements to print descriptions of constraints, using words and +-- the constrained values. Constrained values are followed by printing the +-- expression they originated from, using printExpr. printConstraint :: (OOProg r) => ConstraintCE -> GenState [MSStatement r] printConstraint c = do g <- get let db = sysinfodb $ codeSpec g - printConstraint' :: (OOProg r) => ConstraintCE -> GenState + printConstraint' :: (OOProg r) => ConstraintCE -> GenState [MSStatement r] printConstraint' (Range _ (Bounded (_, e1) (_, e2))) = do lb <- convExpr e1 @@ -392,14 +392,14 @@ printConstraint c = do [printStr " and ", print ub] ++ printExpr e2 db ++ [printStrLn "."] printConstraint' (Range _ (UpTo (_, e))) = do ub <- convExpr e - return $ [printStr "below ", print ub] ++ printExpr e db ++ + return $ [printStr "below ", print ub] ++ printExpr e db ++ [printStrLn "."] printConstraint' (Range _ (UpFrom (_, e))) = do lb <- convExpr e return $ [printStr "above ", print lb] ++ printExpr e db ++ [printStrLn "."] printConstraint' c --- | Don't print expressions that are just literals, because that would be +-- | Don't print expressions that are just literals, because that would be -- redundant (the values are already printed by printConstraint). -- If expression is more than just a literal, print it in parentheses. printExpr :: (OOProg r) => CodeExpr -> ChunkDB -> [MSStatement r] @@ -407,14 +407,14 @@ printExpr Lit{} _ = [] printExpr e db = [printStr $ " (" ++ render (codeExprDoc db Implementation Linear e) ++ ")"] -- | | Generates a function for reading inputs from a file. -genInputFormat :: (OOProg r) => ScopeTag -> +genInputFormat :: (OOProg r) => ScopeTag -> GenState (Maybe (SMethod r)) genInputFormat s = do g <- get dd <- genDataDesc let getFunc Pub = publicInOutFunc getFunc Priv = privateInOutMethod - genInFormat :: (OOProg r) => Bool -> GenState + genInFormat :: (OOProg r) => Bool -> GenState (Maybe (SMethod r)) genInFormat False = return Nothing genInFormat _ = do @@ -427,43 +427,43 @@ genInputFormat s = do genInFormat $ "get_input" `elem` defList g -- | Defines the 'DataDesc' for the format we require for input files. When we make --- input format a design variability, this will read the user's design choices +-- input format a design variability, this will read the user's design choices -- instead of returning a fixed 'DataDesc'. genDataDesc :: GenState DataDesc genDataDesc = do g <- get - return $ junkLine : + return $ junkLine : intersperse junkLine (map singleton (extInputs $ codeSpec g)) --- | Generates a sample input file compatible with the generated program, +-- | Generates a sample input file compatible with the generated program, -- if the user chose to. genSampleInput :: (AuxiliarySym r) => GenState (Maybe (r (Auxiliary r))) genSampleInput = do g <- get dd <- genDataDesc - if hasSampleInput (auxiliaries g) then (return . Just) $ sampleInput + if hasSampleInput (auxiliaries g) then (return . Just) $ sampleInput (sysinfodb $ codeSpec g) dd (sampleData g) else return Nothing ----- CONSTANTS ----- --- | Generates a module containing the class where constants are stored. +-- | Generates a module containing the class where constants are stored. genConstMod :: (OOProg r) => GenState [SFile r] genConstMod = do cDesc <- modDesc $ liftS constModDesc liftS $ genModule "Constants" cDesc [] [genConstClass Primary] --- | Generates a class to store constants, if constants are mapped to the +-- | Generates a class to store constants, if constants are mapped to the -- Constants class in the class definition map, otherwise returns Nothing. genConstClass :: (OOProg r) => ClassType -> GenState (Maybe (SClass r)) genConstClass scp = do g <- get let cs = constants $ codeSpec g - genClass :: (OOProg r) => [CodeDefinition] -> GenState + genClass :: (OOProg r) => [CodeDefinition] -> GenState (Maybe (SClass r)) - genClass [] = return Nothing + genClass [] = return Nothing genClass vs = do - vals <- mapM (convExpr . (^. codeExpr)) vs + vals <- mapM (convExpr . (^. codeExpr)) vs vars <- mapM (\x -> fmap (var (codeName x) . convType) (codeType x)) vs let constVars = zipWith (constVarFunc (conRepr g)) vars vals getFunc Primary = primaryClass @@ -472,7 +472,7 @@ genConstClass scp = do cDesc <- constClassDesc cls <- f cname Nothing cDesc constVars (return []) return $ Just cls - genClass $ filter (flip member (Map.filter (cname ==) (clsMap g)) + genClass $ filter (flip member (Map.filter (cname ==) (clsMap g)) . codeName) cs where cname = "Constants" @@ -483,13 +483,13 @@ genCalcMod :: (OOProg r) => GenState (SFile r) genCalcMod = do g <- get let elmap = extLibMap g - genModuleWithImports "Calculations" calcModDesc (concatMap (^. imports) $ + genModuleWithImports "Calculations" calcModDesc (concatMap (^. imports) $ elems elmap) (map (fmap Just . genCalcFunc) (execOrder $ codeSpec g)) [] -- | Generates a calculation function corresponding to the 'CodeDefinition'. --- For solving ODEs, the 'ExtLibState' containing the information needed to +-- For solving ODEs, the 'ExtLibState' containing the information needed to -- generate code is found by looking it up in the external library map. -genCalcFunc :: (OOProg r) => CodeDefinition -> +genCalcFunc :: (OOProg r) => CodeDefinition -> GenState (SMethod r) genCalcFunc cdef = do g <- get @@ -497,14 +497,14 @@ genCalcFunc cdef = do let nm = codeName cdef tp <- codeType cdef v <- mkVar (quantvar cdef) - blcks <- case cdef ^. defType - of Definition -> liftS $ genCalcBlock CalcReturn cdef + blcks <- case cdef ^. defType + of Definition -> liftS $ genCalcBlock CalcReturn cdef (cdef ^. codeExpr) - ODE -> maybe (error $ nm ++ " missing from ExtLibMap") + ODE -> maybe (error $ nm ++ " missing from ExtLibMap") (\el -> do defStmts <- mapM convStmt (el ^. defs) stepStmts <- mapM convStmt (el ^. steps) - return [block (varDec v : defStmts), + return [block (varDec v : defStmts), block stepStmts, block [returnStmt $ valueOf v]]) (Map.lookup nm (extLibMap g)) @@ -520,7 +520,7 @@ genCalcFunc cdef = do -- | Calculations may be assigned to a variable or asked for a result. data CalcType = CalcAssign | CalcReturn deriving Eq --- | Generates a calculation block for the given 'CodeDefinition', and assigns the +-- | Generates a calculation block for the given 'CodeDefinition', and assigns the -- result to a variable (if 'CalcAssign') or returns the result (if 'CalcReturn'). genCalcBlock :: (OOProg r) => CalcType -> CodeDefinition -> CodeExpr -> GenState (MSBlock r) @@ -532,10 +532,10 @@ genCalcBlock CalcAssign v e = do return $ block $ assign vv ee : l genCalcBlock CalcReturn _ e = block <$> liftS (returnStmt <$> convExpr e) --- | Generates a calculation block for a value defined by cases. --- If the function is defined for every case, the final case is captured by an +-- | Generates a calculation block for a value defined by cases. +-- If the function is defined for every case, the final case is captured by an -- else clause, otherwise an error-throwing else-clause is generated. -genCaseBlock :: (OOProg r) => CalcType -> CodeDefinition -> Completeness +genCaseBlock :: (OOProg r) => CalcType -> CodeDefinition -> Completeness -> [(CodeExpr, CodeExpr)] -> GenState (MSBlock r) genCaseBlock _ _ _ [] = error $ "Case expression with no cases encountered" ++ " in code generator" @@ -547,7 +547,7 @@ genCaseBlock t v c cs = do ifEs Complete = init cs ifEs Incomplete = cs elseE Complete = calcBody $ fst $ last cs - elseE Incomplete = return $ oneLiner $ throw $ + elseE Incomplete = return $ oneLiner $ throw $ "Undefined case encountered in function " ++ codeName v ----- OUTPUT ------- @@ -562,7 +562,7 @@ genOutputMod = do genOutputFormat :: (OOProg r) => GenState (Maybe (SMethod r)) genOutputFormat = do g <- get - let genOutput :: (OOProg r) => Maybe String -> GenState + let genOutput :: (OOProg r) => Maybe String -> GenState (Maybe (SMethod r)) genOutput Nothing = return Nothing genOutput (Just _) = do @@ -576,7 +576,7 @@ genOutputFormat = do printFileLn v_outfile v ] ) (outputs $ codeSpec g) desc <- woFuncDesc - mthd <- publicFunc "write_output" void desc (map pcAuto parms) Nothing + mthd <- publicFunc "write_output" void desc (map pcAuto parms) Nothing [block $ [ varDec var_outfile, openFileW var_outfile (litString "output.txt") ] ++ diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Parameters.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Parameters.hs index d2c4614b87..55c8bc60f4 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Parameters.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Parameters.hs @@ -6,10 +6,10 @@ module Language.Drasil.Code.Imperative.Parameters(getInConstructorParams, import Language.Drasil hiding (isIn, Var) import Language.Drasil.Chunk.CodeDefinition (CodeDefinition, auxExprs) import Language.Drasil.Chunk.CodeBase -import Language.Drasil.Choices (Structure(..), InputModule(..), +import Language.Drasil.Choices (Structure(..), InputModule(..), ConstantStructure(..), ConstantRepr(..)) import Language.Drasil.Code.CodeQuantityDicts (inFileName, inParams, consts) -import Language.Drasil.Code.Imperative.DrasilState (GenState, DrasilState(..), +import Language.Drasil.Code.Imperative.DrasilState (GenState, DrasilState(..), inMod) import Language.Drasil.CodeSpec (CodeSpec(..), constraintvars, getConstraints) import Language.Drasil.Mod (Name) @@ -27,11 +27,11 @@ data ParamType = In | Out deriving Eq isIn :: ParamType -> Bool isIn = (In ==) --- | Since the input constructor calls the three input-related methods, the --- parameters to the constructor are the parameters to the three methods, --- except excluding any of variables that are state variables in the class, +-- | Since the input constructor calls the three input-related methods, the +-- parameters to the constructor are the parameters to the three methods, +-- except excluding any of variables that are state variables in the class, -- since they are already in scope. --- If InputParameters is not in the definition list, then the default +-- If InputParameters is not in the definition list, then the default -- constructor is used, which takes no parameters. getInConstructorParams :: GenState [CodeVarChunk] getInConstructorParams = do @@ -47,7 +47,7 @@ getInConstructorParams = do -- | The inputs to the function for reading inputs are the input file name, and -- the 'inParams' object if inputs are bundled and input components are separated. --- The latter is needed because we want to populate the object through state +-- The latter is needed because we want to populate the object through state -- transitions, not by returning it. getInputFormatIns :: GenState [CodeVarChunk] getInputFormatIns = do @@ -63,7 +63,7 @@ getInputFormatOuts = do g <- get getParams "get_input" Out $ extInputs $ codeSpec g --- | The inputs to the function for calculating derived inputs are any variables +-- | The inputs to the function for calculating derived inputs are any variables -- used in the equations for the derived inputs. getDerivedIns :: GenState [CodeVarChunk] getDerivedIns = do @@ -79,11 +79,11 @@ getDerivedOuts = do g <- get getParams "derived_values" Out $ map codeChunk $ derivedInputs $ codeSpec g --- | The parameters to the function for checking constraints on the inputs are --- any inputs with constraints, and any variables used in the expressions of +-- | The parameters to the function for checking constraints on the inputs are +-- any inputs with constraints, and any variables used in the expressions of -- the constraints. getConstraintParams :: GenState [CodeVarChunk] -getConstraintParams = do +getConstraintParams = do g <- get let cm = cMap $ codeSpec g db = sysinfodb $ codeSpec g @@ -92,12 +92,12 @@ getConstraintParams = do (getConstraints cm varsList)) getParams "input_constraints" In reqdVals --- | The parameters to a calculation function are any variables used in the +-- | The parameters to a calculation function are any variables used in the -- expression representing the calculation. getCalcParams :: CodeDefinition -> GenState [CodeVarChunk] getCalcParams c = do g <- get - getParams (codeName c) In $ delete (quantvar c) $ concatMap (`codevars'` + getParams (codeName c) In $ delete (quantvar c) $ concatMap (`codevars'` (sysinfodb $ codeSpec g)) (c ^. codeExpr : c ^. auxExprs) -- | The parameters to the function for printing outputs are the outputs. @@ -110,7 +110,7 @@ getOutputParams = do -- Passes parameters that are constants to 'getConstVars' for further processing. -- Other parameters are put into the returned parameter list as long as they -- are not matched to a code concept. -getParams :: (Quantity c, MayHaveUnit c) => Name -> ParamType -> [c] -> +getParams :: (Quantity c, MayHaveUnit c) => Name -> ParamType -> [c] -> GenState [CodeVarChunk] getParams n pt cs' = do g <- get @@ -119,28 +119,28 @@ getParams n pt cs' = do cnsnts = map quantvar $ constants $ codeSpec g inpVars = filter (`elem` ins) cs conVars = filter (`elem` cnsnts) cs - csSubIns = filter ((`notMember` concMatches g) . (^. uid)) + csSubIns = filter ((`notMember` concMatches g) . (^. uid)) (cs \\ (ins ++ cnsnts)) inVs <- getInputVars n pt (inStruct g) Var inpVars conVs <- getConstVars n pt (conStruct g) (conRepr g) conVars return $ nub $ inVs ++ conVs ++ csSubIns -- | If the passed list of input variables is empty, then return empty list. --- If the user has chosen 'Unbundled' inputs, then the input variables are +-- If the user has chosen 'Unbundled' inputs, then the input variables are -- returned as-is. --- If the user has chosen 'Bundled' inputs, and the parameters are inputs to the --- function (as opposed to outputs), then the 'inParams' object is returned --- instead of the individual input variables, unless the function being --- parameterized is itself defined in the InputParameters class, in which case +-- If the user has chosen 'Bundled' inputs, and the parameters are inputs to the +-- function (as opposed to outputs), then the 'inParams' object is returned +-- instead of the individual input variables, unless the function being +-- parameterized is itself defined in the InputParameters class, in which case -- the inputs are already in scope and thus no parameter is required. --- If the 'ParamType' is 'Out', the 'inParams' object is not an output parameter +-- If the 'ParamType' is 'Out', the 'inParams' object is not an output parameter -- because it undergoes state transitions, so is not actually an output. --- The final case only happens when getInputVars is called by 'getConstVars' --- because the user has chosen 'WithInputs' as their constant structure. If they --- have chosen 'Bundled' inputs and a constant const representation, then the --- constant variables are static and can be accessed through the class, without +-- The final case only happens when getInputVars is called by 'getConstVars' +-- because the user has chosen 'WithInputs' as their constant structure. If they +-- have chosen 'Bundled' inputs and a constant const representation, then the +-- constant variables are static and can be accessed through the class, without -- an object, so no parameters are required. -getInputVars :: Name -> ParamType -> Structure -> ConstantRepr -> +getInputVars :: Name -> ParamType -> Structure -> ConstantRepr -> [CodeVarChunk] -> GenState [CodeVarChunk] getInputVars _ _ _ _ [] = return [] getInputVars _ _ Unbundled _ cs = return cs @@ -151,19 +151,19 @@ getInputVars n pt Bundled Var _ = do getInputVars _ _ Bundled Const _ = return [] -- | If the passed list of constant variables is empty, then return empty list. --- If the user has chosen 'Unbundled' constants, then the constant variables are +-- If the user has chosen 'Unbundled' constants, then the constant variables are -- returned as-is. --- If the user has chosen 'Bundled' constants and 'Var' representation, and the --- parameters are inputs to the function (as opposed to outputs), then the +-- If the user has chosen 'Bundled' constants and 'Var' representation, and the +-- parameters are inputs to the function (as opposed to outputs), then the -- 'consts' object is returned instead of the individual constant variables. --- If the 'ParamType' is 'Out', the 'consts' object is not an output parameter +-- If the 'ParamType' is 'Out', the 'consts' object is not an output parameter -- because it undergoes state transitions, so is not actually an output. --- The final case only happens when 'getInputVars' is called by 'getConstVars' --- because the user has chosen 'WithInputs' as their constant structure. If they --- have chosen 'Bundled' inputs and a constant const representation, then the --- constant variables are static and can be accessed through the class, without +-- The final case only happens when 'getInputVars' is called by 'getConstVars' +-- because the user has chosen 'WithInputs' as their constant structure. If they +-- have chosen 'Bundled' inputs and a constant const representation, then the +-- constant variables are static and can be accessed through the class, without -- an object, so no parameters are required. -getConstVars :: Name -> ParamType -> ConstantStructure -> ConstantRepr -> +getConstVars :: Name -> ParamType -> ConstantStructure -> ConstantRepr -> [CodeVarChunk] -> GenState [CodeVarChunk] getConstVars _ _ _ _ [] = return [] getConstVars _ _ (Store Unbundled) _ cs = return cs diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Parsers/ConfigParser.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Parsers/ConfigParser.hs index 24f2de2eee..ea24c89b72 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Parsers/ConfigParser.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Parsers/ConfigParser.hs @@ -14,7 +14,7 @@ import Text.Parsec.Perm ((<|?>), (<$?>), (<$$>), (<||>), permute) import qualified Text.Parsec.Token as P import Text.ParserCombinators.Parsec (Parser, ParseError, parse, try, noneOf) import Text.ParserCombinators.Parsec.Language (caseSensitive, reservedNames, reservedOpNames, - opLetter, opStart, identLetter, identStart, nestedComments, commentLine, commentStart, + opLetter, opStart, identLetter, identStart, nestedComments, commentLine, commentStart, commentEnd, LanguageDef, emptyDef) import Language.Drasil.Code.Imperative.GOOL.LanguageRenderer (Options(..)) diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/ReadInput.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/ReadInput.hs index 2ba1c85bff..3f3fe7b662 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/ReadInput.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/ReadInput.hs @@ -4,7 +4,7 @@ module Language.Drasil.Code.Imperative.ReadInput ( ) where import Language.Drasil hiding (Data, Matrix, CodeVarChunk) -import Language.Drasil.Code.DataDesc (DataDesc'(..), Data'(..), DataItem'(..), +import Language.Drasil.Code.DataDesc (DataDesc'(..), Data'(..), DataItem'(..), Delimiter, dataDesc, junk, list, singleton') import Language.Drasil.Chunk.Code (CodeVarChunk) import Language.Drasil.Expr.Development (Expr(Matrix)) @@ -14,19 +14,19 @@ import Data.List (intersperse, isPrefixOf, transpose) import Data.List.Split (splitOn) import Data.List.NonEmpty (NonEmpty(..), toList) --- | Reads data from a file and converts the values to 'Expr's. The file must be +-- | Reads data from a file and converts the values to 'Expr's. The file must be -- formatted according to the 'DataDesc'' passed as a parameter. readWithDataDesc :: FilePath -> DataDesc' -> IO [Expr] -readWithDataDesc fp ddsc = do +readWithDataDesc fp ddsc = do ins <- readFile fp let readDD :: DataDesc' -> String -> [Expr] - readDD (DD ds dlm dd) s = let (dat,rest) = splitAtFirst s dlm in + readDD (DD ds dlm dd) s = let (dat,rest) = splitAtFirst s dlm in readData ds dat ++ readDD dd rest readDD (End d) s = readData d s readData :: Data' -> String -> [Expr] readData Junk _ = [] readData (Datum d) s = [readDataItem d s] - readData (Data dis 0 d) s = zipWith readDataItem (toList dis) (splitOn d s) + readData (Data dis 0 d) s = zipWith readDataItem (toList dis) (splitOn d s) readData (Data ((DI c [dlm1]):|_) 1 dlm2) s = map ((Matrix . (:[])) . map (strAsExpr (getInnerSpace $ c ^. typ))) $ transpose $ map (splitOn dlm2) $ splitOn dlm1 s @@ -34,20 +34,20 @@ readWithDataDesc fp ddsc = do map (map (strAsExpr (getInnerSpace $ c ^. typ)))) $ transpose $ map (map (splitOn dlm3) . splitOn dlm2) $ splitOn dlm1 s readData (Data ((DI c [dlm1, dlm2]):|_) 2 dlm3) s = map (Matrix . - map (map (strAsExpr (getInnerSpace $ c ^. typ))) . transpose) $ + map (map (strAsExpr (getInnerSpace $ c ^. typ))) . transpose) $ transpose $ map (map (splitOn dlm3) . splitOn dlm2) $ splitOn dlm1 s readData _ _ = error "Invalid degree of intermixing in DataDesc or list with more than 2 dimensions (not yet supported)" - -- Below match is an attempt at a generic match for Data, but it doesn't + -- Below match is an attempt at a generic match for Data, but it doesn't -- work because the following are needed: -- - 1-D Vect Expr constructor -- - A map function on Expr Vects (exprVectMap) -- - A transpose function on Expr Vects (exprVectTranspose) - -- readData (Data ((DI c dlms):dis) i dlm2) s = let (ls,rs) = splitAt i + -- readData (Data ((DI c dlms):dis) i dlm2) s = let (ls,rs) = splitAt i -- dlms in transposeData i $ data (ls ++ [dlm] ++ rs) (getInnerType $ c ^. typ) s readDataItem :: DataItem' -> String -> Expr readDataItem (DI c []) s = strAsExpr (c ^. typ) s readDataItem (DI c [dlm]) s = strListAsExpr (c ^. typ) (splitOn dlm s) - readDataItem (DI c [dlm1, dlm2]) s = strList2DAsExpr (c ^. typ) + readDataItem (DI c [dlm1, dlm2]) s = strList2DAsExpr (c ^. typ) (map (splitOn dlm2) $ splitOn dlm1 s) -- FIXME: Since the representation for vectors in Expr is Matrix, and that constructor accepts a 2-D list, building a 3-D or higher matrix is not straightforward. This would be easier if Expr had a constructor for 1-D vectors, which could be nested to achieve n-dimensional structures. readDataItem (DI _ _) _ = error "readWithDataDesc does not yet support lists with 3 or more dimensions" @@ -61,12 +61,12 @@ readWithDataDesc fp ddsc = do -- transposeData 1 = exprVectTranspose -- transposeData n = exprVectMap exprVectTranspose . transposeData (n-1) --- | Defines the DataDesc for the file containing a sample data set, which a +-- | Defines the DataDesc for the file containing a sample data set, which a -- user must supply if they want to generate a sample input file. sampleInputDD :: [CodeVarChunk] -> DataDesc' sampleInputDD ds = dataDesc (junk : intersperse junk (map toData ds)) "\n" where toData d = toData' (d ^. typ) d - toData' t@(Vect _) d = list d + toData' t@(Vect _) d = list d (take (getDimension t) ([", ", "; "] ++ iterate (':':) ":")) toData' _ d = singleton' d @@ -91,9 +91,9 @@ getDimension _ = 0 splitAtFirst :: String -> Delimiter -> (String, String) splitAtFirst = splitAtFirst' [] where splitAtFirst' acc [] _ = (acc, []) - splitAtFirst' acc s@(h:t) d = if d `isPrefixOf` s then + splitAtFirst' acc s@(h:t) d = if d `isPrefixOf` s then (acc, dropDelim d s) else splitAtFirst' (acc++[h]) t d - dropDelim (d:ds) (s:ss) = if d == s then dropDelim ds ss + dropDelim (d:ds) (s:ss) = if d == s then dropDelim ds ss else error "impossible" dropDelim [] s = s dropDelim _ [] = error "impossible" diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/SpaceMatch.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/SpaceMatch.hs index 07d246e3e8..35365a1b67 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/SpaceMatch.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/SpaceMatch.hs @@ -4,7 +4,7 @@ module Language.Drasil.Code.Imperative.SpaceMatch ( import Language.Drasil import Language.Drasil.Choices (Choices(..), Maps(..)) -import Language.Drasil.Code.Imperative.DrasilState (GenState, MatchedSpaces, +import Language.Drasil.Code.Imperative.DrasilState (GenState, MatchedSpaces, addToDesignLog, addLoggedSpace) import Language.Drasil.Code.Lang (Lang(..)) @@ -19,24 +19,24 @@ chooseSpace lng chs = \s -> selectType lng s (spaceMatch (maps chs) s) -- Floats unavailable in Python where selectType :: Lang -> Space -> [CodeType] -> GenState CodeType selectType Python s (Float:ts) = do - modify (addLoggedSpace s Float . + modify (addLoggedSpace s Float . addToDesignLog s Float (incompatibleType Python s Float)) selectType Python s ts -- In all other cases, just select first choice - selectType _ s (t:_) = do + selectType _ s (t:_) = do modify (addLoggedSpace s t . addToDesignLog s t (successLog s t)) return t - selectType l s [] = error $ "Chosen CodeType matches for Space " ++ + selectType l s [] = error $ "Chosen CodeType matches for Space " ++ show s ++ " are not compatible with target language " ++ show l --- | Defines a design log message based on an incompatibility between the given +-- | Defines a design log message based on an incompatibility between the given -- 'Lang' and attempted 'Space'-'CodeType' match. incompatibleType :: Lang -> Space -> CodeType -> Doc incompatibleType l s t = text $ "Language " ++ show l ++ " does not support " - ++ "code type " ++ show t ++ ", chosen as the match for the " ++ show s ++ - " space. Trying next choice." + ++ "code type " ++ show t ++ ", chosen as the match for the " ++ show s ++ + " space. Trying next choice." -- | Defines a successful log message. successLog :: Space -> CodeType -> Doc -successLog s t = text ("Successfully matched "++show s ++ " with "++ show t ++".") \ No newline at end of file +successLog s t = text ("Successfully matched "++show s ++ " with "++ show t ++".") diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/WriteInput.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/WriteInput.hs index 8ce6cd9d22..f450de1bd7 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/WriteInput.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/WriteInput.hs @@ -1,52 +1,52 @@ module Language.Drasil.Code.Imperative.WriteInput ( makeInputFile -) where - +) where + import Utils.Drasil (blank) import Database.Drasil (ChunkDB) import Language.Drasil hiding (space, Matrix) -import Language.Drasil.Code.DataDesc (DataDesc, Data(..), Delim, +import Language.Drasil.Code.DataDesc (DataDesc, Data(..), Delim, LinePattern(..), getDataInputs, isJunk) import Language.Drasil.Expr.Development (Expr(Matrix)) -import Language.Drasil.Printers (Linearity(Linear), exprDoc, sentenceDoc, +import Language.Drasil.Printers (Linearity(Linear), exprDoc, sentenceDoc, unitDoc) import Control.Lens (view) import Data.List (intersperse, transpose) -import Text.PrettyPrint.HughesPJ (Doc, (<+>), char, empty, hcat, parens, space, +import Text.PrettyPrint.HughesPJ (Doc, (<+>), char, empty, hcat, parens, space, text, vcat) -- | Generate a sample input file. makeInputFile :: ChunkDB -> DataDesc -> [Expr] -> Doc makeInputFile db dd sampData = vcat (convDataDesc db dd sampData) --- | Writes a data file formatted according to the given 'DataDesc', where the data --- values come from the passed \['Expr'\]. +-- | Writes a data file formatted according to the given 'DataDesc', where the data +-- values come from the passed \['Expr'\]. convDataDesc :: ChunkDB -> DataDesc -> [Expr] -> [Doc] -convDataDesc _ [] (_:_) = error $ "makeInputFile received more inputs" ++ +convDataDesc _ [] (_:_) = error $ "makeInputFile received more inputs" ++ " than expected, should be impossible" -convDataDesc _ ds [] = if all isJunk ds then replicate (length ds) blank +convDataDesc _ ds [] = if all isJunk ds then replicate (length ds) blank else error "makeInputFile received fewer inputs than expected, should be impossible" convDataDesc db (JunkData : ds@(Singleton _ : _)) es = docLine db ds ' ' es convDataDesc db (JunkData : ds@(Line _ dl : _)) es = docLine db ds dl es convDataDesc db (JunkData : ds@(Lines _ _ dl : _)) es = docLine db ds dl es convDataDesc db (Singleton _ : ds) (e:es) = eDoc db e : convDataDesc db ds es -convDataDesc db (Line (Straight dis) dl : ds) es = let - (l,ls) = splitAt (length dis) es +convDataDesc db (Line (Straight dis) dl : ds) es = let + (l,ls) = splitAt (length dis) es in dataLine db dl l : convDataDesc db ds ls -convDataDesc db (Line (Repeat dis) dl : ds) es = let - (l,ls) = splitAt (length dis) es +convDataDesc db (Line (Repeat dis) dl : ds) es = let + (l,ls) = splitAt (length dis) es in dataLine db dl (concat $ orderVecs l) : convDataDesc db ds ls -convDataDesc db (Lines (Straight _) Nothing dl : _) es = map (dataLine db dl) +convDataDesc db (Lines (Straight _) Nothing dl : _) es = map (dataLine db dl) (orderVecs es) convDataDesc db (Lines (Straight dis) (Just n) dl : ds) es = let - (l,ls) = splitAt (length dis) es + (l,ls) = splitAt (length dis) es vs = orderVecs l in if toInteger (length vs) == n then map (dataLine db dl) vs ++ convDataDesc db ds ls else error "makeInputFile encountered wrong-sized vectors" -convDataDesc db (Lines (Repeat _) Nothing dl : _) es = map +convDataDesc db (Lines (Repeat _) Nothing dl : _) es = map (dataLine db dl . concat . transpose) (orderMtxs es) convDataDesc db (Lines (Repeat dis) (Just n) dl : ds) es = let (l,ls) = splitAt (length dis) es @@ -57,7 +57,7 @@ convDataDesc db (Lines (Repeat dis) (Just n) dl : ds) es = let else error "makeInputFile encountered wrong-sized matrices" convDataDesc db (JunkData : ds) es = blank : convDataDesc db ds es --- helpers +-- helpers -- | Helper to create a data line with the given delimeter. dataLine :: ChunkDB -> Delim -> [Expr] -> Doc @@ -65,10 +65,10 @@ dataLine db dl = hcat . intersperse (char dl) . map (eDoc db) -- | Helper to create document lines with a data description, delimiter, and expressions. docLine :: ChunkDB -> DataDesc -> Delim -> [Expr] -> [Doc] -docLine db ds dl es = let dis = getDataInputs (head ds) - in text "#" <+> hcat (intersperse (char dl <> space) - (map (\di -> (sDoc db . phraseNP . view term) di <+> - maybe empty (parens . uDoc . usymb) (getUnit di)) dis)) +docLine db ds dl es = let dis = getDataInputs (head ds) + in text "#" <+> hcat (intersperse (char dl <> space) + (map (\di -> (sDoc db . phraseNP . view term) di <+> + maybe empty (parens . uDoc . usymb) (getUnit di)) dis)) : convDataDesc db ds es -- | Order vectors. diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/WriteReadMe.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/WriteReadMe.hs index 1651b62103..4f07831f99 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/WriteReadMe.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/WriteReadMe.hs @@ -1,9 +1,9 @@ module Language.Drasil.Code.Imperative.WriteReadMe ( makeReadMe -) where +) where import Language.Drasil.Choices (ImplementationType(..)) -import Language.Drasil.Printers (makeMd, introInfo, verInfo, unsupOS, +import Language.Drasil.Printers (makeMd, introInfo, verInfo, unsupOS, extLibSec, instDoc, endNote, whatInfo) import Language.Drasil.Code.Imperative.GOOL.ClassInterface (ReadMeInfo(..)) @@ -12,7 +12,7 @@ import Text.PrettyPrint.HughesPJ (Doc, empty) import Data.List.NonEmpty (nonEmpty, toList) -- | Generates a README file. -makeReadMe :: ReadMeInfo -> Doc +makeReadMe :: ReadMeInfo -> Doc makeReadMe ReadMeInfo { langName = progLang, langVersion = progLangVers, @@ -20,13 +20,13 @@ makeReadMe ReadMeInfo { implementType = imptype, extLibNV = extLibns, extLibFP = extLibfp, - contributors = auths, + contributors = auths, configFP = configFPs, caseName = name, examplePurpose = purp, exampleDescr = descr, folderNum = number, - inputOutput = inoutf} = + inputOutput = inoutf} = makeMd [introInfo name auths $ fieldEmptySTR purp, whatInfo $ fieldEmptySTR descr, makeInstr imptype configFPs name inoutf, @@ -40,7 +40,7 @@ makeInstr :: ImplementationType -> [FilePath] -> String -> (String, String) -> D makeInstr Library _ _ _ = empty makeInstr Program cfp n inOutf = instDoc cfp n inOutf --- |Helper that checks if the field is empty; allowing optional content +-- |Helper that checks if the field is empty; allowing optional content -- rendering in a README file fieldEmptySTR :: String -> Maybe String fieldEmptySTR = fmap toList . nonEmpty diff --git a/code/drasil-code/lib/Language/Drasil/CodeSpec.hs b/code/drasil-code/lib/Language/Drasil/CodeSpec.hs index 54aebe12d7..16a422bf49 100644 --- a/code/drasil-code/lib/Language/Drasil/CodeSpec.hs +++ b/code/drasil-code/lib/Language/Drasil/CodeSpec.hs @@ -58,7 +58,7 @@ data CodeSpec where outputs :: [Output], -- | List of files that must be in same directory for running the executable. configFiles :: [FilePath], - -- | Mathematical definitions, ordered so that they form a path from inputs to + -- | Mathematical definitions, ordered so that they form a path from inputs to -- outputs. execOrder :: [Def], -- | Map from 'UID's to constraints for all constrained chunks used in the problem. @@ -67,7 +67,7 @@ data CodeSpec where constants :: [Const], -- | Map containing all constants used in the problem. constMap :: ConstantMap, - -- | Additional modules required in the generated code, which Drasil cannot yet + -- | Additional modules required in the generated code, which Drasil cannot yet -- automatically define. mods :: [Mod], -- medium hack -- | The database of all chunks used in the problem. @@ -139,7 +139,7 @@ codeSpec SI {_sys = sys -- medium hacks --- --- | Convert a 'Func' to an implementation-stage 'QuantityDict' representing the +-- | Convert a 'Func' to an implementation-stage 'QuantityDict' representing the -- function. asVC :: Func -> QuantityDict asVC (FDef (FuncDef n _ _ _ _ _)) = implVar n (nounPhraseSP n) Real (Variable n) @@ -150,8 +150,8 @@ asVC (FData (FuncData n _ _)) = implVar n (nounPhraseSP n) Real (Variable n) funcUID :: Func -> UID funcUID f = asVC f ^. uid --- | Determines the derived inputs, which can be immediately calculated from the --- knowns (inputs and constants). If there are DDs, the derived inputs will +-- | Determines the derived inputs, which can be immediately calculated from the +-- knowns (inputs and constants). If there are DDs, the derived inputs will -- come from those. If there are none, then the 'QDefinition's are used instead. getDerivedInputs :: [DataDefinition] -> [Input] -> [Const] -> ChunkDB -> [SimpleQDef] @@ -164,7 +164,7 @@ type Known = CodeVarChunk -- | Calculated values. type Need = CodeVarChunk --- | Orders a list of definitions such that they form a path between 'Known' values +-- | Orders a list of definitions such that they form a path between 'Known' values -- and values that 'Need' to be calculated. getExecOrder :: [Def] -> [Known] -> [Need] -> ChunkDB -> [Def] getExecOrder d k' n' sm = getExecOrder' [] d k' (n' \\ k') diff --git a/code/drasil-code/lib/Language/Drasil/Data/ODEInfo.hs b/code/drasil-code/lib/Language/Drasil/Data/ODEInfo.hs index 0472fdb9f0..23e6147198 100644 --- a/code/drasil-code/lib/Language/Drasil/Data/ODEInfo.hs +++ b/code/drasil-code/lib/Language/Drasil/Data/ODEInfo.hs @@ -5,11 +5,11 @@ module Language.Drasil.Data.ODEInfo ( import Language.Drasil.Chunk.Code (CodeVarChunk) import Language.Drasil.CodeExpr.Development -import Language.Drasil(makeAODESolverFormat, formEquations, +import Language.Drasil(makeAODESolverFormat, formEquations, DifferentialModel(..), ODESolverFormat(..), InitialValueProblem(..)) import Language.Drasil.Chunk.CodeBase (quantvar) --- This may be temporary, but need a structure to hold ODE info for now. +-- This may be temporary, but need a structure to hold ODE info for now. -- Goal will be for this info to be populated by the instance model for the ODE and the Choices structure. -- Probably doesn't belong here, but where? -- | Structure to hold ODE information. @@ -31,16 +31,16 @@ data ODEInfo = ODEInfo { } -- | Basic 'ODEInfo' constructor. -odeInfo :: CodeVarChunk -> CodeVarChunk -> [CodeVarChunk] -> CodeExpr -> CodeExpr -> +odeInfo :: CodeVarChunk -> CodeVarChunk -> [CodeVarChunk] -> CodeExpr -> CodeExpr -> [CodeExpr] -> [CodeExpr] -> ODEOptions -> ODEInfo odeInfo = ODEInfo -- | Create ODEInfo with Other variables, ODEOptions, DifferentialModel, and InitialValueProblem odeInfo' :: [CodeVarChunk] -> ODEOptions -> DifferentialModel -> InitialValueProblem -> ODEInfo -odeInfo' ovs opt dm ivp = ODEInfo - (quantvar $ _indepVar dm) - (quantvar $ _depVar dm) - ovs +odeInfo' ovs opt dm ivp = ODEInfo + (quantvar $ _indepVar dm) + (quantvar $ _depVar dm) + ovs (expr $ initTime ivp) (expr $ finalTime ivp) (map expr $ initValues ivp) diff --git a/code/drasil-code/lib/Language/Drasil/Data/ODELibPckg.hs b/code/drasil-code/lib/Language/Drasil/Data/ODELibPckg.hs index ae840fc0e2..6f052397cc 100644 --- a/code/drasil-code/lib/Language/Drasil/Data/ODELibPckg.hs +++ b/code/drasil-code/lib/Language/Drasil/Data/ODELibPckg.hs @@ -21,29 +21,29 @@ data ODELibPckg = ODELib { libCall :: ODEInfo -> ExternalLibraryCall, -- | Library path. libPath :: Maybe FilePath, - -- It has been said that language information should be in language-related - -- file, but this needs more thought. The language would need to declare - -- which libraries it is compatible with, but how could it refer to a + -- It has been said that language information should be in language-related + -- file, but this needs more thought. The language would need to declare + -- which libraries it is compatible with, but how could it refer to a -- library? Give libraries UID? - -- Also, this case seems different because ExternalLibraries are data. In - -- future, if a user defines a new external library, we wouldn't expect them - -- to update an internal Drasil file to add their library to a language's - -- compatible libraries. So maybe declaring compatible languages at library + -- Also, this case seems different because ExternalLibraries are data. In + -- future, if a user defines a new external library, we wouldn't expect them + -- to update an internal Drasil file to add their library to a language's + -- compatible libraries. So maybe declaring compatible languages at library -- definition time really is the right way to do this. -- | Compatible OO languages. compatibleLangs :: [Lang] } --- | Makes an 'ODELibPckg' with the given name, 'ExternalLibrary' specification, --- 'ExternalLibraryCall' specification parameterized by an 'ODEInfo', local file +-- | Makes an 'ODELibPckg' with the given name, 'ExternalLibrary' specification, +-- 'ExternalLibraryCall' specification parameterized by an 'ODEInfo', local file -- path to the library, and list of compatible languages. -mkODELib :: Name -> Version -> ExternalLibrary -> (ODEInfo -> +mkODELib :: Name -> Version -> ExternalLibrary -> (ODEInfo -> ExternalLibraryCall) -> FilePath -> [Lang] -> ODELibPckg mkODELib n v e c f = ODELib n v e c (Just f) --- | Makes an 'ODELibPckg' with the given name, 'ExternalLibrary' specification, --- 'ExternalLibraryCall' specification parameterized by an 'ODEInfo', and list of +-- | Makes an 'ODELibPckg' with the given name, 'ExternalLibrary' specification, +-- 'ExternalLibraryCall' specification parameterized by an 'ODEInfo', and list of -- compatible languages. -mkODELibNoPath :: Name -> Version -> ExternalLibrary -> (ODEInfo -> +mkODELibNoPath :: Name -> Version -> ExternalLibrary -> (ODEInfo -> ExternalLibraryCall) -> [Lang] -> ODELibPckg -mkODELibNoPath n v e c = ODELib n v e c Nothing \ No newline at end of file +mkODELibNoPath n v e c = ODELib n v e c Nothing diff --git a/code/drasil-code/lib/Language/Drasil/Mod.hs b/code/drasil-code/lib/Language/Drasil/Mod.hs index 9182d3b83f..0f8f3f9b8a 100644 --- a/code/drasil-code/lib/Language/Drasil/Mod.hs +++ b/code/drasil-code/lib/Language/Drasil/Mod.hs @@ -1,9 +1,9 @@ {-# LANGUAGE GADTs #-} -- | Defines an AST for defining Modules. -module Language.Drasil.Mod (Class(..), StateVariable(..), Func(..), - FuncData(..), FuncDef(..), FuncStmt(..), Initializer, Mod(..), Name, - Version, Description, Import, ($:=), pubStateVar, privStateVar, classDef, - classImplements, ctorDef, ffor, fforRange, fDecDef, fname, fstdecl, funcData, funcDef, +module Language.Drasil.Mod (Class(..), StateVariable(..), Func(..), + FuncData(..), FuncDef(..), FuncStmt(..), Initializer, Mod(..), Name, + Version, Description, Import, ($:=), pubStateVar, privStateVar, classDef, + classImplements, ctorDef, ffor, fforRange, fDecDef, fname, fstdecl, funcData, funcDef, funcDefParams, packmod, packmodRequires ) where @@ -11,7 +11,7 @@ import Language.Drasil (Space, MayHaveUnit, Quantity, CodeExpr, LiteralC(..)) import Database.Drasil (ChunkDB) import GOOL.Drasil (ScopeTag(..)) -import Language.Drasil.Chunk.Code (CodeVarChunk, CodeFuncChunk, codevars, +import Language.Drasil.Chunk.Code (CodeVarChunk, CodeFuncChunk, codevars, codevars', quantvar) import Language.Drasil.Chunk.Parameter (ParameterChunk, pcAuto) import Language.Drasil.Code.DataDesc (DataDesc) @@ -36,14 +36,14 @@ data Mod = Mod Name Description [Import] [Class] [Func] packmod :: Name -> Description -> [Class] -> [Func] -> Mod packmod n d = packmodRequires n d [] --- | Define a 'Mod' that requires some library imports, with the given Name, +-- | Define a 'Mod' that requires some library imports, with the given Name, -- Description, Classes, and Functions. packmodRequires :: Name -> Description -> [Import] -> [Class] -> [Func] -> Mod packmodRequires n = Mod (toPlainName n) -- | Holds information needed to define a class. data Class = ClassDef { - className :: Name, + className :: Name, implements :: Maybe Name, classDesc :: Description, stateVars :: [StateVariable], @@ -62,14 +62,14 @@ pubStateVar = SV Pub privStateVar :: CodeVarChunk -> StateVariable privStateVar = SV Priv --- | Define a class with the given 'Name', 'Description', state variables, and +-- | Define a class with the given 'Name', 'Description', state variables, and -- methods. classDef :: Name -> Description -> [StateVariable] -> [Func] -> Class classDef n = ClassDef n Nothing -- | Define a class that implements an interface. 1st 'Name' is class name, 2nd is --- interface name. -classImplements :: Name -> Name -> Description -> [StateVariable] -> [Func] -> +-- interface name. +classImplements :: Name -> Name -> Description -> [StateVariable] -> [Func] -> Class classImplements n i = ClassDef n (Just i) @@ -82,23 +82,23 @@ data Func = FDef FuncDef funcData :: Name -> Description -> DataDesc -> Func funcData n desc d = FData $ FuncData (toPlainName n) desc d --- | Define a function by providing the 'FuncStmt's for its body. Other --- parameters are function name, description, list of parameters, space of the +-- | Define a function by providing the 'FuncStmt's for its body. Other +-- parameters are function name, description, list of parameters, space of the -- returned value, and description of the returned value. -funcDef :: (Quantity c, MayHaveUnit c) => Name -> Description -> [c] -> +funcDef :: (Quantity c, MayHaveUnit c) => Name -> Description -> [c] -> Space -> Maybe Description -> [FuncStmt] -> Func -funcDef s desc i t returnDesc fs = FDef $ FuncDef (toPlainName s) desc - (map (pcAuto . quantvar) i) t returnDesc fs +funcDef s desc i t returnDesc fs = FDef $ FuncDef (toPlainName s) desc + (map (pcAuto . quantvar) i) t returnDesc fs -- | Like 'funcDef' but uses 'ParameterChunk's to represent the parameters. -funcDefParams :: Name -> Description -> [ParameterChunk] -> Space -> +funcDefParams :: Name -> Description -> [ParameterChunk] -> Space -> Maybe Description -> [FuncStmt] -> Func -funcDefParams s desc ps t returnDesc fs = FDef $ FuncDef (toPlainName s) desc +funcDefParams s desc ps t returnDesc fs = FDef $ FuncDef (toPlainName s) desc ps t returnDesc fs --- | Define a constructor, with the given name, description, parameters, --- initializers (variable-value pairs), and 'FuncStmt's for the body. -ctorDef :: Name -> Description -> [ParameterChunk] -> [Initializer] -> +-- | Define a constructor, with the given name, description, parameters, +-- initializers (variable-value pairs), and 'FuncStmt's for the body. +ctorDef :: Name -> Description -> [ParameterChunk] -> [Initializer] -> [FuncStmt] -> Func ctorDef n desc ps is fs = FDef $ CtorDef n desc ps is fs @@ -109,14 +109,14 @@ data FuncData where -- | Defines a function. data FuncDef where -- | Parameters are: Name, description, parameters, return type, return description, statements. - FuncDef :: Name -> Description -> [ParameterChunk] -> Space -> + FuncDef :: Name -> Description -> [ParameterChunk] -> Space -> Maybe Description -> [FuncStmt] -> FuncDef - CtorDef :: Name -> Description -> [ParameterChunk] -> [Initializer] -> + CtorDef :: Name -> Description -> [ParameterChunk] -> [Initializer] -> [FuncStmt] -> FuncDef -- | Variable-value pair. type Initializer = (CodeVarChunk, CodeExpr) - + data FuncStmt where FAsg :: CodeVarChunk -> CodeExpr -> FuncStmt FAsgIndex :: CodeVarChunk -> Integer -> CodeExpr -> FuncStmt @@ -136,12 +136,12 @@ data FuncStmt where FMulti :: [FuncStmt] -> FuncStmt -- slight hack, for now FAppend :: CodeExpr -> CodeExpr -> FuncStmt - + -- | Define an assignment statement. ($:=) :: (Quantity c, MayHaveUnit c) => c -> CodeExpr -> FuncStmt v $:= e = FAsg (quantvar v) e --- | Define a for-loop. 'Quantity' is for the iteration variable, 'CodeExpr' is the +-- | Define a for-loop. 'Quantity' is for the iteration variable, 'CodeExpr' is the -- upper bound at that variable (the variable will start with a value of 0). -- ['FuncStmt'] is for the loop body. ffor :: (Quantity c, MayHaveUnit c) => c -> CodeExpr -> [FuncStmt] -> FuncStmt @@ -150,7 +150,7 @@ ffor v end = fforRange v (int 0) end (int 1) -- | Define a for-loop. 'Quantity' is for the iteration variable, and 3 'CodeExpr's -- for the start, stop, step numbers. -- ['FuncStmt'] is for the loop body. -fforRange :: (Quantity c, MayHaveUnit c) => c -> CodeExpr -> CodeExpr +fforRange :: (Quantity c, MayHaveUnit c) => c -> CodeExpr -> CodeExpr -> CodeExpr -> [FuncStmt] -> FuncStmt fforRange v = FFor (quantvar v) @@ -158,14 +158,14 @@ fforRange v = FFor (quantvar v) fDecDef :: (Quantity c, MayHaveUnit c) => c -> CodeExpr -> FuncStmt fDecDef v = FDecDef (quantvar v) --- | Returns the list of 'CodeVarChunk's that are used in the list of 'FuncStmt's +-- | Returns the list of 'CodeVarChunk's that are used in the list of 'FuncStmt's -- but are not declared in any of the 'FuncStmt's. fstdecl :: ChunkDB -> [FuncStmt] -> [CodeVarChunk] -fstdecl ctx fsts = nub (concatMap (fstvars ctx) fsts) \\ nub (concatMap (declared ctx) fsts) +fstdecl ctx fsts = nub (concatMap (fstvars ctx) fsts) \\ nub (concatMap (declared ctx) fsts) where fstvars :: ChunkDB -> FuncStmt -> [CodeVarChunk] fstvars sm (FDecDef cch e) = cch:codevars' e sm - fstvars sm (FFuncDef cch ps sts) = quantvar cch : map quantvar ps + fstvars sm (FFuncDef cch ps sts) = quantvar cch : map quantvar ps ++ concatMap (fstvars sm) sts fstvars sm (FAsg cch e) = cch:codevars' e sm fstvars sm (FAsgIndex cch _ e) = cch:codevars' e sm @@ -184,7 +184,7 @@ fstdecl ctx fsts = nub (concatMap (fstvars ctx) fsts) \\ nub (concatMap (declare declared :: ChunkDB -> FuncStmt -> [CodeVarChunk] declared _ (FDecDef cch _) = [cch] - declared sm (FFuncDef cch ps sts) = quantvar cch : map quantvar ps + declared sm (FFuncDef cch ps sts) = quantvar cch : map quantvar ps ++ concatMap (declared sm) sts declared _ (FAsg _ _) = [] declared _ FAsgIndex {} = [] @@ -200,7 +200,7 @@ fstdecl ctx fsts = nub (concatMap (fstvars ctx) fsts) \\ nub (concatMap (declare declared sm (FMulti ss) = concatMap (declared sm) ss declared _ (FAppend _ _) = [] --- | Gets the name of a function. +-- | Gets the name of a function. fname :: Func -> Name fname (FDef (FuncDef n _ _ _ _ _)) = n fname (FDef (CtorDef n _ _ _ _)) = n diff --git a/code/drasil-code/lib/Language/README.md b/code/drasil-code/lib/Language/README.md index 3e547719fa..08a14dd0ef 100644 --- a/code/drasil-code/lib/Language/README.md +++ b/code/drasil-code/lib/Language/README.md @@ -5,6 +5,6 @@ Last updated: July 25, 2018 **Drasil** - Contains the code for Drasil - + README.md - - This file \ No newline at end of file + - This file diff --git a/code/drasil-code/package.yaml b/code/drasil-code/package.yaml index 4ab3a11460..5bacd919e3 100644 --- a/code/drasil-code/package.yaml +++ b/code/drasil-code/package.yaml @@ -22,6 +22,7 @@ dependencies: - drasil-database - drasil-gool - drasil-lang +- drasil-metadata - drasil-printers - drasil-sysinfo - drasil-theory diff --git a/code/drasil-code/test/FileTests.hs b/code/drasil-code/test/FileTests.hs index 7d9451fe38..fe359629e7 100644 --- a/code/drasil-code/test/FileTests.hs +++ b/code/drasil-code/test/FileTests.hs @@ -2,15 +2,15 @@ -- and write to files. See stable/gooltest for more details on what is generated through this. module FileTests (fileTests) where -import GOOL.Drasil (GSProgram, MSBlock, MSStatement, SMethod, OOProg, - ProgramSym(..), FileSym(..), BodySym(..), BlockSym(..), TypeSym(..), - DeclStatement(..), IOStatement(..), VariableSym(..), Literal(..), +import GOOL.Drasil (GSProgram, MSBlock, MSStatement, SMethod, OOProg, + ProgramSym(..), FileSym(..), BodySym(..), BlockSym(..), TypeSym(..), + DeclStatement(..), IOStatement(..), VariableSym(..), Literal(..), VariableValue(..), MethodSym(..), ModuleSym(..)) import Prelude hiding (return, print, log, exp, sin, cos, tan) -- | Creates a program in GOOL to test reading and writing to files. fileTests :: (OOProg r) => GSProgram r -fileTests = prog "FileTests" "" [fileDoc (buildModule "FileTests" [] +fileTests = prog "FileTests" "" [fileDoc (buildModule "FileTests" [] [fileTestMethod] [])] -- | File test method starts with 'writeStory' and ends with 'goodBye'. @@ -39,12 +39,12 @@ writeStory = block [ -- | Generates functions to read from a file. readStory :: (OOProg r) => MSStatement r -readStory = getFileInputAll (valueOf $ var "fileToRead" infile) +readStory = getFileInputAll (valueOf $ var "fileToRead" infile) (var "fileContents" (listType string)) -- | Prints the result of the 'readStory' function. Should be the same as -- what was given in 'writeStory'. goodBye :: (OOProg r) => MSBlock r goodBye = block [ - printLn (valueOf $ var "fileContents" (listType string)), - closeFile (valueOf $ var "fileToRead" infile)] \ No newline at end of file + printLn (valueOf $ var "fileContents" (listType string)), + closeFile (valueOf $ var "fileToRead" infile)] diff --git a/code/drasil-code/test/HelloWorld.hs b/code/drasil-code/test/HelloWorld.hs index 91ed45cee5..16b4535ca2 100644 --- a/code/drasil-code/test/HelloWorld.hs +++ b/code/drasil-code/test/HelloWorld.hs @@ -4,9 +4,9 @@ module HelloWorld (helloWorld) where import GOOL.Drasil (GSProgram, MSBody, MSBlock, MSStatement, SMethod, OOProg, - ProgramSym(..), FileSym(..), BodySym(..), bodyStatements, oneLiner, - BlockSym(..), listSlice, TypeSym(..), StatementSym(..), AssignStatement(..), (&=), - DeclStatement(..), IOStatement(..), StringStatement(..), CommentStatement(..), ControlStatement(..), + ProgramSym(..), FileSym(..), BodySym(..), bodyStatements, oneLiner, + BlockSym(..), listSlice, TypeSym(..), StatementSym(..), AssignStatement(..), (&=), + DeclStatement(..), IOStatement(..), StringStatement(..), CommentStatement(..), ControlStatement(..), VariableSym(..), listVar, Literal(..), VariableValue(..), CommandLineArgs(..), NumericExpression(..), BooleanExpression(..), Comparison(..), ValueExpression(..), extFuncApp, List(..), MethodSym(..), ModuleSym(..)) @@ -15,8 +15,8 @@ import Helper (helper) -- | Creates the HelloWorld program and necessary files. helloWorld :: (OOProg r) => GSProgram r -helloWorld = prog "HelloWorld" "" [docMod description - ["Brooks MacLachlan"] "" $ fileDoc (buildModule "HelloWorld" [] +helloWorld = prog "HelloWorld" "" [docMod description + ["Brooks MacLachlan"] "" $ fileDoc (buildModule "HelloWorld" [] [helloWorldMain] []), helper] -- | Description of program. @@ -25,7 +25,7 @@ description = "Tests various GOOL functions. It should run without errors." -- | Main function. Initializes variables and combines all the helper functions defined below. helloWorldMain :: (OOProg r) => SMethod r -helloWorldMain = mainFunction (body [ helloInitVariables, +helloWorldMain = mainFunction (body [ helloInitVariables, helloListSlice, block [ifCond [(valueOf (var "b" int) ?>= litInt 6, bodyStatements [varDecDef (var "dummy" string) (litString "dummy")]), (valueOf (var "b" int) ?== litInt 5, helloIfBody)] helloElseBody, helloIfExists, @@ -34,35 +34,35 @@ helloWorldMain = mainFunction (body [ helloInitVariables, -- | Initialize variables used in the generated program. helloInitVariables :: (OOProg r) => MSBlock r helloInitVariables = block [comment "Initializing variables", - varDec $ var "a" int, + varDec $ var "a" int, varDecDef (var "b" int) (litInt 5), - listDecDef (var "myOtherList" (listType double)) [litDouble 1.0, + listDecDef (var "myOtherList" (listType double)) [litDouble 1.0, litDouble 1.5], - varDecDef (var "oneIndex" int) (indexOf (valueOf $ var "myOtherList" + varDecDef (var "oneIndex" int) (indexOf (valueOf $ var "myOtherList" (listType double)) (litDouble 1.0)), printLn (valueOf $ var "oneIndex" int), var "a" int &= listSize (valueOf $ var "myOtherList" (listType double)), valStmt (listAdd (valueOf $ var "myOtherList" (listType double)) (litInt 2) (litDouble 2.0)), - valStmt (listAppend (valueOf $ var "myOtherList" (listType double)) + valStmt (listAppend (valueOf $ var "myOtherList" (listType double)) (litDouble 2.5)), varDec $ var "e" double, var "e" int &= listAccess (valueOf $ var "myOtherList" (listType double)) (litInt 1), - valStmt (listSet (valueOf $ var "myOtherList" (listType double)) + valStmt (listSet (valueOf $ var "myOtherList" (listType double)) (litInt 1) (litDouble 17.4)), listDec 7 (var "myName" (listType string)), stringSplit ' ' (var "myName" (listType string)) (litString "Brooks Mac"), printLn (valueOf $ var "myName" (listType string)), - listDecDef (var "boringList" (listType bool)) + listDecDef (var "boringList" (listType bool)) [litFalse, litFalse, litFalse, litFalse, litFalse], printLn (valueOf $ var "boringList" (listType bool)), listDec 2 $ var "mySlicedList" (listType double)] -- | Initialize and assign a value to a new variable @mySlicedList@. helloListSlice :: (OOProg r) => MSBlock r -helloListSlice = listSlice (var "mySlicedList" (listType double)) - (valueOf $ var "myOtherList" (listType double)) (Just (litInt 1)) +helloListSlice = listSlice (var "mySlicedList" (listType double)) + (valueOf $ var "myOtherList" (listType double)) (Just (litInt 1)) (Just (litInt 3)) Nothing -- | Create an If statement. @@ -95,12 +95,12 @@ helloIfBody = addComments "If body" (body [ printLn (valueOf $ var "d" int), printLn (valueOf $ var "myOtherList" (listType double)), printLn (valueOf $ var "mySlicedList" (listType double)), - + printStrLn "Type an int", getInput (var "d" int), printStrLn "Type another", discardInput], - + block [ printLn (litString " too"), printStr "boo", @@ -139,32 +139,32 @@ helloIfBody = addComments "If body" (body [ helloElseBody :: (OOProg r) => MSBody r helloElseBody = bodyStatements [printLn (arg 5)] --- | If-else statement checking if a list is empty. +-- | If-else statement checking if a list is empty. helloIfExists :: (OOProg r) => MSStatement r -helloIfExists = ifExists (valueOf $ var "boringList" (listType bool)) +helloIfExists = ifExists (valueOf $ var "boringList" (listType bool)) (oneLiner (printStrLn "Ew, boring list!")) (oneLiner (printStrLn "Great, no bores!")) -- | Creates a switch statement. helloSwitch :: (OOProg r) => MSStatement r -helloSwitch = switch (valueOf $ var "a" int) [(litInt 5, oneLiner (var "b" int &= litInt 10)), +helloSwitch = switch (valueOf $ var "a" int) [(litInt 5, oneLiner (var "b" int &= litInt 10)), (litInt 0, oneLiner (var "b" int &= litInt 5))] (oneLiner (var "b" int &= litInt 0)) -- | Creates a for loop. helloForLoop :: (OOProg r) => MSStatement r -helloForLoop = forRange i (litInt 0) (litInt 9) (litInt 1) (oneLiner (printLn +helloForLoop = forRange i (litInt 0) (litInt 9) (litInt 1) (oneLiner (printLn (valueOf i))) where i = var "i" int -- | Creates a while loop. helloWhileLoop :: (OOProg r) => MSStatement r -helloWhileLoop = while (valueOf (var "a" int) ?< litInt 13) (bodyStatements - [printStrLn "Hello", (&++) (var "a" int)]) +helloWhileLoop = while (valueOf (var "a" int) ?< litInt 13) (bodyStatements + [printStrLn "Hello", (&++) (var "a" int)]) -- | Creates a for-each loop. helloForEachLoop :: (OOProg r) => MSStatement r -helloForEachLoop = forEach i (valueOf $ listVar "myOtherList" double) - (oneLiner (printLn (extFuncApp "Helper" "doubleAndAdd" double [valueOf i, +helloForEachLoop = forEach i (valueOf $ listVar "myOtherList" double) + (oneLiner (printLn (extFuncApp "Helper" "doubleAndAdd" double [valueOf i, litDouble 1.0]))) where i = var "num" double diff --git a/code/drasil-code/test/Helper.hs b/code/drasil-code/test/Helper.hs index ba2853dd48..7531237db7 100644 --- a/code/drasil-code/test/Helper.hs +++ b/code/drasil-code/test/Helper.hs @@ -2,9 +2,9 @@ module Helper (helper) where import GOOL.Drasil (SFile, SMethod, - OOProg, FileSym(..), bodyStatements, TypeSym(..), + OOProg, FileSym(..), bodyStatements, TypeSym(..), DeclStatement(..), ControlStatement(..), (&=), VariableSym(..), - Literal(..), VariableValue(..), NumericExpression(..), ScopeSym(..), ParameterSym(..), MethodSym(..), + Literal(..), VariableValue(..), NumericExpression(..), ScopeSym(..), ParameterSym(..), MethodSym(..), ModuleSym(..)) import Prelude hiding (return,print,log,exp,sin,cos,tan) @@ -14,12 +14,12 @@ helper = fileDoc (buildModule "Helper" [] [doubleAndAdd] []) -- | Creates a function that doubles the arguments and adds them together. doubleAndAdd :: (OOProg r) => SMethod r -doubleAndAdd = docFunc "This function adds two numbers" - ["First number to add", "Second number to add"] (Just "Sum") $ +doubleAndAdd = docFunc "This function adds two numbers" + ["First number to add", "Second number to add"] (Just "Sum") $ function "doubleAndAdd" public double [param $ var "num1" double, param $ var "num2" double] (bodyStatements [ - varDec $ var "doubledSum" double, - var "doubledSum" double &= ((litDouble 2.0 #* valueOf (var "num1" double)) #+ + varDec $ var "doubledSum" double, + var "doubledSum" double &= ((litDouble 2.0 #* valueOf (var "num1" double)) #+ (litDouble 2.0 #* valueOf (var "num2" double))), - returnStmt (valueOf (var "doubledSum" double))]) \ No newline at end of file + returnStmt (valueOf (var "doubledSum" double))]) diff --git a/code/drasil-code/test/Main.hs b/code/drasil-code/test/Main.hs index 96672a6390..b28307744b 100644 --- a/code/drasil-code/test/Main.hs +++ b/code/drasil-code/test/Main.hs @@ -1,10 +1,10 @@ -- | Main module to gather all the GOOL tests and generate them. module Main (main) where -import GOOL.Drasil (Label, OOProg, ProgramSym(..), unCI, unJC, unPC, unCSC, +import GOOL.Drasil (Label, OOProg, ProgramSym(..), unCI, unJC, unPC, unCSC, unCPPC, unSC, FileData(..), ModData(..), ProgData(..), initialState) -import Language.Drasil.Code (PackageSym(..), AuxiliarySym(..), AuxData(..), +import Language.Drasil.Code (PackageSym(..), AuxiliarySym(..), AuxData(..), PackData(..), unPP, unJP, unCSP, unCPPP, unSP, ImplementationType(..)) import Text.PrettyPrint.HughesPJ (Doc, render) @@ -31,7 +31,7 @@ main = do createDirectoryIfMissing False "python" setCurrentDirectory "python" genCode (classes unPC unPP) - setCurrentDirectory workingDir + setCurrentDirectory workingDir createDirectoryIfMissing False "csharp" setCurrentDirectory "csharp" genCode (classes unCSC unCSP) @@ -47,30 +47,30 @@ main = do -- | Gathers all information needed to generate code, sorts it, and calls the renderers. genCode :: [PackData] -> IO() -genCode files = createCodeFiles (concatMap (\p -> replicate (length (progMods +genCode files = createCodeFiles (concatMap (\p -> replicate (length (progMods (packProg p)) + length (packAux p)) (progName $ packProg p)) files) $ makeCode (map (progMods . packProg) files) (map packAux files) --- Cannot assign the list of tests in a where clause and re-use it because the --- "r" type variable needs to be instantiated to two different types +-- Cannot assign the list of tests in a where clause and re-use it because the +-- "r" type variable needs to be instantiated to two different types -- (CodeInfo and a renderer) each time this function is called -- | Gathers the GOOL file tests and prepares them for rendering -classes :: (OOProg r, PackageSym r') => (r (Program r) -> ProgData) -> +classes :: (OOProg r, PackageSym r') => (r (Program r) -> ProgData) -> (r' (Package r') -> PackData) -> [PackData] -classes unRepr unRepr' = zipWith - (\p gs -> let (p',gs') = runState p gs +classes unRepr unRepr' = zipWith + (\p gs -> let (p',gs') = runState p gs pd = unRepr p' - in unRepr' $ package pd [makefile [] Program [] gs' pd]) + in unRepr' $ package pd [makefile [] Program [] gs' pd]) [helloWorld, patternTest, fileTests, vectorTest, nameGenTest] (map (unCI . (`evalState` initialState)) [helloWorld, patternTest, fileTests, vectorTest, nameGenTest]) -- | Formats code to be rendered. makeCode :: [[FileData]] -> [[AuxData]] -> [(FilePath, Doc)] -makeCode files auxs = concat $ zipWith (++) - (map (map (\fd -> (filePath fd, modDoc $ fileMod fd))) files) +makeCode files auxs = concat $ zipWith (++) + (map (map (\fd -> (filePath fd, modDoc $ fileMod fd))) files) (map (map (\ad -> (auxFilePath ad, auxDoc ad))) auxs) - + -- zip (map filePath files) (map (modDoc . fileMod) files) - -- ++ zip (map auxFilePath auxs) (map auxDoc auxs) + -- ++ zip (map auxFilePath auxs) (map auxDoc auxs) ------------------ -- IO Functions -- diff --git a/code/drasil-code/test/Observer.hs b/code/drasil-code/test/Observer.hs index d83f960f51..23fcf26429 100644 --- a/code/drasil-code/test/Observer.hs +++ b/code/drasil-code/test/Observer.hs @@ -1,9 +1,9 @@ -- | Part of the PatternTest GOOL tests. Defines an Observer class. module Observer (observer, observerName, printNum, x) where -import GOOL.Drasil (SFile, SVariable, SMethod, SClass, OOProg, FileSym(..), - PermanenceSym(..), oneLiner, TypeSym(..), IOStatement(..), VariableSym(..), - Literal(..), VariableValue(..), ScopeSym(..), MethodSym(..), initializer, StateVarSym(..), +import GOOL.Drasil (SFile, SVariable, SMethod, SClass, OOProg, FileSym(..), + PermanenceSym(..), oneLiner, TypeSym(..), IOStatement(..), VariableSym(..), + Literal(..), VariableValue(..), ScopeSym(..), MethodSym(..), initializer, StateVarSym(..), ClassSym(..), ModuleSym(..)) import Prelude hiding (return,print,log,exp,sin,cos,tan) @@ -40,4 +40,4 @@ observerConstructor = initializer [] [(x, litInt 5)] -- | Create the @printNum@ method. printNumMethod :: (MethodSym r, IOStatement r, VariableValue r) => SMethod r printNumMethod = method printNum public dynamic void [] $ - oneLiner $ printLn $ valueOf selfX \ No newline at end of file + oneLiner $ printLn $ valueOf selfX diff --git a/code/drasil-code/test/PatternTest.hs b/code/drasil-code/test/PatternTest.hs index 868d38856a..ff7f0cf9fa 100644 --- a/code/drasil-code/test/PatternTest.hs +++ b/code/drasil-code/test/PatternTest.hs @@ -3,16 +3,16 @@ module PatternTest (patternTest) where import GOOL.Drasil (GSProgram, VSType, SVariable, SValue, SMethod, OOProg, - ProgramSym(..), FileSym(..), BodySym(..), oneLiner, BlockSym(..), - TypeSym(..), StatementSym(..), AssignStatement, DeclStatement(..), - IOStatement(..), initState, changeState, initObserverList, - addObserver, VariableSym(..), Literal(..), VariableValue(..), + ProgramSym(..), FileSym(..), BodySym(..), oneLiner, BlockSym(..), + TypeSym(..), StatementSym(..), AssignStatement, DeclStatement(..), + IOStatement(..), initState, changeState, initObserverList, + addObserver, VariableSym(..), Literal(..), VariableValue(..), ValueExpression(..), extNewObj, FunctionSym(..), GetSet(..), List, StatePattern(..), ObserverPattern(..), StrategyPattern(..), MethodSym(..), ModuleSym(..)) import Prelude hiding (return,print,log,exp,sin,cos,tan) import Observer (observer, observerName, printNum, x) -- | Variables, program names, and used strings within the program. -progName, fsmName, offState, onState, noState, strat1, strat2, obs1Name, +progName, fsmName, offState, onState, noState, strat1, strat2, obs1Name, obs2Name, nName :: String progName = "PatternTest" fsmName = "myFSM" @@ -45,34 +45,34 @@ patternTest = prog progName "" [fileDoc (buildModule progName [] [patternTestMainMethod] []), observer] -- | Creates the main function for PatternTest. -patternTestMainMethod :: (MethodSym r, AssignStatement r, DeclStatement r, - IOStatement r, Literal r, VariableValue r, ValueExpression r, GetSet r, +patternTestMainMethod :: (MethodSym r, AssignStatement r, DeclStatement r, + IOStatement r, Literal r, VariableValue r, ValueExpression r, GetSet r, List r, StatePattern r, ObserverPattern r, StrategyPattern r) => SMethod r patternTestMainMethod = mainFunction (body [block [ varDec n, - initState fsmName offState, + initState fsmName offState, changeState fsmName onState, - checkState fsmName - [(litString offState, - oneLiner $ printStrLn offState), - (litString onState, - oneLiner $ printStrLn onState)] + checkState fsmName + [(litString offState, + oneLiner $ printStrLn offState), + (litString onState, + oneLiner $ printStrLn onState)] (oneLiner $ printStrLn noState)], runStrategy strat1 - [(strat1, oneLiner $ printStrLn strat1), + [(strat1, oneLiner $ printStrLn strat1), (strat2, oneLiner $ printStrLn strat2)] (Just $ litInt 3) (Just n), block [ - varDecDef obs1 newObserver, + varDecDef obs1 newObserver, varDecDef obs2 newObserver], block [ - initObserverList observerType [valueOf obs1], + initObserverList observerType [valueOf obs1], addObserver $ valueOf obs2, notifyObservers (func printNum void []) observerType], - + block [ valStmt $ set (valueOf obs1) x (litInt 10), - print $ get (valueOf obs1) x]]) \ No newline at end of file + print $ get (valueOf obs1) x]]) diff --git a/code/drasil-docLang/lib/Drasil/DocumentLanguage.hs b/code/drasil-docLang/lib/Drasil/DocumentLanguage.hs index 953675929c..f9bce915a2 100644 --- a/code/drasil-docLang/lib/Drasil/DocumentLanguage.hs +++ b/code/drasil-docLang/lib/Drasil/DocumentLanguage.hs @@ -48,7 +48,7 @@ import qualified Drasil.Sections.SpecificSystemDescription as SSD (assumpF, import qualified Drasil.Sections.Stakeholders as Stk (stakeholderIntro, tClientF, tCustomerF) import qualified Drasil.DocumentLanguage.TraceabilityMatrix as TM ( - generateTraceTableView, traceMHeader, TraceViewCat) + generateTraceTableView, traceMHeader, layoutUIDs) import qualified Drasil.DocumentLanguage.TraceabilityGraph as TG (traceMGF) import Drasil.DocumentLanguage.TraceabilityGraph (traceyGraphGetRefs) import Drasil.Sections.TraceabilityMandGs (traceMatStandard) @@ -61,6 +61,7 @@ import Data.Function (on) import Data.List (nub, sortBy, sortOn) import qualified Data.Map as Map (elems, toList, assocs, keys) import Data.Char (isSpace) +import Data.Maybe (maybeToList) import Drasil.Sections.ReferenceMaterial (emptySectSentPlu) -- * Main Function @@ -368,17 +369,17 @@ mkSolChSpec si (SCSProg l) = SSD.thModF (siSys si') $ map mkParagraph intro ++ map (LlC . tmodel fields si') ts mkSubSCS si' (DDs intro fields dds ShowDerivation) = --FIXME: need to keep track of DD intro. SSD.dataDefnF EmptyS $ map mkParagraph intro ++ concatMap f dds - where f e = [LlC $ ddefn fields si' e, derivation e] + where f e = LlC (ddefn fields si' e) : maybeToList (derivation e) mkSubSCS si' (DDs intro fields dds _) = SSD.dataDefnF EmptyS $ map mkParagraph intro ++ map f dds where f e = LlC $ ddefn fields si' e mkSubSCS si' (GDs intro fields gs' ShowDerivation) = - SSD.genDefnF $ map mkParagraph intro ++ concatMap (\x -> [LlC $ gdefn fields si' x, derivation x]) gs' + SSD.genDefnF $ map mkParagraph intro ++ concatMap (\x -> LlC (gdefn fields si' x) : maybeToList (derivation x)) gs' mkSubSCS si' (GDs intro fields gs' _) = SSD.genDefnF $ map mkParagraph intro ++ map (LlC . gdefn fields si') gs' mkSubSCS si' (IMs intro fields ims ShowDerivation) = SSD.inModelF SSD.pdStub SSD.ddStub SSD.tmStub SSD.gdStub $ map mkParagraph intro ++ - concatMap (\x -> [LlC $ instanceModel fields si' x, derivation x]) ims + concatMap (\x -> LlC (instanceModel fields si' x) : maybeToList (derivation x)) ims mkSubSCS si' (IMs intro fields ims _) = SSD.inModelF SSD.pdStub SSD.ddStub SSD.tmStub SSD.gdStub $ map mkParagraph intro ++ map (LlC . instanceModel fields si') ims @@ -429,13 +430,9 @@ mkTraceabilitySec (TraceabilityProg progs) si@SI{_sys = sys} = TG.traceMGF trace trace = map (\(TraceConfig u _ desc cols rows) -> TM.generateTraceTableView u desc cols rows si) fProgs fProgs = filter (\(TraceConfig _ _ _ cols rows) -> not $ null - (header (showUIDs rows sidb) si) || null (header (showUIDs cols sidb) si)) progs + (header (TM.layoutUIDs rows sidb) si) || null (header (TM.layoutUIDs cols sidb) si)) progs sidb = _sysinfodb si --- | Helper to get UIDs -showUIDs :: [TM.TraceViewCat] -> ChunkDB -> [UID] -> [UID] -showUIDs a s e = concatMap (filter (`elem` (Map.keys $ s ^. traceTable)) . (\ x -> x e s)) a - -- | Helper to get headers of rows and columns header :: ([UID] -> [UID]) -> SystemInformation -> [Sentence] header f = TM.traceMHeader (f . nub . Map.keys . (^. refbyTable)) diff --git a/code/drasil-docLang/lib/Drasil/DocumentLanguage/Definitions.hs b/code/drasil-docLang/lib/Drasil/DocumentLanguage/Definitions.hs index 25e4789690..750614ef70 100644 --- a/code/drasil-docLang/lib/Drasil/DocumentLanguage/Definitions.hs +++ b/code/drasil-docLang/lib/Drasil/DocumentLanguage/Definitions.hs @@ -72,9 +72,10 @@ instanceModel fs m i = mkRawLC (Defini Instance (foldr (mkIMField i m) [] fs)) ( -- | Create a derivation from a chunk's attributes. This follows the TM, DD, GD, -- or IM definition automatically (called automatically by 'SCSSub' program). -derivation :: (HasDerivation c, HasShortName c, Referable c) => c -> Contents -derivation c = maybe (mkParagraph EmptyS) - (\(Derivation h d) -> LlC $ llcc (ref c) $ DerivBlock h $ map makeDerivCons d) $ c ^. derivations +derivation :: (HasDerivation c, HasShortName c, Referable c) => c -> Maybe Contents +derivation c = fmap + (\(Derivation h d) -> LlC $ llcc (ref c) $ DerivBlock h $ map makeDerivCons d) $ + c ^. derivations -- | Helper function for creating the layout objects -- (paragraphs and equation blocks) for a derivation. @@ -133,8 +134,8 @@ helperSources rs = [mkParagraph $ foldlList Comma List $ map (\r -> Ref (r ^. u -- | Creates the fields for a definition from a 'QDefinition' (used by 'ddefn'). mkDDField :: DataDefinition -> SystemInformation -> Field -> ModRow -> ModRow mkDDField d _ l@Label fs = (show l, [mkParagraph $ atStart d]) : fs -mkDDField d _ l@Symbol fs = (show l, [mkParagraph . P $ eqSymb d]) : fs -mkDDField d _ l@Units fs = (show l, [mkParagraph $ toSentenceUnitless d]) : fs +mkDDField d _ l@Symbol fs = (show l, [mkParagraph . P $ eqSymb $ d ^. defLhs]) : fs +mkDDField d _ l@Units fs = (show l, [mkParagraph $ toSentenceUnitless $ d ^. defLhs]) : fs mkDDField d _ l@DefiningEquation fs = (show l, [unlbldExpr $ express d]) : fs mkDDField d m l@(Description v u) fs = (show l, buildDDescription' v u d m) : fs mkDDField t m l@RefBy fs = (show l, [mkParagraph $ helperRefs t m]) : fs --FIXME: fill this in @@ -202,9 +203,9 @@ mkIMField _ _ l _ = error $ "Label " ++ show l ++ " not supported " ++ -- | Used for making definitions. The first pair is the symbol of the quantity we are -- defining. firstPair' :: InclUnits -> DataDefinition -> ListTuple -firstPair' IgnoreUnits d = (P $ eqSymb d, Flat $ phrase d, Nothing) +firstPair' IgnoreUnits d = (P $ eqSymb $ d ^. defLhs, Flat $ phrase d, Nothing) firstPair' IncludeUnits d = - (P $ eqSymb d, Flat $ phrase d +:+ sParen (toSentenceUnitless d), Nothing) + (P $ eqSymb $ d ^. defLhs, Flat $ phrase d +:+ sParen (toSentenceUnitless $ d ^. defLhs), Nothing) -- | Creates the descriptions for each symbol in the relation/equation. descPairs :: (Quantity q, MayHaveUnit q) => InclUnits -> [q] -> [ListTuple] diff --git a/code/drasil-docLang/lib/Drasil/Sections/Introduction.hs b/code/drasil-docLang/lib/Drasil/Sections/Introduction.hs index ff500e8a0b..1d1f52f2ec 100644 --- a/code/drasil-docLang/lib/Drasil/Sections/Introduction.hs +++ b/code/drasil-docLang/lib/Drasil/Sections/Introduction.hs @@ -84,7 +84,7 @@ overviewParagraph programDefinition = foldlSP [S "The following", phrase section -- | Constructor for Purpose of Document section that each example controls. purpDocPara1 :: CI -> Sentence purpDocPara1 proName = foldlSent [S "The primary purpose of this", phrase document, S "is to", - S "record the", plural requirement, S "of the" +:+. titleize proName, + S "record the", plural requirement, S "of" +:+. getAcc proName, atStart' goal `sC` plural assumption `sC` plural thModel `sC` plural definition `sC` S "and other", phrase model, S "derivation", phrase information, S "are specified" `sC` S "allowing the reader to fully", diff --git a/code/drasil-docLang/lib/Drasil/Sections/Requirements.hs b/code/drasil-docLang/lib/Drasil/Sections/Requirements.hs index 58d73bd35f..47b1c8f1c5 100644 --- a/code/drasil-docLang/lib/Drasil/Sections/Requirements.hs +++ b/code/drasil-docLang/lib/Drasil/Sections/Requirements.hs @@ -15,6 +15,7 @@ import Language.Drasil import Language.Drasil.Chunk.Concept.NamedCombinators import qualified Language.Drasil.Sentence.Combinators as S import Drasil.Sections.ReferenceMaterial(emptySectSentPlu) +import Theory.Drasil (HasOutput(output)) import Data.Drasil.Concepts.Documentation (description, funcReqDom, functionalRequirement, input_, nonfunctionalRequirement, {-output_,-} section_, @@ -119,8 +120,8 @@ mkValsSourceTable vals labl cap = llcc (makeTabRef labl) $ Table [atStart symbol_, atStart description, S "Source", atStart' unit_] (mkTable [ch . fst, atStart . fst, snd, toSentence . fst] $ sortBySymbolTuple vals) cap True -mkQRTuple :: (Quantity i, MayHaveUnit i, HasShortName i, Referable i) => [i] -> [(QuantityDict, Sentence)] -mkQRTuple = map (\c -> (qw c, refS c)) +mkQRTuple :: (HasOutput i, HasShortName i, Referable i) => [i] -> [(QuantityDict, Sentence)] +mkQRTuple = map (\c -> (c ^. output, refS c)) mkQRTupleRef :: (Quantity i, MayHaveUnit i, HasShortName r, Referable r) => [i] -> [r] -> [(QuantityDict, Sentence)] mkQRTupleRef = zipWith (curry (bimap qw refS)) diff --git a/code/drasil-example/README.md b/code/drasil-example/README.md index f41973ca83..0e680c1772 100644 --- a/code/drasil-example/README.md +++ b/code/drasil-example/README.md @@ -5,7 +5,7 @@ Last updated: July 22, 2021 This folder contains our working examples (implementations in Drasil of the previously manually created case studies). -**dblpendulum** +**dblpend** - Contains the current state of the Double Pendulum case study implemented in Drasil **gamephysics** @@ -17,7 +17,7 @@ This folder contains our working examples (implementations in Drasil of the prev **hghc** - Contains the current state of the HGHC (fuel pin) example implemented in Drasil -**nopcm** +**swhsnopcm** - Contains the current state of the solar water heating system case study implemented in Drasil **pdcontroller** @@ -26,7 +26,7 @@ This folder contains our working examples (implementations in Drasil of the prev **projectile** - Contains the current work on implementing the projectile example in Drasil -**sglpendulum** +**sglpend** - Contains the current state of the Single Pendulum case study implemented in Drasil **ssp** diff --git a/code/drasil-example/dblpendulum/app/Main.hs b/code/drasil-example/dblpend/app/Main.hs similarity index 65% rename from code/drasil-example/dblpendulum/app/Main.hs rename to code/drasil-example/dblpend/app/Main.hs index ab4baa567b..fce7f48c0b 100644 --- a/code/drasil-example/dblpendulum/app/Main.hs +++ b/code/drasil-example/dblpend/app/Main.hs @@ -4,15 +4,15 @@ import GHC.IO.Encoding import Language.Drasil.Generate (gen, typeCheckSI, genCode, genDot, genLog, DocSpec(DocSpec), DocType(SRS), Format(..), docChoices, dumpEverything) -import Drasil.DblPendulum.Body (srs, printSetting, fullSI) -import Drasil.DblPendulum.Choices (choices, code) +import Drasil.DblPend.Body (srs, printSetting, fullSI) +import Drasil.DblPend.Choices (choices, code) main :: IO() main = do setLocaleEncoding utf8 dumpEverything fullSI ".drasil/" typeCheckSI fullSI - gen (DocSpec (docChoices SRS [HTML, TeX, JSON]) "DblPendulum_SRS") srs printSetting + gen (DocSpec (docChoices SRS [HTML, TeX, JSON]) "DblPend_SRS") srs printSetting genCode choices code genDot fullSI genLog fullSI printSetting diff --git a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Assumptions.hs b/code/drasil-example/dblpend/lib/Drasil/DblPend/Assumptions.hs similarity index 94% rename from code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Assumptions.hs rename to code/drasil-example/dblpend/lib/Drasil/DblPend/Assumptions.hs index 3545da6a52..6ab180867e 100644 --- a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Assumptions.hs +++ b/code/drasil-example/dblpend/lib/Drasil/DblPend/Assumptions.hs @@ -1,5 +1,5 @@ {-# LANGUAGE PostfixOperators #-} -module Drasil.DblPendulum.Assumptions (twoDMotion, cartSys, cartSysR, +module Drasil.DblPend.Assumptions (twoDMotion, cartSys, cartSysR, yAxisDir, startOriginSingle, startOriginDouble, firstPend, secondPend, assumpSingle, assumpDouble) where import Language.Drasil @@ -9,7 +9,7 @@ import qualified Language.Drasil.Sentence.Combinators as S import Data.Drasil.Concepts.Documentation (assumpDom) import Data.Drasil.Concepts.Math (cartesian, xAxis, yAxis, direction, origin, positive) import Data.Drasil.Concepts.Physics (gravity, twoD, pendulum) -import Drasil.DblPendulum.Concepts (pendMotion, firstRod, secondRod, firstObject, secondObject) +import Drasil.DblPend.Concepts (pendMotion, firstRod, secondRod, firstObject, secondObject) assumpBasic :: [ConceptInstance] assumpBasic = [twoDMotion, cartSys, cartSysR, yAxisDir] diff --git a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Body.hs b/code/drasil-example/dblpend/lib/Drasil/DblPend/Body.hs similarity index 86% rename from code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Body.hs rename to code/drasil-example/dblpend/lib/Drasil/DblPend/Body.hs index d1749bafe1..9072f3ccc7 100644 --- a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Body.hs +++ b/code/drasil-example/dblpend/lib/Drasil/DblPend/Body.hs @@ -1,8 +1,10 @@ {-# LANGUAGE PostfixOperators #-} -module Drasil.DblPendulum.Body where +module Drasil.DblPend.Body where + +import Control.Lens ((^.)) import Language.Drasil hiding (organization, section) -import Theory.Drasil (TheoryModel) +import Theory.Drasil (TheoryModel, output) import Drasil.SRSDocument import qualified Drasil.DocLang.SRS as SRS @@ -29,21 +31,21 @@ import Data.Drasil.Software.Products (prodtcon) import Data.Drasil.Theories.Physics (newtonSL, accelerationTM, velocityTM, newtonSLR) import Data.Drasil.TheoryConcepts (inModel) -import Drasil.DblPendulum.Figures (figMotion, sysCtxFig1) -import Drasil.DblPendulum.Assumptions (assumpDouble) -import Drasil.DblPendulum.Concepts (rod, concepts, pendMotion, progName, firstRod, secondRod, firstObject, secondObject) -import Drasil.DblPendulum.Goals (goals, goalsInputs) -import Drasil.DblPendulum.DataDefs (dataDefs) -import Drasil.DblPendulum.IMods (iMods) -import Drasil.DblPendulum.GenDefs (genDefns) -import Drasil.DblPendulum.Unitals (lenRod_1, lenRod_2, symbols, inputs, outputs, +import Drasil.DblPend.Figures (figMotion, sysCtxFig1) +import Drasil.DblPend.Assumptions (assumpDouble) +import Drasil.DblPend.Concepts (rod, concepts, pendMotion, progName, firstRod, secondRod, firstObject, secondObject) +import Drasil.DblPend.Goals (goals, goalsInputs) +import Drasil.DblPend.DataDefs (dataDefs) +import Drasil.DblPend.IMods (iMods) +import Drasil.DblPend.GenDefs (genDefns) +import Drasil.DblPend.Unitals (lenRod_1, lenRod_2, symbols, inputs, outputs, inConstraints, outConstraints, acronyms, pendDisAngle, constants) -import Drasil.DblPendulum.Requirements (funcReqs, nonFuncReqs) -import Drasil.DblPendulum.References (citations) +import Drasil.DblPend.Requirements (funcReqs, nonFuncReqs) +import Drasil.DblPend.References (citations) import Data.Drasil.ExternalLibraries.ODELibraries (scipyODESymbols, osloSymbols, apacheODESymbols, odeintSymbols, arrayVecDepVar) import Language.Drasil.Code (quantvar) -import Drasil.DblPendulum.ODEs (dblPenODEInfo) +import Drasil.DblPend.ODEs (dblPenODEInfo) srs :: Document @@ -65,15 +67,15 @@ mkSRS = [TableOfContents, -- This creates the Table of Contents , TAandA -- Add table of abbreviation and acronym section ], IntroSec $ - IntroProg justification (phrase progName) + IntroProg (justification progName) (phrase progName) [IPurpose $ purpDoc progName Verbose, IScope scope, IChar [] charsOfReader [], IOrgSec inModel (SRS.inModel [] []) EmptyS], GSDSec $ GSDProg [ - SysCntxt [sysCtxIntro, LlC sysCtxFig1, sysCtxDesc, sysCtxList], - UsrChars [userCharacteristicsIntro], + SysCntxt [sysCtxIntro progName, LlC sysCtxFig1, sysCtxDesc, sysCtxList progName], + UsrChars [userCharacteristicsIntro progName], SystCons [] []], SSDSec $ SSDProg @@ -125,14 +127,14 @@ si = SI { } purp :: Sentence -purp = foldlSent_ [S "predict the", phraseNP (motion `ofA` pendulum)] +purp = foldlSent_ [S "predict the", phrase motion `S.ofA` S "double", phrase pendulum] symbolsAll :: [QuantityDict] symbolsAll = symbols ++ scipyODESymbols ++ osloSymbols ++ apacheODESymbols ++ odeintSymbols ++ map qw [listToArray $ quantvar pendDisAngle, arrayVecDepVar dblPenODEInfo] symbMap :: ChunkDB -symbMap = cdb (map qw iMods ++ map qw symbolsAll) +symbMap = cdb (map (^. output) iMods ++ map qw symbolsAll) (nw newtonSLR : nw progName : nw mass : nw len : nw kilogram : nw inValue : nw newton : nw degree : nw radian : nw unitVect : nw unitVectj : [nw errMsg, nw program] ++ map nw symbols ++ map nw doccon ++ map nw doccon' ++ map nw physicCon ++ map nw mathcon ++ map nw mathcon' ++ map nw physicCon' ++ @@ -142,7 +144,7 @@ symbMap = cdb (map qw iMods ++ map qw symbolsAll) dataDefs iMods genDefns tMods concIns [] [] ([] :: [Reference]) usedDB :: ChunkDB -usedDB = cdb ([] :: [QuantityDict]) (map nw acronyms ++ map nw symbols) ([] :: [ConceptChunk]) +usedDB = cdb ([] :: [QuantityDict]) (nw progName : map nw acronyms ++ map nw symbols) ([] :: [ConceptChunk]) ([] :: [UnitDefn]) [] [] [] [] [] [] [] ([] :: [Reference]) stdFields :: Fields @@ -158,13 +160,13 @@ concIns = assumpDouble ++ goals ++ funcReqs ++ nonFuncReqs ------------------------------ -- Section : INTRODUCTION -- ------------------------------ -justification :: Sentence -justification = foldlSent [ atStartNP (a_ pendulum), S "consists" `S.of_` phrase mass, +justification :: CI -> Sentence +justification prog = foldlSent [ atStartNP (a_ pendulum), S "consists" `S.of_` phrase mass, S "attached to the end" `S.ofA` phrase rod `S.andIts` S "moving curve" `S.is` (S "highly sensitive to initial conditions" !.), S "Therefore" `sC` S "it is useful to have a", phrase program, S "to simulate", phraseNP (motion `the_ofThe` pendulum), (S "to exhibit its chaotic characteristics" !.), - atStartNP (the program), S "documented here is called", phrase progName] + atStartNP (the program), S "documented here is called", phrase prog] ------------------------------- -- 2.1 : Purpose of Document -- @@ -201,12 +203,12 @@ charsOfReader = [phrase undergraduate +:+ S "level 2" +:+ phrase Doc.physics, -------------------------- -- 3.1 : System Context -- -------------------------- -sysCtxIntro :: Contents -sysCtxIntro = foldlSP +sysCtxIntro :: CI -> Contents +sysCtxIntro prog = foldlSP [refS sysCtxFig1, S "shows the" +:+. phrase sysCont, S "A circle represents an entity external to the", phrase software `sC` phraseNP (the user), S "in this case. A rectangle represents the", - phrase softwareSys, S "itself", sParen (short progName) +:+. EmptyS, + phrase softwareSys, S "itself", sParen (short prog) +:+. EmptyS, S "Arrows are used to show the data flow between the", phraseNP (system `andIts` environment)] @@ -216,10 +218,10 @@ sysCtxDesc = foldlSPCol [S "The interaction between the", phraseNP (product_ phrase interface, S "The responsibilities of the", phraseNP (user `andThe` system), S "are as follows"] -sysCtxUsrResp :: [Sentence] -sysCtxUsrResp = [S "Provide initial" +:+ pluralNP (condition `ofThePS` +sysCtxUsrResp :: CI -> [Sentence] +sysCtxUsrResp prog = [S "Provide initial" +:+ pluralNP (condition `ofThePS` physical) +:+ S "state of the" +:+ phrase motion +:+ S "and the" +:+ plural inDatum +:+ S "related to the" +:+ - phrase progName `sC` S "ensuring no errors in the" +:+ + phrase prog `sC` S "ensuring no errors in the" +:+ plural datum +:+. S "entry", S "Ensure that consistent units are used for" +:+. pluralNP (combineNINI input_ Doc.variable), S "Ensure required" +:+ @@ -235,20 +237,20 @@ sysCtxSysResp = [S "Detect data type mismatch, such as a string of characters" + S "Calculate the required" +:+. plural output_, S "Generate the required" +:+. plural graph] -sysCtxResp :: [Sentence] -sysCtxResp = [titleize user +:+ S "Responsibilities", - short progName +:+ S "Responsibilities"] +sysCtxResp :: CI -> [Sentence] +sysCtxResp prog = [titleize user +:+ S "Responsibilities", + short prog +:+ S "Responsibilities"] -sysCtxList :: Contents -sysCtxList = UlC $ ulcc $ Enumeration $ bulletNested sysCtxResp $ - map bulletFlat [sysCtxUsrResp, sysCtxSysResp] +sysCtxList :: CI -> Contents +sysCtxList prog = UlC $ ulcc $ Enumeration $ bulletNested (sysCtxResp prog) $ + map bulletFlat [sysCtxUsrResp prog, sysCtxSysResp] -------------------------------- -- 3.2 : User Characteristics -- -------------------------------- -userCharacteristicsIntro :: Contents -userCharacteristicsIntro = foldlSP - [S "The", phrase endUser `S.of_` short progName, +userCharacteristicsIntro :: CI -> Contents +userCharacteristicsIntro prog = foldlSP + [S "The", phrase endUser `S.of_` short prog, S "should have an understanding of", phrase highSchoolPhysics `sC` phrase highSchoolCalculus `S.and_` plural ode] diff --git a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Choices.hs b/code/drasil-example/dblpend/lib/Drasil/DblPend/Choices.hs similarity index 83% rename from code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Choices.hs rename to code/drasil-example/dblpend/lib/Drasil/DblPend/Choices.hs index baec01aad9..12042aeb82 100644 --- a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Choices.hs +++ b/code/drasil-example/dblpend/lib/Drasil/DblPend/Choices.hs @@ -1,4 +1,4 @@ -module Drasil.DblPendulum.Choices where +module Drasil.DblPend.Choices where import Language.Drasil.Code (Choices(..), CodeSpec, codeSpec, Comments(..), Verbosity(..), ConstraintBehaviour(..), ImplementationType(..), Lang(..), @@ -9,8 +9,8 @@ import Language.Drasil.Code (Choices(..), CodeSpec, codeSpec, Comments(..), import Data.Drasil.ExternalLibraries.ODELibraries (scipyODEPckg, osloPckg, apacheODEPckg, odeintPckg) -import Drasil.DblPendulum.Body (fullSI) -import Drasil.DblPendulum.ODEs (dblPenODEInfo) +import Drasil.DblPend.Body (fullSI) +import Drasil.DblPend.ODEs (dblPenODEInfo) code :: CodeSpec code = codeSpec fullSI choices [] @@ -23,7 +23,7 @@ choices = defaultChoices { optFeats = makeOptFeats (makeDocConfig [CommentFunc, CommentClass, CommentMod] Quiet Hide) (makeLogConfig [] "log.txt") - [SampleInput "../../datafiles/dblpendulum/sampleInput.txt", ReadME], + [SampleInput "../../datafiles/dblpend/sampleInput.txt", ReadME], srsConstraints = makeConstraints Warning Warning, extLibs = [Math (makeODE [dblPenODEInfo] [scipyODEPckg, osloPckg, apacheODEPckg, odeintPckg])] } diff --git a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Concepts.hs b/code/drasil-example/dblpend/lib/Drasil/DblPend/Concepts.hs similarity index 93% rename from code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Concepts.hs rename to code/drasil-example/dblpend/lib/Drasil/DblPend/Concepts.hs index 93b82cd558..93ebac7013 100644 --- a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Concepts.hs +++ b/code/drasil-example/dblpend/lib/Drasil/DblPend/Concepts.hs @@ -1,4 +1,4 @@ -module Drasil.DblPendulum.Concepts where +module Drasil.DblPend.Concepts where import Language.Drasil import Data.Drasil.Domains (physics) @@ -42,4 +42,4 @@ arcLen :: ConceptChunk arcLen = dcc "arc length" (nounPhraseSP "arc length") "the distance between two points on a curve" progName :: CI -progName = commonIdeaWithDict "pendulumTitle" (pn "Pendulum") "DblPendulum" [physics] +progName = commonIdeaWithDict "dblPendulum" (pn "Double Pendulum") "DblPend" [physics] diff --git a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/DataDefs.hs b/code/drasil-example/dblpend/lib/Drasil/DblPend/DataDefs.hs similarity index 88% rename from code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/DataDefs.hs rename to code/drasil-example/dblpend/lib/Drasil/DblPend/DataDefs.hs index 8568c8d7e9..9f95a86c6e 100644 --- a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/DataDefs.hs +++ b/code/drasil-example/dblpend/lib/Drasil/DblPend/DataDefs.hs @@ -1,12 +1,14 @@ -module Drasil.DblPendulum.DataDefs where +module Drasil.DblPend.DataDefs where + +import Control.Lens ((^.)) import Prelude hiding (sin, cos, sqrt) import Language.Drasil import qualified Language.Drasil.Sentence.Combinators as S import Theory.Drasil (DataDefinition, ddENoRefs, ddMENoRefs) -import Drasil.DblPendulum.Figures (figMotion) -import Drasil.DblPendulum.Unitals (pendDisAngle_1, pendDisAngle_2, lenRod_1, lenRod_2, xPos_1, yPos_1, xPos_2, yPos_2) -import Drasil.DblPendulum.Concepts (horizontalPos, verticalPos) +import Drasil.DblPend.Figures (figMotion) +import Drasil.DblPend.Unitals (pendDisAngle_1, pendDisAngle_2, lenRod_1, lenRod_2, xPos_1, yPos_1, xPos_2, yPos_2) +import Drasil.DblPend.Concepts (horizontalPos, verticalPos) import Data.Drasil.Quantities.Physics (velocity, position, time, acceleration, force) import Data.Drasil.Quantities.PhysicalProperties (mass) @@ -71,7 +73,7 @@ positionXQD_2 :: SimpleQDef positionXQD_2 = mkQuantDef xPos_2 positionXEqn_2 positionXEqn_2 :: PExpr -positionXEqn_2 = sy positionXDD_1 `addRe` (sy lenRod_2 `mulRe` sin (sy pendDisAngle_2)) +positionXEqn_2 = sy (positionXDD_1 ^. defLhs) `addRe` (sy lenRod_2 `mulRe` sin (sy pendDisAngle_2)) positionXFigRef_2 :: Sentence positionXFigRef_2 = ch xPos_2 `S.is` S "shown in" +:+. refS figMotion @@ -89,7 +91,7 @@ positionYQD_2 :: SimpleQDef positionYQD_2 = mkQuantDef yPos_2 positionYEqn_2 positionYEqn_2 :: PExpr -positionYEqn_2 = sy positionYDD_1 `addRe` neg (sy lenRod_2 `mulRe` cos (sy pendDisAngle_2)) +positionYEqn_2 = sy (positionYDD_1 ^. defLhs) `addRe` neg (sy lenRod_2 `mulRe` cos (sy pendDisAngle_2)) positionYFigRef_2 :: Sentence positionYFigRef_2 = ch yPos_2 `S.is` S "shown in" +:+. refS figMotion diff --git a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Derivations.hs b/code/drasil-example/dblpend/lib/Drasil/DblPend/Derivations.hs similarity index 96% rename from code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Derivations.hs rename to code/drasil-example/dblpend/lib/Drasil/DblPend/Derivations.hs index 57feb32e8a..bdcb608452 100644 --- a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Derivations.hs +++ b/code/drasil-example/dblpend/lib/Drasil/DblPend/Derivations.hs @@ -1,4 +1,4 @@ -module Drasil.DblPendulum.Derivations where +module Drasil.DblPend.Derivations where import Prelude hiding (sin, cos) @@ -6,9 +6,9 @@ import Language.Drasil (ModelExprC(..), ExprC(..), Express(..), ModelExpr, DefiningExpr(..)) import Data.Drasil.Quantities.Physics(velocity, acceleration, gravitationalMagnitude, time) -import Drasil.DblPendulum.DataDefs -import Drasil.DblPendulum.Expressions (velXExpr_2, velYExpr_2) -import Drasil.DblPendulum.Unitals (lenRod_1, massObj_1, massObj_2, +import Drasil.DblPend.DataDefs +import Drasil.DblPend.Expressions (velXExpr_2, velYExpr_2) +import Drasil.DblPend.Unitals (lenRod_1, massObj_1, massObj_2, xPos_1, xPos_2, yPos_1, yPos_2, xVel_1, xVel_2, yVel_1, yVel_2, xAccel_1, xAccel_2, yAccel_1, yAccel_2, tension_1, tension_2, angularVel_1, pendDisAngle_1, pendDisAngle_2) import Control.Lens ((^.)) diff --git a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Expressions.hs b/code/drasil-example/dblpend/lib/Drasil/DblPend/Expressions.hs similarity index 96% rename from code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Expressions.hs rename to code/drasil-example/dblpend/lib/Drasil/DblPend/Expressions.hs index 9f2cfc5145..de7923dd8c 100644 --- a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Expressions.hs +++ b/code/drasil-example/dblpend/lib/Drasil/DblPend/Expressions.hs @@ -1,11 +1,11 @@ -module Drasil.DblPendulum.Expressions where +module Drasil.DblPend.Expressions where import Prelude hiding (sin, cos, sqrt) import Language.Drasil import Data.Drasil.Quantities.Physics (gravitationalAccel, gravitationalMagnitude) -import Drasil.DblPendulum.DataDefs (positionXEqn_1) -import Drasil.DblPendulum.Unitals (lenRod_1, lenRod_2, massObj_1, massObj_2, +import Drasil.DblPend.DataDefs (positionXEqn_1) +import Drasil.DblPend.Unitals (lenRod_1, lenRod_2, massObj_1, massObj_2, xVel_1, yVel_1, xAccel_1, yAccel_1, angularAccel_1, angularAccel_2, tension_1, tension_2, angularVel_1, angularVel_2, pendDisAngle_1, pendDisAngle_2) diff --git a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Figures.hs b/code/drasil-example/dblpend/lib/Drasil/DblPend/Figures.hs similarity index 58% rename from code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Figures.hs rename to code/drasil-example/dblpend/lib/Drasil/DblPend/Figures.hs index adf00ed7c5..fc794edfcf 100644 --- a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Figures.hs +++ b/code/drasil-example/dblpend/lib/Drasil/DblPend/Figures.hs @@ -1,4 +1,4 @@ -module Drasil.DblPendulum.Figures (figMotion, sysCtxFig1) where +module Drasil.DblPend.Figures (figMotion, sysCtxFig1) where import Language.Drasil import Language.Drasil.Chunk.Concept.NamedCombinators @@ -6,11 +6,11 @@ import Language.Drasil.Chunk.Concept.NamedCombinators import Data.Drasil.Concepts.Documentation (physicalSystem, sysCont) resourcePath :: String -resourcePath = "../../../../datafiles/dblpendulum/" +resourcePath = "../../../../datafiles/dblpend/" figMotion :: LabelledContent -figMotion = llcc (makeFigRef "dblpendulum") $ figWithWidth (atStartNP (the physicalSystem)) - (resourcePath ++ "dblpendulum.png") 60 +figMotion = llcc (makeFigRef "dblpend") $ figWithWidth (atStartNP (the physicalSystem)) + (resourcePath ++ "dblpend.png") 60 sysCtxFig1 :: LabelledContent sysCtxFig1 = llcc (makeFigRef "sysCtxDiag") $ fig (titleize sysCont) diff --git a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/GenDefs.hs b/code/drasil-example/dblpend/lib/Drasil/DblPend/GenDefs.hs similarity index 97% rename from code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/GenDefs.hs rename to code/drasil-example/dblpend/lib/Drasil/DblPend/GenDefs.hs index ffd524531c..776da62724 100644 --- a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/GenDefs.hs +++ b/code/drasil-example/dblpend/lib/Drasil/DblPend/GenDefs.hs @@ -1,5 +1,5 @@ {-# LANGUAGE PostfixOperators #-} -module Drasil.DblPendulum.GenDefs (genDefns, velXGD_1, velYGD_1, +module Drasil.DblPend.GenDefs (genDefns, velXGD_1, velYGD_1, accelXGD_1, accelYGD_1, accelXGD_2, accelYGD_2, xForceGD_1, yForceGD_1, xForceGD_2, yForceGD_2) where @@ -14,12 +14,12 @@ import qualified Language.Drasil.Sentence.Combinators as S import qualified Language.Drasil.NounPhrase.Combinators as NP import Data.Drasil.Concepts.Math (xComp, yComp) import Data.Drasil.Quantities.Physics (velocity, acceleration, force) -import Drasil.DblPendulum.DataDefs -import qualified Drasil.DblPendulum.Expressions as E -import qualified Drasil.DblPendulum.Derivations as D -import Drasil.DblPendulum.Unitals (lenRod_1, xVel_1, xVel_2, +import Drasil.DblPend.DataDefs +import qualified Drasil.DblPend.Expressions as E +import qualified Drasil.DblPend.Derivations as D +import Drasil.DblPend.Unitals (lenRod_1, xVel_1, xVel_2, yVel_1, yVel_2, xAccel_1, yAccel_1, xAccel_2, yAccel_2) -import Drasil.DblPendulum.Concepts (horizontalPos, +import Drasil.DblPend.Concepts (horizontalPos, verticalPos, horizontalVel, verticalVel, horizontalForce, verticalForce, firstObject, secondObject) import Control.Lens ((^.)) diff --git a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Goals.hs b/code/drasil-example/dblpend/lib/Drasil/DblPend/Goals.hs similarity index 89% rename from code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Goals.hs rename to code/drasil-example/dblpend/lib/Drasil/DblPend/Goals.hs index 9763b0dc33..62346ba779 100644 --- a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Goals.hs +++ b/code/drasil-example/dblpend/lib/Drasil/DblPend/Goals.hs @@ -1,5 +1,5 @@ {-# LANGUAGE PostfixOperators#-} -module Drasil.DblPendulum.Goals (goals, goalsInputs) where +module Drasil.DblPend.Goals (goals, goalsInputs) where import Language.Drasil import Language.Drasil.Chunk.Concept.NamedCombinators @@ -8,7 +8,7 @@ import Data.Drasil.Concepts.Documentation (goalStmtDom) import qualified Data.Drasil.Concepts.PhysicalProperties as CPP (mass, len) import Data.Drasil.Concepts.Physics (gravitationalConst, motion) import Data.Drasil.Concepts.Math (iAngle) -import Drasil.DblPendulum.Concepts (rod) +import Drasil.DblPend.Concepts (rod) goals :: [ConceptInstance] diff --git a/code/drasil-example/dblpend/lib/Drasil/DblPend/IMods.hs b/code/drasil-example/dblpend/lib/Drasil/DblPend/IMods.hs new file mode 100644 index 0000000000..ad7b366879 --- /dev/null +++ b/code/drasil-example/dblpend/lib/Drasil/DblPend/IMods.hs @@ -0,0 +1,92 @@ +{-# LANGUAGE PostfixOperators #-} +module Drasil.DblPend.IMods (iMods, angleIM_1, angleIM_2) where + +import Prelude hiding (cos, sin) + +import Language.Drasil +import Theory.Drasil +import Utils.Drasil (weave) +import qualified Language.Drasil.Sentence.Combinators as S + +import Data.Drasil.Concepts.Documentation (condition) +import Data.Drasil.Concepts.Math (ode) + +import Drasil.DblPend.Derivations (angularAccelDerivEqns) +import Drasil.DblPend.Expressions (angularAccelExpr_1, angularAccelExpr_2, + cosAngleExpr1, cosAngleExpr2, forceDerivExpr1, forceDerivExpr2, + sinAngleExpr1, sinAngleExpr2) +import Drasil.DblPend.GenDefs (accelXGD_1, accelXGD_2, accelYGD_1, accelYGD_2, + xForceGD_1, xForceGD_2, yForceGD_1, yForceGD_2) +import Drasil.DblPend.Unitals (angularAccel_1, angularAccel_2, angularVel_1, + angularVel_2, lenRod_1, lenRod_2, massObj_1, massObj_2, pendDisAngle_1, + pendDisAngle_2) + +iMods :: [InstanceModel] +iMods = [angleIM_1, angleIM_2] + +angleDerivSents :: [Sentence] +angleDerivSents = [angleDerivSent1, EmptyS, angleDerivSent2, EmptyS, angleDerivSent3, + angleDerivSent4, EmptyS, angleDerivSent5, angleDerivSent6] + +angleDerivSent1, angleDerivSent2, angleDerivSent3, + angleDerivSent4, angleDerivSent5, angleDerivSent6 :: Sentence +angleDerivSent1 = foldlSentCol [S "By solving equations" +:+ refS xForceGD_2 `S.and_` refS yForceGD_2 + `S.for` eS forceDerivExpr1 `S.and_` eS forceDerivExpr2 `S.and_` S "then substituting into equation" +:+ + refS xForceGD_1 `S.and_` refS yForceGD_1 +:+ S ", We can get equations 1 and 2"] +angleDerivSent2 = foldlSentCol [S "Multiply the equation 1 by" +:+ + eS cosAngleExpr1 `S.and_` S "the equation 2 by" +:+ eS sinAngleExpr1 `S.and_` + S "rearrange to get"] +angleDerivSent3 = S "This leads to the equation 3" +angleDerivSent4 = foldlSentCol[S "Next, multiply equation" +:+ refS xForceGD_2 +:+ S "by" +:+ + eS cosAngleExpr2 `S.and_` S "equation" +:+ refS yForceGD_2 +:+ S "by" +:+ + eS sinAngleExpr2 `S.and_` S "rearrange to get"] +angleDerivSent5 = S "which leads to equation 4" +angleDerivSent6 = foldlSentCol[S "By giving equations" +:+ refS accelXGD_1 `S.and_` refS accelXGD_2 `S.and_` + refS accelYGD_1 `S.and_` refS accelYGD_2 +:+ + S "plus additional two equations, 3 and 4, we can get" +:+ refS angleIM_1 `S.and_` + refS angleIM_2 +:+ S "via a computer algebra program"] + +angleIM_1 :: InstanceModel +angleIM_1 = imNoRefs angleMK_1 + [qwC lenRod_1 $ UpFrom (Exc, exactDbl 0), + qwC lenRod_2 $ UpFrom (Exc, exactDbl 0), + qwC massObj_1 $ UpFrom (Exc, exactDbl 0), + qwC massObj_2 $ UpFrom (Exc, exactDbl 0), + qwUC pendDisAngle_1, + qwUC pendDisAngle_2] + (qw pendDisAngle_1) [] + Nothing "calOfAngle1" [foldlSent [ch pendDisAngle_1 `S.is` + S "calculated by solving the", getAcc ode, S "here together with the initial", + plural condition `S.and_` refS angleIM_2]] + +angleMK_1 :: ModelKind Expr +angleMK_1 = equationalModel "angleIM1" + (nounPhraseSP "calculation of angle of first rod") angleFD_1 + +angleFD_1 :: SimpleQDef +angleFD_1 = mkFuncDefByQ angularAccel_1 + [pendDisAngle_1, pendDisAngle_2, angularVel_1, angularVel_2] angularAccelExpr_1 + +angleIM_2 :: InstanceModel +angleIM_2 = imNoRefs angleMK_2 + [qwC lenRod_1 $ UpFrom (Exc, exactDbl 0), + qwC lenRod_2 $ UpFrom (Exc, exactDbl 0), + qwC massObj_1 $ UpFrom (Exc, exactDbl 0), + qwC massObj_2 $ UpFrom (Exc, exactDbl 0), + qwUC pendDisAngle_1, + qwUC pendDisAngle_2] + (qw pendDisAngle_2) [] + (Just angleDeriv_2) "calOfAngle2" [foldlSent [ch pendDisAngle_2 `S.is` + S "calculated by solving the", getAcc ode, S "here together with the initial", + plural condition `S.and_` refS angleIM_1]] + +angleMK_2 :: ModelKind Expr +angleMK_2 = equationalModel "angleIM2" + (nounPhraseSP "calculation of angle of second rod") angleFD_2 + +angleFD_2 :: SimpleQDef +angleFD_2 = mkFuncDefByQ angularAccel_2 + [pendDisAngle_1, pendDisAngle_2, angularVel_1, angularVel_2] angularAccelExpr_2 + +angleDeriv_2 :: Derivation +angleDeriv_2 = mkDerivName (phrase pendDisAngle_2) (weave [angleDerivSents, map eS angularAccelDerivEqns]) diff --git a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/ODEs.hs b/code/drasil-example/dblpend/lib/Drasil/DblPend/ODEs.hs similarity index 92% rename from code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/ODEs.hs rename to code/drasil-example/dblpend/lib/Drasil/DblPend/ODEs.hs index 916814c0b3..e0b20489fe 100644 --- a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/ODEs.hs +++ b/code/drasil-example/dblpend/lib/Drasil/DblPend/ODEs.hs @@ -1,4 +1,4 @@ -module Drasil.DblPendulum.ODEs (dblPenODEOpts, dblPenODEInfo) where +module Drasil.DblPend.ODEs (dblPenODEOpts, dblPenODEInfo) where import Language.Drasil (ExprC(..), LiteralC(int, exactDbl, dbl), square) import Language.Drasil.Code (odeInfo, odeOptions, quantvar, ODEInfo, @@ -6,7 +6,7 @@ import Language.Drasil.Code (odeInfo, odeOptions, quantvar, ODEInfo, import Data.Drasil.Quantities.Physics (time) -import Drasil.DblPendulum.Unitals(massObj_1, massObj_2, lenRod_1, lenRod_2, pendDisAngle) +import Drasil.DblPend.Unitals(massObj_1, massObj_2, lenRod_1, lenRod_2, pendDisAngle) import Prelude hiding (sin, cos) dblPenODEOpts :: ODEOptions diff --git a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/README.md b/code/drasil-example/dblpend/lib/Drasil/DblPend/README.md similarity index 100% rename from code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/README.md rename to code/drasil-example/dblpend/lib/Drasil/DblPend/README.md diff --git a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/References.hs b/code/drasil-example/dblpend/lib/Drasil/DblPend/References.hs similarity index 87% rename from code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/References.hs rename to code/drasil-example/dblpend/lib/Drasil/DblPend/References.hs index 05b9079872..35fd071972 100644 --- a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/References.hs +++ b/code/drasil-example/dblpend/lib/Drasil/DblPend/References.hs @@ -1,4 +1,4 @@ -module Drasil.DblPendulum.References (citations, koothoor2013, +module Drasil.DblPend.References (citations, koothoor2013, smithEtAl2007, smithLai2005, smithKoothoor2016) where import Language.Drasil diff --git a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Requirements.hs b/code/drasil-example/dblpend/lib/Drasil/DblPend/Requirements.hs similarity index 58% rename from code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Requirements.hs rename to code/drasil-example/dblpend/lib/Drasil/DblPend/Requirements.hs index 2f1e1e10fc..f9fb2457a0 100644 --- a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Requirements.hs +++ b/code/drasil-example/dblpend/lib/Drasil/DblPend/Requirements.hs @@ -1,9 +1,10 @@ -module Drasil.DblPendulum.Requirements where +module Drasil.DblPend.Requirements where import Language.Drasil import Drasil.DocLang.SRS (datCon, propCorSol) import Language.Drasil.Chunk.Concept.NamedCombinators import qualified Language.Drasil.Sentence.Combinators as S + import Data.Drasil.Concepts.Computation (inValue) import Data.Drasil.Concepts.Documentation (datumConstraint, funcReqDom, output_, value, nonFuncReqDom, code, environment, propOfCorSol) @@ -11,32 +12,34 @@ import Data.Drasil.Concepts.Documentation (datumConstraint, funcReqDom, -- requirement, srs, traceyMatrix, unlikelyChg, value, vavPlan) import Data.Drasil.Concepts.Math (calculation) import Data.Drasil.Concepts.Software (errMsg) -import Drasil.DblPendulum.IMods (angularAccelIM_1, angularAccelIM_2) -import Drasil.DblPendulum.Unitals (angularAccel_1, angularAccel_2) + +import Drasil.DblPend.IMods (angleIM_1, angleIM_2) +import Drasil.DblPend.Unitals (pendDisAngle_1, pendDisAngle_2) --Functional Requirements-- funcReqs :: [ConceptInstance] -funcReqs = [verifyInptVals, calcAngPos, outputValues] +funcReqs = [verifyInptVals, calcAng, outputValues] -verifyInptVals, calcAngPos, outputValues :: ConceptInstance +verifyInptVals, calcAng, outputValues :: ConceptInstance -verifyInptVals = cic "verifyInptVals" verifyInptValsDesc "Verify-Input-Values" funcReqDom -calcAngPos = cic "calcAngPos" calcAngPosDesc "Calculate-Angular-Position-Of-Mass" funcReqDom -outputValues = cic "outputValues" outputValuesDesc "Output-Values" funcReqDom +verifyInptVals = cic "verifyInptVals" verifyInptValsDesc "Verify-Input-Values" funcReqDom +calcAng = cic "calcAng" calcAngDesc "Calculate-Angle-Of-Rod" funcReqDom +outputValues = cic "outputValues" outputValuesDesc "Output-Values" funcReqDom -verifyInptValsDesc, calcAngPosDesc, outputValuesDesc :: Sentence +verifyInptValsDesc, calcAngDesc, outputValuesDesc :: Sentence verifyInptValsDesc = foldlSent [S "Check the entered", plural inValue, - S "to ensure that they do not exceed the" +:+. namedRef (datCon ([]::[Contents]) ([]::[Section])) (plural datumConstraint), + S "to ensure that they do not exceed the" +:+. + namedRef (datCon ([]::[Contents]) ([]::[Section])) (plural datumConstraint), S "If any of the", plural inValue, S "are out of bounds" `sC` S "an", phrase errMsg, S "is displayed" `S.andThe` plural calculation, S "stop"] -calcAngPosDesc = foldlSent [S "Calculate the following" +: plural value, - ch angularAccel_1 `S.and_` ch angularAccel_2, - sParen (S "from" +:+ refS angularAccelIM_1), - sParen (S "from" +:+ refS angularAccelIM_2)] -outputValuesDesc = foldlSent [atStart output_, ch angularAccel_1 `S.and_` ch angularAccel_2, - sParen (S "from" +:+ refS angularAccelIM_1 `S.and_` refS angularAccelIM_2)] +calcAngDesc = foldlSent [S "Calculate the following" +: plural value +:+ outputList] +outputValuesDesc = foldlSent [atStart output_ +:+ outputList] + +outputList :: Sentence +outputList = ch pendDisAngle_1 `S.and_` ch pendDisAngle_2 +:+ + sParen (S "from" +:+ refS angleIM_1 `S.and_` refS angleIM_2) --Nonfunctional Requirements-- nonFuncReqs :: [ConceptInstance] diff --git a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Unitals.hs b/code/drasil-example/dblpend/lib/Drasil/DblPend/Unitals.hs similarity index 98% rename from code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Unitals.hs rename to code/drasil-example/dblpend/lib/Drasil/DblPend/Unitals.hs index 2429c5c2df..04fe5b7e1d 100644 --- a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/Unitals.hs +++ b/code/drasil-example/dblpend/lib/Drasil/DblPend/Unitals.hs @@ -1,4 +1,4 @@ -module Drasil.DblPendulum.Unitals where +module Drasil.DblPend.Unitals where import Language.Drasil import Language.Drasil.Display (Symbol(..)) @@ -16,7 +16,7 @@ import qualified Data.Drasil.Quantities.Physics as QP (position, force, velocity import Data.Drasil.Concepts.Physics (twoD) import Data.Drasil.Concepts.Math as CM (angle, xDir, yDir) import Data.Drasil.Quantities.Math as QM (unitVect, unitVectj, pi_) -import Drasil.DblPendulum.Concepts (firstRod, secondRod, firstObject, secondObject, horizontalPos, +import Drasil.DblPend.Concepts (firstRod, secondRod, firstObject, secondObject, horizontalPos, verticalPos, horizontalVel, verticalVel, horizontalAccel, verticalAccel) import Data.Drasil.Units.Physics (velU, accelU, angVelU, angAccelU) import Data.Drasil.Quantities.Physics (gravitationalAccelConst) diff --git a/code/drasil-example/nopcm/package.yaml b/code/drasil-example/dblpend/package.yaml similarity index 88% rename from code/drasil-example/nopcm/package.yaml rename to code/drasil-example/dblpend/package.yaml index af5fd4ab90..7fbcb9fc13 100644 --- a/code/drasil-example/nopcm/package.yaml +++ b/code/drasil-example/dblpend/package.yaml @@ -1,4 +1,4 @@ -name: nopcm +name: dblpend version: 0.1.24.0 author: "Dan Szymczak, Steven Palmer, Jacques Carette, Spencer Smith" maintainer: "Jacques Carette" @@ -24,16 +24,15 @@ dependencies: - drasil-printers - drasil-theory - drasil-utils -- swhs library: source-dirs: lib when: - condition: false - other-modules: Paths_nopcm + other-modules: Paths_dblpend executables: - nopcm: + dblpend: main: Main source-dirs: app ghc-options: @@ -42,7 +41,7 @@ executables: - -threaded - -O2 dependencies: - - nopcm + - dblpend when: - condition: false - other-modules: Paths_nopcm + other-modules: Paths_dblpend diff --git a/code/drasil-example/dblpendulum/stack.yaml b/code/drasil-example/dblpend/stack.yaml similarity index 100% rename from code/drasil-example/dblpendulum/stack.yaml rename to code/drasil-example/dblpend/stack.yaml diff --git a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/IMods.hs b/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/IMods.hs deleted file mode 100644 index ee73fc0b14..0000000000 --- a/code/drasil-example/dblpendulum/lib/Drasil/DblPendulum/IMods.hs +++ /dev/null @@ -1,82 +0,0 @@ -{-# LANGUAGE PostfixOperators #-} -module Drasil.DblPendulum.IMods (iMods, angularAccelIM_1, angularAccelIM_2) where - -import Prelude hiding (cos, sin) - -import Language.Drasil -import Theory.Drasil -import Utils.Drasil (weave) -import qualified Language.Drasil.Sentence.Combinators as S -import Drasil.DblPendulum.Expressions (angularAccelExpr_1, angularAccelExpr_2, - forceDerivExpr1, forceDerivExpr2, - cosAngleExpr1, sinAngleExpr1, cosAngleExpr2, sinAngleExpr2) -import Drasil.DblPendulum.Derivations (angularAccelDerivEqns) -import Drasil.DblPendulum.Unitals (pendDisAngle_1, pendDisAngle_2, lenRod_1, lenRod_2, - massObj_1, massObj_2, angularAccel_1, angularAccel_2, angularVel_1, angularVel_2) -import Drasil.DblPendulum.GenDefs (xForceGD_2, yForceGD_2, xForceGD_1, yForceGD_1, accelXGD_1, accelXGD_2, accelYGD_1, accelYGD_2) - -iMods :: [InstanceModel] -iMods = [angularAccelIM_1, angularAccelIM_2] - -angularAccelDerivSents :: [Sentence] -angularAccelDerivSents = [angularAccelDerivSent1, EmptyS, angularAccelDerivSent2, EmptyS, angularAccelDerivSent3, - angularAccelDerivSent4, EmptyS, angularAccelDerivSent5, angularAccelDerivSent6] - -angularAccelDerivSent1, angularAccelDerivSent2, angularAccelDerivSent3, - angularAccelDerivSent4, angularAccelDerivSent5, angularAccelDerivSent6 :: Sentence -angularAccelDerivSent1 = foldlSentCol [S "By solving equations" +:+ refS xForceGD_2 `S.and_` refS yForceGD_2 - `S.for` eS forceDerivExpr1 `S.and_` eS forceDerivExpr2 `S.and_` S "then substituting into equation" +:+ - refS xForceGD_1 `S.and_` refS yForceGD_1 +:+ S ", We can get equations 1 and 2"] -angularAccelDerivSent2 = foldlSentCol [S "Multiply the equation 1 by" +:+ - eS cosAngleExpr1 `S.and_` S "the equation 2 by" +:+ eS sinAngleExpr1 `S.and_` - S "rearrange to get"] -angularAccelDerivSent3 = S "This leads to the equation 3" -angularAccelDerivSent4 = foldlSentCol[S "Next, multiply equation" +:+ refS xForceGD_2 +:+ S "by" +:+ - eS cosAngleExpr2 `S.and_` S "equation" +:+ refS yForceGD_2 +:+ S "by" +:+ - eS sinAngleExpr2 `S.and_` S "rearrange to get"] -angularAccelDerivSent5 = S "which leads to equation 4" -angularAccelDerivSent6 = foldlSentCol[S "By giving equations" +:+ refS accelXGD_1 `S.and_` refS accelXGD_2 `S.and_` - refS accelYGD_1 `S.and_` refS accelYGD_2 +:+ - S "plus additional two equations, 3 and 4, we can get" +:+ refS angularAccelIM_1 `S.and_` - refS angularAccelIM_2 +:+ S "via a computer algebra program"] - -angularAccelIM_1 :: InstanceModel -angularAccelIM_1 = imNoRefs angularAccelMK_1 - [qwC lenRod_1 $ UpFrom (Exc, exactDbl 0), - qwC lenRod_2 $ UpFrom (Exc, exactDbl 0), - qwC massObj_1 $ UpFrom (Exc, exactDbl 0), - qwC massObj_2 $ UpFrom (Exc, exactDbl 0), - qwUC pendDisAngle_1, - qwUC pendDisAngle_2] - (qw angularAccel_1) [UpFrom (Exc, exactDbl 0)] - Nothing "calOfAngularAcceleration1" [] - -angularAccelMK_1 :: ModelKind Expr -angularAccelMK_1 = equationalModel "angularAccelerationIM1" - (nounPhraseSP "calculation of angular acceleration") angularAccelFD_1 - -angularAccelFD_1 :: SimpleQDef -angularAccelFD_1 = mkFuncDefByQ angularAccel_1 - [pendDisAngle_1, pendDisAngle_2, angularVel_1, angularVel_2] angularAccelExpr_1 - -angularAccelIM_2 :: InstanceModel -angularAccelIM_2 = imNoRefs angularAccelMK_2 - [qwC lenRod_1 $ UpFrom (Exc, exactDbl 0), - qwC lenRod_2 $ UpFrom (Exc, exactDbl 0), - qwC massObj_1 $ UpFrom (Exc, exactDbl 0), - qwC massObj_2 $ UpFrom (Exc, exactDbl 0), - qwUC pendDisAngle_1, - qwUC pendDisAngle_2] - (qw angularAccel_2) [UpFrom (Exc, exactDbl 0)] - (Just angularAccelDeriv_2) "calOfAngularAcceleration2" [{-Notes-}] - -angularAccelMK_2 :: ModelKind Expr -angularAccelMK_2 = equationalModel "angularAccelerationIM2" - (nounPhraseSP "calculation of angular acceleration") angularAccelFD_2 - -angularAccelFD_2 :: SimpleQDef -angularAccelFD_2 = mkFuncDefByQ angularAccel_2 - [pendDisAngle_1, pendDisAngle_2, angularVel_1, angularVel_2] angularAccelExpr_2 - -angularAccelDeriv_2 :: Derivation -angularAccelDeriv_2 = mkDerivName (phrase pendDisAngle_2) (weave [angularAccelDerivSents, map eS angularAccelDerivEqns]) diff --git a/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Body.hs b/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Body.hs index 7dd786624d..6f16912232 100644 --- a/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Body.hs +++ b/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Body.hs @@ -1,11 +1,12 @@ module Drasil.GamePhysics.Body where +import Control.Lens ((^.)) import Data.Maybe (mapMaybe) import Language.Drasil hiding (organization, section) import Drasil.SRSDocument import qualified Drasil.DocLang.SRS as SRS -import Theory.Drasil (qdEFromDD) +import Theory.Drasil (qdEFromDD, output) import Language.Drasil.Chunk.Concept.NamedCombinators import qualified Language.Drasil.Sentence.Combinators as S @@ -147,11 +148,12 @@ units :: [UnitDefn] -- FIXME units = map unitWrapper [metre, kilogram, second, joule] ++ map unitWrapper [newton, radian] symbMap :: ChunkDB -symbMap = cdb (map qw iMods ++ map qw symbolsAll) (map nw symbolsAll - ++ map nw acronyms ++ map nw prodtcon ++ map nw generalDefns ++ map nw iMods - ++ map nw softwarecon ++ map nw doccon ++ map nw doccon' - ++ map nw CP.physicCon ++ map nw educon ++ [nw algorithm] ++ map nw derived - ++ map nw fundamentals ++ map nw CM.mathcon ++ map nw CM.mathcon') +symbMap = cdb (map (^. output) iMods ++ map qw symbolsAll) (nw gamePhysics : + map nw symbolsAll ++ map nw acronyms ++ map nw prodtcon ++ map nw generalDefns + ++ map nw iMods ++ map (nw . (^. output)) iMods ++ map nw softwarecon + ++ map nw doccon ++ map nw doccon' ++ map nw CP.physicCon ++ map nw educon + ++ [nw algorithm] ++ map nw derived ++ map nw fundamentals + ++ map nw CM.mathcon ++ map nw CM.mathcon') (map cw defSymbols ++ srsDomains ++ map cw iMods) units dataDefs iMods generalDefns tMods concIns section [] [] diff --git a/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Concepts.hs b/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Concepts.hs index 7fe34eb3e2..cdfbfa4050 100644 --- a/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Concepts.hs +++ b/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Concepts.hs @@ -14,9 +14,9 @@ import Control.Lens ((^.)) ----- Acronyms ----- acronyms :: [CI] -acronyms = [assumption, centreMass, dataDefn, gamePhysics, genDefn, goalStmt, inModel, +acronyms = [assumption, centreMass, dataDefn, genDefn, goalStmt, inModel, likelyChg, ode, requirement, refBy, refName, srs, thModel, threeD, twoD, typUnc, unlikelyChg] centreMass, gamePhysics :: CI centreMass = commonIdeaWithDict "centreMass" (ctrOfMass ^. term) "CM" [physics] -gamePhysics = commonIdeaWithDict "gamePhysics" (pn "game physics library") "Game Physics" [physics] +gamePhysics = commonIdeaWithDict "gamePhysics" (pn "GamePhysics") "GamePhysics" [physics] \ No newline at end of file diff --git a/code/drasil-example/glassbr/lib/Drasil/GlassBR/Body.hs b/code/drasil-example/glassbr/lib/Drasil/GlassBR/Body.hs index a9282a15e2..0249f75023 100644 --- a/code/drasil-example/glassbr/lib/Drasil/GlassBR/Body.hs +++ b/code/drasil-example/glassbr/lib/Drasil/GlassBR/Body.hs @@ -34,11 +34,11 @@ import Drasil.GlassBR.Assumptions (assumptionConstants, assumptions) import Drasil.GlassBR.Changes (likelyChgs, unlikelyChgs) import Drasil.GlassBR.Concepts (acronyms, blastRisk, glaPlane, glaSlab, glassBR, ptOfExplsn, con, con', glass) -import Drasil.GlassBR.DataDefs (qDefns, configFp) +import Drasil.GlassBR.DataDefs (configFp) import qualified Drasil.GlassBR.DataDefs as GB (dataDefs) import Drasil.GlassBR.Figures import Drasil.GlassBR.Goals (goals) -import Drasil.GlassBR.IMods (symb, iMods, instModIntro) +import Drasil.GlassBR.IMods (symb, iMods, instModIntro, qDefns) import Drasil.GlassBR.References (astm2009, astm2012, astm2016, citations) import Drasil.GlassBR.Requirements (funcReqs, inReqDesc, funcReqsTables, nonfuncReqs) import Drasil.GlassBR.Symbols (symbolsForTable, thisSymbols) diff --git a/code/drasil-example/glassbr/lib/Drasil/GlassBR/DataDefs.hs b/code/drasil-example/glassbr/lib/Drasil/GlassBR/DataDefs.hs index fd8dc36da9..e328574d43 100644 --- a/code/drasil-example/glassbr/lib/Drasil/GlassBR/DataDefs.hs +++ b/code/drasil-example/glassbr/lib/Drasil/GlassBR/DataDefs.hs @@ -1,64 +1,30 @@ -module Drasil.GlassBR.DataDefs (aspRat, dataDefs, dimLL, qDefns, glaTyFac, - hFromt, loadDF, nonFL, risk, standOffDis, strDisFac, tolPre, tolStrDisFac, - eqTNTWDD, probOfBreak, calofCapacity, calofDemand, pbTolUsr, qRef,configFp) - where +module Drasil.GlassBR.DataDefs (dataDefs, aspRat, glaTyFac, glaTyFacQD, gtfRef, + hFromt, hFromtQD, loadDF, standOffDis, eqTNTWDD, calofDemand, aGrtrThanB, + arRef, hRef, configFp, stdVals) where import Control.Lens ((^.)) import Language.Drasil import Prelude hiding (log, exp, sqrt) import Theory.Drasil (DataDefinition, ddE) -import SysInfo.Drasil import qualified Language.Drasil.Sentence.Combinators as S -import Data.Drasil.Concepts.Documentation (datum, user) import Data.Drasil.Concepts.Math (parameter) import Data.Drasil.Concepts.PhysicalProperties (dimension) -import Data.Drasil.Citations (campidelli) - import Drasil.GlassBR.Assumptions (assumpSV, assumpLDFC) import Drasil.GlassBR.Concepts (annealed, fullyT, glass, heatS) -import Drasil.GlassBR.Figures (demandVsSDFig, dimlessloadVsARFig) -import Drasil.GlassBR.References (astm2009, beasonEtAl1998) -import Drasil.GlassBR.Unitals (actualThicknesses, aspectRatio, charWeight, - demand, demandq, dimlessLoad, eqTNTWeight, gTF, glassType, glassTypeCon, - glassTypeFactors, lDurFac, lRe, loadDur, loadSF, minThick, modElas, nomThick, - nominalThicknesses, nonFactorL, pbTol, plateLen, plateWidth, probBr, riskFun, - sdfTol, sdx, sdy, sdz, sflawParamK, sflawParamM, standOffDist, stressDistFac, - tNT, tolLoad, interpY, interpZ) +import Drasil.GlassBR.Figures (demandVsSDFig) +import Drasil.GlassBR.References (astm2009) +import Drasil.GlassBR.Unitals ---------------------- -- DATA DEFINITIONS -- ---------------------- dataDefs :: [DataDefinition] -dataDefs = [risk, hFromt, loadDF, strDisFac, nonFL, glaTyFac, - dimLL, tolPre, tolStrDisFac, standOffDis, aspRat, eqTNTWDD, probOfBreak, - calofCapacity, calofDemand] - -qDefns :: [Block SimpleQDef] -qDefns = Parallel hFromtQD {-DD2-} [glaTyFacQD {-DD6-}] : --can be calculated on their own - map (`Parallel` []) [dimLLQD {-DD7-}, strDisFacQD {-DD4-}, riskQD {-DD1-}, - tolStrDisFacQD {-DD9-}, tolPreQD {-DD8-}, nonFLQD {-DD5-}] - ---DD1-- - -riskEq :: Expr -riskEq = (sy sflawParamK $/ - (mulRe (sy plateLen) (sy plateWidth) $^ (sy sflawParamM $- exactDbl 1))) `mulRe` - ((sy modElas `mulRe` square (sy minThick)) $^ sy sflawParamM) `mulRe` sy lDurFac `mulRe` exp (sy stressDistFac) - --- FIXME [4] !!! -riskQD :: SimpleQDef -riskQD = mkQuantDef riskFun riskEq - -risk :: DataDefinition -risk = ddE riskQD - [dRef astm2009, dRefInfo beasonEtAl1998 $ Equation [4, 5], - dRefInfo campidelli $ Equation [14]] - Nothing "riskFun" [aGrtrThanB, hRef, ldfRef, jRef] +dataDefs = [hFromt, loadDF, glaTyFac, standOffDis, aspRat, eqTNTWDD, calofDemand] ---DD2-- +{--} hFromtEq :: Relation hFromtEq = frac 1 1000 `mulRe` incompleteCase (zipWith hFromtHelper @@ -73,7 +39,7 @@ hFromtQD = mkQuantDef minThick hFromtEq hFromt :: DataDefinition hFromt = ddE hFromtQD [dRef astm2009] Nothing "minThick" [hMin] ---DD3-- (#749) +{--} loadDFEq :: Expr loadDFEq = (sy loadDur $/ exactDbl 60) $^ (sy sflawParamM $/ exactDbl 16) @@ -85,37 +51,10 @@ loadDF :: DataDefinition loadDF = ddE loadDFQD [dRef astm2009] Nothing "loadDurFactor" [stdVals [loadDur, sflawParamM], ldfConst] ---DD4-- - -strDisFacEq :: Expr --- strDisFacEq = apply (sy stressDistFac) --- [sy dimlessLoad, sy aspectRatio] -strDisFacEq = apply interpZ [str "SDF.txt", sy aspectRatio, sy dimlessLoad] - -strDisFacQD :: SimpleQDef -strDisFacQD = mkQuantDef stressDistFac strDisFacEq - -strDisFac :: DataDefinition -strDisFac = ddE strDisFacQD [dRef astm2009] Nothing "stressDistFac" - [interpolating stressDistFac dimlessloadVsARFig, arRef, qHtRef] - ---DD5-- - -nonFLEq :: Expr -nonFLEq = mulRe (mulRe (sy tolLoad) (sy modElas)) (sy minThick $^ exactDbl 4) $/ - square (mulRe (sy plateLen) (sy plateWidth)) - -nonFLQD :: SimpleQDef -nonFLQD = mkQuantDef nonFactorL nonFLEq - -nonFL :: DataDefinition -nonFL = ddE nonFLQD [dRef astm2009] Nothing "nFL" - [qHtTlTolRef, stdVals [modElas], hRef, aGrtrThanB] - ---DD6-- +{--} glaTyFacEq :: Expr -glaTyFacEq = incompleteCase (zipWith glaTyFacHelper glassTypeFactors $ map (getAccStr . snd) glassType) +glaTyFacEq = incompleteCase (zipWith glaTyFacHelper glassTypeFactors $ map (abrv . snd) glassType) glaTyFacHelper :: Integer -> String -> (Expr, Relation) glaTyFacHelper result condition = (int result, sy glassTypeCon $= str condition) @@ -127,49 +66,7 @@ glaTyFac :: DataDefinition glaTyFac = ddE glaTyFacQD [dRef astm2009] Nothing "gTF" [anGlass, ftGlass, hsGlass] ---DD7-- - -dimLLEq :: Expr -dimLLEq = mulRe (sy demand) (square (mulRe (sy plateLen) (sy plateWidth))) - $/ mulRe (mulRe (sy modElas) (sy minThick $^ exactDbl 4)) (sy gTF) - -dimLLQD :: SimpleQDef -dimLLQD = mkQuantDef dimlessLoad dimLLEq - -dimLL :: DataDefinition -dimLL = ddE dimLLQD [dRef astm2009, dRefInfo campidelli $ Equation [7]] Nothing "dimlessLoad" - [qRef, aGrtrThanB, stdVals [modElas], hRef, gtfRef] - ---DD8-- - -tolPreEq :: Expr ---tolPreEq = apply (sy tolLoad) [sy sdfTol, (sy plateLen) / (sy plateWidth)] -tolPreEq = apply interpY [str "SDF.txt", sy aspectRatio, sy sdfTol] - -tolPreQD :: SimpleQDef -tolPreQD = mkQuantDef tolLoad tolPreEq - -tolPre :: DataDefinition -tolPre = ddE tolPreQD [dRef astm2009] Nothing "tolLoad" - [interpolating tolLoad dimlessloadVsARFig, arRef, jtolRef] - ---DD9-- - -tolStrDisFacEq :: Expr -tolStrDisFacEq = ln (ln (recip_ (exactDbl 1 $- sy pbTol)) - `mulRe` ((sy plateLen `mulRe` sy plateWidth) $^ (sy sflawParamM $- exactDbl 1) $/ - (sy sflawParamK `mulRe` ((sy modElas `mulRe` - square (sy minThick)) $^ sy sflawParamM) `mulRe` sy lDurFac))) - -tolStrDisFacQD :: SimpleQDef -tolStrDisFacQD = mkQuantDef sdfTol tolStrDisFacEq - -tolStrDisFac :: DataDefinition -tolStrDisFac = ddE tolStrDisFacQD [dRef astm2009] Nothing "sdfTol" - [pbTolUsr, aGrtrThanB, stdVals [sflawParamM, sflawParamK, mkUnitary modElas], - hRef, ldfRef] - ---DD10-- +{--} standOffDisEq :: Expr standOffDisEq = sqrt (square (sy sdx) `addRe` square (sy sdy) `addRe` square (sy sdz)) @@ -180,7 +77,7 @@ standOffDisQD = mkQuantDef standOffDist standOffDisEq standOffDis :: DataDefinition standOffDis = ddE standOffDisQD [dRef astm2009] Nothing "standOffDist" [] ---DD11-- +{--} aspRatEq :: Expr aspRatEq = sy plateLen $/ sy plateWidth @@ -191,7 +88,8 @@ aspRatQD = mkQuantDef aspectRatio aspRatEq aspRat :: DataDefinition aspRat = ddE aspRatQD [dRef astm2009] Nothing "aspectRatio" [aGrtrThanB] ---DD12-- +{--} + eqTNTWEq :: Expr eqTNTWEq = mulRe (sy charWeight) (sy tNT) @@ -201,28 +99,8 @@ eqTNTWQD = mkQuantDef eqTNTWeight eqTNTWEq eqTNTWDD :: DataDefinition eqTNTWDD = ddE eqTNTWQD [dRef astm2009] Nothing "eqTNTW" [] ---DD13-- -probOfBreakEq :: Expr -probOfBreakEq = exactDbl 1 $- exp (neg (sy risk)) - -probOfBreakQD :: SimpleQDef -probOfBreakQD = mkQuantDef probBr probOfBreakEq +{--} -probOfBreak :: DataDefinition -probOfBreak = ddE probOfBreakQD (map dRef [astm2009, beasonEtAl1998]) Nothing "probOfBreak" [riskRef] - ---DD14-- -calofCapacityEq :: Expr -calofCapacityEq = sy nonFL `mulRe` sy glaTyFac `mulRe` sy loadSF - -calofCapacityQD :: SimpleQDef -calofCapacityQD = mkQuantDef lRe calofCapacityEq - -calofCapacity :: DataDefinition -calofCapacity = ddE calofCapacityQD [dRef astm2009] Nothing "calofCapacity" - [lrCap, nonFLRef, gtfRef] - ---DD15-- calofDemandEq :: Expr calofDemandEq = apply interpY [str "TSD.txt", sy standOffDist, sy eqTNTWeight] @@ -232,8 +110,20 @@ calofDemandQD = mkQuantDef demand calofDemandEq calofDemand :: DataDefinition calofDemand = ddE calofDemandQD [dRef astm2009] Nothing "calofDemand" [calofDemandDesc] +-- Additional Notes -- +aGrtrThanB :: Sentence +aGrtrThanB = ch plateLen `S.and_` ch plateWidth `S.are` + (plural dimension `S.the_ofThe` S "plate") `sC` S "where" +:+. + sParen (eS $ sy plateLen $>= sy plateWidth) + +anGlass, ftGlass, hsGlass :: Sentence +anGlass = glassTypeHelper annealed +ftGlass = glassTypeHelper fullyT +hsGlass = glassTypeHelper heatS + +glassTypeHelper :: CI -> Sentence +glassTypeHelper t = getAcc t `S.is` phrase t +:+. phrase glass ---Additional Notes-- calofDemandDesc :: Sentence calofDemandDesc = foldlSent [ch demand `sC` EmptyS `S.or_` phrase demandq `sC` EmptyS `S.isThe` @@ -243,59 +133,23 @@ calofDemandDesc = S "is defined in" +:+. refS eqTNTWDD, ch standOffDist `S.isThe` phrase standOffDist, S "as defined in", refS standOffDis] -aGrtrThanB :: Sentence -aGrtrThanB = ch plateLen `S.and_` ch plateWidth `S.are` (plural dimension `S.the_ofThe` S "plate") `sC` - S "where" +:+. sParen (eS rel) - where - rel :: ModelExpr - rel = sy plateLen $>= sy plateWidth - -anGlass :: Sentence -anGlass = getAcc annealed `S.is` phrase annealed +:+. phrase glass - -ftGlass :: Sentence -ftGlass = getAcc fullyT `S.is` phrase fullyT +:+. phrase glass - hMin :: Sentence hMin = ch nomThick `S.is` S "a function that maps from the nominal thickness" +:+. (sParen (ch minThick) `S.toThe` phrase minThick) -hsGlass :: Sentence -hsGlass = getAcc heatS `S.is` phrase heatS +:+. phrase glass - ldfConst :: Sentence ldfConst = ch lDurFac `S.is` S "assumed to be constant" +:+. fromSource assumpLDFC -lrCap :: Sentence -lrCap = ch lRe +:+. S "is also called capacity" - -pbTolUsr :: Sentence -pbTolUsr = ch pbTol `S.is` S "entered by the" +:+. phrase user - -qRef :: Sentence -qRef = ch demand `S.isThe` (demandq ^. defn) `sC` S "as given in" +:+. refS calofDemand - -arRef, gtfRef, hRef, jRef, jtolRef, ldfRef, nonFLRef, qHtRef, qHtTlTolRef, riskRef :: Sentence -arRef = definedIn aspRat -gtfRef = definedIn glaTyFac -hRef = definedIn' hFromt (S "and is based on the nominal thicknesses") -jRef = definedIn strDisFac -jtolRef = definedIn tolStrDisFac -ldfRef = definedIn loadDF -nonFLRef = definedIn nonFL -qHtRef = definedIn dimLL -qHtTlTolRef = definedIn tolPre -riskRef = definedIn risk +arRef, gtfRef, hRef :: Sentence +arRef = definedIn aspRat +gtfRef = definedIn glaTyFac +hRef = definedIn' hFromt (S "and is based on the nominal thicknesses") -- List of Configuration Files necessary for DataDefs.hs configFp :: [String] configFp = ["SDF.txt", "TSD.txt"] ---- Helpers -interpolating :: (HasUID s, HasSymbol s, Referable f, HasShortName f) => s -> f -> Sentence -interpolating s f = foldlSent [ch s `S.is` S "obtained by interpolating from", - plural datum, S "shown" `S.in_` refS f] - +--- Helper stdVals :: (HasSymbol s, HasUID s) => [s] -> Sentence stdVals s = foldlList Comma List (map ch s) +:+ sent +:+. refS assumpSV where sent = case s of [ ] -> error "stdVals needs quantities" diff --git a/code/drasil-example/glassbr/lib/Drasil/GlassBR/IMods.hs b/code/drasil-example/glassbr/lib/Drasil/GlassBR/IMods.hs index 2192925c44..6b4cdff747 100644 --- a/code/drasil-example/glassbr/lib/Drasil/GlassBR/IMods.hs +++ b/code/drasil-example/glassbr/lib/Drasil/GlassBR/IMods.hs @@ -1,37 +1,169 @@ -module Drasil.GlassBR.IMods (symb, iMods, pbIsSafe, lrIsSafe, instModIntro) where +module Drasil.GlassBR.IMods (symb, iMods, pbIsSafe, lrIsSafe, instModIntro, + qDefns) where +import Control.Lens ((^.)) import Prelude hiding (exp) import Language.Drasil -import Theory.Drasil (InstanceModel, imNoDeriv, qwC, equationalModelN) +import Theory.Drasil (InstanceModel, imNoDeriv, qwC, qwUC, equationalModelN, + output) import Language.Drasil.Chunk.Concept.NamedCombinators import qualified Language.Drasil.Sentence.Combinators as S +import Drasil.SRSDocument (Block (Parallel)) + +import Data.Drasil.Citations (campidelli) +import Data.Drasil.Concepts.Documentation (goal, user, datum) import Data.Drasil.SI_Units -import Drasil.GlassBR.DataDefs (probOfBreak, calofCapacity, - pbTolUsr, qRef) -import Drasil.GlassBR.Goals (willBreakGS) -import Drasil.GlassBR.References (astm2009) -import Drasil.GlassBR.Unitals (charWeight, demand, isSafeLR, isSafePb, - lRe, pbTol, plateLen, plateWidth, probBr, standOffDist) -import Data.Drasil.Concepts.Documentation (goal) +import Drasil.GlassBR.DataDefs (aGrtrThanB, arRef, calofDemand, glaTyFac, + glaTyFacQD, gtfRef, hFromtQD, hRef, loadDF, stdVals) +import Drasil.GlassBR.Figures (dimlessloadVsARFig) +import Drasil.GlassBR.Goals (willBreakGS) +import Drasil.GlassBR.References (astm2009, beasonEtAl1998) +import Drasil.GlassBR.Unitals iMods :: [InstanceModel] -iMods = [pbIsSafe, lrIsSafe] +iMods = [risk, strDisFac, nonFL, dimLL, tolPre, tolStrDisFac, probOfBreak, + calofCapacity, pbIsSafe, lrIsSafe] symb :: [UnitalChunk] -symb = [ucuc plateLen metre, ucuc plateWidth metre, ucuc charWeight kilogram, ucuc standOffDist metre, demand] -- this is temporary +symb = [ucuc plateLen metre, ucuc plateWidth metre, ucuc charWeight kilogram, + ucuc standOffDist metre, demand] -- this is temporary -- ++ -- [dqdQd (qw calofDemand) demandq] +qDefns :: [Block SimpleQDef] +qDefns = Parallel hFromtQD [glaTyFacQD] : --can be calculated on their own + map (`Parallel` []) [dimLLQD, strDisFacQD, riskQD, tolStrDisFacQD, tolPreQD, + nonFLQD] + +abInputConstraints :: [(QuantityDict, Maybe (RealInterval Expr Expr))] +abInputConstraints = [qwC plateLen $ UpFrom (Exc, exactDbl 0), + qwC plateWidth $ Bounded (Exc, exactDbl 0) (Inc, sy plateLen)] + +aspectRatioConstraint :: RealInterval Expr Expr +aspectRatioConstraint = UpFrom (Inc, exactDbl 1) + +probConstraint :: RealInterval Expr Expr +probConstraint = Bounded (Inc, exactDbl 0) (Inc, exactDbl 1) + +{--} + +risk :: InstanceModel +risk = imNoDeriv (equationalModelN (riskFun ^. term) riskQD) + (qwUC modElas : qwUC lDurFac : qwUC stressDistFac : + map qwUC [sflawParamK, sflawParamM, minThick] ++ abInputConstraints) + (qw riskFun) [] [dRef astm2009, dRefInfo beasonEtAl1998 $ Equation [4, 5], + dRefInfo campidelli $ Equation [14]] "riskFun" [aGrtrThanB, hRef, ldfRef, jRef] + +-- FIXME [4] !!! +riskQD :: SimpleQDef +riskQD = mkQuantDef riskFun ((sy sflawParamK $/ + (mulRe (sy plateLen) (sy plateWidth) $^ (sy sflawParamM $- exactDbl 1))) `mulRe` + ((sy modElas `mulRe` square (sy minThick)) $^ sy sflawParamM) `mulRe` sy lDurFac `mulRe` exp (sy stressDistFac)) + +{--} + +strDisFac :: InstanceModel +strDisFac = imNoDeriv (equationalModelN (stressDistFac ^. term) strDisFacQD) + (qwC aspectRatio aspectRatioConstraint : [qwUC dimlessLoad]) (qw stressDistFac) + [Bounded (Inc, sy stressDistFacMin) (Inc, sy stressDistFacMax)] + [dRef astm2009] "stressDistFac" + [interpolating stressDistFac dimlessloadVsARFig, arRef, qHtRef] + +strDisFacQD :: SimpleQDef +strDisFacQD = mkQuantDef stressDistFac strDisFacEq + +strDisFacEq :: Expr +-- strDisFacEq = apply (sy stressDistFac) +-- [sy dimlessLoad, sy aspectRatio] +strDisFacEq = apply interpZ [str "SDF.txt", sy aspectRatio, sy dimlessLoad] + +{--} + +nonFL :: InstanceModel +nonFL = imNoDeriv (equationalModelN (nonFactorL ^. term) nonFLQD) + (qwUC tolLoad : qwUC modElas : qwUC minThick : abInputConstraints) + (qw nonFactorL) [] [dRef astm2009] "nFL" + [qHtTlTolRef, stdVals [modElas], hRef, aGrtrThanB] + +nonFLEq :: Expr +nonFLEq = mulRe (mulRe (sy tolLoad) (sy modElas)) (sy minThick $^ exactDbl 4) $/ + square (mulRe (sy plateLen) (sy plateWidth)) + +nonFLQD :: SimpleQDef +nonFLQD = mkQuantDef nonFactorL nonFLEq + +{--} + +dimLL :: InstanceModel +dimLL = imNoDeriv (equationalModelN (dimlessLoad ^. term) dimLLQD) + (qwUC demand : qwUC modElas : qwUC minThick : qwUC gTF : abInputConstraints) + (qw dimlessLoad) [] [dRef astm2009, dRefInfo campidelli $ Equation [7]] + "dimlessLoad" [qRef, aGrtrThanB, stdVals [modElas], hRef, gtfRef] + +dimLLEq :: Expr +dimLLEq = mulRe (sy demand) (square (mulRe (sy plateLen) (sy plateWidth))) + $/ mulRe (mulRe (sy modElas) (sy minThick $^ exactDbl 4)) (sy gTF) + +dimLLQD :: SimpleQDef +dimLLQD = mkQuantDef dimlessLoad dimLLEq + +{--} + +tolPre :: InstanceModel +tolPre = imNoDeriv (equationalModelN (tolLoad ^. term) tolPreQD) + [qwC aspectRatio aspectRatioConstraint, qwUC $ tolStrDisFac ^. output] (qw tolLoad) [] + [dRef astm2009] "tolLoad" [interpolating tolLoad dimlessloadVsARFig, arRef, + jtolRef] + +tolPreEq :: Expr +--tolPreEq = apply (sy tolLoad) [sy sdfTol, (sy plateLen) / (sy plateWidth)] +tolPreEq = apply interpY [str "SDF.txt", sy aspectRatio, sy sdfTol] + +tolPreQD :: SimpleQDef +tolPreQD = mkQuantDef tolLoad tolPreEq + +{--} + +tolStrDisFac :: InstanceModel +tolStrDisFac = imNoDeriv (equationalModelN (sdfTol ^. term) tolStrDisFacQD) + ((lDurFac, Nothing) : qwC pbTol probConstraint : qwUC modElas : abInputConstraints ++ + map qwUC [sflawParamM, sflawParamK, minThick]) (qw sdfTol) [] + [dRef astm2009] "sdfTol" [pbTolUsr, aGrtrThanB, stdVals [sflawParamM, + sflawParamK, mkUnitary modElas], hRef, ldfRef] + +tolStrDisFacQD :: SimpleQDef +tolStrDisFacQD = mkQuantDef sdfTol $ ln (ln (recip_ (exactDbl 1 $- sy pbTol)) + `mulRe` ((sy plateLen `mulRe` sy plateWidth) $^ (sy sflawParamM $- exactDbl 1) $/ + (sy sflawParamK `mulRe` ((sy modElas `mulRe` + square (sy minThick)) $^ sy sflawParamM) `mulRe` sy lDurFac))) + +{--} + +probOfBreak :: InstanceModel +probOfBreak = imNoDeriv (equationalModelN (probBr ^. term) probOfBreakQD) + [qwUC $ risk ^. output] (qw probBr) [probConstraint] (map dRef [astm2009, beasonEtAl1998]) "probOfBreak" + [riskRef] + +probOfBreakQD :: SimpleQDef +probOfBreakQD = mkQuantDef probBr (exactDbl 1 $- exp (neg $ sy $ risk ^. output)) + +{--} + +calofCapacity :: InstanceModel +calofCapacity = imNoDeriv (equationalModelN (lRe ^. term) calofCapacityQD) + (qwUC (nonFL ^. output) : qwUC (glaTyFac ^. output) : [qwUC loadSF]) (qw lRe) [] + [dRef astm2009] "calofCapacity" [lrCap, nonFLRef, gtfRef] + +calofCapacityQD :: SimpleQDef +calofCapacityQD = mkQuantDef lRe (sy (nonFL ^. output) `mulRe` sy (glaTyFac ^. defLhs) `mulRe` sy loadSF) + {--} pbIsSafe :: InstanceModel pbIsSafe = imNoDeriv (equationalModelN (nounPhraseSP "Safety Req-Pb") pbIsSafeQD) - [qwC probBr $ UpFrom (Exc, exactDbl 0), qwC pbTol $ UpFrom (Exc, exactDbl 0)] - (qw isSafePb) [] - [dRef astm2009] "isSafePb" - [pbIsSafeDesc, probBRRef, pbTolUsr] - + [qwC probBr probConstraint, qwC pbTol probConstraint] (qw isSafePb) [] + [dRef astm2009] "isSafePb" [pbIsSafeDesc, probBRRef, pbTolUsr] pbIsSafeQD :: SimpleQDef pbIsSafeQD = mkQuantDef isSafePb (sy probBr $< sy pbTol) @@ -59,9 +191,14 @@ instModIntro = foldlSent [atStartNP (the goal), refS willBreakGS, S "is met by", refS pbIsSafe `sC` refS lrIsSafe] -- Notes -- +lrCap :: Sentence +lrCap = ch lRe +:+. S "is also called capacity" -capRef :: Sentence -capRef = definedIn' calofCapacity (S "and is also called capacity") +pbTolUsr :: Sentence +pbTolUsr = ch pbTol `S.is` S "entered by the" +:+. phrase user + +qRef :: Sentence +qRef = ch demand `S.isThe` (demandq ^. defn) `sC` S "as given in" +:+. refS calofDemand lrIsSafeDesc :: Sentence lrIsSafeDesc = iModDesc isSafeLR @@ -69,7 +206,21 @@ lrIsSafeDesc = iModDesc isSafeLR pbIsSafeDesc :: Sentence pbIsSafeDesc = iModDesc isSafePb - (ch isSafePb `S.and_` ch isSafePb +:+ fromSource lrIsSafe) - -probBRRef :: Sentence -probBRRef = definedIn probOfBreak + (ch isSafePb `S.and_` ch isSafeLR +:+ fromSource lrIsSafe) + +capRef, jRef, jtolRef, ldfRef, nonFLRef, probBRRef, qHtRef, qHtTlTolRef, + riskRef :: Sentence +capRef = definedIn' calofCapacity (S "and is also called capacity") +jRef = definedIn strDisFac +jtolRef = definedIn tolStrDisFac +ldfRef = definedIn loadDF +nonFLRef = definedIn nonFL +probBRRef = definedIn probOfBreak +qHtRef = definedIn dimLL +qHtTlTolRef = definedIn tolPre +riskRef = definedIn risk + +-- Helper -- +interpolating :: (HasUID s, HasSymbol s, Referable f, HasShortName f) => s -> f -> Sentence +interpolating s f = foldlSent [ch s `S.is` S "obtained by interpolating from", + plural datum, S "shown" `S.in_` refS f] diff --git a/code/drasil-example/glassbr/lib/Drasil/GlassBR/Requirements.hs b/code/drasil-example/glassbr/lib/Drasil/GlassBR/Requirements.hs index f92bf55f30..2d990e6c50 100644 --- a/code/drasil-example/glassbr/lib/Drasil/GlassBR/Requirements.hs +++ b/code/drasil-example/glassbr/lib/Drasil/GlassBR/Requirements.hs @@ -5,10 +5,10 @@ import Control.Lens ((^.)) import Language.Drasil import Drasil.DocLang (inReq, mkQRTuple, mkQRTupleRef, mkValsSourceTable) import Drasil.DocLang.SRS (datCon, propCorSol) -import Theory.Drasil (DataDefinition) import Language.Drasil.Chunk.Concept.NamedCombinators import qualified Language.Drasil.NounPhrase.Combinators as NP import qualified Language.Drasil.Sentence.Combinators as S +import Theory.Drasil (DataDefinition) import Data.Drasil.Concepts.Computation (inValue) import Data.Drasil.Concepts.Documentation (assumption, characteristic, code, @@ -23,10 +23,8 @@ import Data.Drasil.TheoryConcepts (dataDefn, genDefn, inModel, thModel) import Drasil.GlassBR.Assumptions (assumpSV, assumpGL, assumptionConstants) import Drasil.GlassBR.Concepts (glass) -import Drasil.GlassBR.DataDefs (aspRat, dimLL, glaTyFac, hFromt, loadDF, nonFL, - risk, standOffDis, strDisFac, tolPre, tolStrDisFac) -import Drasil.GlassBR.IMods (iMods) -import Drasil.GlassBR.TMods (lrIsSafe, pbIsSafe) +import Drasil.GlassBR.DataDefs (aspRat, glaTyFac, hFromt, loadDF, standOffDis) +import Drasil.GlassBR.IMods (iMods, pbIsSafe, lrIsSafe) import Drasil.GlassBR.Unitals (blast, isSafeLR, isSafePb, loadSF, notSafe, pbTolfail, safeMessage) @@ -60,7 +58,7 @@ sysSetValsFollowingAssumpsTable :: LabelledContent sysSetValsFollowingAssumpsTable = mkValsSourceTable (mkQRTupleRef r2AQs r2ARs ++ mkQRTuple r2DDs) "ReqAssignments" (S "Required Assignments" `follows` sysSetValsFollowingAssumps) where - r2AQs = qw loadSF : map qw (take 4 assumptionConstants) + r2AQs = qw loadSF : map qw (take 4 assumptionConstants) r2ARs = assumpGL : replicate 4 assumpSV r2DDs = [loadDF, hFromt, glaTyFac, standOffDis, aspRat] @@ -90,7 +88,7 @@ outputValuesTable = mkValsSourceTable (mkQRTuple iMods ++ mkQRTuple r6DDs) "ReqO (S "Required" +:+ titleize' output_ `follows` outputValues) where r6DDs :: [DataDefinition] - r6DDs = [risk, strDisFac, nonFL, glaTyFac, dimLL, tolPre, tolStrDisFac, hFromt, aspRat] + r6DDs = [glaTyFac, hFromt, aspRat] {--Nonfunctional Requirements--} diff --git a/code/drasil-example/glassbr/lib/Drasil/GlassBR/Symbols.hs b/code/drasil-example/glassbr/lib/Drasil/GlassBR/Symbols.hs index e46a45fadd..f7e0629fb3 100644 --- a/code/drasil-example/glassbr/lib/Drasil/GlassBR/Symbols.hs +++ b/code/drasil-example/glassbr/lib/Drasil/GlassBR/Symbols.hs @@ -1,7 +1,10 @@ module Drasil.GlassBR.Symbols where +import Control.Lens ((^.)) + import Language.Drasil (QuantityDict, qw) import Language.Drasil.Code (Mod(Mod), asVC) +import Theory.Drasil (output) import Drasil.GlassBR.IMods (iMods) import Drasil.GlassBR.ModuleDefs (allMods, implVars) @@ -16,7 +19,7 @@ symbolsForTable = inputs ++ outputs ++ tmSymbols ++ map qw specParamVals ++ map qw inputDataConstraints ++ interps thisSymbols :: [QuantityDict] -thisSymbols = map qw iMods +thisSymbols = map (^. output) iMods -- include all module functions as symbols ++ (map asVC (concatMap (\(Mod _ _ _ _ l) -> l) allMods) \\ symbolsForTable) ++ map qw implVars ++ symbolsForTable diff --git a/code/drasil-example/glassbr/lib/Drasil/GlassBR/Unitals.hs b/code/drasil-example/glassbr/lib/Drasil/GlassBR/Unitals.hs index ae3c9c2474..5c2d57dc04 100644 --- a/code/drasil-example/glassbr/lib/Drasil/GlassBR/Unitals.hs +++ b/code/drasil-example/glassbr/lib/Drasil/GlassBR/Unitals.hs @@ -111,7 +111,7 @@ nomThick = cuc "nomThick" [{- TODO: add back constraint: enumc nominalThicknesses -}] $ exactDbl 8 glassTypeCon = constrainedNRV' (dqdNoUnit glassTy lG String) - [{- TODO: add back constraint: EnumeratedStr Software $ map (getAccStr . snd) glassType -}] + [{- TODO: add back constraint: EnumeratedStr Software $ map (abrv . snd) glassType -}] {--} diff --git a/code/drasil-example/hghc/lib/Drasil/HGHC/Body.hs b/code/drasil-example/hghc/lib/Drasil/HGHC/Body.hs index ca0319c604..f8d563851a 100644 --- a/code/drasil-example/hghc/lib/Drasil/HGHC/Body.hs +++ b/code/drasil-example/hghc/lib/Drasil/HGHC/Body.hs @@ -11,6 +11,7 @@ import Data.Drasil.SI_Units (siUnits, fundamentals, derived, degree) import Data.Drasil.People (spencerSmith) import Data.Drasil.Concepts.Documentation (doccon, doccon') import Data.Drasil.Concepts.Math (mathcon) +import Data.Drasil.Concepts.Thermodynamics as CT (heatTrans) import qualified Data.Drasil.Concepts.Documentation as Doc (srs) srs :: Document @@ -28,7 +29,7 @@ si = SI { _kind = Doc.srs, _authors = [spencerSmith], _quants = symbols, - _purpose = [], + _purpose = [purp], _background = [], _concepts = [] :: [UnitalChunk], _instModels = [], -- FIXME; empty _instModels @@ -57,6 +58,9 @@ mkSRS = [TableOfContents, , IMs [] [] HideDerivation ]]] +purp :: Sentence +purp = foldlSent [S "describes", phrase CT.heatTrans, S "coefficients related to clad"] + symbMap :: ChunkDB symbMap = cdb symbols (map nw symbols ++ map nw doccon ++ map nw fundamentals ++ map nw derived ++ [nw fp, nw nuclearPhys, nw hghc, nw degree] ++ map nw doccon' ++ map nw mathcon) diff --git a/code/drasil-example/nopcm/lib/Drasil/NoPCM/README.md b/code/drasil-example/nopcm/lib/Drasil/NoPCM/README.md deleted file mode 100644 index f2fc644347..0000000000 --- a/code/drasil-example/nopcm/lib/Drasil/NoPCM/README.md +++ /dev/null @@ -1,46 +0,0 @@ --------------------------------------------------- -### Summary of Folder Structure and File Contents -Last updated: August 20, 2019 --------------------------------------------------- - -Assumptions.hs - - NoPCM's assumptions - -Body.hs - - The main document body representation for the NoPCM example - -Changes.hs - - NoPCM's likely and unlikely changes - -DataDefs.hs - - NoPCM's data definitions - -DataDesc.hs - - NoPCM's input data - -Definitions.hs - - NoPCM's example-specific concepts - -GenDefs.hs - - NoPCM's general definitions - -Goals.hs - - NoPCM's goal statements - -IMods.hs - - NoPCM's instance models - -Main.hs - - A list of what should be generated - -README.md - - This file - -References.hs - - NoPCM's references - -Requirements.hs - - NoPCM's requirements - -Unitals.hs - - NoPCM's example-specific quantities diff --git a/code/drasil-example/pdcontroller/lib/Drasil/PDController/Concepts.hs b/code/drasil-example/pdcontroller/lib/Drasil/PDController/Concepts.hs index 3aef3072fd..6f5cf05f2f 100644 --- a/code/drasil-example/pdcontroller/lib/Drasil/PDController/Concepts.hs +++ b/code/drasil-example/pdcontroller/lib/Drasil/PDController/Concepts.hs @@ -15,11 +15,11 @@ pdControllerApp, pdControllerCI, proportionalCI, derivativeCI, integralCI, pidCI :: CI pdControllerApp = commonIdeaWithDict "pdControllerApp" (pn "PD Controller") "PD Controller" [] -pdControllerCI = commonIdeaWithDict "pdControllerCI" (pn "Proportional Derivative") "PD" [] -proportionalCI = commonIdeaWithDict "proportionalCI" (pn "Proportional") "P" [] -derivativeCI = commonIdeaWithDict "derivativeCI" (pn "Derivative") "D" [] -integralCI = commonIdeaWithDict "integralCI" (pn "Integral") "I" [] -pidCI = commonIdeaWithDict "pidCI" (pn "Proportional Integral Derivative") "PID" [] +pdControllerCI = commonIdeaWithDict "pdControllerCI" (pn "proportional derivative") "PD" [] +proportionalCI = commonIdeaWithDict "proportionalCI" (pn "proportional") "P" [] +derivativeCI = commonIdeaWithDict "derivativeCI" (pn "derivative") "D" [] +integralCI = commonIdeaWithDict "integralCI" (pn "integral") "I" [] +pidCI = commonIdeaWithDict "pidCI" (pn "proportional integral derivative") "PID" [] pidC, pidCL, summingPt, powerPlant, secondOrderSystem, processError, simulationTime, processVariable, setPoint, propGain, derGain, diff --git a/code/drasil-example/sglpendulum/app/Main.hs b/code/drasil-example/sglpend/app/Main.hs similarity index 70% rename from code/drasil-example/sglpendulum/app/Main.hs rename to code/drasil-example/sglpend/app/Main.hs index 72f40fd252..f69b143b18 100644 --- a/code/drasil-example/sglpendulum/app/Main.hs +++ b/code/drasil-example/sglpend/app/Main.hs @@ -4,7 +4,7 @@ import GHC.IO.Encoding import Language.Drasil.Generate (gen, typeCheckSI, genDot, genLog, DocSpec(DocSpec), DocType(SRS), Format(..), docChoices, dumpEverything) -import Drasil.SglPendulum.Body (srs, printSetting, fullSI) +import Drasil.SglPend.Body (srs, printSetting, fullSI) main :: IO() @@ -12,6 +12,6 @@ main = do setLocaleEncoding utf8 dumpEverything fullSI ".drasil/" typeCheckSI fullSI - gen (DocSpec (docChoices SRS [HTML, TeX, JSON]) "SglPendulum_SRS") srs printSetting + gen (DocSpec (docChoices SRS [HTML, TeX, JSON]) "SglPend_SRS") srs printSetting genDot fullSI genLog fullSI printSetting diff --git a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Body.hs b/code/drasil-example/sglpend/lib/Drasil/SglPend/Body.hs similarity index 86% rename from code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Body.hs rename to code/drasil-example/sglpend/lib/Drasil/SglPend/Body.hs index 2b90dae7e4..3c44fb9065 100644 --- a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Body.hs +++ b/code/drasil-example/sglpend/lib/Drasil/SglPend/Body.hs @@ -1,8 +1,10 @@ {-# LANGUAGE PostfixOperators #-} -module Drasil.SglPendulum.Body where +module Drasil.SglPend.Body where + +import Control.Lens ((^.)) import Language.Drasil hiding (organization, section) -import Theory.Drasil (TheoryModel) +import Theory.Drasil (TheoryModel, output) import Drasil.SRSDocument import qualified Drasil.DocLang.SRS as SRS import Language.Drasil.Chunk.Concept.NamedCombinators (the) @@ -15,7 +17,7 @@ import Data.Drasil.Concepts.Documentation (srsDomains, doccon, doccon') import qualified Data.Drasil.Concepts.Documentation as Doc (srs) import Data.Drasil.Concepts.Education (educon) import Data.Drasil.Concepts.Math (mathcon, mathcon') -import Data.Drasil.Concepts.Physics (physicCon, physicCon') +import Data.Drasil.Concepts.Physics (physicCon, physicCon', motion, pendulum) import Data.Drasil.Concepts.PhysicalProperties (mass, len, physicalcon) import Data.Drasil.Concepts.Software (program, errMsg) import Data.Drasil.Domains (physics) @@ -25,23 +27,23 @@ import Data.Drasil.TheoryConcepts (inModel) import Data.Drasil.Quantities.Math (unitVect, unitVectj) import Data.Drasil.Quantities.Physics (physicscon) -import Drasil.DblPendulum.Assumptions (assumpSingle) -import Drasil.DblPendulum.Body (justification, charsOfReader, purp, +import Drasil.DblPend.Assumptions (assumpSingle) +import Drasil.DblPend.Body (justification, charsOfReader, sysCtxIntro, sysCtxDesc, sysCtxList, stdFields, scope, terms, userCharacteristicsIntro) -import qualified Drasil.DblPendulum.Body as DPD (tMods) -import Drasil.DblPendulum.Concepts (concepts, rod) -import Drasil.DblPendulum.Requirements (nonFuncReqs) -import Drasil.DblPendulum.Unitals (acronyms) -import Drasil.DblPendulum.References (citations) - -import Drasil.SglPendulum.Figures (figMotion, sysCtxFig1) -import Drasil.SglPendulum.Goals (goals, goalsInputs) -import Drasil.SglPendulum.DataDefs (dataDefs) -import Drasil.SglPendulum.IMods (iMods) -import Drasil.SglPendulum.GenDefs (genDefns) -import Drasil.SglPendulum.Unitals (inputs, outputs, inConstraints, outConstraints, symbols) -import Drasil.SglPendulum.Requirements (funcReqs) +import qualified Drasil.DblPend.Body as DPD (tMods) +import Drasil.DblPend.Concepts (concepts, rod) +import Drasil.DblPend.Requirements (nonFuncReqs) +import Drasil.DblPend.Unitals (acronyms) +import Drasil.DblPend.References (citations) + +import Drasil.SglPend.Figures (figMotion, sysCtxFig1) +import Drasil.SglPend.Goals (goals, goalsInputs) +import Drasil.SglPend.DataDefs (dataDefs) +import Drasil.SglPend.IMods (iMods) +import Drasil.SglPend.GenDefs (genDefns) +import Drasil.SglPend.Unitals (inputs, outputs, inConstraints, outConstraints, symbols) +import Drasil.SglPend.Requirements (funcReqs) srs :: Document srs = mkDoc mkSRS (S.forGen titleize phrase) si @@ -62,15 +64,15 @@ mkSRS = [TableOfContents, -- This creates the Table of Contents , TAandA -- Add table of abbreviation and acronym section ], IntroSec $ - IntroProg justification (phrase progName) + IntroProg (justification progName) (phrase progName) [IPurpose $ purpDoc progName Verbose, IScope scope, IChar [] charsOfReader [], IOrgSec inModel (SRS.inModel [] []) EmptyS], GSDSec $ GSDProg [ - SysCntxt [sysCtxIntro, LlC sysCtxFig1, sysCtxDesc, sysCtxList], - UsrChars [userCharacteristicsIntro], + SysCntxt [sysCtxIntro progName, LlC sysCtxFig1, sysCtxDesc, sysCtxList progName], + UsrChars [userCharacteristicsIntro progName], SystCons [] []], SSDSec $ SSDProg @@ -100,15 +102,15 @@ mkSRS = [TableOfContents, -- This creates the Table of Contents ] progName :: CI -progName = commonIdeaWithDict "pendulumTitle" (pn "Pendulum") "SglPendulum" [physics] +progName = commonIdeaWithDict "sglPendulum" (pn "Single Pendulum") "SglPend" [physics] si :: SystemInformation si = SI { _sys = progName, _kind = Doc.srs, _authors = [olu], - _purpose = [], - _background = [purp], + _purpose = [purp], + _background = [], _quants = symbols, _concepts = [] :: [DefinedQuantityDict], _instModels = iMods, @@ -124,8 +126,11 @@ si = SI { refdb = refDB } +purp :: Sentence +purp = foldlSent_ [S "predict the", phrase motion `S.ofA` S "single", phrase pendulum] + symbMap :: ChunkDB -symbMap = cdb (map qw iMods ++ map qw symbols) +symbMap = cdb (map (^. output) iMods ++ map qw symbols) (nw newtonSLR : nw progName : nw mass : nw len : nw kilogram : nw inValue : nw newton : nw degree : nw radian : nw unitVect : nw unitVectj : [nw errMsg, nw program] ++ map nw symbols ++ map nw doccon ++ map nw doccon' ++ map nw physicCon ++ map nw mathcon ++ map nw mathcon' ++ map nw physicCon' ++ @@ -135,7 +140,7 @@ symbMap = cdb (map qw iMods ++ map qw symbols) iMods genDefns tMods concIns [] [] ([] :: [Reference]) usedDB :: ChunkDB -usedDB = cdb ([] :: [QuantityDict]) (map nw acronyms ++ map nw symbols) ([] :: [ConceptChunk]) +usedDB = cdb ([] :: [QuantityDict]) (nw progName : map nw acronyms ++ map nw symbols) ([] :: [ConceptChunk]) ([] :: [UnitDefn]) [] [] [] [] [] [] [] ([] :: [Reference]) refDB :: ReferenceDB diff --git a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/DataDefs.hs b/code/drasil-example/sglpend/lib/Drasil/SglPend/DataDefs.hs similarity index 91% rename from code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/DataDefs.hs rename to code/drasil-example/sglpend/lib/Drasil/SglPend/DataDefs.hs index 3a31947264..cfc6b3b0f2 100644 --- a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/DataDefs.hs +++ b/code/drasil-example/sglpend/lib/Drasil/SglPend/DataDefs.hs @@ -1,4 +1,4 @@ -module Drasil.SglPendulum.DataDefs (dataDefs, positionIY, positionIX, angFrequencyDD, +module Drasil.SglPend.DataDefs (dataDefs, positionIY, positionIX, angFrequencyDD, frequencyDD, periodSHMDD) where import Prelude hiding (sin, cos, sqrt) @@ -6,13 +6,13 @@ import Language.Drasil import qualified Language.Drasil.Sentence.Combinators as S import Data.Drasil.SI_Units (second) import Theory.Drasil (DataDefinition, ddENoRefs) -import Drasil.SglPendulum.Figures (figMotion) +import Drasil.SglPend.Figures (figMotion) import qualified Data.Drasil.Quantities.Physics as QP (ixPos, iyPos, frequency, period, angularFrequency) -import Drasil.SglPendulum.Unitals (lenRod, initialPendAngle) +import Drasil.SglPend.Unitals (lenRod, initialPendAngle) --import Data.Drasil.Concepts.Physics (pendulum) import qualified Data.Drasil.Quantities.Math as QM (pi_) -import Drasil.DblPendulum.Concepts (horizontalPos, verticalPos) +import Drasil.DblPend.Concepts (horizontalPos, verticalPos) dataDefs :: [DataDefinition] diff --git a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Derivations.hs b/code/drasil-example/sglpend/lib/Drasil/SglPend/Derivations.hs similarity index 97% rename from code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Derivations.hs rename to code/drasil-example/sglpend/lib/Drasil/SglPend/Derivations.hs index bba2f22711..7bdbb901be 100644 --- a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Derivations.hs +++ b/code/drasil-example/sglpend/lib/Drasil/SglPend/Derivations.hs @@ -1,4 +1,4 @@ -module Drasil.SglPendulum.Derivations where +module Drasil.SglPend.Derivations where import Prelude hiding (sin, cos, tan, sqrt) @@ -9,7 +9,7 @@ import Data.Drasil.Quantities.Physics (acceleration, angularAccel, angularFreque torque, velocity, xAccel, xPos, xVel, yAccel, yPos, yVel) import Data.Drasil.Quantities.PhysicalProperties (mass) import qualified Data.Drasil.Quantities.Math as QM (pi_) -import Drasil.SglPendulum.Unitals (lenRod, pendDisplacementAngle, initialPendAngle) +import Drasil.SglPend.Unitals (lenRod, pendDisplacementAngle, initialPendAngle) -- Velocity IX/IY velocityIDerivEqn1, velocityIXDerivEqn2, velocityIXDerivEqn3, velocityIXDerivEqn4 :: ModelExpr diff --git a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Expressions.hs b/code/drasil-example/sglpend/lib/Drasil/SglPend/Expressions.hs similarity index 94% rename from code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Expressions.hs rename to code/drasil-example/sglpend/lib/Drasil/SglPend/Expressions.hs index 3e2ec5ebbf..515dbadefa 100644 --- a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Expressions.hs +++ b/code/drasil-example/sglpend/lib/Drasil/SglPend/Expressions.hs @@ -1,4 +1,4 @@ -module Drasil.SglPendulum.Expressions where +module Drasil.SglPend.Expressions where import Prelude hiding (sin, cos, sqrt) import Language.Drasil @@ -7,7 +7,7 @@ import Data.Drasil.Quantities.Physics (angularAccel, angularFrequency, angularVe gravitationalAccel, tension, time, xAccel, yAccel) import Data.Drasil.Quantities.PhysicalProperties (mass) import qualified Data.Drasil.Quantities.Math as QM (pi_) -import Drasil.SglPendulum.Unitals (lenRod, pendDisplacementAngle, initialPendAngle) +import Drasil.SglPend.Unitals (lenRod, pendDisplacementAngle, initialPendAngle) -- Velocity IX/IY velocityIXExpr, velocityIYExpr :: Expr diff --git a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Figures.hs b/code/drasil-example/sglpend/lib/Drasil/SglPend/Figures.hs similarity index 58% rename from code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Figures.hs rename to code/drasil-example/sglpend/lib/Drasil/SglPend/Figures.hs index dce31cb37b..5a8b4f4e48 100644 --- a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Figures.hs +++ b/code/drasil-example/sglpend/lib/Drasil/SglPend/Figures.hs @@ -1,4 +1,4 @@ -module Drasil.SglPendulum.Figures (figMotion, sysCtxFig1) where +module Drasil.SglPend.Figures (figMotion, sysCtxFig1) where import Language.Drasil import Language.Drasil.Chunk.Concept.NamedCombinators @@ -6,11 +6,11 @@ import Language.Drasil.Chunk.Concept.NamedCombinators import Data.Drasil.Concepts.Documentation (physicalSystem, sysCont) resourcePath :: String -resourcePath = "../../../../datafiles/sglpendulum/" +resourcePath = "../../../../datafiles/sglpend/" figMotion :: LabelledContent -figMotion = llcc (makeFigRef "sglpendulum") $ figWithWidth (atStartNP (the physicalSystem)) - (resourcePath ++ "sglpendulum.jpg") 70 +figMotion = llcc (makeFigRef "sglpend") $ figWithWidth (atStartNP (the physicalSystem)) + (resourcePath ++ "sglpend.jpg") 70 sysCtxFig1 :: LabelledContent sysCtxFig1 = llcc (makeFigRef "sysCtxDiag") $ fig (titleize sysCont) diff --git a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/GenDefs.hs b/code/drasil-example/sglpend/lib/Drasil/SglPend/GenDefs.hs similarity index 96% rename from code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/GenDefs.hs rename to code/drasil-example/sglpend/lib/Drasil/SglPend/GenDefs.hs index ab152f8882..d91291526b 100644 --- a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/GenDefs.hs +++ b/code/drasil-example/sglpend/lib/Drasil/SglPend/GenDefs.hs @@ -1,5 +1,5 @@ {-# LANGUAGE PostfixOperators #-} -module Drasil.SglPendulum.GenDefs (genDefns, velocityIXGD, velocityIYGD, +module Drasil.SglPend.GenDefs (genDefns, velocityIXGD, velocityIYGD, accelerationIXGD, accelerationIYGD, hForceOnPendulumGD, vForceOnPendulumGD, angFrequencyGD, periodPend) where @@ -23,13 +23,13 @@ import Data.Drasil.Quantities.Physics (velocity, acceleration, force, import Data.Drasil.Concepts.Physics (pendulum, weight, shm) import Data.Drasil.Quantities.PhysicalProperties (mass, len) import Data.Drasil.Theories.Physics (newtonSLR) -import Drasil.SglPendulum.DataDefs (frequencyDD, periodSHMDD, angFrequencyDD) +import Drasil.SglPend.DataDefs (frequencyDD, periodSHMDD, angFrequencyDD) -- import Drasil.Projectile.Assumptions (cartSyst, constAccel, pointMass, timeStartZero, twoDMotion) -import qualified Drasil.SglPendulum.Derivations as D -import qualified Drasil.SglPendulum.Expressions as E -import Drasil.SglPendulum.Unitals (lenRod, pendDisplacementAngle) -import Drasil.DblPendulum.Concepts (arcLen, horizontalPos, +import qualified Drasil.SglPend.Derivations as D +import qualified Drasil.SglPend.Expressions as E +import Drasil.SglPend.Unitals (lenRod, pendDisplacementAngle) +import Drasil.DblPend.Concepts (arcLen, horizontalPos, verticalPos, horizontalVel, verticalVel, horizontalForce, verticalForce) genDefns :: [GenDefn] diff --git a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Goals.hs b/code/drasil-example/sglpend/lib/Drasil/SglPend/Goals.hs similarity index 89% rename from code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Goals.hs rename to code/drasil-example/sglpend/lib/Drasil/SglPend/Goals.hs index 90e30e266e..8f15c18e8c 100644 --- a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Goals.hs +++ b/code/drasil-example/sglpend/lib/Drasil/SglPend/Goals.hs @@ -1,5 +1,5 @@ {-# LANGUAGE PostfixOperators#-} - module Drasil.SglPendulum.Goals (goals, goalsInputs) where + module Drasil.SglPend.Goals (goals, goalsInputs) where import Language.Drasil import Language.Drasil.Chunk.Concept.NamedCombinators @@ -10,7 +10,7 @@ import qualified Data.Drasil.Concepts.PhysicalProperties as CPP (mass, len) import Data.Drasil.Concepts.Physics (gravitationalConst, motion) import Data.Drasil.Concepts.Math (iAngle) - import Drasil.DblPendulum.Concepts (rod) + import Drasil.DblPend.Concepts (rod) goals :: [ConceptInstance] diff --git a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/IMods.hs b/code/drasil-example/sglpend/lib/Drasil/SglPend/IMods.hs similarity index 91% rename from code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/IMods.hs rename to code/drasil-example/sglpend/lib/Drasil/SglPend/IMods.hs index da8301d52d..2bbeb59e8e 100644 --- a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/IMods.hs +++ b/code/drasil-example/sglpend/lib/Drasil/SglPend/IMods.hs @@ -1,5 +1,5 @@ {-# LANGUAGE PostfixOperators #-} -module Drasil.SglPendulum.IMods (iMods, angularDisplacementIM) where +module Drasil.SglPend.IMods (iMods, angularDisplacementIM) where import Prelude hiding (cos, sin) @@ -15,11 +15,11 @@ import Data.Drasil.Quantities.Physics (gravitationalAccel, import Data.Drasil.Concepts.Math (constraint, equation, amplitude, iAngle, angle) import Data.Drasil.Concepts.Physics (pendulum, motion, shm) import Data.Drasil.Theories.Physics (newtonSLR) -import Drasil.SglPendulum.GenDefs (angFrequencyGD) +import Drasil.SglPend.GenDefs (angFrequencyGD) -import Drasil.SglPendulum.Derivations (angularDisplacementDerivEqns) -import Drasil.SglPendulum.Expressions (angularDisplacementExpr) -import Drasil.SglPendulum.Unitals (lenRod, pendDisplacementAngle, initialPendAngle) +import Drasil.SglPend.Derivations (angularDisplacementDerivEqns) +import Drasil.SglPend.Expressions (angularDisplacementExpr) +import Drasil.SglPend.Unitals (lenRod, pendDisplacementAngle, initialPendAngle) iMods :: [InstanceModel] iMods = [angularDisplacementIM] diff --git a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/README.md b/code/drasil-example/sglpend/lib/Drasil/SglPend/README.md similarity index 100% rename from code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/README.md rename to code/drasil-example/sglpend/lib/Drasil/SglPend/README.md diff --git a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Requirements.hs b/code/drasil-example/sglpend/lib/Drasil/SglPend/Requirements.hs similarity index 81% rename from code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Requirements.hs rename to code/drasil-example/sglpend/lib/Drasil/SglPend/Requirements.hs index d0480486d9..6c8ef25865 100644 --- a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Requirements.hs +++ b/code/drasil-example/sglpend/lib/Drasil/SglPend/Requirements.hs @@ -1,12 +1,12 @@ -module Drasil.SglPendulum.Requirements where +module Drasil.SglPend.Requirements where import Language.Drasil import qualified Language.Drasil.Sentence.Combinators as S import Data.Drasil.Concepts.Documentation (funcReqDom, output_, value) -import Drasil.SglPendulum.IMods (angularDisplacementIM) -import Drasil.SglPendulum.Unitals (lenRod, pendDisplacementAngle) +import Drasil.SglPend.IMods (angularDisplacementIM) +import Drasil.SglPend.Unitals (lenRod, pendDisplacementAngle) import Data.Drasil.Quantities.Physics (angularDisplacement) -import Drasil.DblPendulum.Requirements(verifyInptValsDesc) +import Drasil.DblPend.Requirements(verifyInptValsDesc) --Functional Requirements-- funcReqs :: [ConceptInstance] diff --git a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Unitals.hs b/code/drasil-example/sglpend/lib/Drasil/SglPend/Unitals.hs similarity index 96% rename from code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Unitals.hs rename to code/drasil-example/sglpend/lib/Drasil/SglPend/Unitals.hs index a8e2f95455..6190aae667 100644 --- a/code/drasil-example/sglpendulum/lib/Drasil/SglPendulum/Unitals.hs +++ b/code/drasil-example/sglpend/lib/Drasil/SglPend/Unitals.hs @@ -1,4 +1,4 @@ -module Drasil.SglPendulum.Unitals where +module Drasil.SglPend.Unitals where import Language.Drasil import Language.Drasil.ShortHands @@ -14,8 +14,8 @@ import qualified Data.Drasil.Quantities.Physics as QP (position, ixPos, xPos, fo import Data.Drasil.Concepts.Physics (pendulum) import Data.Drasil.Concepts.Math as CM (angle, iAngle) import Data.Drasil.Quantities.Math as QM (unitVect, unitVectj, pi_) -import Drasil.DblPendulum.Concepts (rod) -import Drasil.DblPendulum.Unitals (lRod) +import Drasil.DblPend.Concepts (rod) +import Drasil.DblPend.Unitals (lRod) symbols:: [QuantityDict] diff --git a/code/drasil-example/dblpendulum/package.yaml b/code/drasil-example/sglpend/package.yaml similarity index 87% rename from code/drasil-example/dblpendulum/package.yaml rename to code/drasil-example/sglpend/package.yaml index 35498b0fe8..43e48ab7d6 100644 --- a/code/drasil-example/dblpendulum/package.yaml +++ b/code/drasil-example/sglpend/package.yaml @@ -1,4 +1,4 @@ -name: dblpendulum +name: sglpend version: 0.1.24.0 author: "Dan Szymczak, Steven Palmer, Jacques Carette, Spencer Smith" maintainer: "Jacques Carette" @@ -24,15 +24,16 @@ dependencies: - drasil-printers - drasil-theory - drasil-utils +- dblpend library: source-dirs: lib when: - condition: false - other-modules: Paths_dblpendulum + other-modules: Paths_sglpend executables: - dblpendulum: + sglpend: main: Main source-dirs: app ghc-options: @@ -41,7 +42,7 @@ executables: - -threaded - -O2 dependencies: - - dblpendulum + - sglpend when: - condition: false - other-modules: Paths_dblpendulum + other-modules: Paths_sglpend diff --git a/code/drasil-example/sglpendulum/stack.yaml b/code/drasil-example/sglpend/stack.yaml similarity index 100% rename from code/drasil-example/sglpendulum/stack.yaml rename to code/drasil-example/sglpend/stack.yaml diff --git a/code/drasil-example/ssp/lib/Drasil/SSP/Body.hs b/code/drasil-example/ssp/lib/Drasil/SSP/Body.hs index 5b1077bd0e..57de07520f 100644 --- a/code/drasil-example/ssp/lib/Drasil/SSP/Body.hs +++ b/code/drasil-example/ssp/lib/Drasil/SSP/Body.hs @@ -1,11 +1,13 @@ {-# LANGUAGE PostfixOperators #-} module Drasil.SSP.Body (srs, si, symbMap, printSetting, fullSI) where +import Control.Lens ((^.)) + import Language.Drasil hiding (Verb, number, organization, section, variable) import Drasil.SRSDocument import qualified Drasil.DocLang.SRS as SRS (inModel, assumpt, genDefn, dataDefn, datCon) -import Theory.Drasil (qdEFromDD) +import Theory.Drasil (qdEFromDD, output) import Prelude hiding (sin, cos, tan) import Data.Maybe (mapMaybe) @@ -155,7 +157,7 @@ stdFields = [DefiningEquation, Description Verbose IncludeUnits, Notes, Source, -- SYMBOL MAP HELPERS -- symbMap :: ChunkDB -symbMap = cdb (map qw SSP.iMods ++ map qw symbols) (map nw symbols +symbMap = cdb (map (^. output) SSP.iMods ++ map qw symbols) (map nw symbols ++ map nw acronyms ++ map nw doccon ++ map nw prodtcon ++ map nw generalDefinitions ++ map nw SSP.iMods ++ map nw defs ++ map nw defs' ++ map nw softwarecon ++ map nw physicCon ++ map nw physicsTMs diff --git a/code/drasil-example/ssp/lib/Drasil/SSP/Requirements.hs b/code/drasil-example/ssp/lib/Drasil/SSP/Requirements.hs index 5809c9f67e..973cbaac09 100644 --- a/code/drasil-example/ssp/lib/Drasil/SSP/Requirements.hs +++ b/code/drasil-example/ssp/lib/Drasil/SSP/Requirements.hs @@ -102,7 +102,8 @@ inputsToOutput = constF : map dqdWr [xMaxExtSlip, xMaxEtrSlip, xMinExtSlip, inputsToOutputTable :: LabelledContent inputsToOutputTable = llcc (makeTabRef "inputsToOutputTable") $ Table [titleize symbol_, titleize name_] (mkTable [ch, phrase] inputsToOutput) - (atStart' input_ +:+ S "to be returned as" +:+ phrase output_) True + (atStart' input_ +:+ S "to be Returned as" +:+ titleize output_ `follows` + displayInput) True {-Nonfunctional Requirements-} nonFuncReqs :: [ConceptInstance] diff --git a/code/drasil-example/ssp/lib/Drasil/SSP/Unitals.hs b/code/drasil-example/ssp/lib/Drasil/SSP/Unitals.hs index b3909a5b70..dc05ebcfbb 100644 --- a/code/drasil-example/ssp/lib/Drasil/SSP/Unitals.hs +++ b/code/drasil-example/ssp/lib/Drasil/SSP/Unitals.hs @@ -27,8 +27,8 @@ import Data.Drasil.Quantities.Physics (acceleration, displacement, distance, symbols :: [DefinedQuantityDict] -symbols = map dqdWr inputs ++ map dqdWr outputs ++ - map dqdWr units ++ map dqdWr unitless +symbols = dqdWr coords : map dqdWr inputs ++ map dqdWr outputs + ++ map dqdWr units ++ map dqdWr unitless --------------------------- -- Imported UnitalChunks -- @@ -66,7 +66,7 @@ wiif = "without the influence of interslice forces" -------------------------------- constrained :: [ConstrainedChunk] -constrained = map cnstrw inputsWUncrtn ++ map cnstrw outputs +constrained = cnstrw coords : map cnstrw inputsWUncrtn ++ map cnstrw outputs inputsWUncrtn :: [UncertQ] inputsWUncrtn = [slopeDist, slopeHght, waterDist, waterHght, xMaxExtSlip, @@ -80,7 +80,7 @@ inputs :: [DefinedQuantityDict] inputs = map dqdWr inputsWUncrtn ++ map dqdWr inputsNoUncrtn outputs :: [ConstrConcept] -outputs = [fs, coords] +outputs = [fs] {- monotonicIn :: [Constraint] --FIXME: Move this? diff --git a/code/drasil-example/swhs/lib/Drasil/SWHS/Body.hs b/code/drasil-example/swhs/lib/Drasil/SWHS/Body.hs index e45434f801..a47f745bd0 100755 --- a/code/drasil-example/swhs/lib/Drasil/SWHS/Body.hs +++ b/code/drasil-example/swhs/lib/Drasil/SWHS/Body.hs @@ -6,7 +6,7 @@ import Control.Lens ((^.)) import Language.Drasil hiding (organization, section, variable) import Drasil.SRSDocument import qualified Drasil.DocLang.SRS as SRS (inModel) -import Theory.Drasil (GenDefn, InstanceModel) +import Theory.Drasil (GenDefn, InstanceModel, output) import Language.Drasil.Chunk.Concept.NamedCombinators import qualified Language.Drasil.NounPhrase.Combinators as NP import qualified Language.Drasil.Sentence.Combinators as S @@ -101,7 +101,7 @@ purp = foldlSent_ [S "investigate the effect" `S.of_` S "employing", short phsChgMtrl, S "within a", phrase sWHT] symbMap :: ChunkDB -symbMap = cdb (qw heatEInPCM : symbolsAll) -- heatEInPCM ? +symbMap = cdb (qw (heatEInPCM ^. output) : symbolsAll) -- heatEInPCM ? (nw heatEInPCM : map nw symbols ++ map nw acronymsFull ++ map nw thermocon ++ map nw units ++ map nw [m_2, m_3] ++ map nw [absTol, relTol] ++ map nw physicscon ++ map nw doccon ++ map nw softwarecon ++ map nw doccon' ++ map nw con @@ -132,7 +132,7 @@ mkSRS = [TableOfContents, IOrgSec inModel (SRS.inModel [] []) orgDocEnd ], GSDSec $ GSDProg - [ SysCntxt [sysCntxtDesc progName, LlC sysCntxtFig, sysCntxtRespIntro progName, systContRespBullets] + [ SysCntxt [sysCntxtDesc progName, LlC sysCntxtFig, sysCntxtRespIntro progName, systContRespBullets progName] , UsrChars [userChars progName] , SystCons [] [] ], @@ -307,9 +307,9 @@ sysCntxtRespIntro pro = foldlSPCol [short pro +:+. S "is mostly self-contained", S "interface", S "responsibilities" `S.the_ofTheC` phraseNP (user `andThe` system) `S.are` S "as follows"] -systContRespBullets :: Contents -systContRespBullets = UlC $ ulcc $ Enumeration $ bulletNested - [titleize user +: S "Responsibilities", short progName +: S "Responsibilities"] +systContRespBullets :: CI -> Contents +systContRespBullets prog = UlC $ ulcc $ Enumeration $ bulletNested + [titleize user +: S "Responsibilities", short prog +: S "Responsibilities"] $ map bulletFlat [userResp, swhsResp] userResp :: [Sentence] diff --git a/code/drasil-example/swhs/lib/Drasil/SWHS/Concepts.hs b/code/drasil-example/swhs/lib/Drasil/SWHS/Concepts.hs index 5619827193..3622d73709 100644 --- a/code/drasil-example/swhs/lib/Drasil/SWHS/Concepts.hs +++ b/code/drasil-example/swhs/lib/Drasil/SWHS/Concepts.hs @@ -19,10 +19,10 @@ con = [charging, coil, discharging, gaussDiv, ---Acronyms--- acronyms :: [CI] acronyms = [assumption, dataDefn, genDefn, goalStmt, inModel, likelyChg, ode, - progName, physSyst, requirement, refBy, refName, srs, thModel, typUnc, unlikelyChg] + physSyst, requirement, refBy, refName, srs, thModel, typUnc, unlikelyChg] acronymsFull :: [CI] -acronymsFull = acronyms ++ [phsChgMtrl, rightSide] +acronymsFull = acronyms ++ [phsChgMtrl, rightSide, progName] phsChgMtrl, progName :: CI diff --git a/code/drasil-example/swhs/lib/Drasil/SWHS/Requirements.hs b/code/drasil-example/swhs/lib/Drasil/SWHS/Requirements.hs index 1e3b3d83f8..6a6309bb02 100644 --- a/code/drasil-example/swhs/lib/Drasil/SWHS/Requirements.hs +++ b/code/drasil-example/swhs/lib/Drasil/SWHS/Requirements.hs @@ -4,6 +4,7 @@ import Language.Drasil import Language.Drasil.Chunk.Concept.NamedCombinators import qualified Language.Drasil.NounPhrase.Combinators as NP import qualified Language.Drasil.Sentence.Combinators as S +import Theory.Drasil (InstanceModel, HasOutput(output)) import Drasil.DocLang (inReq) import Drasil.DocLang.SRS (datCon, propCorSol) @@ -11,8 +12,8 @@ import Drasil.DocLang.SRS (datCon, propCorSol) import Data.Drasil.Concepts.Computation (inValue) import Data.Drasil.Concepts.Documentation (assumption, code, condition, funcReqDom, input_, likelyChg, mg, mis, module_, nonFuncReqDom, output_, - physicalConstraint, property, requirement, simulation, srs, traceyMatrix, - unlikelyChg, value, vavPlan, propOfCorSol) + physicalConstraint, property, propOfCorSol, requirement, srs, traceyMatrix, + unlikelyChg, value, vavPlan) import Data.Drasil.Concepts.Math (parameter) import Data.Drasil.Concepts.PhysicalProperties (materialProprty) import Data.Drasil.Concepts.Thermodynamics as CT (lawConsEnergy, melting) @@ -27,8 +28,9 @@ import Drasil.SWHS.DataDefs (waterMass, waterVolume, tankVolume, import Drasil.SWHS.Concepts (phsChgMtrl, tank) import Drasil.SWHS.IMods (eBalanceOnWtr, eBalanceOnPCM, heatEInWtr, heatEInPCM, iMods) -import Drasil.SWHS.Unitals (consTol, pcmE, tFinalMelt, tInitMelt, tempPCM, - tempW, watE) +import Drasil.SWHS.Unitals (consTol, pcmE, tFinalMelt, tInitMelt, watE) + +import Control.Lens ((^.)) ------------------------------ -- Data Constraint: Table 1 -- @@ -47,12 +49,13 @@ inReqDesc = foldlList Comma List [pluralNP (NP.the (combineNINI tank parameter)) funcReqs :: [ConceptInstance] funcReqs = [findMass, checkWithPhysConsts, outputInputDerivVals, - calcTempWtrOverTime, calcTempPCMOverTime, calcChgHeatEnergyWtrOverTime, - calcChgHeatEnergyPCMOverTime, verifyEnergyOutput, calcPCMMeltBegin, calcPCMMeltEnd] + calcValues swhsOutputs, verifyEnergyOutput, calcPCMMeltBegin, calcPCMMeltEnd, + outputValues swhsOutputs] + +findMass, checkWithPhysConsts, outputInputDerivVals, verifyEnergyOutput, + calcPCMMeltBegin, calcPCMMeltEnd :: ConceptInstance -findMass, checkWithPhysConsts, outputInputDerivVals, calcTempWtrOverTime, - calcTempPCMOverTime, calcChgHeatEnergyWtrOverTime, calcChgHeatEnergyPCMOverTime, - verifyEnergyOutput, calcPCMMeltBegin, calcPCMMeltEnd :: ConceptInstance +calcValues, outputValues :: [InstanceModel] -> ConceptInstance -- findMass = findMassConstruct (inReq EmptyS) (plural mass) iMods @@ -83,36 +86,15 @@ oIDQVals :: [Sentence] oIDQVals = map foldlSent_ [ [pluralNP (the value), fromSource (inReq EmptyS)], [pluralNP (the mass), fromSource findMass], - [ch balanceDecayRate, fromSource balanceDecayRate], - [ch balanceDecayTime, fromSource balanceDecayTime], - [ch balanceSolidPCM, fromSource balanceSolidPCM], - [ch balanceLiquidPCM, fromSource balanceLiquidPCM] + [ch (balanceDecayRate ^. defLhs), fromSource balanceDecayRate], + [ch (balanceDecayTime ^. defLhs), fromSource balanceDecayTime], + [ch (balanceSolidPCM ^. defLhs), fromSource balanceSolidPCM], + [ch (balanceLiquidPCM ^. defLhs), fromSource balanceLiquidPCM] ] - --- -calcTempWtrOverTime = cic "calcTempWtrOverTime" (foldlSent [ - S "Calculate and", phrase output_, phraseNP (the tempW), - sParen (ch tempW :+: sParen (ch time)), S "over the", - phrase simulation, phrase time, fromSource eBalanceOnWtr]) - "Calculate-Temperature-Water-Over-Time" funcReqDom --- -calcTempPCMOverTime = cic "calcTempPCMOverTime" (foldlSent [ - S "Calculate and", phrase output_, phraseNP (the tempPCM), - sParen (ch tempPCM :+: sParen (ch time)), S "over", - phraseNP (NP.the (combineNINI simulation time)), fromSource eBalanceOnPCM]) - "Calculate-Temperature-PCM-Over-Time" funcReqDom --- -calcChgHeatEnergyWtrOverTime = cic "calcChgHeatEnergyWtrOverTime" (foldlSent [ - S "Calculate and", phrase output_, phraseNP (the watE), - sParen (ch watE :+: sParen (ch time)), S "over", - phraseNP (NP.the (combineNINI simulation time)), fromSource heatEInWtr]) - "Calculate-Change-Heat_Energy-Water-Over-Time" funcReqDom + -- -calcChgHeatEnergyPCMOverTime = cic "calcChgHeatEnergyPCMOverTime" (foldlSent [ - S "Calculate and", phrase output_, phraseNP (the pcmE), - sParen (ch pcmE :+: sParen (ch time)), S "over", - phraseNP (NP.the (combineNINI simulation time)), fromSource heatEInPCM]) - "Calculate-Change-Heat_Energy-PCM-Over-Time" funcReqDom +calcValues l = cic "calcValues" (S "Calculate the following" +: plural value +:+. + outputList l) "Calculate-Values" funcReqDom -- verifyEnergyOutput = cic "verifyEnergyOutput" (foldlSent [ S "Verify that the", phrase energy, plural output_, @@ -133,6 +115,16 @@ calcPCMMeltEnd = cic "calcPCMMeltEnd" (foldlSent [ S "at which the", short phsChgMtrl, S "stops", phrase CT.melting, ch tFinalMelt, fromSource eBalanceOnPCM]) "Calculate-PCM-Melt-End-Time" funcReqDom +-- +outputValues l = cic "outputValues" (titleize output_ +:+. outputList l) + "Output-Values" funcReqDom + +outputList :: [InstanceModel] -> Sentence +outputList l = foldlList Comma List $ + map (\x -> ch (x ^. output) :+: sParen (ch time) +:+ fromSource x) l + +swhsOutputs :: [InstanceModel] +swhsOutputs = [eBalanceOnWtr, eBalanceOnPCM, heatEInWtr, heatEInPCM] -- List structure same between all examples diff --git a/code/drasil-example/nopcm/app/Main.hs b/code/drasil-example/swhsnopcm/app/Main.hs similarity index 67% rename from code/drasil-example/nopcm/app/Main.hs rename to code/drasil-example/swhsnopcm/app/Main.hs index c73680ebd3..fad46b0455 100644 --- a/code/drasil-example/nopcm/app/Main.hs +++ b/code/drasil-example/swhsnopcm/app/Main.hs @@ -3,15 +3,15 @@ module Main (main) where import GHC.IO.Encoding import Language.Drasil.Generate (gen, typeCheckSI, genCode, genDot, genLog, DocSpec(DocSpec), DocType(SRS), Format(..), docChoices, dumpEverything) -import Drasil.NoPCM.Body (srs, printSetting, fullSI) -import Drasil.NoPCM.Choices (choices, code) +import Drasil.SWHSNoPCM.Body (srs, printSetting, fullSI) +import Drasil.SWHSNoPCM.Choices (choices, code) main :: IO () main = do setLocaleEncoding utf8 dumpEverything fullSI ".drasil/" typeCheckSI fullSI - gen (DocSpec (docChoices SRS [HTML, TeX, JSON]) "NoPCM_SRS") srs printSetting + gen (DocSpec (docChoices SRS [HTML, TeX, JSON]) "SWHSNoPCM_SRS") srs printSetting genCode choices code genDot fullSI genLog fullSI printSetting diff --git a/code/drasil-example/nopcm/lib/Drasil/NoPCM/Assumptions.hs b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Assumptions.hs similarity index 97% rename from code/drasil-example/nopcm/lib/Drasil/NoPCM/Assumptions.hs rename to code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Assumptions.hs index b9ed5934ec..27227f6305 100644 --- a/code/drasil-example/nopcm/lib/Drasil/NoPCM/Assumptions.hs +++ b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Assumptions.hs @@ -1,5 +1,5 @@ {-# LANGUAGE PostfixOperators #-} -module Drasil.NoPCM.Assumptions where --all of this file is exported +module Drasil.SWHSNoPCM.Assumptions where --all of this file is exported import Language.Drasil import Language.Drasil.Chunk.Concept.NamedCombinators diff --git a/code/drasil-example/nopcm/lib/Drasil/NoPCM/Body.hs b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Body.hs similarity index 86% rename from code/drasil-example/nopcm/lib/Drasil/NoPCM/Body.hs rename to code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Body.hs index fe392e4625..933d911cf2 100644 --- a/code/drasil-example/nopcm/lib/Drasil/NoPCM/Body.hs +++ b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Body.hs @@ -1,4 +1,4 @@ -module Drasil.NoPCM.Body (si, srs, printSetting, noPCMODEInfo, fullSI) where +module Drasil.SWHSNoPCM.Body (si, srs, printSetting, noPCMODEInfo, fullSI) where import Language.Drasil hiding (section) import Drasil.SRSDocument @@ -13,7 +13,7 @@ import Data.List ((\\)) import Data.Drasil.People (thulasi) import Data.Drasil.Concepts.Computation (algorithm, inValue) -import Data.Drasil.Concepts.Documentation as Doc (doccon, doccon', material_, srsDomains) +import Data.Drasil.Concepts.Documentation as Doc (doccon, doccon', material_, srsDomains, sysCont) import qualified Data.Drasil.Concepts.Documentation as Doc (srs) import Data.Drasil.TheoryConcepts as Doc (inModel) import Data.Drasil.Concepts.Education (educon) @@ -34,6 +34,7 @@ import Data.Drasil.Quantities.Math (gradient, pi_, piConst, surface, import Data.Drasil.Quantities.PhysicalProperties (vol, mass, density) import Data.Drasil.Quantities.Physics (time, energy, physicscon) import Data.Drasil.Software.Products (prodtcon) +import Data.Drasil.Domains (materialEng) import Data.Drasil.SI_Units (metre, kilogram, second, centigrade, joule, watt, fundamentals, derived) @@ -41,10 +42,10 @@ import Data.Drasil.SI_Units (metre, kilogram, second, centigrade, joule, watt, -- of the SWHS libraries. If the source for something cannot be found in -- NoPCM, check SWHS. import Drasil.SWHS.Body (charsOfReader, dataContMid, introEnd, introStart, - physSyst1, physSyst2, sysCntxtDesc, sysCntxtFig, systContRespBullets, + physSyst1, physSyst2, sysCntxtDesc, systContRespBullets, sysCntxtRespIntro, userChars) import Drasil.SWHS.Changes (likeChgTCVOD, likeChgTCVOL, likeChgTLH) -import Drasil.SWHS.Concepts (acronyms, coil, progName, sWHT, tank, transient, water, con, phsChgMtrl) +import Drasil.SWHS.Concepts (acronyms, coil, sWHT, tank, transient, water, con, phsChgMtrl) import Drasil.SWHS.Requirements (nfRequirements) import Drasil.SWHS.TMods (PhaseChange(Liquid), consThermE, nwtnCooling, sensHtETemplate) import Drasil.SWHS.Unitals (coilSAMax, deltaT, htFluxC, htFluxIn, @@ -52,19 +53,19 @@ import Drasil.SWHS.Unitals (coilSAMax, deltaT, htFluxC, htFluxIn, tempEnv, tempW, thFluxVect, volHtGen, watE, wMass, wVol, unitalChuncks, absTol, relTol) -import Drasil.NoPCM.Assumptions -import Drasil.NoPCM.Changes (likelyChgs, unlikelyChgs) -import Drasil.NoPCM.DataDefs (qDefs) -import qualified Drasil.NoPCM.DataDefs as NoPCM (dataDefs) -import Drasil.NoPCM.Definitions (srsSWHS, htTrans) -import Drasil.NoPCM.GenDefs (genDefs) -import Drasil.NoPCM.Goals (goals) -import Drasil.NoPCM.IMods (eBalanceOnWtr, instModIntro) -import qualified Drasil.NoPCM.IMods as NoPCM (iMods) -import Drasil.NoPCM.ODEs -import Drasil.NoPCM.Requirements (funcReqs, inputInitValsTable) -import Drasil.NoPCM.References (citations) -import Drasil.NoPCM.Unitals (inputs, constrained, unconstrained, +import Drasil.SWHSNoPCM.Assumptions +import Drasil.SWHSNoPCM.Changes (likelyChgs, unlikelyChgs) +import Drasil.SWHSNoPCM.DataDefs (qDefs) +import qualified Drasil.SWHSNoPCM.DataDefs as NoPCM (dataDefs) +import Drasil.SWHSNoPCM.Definitions (srsSWHS, htTrans) +import Drasil.SWHSNoPCM.GenDefs (genDefs) +import Drasil.SWHSNoPCM.Goals (goals) +import Drasil.SWHSNoPCM.IMods (eBalanceOnWtr, instModIntro) +import qualified Drasil.SWHSNoPCM.IMods as NoPCM (iMods) +import Drasil.SWHSNoPCM.ODEs +import Drasil.SWHSNoPCM.Requirements (funcReqs, inputInitValsTable) +import Drasil.SWHSNoPCM.References (citations) +import Drasil.SWHSNoPCM.Unitals (inputs, constrained, unconstrained, specParamValList) srs :: Document @@ -77,7 +78,7 @@ printSetting :: PrintingInformation printSetting = piSys fullSI Equational defaultConfiguration resourcePath :: String -resourcePath = "../../../../datafiles/nopcm/" +resourcePath = "../../../../datafiles/swhsnopcm/" -- This defines the standard concepts used throughout the document units :: [UnitDefn] @@ -126,7 +127,7 @@ mkSRS = [TableOfContents, ], GSDSec $ GSDProg - [ SysCntxt [sysCntxtDesc progName, LlC sysCntxtFig, sysCntxtRespIntro progName, systContRespBullets] + [ SysCntxt [sysCntxtDesc progName, LlC sysCntxtFig, sysCntxtRespIntro progName, systContRespBullets progName] , UsrChars [userChars progName] , SystCons [] [] ], @@ -194,6 +195,12 @@ si = SI { refdb = refDB } +progName :: CI +progName = commonIdeaWithDict "swhsNoPCM" + (nounPhrase' "solar water heating system with no phase change material" + "solar water heating systems with no phase change material" $ Replace $ + S "Solar Water Heating System with no Phase Change Material") "SWHSNoPCM" [materialEng] + purp :: Sentence purp = foldlSent_ [S "investigate the heating" `S.of_` phraseNP (water `inA` sWHT)] @@ -201,7 +208,7 @@ refDB :: ReferenceDB refDB = rdb citations concIns symbMap :: ChunkDB -symbMap = cdb symbolsAll (map nw symbols ++ map nw acronyms ++ map nw thermocon +symbMap = cdb symbolsAll (nw progName : map nw symbols ++ map nw acronyms ++ map nw thermocon ++ map nw physicscon ++ map nw doccon ++ map nw softwarecon ++ map nw doccon' ++ map nw con ++ map nw prodtcon ++ map nw physicCon ++ map nw physicCon' ++ map nw mathcon ++ map nw mathcon' ++ map nw specParamValList ++ map nw fundamentals ++ map nw educon ++ map nw derived @@ -211,13 +218,14 @@ symbMap = cdb symbolsAll (map nw symbols ++ map nw acronyms ++ map nw thermocon tMods concIns section labCon [] usedDB :: ChunkDB -usedDB = cdb ([] :: [QuantityDict]) (map nw symbols ++ map nw acronyms) +usedDB = cdb ([] :: [QuantityDict]) (nw progName : map nw symbols ++ map nw acronyms) ([] :: [ConceptChunk]) ([] :: [UnitDefn]) [] [] [] [] [] [] [] ([] :: [Reference]) -------------------------- --Section 2 : INTRODUCTION -------------------------- +-- To get this generating properly we need to add a constructor for custom plural and capital case, see #3535 introStartNoPCM :: Sentence introStartNoPCM = atStart' progName +:+ S "provide a novel way of storing" +:+. phrase energy @@ -252,7 +260,7 @@ orgDocEnd = foldlSent_ [atStartNP (the inModel), --Section 3 : GENERAL SYSTEM DESCRIPTION ---------------------------------------- ---ALL OF THIS SECTION IS NOW PULLED FROM SWHS +--ALL OF THIS SECTION IS NOW PULLED FROM SWHS (Exept System Context Figure) --TODO: If/when system constraints recieves any content, add s3_3_intro @@ -260,6 +268,11 @@ orgDocEnd = foldlSent_ [atStartNP (the inModel), --Section 3.1 : SYSTEM CONTEXT ------------------------------ +sysCntxtFig :: LabelledContent +sysCntxtFig = llcc (makeFigRef "SysCon") $ fig (foldlSent_ + [refS sysCntxtFig +: EmptyS, titleize sysCont]) + $ resourcePath ++ "SystemContextFigure.png" + ------------------------------------ --Section 3.2 : USER CHARACTERISTICS ------------------------------------ diff --git a/code/drasil-example/nopcm/lib/Drasil/NoPCM/Changes.hs b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Changes.hs similarity index 88% rename from code/drasil-example/nopcm/lib/Drasil/NoPCM/Changes.hs rename to code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Changes.hs index a26d85e0ce..681cbb83c7 100644 --- a/code/drasil-example/nopcm/lib/Drasil/NoPCM/Changes.hs +++ b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Changes.hs @@ -1,5 +1,5 @@ {-# LANGUAGE PostfixOperators #-} -module Drasil.NoPCM.Changes (likelyChgs, unlikelyChgs) where +module Drasil.SWHSNoPCM.Changes (likelyChgs, unlikelyChgs) where import Language.Drasil import Language.Drasil.Chunk.Concept.NamedCombinators @@ -8,8 +8,8 @@ import qualified Language.Drasil.Sentence.Combinators as S import Data.Drasil.Concepts.Documentation (model, likeChgDom, unlikeChgDom) import Data.Drasil.Concepts.Thermodynamics (temp) -import Drasil.NoPCM.Assumptions (assumpCTNTD, assumpNIHGBW, assumpWAL) -import Drasil.NoPCM.IMods (eBalanceOnWtr) +import Drasil.SWHSNoPCM.Assumptions (assumpCTNTD, assumpNIHGBW, assumpWAL) +import Drasil.SWHSNoPCM.IMods (eBalanceOnWtr) import Drasil.SWHS.Concepts (tank, water) -------------------------------- -- Section 6 : LIKELY CHANGES -- diff --git a/code/drasil-example/nopcm/lib/Drasil/NoPCM/Choices.hs b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Choices.hs similarity index 87% rename from code/drasil-example/nopcm/lib/Drasil/NoPCM/Choices.hs rename to code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Choices.hs index 1b7192deca..262be9d450 100644 --- a/code/drasil-example/nopcm/lib/Drasil/NoPCM/Choices.hs +++ b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Choices.hs @@ -1,4 +1,4 @@ -module Drasil.NoPCM.Choices where +module Drasil.SWHSNoPCM.Choices where import Language.Drasil.Code (Choices(..), CodeSpec, codeSpec, Comments(..), Verbosity(..), ConstraintBehaviour(..), ImplementationType(..), Lang(..), @@ -9,7 +9,7 @@ import Language.Drasil.Code (Choices(..), CodeSpec, codeSpec, Comments(..), import Data.Drasil.ExternalLibraries.ODELibraries (scipyODEPckg, osloPckg, apacheODEPckg, odeintPckg) -import Drasil.NoPCM.Body (noPCMODEInfo, fullSI) +import Drasil.SWHSNoPCM.Body (noPCMODEInfo, fullSI) code :: CodeSpec code = codeSpec fullSI choices [] @@ -23,7 +23,7 @@ choices = defaultChoices { optFeats = makeOptFeats (makeDocConfig [CommentFunc, CommentClass, CommentMod] Quiet Hide) (makeLogConfig [] "log.txt") - [SampleInput "../../datafiles/nopcm/sampleInput.txt", ReadME], + [SampleInput "../../datafiles/swhsnopcm/sampleInput.txt", ReadME], srsConstraints = makeConstraints Warning Warning, extLibs = [Math (makeODE [noPCMODEInfo] [scipyODEPckg, osloPckg, apacheODEPckg, odeintPckg])] } \ No newline at end of file diff --git a/code/drasil-example/nopcm/lib/Drasil/NoPCM/DataDefs.hs b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/DataDefs.hs similarity index 93% rename from code/drasil-example/nopcm/lib/Drasil/NoPCM/DataDefs.hs rename to code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/DataDefs.hs index 16c35eab39..1408b6fc97 100644 --- a/code/drasil-example/nopcm/lib/Drasil/NoPCM/DataDefs.hs +++ b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/DataDefs.hs @@ -1,4 +1,4 @@ -module Drasil.NoPCM.DataDefs where --exports all of it +module Drasil.SWHSNoPCM.DataDefs where --exports all of it import Language.Drasil import Theory.Drasil (DataDefinition, ddENoRefs) diff --git a/code/drasil-example/nopcm/lib/Drasil/NoPCM/Definitions.hs b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Definitions.hs similarity index 79% rename from code/drasil-example/nopcm/lib/Drasil/NoPCM/Definitions.hs rename to code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Definitions.hs index 5d8bd43877..d8cb1c2a37 100644 --- a/code/drasil-example/nopcm/lib/Drasil/NoPCM/Definitions.hs +++ b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Definitions.hs @@ -1,4 +1,4 @@ -module Drasil.NoPCM.Definitions where --whole file is used +module Drasil.SWHSNoPCM.Definitions where --whole file is used import Language.Drasil @@ -8,4 +8,4 @@ htTrans = nc "heat transfer" (cn "heat transfer") --Not really a nounphase, --just a hack to get RefSec to work srsSWHS :: CI -- Used to make the title of the paper -srsSWHS = commonIdea "srsSWHS" (nounPhraseSP "Solar Water Heating Systems") "NoPCM" [] +srsSWHS = commonIdea "srsSWHS" (nounPhraseSP "Solar Water Heating Systems") "SWHSNoPCM" [] \ No newline at end of file diff --git a/code/drasil-example/nopcm/lib/Drasil/NoPCM/Derivations.hs b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Derivations.hs similarity index 96% rename from code/drasil-example/nopcm/lib/Drasil/NoPCM/Derivations.hs rename to code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Derivations.hs index c9fcb73968..2f9d46da92 100644 --- a/code/drasil-example/nopcm/lib/Drasil/NoPCM/Derivations.hs +++ b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Derivations.hs @@ -1,4 +1,4 @@ -module Drasil.NoPCM.Derivations ( +module Drasil.SWHSNoPCM.Derivations ( eBalanceOnWtrDerivEqns ) where diff --git a/code/drasil-example/nopcm/lib/Drasil/NoPCM/GenDefs.hs b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/GenDefs.hs similarity index 80% rename from code/drasil-example/nopcm/lib/Drasil/NoPCM/GenDefs.hs rename to code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/GenDefs.hs index c4aef42e1c..ceed6e7774 100644 --- a/code/drasil-example/nopcm/lib/Drasil/NoPCM/GenDefs.hs +++ b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/GenDefs.hs @@ -1,11 +1,11 @@ {-# LANGUAGE NoMonomorphismRestriction #-} -module Drasil.NoPCM.GenDefs (rocTempSimp, genDefs) where +module Drasil.SWHSNoPCM.GenDefs (rocTempSimp, genDefs) where import Language.Drasil import Theory.Drasil (GenDefn, gdNoRefs, othModel') -import Drasil.NoPCM.Assumptions (assumpDWCoW, assumpSHECoW) +import Drasil.SWHSNoPCM.Assumptions (assumpDWCoW, assumpSHECoW) import Drasil.SWHS.Assumptions (assumpCWTAT) import Drasil.SWHS.GenDefs (htFluxWaterFromCoil, rocTempSimpRC, rocTempSimpDeriv) diff --git a/code/drasil-example/nopcm/lib/Drasil/NoPCM/Goals.hs b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Goals.hs similarity index 66% rename from code/drasil-example/nopcm/lib/Drasil/NoPCM/Goals.hs rename to code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Goals.hs index ef28fcf1cd..cf739654ea 100644 --- a/code/drasil-example/nopcm/lib/Drasil/NoPCM/Goals.hs +++ b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Goals.hs @@ -1,4 +1,4 @@ -module Drasil.NoPCM.Goals (goals, waterTempGS, waterEnergyGS) where +module Drasil.SWHSNoPCM.Goals (goals, waterTempGS, waterEnergyGS) where import Language.Drasil diff --git a/code/drasil-example/nopcm/lib/Drasil/NoPCM/IMods.hs b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/IMods.hs similarity index 92% rename from code/drasil-example/nopcm/lib/Drasil/NoPCM/IMods.hs rename to code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/IMods.hs index bacb9c4103..ab4acbdec2 100644 --- a/code/drasil-example/nopcm/lib/Drasil/NoPCM/IMods.hs +++ b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/IMods.hs @@ -1,4 +1,4 @@ -module Drasil.NoPCM.IMods (eBalanceOnWtr, iMods, instModIntro, eBalanceOnWtrRC) where +module Drasil.SWHSNoPCM.IMods (eBalanceOnWtr, iMods, instModIntro, eBalanceOnWtrRC) where import Language.Drasil import Theory.Drasil (InstanceModel, im, qwC, qwUC, newDEModel') @@ -22,9 +22,9 @@ import Drasil.SWHS.References (koothoor2013) import Drasil.SWHS.Unitals (coilHTC, coilSA, htCapW, htFluxC, tauW, tempC, tempInit, tempW, timeFinal, wMass) -import Drasil.NoPCM.Assumptions (assumpNIHGBW, assumpWAL) -import Drasil.NoPCM.Goals (waterTempGS, waterEnergyGS) -import Drasil.NoPCM.Derivations (eBalanceOnWtrDerivEqns) +import Drasil.SWHSNoPCM.Assumptions (assumpNIHGBW, assumpWAL) +import Drasil.SWHSNoPCM.Goals (waterTempGS, waterEnergyGS) +import Drasil.SWHSNoPCM.Derivations (eBalanceOnWtrDerivEqns) iMods :: [InstanceModel] iMods = [eBalanceOnWtr, heatEInWtr] diff --git a/code/drasil-example/nopcm/lib/Drasil/NoPCM/ODEs.hs b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/ODEs.hs similarity index 84% rename from code/drasil-example/nopcm/lib/Drasil/NoPCM/ODEs.hs rename to code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/ODEs.hs index 9b082e1d38..3012365317 100644 --- a/code/drasil-example/nopcm/lib/Drasil/NoPCM/ODEs.hs +++ b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/ODEs.hs @@ -1,10 +1,10 @@ -module Drasil.NoPCM.ODEs (noPCMODEOpts, noPCMODEInfo) where +module Drasil.SWHSNoPCM.ODEs (noPCMODEOpts, noPCMODEInfo) where import Language.Drasil (ExprC(sy),LiteralC(exactDbl), InitialValueProblem, makeAIVP) import Language.Drasil.Code (odeInfo', odeOptions, quantvar, ODEInfo, ODEMethod(RK45), ODEOptions) import Drasil.SWHS.Unitals (tauW, tempC, tempInit, timeFinal, timeStep, absTol, relTol) -import Drasil.NoPCM.IMods(eBalanceOnWtrRC) +import Drasil.SWHSNoPCM.IMods(eBalanceOnWtrRC) noPCMODEOpts :: ODEOptions diff --git a/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/README.md b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/README.md new file mode 100644 index 0000000000..56a1a9d7ee --- /dev/null +++ b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/README.md @@ -0,0 +1,46 @@ +-------------------------------------------------- +### Summary of Folder Structure and File Contents +Last updated: August 20, 2019 +-------------------------------------------------- + +Assumptions.hs + - SWHSNoPCM's assumptions + +Body.hs + - The main document body representation for the SWHSNoPCM example + +Changes.hs + - SWHSNoPCM's likely and unlikely changes + +DataDefs.hs + - SWHSNoPCM's data definitions + +DataDesc.hs + - SWHSNoPCM's input data + +Definitions.hs + - SWHSNoPCM's example-specific concepts + +GenDefs.hs + - SWHSNoPCM's general definitions + +Goals.hs + - SWHSNoPCM's goal statements + +IMods.hs + - SWHSNoPCM's instance models + +Main.hs + - A list of what should be generated + +README.md + - This file + +References.hs + - SWHSNoPCM's references + +Requirements.hs + - SWHSNoPCM's requirements + +Unitals.hs + - SWHSNoPCM's example-specific quantities diff --git a/code/drasil-example/nopcm/lib/Drasil/NoPCM/References.hs b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/References.hs similarity index 86% rename from code/drasil-example/nopcm/lib/Drasil/NoPCM/References.hs rename to code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/References.hs index 45300b5f9c..acf248ba1d 100644 --- a/code/drasil-example/nopcm/lib/Drasil/NoPCM/References.hs +++ b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/References.hs @@ -1,4 +1,4 @@ -module Drasil.NoPCM.References (citations) where +module Drasil.SWHSNoPCM.References (citations) where import Language.Drasil diff --git a/code/drasil-example/nopcm/lib/Drasil/NoPCM/Requirements.hs b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Requirements.hs similarity index 69% rename from code/drasil-example/nopcm/lib/Drasil/NoPCM/Requirements.hs rename to code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Requirements.hs index 2809bcb2b5..0214d680ea 100644 --- a/code/drasil-example/nopcm/lib/Drasil/NoPCM/Requirements.hs +++ b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Requirements.hs @@ -1,20 +1,23 @@ -module Drasil.NoPCM.Requirements (funcReqs, inputInitValsTable) where +module Drasil.SWHSNoPCM.Requirements (funcReqs, inputInitValsTable) where + +import Control.Lens ((^.)) import Language.Drasil import Drasil.DocLang (mkInputPropsTable) import Language.Drasil.Chunk.Concept.NamedCombinators +import Theory.Drasil (InstanceModel) import Data.Drasil.Concepts.Documentation (funcReqDom, input_, value) - import Data.Drasil.Quantities.PhysicalProperties (mass) import Drasil.SWHS.DataDefs (waterMass, tankVolume, balanceDecayRate) -import Drasil.SWHS.Requirements (calcTempWtrOverTime, calcChgHeatEnergyWtrOverTime, - checkWithPhysConsts, findMassConstruct, inReqDesc, oIDQConstruct) +import Drasil.SWHS.IMods (heatEInWtr) +import Drasil.SWHS.Requirements (calcValues, checkWithPhysConsts, + findMassConstruct, inReqDesc, oIDQConstruct, outputValues) -import Drasil.NoPCM.DataDefs (waterVolume) -import Drasil.NoPCM.IMods (eBalanceOnWtr) -import Drasil.NoPCM.Unitals (inputs) +import Drasil.SWHSNoPCM.DataDefs (waterVolume) +import Drasil.SWHSNoPCM.IMods (eBalanceOnWtr) +import Drasil.SWHSNoPCM.Unitals (inputs) -------------------------- --Section 5 : REQUIREMENTS @@ -41,7 +44,7 @@ oIDQVals :: [Sentence] oIDQVals = map foldlSent_ [ [pluralNP (the value), fromSource inputInitVals], [phraseNP (the mass), fromSource findMass], - [ch balanceDecayRate, fromSource balanceDecayRate] + [ch (balanceDecayRate ^. defLhs), fromSource balanceDecayRate] ] inputInitValsTable :: LabelledContent @@ -49,7 +52,10 @@ inputInitValsTable = mkInputPropsTable inputs inputInitVals funcReqs :: [ConceptInstance] funcReqs = [inputInitVals, findMass, checkWithPhysConsts, - oIDQConstruct oIDQVals, calcTempWtrOverTime, calcChgHeatEnergyWtrOverTime] + oIDQConstruct oIDQVals, calcValues noPCMOutputs, outputValues noPCMOutputs] + +noPCMOutputs :: [InstanceModel] +noPCMOutputs = [eBalanceOnWtr, heatEInWtr] ------------------------------------------- --Section 5.2 : NON-FUNCTIONAL REQUIREMENTS diff --git a/code/drasil-example/nopcm/lib/Drasil/NoPCM/Unitals.hs b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Unitals.hs similarity index 96% rename from code/drasil-example/nopcm/lib/Drasil/NoPCM/Unitals.hs rename to code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Unitals.hs index 8416421c33..9730a54e93 100644 --- a/code/drasil-example/nopcm/lib/Drasil/NoPCM/Unitals.hs +++ b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Unitals.hs @@ -1,4 +1,4 @@ -module Drasil.NoPCM.Unitals where +module Drasil.SWHSNoPCM.Unitals where import Language.Drasil diff --git a/code/drasil-example/sglpendulum/package.yaml b/code/drasil-example/swhsnopcm/package.yaml similarity index 86% rename from code/drasil-example/sglpendulum/package.yaml rename to code/drasil-example/swhsnopcm/package.yaml index 82e99aa67b..834792c9c8 100644 --- a/code/drasil-example/sglpendulum/package.yaml +++ b/code/drasil-example/swhsnopcm/package.yaml @@ -1,4 +1,4 @@ -name: sglpendulum +name: swhsnopcm version: 0.1.24.0 author: "Dan Szymczak, Steven Palmer, Jacques Carette, Spencer Smith" maintainer: "Jacques Carette" @@ -24,16 +24,16 @@ dependencies: - drasil-printers - drasil-theory - drasil-utils -- dblpendulum +- swhs library: source-dirs: lib when: - condition: false - other-modules: Paths_sglpendulum + other-modules: Paths_swhsnopcm executables: - sglpendulum: + swhsnopcm: main: Main source-dirs: app ghc-options: @@ -42,7 +42,7 @@ executables: - -threaded - -O2 dependencies: - - sglpendulum + - swhsnopcm when: - condition: false - other-modules: Paths_sglpendulum + other-modules: Paths_swhsnopcm diff --git a/code/drasil-example/nopcm/stack.yaml b/code/drasil-example/swhsnopcm/stack.yaml similarity index 100% rename from code/drasil-example/nopcm/stack.yaml rename to code/drasil-example/swhsnopcm/stack.yaml diff --git a/code/drasil-example/template/lib/Drasil/Template/Body.hs b/code/drasil-example/template/lib/Drasil/Template/Body.hs index 02eb09077a..d9319fe445 100644 --- a/code/drasil-example/template/lib/Drasil/Template/Body.hs +++ b/code/drasil-example/template/lib/Drasil/Template/Body.hs @@ -134,8 +134,8 @@ outConstraints :: [UncertQ] outConstraints = [] figTemp :: LabelledContent -figTemp = llcc (makeFigRef "dblpendulum") $ figWithWidth EmptyS - (resourcePath ++ "dblpendulum.png") 60 +figTemp = llcc (makeFigRef "dblpend") $ figWithWidth EmptyS + (resourcePath ++ "dblpend.png") 60 -- MOVE TO CONCEPTS diff --git a/code/drasil-gen/lib/Language/Drasil/Dump.hs b/code/drasil-gen/lib/Language/Drasil/Dump.hs index 82933e3db5..dc264ffd9a 100644 --- a/code/drasil-gen/lib/Language/Drasil/Dump.hs +++ b/code/drasil-gen/lib/Language/Drasil/Dump.hs @@ -14,12 +14,24 @@ import qualified Data.Map.Strict as SM import Utils.Drasil (invert, atLeast2) import Database.Drasil (traceTable, refbyTable) import Control.Lens ((^.)) +import System.Environment (lookupEnv) type Path = String type TargetFile = String +-- | For debugging purposes, if the system has a `DEBUG_ENV` environment +-- variable set to anything, we can dump the chunk maps in a system to the +-- host system. dumpEverything :: SystemInformation -> Path -> IO () -dumpEverything si targetPath = do +dumpEverything si p = do + maybeDebugging <- lookupEnv "DEBUG_ENV" + case maybeDebugging of + (Just (_:_)) -> do + dumpEverything0 si p + _ -> mempty + +dumpEverything0 :: SystemInformation -> Path -> IO () +dumpEverything0 si targetPath = do createDirectoryIfMissing True targetPath let chunkDb = _sysinfodb si chunkDump = DB.dumpChunkDB chunkDb diff --git a/code/drasil-gen/package.yaml b/code/drasil-gen/package.yaml index a79237703d..c8fc4a501a 100644 --- a/code/drasil-gen/package.yaml +++ b/code/drasil-gen/package.yaml @@ -23,6 +23,7 @@ dependencies: - drasil-database - drasil-docLang - drasil-gool +- drasil-metadata - drasil-lang - drasil-printers - drasil-sysinfo diff --git a/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer.hs b/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer.hs index 77b580ed26..b12bb07262 100644 --- a/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer.hs +++ b/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer.hs @@ -46,6 +46,7 @@ import Prelude hiding (break,print,last,sqrt,abs,log,exp,sin,cos,tan,asin,acos, import Text.PrettyPrint.HughesPJ (Doc, text, empty, render, (<>), (<+>), ($+$), space, brackets, parens, isEmpty, rbrace, lbrace, vcat, semi, equals, colon, comma) +import Metadata.Drasil.DrasilMetaCall(drasilMeta, DrasilMeta(..), watermark) ---------------------------------------- -- Syntax common to several renderers -- @@ -414,7 +415,8 @@ moduleDox :: ModuleDocRenderer moduleDox desc as date m = (doxFile ++ m) : [doxAuthor ++ stringList as | not (null as)] ++ [doxDate ++ date | not (null date)] ++ - [doxBrief ++ desc | not (null desc)] + [doxBrief ++ desc | not (null desc)] ++ + [doxCommand ++ watermark ++ version drasilMeta] commentedMod :: FileData -> Doc -> FileData commentedMod m cmt = updateFileMod (updateMod (commentedItem cmt) (fileMod m)) m diff --git a/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/CSharpRenderer.hs b/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/CSharpRenderer.hs index 7743a31bdf..696803b7b7 100644 --- a/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/CSharpRenderer.hs +++ b/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/CSharpRenderer.hs @@ -62,7 +62,7 @@ import qualified GOOL.Drasil.LanguageRenderer.LanguagePolymorphic as G ( increment, objDecNew, print, closeFile, returnStmt, valStmt, comment, throw, ifCond, tryCatch, construct, param, method, getMethod, setMethod, function, buildClass, implementingClass, commentedClass, - modFromData, fileDoc, fileFromData) + modFromData, fileDoc, fileFromData, defaultOptSpace) import qualified GOOL.Drasil.LanguageRenderer.CommonPseudoOO as CP (int, constructor, doxFunc, doxClass, doxMod, extVar, classVar, objVarSelf, extFuncAppMixedArgs, indexOf, listAddFunc, discardFileLine, intClass, @@ -559,7 +559,7 @@ instance ControlStatement CSharpCode where modify (addLangImport csSystem) G.throw csThrowDoc Semi msg - ifCond = G.ifCond parens bodyStart elseIfLabel bodyEnd + ifCond = G.ifCond parens bodyStart G.defaultOptSpace elseIfLabel bodyEnd switch = C.switch parens break ifExists = M.ifExists diff --git a/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/CppRenderer.hs b/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/CppRenderer.hs index 87309106fe..28feae1024 100644 --- a/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/CppRenderer.hs +++ b/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/CppRenderer.hs @@ -66,7 +66,7 @@ import qualified GOOL.Drasil.LanguageRenderer.LanguagePolymorphic as G ( increment, objDecNew, print, closeFile, returnStmt, valStmt, comment, throw, ifCond, tryCatch, construct, param, method, getMethod, setMethod, function, buildClass, implementingClass, commentedClass, modFromData, fileDoc, - fileFromData) + fileFromData, defaultOptSpace) import GOOL.Drasil.LanguageRenderer.LanguagePolymorphic (classVarCheckStatic) import qualified GOOL.Drasil.LanguageRenderer.CommonPseudoOO as CP (int, constructor, doxFunc, doxClass, doxMod, funcType, buildModule, litArray, @@ -1492,7 +1492,7 @@ instance ControlStatement CppSrcCode where throw = G.throw cppThrowDoc Semi - ifCond = G.ifCond parens bodyStart elseIfLabel bodyEnd + ifCond = G.ifCond parens bodyStart G.defaultOptSpace elseIfLabel bodyEnd switch = C.switch parens break ifExists _ ifBody _ = do diff --git a/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/JavaRenderer.hs b/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/JavaRenderer.hs index a4f40c6c11..0b5293ca29 100644 --- a/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/JavaRenderer.hs +++ b/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/JavaRenderer.hs @@ -65,7 +65,7 @@ import qualified GOOL.Drasil.LanguageRenderer.LanguagePolymorphic as G ( increment, objDecNew, print, closeFile, returnStmt, valStmt, comment, throw, ifCond, tryCatch, construct, param, method, getMethod, setMethod, function, buildClass, implementingClass, commentedClass, modFromData, fileDoc, - fileFromData) + fileFromData, defaultOptSpace) import GOOL.Drasil.LanguageRenderer.LanguagePolymorphic (docFuncRepr) import qualified GOOL.Drasil.LanguageRenderer.CommonPseudoOO as CP (int, constructor, doxFunc, doxClass, doxMod, extVar, classVar, objVarSelf, @@ -591,7 +591,7 @@ instance ControlStatement JavaCode where throw = G.throw jThrowDoc Semi - ifCond = G.ifCond parens bodyStart elseIfLabel bodyEnd + ifCond = G.ifCond parens bodyStart G.defaultOptSpace elseIfLabel bodyEnd switch = C.switch parens break ifExists = M.ifExists diff --git a/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/LanguagePolymorphic.hs b/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/LanguagePolymorphic.hs index 5db3020ace..0a19c20752 100644 --- a/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/LanguagePolymorphic.hs +++ b/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/LanguagePolymorphic.hs @@ -13,7 +13,7 @@ module GOOL.Drasil.LanguageRenderer.LanguagePolymorphic (fileFromData, objDecNew, print, closeFile, returnStmt, valStmt, comment, throw, ifCond, tryCatch, construct, param, method, getMethod, setMethod, initStmts, function, docFuncRepr, docFunc, buildClass, implementingClass, docClass, - commentedClass, modFromData, fileDoc, docMod + commentedClass, modFromData, fileDoc, docMod, OptionalSpace(..), defaultOptSpace ) where import Utils.Drasil (indent) @@ -75,7 +75,7 @@ import Control.Monad.State (modify) import Control.Lens ((^.), over) import Control.Lens.Zoom (zoom) import Text.PrettyPrint.HughesPJ (Doc, text, empty, render, (<>), (<+>), parens, - brackets, integer, vcat, comma, isEmpty) + brackets, integer, vcat, comma, isEmpty, space) import qualified Text.PrettyPrint.HughesPJ as D (char, double) -- Bodies -- @@ -386,26 +386,34 @@ throw f t l = do msg <- zoom lensMStoVS (S.litString l) stmtFromData (f msg) t +newtype OptionalSpace = OSpace {oSpace :: Doc} + +defaultOptSpace :: OptionalSpace +defaultOptSpace = OSpace {oSpace = space} + +optSpaceDoc :: OptionalSpace -> Doc +optSpaceDoc OSpace {oSpace = sp} = sp + -- ControlStatements -- -- 1st parameter is a Doc function to use on the render of each condition (i.e. parens) -- 2nd parameter is the syntax for starting a block in an if-condition -- 3rd parameter is the keyword for an else-if statement -- 4th parameter is the syntax for ending a block in an if-condition -ifCond :: (RenderSym r) => (Doc -> Doc) -> Doc -> Doc -> Doc -> +ifCond :: (RenderSym r) => (Doc -> Doc) -> Doc -> OptionalSpace -> Doc -> Doc -> [(SValue r, MSBody r)] -> MSBody r -> MSStatement r -ifCond _ _ _ _ [] _ = error "if condition created with no cases" -ifCond f ifStart elif bEnd (c:cs) eBody = +ifCond _ _ _ _ _ [] _ = error "if condition created with no cases" +ifCond f ifStart os elif bEnd (c:cs) eBody = let ifSect (v, b) = on2StateValues (\val bd -> vcat [ - ifLabel <+> f (RC.value val) <+> ifStart, + ifLabel <+> f (RC.value val) <> optSpaceDoc os <> ifStart, indent $ RC.body bd, bEnd]) (zoom lensMStoVS v) b elseIfSect (v, b) = on2StateValues (\val bd -> vcat [ - elif <+> f (RC.value val) <+> ifStart, + elif <+> f (RC.value val) <> optSpaceDoc os <> ifStart, indent $ RC.body bd, bEnd]) (zoom lensMStoVS v) b elseSect = onStateValue (\bd -> emptyIfEmpty (RC.body bd) $ vcat [ - elseLabel <+> ifStart, + elseLabel <> optSpaceDoc os <> ifStart, indent $ RC.body bd, bEnd]) eBody in sequence (ifSect c : map elseIfSect cs ++ [elseSect]) @@ -496,8 +504,8 @@ fileDoc ext topb botb mdl = do (R.file (RC.block $ topb m) d (RC.block botb))) m S.fileFromData fp (toState updm) -docMod :: (RenderSym r) => ModuleDocRenderer -> String -> String -> [String] -> - String -> SFile r -> SFile r +docMod :: (RenderSym r) => ModuleDocRenderer -> String -> String -> + [String] -> String -> SFile r -> SFile r docMod mdr e d a dt fl = commentedMod fl (docComment $ mdr d a dt . addExt e <$> getModuleName) diff --git a/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/PythonRenderer.hs b/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/PythonRenderer.hs index 8b2e3e7048..6e0872e697 100644 --- a/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/PythonRenderer.hs +++ b/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/PythonRenderer.hs @@ -95,6 +95,7 @@ import Data.List (intercalate, sort) import qualified Data.Map as Map (lookup) import Text.PrettyPrint.HughesPJ (Doc, text, (<>), (<+>), parens, empty, equals, vcat, colon, brackets, isEmpty, quotes) +import GOOL.Drasil.LanguageRenderer.LanguagePolymorphic (OptionalSpace(..)) pyExt :: String pyExt = "py" @@ -571,7 +572,7 @@ instance ControlStatement PythonCode where throw = G.throw pyThrow Empty - ifCond = G.ifCond parens pyBodyStart pyElseIf pyBodyEnd + ifCond = G.ifCond parens pyBodyStart pySpace pyElseIf pyBodyEnd switch = switchAsIf ifExists = M.ifExists @@ -810,6 +811,9 @@ pyCommentStart = text "#" pyDocCommentStart = pyCommentStart <> pyCommentStart pyNamedArgSep = equals +pySpace :: OptionalSpace +pySpace = OSpace {oSpace = empty} + pyNotOp :: (Monad r) => VSOp r pyNotOp = unOpPrec "not" @@ -946,9 +950,9 @@ pyWhile v b = vcat [ pyTryCatch :: (RenderSym r) => r (Body r) -> r (Body r) -> Doc pyTryCatch tryB catchB = vcat [ - tryLabel <+> colon, + tryLabel <> colon, indent $ RC.body tryB, - pyExcept <+> exceptionObj' <+> colon, + pyExcept <+> exceptionObj' <> colon, indent $ RC.body catchB] pyListSlice :: (RenderSym r, Monad r) => SVariable r -> SValue r -> SValue r -> diff --git a/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/SwiftRenderer.hs b/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/SwiftRenderer.hs index 9a58c52f0a..30343afa2d 100644 --- a/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/SwiftRenderer.hs +++ b/code/drasil-gool/lib/GOOL/Drasil/LanguageRenderer/SwiftRenderer.hs @@ -65,7 +65,7 @@ import qualified GOOL.Drasil.LanguageRenderer.LanguagePolymorphic as G ( increment, objDecNew, print, returnStmt, valStmt, comment, throw, ifCond, tryCatch, construct, param, method, getMethod, setMethod, initStmts, function, docFunc, buildClass, implementingClass, docClass, commentedClass, - modFromData, fileDoc, docMod, fileFromData) + modFromData, fileDoc, docMod, fileFromData, defaultOptSpace) import qualified GOOL.Drasil.LanguageRenderer.CommonPseudoOO as CP (classVar, objVarSelf, intClass, buildModule, bindingError, extFuncAppMixedArgs, notNull, listDecDef, destructorError, stateVarDef, constVar, litArray, @@ -105,6 +105,7 @@ import Data.Maybe (fromMaybe) import Text.PrettyPrint.HughesPJ (Doc, text, (<>), (<+>), parens, empty, equals, vcat, lbrace, rbrace, braces, brackets, colon, space, doubleQuotes) import qualified Text.PrettyPrint.HughesPJ as D (float) +import Metadata.Drasil.DrasilMetaCall (drasilMeta, DrasilMeta(..), watermark) swiftExt :: String swiftExt = "swift" @@ -597,7 +598,7 @@ instance ControlStatement SwiftCode where modify setThrowUsed G.throw swiftThrowDoc Empty msg - ifCond = G.ifCond id bodyStart elseIfLabel bodyEnd + ifCond = G.ifCond id bodyStart G.defaultOptSpace elseIfLabel bodyEnd switch = C.switch (space <>) emptyStmt ifExists = M.ifExists @@ -1161,7 +1162,7 @@ swiftModDoc desc as date m = m : [desc | not (null desc)] ++ [swiftDocCommandInit ++ swiftAuthorDoc ++ swiftDocCommandSep ++ stringList as | not (null as)] ++ [swiftDocCommandInit ++ swiftDateDoc ++ swiftDocCommandSep ++ date - | not (null date)] + | not (null date)] ++ [swiftDocCommandInit ++ watermark ++ version drasilMeta] swiftDocCommandInit, swiftDocCommandSep, swiftParamDoc, swiftRetDoc, swiftAuthorDoc, swiftDateDoc :: String diff --git a/code/drasil-gool/package.yaml b/code/drasil-gool/package.yaml index fbdc00e67f..bd97cef2d5 100644 --- a/code/drasil-gool/package.yaml +++ b/code/drasil-gool/package.yaml @@ -17,6 +17,7 @@ dependencies: - mtl - composition - drasil-codeLang +- drasil-metadata - drasil-utils ghc-options: diff --git a/code/drasil-lang/lib/Language/Drasil.hs b/code/drasil-lang/lib/Language/Drasil.hs index f2756ec294..694a0fd1f9 100644 --- a/code/drasil-lang/lib/Language/Drasil.hs +++ b/code/drasil-lang/lib/Language/Drasil.hs @@ -82,16 +82,15 @@ module Language.Drasil ( -- Similar types are grouped together. -- *** Basic types - , UID, mkUid + , UID, mkUid, nsUid -- Language.Drasil.Chunk.NamedIdea , (+++), (+++.), (+++!) , nc, ncUID, IdeaDict , mkIdea , nw -- bad name (historical) - -- Language.Drasil.Chunk.CodeBase , CodeIdea(..), CodeChunk(..), CodeVarChunk(..), CodeFuncChunk(..), VarOrFunc(..) , obv, qc, ccf, ccv, listToArray, programName, funcPrefix, DefiningCodeExpr(..) -- Language.Drasil.Chunk.CommonIdea - , CI, commonIdea, getAcc, getAccStr, commonIdeaWithDict, prependAbrv + , CI, commonIdea, getAcc, commonIdeaWithDict, prependAbrv -- *** Concepts -- Language.Drasil.Chunk.Concept.Core @@ -106,8 +105,8 @@ module Language.Drasil ( -- *** Quantities and Units -- Language.Drasil.Chunk.Quantity - , QuantityDict, qw, mkQuant, mkQuant', codeVC, implVar, implVar', implVarUID, implVarUID' - , vc, vc'', vcSt, vcUnit + , QuantityDict, DefinesQuantity(defLhs), qw, mkQuant, mkQuant' + , codeVC, implVar, implVar', implVarUID, implVarUID' , vc, vc'', vcSt, vcUnit -- Language.Drasil.Chunk.Eq , QDefinition, fromEqn, fromEqn', fromEqnSt, fromEqnSt', fromEqnSt'' , mkQDefSt, mkQuantDef, mkQuantDef', ec @@ -329,7 +328,7 @@ import Language.Drasil.Document.Contents (lbldExpr, unlbldExpr, unlbldCode import Language.Drasil.Document.Combinators import Language.Drasil.Unicode (RenderSpecial(..), Special(..)) import Language.Drasil.UID - (UID, HasUID(..), (+++), (+++.), (+++!), mkUid) + (UID, HasUID(..), (+++), (+++.), (+++!), mkUid, nsUid) import Language.Drasil.Symbol (HasSymbol(symbol), Decoration, Symbol) import Language.Drasil.Classes (Definition(defn), ConceptDomain(cdom), Concept, HasUnitSymbol(usymb), IsUnit(getUnits), CommonIdea(abrv), HasAdditionalNotes(getNotes), Constrained(constraints), @@ -345,8 +344,9 @@ import Language.Drasil.Chunk.Citation ( , cInBookACP, cInBookECP, cInBookAC, cInBookEC, cInBookAP, cInBookEP , cInCollection, cInProceedings, cManual, cMThesis, cMisc, cPhDThesis , cProceedings, cTechReport, cUnpublished) -import Language.Drasil.Chunk.CodeBase (CodeIdea(..), CodeChunk(..), CodeVarChunk(..), CodeFuncChunk(..), - VarOrFunc(..), obv, qc, ccf, ccv, listToArray, programName, funcPrefix, DefiningCodeExpr(..)) +import Language.Drasil.Chunk.CodeVar (CodeIdea(..), CodeChunk(..), + CodeVarChunk(..), CodeFuncChunk(..), VarOrFunc(..), obv, qc, ccf, ccv, + listToArray, programName, funcPrefix, DefiningCodeExpr(..)) import Language.Drasil.Chunk.CommonIdea import Language.Drasil.Chunk.Concept import Language.Drasil.Chunk.Concept.Core (sDom) -- exported for drasil-database FIXME: move to development package? diff --git a/code/drasil-lang/lib/Language/Drasil/Chunk/CodeBase.hs b/code/drasil-lang/lib/Language/Drasil/Chunk/CodeVar.hs similarity index 98% rename from code/drasil-lang/lib/Language/Drasil/Chunk/CodeBase.hs rename to code/drasil-lang/lib/Language/Drasil/Chunk/CodeVar.hs index 977e2924b8..3b0fbd6d64 100644 --- a/code/drasil-lang/lib/Language/Drasil/Chunk/CodeBase.hs +++ b/code/drasil-lang/lib/Language/Drasil/Chunk/CodeVar.hs @@ -1,6 +1,6 @@ {-# LANGUAGE TemplateHaskell #-} -- | Defines chunk types for use in code generation. -module Language.Drasil.Chunk.CodeBase where +module Language.Drasil.Chunk.CodeVar where import Control.Lens ((^.), view, makeLenses, Lens') @@ -114,7 +114,7 @@ instance MayHaveUnit CodeFuncChunk where getUnit = getUnit . view ccf -- FIXME: use show for the UID here? Perhaps need a different implVar function for UIDs -- Changes a 'CodeVarChunk'\'s space from 'Vect' to 'Array'. listToArray :: CodeVarChunk -> CodeVarChunk -listToArray c = newSpc (c ^. typ) +listToArray c = newSpc (c ^. typ) where newSpc (Vect t) = CodeVC (CodeC (implVar' (show $ c +++ "_array") (c ^. term) (getA c) (Array t) (symbol c Implementation) (getUnit c)) Var) (c ^. obv) diff --git a/code/drasil-lang/lib/Language/Drasil/Chunk/CommonIdea.hs b/code/drasil-lang/lib/Language/Drasil/Chunk/CommonIdea.hs index 033c797693..77efea8909 100644 --- a/code/drasil-lang/lib/Language/Drasil/Chunk/CommonIdea.hs +++ b/code/drasil-lang/lib/Language/Drasil/Chunk/CommonIdea.hs @@ -6,7 +6,7 @@ module Language.Drasil.Chunk.CommonIdea ( -- * Constructors commonIdea, commonIdeaWithDict, -- * Functions - getAcc, getAccStr, prependAbrv) where + getAcc, prependAbrv) where import Language.Drasil.Chunk.NamedIdea (IdeaDict, nc) import Language.Drasil.Classes (NamedIdea(term), Idea(getA), @@ -51,10 +51,6 @@ commonIdeaWithDict x y z = commonIdea x y z . map (^.uid) getAcc :: CI -> Sentence getAcc = S . abrv --- | Get abbreviation in 'String' form from a 'CI'. -getAccStr :: CI -> String -getAccStr = abrv - -- | Prepends the abbreviation from a 'CommonIdea' to a 'String'. prependAbrv :: CommonIdea c => c -> String -> String prependAbrv c s = abrv c ++ (':' : repUnd s) diff --git a/code/drasil-lang/lib/Language/Drasil/Chunk/Eq.hs b/code/drasil-lang/lib/Language/Drasil/Chunk/Eq.hs index bce9288826..cb247f4b62 100644 --- a/code/drasil-lang/lib/Language/Drasil/Chunk/Eq.hs +++ b/code/drasil-lang/lib/Language/Drasil/Chunk/Eq.hs @@ -12,7 +12,7 @@ module Language.Drasil.Chunk.Eq ( mkFuncDef, mkFuncDef', mkFuncDefByQ ) where -import Control.Lens ((^.), view, lens, Lens') +import Control.Lens ((^.), view, lens, Lens', to) import Language.Drasil.Chunk.UnitDefn (unitWrapper, MayHaveUnit(getUnit), UnitDefn) import Language.Drasil.Symbol (HasSymbol(symbol), Symbol) @@ -22,6 +22,7 @@ import Language.Drasil.Classes (NamedIdea(term), Idea(getA), import Language.Drasil.Chunk.DefinedQuantity (DefinedQuantityDict, dqd, dqd') import Language.Drasil.Chunk.Concept (cc') import Language.Drasil.Chunk.NamedIdea (ncUID, mkIdea, nw) +import Language.Drasil.Chunk.Quantity (DefinesQuantity(defLhs), qw) import Language.Drasil.Expr.Lang (Expr) import qualified Language.Drasil.Expr.Lang as E (Expr(C)) @@ -47,16 +48,17 @@ qdInputs = lens (\(QD _ ins _) -> ins) (\(QD qua _ e) ins' -> QD qua ins' e) qdExpr :: Lens' (QDefinition e) e qdExpr = lens (\(QD _ _ e) -> e) (\(QD qua ins _) e' -> QD qua ins e') -instance HasUID (QDefinition e) where uid = qdQua . uid -instance NamedIdea (QDefinition e) where term = qdQua . term -instance Idea (QDefinition e) where getA = getA . (^. qdQua) -instance HasSpace (QDefinition e) where typ = qdQua . typ -instance HasSymbol (QDefinition e) where symbol = symbol . (^. qdQua) -instance Definition (QDefinition e) where defn = qdQua . defn -instance Quantity (QDefinition e) where -instance Eq (QDefinition e) where a == b = a ^. uid == b ^. uid -instance MayHaveUnit (QDefinition e) where getUnit = getUnit . view qdQua -instance DefiningExpr QDefinition where defnExpr = qdExpr +instance HasUID (QDefinition e) where uid = qdQua . uid +instance NamedIdea (QDefinition e) where term = qdQua . term +instance Idea (QDefinition e) where getA = getA . (^. qdQua) +instance DefinesQuantity (QDefinition e) where defLhs = qdQua . to qw +instance HasSpace (QDefinition e) where typ = qdQua . typ +instance HasSymbol (QDefinition e) where symbol = symbol . (^. qdQua) +instance Definition (QDefinition e) where defn = qdQua . defn +instance Quantity (QDefinition e) where +instance Eq (QDefinition e) where a == b = a ^. uid == b ^. uid +instance MayHaveUnit (QDefinition e) where getUnit = getUnit . view qdQua +instance DefiningExpr QDefinition where defnExpr = qdExpr instance Express e => Express (QDefinition e) where express q = f $ express $ q ^. defnExpr where diff --git a/code/drasil-lang/lib/Language/Drasil/Chunk/NamedIdea.hs b/code/drasil-lang/lib/Language/Drasil/Chunk/NamedIdea.hs index 5aaa30683e..87826e7a4b 100644 --- a/code/drasil-lang/lib/Language/Drasil/Chunk/NamedIdea.hs +++ b/code/drasil-lang/lib/Language/Drasil/Chunk/NamedIdea.hs @@ -47,7 +47,7 @@ ncUID u np' = IdeaDict u np' Nothing -- | 'IdeaDict' is the canonical dictionary associated to an 'Idea'. -- Contains a 'UID' and a term that could have an abbreviation ('Maybe' 'String'). -- --- Ex. The project name "Double Pendulum" may have the abbreviation "DblPendulum". +-- Ex. The project name "Double Pendulum" may have the abbreviation "DblPend". data IdeaDict = IdeaDict { _uu :: UID, _np :: NP, diff --git a/code/drasil-lang/lib/Language/Drasil/Chunk/Quantity.hs b/code/drasil-lang/lib/Language/Drasil/Chunk/Quantity.hs index 71752b8e63..ee4bad29c1 100644 --- a/code/drasil-lang/lib/Language/Drasil/Chunk/Quantity.hs +++ b/code/drasil-lang/lib/Language/Drasil/Chunk/Quantity.hs @@ -3,11 +3,13 @@ module Language.Drasil.Chunk.Quantity ( -- * Chunk Type QuantityDict, + -- * Class + DefinesQuantity(defLhs), -- * Constructors codeVC, implVar, implVar', implVarUID, implVarUID', mkQuant, mkQuant', qw, vc, vc'', vcSt, vcUnit) where -import Control.Lens ((^.),makeLenses,view) +import Control.Lens (Getter, (^.), makeLenses, view) import Language.Drasil.Classes (NamedIdea(term), Idea(getA), Quantity, Express(..)) @@ -33,6 +35,9 @@ data QuantityDict = QD { _id' :: IdeaDict } makeLenses ''QuantityDict +class DefinesQuantity d where + defLhs :: Getter d QuantityDict + -- | Finds the 'UID' of the 'IdeaDict' used to make the 'QuantityDict'. instance HasUID QuantityDict where uid = id' . uid -- | Finds the term ('NP') of the 'IdeaDict' used to make the 'QuantityDict'. diff --git a/code/drasil-lang/lib/Language/Drasil/CodeExpr/Class.hs b/code/drasil-lang/lib/Language/Drasil/CodeExpr/Class.hs index e71059bf5b..ed91dca84b 100644 --- a/code/drasil-lang/lib/Language/Drasil/CodeExpr/Class.hs +++ b/code/drasil-lang/lib/Language/Drasil/CodeExpr/Class.hs @@ -4,7 +4,7 @@ import Language.Drasil.Classes(IsArgumentName, Callable) import Language.Drasil.UID (HasUID(..)) import Language.Drasil.Symbol (HasSymbol) import Language.Drasil.Space (Space(Actor), HasSpace(..)) -import Language.Drasil.Chunk.CodeBase (CodeIdea, CodeVarChunk) +import Language.Drasil.Chunk.CodeVar (CodeIdea, CodeVarChunk) import Language.Drasil.Expr.Class (ExprC(..)) import Language.Drasil.CodeExpr.Lang (CodeExpr(FCall, New, Message, Field)) diff --git a/code/drasil-lang/lib/Language/Drasil/Document/Combinators.hs b/code/drasil-lang/lib/Language/Drasil/Document/Combinators.hs index d03801e0e7..39e1178a3e 100644 --- a/code/drasil-lang/lib/Language/Drasil/Document/Combinators.hs +++ b/code/drasil-lang/lib/Language/Drasil/Document/Combinators.hs @@ -20,6 +20,7 @@ module Language.Drasil.Document.Combinators ( ) where import Language.Drasil.Chunk.Concept.Core ( ConceptChunk ) +import Language.Drasil.Chunk.Quantity (DefinesQuantity(defLhs)) import Language.Drasil.Chunk.UnitDefn ( UnitDefn, MayHaveUnit(..) ) import Language.Drasil.Chunk.Unital ( UnitalChunk ) import Language.Drasil.Classes @@ -93,17 +94,17 @@ fromReplace :: (Referable r, HasShortName r) => r -> UnitalChunk -> Sentence fromReplace src c = S "From" +:+ refS src `sC` S "we can replace" +: ch c -- | Takes a list of 'Referable's and 'Symbol's and outputs as a Sentence "By substituting @symbols@, this can be written as:". -substitute :: (Referable r, HasShortName r, HasSymbol r) => [r] -> Sentence +substitute :: (Referable r, HasShortName r, DefinesQuantity r) => [r] -> Sentence substitute s = S "By substituting" +: (foldlList Comma List l `sC` S "this can be written as") - where l = map (\x -> ch x +:+ fromSource x) s + where l = map (\x -> ch (x ^. defLhs) +:+ fromSource x) s -- | Takes a 'HasSymbol' that is also 'Referable' and outputs as a 'Sentence': "@symbol@ is defined in @reference@." -definedIn :: (Referable r, HasShortName r, HasSymbol r) => r -> Sentence -definedIn q = ch q `S.is` S "defined in" +:+. refS q +definedIn :: (Referable r, HasShortName r, DefinesQuantity r) => r -> Sentence +definedIn q = ch (q ^. defLhs) `S.is` S "defined in" +:+. refS q -- | Same as 'definedIn', but allows for additional information to be appended to the 'Sentence'. -definedIn' :: (Referable r, HasShortName r, HasSymbol r) => r -> Sentence -> Sentence -definedIn' q info = ch q `S.is` S "defined" `S.in_` refS q +:+. info +definedIn' :: (Referable r, HasShortName r, DefinesQuantity r) => r -> Sentence -> Sentence +definedIn' q info = ch (q ^. defLhs) `S.is` S "defined" `S.in_` refS q +:+. info -- | Takes a 'Referable' and outputs as a 'Sentence' "defined in @reference@" (no 'HasSymbol'). definedIn'' :: (Referable r, HasShortName r) => r -> Sentence diff --git a/code/drasil-lang/lib/Language/Drasil/Space.hs b/code/drasil-lang/lib/Language/Drasil/Space.hs index 212f0bb71e..b0c16092a7 100644 --- a/code/drasil-lang/lib/Language/Drasil/Space.hs +++ b/code/drasil-lang/lib/Language/Drasil/Space.hs @@ -19,7 +19,7 @@ module Language.Drasil.Space ( import qualified Data.List.NonEmpty as NE -import Control.Lens (Lens') +import Control.Lens (Getter) import Language.Drasil.Symbol (Symbol) -- FIXME: These need to be spaces and not just types. @@ -48,8 +48,8 @@ data Space = -- | HasSpace is anything which has a 'Space'. class HasSpace c where - -- | Provides a 'Lens' to the 'Space'. - typ :: Lens' c Space + -- | Provides a 'Getter' to the 'Space'. + typ :: Getter c Space type Primitive = Space diff --git a/code/drasil-metadata/lib/Metadata/Drasil/DrasilMeta.hs b/code/drasil-metadata/lib/Metadata/Drasil/DrasilMeta.hs new file mode 100644 index 0000000000..0f9cdd5b4a --- /dev/null +++ b/code/drasil-metadata/lib/Metadata/Drasil/DrasilMeta.hs @@ -0,0 +1,30 @@ +{-# LANGUAGE TemplateHaskellQuotes, DeriveLift, DeriveGeneric #-} +module Metadata.Drasil.DrasilMeta where + +import Data.Aeson (decodeFileStrict, FromJSON, ToJSON) +import GHC.Generics (Generic) +import Language.Haskell.TH.Syntax (Lift, addDependentFile) +import Language.Haskell.TH (Exp, Q, runIO) + +{- + Thank you to the following people for their helpful public resources. + - 'leftaroundabout': https://stackoverflow.com/a/44369564/16760741 + - Mark Karpov: https://markkarpov.com/tutorial/th.html +-} + +-- | Create DrasilMeta newtype +newtype DrasilMeta = DrasilMeta {version :: String} deriving (Generic, Show, Lift) + +instance ToJSON DrasilMeta + +instance FromJSON DrasilMeta + +-- | Configures drasilMeta at compile-time +drasilMetaCfg :: Q Exp +drasilMetaCfg = do + let fp = "lib/Metadata/Drasil/DrasilMetadata.json" + maybeDM <- runIO (decodeFileStrict fp :: IO (Maybe DrasilMeta)) + addDependentFile fp + [|fromMaybe (error "could not read in the drasil metadata file") maybeDM|] + + diff --git a/code/drasil-metadata/lib/Metadata/Drasil/DrasilMetaCall.hs b/code/drasil-metadata/lib/Metadata/Drasil/DrasilMetaCall.hs new file mode 100644 index 0000000000..7548d7e2d2 --- /dev/null +++ b/code/drasil-metadata/lib/Metadata/Drasil/DrasilMetaCall.hs @@ -0,0 +1,13 @@ +{-#LANGUAGE TemplateHaskell#-} +module Metadata.Drasil.DrasilMetaCall (drasilMeta, DrasilMeta(..), watermark)where + +import Metadata.Drasil.DrasilMeta (drasilMetaCfg, DrasilMeta(..)) +import Data.Maybe (fromMaybe) + + +-- | Reads drasilMeta at compile-time +drasilMeta :: DrasilMeta +drasilMeta = $drasilMetaCfg + +watermark :: String +watermark = "Generated by Drasil " diff --git a/code/drasil-metadata/lib/Metadata/Drasil/DrasilMetadata.json b/code/drasil-metadata/lib/Metadata/Drasil/DrasilMetadata.json new file mode 100644 index 0000000000..4861dcf08c --- /dev/null +++ b/code/drasil-metadata/lib/Metadata/Drasil/DrasilMetadata.json @@ -0,0 +1,3 @@ +{ + "version": "v0.1-alpha" +} diff --git a/code/drasil-metadata/lib/Metadata/Drasil/README.md b/code/drasil-metadata/lib/Metadata/Drasil/README.md new file mode 100644 index 0000000000..2632e8851b --- /dev/null +++ b/code/drasil-metadata/lib/Metadata/Drasil/README.md @@ -0,0 +1,13 @@ +-------------------------------------------------- +### Summary of Folder Structure and File Contents +Last updated: Aug. 04, 2023 +-------------------------------------------------- + +**DrasilMeta** + - Contains functions to compile the DrasilMetadata at compile-time. + +**DrasilMetaCall** + - Reads DrasilMeta at compile-time + +**DrasilMetadata.json** + - Contains the metadata for Drasil. \ No newline at end of file diff --git a/code/drasil-metadata/lib/README.md b/code/drasil-metadata/lib/README.md index 429f4edc5e..18d06c4e64 100644 --- a/code/drasil-metadata/lib/README.md +++ b/code/drasil-metadata/lib/README.md @@ -1,8 +1,11 @@ -------------------------------------------------- ### Summary of Folder Structure and File Contents -Last updated: Sept. 15, 2021 +Last updated: Aug 04, 2023 -------------------------------------------------- **Data** - Contains very fundamental data for Drasil. It is meta in the sense that drasil-data (and drasil-theory) use it + +**Metadata** + - Contains very fundamental metadata for Drasil diff --git a/code/drasil-metadata/package.yaml b/code/drasil-metadata/package.yaml index a35b4b18ab..e55250752e 100644 --- a/code/drasil-metadata/package.yaml +++ b/code/drasil-metadata/package.yaml @@ -11,7 +11,10 @@ extra-source-files: [] dependencies: - base >= 4.7 && < 5 +- aeson +- template-haskell - drasil-lang +- drasil-utils ghc-options: - -Wall @@ -21,6 +24,7 @@ library: source-dirs: lib exposed-modules: - Data.Drasil.Domains + - Metadata.Drasil.DrasilMetaCall when: - condition: false other-modules: Paths_drasil_metadata diff --git a/code/drasil-printers/lib/Language/Drasil/HTML/CSS.hs b/code/drasil-printers/lib/Language/Drasil/HTML/CSS.hs index 84ba99c66d..31b7309630 100644 --- a/code/drasil-printers/lib/Language/Drasil/HTML/CSS.hs +++ b/code/drasil-printers/lib/Language/Drasil/HTML/CSS.hs @@ -66,9 +66,8 @@ makeCSS _ = vcat [ text " margin-left: auto;", text " margin-right: auto;}"], text "th, td {border: 1px solid black; padding: 0.5em;}", - text ".tdefn, .ddefn {width: 75%; margin-top: 1%; margin-bottom: 1%;}", - text ".tdefn th {width: 15%;}", - text ".ddefn th {width: 15%;}", + text ".tdefn, .ddefn, .gdefn, .idefn {width: 75%; margin-top: 1%; margin-bottom: 1%;}", + text ".tdefn th, .ddefn th, .gdefn th, .idefn th {width: 15%;}", text ".section {width: 80%; margin: 0 auto; text-align: left;}", vcat [ text ".code {", diff --git a/code/drasil-printers/lib/Language/Drasil/Log/Print.hs b/code/drasil-printers/lib/Language/Drasil/Log/Print.hs index fc7f871ee6..de36b6182f 100644 --- a/code/drasil-printers/lib/Language/Drasil/Log/Print.hs +++ b/code/drasil-printers/lib/Language/Drasil/Log/Print.hs @@ -94,7 +94,7 @@ mkTableDataDef pinfo = mkTableFromLenses pinfo (view dataDefnTable) "Data Definitions" "UID" "Term" "Symbol" (text . showUID) (sentenceDoc (pinfo ^. ckdb) (pinfo ^. stg) Nonlinear . phraseNP . view term) - (symbolDoc . flip L.symbol (pinfo ^. stg)) + (symbolDoc . flip L.symbol (pinfo ^. stg) . view defLhs) -- | Makes a table with all general definitions in the SRS. mkTableGenDef :: PrintingInformation -> Doc diff --git a/code/drasil-printers/lib/Language/Drasil/Markdown/CreateMd.hs b/code/drasil-printers/lib/Language/Drasil/Markdown/CreateMd.hs index 3591331757..c963658260 100644 --- a/code/drasil-printers/lib/Language/Drasil/Markdown/CreateMd.hs +++ b/code/drasil-printers/lib/Language/Drasil/Markdown/CreateMd.hs @@ -8,16 +8,13 @@ module Language.Drasil.Markdown.CreateMd ( import Prelude hiding ((<>)) import Text.PrettyPrint.HughesPJ (Doc, empty, isEmpty, vcat, text, (<+>), - (<>), comma, punctuate, hsep) -import Utils.Drasil.Document (drasilImage, contSep) + (<>), punctuate, hsep) import Language.Drasil.Printing.Helpers (upcase) - --- | Separates document sections. -type Separator = Doc +import Utils.Drasil -- | Combines a list of sentences into a final Doc, also appends end note. makeMd :: [Doc] -> Doc -makeMd = vcat . punctuate secSep . filtEmp +makeMd = vcat . punctuate secSep . filterEmpty -- | Example title, authors, and maybe purpose section. introInfo :: String -> [String] -> Maybe String -> Doc @@ -86,7 +83,7 @@ unsupOS = maybe empty (\uns-> regularSec (text "Unsupported Operating Systems") extLibSec:: [(String, String)] -> [String]-> Doc extLibSec libns libfps = let libs = addListToTuple libns libfps - formattedLibs = (hsep . punctuate contSep . filtEmp . + formattedLibs = (hsep . punctuate contSep . filterEmpty . map libStatment) libs in if isEmpty formattedLibs then empty else regularSec (text "External Libraries") formattedLibs @@ -140,10 +137,16 @@ introSec hd ms1 l descr = text "#" <+> hd <+> contSep <> (if l == 1 then text "> regularSec :: Doc -> Doc -> Doc regularSec hd ms = text "##" <+> hd <+> contSep <+> ms --- | Helper for 'makeMd' and 'extLibSec'. -filtEmp :: [Doc] -> [Doc] -filtEmp = filter (not . isEmpty) +-- Function to create the prefix for the path of the Drasil Logo +buildPath :: Int -> String +buildPath num = filter (/= ' ') $ unwords $ replicate num "../" + +-- | Drasil Tree icon. Uses HTML directly to format image since normal markdown doesn't support it. +drasilImage :: Int -> Doc +drasilImage num = alignImage (buildPath num ++ + "drasil-website/WebInfo/images/Icon.png") --- | Helper for authors and configuration files. -listToDoc :: [String] -> Doc -listToDoc = hsep . punctuate comma . map text +-- | Aligns an image to the center using HTML, since markdown doesn't support it. +alignImage :: FilePath -> Doc +alignImage img = text "
" <> contSep <> text ("") <> contSep <> text "
" <> contSep <> text ("") <> contSep <> text "
+ Drasil is a framework for generating all of the software artifacts from a stable knowledge base, focusing currently on scientific software. We welcome students and collaborators to assist us as we research optimal ways to extend Drasil's functionality. +
++ Navigate to the Quick Start Guide to see what Drasil can do. +
++ Workspace recommendations are available in the New Workspace Setup page. +
++ If you are interested in contributing to the project, please look at the Contributor's Guide as well as the Workflow page. +
++ If you are interested in creating your own project in Drasil, please look at the Creating Your Project in Drasil page. +
++ Debugging information can be found in the Debugging in Drasil page. +
++ Drasil is a framework for generating all of the software artifacts from a stable knowledge base, focusing currently on scientific software. The main goals are to reduce knowledge duplication and improve traceability. The artifacts are generated from a common knowledge-base using recipes written in a Domain-Specific Language (DSL). These recipes allow us to specify which pieces of knowledge should be used in which artifacts, how to transform them, and more. For more information on the design, documentation, useage, and specifics of Drasil, please visit the GitHub repository or the GitHub Wiki. +
++ This webpage is designed to contain the most up to date case study artifacts, Haddock documentation, and Drasil analysis from the Drasil repository. The case study artifacts include the Software Requirements Specification (SRS) for each case study, which specifies what the program sets out to achieve. The Haddock Documentation section contains the current documentation for the Drasil framework. The package dependency graphs shows the hierarchy of modules within each package. +
++ The following is a list of artifacts that Drasil currently generates: +
++ We hope to generate the following artifacts in the future: +
++ As described in the Information Encoding wiki page, Drasil uses specific terminology to address types of knowledge for the purpose of encoding information, since we know that we want to eventually generate words, sentences, paragraphs, whole documents with headings, references, formulas, tables, graphs, and code. This is done by trying to understand the basic 'units' of all artifacts, and methods for composing larger structures from these units. The removal of duplicate units is an important feature of this methodology. The basic building blocks of the methodology include different expressions for units with a specific meaning. These are built into ontologies of domains that address broader knowledge. Chunks form a fundamental part of such ontologies. +
++ As described in the Chunks wiki page, a chunk is a data type specialized in holding a specific type of information for a specific purpose so that knowledge may be used in generated models, definitions, and theories. Chunks are usually made up of several lower-level types that hold lower-lever information; when contained together, these pieces of lower-level information hold a new specific purpose. The structure of a chunk can be thought of as a wrapper of information, and this is all implemented using Haskell's record-type syntax. Recipes transform the acquired knowledge into a usable format. +
++ As described in the Recipes wiki page, recipes are instructions that unpackage necessary information from chunks and send that information to Drasil generators/printers to build complete artifacts. When an artifact needs to be changed, the recipe is modified to unpackage the additional necessary information from a chunk, or alternatively to omit unpackaging information that is no longer required. +
++ As described in the GOOL paper, this is a Generic Object-Oriented Language that provides intermediary assistance in code generation, allowing Drasil to more efficiently generate code in several languages, including Python, Java, C-Sharp, and C++. +
++ A list of papers and documents written about Drasil can be found in the Drasil Papers and Documents wiki page +
++ The development of Drasil follows an example-driven approach, with a current focus on creating Software Requirement Specifications (SRS). More specifically, Drasil's knowledge of the domain of Physics has seen significant growth through the creation of these examples, ranging from mechanics to thermodynamics. Each of the case studies implemented in Drasil contain their own generated PDF and HTML reports, and in some cases, their own generated code to solve the problem defined in their respective SRS documents. +
++ Drasil allows some design decisions to be made by the user when generating code. The table below summarizes the design decisions made for each case study, followed by a guide giving the meaning of the short-forms used in the table: +
+Case Study | +Modularity | +Implementation Type | +Logging | +Input Structure | +Constant Structure | +Constant Representation | +Real Number Representation | +
---|---|---|---|---|---|---|---|
DblPend | +C | +P | +NoL | +U | +B | +C | +D | +
GlassBR | +S | +P | +L | +B | +I | +C | +D | +
SWHSNoPCM | +C | +P | +NoL | +U | +B | +C | +D | +
PD_Controller | +C | +P | +NoL | +U | +B | +C | +D | +
Projectile_U_P_NoL_U_WI_V_D | +U | +P | +NoL | +U | +WI | +V | +D | +
Projectile_C_P_NoL_B_U_V_D | +C | +P | +NoL | +B | +U | +V | +D | +
Projectile_S_L_NoL_U_U_V_F | +S | +L | +NoL | +U | +U | +V | +F | +
Projectile_U_P_L_B_B_C_D | +U | +P | +L | +B | +B | +C | +D | +
Projectile_U_P_L_B_WI_V_F | +U | +P | +L | +B | +WI | +V | +F | +
+ The legend for the Case Studies Table is listed below according to column header: +
++ Drasil's framework is primariliy written in Haskell, so we use Haddock to document our code. The following link will take you to the current Haddock documentation for the Drasil framework. A variant with fully exposed modules is also available. +
++ This section contains an graphs and tables that may be used to analyze the structure of the Drasil framework. Here, we will explore the relationship between data types, classes, and instances of those classes within Drasil, as well as the structure of individual Drasil packages. +
++ This Data Table is generated by Drasil to keep track of all the different types, classes, and where they intersect through instances. The rows are organized in order of Drasil packages, modules, and data types. The data types are further separated by their composition; those labelled Data Type are completely new types created and used in Drasil, while Newtype Types are type synonyms. All of the classes in Drasil are defined as column headers, starting from Haskell-native classes like Eq and going through every unique Drasil-defined class. A box marked with 'YYYY' symbolizes the file location of where that particular data type is an instance of a particular class. There is also a downloadable version of the Data Table available as a .csv file. +
++ The following Table of Type and Class Instance Graphs is another artifact generated by Drasil. The type graphs explore the dependency of data types upon each other. These graphs include record-defined types, newtype wrappers, and data types built from other other types. For these graphs, a node with a black outline signifies that the type is not defined in that package, but still used in the creation of other types (this includes Haskell-native types since we do not redefine those). A red outline signifies that the type was created using Haskell's 'type' syntax, while dark green means the type was made using 'newtype' syntax. A purple border shows that the type uses constructor syntax and cyan is used for types written with record syntax. The arrow starts from the base types at the tip and follows through so that dependent types are placed at the tail. Usually, this means that those types at the tail may contain the type at the tip of the arrow. +
++ The class instance graphs aim to look at the structure of classes, data types, and the interactions between those two. Specifically, each arrow represents the given type as an instance of a given class. The tip of the arrow points to the class, and the tail specifies the type that is an instance of the tip's class. For clarity in analyzing the structure, classes defined in the graph's package are coloured magenta, classes that are used but not defined in the package are rendered pink (includes Haskell-native classes), and data types are rendered with a turquoise border. +
+Generated Type Graphs | +Generated Class Instance Graphs | +
---|---|
+ drasil-lang Types + | ++ drasil-lang Class Instances + | +
+ drasil-metadata Types + | ++ drasil-metadata Class Instances + | +
+ drasil-code Types + | ++ drasil-code Class Instances + | +
+ drasil-docLang Types + | ++ drasil-docLang Class Instances + | +
+ drasil-printers Types + | ++ drasil-printers Class Instances + | +
+ drasil-build Types + | ++ drasil-build Class Instances + | +
+ drasil-theory Types + | ++ drasil-theory Class Instances + | +
+ drasil-gool Types + | ++ drasil-gool Class Instances + | +
+ drasil-data Types + | ++ drasil-data Class Instances + | +
+ drasil-database Types + | ++ drasil-database Class Instances + | +
+ drasil-gen Types + | ++ drasil-gen Class Instances + | +
+ drasil-utils Types + | ++ drasil-utils Class Instances + | +
+ drasil-website Types + | ++ drasil-website Class Instances + | +
+ drasil-example Types + | ++ drasil-example Class Instances + | +
Type Graphs
++ The below list contains all of the different packages used to build the Drasil Framework. Each package and its dependencies are displayed in the form of a graph, with the tail of the arrow being the dependent module, and the tip of the arrow being the base module. In other words, the tip builds off of (or relies on) the tail to work. Links are available to a pdf version of each package's dependency graph at the bottom. For example, the graph for the website package is shown below. Each section is made from different modules that come together under the Drasil.Website.Body module and then are generated by Drasil.Website.Main. This result shows that the package structure has a pyramid-like hierarchy. +
++ The graph displayed below shows the dependencies between the packages used to build the Drasil Framework. +
+