tomland-0.5.0: Bidirectional TOML parser

Safe HaskellSafe
LanguageHaskell2010

Toml.Type.Value

Contents

Synopsis

Type of value

data TValue Source #

Needed for GADT parameterization

Constructors

TBool 
TInteger 
TDouble 
TText 
TDate 
TArray 
Instances
Eq TValue Source # 
Instance details

Defined in Toml.Type.Value

Methods

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

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

Show TValue Source # 
Instance details

Defined in Toml.Type.Value

Generic TValue Source # 
Instance details

Defined in Toml.Type.Value

Associated Types

type Rep TValue :: Type -> Type #

Methods

from :: TValue -> Rep TValue x #

to :: Rep TValue x -> TValue #

NFData TValue Source # 
Instance details

Defined in Toml.Type.Value

Methods

rnf :: TValue -> () #

type Rep TValue Source # 
Instance details

Defined in Toml.Type.Value

type Rep TValue = D1 (MetaData "TValue" "Toml.Type.Value" "tomland-0.5.0-LfjG6U9ib3bHsNLsVqknKF" False) ((C1 (MetaCons "TBool" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "TInteger" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "TDouble" PrefixI False) (U1 :: Type -> Type))) :+: (C1 (MetaCons "TText" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "TDate" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "TArray" PrefixI False) (U1 :: Type -> Type))))

Value

data Value (t :: TValue) where Source #

Value in key = value pair.

Constructors

Bool :: Bool -> Value TBool

Boolean value:

bool1 = true
bool2 = false
Integer :: Integer -> Value TInteger

Integer value:

int1 = +99
int2 = 42
int3 = 0
int4 = -17
int5 = 5_349_221
hex1 = 0xDEADBEEF
oct2 = 0o755 # useful for Unix file permissions
bin1 = 0b11010110
Double :: Double -> Value TDouble

Floating point number:

flt1 = -3.1415   # fractional
flt2 = 1e6       # exponent
flt3 = 6.626e-34 # both
flt4 = 9_224_617.445_991_228_313
Text :: Text -> Value TText

String value:

key = "value"
bare_key = "value"
bare-key = "value"
Date :: DateTime -> Value TDate

Date-time. See documentation for DateTime type.

Array :: [Value t] -> Value TArray

Array of values. According to TOML specification all values in array should have the same type. This is guaranteed statically with this type.

arr1 = [ 1, 2, 3 ]
arr2 = [ "red", "yellow", "green" ]
arr3 = [ [ 1, 2 ], [3, 4, 5] ]
arr4 = [ "all", strings, """are the same""", ''type'']
arr5 = [ [ 1, 2 ], ["a", "b", "c"] ]

arr6 = [ 1, 2.0 ] # INVALID
Instances
Eq (Value t) Source # 
Instance details

Defined in Toml.Type.Value

Methods

(==) :: Value t -> Value t -> Bool #

(/=) :: Value t -> Value t -> Bool #

t ~ TInteger => Num (Value t) Source # 
Instance details

Defined in Toml.Type.Value

Methods

(+) :: Value t -> Value t -> Value t #

(-) :: Value t -> Value t -> Value t #

(*) :: Value t -> Value t -> Value t #

negate :: Value t -> Value t #

abs :: Value t -> Value t #

signum :: Value t -> Value t #

fromInteger :: Integer -> Value t #

Show (Value t) Source # 
Instance details

Defined in Toml.Type.Value

Methods

showsPrec :: Int -> Value t -> ShowS #

show :: Value t -> String #

showList :: [Value t] -> ShowS #

t ~ TText => IsString (Value t) Source # 
Instance details

Defined in Toml.Type.Value

Methods

fromString :: String -> Value t #

NFData (Value t) Source # 
Instance details

Defined in Toml.Type.Value

Methods

rnf :: Value t -> () #

data DateTime Source #

Constructors

Zoned !ZonedTime

Offset date-time:

odt1 = 1979-05-27T07:32:00Z
odt2 = 1979-05-27T00:32:00-07:00
Local !LocalTime

Local date-time (without offset):

ldt1 = 1979-05-27T07:32:00
ldt2 = 1979-05-27T00:32:00.999999
Day !Day

Local date (only day):

ld1 = 1979-05-27
Hours !TimeOfDay

Local time (time of the day):

lt1 = 07:32:00
lt2 = 00:32:00.999999

Instances
Eq DateTime Source # 
Instance details

Defined in Toml.Type.Value

Show DateTime Source # 
Instance details

Defined in Toml.Type.Value

NFData DateTime Source # 
Instance details

Defined in Toml.Type.Value

Methods

rnf :: DateTime -> () #

eqValueList :: [Value a] -> [Value b] -> Bool Source #

valueType :: Value t -> TValue Source #

Reifies type of Value into ValueType. Unfortunately, there's no way to guarante that valueType will return t for object with type Value 't.

Type checking

data TypeMismatchError Source #

Data type that holds expected vs. actual type.