config-value-0.7.0.0: Simple, layout-based value language similar to YAML or JSON
Copyright(c) Eric Mertens 2019
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellSafe
LanguageHaskell2010

Config.Number

Description

This module provides a representation of numbers in scientific notation.

Synopsis

Documentation

data Number Source #

Numbers are represented as base, coefficient, and exponent.

The most convenient way to get numbers into and out of this form is to use one of: numberToRational, numberToInteger, rationalToNumber, or integerToNumber.

This representation is explicit about the radix and exponent used to facilitate better pretty-printing. By using explicit exponents extremely large numbers can be represented compactly. Consider that it is easy to write `1e100000000` which would use a significant amount of memory if realized as an Integer. This representation allows concerned programs to check bounds before converting to a representation like Integer.

Constructors

MkNumber 

Instances

Instances details
Eq Number Source # 
Instance details

Defined in Config.Number

Methods

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

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

Data Number Source # 
Instance details

Defined in Config.Number

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Number -> c Number #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Number #

toConstr :: Number -> Constr #

dataTypeOf :: Number -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Number) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Number) #

gmapT :: (forall b. Data b => b -> b) -> Number -> Number #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Number -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Number -> r #

gmapQ :: (forall d. Data d => d -> u) -> Number -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Number -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Number -> m Number #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Number -> m Number #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Number -> m Number #

Ord Number Source # 
Instance details

Defined in Config.Number

Read Number Source # 
Instance details

Defined in Config.Number

Show Number Source # 
Instance details

Defined in Config.Number

Generic Number Source # 
Instance details

Defined in Config.Number

Associated Types

type Rep Number :: Type -> Type #

Methods

from :: Number -> Rep Number x #

to :: Rep Number x -> Number #

type Rep Number Source # 
Instance details

Defined in Config.Number

type Rep Number = D1 ('MetaData "Number" "Config.Number" "config-value-0.7.0.0-JboFCtXlIzo1Q4jM4SfnDg" 'False) (C1 ('MetaCons "MkNumber" 'PrefixI 'True) (S1 ('MetaSel ('Just "numberRadix") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Radix) :*: S1 ('MetaSel ('Just "numberCoefficient") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Rational)))

data Radix Source #

Radix used for a number. Some radix modes support an exponent.

Constructors

Radix2

binary, base 2

Radix8

octal, base 8

Radix10 !Integer

decimal, base 10, exponent base 10

Radix16 !Integer

hexdecimal, base 16, exponent base 2

Instances

Instances details
Eq Radix Source # 
Instance details

Defined in Config.Number

Methods

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

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

Data Radix Source # 
Instance details

Defined in Config.Number

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Radix -> c Radix #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Radix #

toConstr :: Radix -> Constr #

dataTypeOf :: Radix -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Radix) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Radix) #

gmapT :: (forall b. Data b => b -> b) -> Radix -> Radix #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Radix -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Radix -> r #

gmapQ :: (forall d. Data d => d -> u) -> Radix -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Radix -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Radix -> m Radix #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Radix -> m Radix #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Radix -> m Radix #

Ord Radix Source # 
Instance details

Defined in Config.Number

Methods

compare :: Radix -> Radix -> Ordering #

(<) :: Radix -> Radix -> Bool #

(<=) :: Radix -> Radix -> Bool #

(>) :: Radix -> Radix -> Bool #

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

max :: Radix -> Radix -> Radix #

min :: Radix -> Radix -> Radix #

Read Radix Source # 
Instance details

Defined in Config.Number

Show Radix Source # 
Instance details

Defined in Config.Number

Methods

showsPrec :: Int -> Radix -> ShowS #

show :: Radix -> String #

showList :: [Radix] -> ShowS #

Generic Radix Source # 
Instance details

Defined in Config.Number

Associated Types

type Rep Radix :: Type -> Type #

Methods

from :: Radix -> Rep Radix x #

to :: Rep Radix x -> Radix #

type Rep Radix Source # 
Instance details

Defined in Config.Number

type Rep Radix = D1 ('MetaData "Radix" "Config.Number" "config-value-0.7.0.0-JboFCtXlIzo1Q4jM4SfnDg" 'False) ((C1 ('MetaCons "Radix2" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Radix8" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Radix10" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Integer)) :+: C1 ('MetaCons "Radix16" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Integer))))

radixToInt :: Radix -> Int Source #

Returns the radix as an integer ignoring any exponent.

numberToRational :: Number -> Rational Source #

Convert a number to a Rational. Warning: This can use a lot of member in the case of very large exponent parts.

numberToInteger :: Number -> Maybe Integer Source #

Convert a number to a Integer. Warning: This can use a lot of member in the case of very large exponent parts.

integerToNumber :: Integer -> Number Source #

Integer to a radix 10 Number with no exponent

rationalToNumber :: Rational -> Number Source #

Rational to a radix 10 Number with no exponent