Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module defines singleton types for integers and concrete units.
Synopsis
- data SUnit (u :: UnitSyntax Symbol) where
- forgetSUnit :: SUnit u -> UnitSyntax String
- class KnownUnit (u :: UnitSyntax Symbol) where
- unitVal :: forall proxy u. KnownUnit u => proxy u -> UnitSyntax String
- testEquivalentSUnit :: SUnit u -> SUnit v -> Maybe (Pack u :~: Pack v)
- data SList (xs :: [Symbol]) where
- class KnownList (xs :: [Symbol]) where
Singletons for units
data SUnit (u :: UnitSyntax Symbol) where Source #
Singleton type for concrete units of measure represented as lists of base units
Instances
TestEquality SUnit Source # | |
Defined in Data.UnitsOfMeasure.Singleton |
forgetSUnit :: SUnit u -> UnitSyntax String Source #
Extract the runtime syntactic representation from a singleton unit
class KnownUnit (u :: UnitSyntax Symbol) where Source #
A constraint
means that KnownUnit
uu
must be a concrete
unit that is statically known but passed at runtime
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 SUnit
s 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 :: [Symbol]) where Source #
Singleton type for lists of base units
Instances
TestEquality SList Source # | |
Defined in Data.UnitsOfMeasure.Singleton |