aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/type.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/library/lux/type.lux39
1 files changed, 21 insertions, 18 deletions
diff --git a/stdlib/source/library/lux/type.lux b/stdlib/source/library/lux/type.lux
index e6a7504e9..52c70ada9 100644
--- a/stdlib/source/library/lux/type.lux
+++ b/stdlib/source/library/lux/type.lux
@@ -442,15 +442,21 @@
[#type Code
#expression Code]))
-(def: typed
- (Parser Typed)
- (<>.and <code>.any <code>.any))
+(def: (typed lux)
+ (-> Lux (Parser Typed))
+ (do <>.monad
+ [it <code>.any
+ type_check (<>.lifted (meta.result lux (macro.expansion it)))]
+ (<| (<code>.locally type_check)
+ <code>.form
+ (<>.after (<code>.this (` "lux type check")))
+ (<>.and <code>.any <code>.any))))
... TODO: Make sure the generated code always gets optimized away.
(def: .public sharing
- (syntax (_ [type_vars ..type_parameters
- exemplar ..typed
- computation ..typed])
+ (syntax (_ lux [type_vars ..type_parameters
+ exemplar (..typed lux)
+ computation (..typed lux)])
(macro.with_symbols [g!_]
(.let [typeC (` (All ((~ g!_) (~+ (list#each code.local type_vars)))
(-> (~ (the #type exemplar))
@@ -461,18 +467,15 @@
(in (list (` ((~ shareC) (~ (the #expression exemplar))))))))))
(def: .public by_example
- (syntax (_ [type_vars ..type_parameters
- exemplar ..typed
- extraction <code>.any])
- (in (list (` (.type_of ((~! ..sharing)
- [(~+ (list#each code.local type_vars))]
-
- (~ (the #type exemplar))
- (~ (the #expression exemplar))
-
- (~ extraction)
- ... The value of this expression will never be relevant, so it doesn't matter what it is.
- (.as .Nothing []))))))))
+ (syntax (_ lux [type_vars ..type_parameters
+ exemplar (..typed lux)
+ extraction <code>.any])
+ (in (list (` (.type_of ((~! ..sharing) [(~+ (list#each code.local type_vars))]
+ (is (~ (the #type exemplar))
+ (~ (the #expression exemplar)))
+ (is (~ extraction)
+ ... The value of this expression will never be relevant, so it doesn't matter what it is.
+ (.as .Nothing [])))))))))
(def: .public (replaced before after)
(-> Type Type Type Type)