aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/type/abstract.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/type/abstract.lux')
-rw-r--r--stdlib/source/lux/type/abstract.lux14
1 files changed, 12 insertions, 2 deletions
diff --git a/stdlib/source/lux/type/abstract.lux b/stdlib/source/lux/type/abstract.lux
index 9a991a2a9..d3f3eb118 100644
--- a/stdlib/source/lux/type/abstract.lux
+++ b/stdlib/source/lux/type/abstract.lux
@@ -49,8 +49,8 @@
plist'
(#.Cons [k' v'] (remove k plist')))))
-(def: down-cast Text "@abstract")
-(def: up-cast Text "@repr")
+(def: down-cast Text "@abstraction")
+(def: up-cast Text "@representation")
(def: macro-anns Code (' {#.macro? true}))
(def: representation-name
@@ -164,3 +164,13 @@
(` ((~! install-casts) (~ (code.local-symbol name)) [(~+ type-varsC)]))
(list/compose primitives
(list (` ((~! un-install-casts)))))))))
+
+(syntax: #export (^@representation [name (s.form s.local-symbol)] body [branches (p.some s.any)])
+ (let [g!representation (code.local-symbol name)]
+ (do @
+ [current-module macro.current-module-name
+ #let [g!@representation (code.symbol [current-module "@representation"])]]
+ (wrap (list& g!representation
+ (` (.let [(~ g!representation) ((~ g!@representation) (~ g!representation))]
+ (~ body)))
+ branches)))))