From 74a835634fc9ee5457f3cc7109af069dad9f2d2f Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 11 Oct 2017 18:57:44 -0400 Subject: - Migrated new-luxc to latest version of stdlib. - Some refactoring. --- new-luxc/source/luxc/analyser/function.lux | 45 +++++++++++++++--------------- 1 file changed, 23 insertions(+), 22 deletions(-) (limited to 'new-luxc/source/luxc/analyser/function.lux') diff --git a/new-luxc/source/luxc/analyser/function.lux b/new-luxc/source/luxc/analyser/function.lux index 31bc367f4..f9fde0eab 100644 --- a/new-luxc/source/luxc/analyser/function.lux +++ b/new-luxc/source/luxc/analyser/function.lux @@ -1,12 +1,13 @@ (;module: lux (lux (control monad) - (data [text] + (data [maybe] + [text] text/format - (coll [list "L/" Fold Monoid Monad])) + (coll [list "list/" Fold Monoid Monad])) [macro #+ Monad] [type] - (type ["TC" check])) + (type ["tc" check])) (luxc ["&" base] (lang ["la" analysis #+ Analysis]) ["&;" scope] @@ -35,23 +36,23 @@ (#;UnivQ _) (do @ - [[var-id var] (&;within-type-env - TC;existential)] - (recur (assume (type;apply (list var) expected)))) + [[var-id var] (&;with-type-env + tc;existential)] + (recur (maybe;assume (type;apply (list var) expected)))) (#;ExQ _) (&common;with-var (function [[var-id var]] - (recur (assume (type;apply (list var) expected))))) + (recur (maybe;assume (type;apply (list var) expected))))) (#;Var id) (do @ - [? (&;within-type-env - (TC;bound? id))] + [? (&;with-type-env + (tc;bound? id))] (if ? (do @ - [expected' (&;within-type-env - (TC;read-var id))] + [expected' (&;with-type-env + (tc;read id))] (recur expected')) ## Inference (&common;with-var @@ -61,16 +62,16 @@ (do @ [#let [funT (#;Function inputT outputT)] funA (recur funT) - funT' (&;within-type-env - (TC;clean output-id funT)) - concrete-input? (&;within-type-env - (TC;bound? input-id)) + funT' (&;with-type-env + (tc;clean output-id funT)) + concrete-input? (&;with-type-env + (tc;bound? input-id)) funT'' (if concrete-input? - (&;within-type-env - (TC;clean input-id funT')) + (&;with-type-env + (tc;clean input-id funT')) (wrap (type;univ-q +1 (&inference;replace-var input-id +1 funT')))) - _ (&;within-type-env - (TC;check expected funT''))] + _ (&;with-type-env + (tc;check expected funT''))] (wrap funA)) )))))) @@ -92,10 +93,10 @@ (-> &;Analyser Type Analysis (List Code) (Lux Analysis)) (&;with-stacked-errors (function [_] (format "Cannot apply function " (%type funcT) - " to args: " (|> args (L/map %code) (text;join-with " ")))) + " to args: " (|> args (list/map %code) (text;join-with " ")))) (do Monad [expected macro;expected-type [applyT argsA] (&inference;apply-function analyse funcT args) - _ (&;within-type-env - (TC;check expected applyT))] + _ (&;with-type-env + (tc;check expected applyT))] (wrap (la;apply argsA funcA))))) -- cgit v1.2.3