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/function.lux | 38 +++++++++++++++---------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'new-luxc/source/luxc/lang/analysis/function.lux') diff --git a/new-luxc/source/luxc/lang/analysis/function.lux b/new-luxc/source/luxc/lang/analysis/function.lux index a502a9d19..eaddfa5bb 100644 --- a/new-luxc/source/luxc/lang/analysis/function.lux +++ b/new-luxc/source/luxc/lang/analysis/function.lux @@ -17,9 +17,14 @@ ["&." inference]) [".L" variable #+ Variable]))) -(exception: #export Cannot-Analyse-Function) -(exception: #export Invalid-Function-Type) -(exception: #export Cannot-Apply-Function) +(do-template [] + [(exception: #export ( {message Text}) + message)] + + [Cannot-Analyse-Function] + [Invalid-Function-Type] + [Cannot-Apply-Function] + ) ## [Analysers] (def: #export (analyse-function analyse func-name arg-name body) @@ -28,10 +33,12 @@ [functionT macro.expected-type] (loop [expectedT functionT] (&.with-stacked-errors - (function [_] (Cannot-Analyse-Function (format " Type: " (%type expectedT) "\n" - "Function: " func-name "\n" - "Argument: " arg-name "\n" - " Body: " (%code body)))) + (function (_ _) + (ex.construct Cannot-Analyse-Function + (format " Type: " (%type expectedT) "\n" + "Function: " func-name "\n" + "Argument: " arg-name "\n" + " Body: " (%code body)))) (case expectedT (#.Named name unnamedT) (recur unnamedT) @@ -73,7 +80,7 @@ )) (#.Function inputT outputT) - (<| (:: @ map (function [[scope bodyA]] + (<| (:: @ map (function (_ [scope bodyA]) (` ("lux function" [(~+ (list/map code.int (variableL.environment scope)))] (~ bodyA))))) &.with-scope @@ -91,13 +98,14 @@ (def: #export (analyse-apply analyse funcT funcA args) (-> &.Analyser Type Analysis (List Code) (Meta Analysis)) (&.with-stacked-errors - (function [_] - (Cannot-Apply-Function (format " Function: " (%type funcT) "\n" - "Arguments:" (|> args - list.enumerate - (list/map (function [[idx argC]] - (format "\n " (%n idx) " " (%code argC)))) - (text.join-with ""))))) + (function (_ _) + (ex.construct Cannot-Apply-Function + (format " Function: " (%type funcT) "\n" + "Arguments:" (|> args + list.enumerate + (list/map (function (_ [idx argC]) + (format "\n " (%n idx) " " (%code argC)))) + (text.join-with ""))))) (do macro.Monad [[applyT argsA] (&inference.general analyse funcT args)] (wrap (la.apply argsA funcA))))) -- cgit v1.2.3