aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library
diff options
context:
space:
mode:
authorEduardo Julian2021-09-08 00:22:45 -0400
committerEduardo Julian2021-09-08 00:22:45 -0400
commit964ec62d4fbcc1fb2336a3de355ce3554ef7eb04 (patch)
tree04ae6f260d3345772a86849b6f969a9d87e959c8 /stdlib/source/library
parentac419f9e94bc3b82cfb78c41e91b08b308a2ac71 (diff)
Now using eval to derive code for arbitrary types.
Diffstat (limited to 'stdlib/source/library')
-rw-r--r--stdlib/source/library/lux/type/poly.lux28
1 files changed, 3 insertions, 25 deletions
diff --git a/stdlib/source/library/lux/type/poly.lux b/stdlib/source/library/lux/type/poly.lux
index 5bc9254c8..4f7a32f1c 100644
--- a/stdlib/source/library/lux/type/poly.lux
+++ b/stdlib/source/library/lux/type/poly.lux
@@ -34,42 +34,20 @@
(syntax: .public (poly: [[export_policy name body] ..polyP])
(with_identifiers [g!_ g!type g!output]
(let [g!name (code.identifier ["" name])]
- (in (.list (` ((~! syntax:) (~ export_policy) ((~ g!name) [(~ g!type) (~! <code>.identifier)])
+ (in (.list (` ((~! syntax:) (~ export_policy) ((~ g!name) [(~ g!type) (~! <code>.any)])
((~! do) (~! meta.monad)
- [(~ g!type) ((~! meta.type_definition) (~ g!type))]
+ [(~ g!type) ((~! meta.eval) .Type (~ g!type))]
(case (: (.Either .Text .Code)
((~! <type>.result) ((~! <>.rec)
(function ((~ g!_) (~ g!name))
(~ body)))
- (~ g!type)))
+ (.:as .Type (~ g!type))))
(#.Left (~ g!output))
((~! meta.failure) (~ g!output))
(#.Right (~ g!output))
((~' in) (.list (~ g!output))))))))))))
-(def: derivedP
- (Parser [Code Text [Name (List Name)] (Maybe Code)])
- (let [private ($_ <>.and
- <code>.local_identifier
- (<code>.form (<>.and <code>.identifier (<>.many <code>.identifier)))
- (<>.maybe <code>.any))]
- (<>.either (<>.and <code>.any private)
- (<>.and (<>\in (` .private)) private))))
-
-(syntax: .public (derived: [[export_policy name [poly_func poly_args] ?custom_impl] ..derivedP])
- (do [! meta.monad]
- [poly_args (monad.each ! meta.normal poly_args)
- .let [impl (case ?custom_impl
- (#.Some custom_impl)
- custom_impl
-
- #.None
- (` ((~ (code.identifier poly_func)) (~+ (list\each code.identifier poly_args)))))]]
- (in (.list (` (def: (~ export_policy) (~ (code.identifier ["" name]))
- {#.implementation? #1}
- (~ impl)))))))
-
(def: .public (code env type)
(-> Env Type Code)
(`` (case type