-
-
Notifications
You must be signed in to change notification settings - Fork 174
/
Type.dhall
63 lines (54 loc) · 1.39 KB
/
Type.dhall
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
60
61
62
63
{-|
Dhall encoding of an arbitrary JSON value
For example, the following JSON value:
```
[ { "foo": null, "bar": [ 1.0, true ] } ]
```
... corresponds to the following Dhall expression:
```
λ(JSON : Type) →
λ ( json
: { array : List JSON → JSON
, bool : Bool → JSON
, null : JSON
, double : Double → JSON
, integer : Integer → JSON
, object : List { mapKey : Text, mapValue : JSON } → JSON
, string : Text → JSON
}
) →
json.object
[ { mapKey = "foo", mapValue = json.null }
, { mapKey = "bar"
, mapValue = json.array [ json.double 1.0, json.bool True ]
}
]
```
You do not need to create these values directly, though. You can use
the utilities exported by `./package.dhall` to create values of this type,
such as:
```
let JSON = ./package.dhall
in JSON.object
[ { mapKey = "foo", mapValue = JSON.null }
, { mapKey = "bar"
, mapValue = JSON.array [ JSON.double 1.0, JSON.bool True ]
}
]
```
-}
let JSON/Type
: Type
= ∀(JSON : Type) →
∀ ( json
: { array : List JSON → JSON
, bool : Bool → JSON
, double : Double → JSON
, integer : Integer → JSON
, null : JSON
, object : List { mapKey : Text, mapValue : JSON } → JSON
, string : Text → JSON
}
) →
JSON
in JSON/Type