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 DefinedQuantityDict 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

HasUID CodeChunk

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

Instance details

Defined in Drasil.Code.CodeVar

Methods

uid :: Getter CodeChunk UID #

Idea CodeChunk

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

Instance details

Defined in Drasil.Code.CodeVar

Methods

getA :: CodeChunk -> Maybe String #

NamedIdea CodeChunk

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

Instance details

Defined in Drasil.Code.CodeVar

Methods

term :: Lens' CodeChunk NP #

MayHaveUnit CodeChunk

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

Instance details

Defined in Drasil.Code.CodeVar

ConceptDomain CodeChunk 
Instance details

Defined in Drasil.Code.CodeVar

Methods

cdom :: CodeChunk -> [UID] #

Definition CodeChunk

Finds the Definition contained in the DefinedQuantityDict used to make the CodeChunk

Instance details

Defined in Drasil.Code.CodeVar

Methods

defn :: Lens' CodeChunk Sentence #

Quantity CodeChunk

CodeChunks have a Quantity.

Instance details

Defined in Drasil.Code.CodeVar

HasSpace CodeChunk

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

Instance details

Defined in Drasil.Code.CodeVar

Methods

typ :: Getter CodeChunk Space #

HasSymbol CodeChunk

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

Instance details

Defined in Drasil.Code.CodeVar

Methods

symbol :: CodeChunk -> Stage -> Symbol #

Eq CodeChunk

Equal if UIDs are equal.

Instance details

Defined in Drasil.Code.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

HasUID CodeVarChunk

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

Instance details

Defined in Drasil.Code.CodeVar

Methods

uid :: Getter CodeVarChunk UID #

Idea CodeVarChunk

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

Instance details

Defined in Drasil.Code.CodeVar

NamedIdea CodeVarChunk

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

Instance details

Defined in Drasil.Code.CodeVar

Methods

term :: Lens' CodeVarChunk NP #

MayHaveUnit CodeVarChunk

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

Instance details

Defined in Drasil.Code.CodeVar

ConceptDomain CodeVarChunk 
Instance details

Defined in Drasil.Code.CodeVar

Methods

cdom :: CodeVarChunk -> [UID] #

Definition CodeVarChunk 
Instance details

Defined in Drasil.Code.CodeVar

Methods

defn :: Lens' CodeVarChunk Sentence #

Quantity CodeVarChunk

CodeVarChunks have a Quantity.

Instance details

Defined in Drasil.Code.CodeVar

HasSpace CodeVarChunk

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

Instance details

Defined in Drasil.Code.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 Drasil.Code.CodeVar

Methods

symbol :: CodeVarChunk -> Stage -> Symbol #

Eq CodeVarChunk

Equal if UIDs are equal.

Instance details

Defined in Drasil.Code.CodeVar

newtype CodeFuncChunk #

Chunk representing a function.

Constructors

CodeFC 

Fields

Instances

Instances details
Callable CodeFuncChunk

Functions are Callable.

Instance details

Defined in Drasil.Code.CodeVar

CodeIdea CodeFuncChunk Source #

Finds the code name and CodeChunk within a CodeFuncChunk.

Instance details

Defined in Language.Drasil.Chunk.Code

HasUID CodeFuncChunk

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

Instance details

Defined in Drasil.Code.CodeVar

Methods

uid :: Getter CodeFuncChunk UID #

Idea CodeFuncChunk

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

Instance details

Defined in Drasil.Code.CodeVar

NamedIdea CodeFuncChunk

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

Instance details

Defined in Drasil.Code.CodeVar

Methods

term :: Lens' CodeFuncChunk NP #

MayHaveUnit CodeFuncChunk

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

Instance details

Defined in Drasil.Code.CodeVar

ConceptDomain CodeFuncChunk

Finds the ConceptDomain of the CodeChunk used to make the CodeFuncChunk

Instance details

Defined in Drasil.Code.CodeVar

Methods

cdom :: CodeFuncChunk -> [UID] #

Definition CodeFuncChunk

Finds the Definition of the CodeChunk used to make the CodeFuncChunk

Instance details

Defined in Drasil.Code.CodeVar

Methods

defn :: Lens' CodeFuncChunk Sentence #

Quantity CodeFuncChunk

CodeFuncChunks have a Quantity.

Instance details

Defined in Drasil.Code.CodeVar

HasSpace CodeFuncChunk

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

Instance details

Defined in Drasil.Code.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 Drasil.Code.CodeVar

Eq CodeFuncChunk

Equal if UIDs are equal.

Instance details

Defined in Drasil.Code.CodeVar

data VarOrFunc #

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

Constructors

Var 
Func 

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