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

Language.Drasil.UnitLang

Description

Language for defining and manipulating units.

Synopsis

Types

newtype USymb Source #

Language of units (how to build them up into a unit symbol). Of the form (Symbol ^ Integer). The Integer may be negative, but should not be zero.

Constructors

US [(Symbol, Integer)] 

Instances

Instances details
Eq USymb Source # 
Instance details

Defined in Language.Drasil.UnitLang

Methods

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

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

data UDefn Source #

Language of unit equations, to define a unit relative to another.

Constructors

USynonym USymb

to define straight synonyms.

UScale Double USymb

scale, i.e. *.

UShift Double USymb

shift, i.e. +.

data UnitSymbol Source #

When we define units, they come in three flavours: SI (base) units, derived SI units (aka synonyms), and defined units. The type below captures that knowledge.

Functions

fromUDefn :: UDefn -> USymb Source #

Generates a default unit symbol.

compUSymb :: USymb -> USymb -> Ordering Source #

Hand-rolled version of compare. Should assume USymb is normalized, so that some redundant EQ cases can be removed.

getUSymb :: UnitSymbol -> USymb Source #

Generates a default unit symbol.

getDefn :: UnitSymbol -> Maybe UDefn Source #

Gets the unit definition of a unit symbol.