diff options
Diffstat (limited to 'stdlib/source/lux/type/check.lux')
-rw-r--r-- | stdlib/source/lux/type/check.lux | 49 |
1 files changed, 11 insertions, 38 deletions
diff --git a/stdlib/source/lux/type/check.lux b/stdlib/source/lux/type/check.lux index e8f24102c..1779f62bd 100644 --- a/stdlib/source/lux/type/check.lux +++ b/stdlib/source/lux/type/check.lux @@ -253,7 +253,7 @@ =right (clean t-id right)] (wrap (<tag> =left =right)))) ([#;Function] - [#;App] + [#;Apply] [#;Product] [#;Sum]) @@ -293,36 +293,9 @@ (def: #export (delete-var id) (-> Nat (Check Unit)) - (do Monad<Check> - [? (bound? id) - _ (if ? - (wrap []) - (do Monad<Check> - [[ex-id ex] existential] - (write-var id ex))) - bindings get-bindings - bindings' (mapM @ - (function [(^@ binding [b-id b-type])] - (if (n.= id b-id) - (wrap binding) - (case b-type - #;None - (wrap binding) - - (#;Some b-type') - (case b-type' - (#;Var t-id) - (if (n.= id t-id) - (wrap [b-id #;None]) - (wrap binding)) - - _ - (do Monad<Check> - [b-type'' (clean id b-type')] - (wrap [b-id (#;Some b-type'')]))) - ))) - bindings)] - (set-bindings (var::remove id bindings')))) + (function [context] + (#R;Success [(update@ #;var-bindings (var::remove id) context) + []]))) (def: #export (with-var k) (All [a] (-> (-> [Nat Type] (Check a)) (Check a))) @@ -429,32 +402,32 @@ (function [bound] (check' expected bound fixed))) - [(#;App (#;Ex eid) eA) (#;App (#;Ex aid) aA)] + [(#;Apply eA (#;Ex eid)) (#;Apply aA (#;Ex aid))] (if (n.= eid aid) (check' eA aA fixed) (fail-check expected actual)) - [(#;App (#;Var id) A1) (#;App F2 A2)] + [(#;Apply A1 (#;Var id)) (#;Apply A2 F2)] (either (do Monad<Check> [F1 (read-var id)] - (check' (#;App F1 A1) actual fixed)) + (check' (#;Apply A1 F1) actual fixed)) (do Monad<Check> [fixed (check' (#;Var id) F2 fixed) e' (apply-type! F2 A1) a' (apply-type! F2 A2)] (check' e' a' fixed))) - [(#;App F1 A1) (#;App (#;Var id) A2)] + [(#;Apply A1 F1) (#;Apply A2 (#;Var id))] (either (do Monad<Check> [F2 (read-var id)] - (check' expected (#;App F2 A2) fixed)) + (check' expected (#;Apply A2 F2) fixed)) (do Monad<Check> [fixed (check' F1 (#;Var id) fixed) e' (apply-type! F1 A1) a' (apply-type! F1 A2)] (check' e' a' fixed))) - [(#;App F A) _] + [(#;Apply A F) _] (let [fx-pair [expected actual]] (case (fx-get fx-pair fixed) (#;Some ?) @@ -467,7 +440,7 @@ [expected' (apply-type! F A)] (check' expected' actual (fx-put fx-pair true fixed))))) - [_ (#;App F A)] + [_ (#;Apply A F)] (do Monad<Check> [actual' (apply-type! F A)] (check' expected actual' fixed)) |