Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Defines a language for specifying external library use scenarios
Synopsis
- type ExternalLibrary = [StepGroup]
- data Step
- = Call FunctionInterface
- | Loop (NonEmpty FunctionInterface) ([CodeExpr] -> Condition) (NonEmpty Step)
- | Statement ([CodeVarChunk] -> [CodeExpr] -> FuncStmt)
- data FunctionInterface = FI (NonEmpty Requires) FuncType CodeFuncChunk [Argument] (Maybe Result)
- data Result
- data Argument = Arg (Maybe NamedArgument) ArgumentInfo
- data ArgumentInfo
- = LockedArg CodeExpr
- | Basic Space (Maybe CodeVarChunk)
- | Fn CodeFuncChunk [Parameter] Step
- | Class [Requires] Description CodeVarChunk CodeFuncChunk ClassInfo
- | Record (NonEmpty Requires) CodeFuncChunk CodeVarChunk [CodeVarChunk]
- data Parameter
- data ClassInfo
- = Regular [MethodInfo]
- | Implements String [MethodInfo]
- data MethodInfo
- = CI Description [Parameter] [Step]
- | MI CodeFuncChunk Description [Parameter] (Maybe Description) (NonEmpty Step)
- data FuncType
- externalLib :: [StepGroup] -> ExternalLibrary
- choiceSteps :: [[Step]] -> StepGroup
- choiceStep :: [Step] -> StepGroup
- mandatoryStep :: Step -> StepGroup
- mandatorySteps :: [Step] -> StepGroup
- callStep :: FunctionInterface -> Step
- libFunction :: Requires -> CodeFuncChunk -> [Argument] -> FunctionInterface
- libMethod :: Requires -> CodeVarChunk -> CodeFuncChunk -> [Argument] -> FunctionInterface
- libFunctionWithResult :: Requires -> CodeFuncChunk -> [Argument] -> CodeVarChunk -> FunctionInterface
- libMethodWithResult :: Requires -> CodeVarChunk -> CodeFuncChunk -> [Argument] -> CodeVarChunk -> FunctionInterface
- libConstructor :: Requires -> CodeFuncChunk -> [Argument] -> CodeVarChunk -> FunctionInterface
- libConstructorMultiReqs :: [Requires] -> CodeFuncChunk -> [Argument] -> CodeVarChunk -> FunctionInterface
- constructAndReturn :: Requires -> CodeFuncChunk -> [Argument] -> FunctionInterface
- lockedArg :: CodeExpr -> Argument
- lockedNamedArg :: NamedArgument -> CodeExpr -> Argument
- inlineArg :: Space -> Argument
- inlineNamedArg :: NamedArgument -> Space -> Argument
- preDefinedArg :: CodeVarChunk -> Argument
- preDefinedNamedArg :: NamedArgument -> CodeVarChunk -> Argument
- functionArg :: CodeFuncChunk -> [Parameter] -> Step -> Argument
- customObjArg :: [Requires] -> Description -> CodeVarChunk -> CodeFuncChunk -> ClassInfo -> Argument
- recordArg :: Requires -> CodeFuncChunk -> CodeVarChunk -> [CodeVarChunk] -> Argument
- lockedParam :: CodeVarChunk -> Parameter
- unnamedParam :: Space -> Parameter
- customClass :: [MethodInfo] -> ClassInfo
- implementation :: String -> [MethodInfo] -> ClassInfo
- constructorInfo :: CodeFuncChunk -> [Parameter] -> [Step] -> MethodInfo
- methodInfo :: CodeFuncChunk -> Description -> [Parameter] -> Description -> [Step] -> MethodInfo
- methodInfoNoReturn :: CodeFuncChunk -> Description -> [Parameter] -> [Step] -> MethodInfo
- appendCurrSol :: CodeExpr -> Step
- populateSolList :: CodeVarChunk -> CodeVarChunk -> CodeVarChunk -> [Step]
- assignArrayIndex :: Step
- assignSolFromObj :: CodeVarChunk -> Step
- initSolListFromArray :: CodeVarChunk -> Step
- initSolListWithVal :: Step
- solveAndPopulateWhile :: FunctionInterface -> CodeVarChunk -> CodeVarChunk -> FunctionInterface -> CodeVarChunk -> Step
- returnExprList :: Step
- fixedReturn :: CodeExpr -> Step
- fixedReturn' :: Step
- initSolWithVal :: Step
Documentation
type ExternalLibrary = [StepGroup] Source #
External library is a group of Step
s
A step can be a call to an external library function or method.
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.
The result of a function call can be assigned to a variable or returned.
An argument may contain a named argument and argument information.
data ArgumentInfo Source #
Determines the context needed for an argument to work.
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 |
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. |
Function parameter may or may not be dependent on use case.
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).
CI Description [Parameter] [Step] | |
MI CodeFuncChunk Description [Parameter] (Maybe Description) (NonEmpty Step) | Method, description, known parameters, maybe return description, body. |
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.
callStep :: FunctionInterface -> Step Source #
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.
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.
methodInfo :: CodeFuncChunk -> Description -> [Parameter] -> Description -> [Step] -> MethodInfo Source #
Specifies a method.
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.