type-digits-0.3: Arbitrary-base type-level digits

Portabilitysee LANGUAGE pragmas (... GHC)
Stabilityexperimental
Maintainernicolas.frisby@gmail.com
Safe HaskellNone

Type.Digits

Description

Type-level numerals built from type-level digits of an arbitrary radix.

Synopsis

Documentation

digitStrings :: [String]Source

The names of the digits.

radix :: Num i => iSource

The number of digits.

digit :: (Show a, Eq a, Num a) => a -> NameSource

Convert a number to the name of the corresponding digit -- error if the argument is out of range.

toType :: [Name] -> Type -> TypeSource

Give a list of digit names, and a base type, yields a type.

toType_ :: [Name] -> TypeSource

toType_ = ($ PromotedT 'DigitStop) . toType.

toDigits :: (a -> [Name]) -> a -> Type -> TypeSource

toDigits f = toType . f

toDigits_ :: (a -> [Name]) -> a -> TypeSource

toDigits_ = (($ PromotedT 'DigitStop) .) . toDigits.

flexible :: (Show a, Eq a, Integral a) => a -> [Name]Source

Converts an Integral to a type-level numeral using as many digits as it takes that particular number.

fixed :: forall a. (Bounded a, Show a, Eq a, Integral a) => a -> [Name]Source

Converts a Bounded Integral to a type-level numeral using exactly the number of digits it takes to represent each value of that type uniquely.

flexible' :: Enum a => a -> [Name]Source

flexible' = flexible . fromEnum

fixed' :: Enum a => a -> [Name]Source

fixed' = fixed . fromEnum

exactly :: Int -> [Name] -> [Name]Source

Pads its second argument so that the resulting length is its first argument; fails if the second argument is already larger.