Skip to content

Commit 780fbaa

Browse files
committed
Update to standard v17.0.0 (#46)
1 parent deda159 commit 780fbaa

File tree

14 files changed

+2116
-2749
lines changed

14 files changed

+2116
-2749
lines changed

binary/cbor.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ var nameToBuiltin = map[string]Term{
5050
"List/last": ListLast,
5151
"List/indexed": ListIndexed,
5252
"List/reverse": ListReverse,
53-
54-
"Optional/build": OptionalBuild,
55-
"Optional/fold": OptionalFold,
5653
}
5754

5855
func unwrapUint(i interface{}) (uint, error) {
@@ -107,7 +104,7 @@ func decode(decodedCbor interface{}) (Term, error) {
107104
// _@n
108105
return Var{Name: "_", Index: int(val)}, nil
109106
case string:
110-
// Type, Double, Optional/fold
107+
// Type, Double, List/fold
111108
if builtin, ok := nameToBuiltin[val]; ok {
112109
return builtin, nil
113110
}

core/ast.go

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,8 @@ type (
7676

7777
doubleShow struct{}
7878

79-
optional struct{}
80-
optionalBuild struct{ typ Value }
81-
optionalFold struct {
82-
typ1 Value
83-
opt Value
84-
typ2 Value
85-
some Value
86-
// none Value
87-
}
88-
none struct{}
79+
optional struct{}
80+
none struct{}
8981

9082
textShow struct{}
9183

@@ -124,10 +116,8 @@ func (integerToDouble) isValue() {}
124116

125117
func (doubleShow) isValue() {}
126118

127-
func (optional) isValue() {}
128-
func (optionalBuild) isValue() {}
129-
func (optionalFold) isValue() {}
130-
func (none) isValue() {}
119+
func (optional) isValue() {}
120+
func (none) isValue() {}
131121

132122
func (textShow) isValue() {}
133123

core/builtins.go

Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -193,80 +193,6 @@ func (doubleShow) ArgType() Value { return Double }
193193
func (optional) Call(x Value) Value { return OptionalOf{x} }
194194
func (optional) ArgType() Value { return Type }
195195

196-
func (build optionalBuild) Call(x Value) Value {
197-
if build.typ == nil {
198-
return optionalBuild{typ: x}
199-
}
200-
var some Value = lambda{
201-
Label: "a",
202-
Domain: build.typ,
203-
Fn: func(a Value) Value {
204-
return Some{a}
205-
},
206-
}
207-
return apply(x, OptionalOf{build.typ}, some, NoneOf{build.typ})
208-
}
209-
210-
func (build optionalBuild) ArgType() Value {
211-
if build.typ == nil {
212-
return Type
213-
}
214-
return NewPi("optional", Type, func(optional Value) Value {
215-
return NewFnType("just", NewFnType("_", build.typ, optional),
216-
NewFnType("nothing", optional,
217-
optional))
218-
})
219-
}
220-
221-
func (fold optionalFold) Call(x Value) Value {
222-
if fold.typ1 == nil {
223-
return optionalFold{typ1: x}
224-
}
225-
if fold.opt == nil {
226-
return optionalFold{typ1: fold.typ1, opt: x}
227-
}
228-
if fold.typ2 == nil {
229-
return optionalFold{
230-
typ1: fold.typ1,
231-
opt: fold.opt,
232-
typ2: x,
233-
}
234-
}
235-
if fold.some == nil {
236-
return optionalFold{
237-
typ1: fold.typ1,
238-
opt: fold.opt,
239-
typ2: fold.typ2,
240-
some: x,
241-
}
242-
}
243-
none := x
244-
if s, ok := fold.opt.(Some); ok {
245-
return apply(fold.some, s.Val)
246-
}
247-
if _, ok := fold.opt.(NoneOf); ok {
248-
return none
249-
}
250-
return nil
251-
}
252-
253-
func (fold optionalFold) ArgType() Value {
254-
if fold.typ1 == nil {
255-
return Type
256-
}
257-
if fold.opt == nil {
258-
return OptionalOf{fold.typ1}
259-
}
260-
if fold.typ2 == nil {
261-
return Type
262-
}
263-
if fold.some == nil {
264-
return NewFnType("_", fold.typ1, fold.typ2)
265-
}
266-
// none
267-
return fold.typ2
268-
}
269-
270196
func (none) Call(a Value) Value { return NoneOf{a} }
271197
func (none) ArgType() Value { return Type }
272198

@@ -527,10 +453,8 @@ var (
527453
IntegerToDouble Callable = integerToDouble{}
528454
DoubleShow Callable = doubleShow{}
529455

530-
Optional Callable = optional{}
531-
OptionalBuild Callable = optionalBuild{}
532-
OptionalFold Callable = optionalFold{}
533-
None Callable = none{}
456+
Optional Callable = optional{}
457+
None Callable = none{}
534458

535459
TextShow Callable = textShow{}
536460

core/builtins_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,6 @@ var _ = DescribeTable("ArgType of builtins", func(src, typ string) {
4949
Entry("List/reverse arg 1", `List/reverse`, `Type`),
5050
Entry("List/reverse arg 2", `List/reverse Natural`, `List Natural`),
5151

52-
Entry("Optional/build arg 1", `Optional/build`, `Type`),
53-
Entry("Optional/build arg 2", `Optional/build Natural`,
54-
`∀(optional : Type) → ∀(just : Natural → optional) → ∀(nothing : optional) → optional`),
55-
Entry("Optional/fold arg 1", `Optional/fold`, `Type`),
56-
Entry("Optional/fold arg 2", `Optional/fold Natural`, `Optional Natural`),
57-
Entry("Optional/fold arg 3", `Optional/fold Natural (Some 2)`, `Type`),
58-
Entry("Optional/fold arg 4", `Optional/fold Natural (Some 2) Text`, `Natural → Text`),
59-
Entry("Optional/fold arg 5", `Optional/fold Natural (Some 2) Text (λ(x : Natural) → "some")`, `Text`),
60-
6152
Entry("Integer/show", `Integer/show`, `Integer`),
6253
Entry("Integer/toDouble", `Integer/toDouble`, `Integer`),
6354
Entry("Integer/negate", `Integer/negate`, `Integer`),

core/equivalence.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func alphaEquivalentWith(level int, v1 Value, v2 Value) bool {
2020
naturalSubtract, naturalToInteger,
2121
integerShow, integerClamp, integerNegate, integerToDouble,
2222
doubleShow,
23-
optional, optionalBuild, optionalFold, none,
23+
optional, none,
2424
textShow,
2525
list, listBuild, listFold, listHead, listIndexed,
2626
listLength, listLast, listReverse,

core/eval.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ func evalWith(t term.Term, e env) Value {
5858
return DoubleShow
5959
case term.Optional:
6060
return Optional
61-
case term.OptionalBuild:
62-
return OptionalBuild
63-
case term.OptionalFold:
64-
return OptionalFold
6561
case term.None:
6662
return None
6763
case term.Text:

core/quote.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -78,29 +78,6 @@ func quoteWith(ctx quoteContext, shouldAlphaNormalize bool, v Value) term.Term {
7878
return term.DoubleShow
7979
case optional:
8080
return term.Optional
81-
case optionalBuild:
82-
if v.typ != nil {
83-
return term.App{term.OptionalBuild, quoteWith(ctx, shouldAlphaNormalize, v.typ)}
84-
}
85-
return term.OptionalBuild
86-
case optionalFold:
87-
var result term.Term = term.OptionalFold
88-
if v.typ1 == nil {
89-
return result
90-
}
91-
result = term.App{result, quoteWith(ctx, shouldAlphaNormalize, v.typ1)}
92-
if v.opt == nil {
93-
return result
94-
}
95-
result = term.App{result, quoteWith(ctx, shouldAlphaNormalize, v.opt)}
96-
if v.typ2 == nil {
97-
return result
98-
}
99-
result = term.App{result, quoteWith(ctx, shouldAlphaNormalize, v.typ2)}
100-
if v.some == nil {
101-
return result
102-
}
103-
return term.App{result, quoteWith(ctx, shouldAlphaNormalize, v.some)}
10481
case none:
10582
return term.None
10683
case textShow:

core/typecheck.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -158,26 +158,6 @@ func typeWith(ctx context, t term.Term) (Value, error) {
158158
return NewFnType("_", Natural, NewFnType("_", Natural, Natural)), nil
159159
case term.None:
160160
return NewPi("A", Type, func(A Value) Value { return OptionalOf{A} }), nil
161-
case term.OptionalBuild:
162-
return NewPi("a", Type, func(a Value) Value {
163-
return NewFnType("_",
164-
NewPi("optional", Type, func(optional Value) Value {
165-
return NewFnType("just",
166-
NewFnType("_", a, optional),
167-
NewFnType("nothing", optional, optional))
168-
}),
169-
OptionalOf{a})
170-
}), nil
171-
case term.OptionalFold:
172-
return NewPi("a", Type, func(a Value) Value {
173-
return NewFnType("_",
174-
OptionalOf{a},
175-
NewPi("optional", Type, func(optional Value) Value {
176-
return NewFnType("just",
177-
NewFnType("_", a, optional),
178-
NewFnType("nothing", optional, optional))
179-
}))
180-
}), nil
181161
case term.TextShow:
182162
return NewFnType("_", Text, Text), nil
183163
default:

dhall-lang

Submodule dhall-lang updated 199 files

doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ handling skipped for brevity):
2424
dhallBytes, err := ioutil.ReadFile("foo.dhall")
2525
err = dhall.Unmarshal(dhallBytes, &m)
2626
27-
This version supports Dhall standard 15.0.0, except that it doesn't
27+
This version supports Dhall standard 17.0.0, except that it doesn't
2828
support `using` directives.
2929
*/
3030
package dhall

0 commit comments

Comments
 (0)