drasil-lang-0.1.60.0: A framework for code and document generation for scientific software - Language SubPackage
Safe HaskellSafe-Inferred
LanguageHaskell2010

Language.Drasil.Symbol

Description

Drasil uses symbols in expressions and sentences.

Synopsis

Types

data Decoration Source #

Decorations on symbols/characters such as hats or Vector representations (determines bolding, italics, etc).

Constructors

Hat

Places a ^ on top of a symbol.

Vector

Makes a symbol bold.

Prime

Appends a ' to a symbol.

Delta

Prepends a Δ to a symbol.

Magnitude

Places || before and after a symbol.

data Symbol Source #

A Symbol is actually going to be a graphical description of what gets rendered as a (unique) symbol. This is actually NOT based on semantics at all, but just a description of how things look.

Symbols can be:

  • Variable (string such as "x" that represent a value that can vary)
  • Label (strings such as "max" or "target" that represent a single idea)
  • Symbol characters (ex. unicode)
  • Decorated symbols using Atop
  • Concatenations of symbols, including subscripts and superscripts
  • Empty! (this is to give this a monoid-like flavour)

Constructors

Variable String

Basic variable name creation.

Label String

For when symbols need more context, but we don't want to add a new variable name. For example, v_f may be encoded as Concat [variable "v", label "f"].

Integ Int

For using numbers in Symbols.

Special Special

For now, special characters are the degree and partial differentiation symbols. These should eventually move elsewhere and the Symbol type removed.

Atop Decoration Symbol

Used to decorate symbols. For things like vectors (which need to be bold), primes, magnitudes, etc. See Decoration for more details.

Corners [Symbol] [Symbol] [Symbol] [Symbol] Symbol

Order of Symbols: upleft lowleft upright lowright base. Ex:

Corners [1]   [2]   [3]   [4]   [5]
 Visually:  [1]   [3]

               [5]

            [2]   [4]
Concat [Symbol]

Concatentation of two symbols: [s1, s2] -> s1s2

Empty

Placeholder for when a symbol is not needed.

Instances

Instances details
Monoid Symbol Source #

Symbols can be empty or concatenated.

Instance details

Defined in Language.Drasil.Symbol

Semigroup Symbol Source #

Symbols may be concatenated.

Instance details

Defined in Language.Drasil.Symbol

Eq Symbol Source # 
Instance details

Defined in Language.Drasil.Symbol

Methods

(==) :: Symbol -> Symbol -> Bool #

(/=) :: Symbol -> Symbol -> Bool #

Classes

class HasSymbol c where Source #

A HasSymbol is anything which has a Symbol.

Methods

symbol :: c -> Stage -> Symbol Source #

Provides the Symbol for a particular stage of generation.

Instances

Instances details
HasSymbol CodeChunk Source #

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

Instance details

Defined in Language.Drasil.Chunk.CodeVar

HasSymbol CodeFuncChunk Source #

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

Instance details

Defined in Language.Drasil.Chunk.CodeVar

HasSymbol CodeVarChunk Source #

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

Instance details

Defined in Language.Drasil.Chunk.CodeVar

HasSymbol ConstrConcept Source #

Finds the Symbol of the DefinedQuantityDict used to make the ConstrConcept.

Instance details

Defined in Language.Drasil.Chunk.Constrained

HasSymbol ConstrainedChunk Source #

Finds the Symbol of the QuantityDict used to make the ConstrainedChunk.

Instance details

Defined in Language.Drasil.Chunk.Constrained

HasSymbol DefinedQuantityDict Source #

Finds the Stage -> Symbol of the DefinedQuantityDict.

Instance details

Defined in Language.Drasil.Chunk.DefinedQuantity

HasSymbol QuantityDict Source #

Finds the Stage dependent Symbol of the QuantityDict.

Instance details

Defined in Language.Drasil.Chunk.Quantity

HasSymbol UncertQ Source #

Finds the Symbol of the ConstrConcept used to make the UncertQ.

Instance details

Defined in Language.Drasil.Chunk.UncertainQuantity

Methods

symbol :: UncertQ -> Stage -> Symbol Source #

HasSymbol UncertainChunk Source #

Finds the Symbol of the ConstrainedChunk used to make the UncertainChunk.

Instance details

Defined in Language.Drasil.Chunk.UncertainQuantity

HasSymbol UnitalChunk Source #

Finds the Symbol of the DefinedQuantityDict used to make the UnitalChunk.

Instance details

Defined in Language.Drasil.Chunk.Unital

HasSymbol UnitaryChunk Source #

Finds the Symbol of the QuantityDict used to make the UnitaryChunk.

Instance details

Defined in Language.Drasil.Chunk.Unitary

HasSymbol (QDefinition e) Source # 
Instance details

Defined in Language.Drasil.Chunk.Eq

Ordering Function

compsy :: Symbol -> Symbol -> Ordering Source #

The default compare function that sorts all the lower case symbols after the upper case ones.

Comparation is used twice for each Atomic case, once for making sure they are the same letter, once for case sensitive. As far as this comparison is considered, Δ is a "decoration" and ignored unless the compared symbols are the exact same, in which case it is ordered after the undecorated symbol.

Superscripts and subscripts are ordered after the base symbols (because they add additional context to a symbol). For example: `v_f^{AB}` (expressed in LaTeX notation for clarity), where v_f is a final velocity, and the `^{AB}` adds context that it is the final velocity between points A and B. In these cases, the sorting of `v_f^{AB}` should be following v_f as it is logical to place it with its parent concept.