drasil-code-0.1.9.0: A framework for code and document generation for scientific software - Code SubPackage
Safe HaskellNone
LanguageGHC2024

Language.Drasil.Code.Imperative.Modules

Synopsis

Documentation

genMain :: OOProg r prg file mod cls stvr mthd attch vis param bod block stmt var scope val binder typ => GenState (FS (r file)) Source #

Generates a controller module.

genMainProc :: (NativeVector r val typ, ProcProg r prg file mod mthd vis param bod block stmt var scope val binder typ) => GenState (FS (r file)) Source #

Generates a controller module.

genMainFunc :: OOProg r prg file mod cls stvr mthd attch vis param bod block stmt var scope val binder typ => GenState (Maybe (MS (r mthd))) Source #

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 constraints, calculating outputs, and printing outputs. Returns Nothing if the user chose to generate a library.

genMainFuncProc :: forall {k} r (block :: k) (stmt :: k) (bod :: k) (typ :: k) (val :: k) (scope :: k) (var :: k) (binder :: k) (mthd :: k) (vis :: k) (param :: k). (BlockSym r block stmt, BodySym r bod block, TypeSym r typ, ValueSym r val typ, CommandLineArgs r val, Literal r val typ, MathConstant r val, ScopeSym r scope, VariableSym r var typ, VariableValue r var val, BooleanExpression r val, Comparison r val, NumericExpression r val, ValueExpression r var val binder typ, MultiStatement r stmt, ValueStatement r stmt val, DeclStatement r bod stmt var scope val, FuncAppStatement r stmt var val, Argument r val, List r val, NativeVector r val typ, Reference r val, Set r val, MethodSym r mthd vis param bod var typ, TypeElim r typ) => GenState (Maybe (MS (r mthd))) Source #

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 constraints, calculating outputs, and printing outputs. Returns Nothing if the user chose to generate a library.

genInputClass :: OOProg r prg file mod cls stvr mthd attch vis param bod block stmt var scope val binder typ => ClassType -> GenState (Maybe (CS (r cls))) Source #

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 variables. If the InputParameters constructor is also exported, then the generated class also contains the input-related functions as private methods.

genInputDerived :: OOProg r prg file mod cls stvr mthd attch vis param bod block stmt var scope val binder typ => VisibilityTag -> GenState (Maybe (MS (r mthd))) Source #

Generates a function for calculating derived inputs.

genInputDerivedProc :: forall {k} r (block :: k) (stmt :: k) (bod :: k) (typ :: k) (val :: k) (scope :: k) (var :: k) (binder :: k) (vis :: k) (mthd :: k) (param :: k). (BlockSym r block stmt, BodySym r bod block, TypeSym r typ, ValueSym r val typ, NativeVector r val typ, Literal r val typ, MathConstant r val, ScopeSym r scope, VariableSym r var typ, VariableValue r var val, BooleanExpression r val, Comparison r val, NumericExpression r val, ValueExpression r var val binder typ, Argument r val, Array r var val, List r val, Reference r val, Set r val, VisibilitySym r vis, MultiStatement r stmt, DeclStatement r bod stmt var scope val, AssignStatement r stmt var val, ControlStatement r bod stmt var val, StringStatement r stmt var val, FileHandling r stmt var val, PrintFile r stmt val, ReadFile r stmt var val, MethodSym r mthd vis param bod var typ, TypeElim r typ, VariableElim r var typ) => VisibilityTag -> GenState (Maybe (MS (r mthd))) Source #

Generates a function for calculating derived inputs.

genInputMod :: OOProg r prg file mod cls stvr mthd attch vis param bod block stmt var scope val binder typ => GenState [FS (r file)] Source #

Generates a single module containing all input-related components.

genInputModProc :: (NativeVector r val typ, ProcProg r prg file mod mthd vis param bod block stmt var scope val binder typ) => GenState [FS (r file)] Source #

Generates a single module containing all input-related components.

genInputConstraints :: OOProg r prg file mod cls stvr mthd attch vis param bod block stmt var scope val binder typ => VisibilityTag -> GenState (Maybe (MS (r mthd))) Source #

Generates function that checks constraints on the input.

genInputConstraintsProc :: forall {k} r (block :: k) (stmt :: k) (bod :: k) (typ :: k) (val :: k) (scope :: k) (var :: k) (binder :: k) (param :: k) (vis :: k) (mthd :: k). (BlockSym r block stmt, BodySym r bod block, TypeSym r typ, ValueSym r val typ, Literal r val typ, MathConstant r val, ScopeSym r scope, VariableSym r var typ, VariableValue r var val, BooleanExpression r val, Comparison r val, NumericExpression r val, ValueExpression r var val binder typ, Argument r val, NativeVector r val typ, Reference r val, Set r val, List r val, ParameterSym r param var, VisibilitySym r vis, EmptyStatement r stmt, MultiStatement r stmt, DeclStatement r bod stmt var scope val, PrintConsole r stmt val, FileHandling r stmt var val, PrintFile r stmt val, ControlStatement r bod stmt var val, MethodSym r mthd vis param bod var typ, TypeElim r typ, VariableElim r var typ) => VisibilityTag -> GenState (Maybe (MS (r mthd))) Source #

Generates function that checks constraints on the input.

genInputFormat :: OOProg r prg file mod cls stvr mthd attch vis param bod block stmt var scope val binder typ => VisibilityTag -> GenState (Maybe (MS (r mthd))) Source #

| Generates a function for reading inputs from a file.

genInputFormatProc :: forall {k} r (block :: k) (stmt :: k) (bod :: k) (typ :: k) (val :: k) (scope :: k) (var :: k) (binder :: k) (vis :: k) (mthd :: k) (param :: k). (BlockSym r block stmt, BodySym r bod block, TypeSym r typ, ValueSym r val typ, NativeVector r val typ, Literal r val typ, MathConstant r val, ScopeSym r scope, VariableSym r var typ, VariableValue r var val, BooleanExpression r val, Comparison r val, NumericExpression r val, ValueExpression r var val binder typ, VisibilitySym r vis, MultiStatement r stmt, DeclStatement r bod stmt var scope val, ControlStatement r bod stmt var val, StringStatement r stmt var val, FileHandling r stmt var val, PrintFile r stmt val, ReadFile r stmt var val, Argument r val, List r val, ListStatement r stmt val, Reference r val, Set r val, MethodSym r mthd vis param bod var typ, TypeElim r typ, VariableElim r var typ) => VisibilityTag -> GenState (Maybe (MS (r mthd))) Source #

| Generates a function for reading inputs from a file.

genConstMod :: OOProg r prg file mod cls stvr mthd attch vis param bod block stmt var scope val binder typ => GenState [FS (r file)] Source #

Generates a module containing the class where constants are stored.

checkConstClass :: GenState Bool Source #

Checks if a class is needed to store constants, i.e. if constants are mapped to the constants class in the class definition map.

genConstClass :: OOProg r prg file mod cls stvr mthd attch vis param bod block stmt var scope val binder typ => ClassType -> GenState (Maybe (CS (r cls))) Source #

Generates a class to store constants, if constants are mapped to the Constants class in the class definition map, otherwise returns Nothing.

genCalcMod :: OOProg r prg file mod cls stvr mthd attch vis param bod block stmt var scope val binder typ => GenState (FS (r file)) Source #

Generates a module containing calculation functions.

genCalcModProc :: (NativeVector r val typ, ProcProg r prg file mod mthd vis param bod block stmt var scope val binder typ) => GenState (FS (r file)) Source #

Generates a module containing calculation functions.

genCalcFunc :: OOProg r prg file mod cls stvr mthd attch vis param bod block stmt var scope val binder typ => CodeDefinition -> GenState (MS (r mthd)) Source #

Generates a calculation function corresponding to the CodeDefinition. For solving ODEs, the ExtLibState containing the information needed to generate code is found by looking it up in the external library map.

genCalcFuncProc :: forall {k} r (block :: k) (stmt :: k) (bod :: k) (typ :: k) (val :: k) (scope :: k) (var :: k) (binder :: k) (param :: k) (vis :: k) (mthd :: k). (BlockSym r block stmt, BodySym r bod block, TypeSym r typ, ValueSym r val typ, NativeVector r val typ, Literal r val typ, MathConstant r val, ScopeSym r scope, VariableSym r var typ, VariableValue r var val, BooleanExpression r val, Comparison r val, NumericExpression r val, ValueExpression r var val binder typ, Argument r val, Array r var val, List r val, ListStatement r stmt val, Reference r val, Set r val, ParameterSym r param var, VisibilitySym r vis, MultiStatement r stmt, ValueStatement r stmt val, DeclStatement r bod stmt var scope val, AssignStatement r stmt var val, ControlStatement r bod stmt var val, StringStatement r stmt var val, FileHandling r stmt var val, PrintFile r stmt val, ReadFile r stmt var val, MethodSym r mthd vis param bod var typ, TypeElim r typ, VariableElim r var typ) => CodeDefinition -> GenState (MS (r mthd)) Source #

Generates a calculation function corresponding to the CodeDefinition. For solving ODEs, the ExtLibState containing the information needed to generate code is found by looking it up in the external library map.

genOutputMod :: OOProg r prg file mod cls stvr mthd attch vis param bod block stmt var scope val binder typ => GenState [FS (r file)] Source #

Generates a module containing the function for printing outputs.

genOutputModProc :: (NativeVector r val typ, ProcProg r prg file mod mthd vis param bod block stmt var scope val binder typ) => GenState [FS (r file)] Source #

Generates a module containing the function for printing outputs.

genOutputFormat :: OOProg r prg file mod cls stvr mthd attch vis param bod block stmt var scope val binder typ => GenState (Maybe (MS (r mthd))) Source #

Generates a function for printing output values.

genOutputFormatProc :: forall {k} r (block :: k) (stmt :: k) (bod :: k) (typ :: k) (val :: k) (scope :: k) (var :: k) (binder :: k) (vis :: k) (param :: k) (mthd :: k). (BlockSym r block stmt, BodySym r bod block, TypeSym r typ, ValueSym r val typ, NativeVector r val typ, Literal r val typ, MathConstant r val, ScopeSym r scope, VariableSym r var typ, VariableValue r var val, BooleanExpression r val, Comparison r val, NumericExpression r val, ValueExpression r var val binder typ, Argument r val, List r val, Reference r val, Set r val, VisibilitySym r vis, ParameterSym r param var, MultiStatement r stmt, DeclStatement r bod stmt var scope val, ControlStatement r bod stmt var val, FileHandling r stmt var val, PrintFile r stmt val, MethodSym r mthd vis param bod var typ, TypeElim r typ, VariableElim r var typ) => GenState (Maybe (MS (r mthd))) Source #

Generates a function for printing output values.

genSampleInput :: Applicative r => GenState (Maybe (r FileLayout)) Source #

Generates a sample input file compatible with the generated program, if the user chose to.