diff options
Diffstat (limited to 'stdlib/source')
-rw-r--r-- | stdlib/source/lux/lang.lux | 4 | ||||
-rw-r--r-- | stdlib/source/lux/lang/analysis.lux | 7 | ||||
-rw-r--r-- | stdlib/source/lux/lang/extension/analysis.lux | 4 | ||||
-rw-r--r-- | stdlib/source/lux/lang/extension/analysis/common.lux | 32 | ||||
-rw-r--r-- | stdlib/source/lux/lang/extension/analysis/host.jvm.lux | 88 | ||||
-rw-r--r-- | stdlib/source/lux/lang/synthesis.lux | 5 | ||||
-rw-r--r-- | stdlib/source/lux/lang/synthesis/expression.lux | 2 | ||||
-rw-r--r-- | stdlib/source/lux/lang/synthesis/loop.lux | 7 |
8 files changed, 76 insertions, 73 deletions
diff --git a/stdlib/source/lux/lang.lux b/stdlib/source/lux/lang.lux index 4c467c7fb..2259b615b 100644 --- a/stdlib/source/lux/lang.lux +++ b/stdlib/source/lux/lang.lux @@ -9,6 +9,10 @@ [macro] (macro ["s" syntax #+ syntax:]))) +(type: #export (Extension e) + {#name Text + #parameters (List e)}) + (type: #export Eval (-> Type Code (Meta Any))) diff --git a/stdlib/source/lux/lang/analysis.lux b/stdlib/source/lux/lang/analysis.lux index d5a25cad3..0996ad1f4 100644 --- a/stdlib/source/lux/lang/analysis.lux +++ b/stdlib/source/lux/lang/analysis.lux @@ -2,6 +2,7 @@ [lux #- nat int deg] (lux [function] (data (coll [list "list/" Fold<List>]))) + [// #+ Extension] [//reference #+ Register Variable Reference]) (type: #export #rec Primitive @@ -34,10 +35,6 @@ (type: #export Environment (List Variable)) -(type: #export (Special e) - {#extension Text - #parameters (List e)}) - (type: #export #rec Analysis (#Primitive Primitive) (#Structure (Composite Analysis)) @@ -45,7 +42,7 @@ (#Case Analysis (Match' Analysis)) (#Function Environment Analysis) (#Apply Analysis Analysis) - (#Special (Special Analysis))) + (#Extension (Extension Analysis))) (type: #export Branch (Branch' Analysis)) diff --git a/stdlib/source/lux/lang/extension/analysis.lux b/stdlib/source/lux/lang/extension/analysis.lux index 40fd84679..b412e28df 100644 --- a/stdlib/source/lux/lang/extension/analysis.lux +++ b/stdlib/source/lux/lang/extension/analysis.lux @@ -9,8 +9,8 @@ (def: #export defaults (//.Extension //.Analysis) - (|> /common.specials - (dict.merge /host.specials) + (|> /common.extensions + (dict.merge /host.extensions) dict.entries (list/map (function (_ [name proc]) [name (proc name)])) (dict.from-list text.Hash<Text>))) diff --git a/stdlib/source/lux/lang/extension/analysis/common.lux b/stdlib/source/lux/lang/extension/analysis/common.lux index 8c0116721..3faae601b 100644 --- a/stdlib/source/lux/lang/extension/analysis/common.lux +++ b/stdlib/source/lux/lang/extension/analysis/common.lux @@ -20,13 +20,13 @@ [io]) [///]) -(exception: #export (incorrect-special-arity {name Text} {arity Nat} {args Nat}) - (ex.report ["Special" (%t name)] +(exception: #export (incorrect-extension-arity {name Text} {arity Nat} {args Nat}) + (ex.report ["Extension" (%t name)] ["Expected arity" (|> arity .int %i)] ["Actual arity" (|> args .int %i)])) (exception: #export (invalid-syntax {name Text} {arguments (List Code)}) - (ex.report ["Special" name] + (ex.report ["Extension" name] ["Inputs" (|> arguments list.enumerate (list/map (function (_ [idx argC]) @@ -62,8 +62,8 @@ (typeA.with-type argT (analyse argC))) (list.zip2 inputsT+ args))] - (wrap (#analysisL.Special proc argsA))) - (lang.throw incorrect-special-arity [proc num-expected num-actual])))))) + (wrap (#analysisL.Extension proc argsA))) + (lang.throw incorrect-extension-arity [proc num-expected num-actual])))))) (def: #export (nullary valueT proc) (-> Type Text ///.Analysis) @@ -103,10 +103,10 @@ _ (typeA.infer (type (Either Text varT))) opA (typeA.with-type (type (io.IO varT)) (analyse opC))] - (wrap (#analysisL.Special proc (list opA)))) + (wrap (#analysisL.Extension proc (list opA)))) _ - (lang.throw incorrect-special-arity [proc +1 (list.size args)])))) + (lang.throw incorrect-extension-arity [proc +1 (list.size args)])))) (def: (lux//function proc) (-> Text ///.Analysis) @@ -118,7 +118,7 @@ (functionA.function analyse func-name arg-name body) _ - (lang.throw incorrect-special-arity [proc +3 (list.size args)])))) + (lang.throw incorrect-extension-arity [proc +3 (list.size args)])))) (def: (lux//case proc) (-> Text ///.Analysis) @@ -128,7 +128,7 @@ (caseA.case analyse input branches) _ - (lang.throw incorrect-special-arity [proc +2 (list.size args)])))) + (lang.throw incorrect-extension-arity [proc +2 (list.size args)])))) (def: (lux//in-module proc) (-> Text ///.Analysis) @@ -154,7 +154,7 @@ (analyse valueC))) _ - (lang.throw incorrect-special-arity [proc +2 (list.size args)]))))] + (lang.throw incorrect-extension-arity [proc +2 (list.size args)]))))] [lux//check (:! Type actualT)] [lux//coerce Any] @@ -172,7 +172,7 @@ (wrap valueA)) _ - (lang.throw incorrect-special-arity [proc +1 (list.size args)])))) + (lang.throw incorrect-extension-arity [proc +1 (list.size args)])))) (def: lux-procs Bundle @@ -346,10 +346,10 @@ _ (typeA.infer (type (Atom varT))) initA (typeA.with-type varT (analyse initC))] - (wrap (#analysisL.Special proc (list initA)))) + (wrap (#analysisL.Extension proc (list initA)))) _ - (lang.throw incorrect-special-arity [proc +1 (list.size args)])))) + (lang.throw incorrect-extension-arity [proc +1 (list.size args)])))) (def: (atom-read proc) (-> Text ///.Analysis) @@ -386,10 +386,10 @@ _ (typeA.infer (type (All [!] (thread.Box ! varT)))) initA (typeA.with-type varT (analyse initC))] - (wrap (#analysisL.Special proc (list initA)))) + (wrap (#analysisL.Extension proc (list initA)))) _ - (lang.throw incorrect-special-arity [proc +1 (list.size args)])))) + (lang.throw incorrect-extension-arity [proc +1 (list.size args)])))) (def: (box//read proc) (-> Text ///.Analysis) @@ -426,7 +426,7 @@ (install "schedule" (binary Nat (type (io.IO Any)) Any)) ))) -(def: #export specials +(def: #export extensions Bundle (<| (prefix "lux") (|> (dict.new text.Hash<Text>) diff --git a/stdlib/source/lux/lang/extension/analysis/host.jvm.lux b/stdlib/source/lux/lang/extension/analysis/host.jvm.lux index 31b811fac..56da166c5 100644 --- a/stdlib/source/lux/lang/extension/analysis/host.jvm.lux +++ b/stdlib/source/lux/lang/extension/analysis/host.jvm.lux @@ -211,10 +211,10 @@ [var-id varT] (typeA.with-env tc.var) arrayA (typeA.with-type (type (Array varT)) (analyse arrayC))] - (wrap (#analysisL.Special proc (list arrayA)))) + (wrap (#analysisL.Extension proc (list arrayA)))) _ - (lang.throw /.incorrect-special-arity [proc +1 (list.size args)])))) + (lang.throw /.incorrect-extension-arity [proc +1 (list.size args)])))) (def: (array//new proc) (-> Text ///.Analysis) @@ -248,12 +248,12 @@ _ (if (n/> +0 level) (wrap []) (lang.throw non-array expectedT))] - (wrap (#analysisL.Special proc (list (analysisL.nat (dec level)) - (analysisL.text elem-class) - lengthA)))) + (wrap (#analysisL.Extension proc (list (analysisL.nat (dec level)) + (analysisL.text elem-class) + lengthA)))) _ - (lang.throw /.incorrect-special-arity [proc +1 (list.size args)])))) + (lang.throw /.incorrect-extension-arity [proc +1 (list.size args)])))) (def: (check-jvm objectT) (-> Type (Meta Text)) @@ -324,10 +324,10 @@ [elemT elem-class] (box-array-element-type (maybe.default varT ?elemT)) idxA (typeA.with-type Nat (analyse idxC))] - (wrap (#analysisL.Special proc (list (analysisL.text elem-class) idxA arrayA)))) + (wrap (#analysisL.Extension proc (list (analysisL.text elem-class) idxA arrayA)))) _ - (lang.throw /.incorrect-special-arity [proc +2 (list.size args)])))) + (lang.throw /.incorrect-extension-arity [proc +2 (list.size args)])))) (def: (array//write proc) (-> Text ///.Analysis) @@ -346,10 +346,10 @@ (analyse idxC)) valueA (typeA.with-type valueT (analyse valueC))] - (wrap (#analysisL.Special proc (list (analysisL.text elem-class) idxA valueA arrayA)))) + (wrap (#analysisL.Extension proc (list (analysisL.text elem-class) idxA valueA arrayA)))) _ - (lang.throw /.incorrect-special-arity [proc +3 (list.size args)])))) + (lang.throw /.incorrect-extension-arity [proc +3 (list.size args)])))) (def: array-procs /.Bundle @@ -369,10 +369,10 @@ (do macro.Monad<Meta> [expectedT macro.expected-type _ (check-object expectedT)] - (wrap (#analysisL.Special proc (list)))) + (wrap (#analysisL.Extension proc (list)))) _ - (lang.throw /.incorrect-special-arity [proc +0 (list.size args)])))) + (lang.throw /.incorrect-extension-arity [proc +0 (list.size args)])))) (def: (object//null? proc) (-> Text ///.Analysis) @@ -384,10 +384,10 @@ [objectT objectA] (typeA.with-inference (analyse objectC)) _ (check-object objectT)] - (wrap (#analysisL.Special proc (list objectA)))) + (wrap (#analysisL.Extension proc (list objectA)))) _ - (lang.throw /.incorrect-special-arity [proc +1 (list.size args)])))) + (lang.throw /.incorrect-extension-arity [proc +1 (list.size args)])))) (def: (object//synchronized proc) (-> Text ///.Analysis) @@ -399,10 +399,10 @@ (analyse monitorC)) _ (check-object monitorT) exprA (analyse exprC)] - (wrap (#analysisL.Special proc (list monitorA exprA)))) + (wrap (#analysisL.Extension proc (list monitorA exprA)))) _ - (lang.throw /.incorrect-special-arity [proc +2 (list.size args)])))) + (lang.throw /.incorrect-extension-arity [proc +2 (list.size args)])))) (host.import java/lang/Object (equals [Object] boolean)) @@ -496,10 +496,10 @@ (if ? (wrap []) (lang.throw non-throwable exception-class)))] - (wrap (#analysisL.Special proc (list exceptionA)))) + (wrap (#analysisL.Extension proc (list exceptionA)))) _ - (lang.throw /.incorrect-special-arity [proc +1 (list.size args)])))) + (lang.throw /.incorrect-extension-arity [proc +1 (list.size args)])))) (def: (object//class proc) (-> Text ///.Analysis) @@ -511,13 +511,13 @@ (do macro.Monad<Meta> [_ (typeA.infer (#.Primitive "java.lang.Class" (list (#.Primitive class (list))))) _ (load-class class)] - (wrap (#analysisL.Special proc (list (analysisL.text class))))) + (wrap (#analysisL.Extension proc (list (analysisL.text class))))) _ (lang.throw /.invalid-syntax [proc args])) _ - (lang.throw /.incorrect-special-arity [proc +1 (list.size args)])))) + (lang.throw /.incorrect-extension-arity [proc +1 (list.size args)])))) (def: (object//instance? proc) (-> Text ///.Analysis) @@ -533,14 +533,14 @@ object-class (check-object objectT) ? (sub-class? class object-class)] (if ? - (wrap (#analysisL.Special proc (list (analysisL.text class)))) + (wrap (#analysisL.Extension proc (list (analysisL.text class)))) (lang.throw Cannot-Possibly-Be-Instance (format object-class " !<= " class)))) _ (lang.throw /.invalid-syntax [proc args])) _ - (lang.throw /.incorrect-special-arity [proc +2 (list.size args)])))) + (lang.throw /.incorrect-extension-arity [proc +2 (list.size args)])))) (def: (java-type-to-class type) (-> java/lang/reflect/Type (Meta Text)) @@ -714,9 +714,9 @@ " For value: " (%code valueC) "\n"))) ))))))] (if can-cast? - (wrap (#analysisL.Special proc (list (analysisL.text from-name) - (analysisL.text to-name) - valueA))) + (wrap (#analysisL.Extension proc (list (analysisL.text from-name) + (analysisL.text to-name) + valueA))) (lang.throw Cannot-Cast (format "From class/primitive: " from-name "\n" " To class/primitive: " to-name "\n" " For value: " (%code valueC) "\n")))) @@ -808,13 +808,13 @@ [[_ (#.Text class)] [_ (#.Text field)]] (do macro.Monad<Meta> [[fieldT final?] (static-field class field)] - (wrap (#analysisL.Special proc (list (analysisL.text class) (analysisL.text field))))) + (wrap (#analysisL.Extension proc (list (analysisL.text class) (analysisL.text field))))) _ (lang.throw /.invalid-syntax [proc args])) _ - (lang.throw /.incorrect-special-arity [proc +2 (list.size args)])))) + (lang.throw /.incorrect-extension-arity [proc +2 (list.size args)])))) (def: (static//put proc) (-> Text ///.Analysis) @@ -830,13 +830,13 @@ (not final?)) valueA (typeA.with-type fieldT (analyse valueC))] - (wrap (#analysisL.Special proc (list (analysisL.text class) (analysisL.text field) valueA)))) + (wrap (#analysisL.Extension proc (list (analysisL.text class) (analysisL.text field) valueA)))) _ (lang.throw /.invalid-syntax [proc args])) _ - (lang.throw /.incorrect-special-arity [proc +3 (list.size args)])))) + (lang.throw /.incorrect-extension-arity [proc +3 (list.size args)])))) (def: (virtual//get proc) (-> Text ///.Analysis) @@ -849,13 +849,13 @@ [[objectT objectA] (typeA.with-inference (analyse objectC)) [fieldT final?] (virtual-field class field objectT)] - (wrap (#analysisL.Special proc (list (analysisL.text class) (analysisL.text field) objectA)))) + (wrap (#analysisL.Extension proc (list (analysisL.text class) (analysisL.text field) objectA)))) _ (lang.throw /.invalid-syntax [proc args])) _ - (lang.throw /.incorrect-special-arity [proc +3 (list.size args)])))) + (lang.throw /.incorrect-extension-arity [proc +3 (list.size args)])))) (def: (virtual//put proc) (-> Text ///.Analysis) @@ -873,13 +873,13 @@ (not final?)) valueA (typeA.with-type fieldT (analyse valueC))] - (wrap (#analysisL.Special proc (list (analysisL.text class) (analysisL.text field) valueA objectA)))) + (wrap (#analysisL.Extension proc (list (analysisL.text class) (analysisL.text field) valueA objectA)))) _ (lang.throw /.invalid-syntax [proc args])) _ - (lang.throw /.incorrect-special-arity [proc +4 (list.size args)])))) + (lang.throw /.incorrect-extension-arity [proc +4 (list.size args)])))) (def: (java-type-to-parameter type) (-> java/lang/reflect/Type (Meta Text)) @@ -1104,8 +1104,8 @@ [methodT exceptionsT] (methods class method #Static argsT) [outputT argsA] (inferenceA.general analyse methodT (list/map product.right argsTC)) outputJC (check-jvm outputT)] - (wrap (#analysisL.Special proc (list& (analysisL.text class) (analysisL.text method) - (analysisL.text outputJC) (decorate-inputs argsT argsA))))) + (wrap (#analysisL.Extension proc (list& (analysisL.text class) (analysisL.text method) + (analysisL.text outputJC) (decorate-inputs argsT argsA))))) _ (lang.throw /.invalid-syntax [proc args])))) @@ -1127,8 +1127,8 @@ _ (undefined))] outputJC (check-jvm outputT)] - (wrap (#analysisL.Special proc (list& (analysisL.text class) (analysisL.text method) - (analysisL.text outputJC) objectA (decorate-inputs argsT argsA))))) + (wrap (#analysisL.Extension proc (list& (analysisL.text class) (analysisL.text method) + (analysisL.text outputJC) objectA (decorate-inputs argsT argsA))))) _ (lang.throw /.invalid-syntax [proc args])))) @@ -1144,8 +1144,8 @@ [methodT exceptionsT] (methods class method #Special argsT) [outputT argsA] (inferenceA.general analyse methodT (list& objectC (list/map product.right argsTC))) outputJC (check-jvm outputT)] - (wrap (#analysisL.Special proc (list& (analysisL.text class) (analysisL.text method) - (analysisL.text outputJC) (decorate-inputs argsT argsA))))) + (wrap (#analysisL.Extension proc (list& (analysisL.text class) (analysisL.text method) + (analysisL.text outputJC) (decorate-inputs argsT argsA))))) _ (lang.throw /.invalid-syntax [proc args])))) @@ -1164,9 +1164,9 @@ [methodT exceptionsT] (methods class-name method #Interface argsT) [outputT argsA] (inferenceA.general analyse methodT (list& objectC (list/map product.right argsTC))) outputJC (check-jvm outputT)] - (wrap (#analysisL.Special proc - (list& (analysisL.text class-name) (analysisL.text method) (analysisL.text outputJC) - (decorate-inputs argsT argsA))))) + (wrap (#analysisL.Extension proc + (list& (analysisL.text class-name) (analysisL.text method) (analysisL.text outputJC) + (decorate-inputs argsT argsA))))) _ (lang.throw /.invalid-syntax [proc args])))) @@ -1181,7 +1181,7 @@ [#let [argsT (list/map product.left argsTC)] [methodT exceptionsT] (constructor-methods class argsT) [outputT argsA] (inferenceA.general analyse methodT (list/map product.right argsTC))] - (wrap (#analysisL.Special proc (list& (analysisL.text class) (decorate-inputs argsT argsA))))) + (wrap (#analysisL.Extension proc (list& (analysisL.text class) (decorate-inputs argsT argsA))))) _ (lang.throw /.invalid-syntax [proc args])))) @@ -1208,7 +1208,7 @@ ))) ))) -(def: #export specials +(def: #export extensions /.Bundle (<| (/.prefix "jvm") (|> (dict.new text.Hash<Text>) diff --git a/stdlib/source/lux/lang/synthesis.lux b/stdlib/source/lux/lang/synthesis.lux index 359ef445a..779581cc4 100644 --- a/stdlib/source/lux/lang/synthesis.lux +++ b/stdlib/source/lux/lang/synthesis.lux @@ -3,8 +3,9 @@ (lux (control [monad #+ do]) (data [error #+ Error] (coll (dictionary ["dict" unordered #+ Dict])))) + [// #+ Extension] [//reference #+ Register Variable Reference] - [//analysis #+ Environment Special Analysis] + [//analysis #+ Environment Analysis] [//compiler #+ Operation Compiler]) (type: #export Arity Nat) @@ -91,7 +92,7 @@ (#Structure (Structure Synthesis)) (#Reference Reference) (#Control (Control Synthesis)) - (#Special (Special Synthesis))) + (#Extension (Extension Synthesis))) (type: #export Path (Path' Synthesis)) diff --git a/stdlib/source/lux/lang/synthesis/expression.lux b/stdlib/source/lux/lang/synthesis/expression.lux index 2985d2d08..52ea33805 100644 --- a/stdlib/source/lux/lang/synthesis/expression.lux +++ b/stdlib/source/lux/lang/synthesis/expression.lux @@ -61,7 +61,7 @@ (#///analysis.Function environmentA bodyA) (//function.function synthesize environmentA bodyA) - (#///analysis.Special name args) + (#///analysis.Extension name args) (case (dict.get name extensions) #.None (///compiler.throw unknown-synthesis-extension name) diff --git a/stdlib/source/lux/lang/synthesis/loop.lux b/stdlib/source/lux/lang/synthesis/loop.lux index 1b5d3401c..6aab72213 100644 --- a/stdlib/source/lux/lang/synthesis/loop.lux +++ b/stdlib/source/lux/lang/synthesis/loop.lux @@ -6,6 +6,7 @@ (coll [list "list/" Functor<List>])) (macro [code] [syntax])) + [///] [///reference #+ Register Variable] [///analysis #+ Environment] [// #+ Path Abstraction Synthesis]) @@ -89,7 +90,7 @@ (and (proper? funcS) (list.every? proper? argsS)))) - (#//.Special [special argsS]) + (#//.Extension [name argsS]) (list.every? proper? argsS) _ @@ -270,10 +271,10 @@ arguments' (monad.map maybe.Monad<Maybe> recur arguments)] (wrap (//.function/apply [function' arguments']))) - (#//.Special [procedure argsS]) + (#//.Extension [name argsS]) (|> argsS (monad.map maybe.Monad<Maybe> recur) - (maybe/map (|>> [procedure] #//.Special))) + (maybe/map (|>> [name] #//.Extension))) _ (#.Some exprS)))) |