HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduletomland-1.3.3.3Haskell2010

Toml.Type.Value

SPDX-License-Identifier : MPL-2.0 Maintainer : Kowainik xrom.xkov@gmail.com Stability : Stable Portability : Portable

GADT value for TOML.

  • 3 types
  • 4 values
  • Packagetomland-1.3.3.3
  • Exports7
  • LanguageHaskell2010
  • LicenceMPL-2.0
  • SourceValue.hs

Type of value

2 declarations
datadata TValue
#
Instances6Eq, Read, Show, Generic, NFData, Rep

Value

3 declarations
datadata Value (t :: TValue) where
#

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  # 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 t1] -> 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
    
Instances5Eq, Num, Show, IsString, NFData
  • Eq (Value t)Defined in tomland-1.3.3.3 · Toml.Type.Value
  • t ~ 'TInteger => Num (Value t)Defined in tomland-1.3.3.3 · Toml.Type.Value
  • Show (Value t)Defined in tomland-1.3.3.3 · Toml.Type.Value
  • t ~ 'TText => IsString (Value t)Defined in tomland-1.3.3.3 · Toml.Type.Value
  • NFData (Value t)Defined in tomland-1.3.3.3 · Toml.Type.Value

Type checking

2 declarations
valuesameValue :: Value a -> Value b -> Either TypeMismatchError (a :~: b)
#

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.