Skip to content

Commit 99642f0

Browse files
authored
Merge pull request #63 from Gabriel439/gabriel/57
Remove dependence on `Prelude/JSON/Type.dhall` file
2 parents 41c8c73 + 8f50232 commit 99642f0

File tree

1 file changed

+61
-8
lines changed

1 file changed

+61
-8
lines changed

unmarshal.go

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,68 @@ var jsonConstructors core.Value = core.RecordLit{
3838
}
3939

4040
func mkJSONType() core.Value {
41-
term, err := parser.ParseFile("./dhall-lang/Prelude/JSON/Type.dhall")
42-
if err != nil {
43-
panic(err)
44-
}
45-
_, err = core.TypeOf(term)
46-
if err != nil {
47-
panic(err)
41+
return core.Pi{
42+
Label: "JSON",
43+
Domain: core.Type,
44+
Codomain: func(JSON core.Value) core.Value {
45+
return core.Pi{
46+
Label: "json",
47+
Domain: core.RecordType{
48+
"array": core.Pi{
49+
Label: "_",
50+
Domain: core.ListOf{JSON},
51+
Codomain: func(_ core.Value) core.Value{
52+
return JSON
53+
},
54+
},
55+
"bool": core.Pi{
56+
Label: "_",
57+
Domain: core.Bool,
58+
Codomain: func(_ core.Value) core.Value{
59+
return JSON
60+
},
61+
},
62+
"double": core.Pi{
63+
Label: "_",
64+
Domain: core.Double,
65+
Codomain: func(_ core.Value) core.Value{
66+
return JSON
67+
},
68+
},
69+
"integer": core.Pi{
70+
Label: "_",
71+
Domain: core.Integer,
72+
Codomain: func(_ core.Value) core.Value{
73+
return JSON
74+
},
75+
},
76+
"null": JSON,
77+
"object": core.Pi{
78+
Label: "_",
79+
Domain: core.ListOf{
80+
Type: core.RecordType{
81+
"mapKey": core.Text,
82+
"mapValue": JSON,
83+
},
84+
},
85+
Codomain: func(_ core.Value) core.Value{
86+
return JSON
87+
},
88+
},
89+
"string": core.Pi{
90+
Label: "_",
91+
Domain: core.Text,
92+
Codomain: func(_ core.Value) core.Value{
93+
return JSON
94+
},
95+
},
96+
},
97+
Codomain: func(json core.Value) core.Value {
98+
return JSON
99+
},
100+
}
101+
},
48102
}
49-
return core.Eval(term)
50103
}
51104

52105
// Unmarshal takes dhall input as a byte array and parses it, resolves

0 commit comments

Comments
 (0)