aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library')
-rw-r--r--stdlib/source/library/lux/documentation.lux53
-rw-r--r--stdlib/source/library/lux/ffi.lux2
-rw-r--r--stdlib/source/library/lux/meta.lux27
-rw-r--r--stdlib/source/library/lux/meta/compiler/meta/cache/dependency/module.lux20
-rw-r--r--stdlib/source/library/lux/world/finance/market/price.lux2
5 files changed, 81 insertions, 23 deletions
diff --git a/stdlib/source/library/lux/documentation.lux b/stdlib/source/library/lux/documentation.lux
index 882726779..c5d240074 100644
--- a/stdlib/source/library/lux/documentation.lux
+++ b/stdlib/source/library/lux/documentation.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Definition Module Declaration #Definition #module comment)
+ [lux (.except Definition Module Declaration #Definition #module comment alias)
["[0]" debug]
[abstract
[monad (.only do)]
@@ -533,6 +533,24 @@
(` (type_documentation (, g!module) (, g!type))))))))
)))))))
+(def alias_documentation
+ (syntax (_ [name ..qualified_symbol])
+ (do meta.monad
+ [original (meta.alias name)
+ .let [link (let [[module short] original]
+ (%.format "#" module ":" short))]]
+ (in (list (` (all md.then
+ ... Name
+ (md.heading/4 (md.and (md.anchor (, (let [[module short] name]
+ (code.text (format module ":" short)))))
+ (md.text (, (code.text (%.code (|> name product.right code.local)))))))
+ (md.paragraph
+ (all md.and
+ (md.text (, (code.text "Alias for")))
+ (md.link (md.text (, (code.text (%.symbol original))))
+ (, (code.text link))))))
+ ))))))
+
(def definition_documentation
(syntax (_ [[name parameters] ..declaration
description ..description
@@ -606,6 +624,19 @@
..#documentation (,* documentation)]}))]
((, g!_) []))))))))))
+(def .public alias
+ (syntax (_ [name ..qualified_symbol])
+ (do meta.monad
+ [documentation (expansion.single (` (..alias_documentation (, (code.symbol name)))))]
+ (macro.with_symbols [g!_]
+ (let [[module short] name]
+ (in (list (` (.let [(, g!_) (.is (.-> .Any
+ ..Documentation)
+ (.function ((, g!_) (, g!_))
+ {#Definition [..#global [(, (code.text module)) (, (code.text short))]
+ ..#documentation (,* documentation)]}))]
+ ((, g!_) []))))))))))
+
(def (definition#< left right)
(-> Definition Definition
Bit)
@@ -632,20 +663,30 @@
_ (format aggregate ..coverage_separator short)))
""))
+(def (exported_non_default? [name [exported? global]])
+ (-> [Text [Bit Global]]
+ Bit)
+ (when global
+ {.#Default _}
+ false
+
+ _
+ exported?))
+
(`` (def .public module
(syntax (_ [[name _] ..qualified_symbol
description <code>.any])
- (do meta.monad
- [coverage (meta.exports name)
+ (do [! meta.monad]
+ [coverage (|> (meta.globals name)
+ (of ! each (|>> (list.only exported_non_default?)
+ (list#each product.left))))
dependees (meta.imported_modules name)]
(in (list (` (is Documentation
{#Module [..#module (, (code.text name))
..#description (, description)
..#dependees (|> (list (,* (list#each code.text dependees)))
(set.of_list text.hash))
- ..#coverage (|> (, (code.text (|> coverage
- (list#each product.left)
- ..coverage_format)))
+ ..#coverage (|> (, (code.text (..coverage_format coverage)))
(text.all_split_by (,, (static ..coverage_separator)))
(set.of_list text.hash))]}))))))))
diff --git a/stdlib/source/library/lux/ffi.lux b/stdlib/source/library/lux/ffi.lux
index 261e555ba..6d0f9d390 100644
--- a/stdlib/source/library/lux/ffi.lux
+++ b/stdlib/source/library/lux/ffi.lux
@@ -510,7 +510,7 @@
(def (input_type input :it:)
(-> Input Code Code)
(let [:it: (if (the #try? input)
- (` (.Either .Text (, :it:)))
+ (` (try.Try (, :it:)))
:it:)]
(if (the #io? input)
(` (io.IO (, :it:)))
diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux
index 25cc41183..4219acd70 100644
--- a/stdlib/source/library/lux/meta.lux
+++ b/stdlib/source/library/lux/meta.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except try macro type local)
+ [lux (.except try macro type local alias)
[abstract
[functor (.only Functor)]
[apply (.only Apply)]
@@ -289,7 +289,7 @@
(list.sorted text#<)
(text.interposed ..listing_separator)))
-(with_template [<name> <yes> <no>]
+(with_template [<name> <yes>]
[(def .public (<name> name)
(-> Symbol (Meta [Bit Global]))
(do ..monad
@@ -329,10 +329,7 @@
{.#Some (symbol#encoded [module_name def_name])}
{.#None})
- {.#Alias _}
- {.#None}
-
- {<no> _}
+ _
{.#None})))))))
list.together
(list.sorted text#<)
@@ -354,8 +351,9 @@
"")
" All known modules: " all_known_modules text.new_line)})))))]
- [definition .#Definition .#Default]
- [default' .#Default .#Definition]
+ [definition .#Definition]
+ [default' .#Default]
+ [alias' .#Alias]
)
(def .public (export name)
@@ -409,6 +407,19 @@
(in it)
(failure (all text#composite "Default is not an export: " (symbol#encoded name)))))))))
+(def .public (alias name)
+ (-> Symbol
+ (Meta Symbol))
+ (do [! ..monad]
+ [name (..normal name)
+ [exported? it] (..alias' name)]
+ (when it
+ {.#Alias it}
+ (in it)
+
+ _
+ (undefined))))
+
(with_template [<name> <slot> <type>]
[(def .public <name>
(Meta <type>)
diff --git a/stdlib/source/library/lux/meta/compiler/meta/cache/dependency/module.lux b/stdlib/source/library/lux/meta/compiler/meta/cache/dependency/module.lux
index 9b8f0934a..c9724b39b 100644
--- a/stdlib/source/library/lux/meta/compiler/meta/cache/dependency/module.lux
+++ b/stdlib/source/library/lux/meta/compiler/meta/cache/dependency/module.lux
@@ -26,19 +26,20 @@
(type .public Ancestry
(Set descriptor.Module))
-(def fresh
+(def .public fresh
Ancestry
(set.empty text.hash))
(type .public Graph
(Dictionary descriptor.Module Ancestry))
-(def empty
+(def .public empty
Graph
(dictionary.empty text.hash))
(def .public modules
- (-> Graph (List descriptor.Module))
+ (-> Graph
+ (List descriptor.Module))
dictionary.keys)
(type .public Dependency
@@ -47,13 +48,15 @@
#imports Ancestry]))
(def .public graph
- (-> (List Dependency) Graph)
+ (-> (List Dependency)
+ Graph)
(list#mix (function (_ [module imports] graph)
(dictionary.has module imports graph))
..empty))
(def (ancestry archive)
- (-> Archive Graph)
+ (-> Archive
+ Graph)
(let [memo (is (Memo descriptor.Module Ancestry)
(function (_ again module)
(do [! state.monad]
@@ -75,7 +78,8 @@
(archive.archived archive))))
(def (dependency? ancestry target source)
- (-> Graph descriptor.Module descriptor.Module Bit)
+ (-> Graph descriptor.Module descriptor.Module
+ Bit)
(let [target_ancestry (|> ancestry
(dictionary.value target)
(maybe.else ..fresh))]
@@ -85,7 +89,9 @@
(List [descriptor.Module [module.ID (archive.Entry a)]]))
(def .public (load_order key archive)
- (All (_ a) (-> (Key a) Archive (Try (Order a))))
+ (All (_ of)
+ (-> (Key of) Archive
+ (Try (Order of))))
(let [ancestry (..ancestry archive)]
(|> ancestry
dictionary.keys
diff --git a/stdlib/source/library/lux/world/finance/market/price.lux b/stdlib/source/library/lux/world/finance/market/price.lux
index c7b6e8e8c..9dbf1ab02 100644
--- a/stdlib/source/library/lux/world/finance/market/price.lux
+++ b/stdlib/source/library/lux/world/finance/market/price.lux
@@ -129,7 +129,7 @@
(%.format (%.int macro)
(when micro
+0 ""
- _ (%.format "." (%.nat (.nat micro))))
+ _ (%.format "." (%.nat (.nat (i.abs micro)))))
" " (currency.alphabetic_code currency))))
)