Skip to content

Commit

Permalink
Remove 'constructors' keyword
Browse files Browse the repository at this point in the history
As standardized in dhall-lang/dhall-lang#385
  • Loading branch information
f-f committed Mar 4, 2019
1 parent 268f282 commit 2c9818e
Show file tree
Hide file tree
Showing 12 changed files with 1 addition and 59 deletions.
2 changes: 1 addition & 1 deletion dhall-lang
4 changes: 0 additions & 4 deletions src/dhall_clj/alpha_normalize.clj
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,6 @@
(update :b alpha-normalize)
(assoc :type? (when type? (alpha-normalize type?)))))

dhall_clj.ast.Constructors
(alpha-normalize [this]
(update this :e alpha-normalize))

dhall_clj.ast.Field
(alpha-normalize [this]
(update this :e alpha-normalize))
Expand Down
9 changes: 0 additions & 9 deletions src/dhall_clj/ast.clj
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
(defrecord CombineTypes [a b])
(defrecord Prefer [a b])
(defrecord Merge [a b type?])
(defrecord Constructors [e])
(defrecord Field [e k])
(defrecord Project [e ks])
(defrecord ImportAlt [a b])
Expand Down Expand Up @@ -396,10 +395,6 @@
(update :a shift diff var)
(update :b shift diff var)))

Constructors
(shift [this diff var]
(update this :e shift diff var))

Merge
(shift [this diff var]
(let [type? (:type? this)
Expand Down Expand Up @@ -710,10 +705,6 @@
(update :b subst var e)
(assoc :type? (when type? (subst type? var e)))))

Constructors
(subst [this var e]
(update this :e subst var e))

Field
(subst [this var e]
(update this :e subst var e))
Expand Down
7 changes: 0 additions & 7 deletions src/dhall_clj/beta_normalize.clj
Original file line number Diff line number Diff line change
Expand Up @@ -645,13 +645,6 @@
(:v b')))
(->Merge a' b' type?'))))

dhall_clj.ast.Constructors
(beta-normalize [this]
(let [e' (beta-normalize (:e this))]
(if (instance? UnionT e')
e'
(->Constructors e'))))

dhall_clj.ast.Field
(beta-normalize [{:keys [e k] :as this}]
(let [e' (beta-normalize e)]
Expand Down
5 changes: 0 additions & 5 deletions src/dhall_clj/binary.clj
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@
12 (let [[k v kvs] (rest e)]
(assert-len! e 4)
(->UnionLit k (decbor v) (map-vals decbor kvs)))
13 (->Constructors (decbor (second e)))
14 (let [[test then else] (rest e)]
(assert-len! e 4)
(->BoolIf (decbor test) (decbor then) (decbor else)))
Expand Down Expand Up @@ -489,10 +488,6 @@
[6 (cbor a) (cbor b) (cbor type?)]
[6 (cbor a) (cbor b)]))

dhall_clj.ast.Constructors
(cbor [{:keys [e]}]
[13 (cbor e)])

dhall_clj.ast.Field
(cbor [{:keys [e k]}]
[9 (cbor e) k])
Expand Down
4 changes: 0 additions & 4 deletions src/dhall_clj/emit.clj
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,6 @@
(emit [{:keys [a b type?]}]
"Merge") ;; TODO

dhall_clj.ast.Constructors
(emit [{:keys [e]}]
"Constructors") ;; TODO

dhall_clj.ast.Field
(emit [{:keys [e k]}]
`(get ~(emit e) ~k))
Expand Down
1 change: 0 additions & 1 deletion src/dhall_clj/fail.clj
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@
(typecheck-ex cant-project)
(typecheck-ex cant-text-append)
(typecheck-ex combine-records-requires-record-type)
(typecheck-ex constructors-require-a-union-type)
(typecheck-ex duplicate-alternative)
(typecheck-ex field-annotation-mismatch)
(typecheck-ex field-collision)
Expand Down
4 changes: 0 additions & 4 deletions src/dhall_clj/import.clj
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,6 @@
(update :a resolve-imports state)
(update :b resolve-imports state)))

dhall_clj.ast.Constructors
(resolve-imports [this state]
(update this :e resolve-imports state))

dhall_clj.ast.Merge
(resolve-imports [{:keys [type?] :as this} state]
(-> this
Expand Down
5 changes: 0 additions & 5 deletions src/dhall_clj/parse.clj
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"as"
"using"
"merge"
"constructors"
"Some"])

(defn patch-grammar [grammar]
Expand Down Expand Up @@ -424,13 +423,9 @@
(defmethod expr :application-expression [{:keys [c t]}]
(if (> (count c) 1)
(let [exprs (remove #(= :whitespace-chunk (:t %)) c)
constructors? (= :constructors (-> c first :t))
some? (= :Some (-> c first :t))]
(loop [more (nnext exprs)
app (cond
constructors?
(->Constructors (expr (second exprs)))

some?
(->Some (expr (second exprs)))

Expand Down
11 changes: 0 additions & 11 deletions src/dhall_clj/typecheck.clj
Original file line number Diff line number Diff line change
Expand Up @@ -753,17 +753,6 @@
ktsB)
t))

dhall_clj.ast.Constructors
(typecheck [{:keys [e] :as this} ctx]
(typecheck e ctx)
(let [e' (beta-normalize e)]
(if (instance? UnionT e')
(typecheck e' ctx)
(fail/constructors-require-a-union-type!
ctx
this
{:type e :type-normal e'}))))

dhall_clj.ast.Field
(typecheck [{:keys [e k] :as this} ctx]
(let [eT (-> e (typecheck ctx) beta-normalize)]
Expand Down
2 changes: 0 additions & 2 deletions test/dhall_clj/binary_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
(defn union-type [a] (gen/fmap ->UnionT (kvs a)))
(defn union [a b] (gen/fmap (partial apply ->UnionLit) (gen/tuple label a (kvs b))))
(defn merge' [a b] (gen/fmap (partial apply ->Merge) (gen/tuple a b (maybe b))))
(defn constructors [a] (gen/fmap ->Constructors a))
(defn field [a] (gen/fmap (partial apply ->Field) (gen/tuple a label)))
(defn project [a] (gen/fmap (partial apply ->Project) (gen/tuple a (gen/not-empty (gen/vector label)))))

Expand Down Expand Up @@ -144,7 +143,6 @@
(union-type a)
(union a b)
(merge' a b)
(constructors a)
(field a)
(project a)
(app a b)
Expand Down
6 changes: 0 additions & 6 deletions test/dhall_clj/parser_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,6 @@
["Natural/even 3"
(->App (->NaturalEven) (->NaturalLit 3))]

["constructors < A : Bool >"
(->Constructors (->UnionT {"A" (->BoolT)}))]

["constructors < A : Bool > 2"
(->App (->Constructors (->UnionT {"A" (->BoolT)})) (->NaturalLit 2))]

["foo.a"
(->Field (->Var "foo" 0) "a")]

Expand Down

0 comments on commit 2c9818e

Please sign in to comment.