aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/source/lux/lang/type.lux27
1 files changed, 25 insertions, 2 deletions
diff --git a/stdlib/source/lux/lang/type.lux b/stdlib/source/lux/lang/type.lux
index 96ea1a9b0..793d1c8be 100644
--- a/stdlib/source/lux/lang/type.lux
+++ b/stdlib/source/lux/lang/type.lux
@@ -10,7 +10,7 @@
(coll [list #+ "list/" Functor<List> Monoid<List> Fold<List>]))
[macro]
(macro [code]
- ["s" syntax #+ syntax:])
+ ["s" syntax #+ Syntax syntax:])
))
## [Utils]
@@ -351,7 +351,11 @@
(wrap (list (` (.let [(~ g!value) (~ valueC)]
(..:log! (~ g!value)))))))))
-(syntax: #export (:cast {type-vars (s.tuple (p.some s.local-symbol))}
+(def: type-parameters
+ (Syntax (List Text))
+ (s.tuple (p.some s.local-symbol)))
+
+(syntax: #export (:cast {type-vars type-parameters}
input
output
{value (p.maybe s.any)})
@@ -364,3 +368,22 @@
(#.Some value)
(wrap (list (` ((~ casterC) (~ value))))))))
+
+(type: Typed
+ {#type Code
+ #expression Code})
+
+(def: typed
+ (Syntax Typed)
+ (s.record (p.seq s.any s.any)))
+
+(syntax: #export (:share {type-vars type-parameters}
+ {exemplar typed}
+ {computation typed})
+ (macro.with-gensyms [g!_]
+ (let [shareC (` (: (All [(~+ (list/map code.local-symbol type-vars))]
+ (-> (~ (get@ #type exemplar))
+ (~ (get@ #type computation))))
+ (.function ((~ g!_) (~ g!_))
+ (:assume (~ (get@ #expression computation))))))]
+ (wrap (list (` ((~ shareC) (~ (get@ #expression exemplar)))))))))