From ca238f9c89d3156842b0a3d5fe24a5d69b2eedb0 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 6 Apr 2018 08:32:41 -0400 Subject: - Adapted new-luxc's code to latest stdlib changes. --- new-luxc/source/luxc/lang/analysis/inference.lux | 28 ++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'new-luxc/source/luxc/lang/analysis/inference.lux') diff --git a/new-luxc/source/luxc/lang/analysis/inference.lux b/new-luxc/source/luxc/lang/analysis/inference.lux index 3919ff78d..9bc668050 100644 --- a/new-luxc/source/luxc/lang/analysis/inference.lux +++ b/new-luxc/source/luxc/lang/analysis/inference.lux @@ -13,23 +13,28 @@ (lang ["la" analysis #+ Analysis] (analysis ["&." common])))) -(exception: #export Cannot-Infer) +(do-template [] + [(exception: #export ( {message Text}) + message)] + + [Cannot-Infer] + [Cannot-Infer-Argument] + [Smaller-Variant-Than-Expected] + [Invalid-Type-Application] + [Not-A-Record-Type] + [Not-A-Variant-Type] + ) + (def: (cannot-infer type args) (-> Type (List Code) Text) (format " Type: " (%type type) "\n" "Arguments:" (|> args list.enumerate - (list/map (function [[idx argC]] + (list/map (function (_ [idx argC]) (format "\n " (%n idx) " " (%code argC)))) (text.join-with "")))) -(exception: #export Cannot-Infer-Argument) -(exception: #export Smaller-Variant-Than-Expected) -(exception: #export Invalid-Type-Application) -(exception: #export Not-A-Record-Type) -(exception: #export Not-A-Variant-Type) - (def: (replace-bound bound-idx replacementT type) (-> Nat Type Type Type) (case type @@ -131,9 +136,10 @@ (do macro.Monad [[outputT' args'A] (general analyse outputT args') argA (&.with-stacked-errors - (function [_] (Cannot-Infer-Argument - (format "Inferred Type: " (%type inputT) "\n" - " Argument: " (%code argC)))) + (function (_ _) + (ex.construct Cannot-Infer-Argument + (format "Inferred Type: " (%type inputT) "\n" + " Argument: " (%code argC)))) (&.with-type inputT (analyse argC)))] (wrap [outputT' (list& argA args'A)])) -- cgit v1.2.3