aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/analysis/inference.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--new-luxc/source/luxc/lang/analysis/inference.lux28
1 files changed, 17 insertions, 11 deletions
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 [<name>]
+ [(exception: #export (<name> {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<Meta>
[[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)]))