drasil-code-0.1.9.0: A framework for code and document generation for scientific software - Code SubPackage
Safe HaskellSafe-Inferred
LanguageHaskell2010

Language.Drasil.Code.ExternalLibrary

Description

Defines a language for specifying external library use scenarios

Synopsis

Documentation

type ExternalLibrary = [StepGroup] Source #

External library is a group of Steps

data Step Source #

A step can be a call to an external library function or method.

Constructors

Call FunctionInterface 
Loop (NonEmpty FunctionInterface) ([CodeExpr] -> Condition) (NonEmpty Step)

A while loop. The function calls in the condition, other conditions, and steps for the body of the loop.

Statement ([CodeVarChunk] -> [CodeExpr] -> FuncStmt) 

data FunctionInterface Source #

The first item in the Requires list should be where the function being called is defined.

Constructors

FI (NonEmpty Requires) FuncType CodeFuncChunk [Argument] (Maybe Result) 

data Result Source #

The result of a function call can be assigned to a variable or returned.

Constructors

Assign CodeVarChunk 
Return 

data Argument Source #

An argument may contain a named argument and argument information.

data ArgumentInfo Source #

Determines the context needed for an argument to work.

Constructors

LockedArg CodeExpr

An argument not dependent on use case.

Basic Space (Maybe CodeVarChunk)

An argument dependent on the use case. Maybe is the variable if it needs to be declared and defined prior to calling.

Fn CodeFuncChunk [Parameter] Step

A function-type argument, with a single Step for the body.

Class [Requires] Description CodeVarChunk CodeFuncChunk ClassInfo

An argument that is an object of a class that must be implemented in the calling program. Parameters: Requires, description, object, constructor, class info.

Record (NonEmpty Requires) CodeFuncChunk CodeVarChunk [CodeVarChunk]

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. First Require should be where the record type is defined.

data Parameter Source #

Function parameter may or may not be dependent on use case.

data ClassInfo Source #

For classes that need to be generated in the calling program. May be a regular class or a class that implements an interface from the external library.

data MethodInfo Source #

Constructor: description, known parameters, body. (CodeFuncChunk for constructor is not here because it is higher up in the AST, at the Class node).

Constructors

CI Description [Parameter] [Step] 
MI CodeFuncChunk Description [Parameter] (Maybe Description) (NonEmpty Step)

Method, description, known parameters, maybe return description, body.

data FuncType Source #

Function type may be a function, a method, or a constructor.

externalLib :: [StepGroup] -> ExternalLibrary Source #

Specifies an external library.

choiceSteps :: [[Step]] -> StepGroup Source #

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.

choiceStep :: [Step] -> StepGroup Source #

To be used when there are multiple options for a single step, where a use-case-specific factor decides which step to use.

mandatoryStep :: Step -> StepGroup Source #

Specifies a step which must exist in some form in every use case.

mandatorySteps :: [Step] -> StepGroup Source #

Specifies multiple consecutive steps that all must exist in some form in every use case.

libFunction :: Requires -> CodeFuncChunk -> [Argument] -> FunctionInterface Source #

Specifies a call to an external library function.

libMethod :: Requires -> CodeVarChunk -> CodeFuncChunk -> [Argument] -> FunctionInterface Source #

Specifies a call to an external library method.

libFunctionWithResult :: Requires -> CodeFuncChunk -> [Argument] -> CodeVarChunk -> FunctionInterface Source #

Specifies a call to an external library function, where the result is assigned to a variable.

libMethodWithResult :: Requires -> CodeVarChunk -> CodeFuncChunk -> [Argument] -> CodeVarChunk -> FunctionInterface Source #

Specifies a call to an external library method, where the result is assigned to a variable.

libConstructor :: Requires -> CodeFuncChunk -> [Argument] -> CodeVarChunk -> FunctionInterface Source #

Specifies a call to an external library constructor, where the result is assigned to a variable.

libConstructorMultiReqs :: [Requires] -> CodeFuncChunk -> [Argument] -> CodeVarChunk -> FunctionInterface Source #

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.

constructAndReturn :: Requires -> CodeFuncChunk -> [Argument] -> FunctionInterface Source #

Specifies a call to an external library constructor, where the result is returned.

lockedArg :: CodeExpr -> Argument Source #

Specifies an argument that is not use-case-dependent.

lockedNamedArg :: NamedArgument -> CodeExpr -> Argument Source #

Specifies a named argument that is not use-case-dependent.

inlineArg :: Space -> Argument Source #

Specifies a use-case-dependent argument whose value can be inlined in the call.

inlineNamedArg :: NamedArgument -> Space -> Argument Source #

Specifies a use-case-dependent named argument whose value can be inlined in the call.

preDefinedArg :: CodeVarChunk -> Argument Source #

Specifies use-case-dependent argument whose value must be assigned to a variable before being passed in the call.

preDefinedNamedArg :: NamedArgument -> CodeVarChunk -> Argument Source #

Specifies use-case-dependent named argument whose value must be assigned to a variable before being passed in the call.

functionArg :: CodeFuncChunk -> [Parameter] -> Step -> Argument Source #

Specifies a function type argument, where the body consists of a single step.

customObjArg :: [Requires] -> Description -> CodeVarChunk -> CodeFuncChunk -> ClassInfo -> Argument Source #

Specifies an argument that is an object of a class that must be defined in the calling program.

recordArg :: Requires -> CodeFuncChunk -> CodeVarChunk -> [CodeVarChunk] -> Argument Source #

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 in the calling program.

lockedParam :: CodeVarChunk -> Parameter Source #

Specifies a use-case-independent parameter.

unnamedParam :: Space -> Parameter Source #

Specifies a parameter whose name depends on the use case.

customClass :: [MethodInfo] -> ClassInfo Source #

Specifies a class that must be implemented in the calling program.

implementation :: String -> [MethodInfo] -> ClassInfo Source #

Specifies an implementation of an interface from the external library.

constructorInfo :: CodeFuncChunk -> [Parameter] -> [Step] -> MethodInfo Source #

Specifies a constructor.

methodInfoNoReturn :: CodeFuncChunk -> Description -> [Parameter] -> [Step] -> MethodInfo Source #

Specifies a method that does not return anything.

appendCurrSol :: CodeExpr -> Step Source #

Specifies a statement where a current solution is appended to a solution list.

populateSolList :: CodeVarChunk -> CodeVarChunk -> CodeVarChunk -> [Step] Source #

Specifies a statement where a solution list is populated by iterating through a solution array.

assignArrayIndex :: Step Source #

Specifies statements where every index of an array is assigned a value.

assignSolFromObj :: CodeVarChunk -> Step Source #

Specifies a statement where a solution is assigned from the field of an object.

initSolListFromArray :: CodeVarChunk -> Step Source #

Specifies a statement where a solution list is initialized with the first element of an array.

initSolListWithVal :: Step Source #

Specifies a statement where a solution list is initialized with the first value.

solveAndPopulateWhile :: FunctionInterface -> CodeVarChunk -> CodeVarChunk -> FunctionInterface -> CodeVarChunk -> Step Source #

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.

returnExprList :: Step Source #

Specifies a statement where a list is returned, where each value of the list is explicitly defined.

fixedReturn :: CodeExpr -> Step Source #

Specifies a use-case-independent statement that returns a fixed value.

fixedReturn' :: Step Source #

Specifies a use-case-dependent statement that returns a non-fixed value.

initSolWithVal :: Step Source #

Specifies a statement where a single solution is initialized with a value.