module Toml.Value (
Value(..),
Table,
) where
import Data.Data (Data)
import Data.Map (Map)
import Data.Time (Day, LocalTime, TimeOfDay, ZonedTime(zonedTimeToLocalTime, zonedTimeZone), timeZoneMinutes)
import GHC.Generics (Generic)
type Table = Map String Value
data Value
= Integer Integer
| Float Double
| Array [Value]
| Table Table
| Bool Bool
| String String
| TimeOfDay TimeOfDay
| ZonedTime ZonedTime
| LocalTime LocalTime
| Day Day
deriving (
Show ,
Read ,
Data ,
Generic )
instance Eq Value where
Integer Integer
x == :: Value -> Value -> Bool
== Integer Integer
y = Integer
x Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
== Integer
y
Float Double
x == Float Double
y = Double
x Double -> Double -> Bool
forall a. Eq a => a -> a -> Bool
== Double
y
Array [Value]
x == Array [Value]
y = [Value]
x [Value] -> [Value] -> Bool
forall a. Eq a => a -> a -> Bool
== [Value]
y
Table Table
x == Table Table
y = Table
x Table -> Table -> Bool
forall a. Eq a => a -> a -> Bool
== Table
y
Bool Bool
x == Bool Bool
y = Bool
x Bool -> Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Bool
y
String String
x == String String
y = String
x String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
y
TimeOfDay TimeOfDay
x == TimeOfDay TimeOfDay
y = TimeOfDay
x TimeOfDay -> TimeOfDay -> Bool
forall a. Eq a => a -> a -> Bool
== TimeOfDay
y
LocalTime LocalTime
x == LocalTime LocalTime
y = LocalTime
x LocalTime -> LocalTime -> Bool
forall a. Eq a => a -> a -> Bool
== LocalTime
y
Day Day
x == Day Day
y = Day
x Day -> Day -> Bool
forall a. Eq a => a -> a -> Bool
== Day
y
ZonedTime ZonedTime
x == ZonedTime ZonedTime
y = ZonedTime -> (LocalTime, Int)
projectZT ZonedTime
x (LocalTime, Int) -> (LocalTime, Int) -> Bool
forall a. Eq a => a -> a -> Bool
== ZonedTime -> (LocalTime, Int)
projectZT ZonedTime
y
Value
_ == Value
_ = Bool
False
projectZT :: ZonedTime -> (LocalTime, Int)
projectZT :: ZonedTime -> (LocalTime, Int)
projectZT ZonedTime
x = (ZonedTime -> LocalTime
zonedTimeToLocalTime ZonedTime
x, TimeZone -> Int
timeZoneMinutes (ZonedTime -> TimeZone
zonedTimeZone ZonedTime
x))