uom-plugin-0.2.0.1: Units of measure as a GHC typechecker plugin

Safe HaskellNone
LanguageHaskell2010

Data.UnitsOfMeasure.Singleton

Contents

Description

This module defines singleton types for integers and concrete units.

Synopsis

Singletons for units

data SUnit u where Source

Singleton type for concrete units of measure represented as lists of base units

Constructors

SUnit :: SList xs -> SList ys -> SUnit (xs :/ ys) 

forgetSUnit :: SUnit u -> UnitSyntax String Source

Extract the runtime syntactic representation from a singleton unit

class KnownUnit u where Source

A constraint KnownUnit u means that u must be a concrete unit that is statically known but passed at runtime

Methods

unitSing :: SUnit u Source

Instances

unitVal :: forall proxy u. KnownUnit u => proxy u -> UnitSyntax String Source

Extract the runtime syntactic representation of a KnownUnit

testEquivalentSUnit :: SUnit u -> SUnit v -> Maybe (Pack u :~: Pack v) Source

Test whether two SUnits represent the same units, up to the equivalence relation. TODO: this currently uses unsafeCoerce, but in principle it should be possible to avoid it.

Singletons for lists

data SList xs where Source

Singleton type for lists of base units

Constructors

SNil :: SList [] 
SCons :: KnownSymbol x => proxy x -> SList xs -> SList (x : xs) 

class KnownList xs where Source

A constraint KnownList xs means that xs must be a list of base units that is statically known but passed at runtime

Methods

listSing :: SList xs Source

Instances