-- | Defines concepts used in the field of software.
module Data.Drasil.Concepts.Software where

import Language.Drasil
import qualified Language.Drasil.Sentence.Combinators as S
import Drasil.Metadata.Documentation (srs)
import Drasil.Database (mkUid)

import Data.Drasil.Concepts.Computation (algorithm, dataStruct, inParam)
import Data.Drasil.Concepts.Documentation (input_, physical, physicalConstraint,
  softwareConstraint, quantity)
import Data.Drasil.Concepts.Math (equation)

-- * Common Software Concepts

-- | Collects all software-related concepts.
softwarecon :: [ConceptChunk]
softwarecon :: [ConceptChunk]
softwarecon = [ConceptChunk
correctness, ConceptChunk
verifiability, ConceptChunk
physLib,
  ConceptChunk
understandability, ConceptChunk
reusability, ConceptChunk
maintainability, ConceptChunk
portability,
  ConceptChunk
performance, ConceptChunk
accuracy, ConceptChunk
reliability]

c, errMsg, physLib, program :: ConceptChunk

c :: ConceptChunk
c       = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"c") (String -> NP
pn String
"C")
  (String -> Sentence
S String
"the C programming language")
physLib :: ConceptChunk
physLib = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"physLib") (String -> NP
cnIES String
"physics library")
  (String -> Sentence
S String
"a programming library which provides functions for modelling physical phenomenon")
program :: ConceptChunk
program = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"program") (String -> NP
cn' String
"program")
  (String -> Sentence
S String
"a series of coded software instructions to control the operation of a computer or other machine")
errMsg :: ConceptChunk
errMsg  = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"errMsg") (String -> NP
cn' String
"error message")
  (String -> Sentence
S String
"a message that indicates an incorrect instruction has been given, or that there is an error resulting from faulty software")

-- * Non-functional Requirements

accuracy, correctness, maintainability, performance, performanceSpd, portability,
  reliability, reusability, understandability, verifiability :: ConceptChunk

qualOfBeing :: String -> String
qualOfBeing :: String -> String
qualOfBeing String
s = String
"the quality or state of being" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
s

accuracy :: ConceptChunk
accuracy          = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"accuracy")          (String -> NP
nounPhraseSP String
"accuracy")
  (String -> Sentence
S (String -> Sentence) -> String -> Sentence
forall a b. (a -> b) -> a -> b
$ String -> String
qualOfBeing String
"correct or precise")

correctness :: ConceptChunk
correctness       = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"correctness")       (String -> NP
nounPhraseSP String
"correctness")
  (String -> Sentence
S (String -> Sentence) -> String -> Sentence
forall a b. (a -> b) -> a -> b
$ String -> String
qualOfBeing String
"free from error")

maintainability :: ConceptChunk
maintainability   = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"maintainability")   (String -> NP
nounPhraseSP String
"maintainability")
  (String -> Sentence
S String
"the probability of performing a successful repair action within a given time")

performance :: ConceptChunk
performance       = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"performance")       (String -> NP
nounPhraseSP String
"performance")
  (String -> Sentence
S String
"the action or process of carrying out or accomplishing an action, task, or function")

performanceSpd :: ConceptChunk
performanceSpd    = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"performanceSpd")    (String -> NP
cn' String
"performance speed")
  (String -> Sentence
S String
"the action or process of carrying out or accomplishing an action, task, or function quickly")

portability :: ConceptChunk
portability       = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"portability")       (String -> NP
nounPhraseSP String
"portability")
  (String -> Sentence
S String
"the ability of software to be transferred from one machine or system to another")

reliability :: ConceptChunk
reliability       = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"reliability")       (String -> NP
nounPhraseSP String
"reliability")
  (String -> Sentence
S (String
"the degree to which the result of a measurement, calculation," String -> String -> String
forall a. [a] -> [a] -> [a]
++
  String
"or specification can be depended on to be accurate"))

reusability :: ConceptChunk
reusability       = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"reusability")       (String -> NP
nounPhraseSP String
"reusability")
  (String -> Sentence
S String
"the use of existing assets in some form within the software product development process")

understandability :: ConceptChunk
understandability = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"understandability") (String -> NP
nounPhraseSP String
"understandability")
  (String -> Sentence
S (String -> Sentence) -> String -> Sentence
forall a b. (a -> b) -> a -> b
$ String -> String
qualOfBeing String
"understandable")

verifiability :: ConceptChunk
verifiability     = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"verifiability")     (String -> NP
nounPhraseSP String
"verifiability")
  (String -> Sentence
S (String -> Sentence) -> String -> Sentence
forall a b. (a -> b) -> a -> b
$ String -> String
qualOfBeing String
"capable of being verified, confirmed, or substantiated")

-- * Module Concepts

-- MODULES Concepts (Maybe move to D.D.C.Software.Modules ?)

--FIXME: "hiding" is not a noun.
hwHiding :: ConceptChunk
hwHiding :: ConceptChunk
hwHiding = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"hwHiding") (String -> NP
cn String
"hardware hiding")
  (String -> Sentence
S (String
"hides the exact details of the hardware, and provides a uniform interface" String -> String -> String
forall a. [a] -> [a] -> [a]
++
   String
" for the rest of the system to use"))

modBehavHiding :: ConceptChunk
modBehavHiding :: ConceptChunk
modBehavHiding = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"modBehavHiding") (String -> NP
cn String
"behaviour hiding") ([Sentence] -> Sentence
foldlSent_
  [String -> Sentence
S String
"includes programs that provide externally visible behaviour of the",
   String -> Sentence
S String
"system as specified in the", CI -> Sentence
forall n. NamedIdea n => n -> Sentence
phrase CI
srs, Sentence -> Sentence
sParen (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ CI -> Sentence
forall c. Idea c => c -> Sentence
short CI
srs Sentence -> Sentence -> Sentence
+:+. String -> Sentence
S String
"documents",
   String -> Sentence
S String
"This module serves as a communication layer between the hardware-hiding module",
   String -> Sentence
S String
"and the software decision module. The programs in this module will need",
   String -> Sentence
S String
"to change if there are changes in the", CI -> Sentence
forall c. Idea c => c -> Sentence
short CI
srs])

modControl :: ConceptChunk
modControl :: ConceptChunk
modControl = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"modControl") (String -> NP
cn' String
"control module") (String -> Sentence
S String
"provides the main program")

modSfwrDecision :: ConceptChunk
modSfwrDecision :: ConceptChunk
modSfwrDecision = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"modSfwrDecision") (String -> NP
cn' String
"software decision module") ([Sentence] -> Sentence
foldlSent_
  [String -> Sentence
S String
"includes", IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
plural IdeaDict
dataStruct Sentence -> Sentence -> Sentence
`S.and_` ConceptChunk -> Sentence
forall n. NamedIdea n => n -> Sentence
plural ConceptChunk
algorithm,
   String -> Sentence
S String
"used in the system that do not provide direct interaction with the user"])

modInputFormat :: ConceptChunk
modInputFormat :: ConceptChunk
modInputFormat = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"modInputFormat") (String -> NP
cn' String
"input format module")
  (String -> Sentence
S String
"converts the input data into the data structure used by the input parameters module")

modInputParam :: ConceptChunk
modInputParam :: ConceptChunk
modInputParam = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"modInputParam") (String -> NP
cn' String
"input parameter module") ([Sentence] -> Sentence
foldlSent_
  [String -> Sentence
S String
"stores the parameters needed for the program, including" Sentence -> Sentence -> Sentence
+:+. SepType -> FoldType -> [Sentence] -> Sentence
foldlList SepType
Comma FoldType
List
   [String -> Sentence
S String
"material properties", String -> Sentence
S String
"processing conditions", String -> Sentence
S String
"numerical parameters"],
   String -> Sentence
S String
"The values can be read as needed. This module knows how many parameters it stores"])

modInputConstraint :: ConceptChunk
modInputConstraint :: ConceptChunk
modInputConstraint = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"modInputConstraint") (String -> NP
cn' String
"input constraint module")
  (String -> Sentence
S (String
"defines the constraints on the input data and gives an error if " String -> String -> String
forall a. [a] -> [a] -> [a]
++
   String
"a constraint is violated"))

modInputVerif :: ConceptChunk
modInputVerif :: ConceptChunk
modInputVerif = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"modInputVerif") (String -> NP
cn' String
"input verification module") ([Sentence] -> Sentence
foldlSent
  [String -> Sentence
S String
"verifies that the", IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
plural IdeaDict
inParam, String -> Sentence
S String
"comply with", IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
phrase IdeaDict
physical Sentence -> Sentence -> Sentence
`S.and_`
   IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
plural IdeaDict
softwareConstraint, String -> Sentence
S String
"Throws an error if a parameter violates a" Sentence -> Sentence -> Sentence
+:+.
   IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
phrase IdeaDict
physicalConstraint, String -> Sentence
S String
"Throws a warning if a parameter violates a",
   IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
phrase IdeaDict
softwareConstraint])

modDerivedVal :: ConceptChunk
modDerivedVal :: ConceptChunk
modDerivedVal = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"modDerivedVal") (String -> NP
cn' String
"derived value module") ([Sentence] -> Sentence
foldlSent_
  [String -> Sentence
S String
"defines the", ConceptChunk -> Sentence
forall n. NamedIdea n => n -> Sentence
plural ConceptChunk
equation, String -> Sentence
S String
"transforming the initial", IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
plural IdeaDict
input_,
   String -> Sentence
S String
"into derived", IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
plural IdeaDict
quantity])

modInterpolation :: ConceptChunk
modInterpolation :: ConceptChunk
modInterpolation = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"modInterpolation") (String -> NP
cn String
"interpolation module") ([Sentence] -> Sentence
foldlSent_
  [String -> Sentence
S String
"provides the", ConceptChunk -> Sentence
forall n. NamedIdea n => n -> Sentence
plural ConceptChunk
equation, String -> Sentence
S String
"that take the", IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
plural IdeaDict
inParam Sentence -> Sentence -> Sentence
`S.and_`
   String -> Sentence
S String
"interpolation data" Sentence -> Sentence -> Sentence
`S.and_` String -> Sentence
S String
"return an interpolated value"])

modInterpDatum :: ConceptChunk
modInterpDatum :: ConceptChunk
modInterpDatum = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"modInterpDatum") (String -> NP
cn String
"interpolation datum module") ([Sentence] -> Sentence
foldlSent_
  [String -> Sentence
S String
"converts the input interpolation data into the", IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
phrase IdeaDict
dataStruct,
   String -> Sentence
S String
"used by the", ConceptChunk -> Sentence
forall n. NamedIdea n => n -> Sentence
phrase ConceptChunk
modInterpolation])

{-- Concept Chunks for Modules  --}

modSeqServ :: ConceptChunk
modSeqServ :: ConceptChunk
modSeqServ = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"modSeqServ") (String -> NP
cn' String
"sequence data structure")
  (String -> Sentence
S String
"Provides array manipulation operations, such as" Sentence -> Sentence -> Sentence
+:+ SepType -> FoldType -> [Sentence] -> Sentence
foldlList SepType
Comma FoldType
List
   [String -> Sentence
S String
"building an array", String -> Sentence
S String
"accessing a specific entry", String -> Sentence
S String
"slicing an array"])

modLinkedServ :: ConceptChunk
modLinkedServ :: ConceptChunk
modLinkedServ = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"modLinkedServ") (String -> NP
cn' String
"linked data structure")
  (String -> Sentence
S String
"Provides tree manipulation operations, such as" Sentence -> Sentence -> Sentence
+:+ SepType -> FoldType -> [Sentence] -> Sentence
foldlList SepType
Comma FoldType
List
   [String -> Sentence
S String
"building a tree", String -> Sentence
S String
"accessing a specific entry"])

modAssocServ :: ConceptChunk
modAssocServ :: ConceptChunk
modAssocServ = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"modAssocServ") (String -> NP
cn' String
"associative data structure")
  (String -> Sentence
S String
"Provides operations on hash tables, such as" Sentence -> Sentence -> Sentence
+:+ SepType -> FoldType -> [Sentence] -> Sentence
foldlList SepType
Comma FoldType
List
   [String -> Sentence
S String
"building a hash table", String -> Sentence
S String
"accessing a specific entry"])

modVectorServ :: ConceptChunk
modVectorServ :: ConceptChunk
modVectorServ = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"modVectorServ") (String -> NP
cn' String
"vector")
  (String -> Sentence
S String
"Provides vector operations such as" Sentence -> Sentence -> Sentence
+:+ SepType -> FoldType -> [Sentence] -> Sentence
foldlList SepType
Comma FoldType
List [String -> Sentence
S String
"addition",
   String -> Sentence
S String
"scalar and vector multiplication", String -> Sentence
S String
"dot and cross products", String -> Sentence
S String
"rotations"])

modPlotDesc :: ConceptChunk
modPlotDesc :: ConceptChunk
modPlotDesc = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"modPlotDesc") (String -> NP
cn' String
"plotting") (String -> Sentence
S String
"provides a plot function")

modOutputfDescFun :: Sentence -> ConceptChunk
modOutputfDescFun :: Sentence -> ConceptChunk
modOutputfDescFun Sentence
desc = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"modOutputfDescFun") (String -> NP
cn' String
"output format")
  (String -> Sentence
S String
"outputs the results of the calculations, including the" Sentence -> Sentence -> Sentence
+:+ Sentence
desc)

-- ODE Solver Module
modOdeDesc :: ConceptChunk
modOdeDesc :: ConceptChunk
modOdeDesc = UID -> NP -> Sentence -> ConceptChunk
cncpt''' (String -> UID
mkUid String
"modOdeDesc") (String -> NP
nounPhraseSP String
"ODE solver")
  (String -> Sentence
S String
"provides solvers that take the" Sentence -> Sentence -> Sentence
+:+ SepType -> FoldType -> [Sentence] -> Sentence
foldlList SepType
Comma FoldType
List
   [String -> Sentence
S String
"governing equation", String -> Sentence
S String
"initial conditions", String -> Sentence
S String
"numerical parameters"] Sentence -> Sentence -> Sentence
`S.and_`
   String -> Sentence
S String
"solve them")