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

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 QuantityDict used to make the CodeChunk.

Instance details

Defined in Language.Drasil.Chunk.CodeVar

MayHaveUnit CodeFuncChunk Source #

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

Instance details

Defined in Language.Drasil.Chunk.CodeVar

MayHaveUnit CodeVarChunk Source #

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

Instance details

Defined in Language.Drasil.Chunk.CodeVar

MayHaveUnit ConstrConcept Source #

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

Instance details

Defined in Language.Drasil.Chunk.Constrained

MayHaveUnit ConstrainedChunk Source #

Finds units contained in the QuantityDict used to make the ConstrainedChunk.

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 QuantityDict Source #

Finds the units of the QuantityDict.

Instance details

Defined in Language.Drasil.Chunk.Quantity

MayHaveUnit UncertQ Source #

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

Instance details

Defined in Language.Drasil.Chunk.UncertainQuantity

MayHaveUnit UncertainChunk Source #

Finds units contained in the ConstrainedChunk used to make the UncertainChunk.

Instance details

Defined in Language.Drasil.Chunk.UncertainQuantity

MayHaveUnit UnitalChunk Source #

Finds the units used to make the UnitalChunk.

Instance details

Defined in Language.Drasil.Chunk.Unital

MayHaveUnit UnitaryChunk Source #

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

Instance details

Defined in Language.Drasil.Chunk.Unitary

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

class TempHasUnit u where Source #

Temporary class to make sure chunks have a unit (in order to eventually get rid of MayHaveUnit).

Methods

findUnit :: u -> UnitDefn Source #

Instances

Instances details
TempHasUnit UnitalChunk Source #

Finds the units used to make the UnitalChunk.

Instance details

Defined in Language.Drasil.Chunk.Unital

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

ConceptDomain UnitDefn Source #

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

Instance details

Defined in Language.Drasil.Chunk.UnitDefn

Methods

cdom :: UnitDefn -> [UID] 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

HasUID UnitDefn Source #

Finds UID of the ConceptChunk used to make the UnitDefn.

Instance details

Defined in Language.Drasil.Chunk.UnitDefn

Methods

uid :: Lens' UnitDefn UID Source #

Eq UnitDefn Source #

Equal if Symbols are equal.

Instance details

Defined in Language.Drasil.Chunk.UnitDefn

Constructors

makeDerU :: ConceptChunk -> UnitEquation -> UnitDefn Source #

Create a derived unit chunk from a concept and a unit equation.

newUnit :: String -> UnitEquation -> UnitDefn Source #

Smart constructor for new derived units from existing units.

derUC :: String -> String -> String -> Symbol -> UDefn -> UnitDefn Source #

Uses self-plural term.

Create a derived unit chunk from a UID, term (String), definition, Symbol, and unit equation.

derUC' :: String -> String -> String -> Symbol -> UDefn -> UnitDefn Source #

Uses term that pluralizes by adding "s" to the end.

Create a derived unit chunk from a UID, term (String), definition, Symbol, and unit equation.

derUC'' :: String -> NP -> String -> Symbol -> UDefn -> UnitDefn Source #

Create a derived unit chunk from a UID, term (NP), definition, Symbol, and unit equation.

fund :: String -> String -> String -> UnitDefn Source #

Smart constructor for a "fundamental" unit.

fund' :: String -> String -> Symbol -> UnitDefn Source #

Variant of the fund, useful for degree.

derCUC :: String -> String -> String -> Symbol -> UnitEquation -> UnitDefn Source #

Create a SI_Unit with two Symbol representations. The created NP is self-plural.

derCUC' :: String -> String -> String -> Symbol -> UnitEquation -> UnitDefn Source #

Similar to derCUC, but the created NP has the AddS plural rule.

derCUC'' :: String -> NP -> String -> Symbol -> UnitEquation -> UnitDefn Source #

Create a derived unit chunk from a UID, term (NP), definition, Symbol, and unit equation.

unitWrapper :: IsUnit u => u -> UnitDefn Source #

For allowing lists to mix together chunks that are units by projecting them into a UnitDefn. For now, this only works on UnitDefns.

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.

Unit Relation Functions

scale :: IsUnit s => Double -> s -> UDefn Source #

Combinator for scaling one unit by some number.

shift :: IsUnit s => Double -> s -> UDefn Source #

Combinator for shifting one unit by some number.

Helpers

fromUDefn :: UDefn -> USymb Source #

Generates a default unit symbol.

unitCon :: String -> ConceptChunk Source #

Helper for fundamental unit concept chunk creation. Uses the same String for the identifier, term, and definition.

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.