aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
authorEduardo Julian2021-08-30 04:21:53 -0400
committerEduardo Julian2021-08-30 04:21:53 -0400
commit834ed92e323fd274c2da08c82a7d8785663e10be (patch)
treed7b0f211c50a74f70a1ae01f5311be4e06575f4d /stdlib/source
parentef437d6584d8fd863c0dab276e5a3d4dc094767b (diff)
Better tagged type documentation + lexer fix.
Diffstat (limited to '')
-rw-r--r--stdlib/source/documentation/lux/control/maybe.lux2
-rw-r--r--stdlib/source/documentation/lux/data/collection/list.lux2
-rw-r--r--stdlib/source/library/lux/documentation.lux38
-rw-r--r--stdlib/source/library/lux/meta.lux9
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux2
5 files changed, 31 insertions, 22 deletions
diff --git a/stdlib/source/documentation/lux/control/maybe.lux b/stdlib/source/documentation/lux/control/maybe.lux
index dabdcde5e..f096b1d40 100644
--- a/stdlib/source/documentation/lux/control/maybe.lux
+++ b/stdlib/source/documentation/lux/control/maybe.lux
@@ -35,7 +35,7 @@
"Can be used as a guard in (co)monadic be/do expressions."
[(do monad
[value (do_something 1 2 3)
- /.when (passes_test? value)]
+ .when (passes_test? value)]
(do_something_else 4 5 6))])
(.def: .public documentation
diff --git a/stdlib/source/documentation/lux/data/collection/list.lux b/stdlib/source/documentation/lux/data/collection/list.lux
index f5dda38bc..d11cc2605 100644
--- a/stdlib/source/documentation/lux/data/collection/list.lux
+++ b/stdlib/source/documentation/lux/data/collection/list.lux
@@ -174,7 +174,7 @@
"Can be used as a guard in (co)monadic be/do expressions."
[(do monad
[value (do_something 1 2 3)
- /.when (passes_test? value)]
+ .when (passes_test? value)]
(do_something_else 4 5 6))])
(.def: .public documentation
diff --git a/stdlib/source/library/lux/documentation.lux b/stdlib/source/library/lux/documentation.lux
index 5de44d483..1c5150f41 100644
--- a/stdlib/source/library/lux/documentation.lux
+++ b/stdlib/source/library/lux/documentation.lux
@@ -97,18 +97,22 @@
(def: (code_documentation expected_module old_location reference_column example)
(-> Text Location Nat Code [Location Text])
(case example
- [new_location (#.Identifier [module short])]
- (let [documentation (cond (text\= expected_module module)
- short
-
- (text\= .prelude_module module)
- (format "." short)
-
- ... else
- (%.name [module short]))]
- [(revised@ #.column (n.+ (text.size documentation)) new_location)
- (format (padding reference_column old_location new_location)
- documentation)])
+ (^template [<tag> <prefix>]
+ [[new_location (<tag> [module short])]
+ (let [documentation (<| (text.prefix <prefix>)
+ (cond (text\= expected_module module)
+ short
+
+ (text\= .prelude_module module)
+ (format "." short)
+
+ ... else
+ (%.name [module short])))]
+ [(revised@ #.column (n.+ (text.size documentation)) new_location)
+ (format (padding reference_column old_location new_location)
+ documentation)])])
+ ([#.Identifier ""]
+ [#.Tag syntax.sigil])
(^template [<tag> <format>]
[[new_location (<tag> value)]
@@ -121,8 +125,7 @@
[#.Int [%.int]]
[#.Rev [%.rev]]
[#.Frac [%.frac]]
- [#.Text [%.text]]
- [#.Tag [%.name (text.prefix syntax.sigil)]])
+ [#.Text [%.text]])
(^template [|<| |>| <tag> <prep>]
[[group_location (<tag> members)]
@@ -492,7 +495,8 @@
[[name parameters] ..declaration])
(do meta.monad
[.let [g!module (code.text (product.left name))]
- [[_ def_type def_annotations def_value]] (meta.export name)]
+ [[_ def_type def_annotations def_value]] (meta.export name)
+ tags (meta.tags_of name)]
(with_expansions [<\n> (~! text.\n)]
(macro.with_identifiers [g!type]
(in (list (` ($_ ((~! md.then))
@@ -517,7 +521,9 @@
((~! ..type_definition)
(~ g!module)
[(~ (code.text (product.right name))) (list (~+ (list\each code.text parameters)))]
- (list))
+ (.list (~+ (|> tags
+ (maybe.else (list))
+ (list\each (|>> product.right code.text))))))
((~! %.format)
((~! ..single_line_comment) ((~! ..type) (~ g!module) (~ g!type)))
<\n>)))
diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux
index f19bc2964..3cc8deedf 100644
--- a/stdlib/source/library/lux/meta.lux
+++ b/stdlib/source/library/lux/meta.lux
@@ -505,9 +505,12 @@
[.let [[module_name name] type_name]
module (..module module_name)]
(case (plist.value name (value@ #.definitions module))
- (#.Some (#.Type [exported? type (#.Right slots)]))
- (in (#.Some (list\each (|>> [module_name])
- (#.Item slots))))
+ (#.Some (#.Type [exported? type labels]))
+ (case labels
+ (^or (#.Left labels)
+ (#.Right labels))
+ (in (#.Some (list\each (|>> [module_name])
+ (#.Item labels)))))
_
(in #.None))))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux
index 3105f2ad8..734f38260 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux
@@ -435,7 +435,7 @@
(template: (!half_name_parser @offset @char @module)
[(!if_name_char?|head @char
- (!letE [source' name] (..name_part_parser @offset where (!++ @offset) source_code)
+ (!letE [source' name] (..name_part_parser @offset (!forward 1 where) (!++ @offset) source_code)
(#.Right [source' [@module name]]))
(!failure ..!half_name_parser where @offset source_code))])