diff options
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/lang/extension/analysis/common.lux | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/new-luxc/source/luxc/lang/extension/analysis/common.lux b/new-luxc/source/luxc/lang/extension/analysis/common.lux index 9fc807f75..8ec031066 100644 --- a/new-luxc/source/luxc/lang/extension/analysis/common.lux +++ b/new-luxc/source/luxc/lang/extension/analysis/common.lux @@ -20,8 +20,13 @@ [".A" type]))) [///]) -(exception: #export Incorrect-Procedure-Arity) -(exception: #export Invalid-Syntax) +(do-template [<name>] + [(exception: #export (<name> {message Text}) + message)] + + [Incorrect-Procedure-Arity] + [Invalid-Syntax] + ) ## [Utils] (type: #export Bundle @@ -36,7 +41,7 @@ (-> Text Bundle Bundle) (|> bundle dict.entries - (list/map (function [[key val]] [(format prefix " " key) val])) + (list/map (function (_ [key val]) [(format prefix " " key) val])) (dict.from-list text.Hash<Text>))) (def: #export (wrong-arity proc expected actual) @@ -48,13 +53,13 @@ (def: (simple proc inputsT+ outputT) (-> Text (List Type) Type ///.Analysis) (let [num-expected (list.size inputsT+)] - (function [analyse eval args] + (function (_ analyse eval args) (let [num-actual (list.size args)] (if (n/= num-expected num-actual) (do macro.Monad<Meta> [_ (&.infer outputT) argsA (monad.map @ - (function [[argT argC]] + (function (_ [argT argC]) (&.with-type argT (analyse argC))) (list.zip2 inputsT+ args))] @@ -81,7 +86,7 @@ ## "lux is" represents reference/pointer equality. (def: (lux//is proc) (-> Text ///.Analysis) - (function [analyse eval args] + (function (_ analyse eval args) (do macro.Monad<Meta> [[var-id varT] (&.with-type-env tc.var)] ((binary varT varT Bool proc) @@ -91,7 +96,7 @@ ## error-handling facilities. (def: (lux//try proc) (-> Text ///.Analysis) - (function [analyse eval args] + (function (_ analyse eval args) (case args (^ (list opC)) (do macro.Monad<Meta> @@ -106,7 +111,7 @@ (def: (lux//function proc) (-> Text ///.Analysis) - (function [analyse eval args] + (function (_ analyse eval args) (case args (^ (list [_ (#.Symbol ["" func-name])] [_ (#.Symbol ["" arg-name])] @@ -118,7 +123,7 @@ (def: (lux//case proc) (-> Text ///.Analysis) - (function [analyse eval args] + (function (_ analyse eval args) (case args (^ (list input [_ (#.Record branches)])) (caseA.analyse-case analyse input branches) @@ -128,7 +133,7 @@ (def: (lux//in-module proc) (-> Text ///.Analysis) - (function [analyse eval argsC+] + (function (_ analyse eval argsC+) (case argsC+ (^ (list [_ (#.Text module-name)] exprC)) (&.with-current-module module-name @@ -138,14 +143,14 @@ (&.throw Invalid-Syntax (format "Procedure: " proc "\n" " Inputs:" (|> argsC+ list.enumerate - (list/map (function [[idx argC]] + (list/map (function (_ [idx argC]) (format "\n " (%n idx) " " (%code argC)))) (text.join-with "")) "\n"))))) (do-template [<name> <analyser>] [(def: (<name> proc) (-> Text ///.Analysis) - (function [analyse eval args] + (function (_ analyse eval args) (case args (^ (list typeC valueC)) (<analyser> analyse eval typeC valueC) @@ -158,7 +163,7 @@ (def: (lux//check//type proc) (-> Text ///.Analysis) - (function [analyse eval args] + (function (_ analyse eval args) (case args (^ (list valueC)) (do macro.Monad<Meta> @@ -295,7 +300,7 @@ (def: (array//get proc) (-> Text ///.Analysis) - (function [analyse eval args] + (function (_ analyse eval args) (do macro.Monad<Meta> [[var-id varT] (&.with-type-env tc.var)] ((binary (type (Array varT)) Nat (type (Maybe varT)) proc) @@ -303,7 +308,7 @@ (def: (array//put proc) (-> Text ///.Analysis) - (function [analyse eval args] + (function (_ analyse eval args) (do macro.Monad<Meta> [[var-id varT] (&.with-type-env tc.var)] ((trinary (type (Array varT)) Nat varT (type (Array varT)) proc) @@ -311,7 +316,7 @@ (def: (array//remove proc) (-> Text ///.Analysis) - (function [analyse eval args] + (function (_ analyse eval args) (do macro.Monad<Meta> [[var-id varT] (&.with-type-env tc.var)] ((binary (type (Array varT)) Nat (type (Array varT)) proc) @@ -352,7 +357,7 @@ (def: (atom-new proc) (-> Text ///.Analysis) - (function [analyse eval args] + (function (_ analyse eval args) (case args (^ (list initC)) (do macro.Monad<Meta> @@ -367,7 +372,7 @@ (def: (atom-read proc) (-> Text ///.Analysis) - (function [analyse eval args] + (function (_ analyse eval args) (do macro.Monad<Meta> [[var-id varT] (&.with-type-env tc.var)] ((unary (type (Atom varT)) varT proc) @@ -375,7 +380,7 @@ (def: (atom//compare-and-swap proc) (-> Text ///.Analysis) - (function [analyse eval args] + (function (_ analyse eval args) (do macro.Monad<Meta> [[var-id varT] (&.with-type-env tc.var)] ((trinary (type (Atom varT)) varT varT Bool proc) @@ -395,7 +400,7 @@ (def: (box//new proc) (-> Text ///.Analysis) - (function [analyse eval args] + (function (_ analyse eval args) (case args (^ (list initC)) (do macro.Monad<Meta> @@ -410,7 +415,7 @@ (def: (box//read proc) (-> Text ///.Analysis) - (function [analyse eval args] + (function (_ analyse eval args) (do macro.Monad<Meta> [[thread-id threadT] (&.with-type-env tc.var) [var-id varT] (&.with-type-env tc.var)] @@ -419,7 +424,7 @@ (def: (box//write proc) (-> Text ///.Analysis) - (function [analyse eval args] + (function (_ analyse eval args) (do macro.Monad<Meta> [[thread-id threadT] (&.with-type-env tc.var) [var-id varT] (&.with-type-env tc.var)] |