From 8b7f5c6d38d45c1f38aa2c416afbd8c38f0bfafb Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 26 Apr 2015 16:51:17 -0400 Subject: Made a correction to lux.lux and the analyser regarding how to handle type-vars. --- source/lux.lux | 7 ++++--- src/lux/analyser/lux.clj | 3 ++- src/lux/type.clj | 15 +++++++++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/source/lux.lux b/source/lux.lux index 19a89c8ee..c5a532a2a 100644 --- a/source/lux.lux +++ b/source/lux.lux @@ -516,9 +516,10 @@ (fold f (f init x) xs'))) (def (reverse' list) - (->' ($' List Syntax) ($' List Syntax)) - (fold (:' (->' ($' List Syntax) Syntax - ($' List Syntax)) + (All' [a] + (->' ($' List (B' a)) ($' List (B' a)))) + (fold (:' (All' [a] + (->' ($' List (B' a)) (B' a) ($' List (B' a)))) (lambda [tail head] (#Cons [head tail]))) #Nil diff --git a/src/lux/analyser/lux.clj b/src/lux/analyser/lux.clj index c9244a91e..1761ec1a2 100644 --- a/src/lux/analyser/lux.clj +++ b/src/lux/analyser/lux.clj @@ -267,7 +267,8 @@ [["lux;VarT" ?id]] (|do [? (&type/bound? ?id)] (if ? - (fail "[Analyser Error] Can't use type-var in any type-specific way inside polymorphic functions.") + (|do [dtype (&type/deref ?id)] + (fail (str "[Analyser Error] Can't use type-var in any type-specific way inside polymorphic functions: " ?id (&type/show-type dtype)))) (return output))))))) [_] diff --git a/src/lux/type.clj b/src/lux/type.clj index 82a405977..dcaf0bf5e 100644 --- a/src/lux/type.clj +++ b/src/lux/type.clj @@ -138,10 +138,17 @@ (defn bound? [id] (fn [state] - (if-let [type* (->> state (&/get$ &/$TYPES) (&/get$ &/$MAPPINGS) (&/|get id))] - (matchv ::M/objects [type*] - [["lux;Some" _]] - (return* state true) + (if-let [type (->> state (&/get$ &/$TYPES) (&/get$ &/$MAPPINGS) (&/|get id))] + (matchv ::M/objects [type] + [["lux;Some" type*]] + (matchv ::M/objects [type*] + [["lux;VarT" ?id]] + (&/run-state (&/try-all% (&/|list (bound? ?id) + (return false))) + state) + + [_] + (return* state true)) [["lux;None" _]] (return* state false)) -- cgit v1.2.3