drasil-lang-0.1.60.0: A framework for code and document generation for scientific software - Language SubPackage
Safe HaskellNone
LanguageGHC2024

Language.Drasil.Chunk.UnitDefn

Description

For defining units built from a concept.

Synopsis

Classes

class MayHaveUnit u where Source #

Types may contain a unit (UnitDefn).

Methods

getUnit :: u -> Maybe UnitDefn Source #

Instances

Instances details
MayHaveUnit CodeChunk Source #

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

Instance details

Defined in Drasil.Code.CodeVar

MayHaveUnit CodeFuncChunk Source #

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

Instance details

Defined in Drasil.Code.CodeVar

MayHaveUnit CodeVarChunk Source #

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

Instance details

Defined in Drasil.Code.CodeVar

MayHaveUnit ConstrConcept Source #

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

Instance details

Defined in Language.Drasil.Chunk.Constrained

MayHaveUnit DefinedQuantityDict Source #

Finds the units of the DefinedQuantityDict.

Instance details

Defined in Language.Drasil.Chunk.DefinedQuantity

MayHaveUnit UncertQ Source #

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

Instance details

Defined in Language.Drasil.Chunk.UncertainQuantity

MayHaveUnit (QDefinition e) Source # 
Instance details

Defined in Language.Drasil.Chunk.Eq

class (Idea u, Definition u, HasUnitSymbol u) => IsUnit u where Source #

Units are Ideas with a Definition which store a unit symbol. They must also be explicitly declared to be instances of IsUnit.

Minimal complete definition

udefn, getUnits

Methods

getUnits :: u -> [UID] Source #

Holds units as a list of UID.

Instances

Instances details
IsUnit UnitDefn Source #

Gets the UnitDefn and contributing units.

Instance details

Defined in Language.Drasil.Chunk.UnitDefn

Chunk Type

data UnitDefn Source #

For defining units. It has a ConceptChunk (that defines what kind of unit it is), a unit symbol, maybe another (when it is a synonym), perhaps a definition, and a list of UID of the units that make up the definition.

Ex. Meter is a unit of length defined by the symbol (m).

Constructors

UD 

Fields

Instances

Instances details
HasChunkRefs UnitDefn Source # 
Instance details

Defined in Language.Drasil.Chunk.UnitDefn

Methods

chunkRefs :: UnitDefn -> Set UID #

HasUID UnitDefn Source #

Finds UID of the ConceptChunk used to make the UnitDefn.

Instance details

Defined in Language.Drasil.Chunk.UnitDefn

Methods

uid :: Getter UnitDefn UID #

Idea UnitDefn Source #

Finds the idea contained in the ConceptChunk used to make the UnitDefn.

Instance details

Defined in Language.Drasil.Chunk.UnitDefn

NamedIdea UnitDefn Source #

Finds term (NP) of the ConceptChunk used to make the UnitDefn.

Instance details

Defined in Language.Drasil.Chunk.UnitDefn

Methods

term :: Lens' UnitDefn NP Source #

Definition UnitDefn Source #

Finds definition of the ConceptChunk used to make the UnitDefn.

Instance details

Defined in Language.Drasil.Chunk.UnitDefn

Methods

defn :: Lens' UnitDefn Sentence Source #

HasUnitSymbol UnitDefn Source #

Finds unit symbol of the ConceptChunk used to make the UnitDefn.

Instance details

Defined in Language.Drasil.Chunk.UnitDefn

Methods

usymb :: UnitDefn -> USymb Source #

IsUnit UnitDefn Source #

Gets the UnitDefn and contributing units.

Instance details

Defined in Language.Drasil.Chunk.UnitDefn

Eq UnitDefn Source #

Equal if Symbols are equal.

Instance details

Defined in Language.Drasil.Chunk.UnitDefn

Constructors

baseUnit :: String -> NP -> String -> Symbol -> UnitDefn Source #

Create a base unit (one not defined in terms of any other unit, e.g. m, kg) from a UID string, term, definition, and its symbol.

derivedUnit :: String -> NP -> String -> Symbol -> UnitEquation -> UnitDefn Source #

Create a derived unit (a combination of other units that has its own special symbol, e.g. N) from a UID string, term, definition, its symbol, and the unit equation it is defined by.

derivedUnitScale :: String -> NP -> String -> Symbol -> Double -> UnitDefn -> UnitDefn Source #

Create a derived unit that is a scaled version of another unit from a UID string, term, definition, its symbol, the scaling factor, and the unit being scaled.

derivedUnitShift :: String -> NP -> String -> Symbol -> Double -> UnitDefn -> UnitDefn Source #

Create a derived unit that is a shifted version of another unit (e.g. centigrade = kelvin - 273.15) from a UID string, term, definition, its symbol, the shift factor, and the unit being shifted.

compoundUnit :: String -> NP -> String -> UnitEquation -> UnitDefn Source #

Create a compound unit (a combination of other units without its own special symbol, e.g. m/s) from a UID string, term, definition, and the unit equation it is defined by.

compoundUnitScale :: String -> NP -> String -> Symbol -> Double -> UnitDefn -> UnitDefn Source #

Create a defined unit that is a scaled version of another unit (e.g. millimetre = 0.001 × metre) from a UID string, term, definition, its symbol, the scaling factor, and the unit being scaled.

compoundUnitShift :: String -> NP -> String -> Symbol -> Double -> UnitDefn -> UnitDefn Source #

Create a defined unit that is a shifted version of another unit from a UID string, term, definition, its symbol, the shift factor, and the unit being shifted.

Unit Combinators (UnitEquations)

(^:) :: UnitDefn -> Integer -> UnitEquation Source #

Combinator for raising a unit to a power.

(/:) :: UnitDefn -> UnitDefn -> UnitEquation Source #

Combinator for dividing one unit by another.

(*:) :: UnitDefn -> UnitDefn -> UnitEquation Source #

Combinator for multiplying two units together.

(*$) :: UnitDefn -> UnitEquation -> UnitEquation Source #

Combinator for multiplying a unit and a symbol.

(/$) :: UnitDefn -> UnitEquation -> UnitEquation Source #

Combinator for dividing a unit and a symbol.

(^$) :: UnitEquation -> UnitEquation -> UnitEquation Source #

Combinator for mulitiplying two unit equations.

Helpers

fromUDefn :: UDefn -> USymb Source #

Generates a default unit symbol.

getCu :: UnitEquation -> [UID] Source #

Get a list of UID of the units that make up the UnitEquation.

compUnitDefn :: UnitDefn -> UnitDefn -> Ordering Source #

We don't want an Ord on units, but this still allows us to compare them.