on develop help sign in
Adding explicit internal date/time types matching JSON Schema RFC
65605a1Brendan Hay
core/src/Network/Google/Prelude.hs+9
@@ -55,6 +55,15 @@ _Default = iso f Just
55 f (Just x) = x
55 f (Just x) = x
56 f Nothing = mempty
56 f Nothing = mempty
57
57
58+data Time = Time Text
59+ deriving (Eq, Ord, Show, Read, Generic, Data, Typeable, ToText, FromText)
60+
61+data Date = Date Text
62+ deriving (Eq, Ord, Show, Read, Generic, Data, Typeable, ToText, FromText)
63+
64+data DateTime = DateTime Text
65+ deriving (Eq, Ord, Show, Read, Generic, Data, Typeable, ToText, FromText)
66+
58data AltJSON = AltJSON
67data AltJSON = AltJSON
59 deriving (Eq, Ord, Show, Read, Generic, Data, Typeable)
68 deriving (Eq, Ord, Show, Read, Generic, Data, Typeable)
60
69
gen/src/Gen/Syntax.hs+26−24
@@ -386,18 +386,19 @@ internalType = \case
386
386
387externalLit :: Lit -> Type
387externalLit :: Lit -> Type
388externalLit = \case
388externalLit = \case
389− Text -> TyCon "Text"
389+ Text -> TyCon "Text"
390− Bool -> TyCon "Bool"
390+ Bool -> TyCon "Bool"
391− Time -> TyCon "UTCTime"
391+ Time -> TyCon "UTCTime"
392+ Date -> TyCon "UTCTime"
392− Date -> TyCon "UTCTime"
393+ DateTime -> TyCon "UTCTime"
393− Nat -> TyCon "Natural"
394+ Nat -> TyCon "Natural"
394− Float -> TyCon "Float"
395+ Float -> TyCon "Float"
395− Double -> TyCon "Double"
396+ Double -> TyCon "Double"
396− Byte -> TyCon "Word8"
397+ Byte -> TyCon "Word8"
397− UInt32 -> TyCon "Word32"
398+ UInt32 -> TyCon "Word32"
398− UInt64 -> TyCon "Word64"
399+ UInt64 -> TyCon "Word64"
399− Int32 -> TyCon "Int32"
400+ Int32 -> TyCon "Int32"
400− Int64 -> TyCon "Int64"
401+ Int64 -> TyCon "Int64"
401
402
402 Alt t -> TyCon (unqual (Text.unpack t))
403 Alt t -> TyCon (unqual (Text.unpack t))
403 Key -> TyCon "Key"
404 Key -> TyCon "Key"
@@ -406,18 +407,19 @@ externalLit = \case
406
407
407internalLit :: Lit -> Type
408internalLit :: Lit -> Type
408internalLit = \case
409internalLit = \case
409− Text -> TyCon "Text"
410+ Text -> TyCon "Text"
410− Bool -> TyCon "Bool"
411+ Bool -> TyCon "Bool"
411− Time -> TyCon "UTCTime"
412+ Time -> TyCon "Time"
412− Date -> TyCon "UTCTime"
413+ Date -> TyCon "Date"
414+ DateTime -> TyCon "DateTime"
413− Nat -> TyCon "Nat"
415+ Nat -> TyCon "Nat"
414− Float -> TyCon "Float"
416+ Float -> TyCon "Float"
415− Double -> TyCon "Double"
417+ Double -> TyCon "Double"
416− Byte -> TyCon "Word8"
418+ Byte -> TyCon "Word8"
417− UInt32 -> TyCon "Word32"
419+ UInt32 -> TyCon "Word32"
418− UInt64 -> TyCon "Word64"
420+ UInt64 -> TyCon "Word64"
419− Int32 -> TyCon "Int32"
421+ Int32 -> TyCon "Int32"
420− Int64 -> TyCon "Int64"
422+ Int64 -> TyCon "Int64"
421
423
422 Alt t -> TyCon (unqual (Text.unpack t))
424 Alt t -> TyCon (unqual (Text.unpack t))
423 Key -> TyCon "Key"
425 Key -> TyCon "Key"
gen/src/Gen/Types/Schema.hs+4−2
@@ -188,8 +188,9 @@ data Lit
188 | Int32
188 | Int32
189 | Int64
189 | Int64
190 | Nat
190 | Nat
191− | Date
192 | Time
191 | Time
192+ | Date
193+ | DateTime
193 -- Core types.
194 -- Core types.
194 | Body
195 | Body
195 | Alt Text
196 | Alt Text
@@ -213,8 +214,9 @@ instance FromJSON Lit where
213 "uint64" -> pure UInt64
214 "uint64" -> pure UInt64
214 "int32" -> pure Int32
215 "int32" -> pure Int32
215 "int64" -> pure Int64
216 "int64" -> pure Int64
217+ "time" -> pure Time
216 "date" -> pure Date
218 "date" -> pure Date
217− "date-time" -> pure Time
219+ "date-time" -> pure DateTime
218
220
219 _ -> fail $
221 _ -> fail $
220 "Unable to parse Literal from: " ++ Text.unpack t
222 "Unable to parse Literal from: " ++ Text.unpack t