From b08f7d83a591be770af64b4c9ccd59f3306689e8 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 13 Nov 2017 21:13:00 -0400 Subject: - Improved handling of type variables. --- stdlib/source/lux/meta/type/check.lux | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'stdlib') diff --git a/stdlib/source/lux/meta/type/check.lux b/stdlib/source/lux/meta/type/check.lux index bd49a5588..d6589760e 100644 --- a/stdlib/source/lux/meta/type/check.lux +++ b/stdlib/source/lux/meta/type/check.lux @@ -144,16 +144,6 @@ (function [context] (ex;throw exception message))) -(def: (apply-type! funcT argT) - (-> Type Type (Check Type)) - (function [context] - (case (type;apply (list argT) funcT) - #;None - (ex;throw Invalid-Type-Application (type;to-text (#;Apply argT funcT))) - - (#;Some output) - (#e;Success [context output])))) - (def: #export existential {#;doc "A producer of existential types."} (Check [Nat Type]) @@ -296,6 +286,27 @@ (#e;Success [(set@ #;var-bindings value context) []]))) +(def: (apply-type! funcT argT) + (-> Type Type (Check Type)) + (case funcT + (#;Var func-id) + (do Monad + [? (concrete? func-id)] + (if ? + (do @ + [funcT' (read func-id)] + (apply-type! funcT' argT)) + (throw Invalid-Type-Application (type;to-text (#;Apply argT funcT))))) + + _ + (function [context] + (case (type;apply (list argT) funcT) + #;None + (ex;throw Invalid-Type-Application (type;to-text (#;Apply argT funcT))) + + (#;Some output) + (#e;Success [context output]))))) + (type: #export Ring (Set Var)) (def: empty-ring Ring (set;new number;Hash)) -- cgit v1.2.3