| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Language.Drasil.Chunk.UnitDefn
Description
For defining units built from a concept.
Synopsis
- class MayHaveUnit u where
- class (Idea u, Definition u, HasUnitSymbol u) => IsUnit u where
- data UnitDefn = UD {
- _vc :: ConceptChunk
- _cas :: UnitSymbol
- _cu :: [UID]
- baseUnit :: String -> NP -> String -> Symbol -> UnitDefn
- derivedUnit :: String -> NP -> String -> Symbol -> UnitEquation -> UnitDefn
- derivedUnitScale :: String -> NP -> String -> Symbol -> Double -> UnitDefn -> UnitDefn
- derivedUnitShift :: String -> NP -> String -> Symbol -> Double -> UnitDefn -> UnitDefn
- compoundUnit :: String -> NP -> String -> UnitEquation -> UnitDefn
- compoundUnitScale :: String -> NP -> String -> Symbol -> Double -> UnitDefn -> UnitDefn
- compoundUnitShift :: String -> NP -> String -> Symbol -> Double -> UnitDefn -> UnitDefn
- (^:) :: UnitDefn -> Integer -> UnitEquation
- (/:) :: UnitDefn -> UnitDefn -> UnitEquation
- (*:) :: UnitDefn -> UnitDefn -> UnitEquation
- (*$) :: UnitDefn -> UnitEquation -> UnitEquation
- (/$) :: UnitDefn -> UnitEquation -> UnitEquation
- (^$) :: UnitEquation -> UnitEquation -> UnitEquation
- fromUDefn :: UDefn -> USymb
- getCu :: UnitEquation -> [UID]
- compUnitDefn :: UnitDefn -> UnitDefn -> Ordering
- unitSymbol :: UnitDefn -> UnitSymbol
Classes
class MayHaveUnit u where Source #
Types may contain a unit (UnitDefn).
Instances
| MayHaveUnit CodeChunk Source # | Finds the units of the |
| MayHaveUnit CodeFuncChunk Source # | Finds the units of the |
Defined in Drasil.Code.CodeVar | |
| MayHaveUnit CodeVarChunk Source # | Finds the units of the |
Defined in Drasil.Code.CodeVar | |
| MayHaveUnit ConstrConcept Source # | Finds the units of the |
Defined in Language.Drasil.Chunk.Constrained | |
| MayHaveUnit DefinedQuantityDict Source # | Finds the units of the |
Defined in Language.Drasil.Chunk.DefinedQuantity | |
| MayHaveUnit UncertQ Source # | Finds the units of the |
| MayHaveUnit (QDefinition e) Source # | |
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.
Chunk Type
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
| HasChunkRefs UnitDefn Source # | |
| HasUID UnitDefn Source # | Finds |
Defined in Language.Drasil.Chunk.UnitDefn | |
| Idea UnitDefn Source # | Finds the idea contained in the |
| NamedIdea UnitDefn Source # | Finds term ( |
| Definition UnitDefn Source # | Finds definition of the |
| HasUnitSymbol UnitDefn Source # | Finds unit symbol of the |
| IsUnit UnitDefn Source # | Gets the UnitDefn and contributing units. |
| Eq UnitDefn Source # | Equal if |
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 -> 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
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.
unitSymbol :: UnitDefn -> UnitSymbol Source #
Extract the UnitSymbol of a UnitDefn.