aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/analysis/function.lux
diff options
context:
space:
mode:
Diffstat (limited to 'new-luxc/source/luxc/lang/analysis/function.lux')
-rw-r--r--new-luxc/source/luxc/lang/analysis/function.lux84
1 files changed, 42 insertions, 42 deletions
diff --git a/new-luxc/source/luxc/lang/analysis/function.lux b/new-luxc/source/luxc/lang/analysis/function.lux
index b4aa31c90..758acd681 100644
--- a/new-luxc/source/luxc/lang/analysis/function.lux
+++ b/new-luxc/source/luxc/lang/analysis/function.lux
@@ -1,4 +1,4 @@
-(;module:
+(.module:
lux
(lux (control monad
["ex" exception #+ exception:])
@@ -11,11 +11,11 @@
(lang [type]
(type ["tc" check])))
(luxc ["&" lang]
- (lang ["&;" scope]
+ (lang ["&." scope]
["la" analysis #+ Analysis]
- (analysis ["&;" common]
- ["&;" inference])
- [";L" variable #+ Variable])))
+ (analysis ["&." common]
+ ["&." inference])
+ [".L" variable #+ Variable])))
(exception: #export Cannot-Analyse-Function)
(exception: #export Invalid-Function-Type)
@@ -23,81 +23,81 @@
## [Analysers]
(def: #export (analyse-function analyse func-name arg-name body)
- (-> &;Analyser Text Text Code (Meta Analysis))
- (do macro;Monad<Meta>
- [functionT macro;expected-type]
+ (-> &.Analyser Text Text Code (Meta Analysis))
+ (do macro.Monad<Meta>
+ [functionT macro.expected-type]
(loop [expectedT functionT]
- (&;with-stacked-errors
+ (&.with-stacked-errors
(function [_] (Cannot-Analyse-Function (format " Type: " (%type expectedT) "\n"
"Function: " func-name "\n"
"Argument: " arg-name "\n"
" Body: " (%code body))))
(case expectedT
- (#;Named name unnamedT)
+ (#.Named name unnamedT)
(recur unnamedT)
- (#;Apply argT funT)
- (case (type;apply (list argT) funT)
- (#;Some value)
+ (#.Apply argT funT)
+ (case (type.apply (list argT) funT)
+ (#.Some value)
(recur value)
- #;None
- (&;throw Invalid-Function-Type (%type expectedT)))
+ #.None
+ (&.throw Invalid-Function-Type (%type expectedT)))
(^template [<tag> <instancer>]
(<tag> _)
(do @
- [[_ instanceT] (&;with-type-env <instancer>)]
- (recur (maybe;assume (type;apply (list instanceT) expectedT)))))
- ([#;UnivQ tc;existential]
- [#;ExQ tc;var])
+ [[_ instanceT] (&.with-type-env <instancer>)]
+ (recur (maybe.assume (type.apply (list instanceT) expectedT)))))
+ ([#.UnivQ tc.existential]
+ [#.ExQ tc.var])
- (#;Var id)
+ (#.Var id)
(do @
- [?expectedT' (&;with-type-env
- (tc;read id))]
+ [?expectedT' (&.with-type-env
+ (tc.read id))]
(case ?expectedT'
- (#;Some expectedT')
+ (#.Some expectedT')
(recur expectedT')
_
## Inference
(do @
- [[input-id inputT] (&;with-type-env tc;var)
- [output-id outputT] (&;with-type-env tc;var)
- #let [funT (#;Function inputT outputT)]
+ [[input-id inputT] (&.with-type-env tc.var)
+ [output-id outputT] (&.with-type-env tc.var)
+ #let [funT (#.Function inputT outputT)]
funA (recur funT)
- _ (&;with-type-env
- (tc;check expectedT funT))]
+ _ (&.with-type-env
+ (tc.check expectedT funT))]
(wrap funA))
))
- (#;Function inputT outputT)
+ (#.Function inputT outputT)
(<| (:: @ map (function [[scope bodyA]]
- (` ("lux function" [(~@ (list/map code;int (variableL;environment scope)))]
+ (` ("lux function" [(~@ (list/map code.int (variableL.environment scope)))]
(~ bodyA)))))
- &;with-scope
+ &.with-scope
## Functions have access not only to their argument, but
## also to themselves, through a local variable.
- (&scope;with-local [func-name expectedT])
- (&scope;with-local [arg-name inputT])
- (&;with-type outputT)
+ (&scope.with-local [func-name expectedT])
+ (&scope.with-local [arg-name inputT])
+ (&.with-type outputT)
(analyse body))
_
- (&;fail "")
+ (&.fail "")
)))))
(def: #export (analyse-apply analyse funcT funcA args)
- (-> &;Analyser Type Analysis (List Code) (Meta Analysis))
- (&;with-stacked-errors
+ (-> &.Analyser Type Analysis (List Code) (Meta Analysis))
+ (&.with-stacked-errors
(function [_]
(Cannot-Apply-Function (format " Function: " (%type funcT) "\n"
"Arguments:" (|> args
- list;enumerate
+ list.enumerate
(list/map (function [[idx argC]]
(format "\n " (%n idx) " " (%code argC))))
- (text;join-with "")))))
- (do macro;Monad<Meta>
- [[applyT argsA] (&inference;general analyse funcT args)]
- (wrap (la;apply argsA funcA)))))
+ (text.join-with "")))))
+ (do macro.Monad<Meta>
+ [[applyT argsA] (&inference.general analyse funcT args)]
+ (wrap (la.apply argsA funcA)))))