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

Language.Drasil.Chunk.Code

Description

Defines chunk types for use in code generation.

Synopsis

Documentation

class CodeIdea c where #

A CodeIdea must include some code and its name.

Methods

codeName :: c -> String #

Name of the idea.

codeChunk :: c -> CodeChunk #

Code chunk associated with the idea.

Instances

Instances details
CodeIdea CodeDefinition Source #

Finds the code name of a CodeDefinition. Function CodeDefinitions are named with the function prefix to distinguish them from the corresponding variable version.

Instance details

Defined in Language.Drasil.Chunk.CodeDefinition

CodeIdea ParameterChunk Source #

Finds the code name and CodeChunk of a ParameterChunk.

Instance details

Defined in Language.Drasil.Chunk.Parameter

CodeIdea CodeChunk Source #

Finds the code name of a CodeChunk.

Instance details

Defined in Language.Drasil.Chunk.Code

CodeIdea CodeFuncChunk Source #

Finds the code name and CodeChunk within a CodeFuncChunk.

Instance details

Defined in Language.Drasil.Chunk.Code

CodeIdea CodeVarChunk Source #

Finds the code name and CodeChunk within a CodeVarChunk.

Instance details

Defined in Language.Drasil.Chunk.Code

data CodeChunk #

Basic chunk representation in the code generation context. Contains a QuantityDict and the kind of code (variable or function).

Constructors

CodeC 

Instances

Instances details
CodeIdea CodeChunk Source #

Finds the code name of a CodeChunk.

Instance details

Defined in Language.Drasil.Chunk.Code

Idea CodeChunk

Finds the idea contained in the QuantityDict used to make the CodeChunk.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

Methods

getA :: CodeChunk -> Maybe String #

NamedIdea CodeChunk

Finds the term (NP) of the QuantityDict used to make the CodeChunk.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

Methods

term :: Lens' CodeChunk NP #

MayHaveUnit CodeChunk

Finds the units of the QuantityDict used to make the CodeChunk.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

Quantity CodeChunk

CodeChunks have a Quantity.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

HasSpace CodeChunk

Finds the Space of the QuantityDict used to make the CodeChunk.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

Methods

typ :: Getter CodeChunk Space #

HasSymbol CodeChunk

Finds the Stage dependent Symbol of the QuantityDict used to make the CodeChunk.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

Methods

symbol :: CodeChunk -> Stage -> Symbol #

HasUID CodeChunk

Finds the UID of the QuantityDict used to make the CodeChunk.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

Methods

uid :: Lens' CodeChunk UID #

Eq CodeChunk

Equal if UIDs are equal.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

data CodeVarChunk #

Chunk representing a variable. The obv field represents the object containing this variable, if it is an object field.

Constructors

CodeVC 

Instances

Instances details
CodeIdea CodeVarChunk Source #

Finds the code name and CodeChunk within a CodeVarChunk.

Instance details

Defined in Language.Drasil.Chunk.Code

Idea CodeVarChunk

Finds the idea contained in the CodeChunk used to make the CodeVarChunk.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

NamedIdea CodeVarChunk

Finds the term (NP) of the CodeChunk used to make the CodeVarChunk.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

Methods

term :: Lens' CodeVarChunk NP #

MayHaveUnit CodeVarChunk

Finds the units of the CodeChunk used to make the CodeVarChunk.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

Quantity CodeVarChunk

CodeVarChunks have a Quantity.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

HasSpace CodeVarChunk

Finds the Space of the CodeChunk used to make the CodeVarChunk.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

Methods

typ :: Getter CodeVarChunk Space #

HasSymbol CodeVarChunk

Finds the Stage dependent Symbol of the CodeChunk used to make the CodeVarChunk.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

Methods

symbol :: CodeVarChunk -> Stage -> Symbol #

HasUID CodeVarChunk

Finds the UID of the CodeChunk used to make the CodeVarChunk.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

Methods

uid :: Lens' CodeVarChunk UID #

Eq CodeVarChunk

Equal if UIDs are equal.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

newtype CodeFuncChunk #

Chunk representing a function.

Constructors

CodeFC 

Fields

Instances

Instances details
CodeIdea CodeFuncChunk Source #

Finds the code name and CodeChunk within a CodeFuncChunk.

Instance details

Defined in Language.Drasil.Chunk.Code

Idea CodeFuncChunk

Finds the idea contained in the CodeChunk used to make the CodeFuncChunk.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

NamedIdea CodeFuncChunk

Finds the term (NP) of the CodeChunk used to make the CodeFuncChunk.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

Methods

term :: Lens' CodeFuncChunk NP #

MayHaveUnit CodeFuncChunk

Finds the units of the CodeChunk used to make the CodeFuncChunk.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

Callable CodeFuncChunk

Functions are Callable.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

Quantity CodeFuncChunk

CodeFuncChunks have a Quantity.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

HasSpace CodeFuncChunk

Finds the Space of the CodeChunk used to make the CodeFuncChunk.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

Methods

typ :: Getter CodeFuncChunk Space #

HasSymbol CodeFuncChunk

Finds the Stage dependent Symbol of the CodeChunk used to make the CodeFuncChunk.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

HasUID CodeFuncChunk

Finds the UID of the CodeChunk used to make the CodeFuncChunk.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

Methods

uid :: Lens' CodeFuncChunk UID #

Eq CodeFuncChunk

Equal if UIDs are equal.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

data VarOrFunc #

Details if a piece of code is meant to be a variable or a function.

Constructors

Var 
Func 

quantvar :: (Quantity c, MayHaveUnit c) => c -> CodeVarChunk Source #

Construct a CodeVarChunk from a Quantity.

ccObjVar :: CodeVarChunk -> CodeVarChunk -> CodeVarChunk Source #

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.

codevars :: CodeExpr -> ChunkDB -> [CodeVarChunk] Source #

Get a list of CodeChunks from an equation.

codevars' :: CodeExpr -> ChunkDB -> [CodeVarChunk] Source #

Get a list of CodeChunks from an equation (no functions).

programName :: CommonIdea c => c -> String #

Convert an abbreviation into one deemed 'code-friendly', removing spaces, and replacing special characters with underscores.

FIXME: This should NOT be treated as a getter, but something we cache local to something that has a 'program name'.

funcPrefix :: String #

Used when a function name needs to be distinguishable from a variable name.

class CodeIdea c => DefiningCodeExpr c where #

A DefiningCodeExpr must have it's underlying chunk defined in the CodeExpr language.

Methods

codeExpr :: Lens' c CodeExpr #

Instances

Instances details
DefiningCodeExpr CodeDefinition Source #

Finds the defining expression of a CodeDefinition.

Instance details

Defined in Language.Drasil.Chunk.CodeDefinition

Orphan instances

CodeIdea CodeChunk Source #

Finds the code name of a CodeChunk.

Instance details

CodeIdea CodeFuncChunk Source #

Finds the code name and CodeChunk within a CodeFuncChunk.

Instance details

CodeIdea CodeVarChunk Source #

Finds the code name and CodeChunk within a CodeVarChunk.

Instance details