Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Defines chunk types for use in code generation.
Synopsis
- class CodeIdea c where
- data CodeChunk = CodeC {
- _qc :: QuantityDict
- kind :: VarOrFunc
- data CodeVarChunk = CodeVC {}
- newtype CodeFuncChunk = CodeFC {}
- data VarOrFunc
- obv :: Lens' CodeVarChunk (Maybe CodeChunk)
- quantvar :: (Quantity c, MayHaveUnit c) => c -> CodeVarChunk
- quantfunc :: (Quantity c, MayHaveUnit c) => c -> CodeFuncChunk
- ccObjVar :: CodeVarChunk -> CodeVarChunk -> CodeVarChunk
- codevars :: CodeExpr -> ChunkDB -> [CodeVarChunk]
- codevars' :: CodeExpr -> ChunkDB -> [CodeVarChunk]
- funcResolve :: ChunkDB -> UID -> CodeFuncChunk
- varResolve :: ChunkDB -> UID -> CodeVarChunk
- listToArray :: CodeVarChunk -> CodeVarChunk
- programName :: CommonIdea c => c -> String
- funcPrefix :: String
- class CodeIdea c => DefiningCodeExpr c where
Documentation
A CodeIdea
must include some code and its name.
Name of the idea.
Code chunk associated with the idea.
Instances
Basic chunk representation in the code generation context. Contains a QuantityDict and the kind of code (variable or function).
CodeC | |
|
Instances
CodeIdea CodeChunk Source # | Finds the code name of a |
Idea CodeChunk | Finds the idea contained in the |
NamedIdea CodeChunk | Finds the term ( |
Defined in Language.Drasil.Chunk.CodeVar | |
MayHaveUnit CodeChunk | Finds the units of the |
Quantity CodeChunk | |
Defined in Language.Drasil.Chunk.CodeVar | |
HasSpace CodeChunk | Finds the |
Defined in Language.Drasil.Chunk.CodeVar | |
HasSymbol CodeChunk | Finds the |
HasUID CodeChunk | Finds the |
Defined in Language.Drasil.Chunk.CodeVar | |
Eq CodeChunk | Equal if |
data CodeVarChunk #
Chunk representing a variable. The obv
field represents the object containing
this variable, if it is an object field.
Instances
newtype CodeFuncChunk #
Chunk representing a function.
Instances
obv :: Lens' CodeVarChunk (Maybe CodeChunk) #
quantvar :: (Quantity c, MayHaveUnit c) => c -> CodeVarChunk Source #
Construct a CodeVarChunk
from a Quantity
.
quantfunc :: (Quantity c, MayHaveUnit c) => c -> CodeFuncChunk Source #
Construct a CodeFuncChunk
from a Quantity
.
ccObjVar :: CodeVarChunk -> CodeVarChunk -> CodeVarChunk Source #
codevars :: CodeExpr -> ChunkDB -> [CodeVarChunk] Source #
Get a list of CodeChunk
s from an equation.
codevars' :: CodeExpr -> ChunkDB -> [CodeVarChunk] Source #
Get a list of CodeChunk
s from an equation (no functions).
funcResolve :: ChunkDB -> UID -> CodeFuncChunk Source #
Make a CodeFuncChunk
from a UID
in the ChunkDB
.
varResolve :: ChunkDB -> UID -> CodeVarChunk Source #
Make a CodeVarChunk
from a UID
in the ChunkDB
.
listToArray :: CodeVarChunk -> CodeVarChunk #
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.
Instances
DefiningCodeExpr CodeDefinition Source # | Finds the defining expression of a CodeDefinition. |
Defined in Language.Drasil.Chunk.CodeDefinition codeExpr :: Lens' CodeDefinition CodeExpr # |
Orphan instances
CodeIdea CodeChunk Source # | Finds the code name of a |
CodeIdea CodeFuncChunk Source # | Finds the code name and |
codeName :: CodeFuncChunk -> String # codeChunk :: CodeFuncChunk -> CodeChunk # | |
CodeIdea CodeVarChunk Source # | Finds the code name and |
codeName :: CodeVarChunk -> String # codeChunk :: CodeVarChunk -> CodeChunk # |