aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/type/abstract.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/library/lux/type/abstract.lux78
1 files changed, 44 insertions, 34 deletions
diff --git a/stdlib/source/library/lux/type/abstract.lux b/stdlib/source/library/lux/type/abstract.lux
index 7eb42acb2..2ea87233e 100644
--- a/stdlib/source/library/lux/type/abstract.lux
+++ b/stdlib/source/library/lux/type/abstract.lux
@@ -17,7 +17,6 @@
[macro
["." code]
[syntax (#+ syntax:)
- ["|.|" export]
["|.|" annotations]]]]])
(type: Stack List)
@@ -34,7 +33,7 @@
(All [a] (-> (Stack a) (Maybe (Stack a))))
list.tail)
-(type: #export Frame
+(type: .public Frame
{#name Text
#type_vars (List Code)
#abstraction Code
@@ -45,15 +44,15 @@
#.End)
(template: (!peek <source> <reference> <then>)
- (loop [entries <source>]
- (case entries
- (#.Item [head_name head] tail)
- (if (text\= <reference> head_name)
- <then>
- (recur tail))
+ [(loop [entries <source>]
+ (case entries
+ (#.Item [head_name head] tail)
+ (if (text\= <reference> head_name)
+ <then>
+ (recur tail))
- #.End
- (undefined))))
+ #.End
+ (undefined)))])
(def: (peek_frames_definition reference source)
(-> Text (List [Text Global]) (Stack Frame))
@@ -70,7 +69,7 @@
(!peek source reference
(peek_frames_definition definition_reference (get@ #.definitions head))))
-(exception: #export no_active_frames)
+(exception: .public no_active_frames)
(def: (peek! frame)
(-> (Maybe Text) (Meta Frame))
@@ -91,26 +90,26 @@
#.None
(exception.except ..no_active_frames [])))))
-(def: #export current
+(def: .public current
(Meta Frame)
(..peek! #.None))
-(def: #export (specific name)
+(def: .public (specific name)
(-> Text (Meta Frame))
(..peek! (#.Some name)))
(template: (!push <source> <reference> <then>)
- (loop [entries <source>]
- (case entries
- (#.Item [head_name head] tail)
- (if (text\= <reference> head_name)
- (#.Item [head_name <then>]
- tail)
- (#.Item [head_name head]
- (recur tail)))
-
- #.End
- (undefined))))
+ [(loop [entries <source>]
+ (case entries
+ (#.Item [head_name head] tail)
+ (if (text\= <reference> head_name)
+ (#.Item [head_name <then>]
+ tail)
+ (#.Item [head_name head]
+ (recur tail)))
+
+ #.End
+ (undefined)))])
(def: (push_frame_definition reference frame source)
(-> Text Frame (List [Text Global]) (List [Text Global]))
@@ -175,7 +174,7 @@
(<>.and (<>\in #.None) <code>.any)))
(template [<name> <from> <to>]
- [(syntax: #export (<name> {[frame value] ..cast})
+ [(syntax: .public (<name> {[frame value] ..cast})
(do meta.monad
[[name type_vars abstraction representation] (peek! frame)]
(in (list (` ((~! :cast) [(~+ type_vars)] (~ <from>) (~ <to>)
@@ -203,14 +202,25 @@
(<>.either (<code>.form (<>.and <code>.local_identifier (<>.some <code>.local_identifier)))
(<>.and <code>.local_identifier (\ <>.monad in (list)))))
+(def: abstract
+ (Parser [Code [Text (List Text)] |annotations|.Annotations Code (List Code)])
+ (let [private (: (Parser [[Text (List Text)] |annotations|.Annotations Code (List Code)])
+ ($_ <>.and
+ ..declaration
+ |annotations|.parser
+ <code>.any
+ (<>.some <code>.any)
+ ))]
+ ($_ <>.either
+ (<>.and <code>.any private)
+ (<>.and (<>\in (` .private)) private)
+ )))
+
## TODO: Make sure the generated code always gets optimized away.
## (This applies to uses of ":abstraction" and ":representation")
-(syntax: #export (abstract:
- {export |export|.parser}
- {[name type_vars] declaration}
- representation_type
- {annotations (<>.else |annotations|.empty |annotations|.parser)}
- {primitives (<>.some <code>.any)})
+(syntax: .public (abstract:
+ {[export_policy [name type_vars] annotations representation_type primitives]
+ ..abstract})
(do meta.monad
[current_module meta.current_module_name
.let [type_varsC (list\map code.local_identifier type_vars)
@@ -221,7 +231,7 @@
type_varsC
abstraction_declaration
representation_declaration])]
- (in (list& (` (type: (~+ (|export|.format export)) (~ abstraction_declaration)
+ (in (list& (` (type: (~ export_policy) (~ abstraction_declaration)
(~ (|annotations|.format annotations))
(primitive (~ (code.text (abstraction_type_name [current_module name])))
[(~+ type_varsC)])))
@@ -240,7 +250,7 @@
(<>.or (<>.and <code>.any parser)
parser))
-(syntax: #export (:transmutation {selection (..selection <code>.any)})
+(syntax: .public (:transmutation {selection (..selection <code>.any)})
(case selection
(#Specific specific value)
(in (list (` (..:abstraction (~ specific)
@@ -250,7 +260,7 @@
(#Current value)
(in (list (` (..:abstraction (..:representation (~ value))))))))
-(syntax: #export (^:representation {selection (<code>.form (..selection <code>.local_identifier))}
+(syntax: .public (^:representation {selection (<code>.form (..selection <code>.local_identifier))}
body
{branches (<>.some <code>.any)})
(case selection