-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathHelpers.hs
More file actions
59 lines (37 loc) · 1.41 KB
/
Helpers.hs
File metadata and controls
59 lines (37 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
module Data.Schematic.Helpers where
import Data.Schematic.Constraints
import GHC.TypeLits
type UUIDRegex =
'TRegex "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
type IsUUID = '[UUIDRegex]
-- [ "1985-04-12T23:20:50.52Z"
-- , "1996-12-19T16:39:57-08:00"
-- , "1990-12-31T23:59:60Z"
-- , "1990-12-31T15:59:60-08:00"
-- , "1937-01-01T12:00:27.87+00:20"
-- ]
-- components
type ISO8601Date = "[1-9][0-9]{3}-(0[1-9]|1[0-2])-([0-2][0-9]|3[0-1])"
type ISO8601Time = "([0-1][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]"
type ISO8601DateTime =
AppendSymbol
ISO8601Date
(AppendSymbol "(T" (AppendSymbol ISO8601Time ")?"))
type ISO8601UTC = "(Z|\\+00:00)"
type ISO8601DateTimeUTC =
AppendSymbol ISO8601Date (AppendSymbol "T" (AppendSymbol ISO8601Time ISO8601UTC))
type ISO8601TZ = "\\+[0-1][0-9]:[0-6][0-9]"
type ISO8601DateTimeZoned =
AppendSymbol ISO8601Date (AppendSymbol "T" (AppendSymbol ISO8601Time ISO8601TZ))
-- regexes
type ISO8601DateRegex = 'TRegex ISO8601Date
type ISO8601TimeRegex = 'TRegex ISO8601Time
type ISO8601DateTimeRegex = 'TRegex ISO8601DateTime
type ISO8601DateTimeRegexUTC = 'TRegex ISO8601DateTimeUTC
type ISO8601DateTimeRegexZoned = 'TRegex ISO8601DateTimeZoned
-- constraints
type IsDate = '[ISO8601DateRegex]
type IsTime = '[ISO8601TimeRegex]
type IsDateTime = '[ISO8601DateTimeRegex]
type IsZonedDateTime = '[ISO8601DateTimeRegexZoned]
type IsUTCDateTime = '[ISO8601DateTimeRegexUTC]