tomland-1.3.3.2: Bidirectional TOML serialization
Copyright(c) 2018-2022 Kowainik
LicenseMPL-2.0
MaintainerKowainik <xrom.xkov@gmail.com>
StabilityStable
PortabilityPortable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Toml.Type.Value

Description

GADT value for TOML.

Since: 0.0.0

Synopsis

Type of value

data TValue Source #

Needed for GADT parameterization

Since: 0.0.0

Instances

Instances details
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 #

Read TValue Source # 
Instance details

Defined in Toml.Type.Value

Show TValue Source # 
Instance details

Defined in Toml.Type.Value

NFData TValue Source # 
Instance details

Defined in Toml.Type.Value

Methods

rnf :: TValue -> () #

Eq TValue Source # 
Instance details

Defined in Toml.Type.Value

Methods

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

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

type Rep TValue Source # 
Instance details

Defined in Toml.Type.Value

type Rep TValue = D1 ('MetaData "TValue" "Toml.Type.Value" "tomland-1.3.3.2-JRrBhNpiCh26pzVBpYNNR0" '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 "TZoned" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TLocal" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "TDay" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "THours" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TArray" 'PrefixI 'False) (U1 :: Type -> Type)))))

showType :: TValue -> String Source #

Convert TValue constructors to String without T prefix.

Since: 0.0.0

Value

data Value (t :: TValue) where Source #

Value in key = value pair.

Since: 0.0.0

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  # hexadecimal
oct2 = 0o755  # octal, useful for Unix file permissions
bin1 = 0b11010110  # binary
Double :: Double -> Value 'TDouble

Floating point number:

# fractional
flt1 = +1.0
flt2 = 3.1415
flt3 = -0.01

# exponent
flt4 = 5e+22
flt5 = 1e6
flt6 = -2E-2

# both
flt7 = 6.626e-34

# infinity
sf1 = inf  # positive infinity
sf2 = +inf # positive infinity
sf3 = -inf # negative infinity

# not a number
sf4 = nan  # actual sNaN/qNaN encoding is implementation specific
sf5 = +nan # same as `nan`
sf6 = -nan # same as `nan`
Text :: Text -> Value 'TText

String value:

# basic string
name = "Orange"
physical.color = "orange"
physical.shape = "round"

# multiline basic string
str1 = """
Roses are red
Violets are blue"""

# literal string: What you see is what you get.
winpath  = 'C:Usersnodejstemplates'
winpath2 = '\ServerXadmin$system32'
quoted   = 'Tom "Dubs" Preston-Werner'
regex    = 'ic*s*'
Zoned :: ZonedTime -> Value 'TZoned

Offset date-time:

odt1 = 1979-05-27T07:32:00Z
odt2 = 1979-05-27T00:32:00-07:00
odt3 = 1979-05-27T00:32:00.999999-07:00
Local :: LocalTime -> Value 'TLocal

Local date-time (without offset):

ldt1 = 1979-05-27T07:32:00
ldt2 = 1979-05-27T00:32:00.999999
Day :: Day -> Value 'TDay

Local date (only day):

ld1 = 1979-05-27
Hours :: TimeOfDay -> Value 'THours

Local time (time of the day):

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

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

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

Defined in Toml.Type.Value

Methods

fromString :: String -> Value t #

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 #

Since: 0.0.0

Instance details

Defined in Toml.Type.Value

Methods

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

show :: Value t -> String #

showList :: [Value t] -> ShowS #

NFData (Value t) Source # 
Instance details

Defined in Toml.Type.Value

Methods

rnf :: Value t -> () #

Eq (Value t) Source # 
Instance details

Defined in Toml.Type.Value

Methods

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

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

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

Compare list of Value of possibly different types.

Since: 0.0.0

valueType :: Value t -> TValue Source #

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

Since: 0.0.0

Type checking

data TypeMismatchError Source #

Data type that holds expected vs. actual type.

Since: 0.1.0

Constructors

TypeMismatchError 

Instances

Instances details
Show TypeMismatchError Source #

Since: 0.1.0

Instance details

Defined in Toml.Type.Value

Eq TypeMismatchError Source # 
Instance details

Defined in Toml.Type.Value

sameValue :: Value a -> Value b -> Either TypeMismatchError (a :~: b) Source #

Checks whether two values are the same. This function is used for type checking where first argument is expected type and second argument is actual type.

Since: 0.0.0