aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/analyser/function.lux
diff options
context:
space:
mode:
Diffstat (limited to 'new-luxc/source/luxc/analyser/function.lux')
-rw-r--r--new-luxc/source/luxc/analyser/function.lux16
1 files changed, 10 insertions, 6 deletions
diff --git a/new-luxc/source/luxc/analyser/function.lux b/new-luxc/source/luxc/analyser/function.lux
index 55896480e..3d2da6326 100644
--- a/new-luxc/source/luxc/analyser/function.lux
+++ b/new-luxc/source/luxc/analyser/function.lux
@@ -6,11 +6,13 @@
[text]
text/format
(coll [list "list/" Fold<List> Monoid<List> Monad<List>]))
- [meta #+ Monad<Meta>]
- (meta [type]
+ [meta]
+ (meta [code]
+ [type]
(type ["tc" check])))
(luxc ["&" base]
- (lang ["la" analysis #+ Analysis])
+ (lang ["la" analysis #+ Analysis]
+ [";L" variable #+ Variable])
["&;" scope]
(analyser ["&;" common]
["&;" inference])))
@@ -21,7 +23,7 @@
## [Analysers]
(def: #export (analyse-function analyse func-name arg-name body)
(-> &;Analyser Text Text Code (Meta Analysis))
- (do Monad<Meta>
+ (do meta;Monad<Meta>
[functionT meta;expected-type]
(loop [expectedT functionT]
(&;with-stacked-errors
@@ -80,7 +82,9 @@
))))))
(#;Function inputT outputT)
- (<| (:: @ map (|>. #la;Function))
+ (<| (:: @ map (function [[scope bodyA]]
+ (` ("lux function" [(~@ (list/map code;int (variableL;environment scope)))]
+ (~ bodyA)))))
&;with-scope
## Functions have access not only to their argument, but
## also to themselves, through a local variable.
@@ -99,7 +103,7 @@
(function [_]
(Cannot-Apply-Function (format " Function: " (%type funcT) "\n"
"Arguments: " (|> args (list/map %code) (text;join-with " ")))))
- (do Monad<Meta>
+ (do meta;Monad<Meta>
[expected meta;expected-type
[applyT argsA] (&inference;apply-function analyse funcT args)
_ (&;with-type-env