aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2021-08-14 03:09:58 -0400
committerEduardo Julian2021-08-14 03:09:58 -0400
commit6fd22846f21b8b70b7867e989109d14a366c0a3e (patch)
tree9086774968ad944133dc5cf29c546add6e13a4b6
parente53c1a090eb9cfac3cb23d10d981648d02518ed1 (diff)
Moved documentation-generation machinery to its own module.
-rw-r--r--documentation/book/the_lux_programming_language/chapter_13.md2
-rw-r--r--documentation/book/the_lux_programming_language/chapter_14.md193
-rw-r--r--lux-cl/source/program.lux4
-rw-r--r--lux-js/source/program.lux10
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm.lux4
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux2
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/function.lux10
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/runtime.lux2
-rw-r--r--lux-jvm/test/test/luxc/lang/synthesis/loop.lux4
-rw-r--r--lux-lua/source/program.lux16
-rw-r--r--lux-mode/lux-mode.el2
-rw-r--r--lux-php/source/program.lux8
-rw-r--r--lux-ruby/source/program.lux8
-rw-r--r--lux-scheme/source/program.lux10
-rw-r--r--stdlib/commands.md9
-rw-r--r--stdlib/project.lux25
-rw-r--r--stdlib/source/documentation/lux.lux31
-rw-r--r--stdlib/source/documentation/lux/abstract.lux42
-rw-r--r--stdlib/source/documentation/lux/abstract/apply.lux19
-rw-r--r--stdlib/source/documentation/lux/abstract/codec.lux24
-rw-r--r--stdlib/source/documentation/lux/abstract/comonad.lux29
-rw-r--r--stdlib/source/documentation/lux/abstract/comonad/cofree.lux17
-rw-r--r--stdlib/source/documentation/lux/abstract/enum.lux20
-rw-r--r--stdlib/source/documentation/lux/abstract/equivalence.lux24
-rw-r--r--stdlib/source/documentation/lux/abstract/functor.lux33
-rw-r--r--stdlib/source/documentation/lux/abstract/functor/contravariant.lux15
-rw-r--r--stdlib/source/documentation/lux/abstract/monad.lux54
-rw-r--r--stdlib/source/documentation/lux/abstract/monad/free.lux18
-rw-r--r--stdlib/source/library/lux.lux44
-rw-r--r--stdlib/source/library/lux/abstract/apply.lux2
-rw-r--r--stdlib/source/library/lux/abstract/codec.lux2
-rw-r--r--stdlib/source/library/lux/abstract/comonad.lux7
-rw-r--r--stdlib/source/library/lux/abstract/comonad/cofree.lux1
-rw-r--r--stdlib/source/library/lux/abstract/enum.lux2
-rw-r--r--stdlib/source/library/lux/abstract/equivalence.lux2
-rw-r--r--stdlib/source/library/lux/abstract/functor.lux3
-rw-r--r--stdlib/source/library/lux/abstract/monad.lux13
-rw-r--r--stdlib/source/library/lux/abstract/monad/free.lux1
-rw-r--r--stdlib/source/library/lux/control/concurrency/semaphore.lux6
-rw-r--r--stdlib/source/library/lux/control/concurrency/stm.lux8
-rw-r--r--stdlib/source/library/lux/control/parser/text.lux4
-rw-r--r--stdlib/source/library/lux/control/parser/type.lux2
-rw-r--r--stdlib/source/library/lux/control/region.lux2
-rw-r--r--stdlib/source/library/lux/control/thread.lux10
-rw-r--r--stdlib/source/library/lux/data/binary.lux4
-rw-r--r--stdlib/source/library/lux/data/collection/array.lux48
-rw-r--r--stdlib/source/library/lux/data/collection/bits.lux4
-rw-r--r--stdlib/source/library/lux/data/collection/dictionary.lux112
-rw-r--r--stdlib/source/library/lux/data/collection/list.lux10
-rw-r--r--stdlib/source/library/lux/data/collection/queue.lux6
-rw-r--r--stdlib/source/library/lux/data/collection/queue/priority.lux6
-rw-r--r--stdlib/source/library/lux/data/collection/row.lux12
-rw-r--r--stdlib/source/library/lux/data/collection/sequence.lux4
-rw-r--r--stdlib/source/library/lux/data/collection/set/multi.lux2
-rw-r--r--stdlib/source/library/lux/data/collection/stack.lux6
-rw-r--r--stdlib/source/library/lux/data/format/binary.lux2
-rw-r--r--stdlib/source/library/lux/data/format/css/value.lux2
-rw-r--r--stdlib/source/library/lux/data/format/json.lux4
-rw-r--r--stdlib/source/library/lux/data/format/markdown.lux22
-rw-r--r--stdlib/source/library/lux/data/text.lux6
-rw-r--r--stdlib/source/library/lux/debug.lux6
-rw-r--r--stdlib/source/library/lux/documentation.lux366
-rw-r--r--stdlib/source/library/lux/math/number/rev.lux2
-rw-r--r--stdlib/source/library/lux/math/random.lux2
-rw-r--r--stdlib/source/library/lux/meta.lux27
-rw-r--r--stdlib/source/library/lux/target/jvm/reflection.lux4
-rw-r--r--stdlib/source/library/lux/tool/compiler/default/platform.lux18
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux6
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux9
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux8
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/io/context.lux2
-rw-r--r--stdlib/source/library/lux/type/check.lux6
-rw-r--r--stdlib/source/library/lux/type/implicit.lux2
-rw-r--r--stdlib/source/library/lux/world/file.lux30
-rw-r--r--stdlib/source/library/lux/world/file/watch.lux26
-rw-r--r--stdlib/source/library/lux/world/net/http/header.lux14
-rw-r--r--stdlib/source/library/lux/world/program.lux6
-rw-r--r--stdlib/source/poly/lux/abstract/equivalence.lux2
-rw-r--r--stdlib/source/poly/lux/abstract/functor.lux2
-rw-r--r--stdlib/source/poly/lux/data/format/json.lux4
-rw-r--r--stdlib/source/program/aedifex/hash.lux2
-rw-r--r--stdlib/source/program/aedifex/repository.lux4
-rw-r--r--stdlib/source/program/compositor/import.lux2
-rw-r--r--stdlib/source/specification/compositor/generation/function.lux4
-rw-r--r--stdlib/source/specification/compositor/generation/structure.lux6
-rw-r--r--stdlib/source/test/aedifex/command/version.lux2
-rw-r--r--stdlib/source/test/lux.lux2
-rw-r--r--stdlib/source/test/lux/abstract/comonad/cofree.lux4
-rw-r--r--stdlib/source/test/lux/control/concurrency/actor.lux2
-rw-r--r--stdlib/source/test/lux/control/concurrency/stm.lux40
-rw-r--r--stdlib/source/test/lux/control/parser.lux8
-rw-r--r--stdlib/source/test/lux/control/parser/text.lux6
-rw-r--r--stdlib/source/test/lux/control/parser/type.lux8
-rw-r--r--stdlib/source/test/lux/control/region.lux30
-rw-r--r--stdlib/source/test/lux/control/thread.lux16
-rw-r--r--stdlib/source/test/lux/data/binary.lux8
-rw-r--r--stdlib/source/test/lux/data/collection/array.lux20
-rw-r--r--stdlib/source/test/lux/data/collection/dictionary.lux16
-rw-r--r--stdlib/source/test/lux/data/collection/list.lux22
-rw-r--r--stdlib/source/test/lux/data/collection/queue.lux14
-rw-r--r--stdlib/source/test/lux/data/collection/queue/priority.lux30
-rw-r--r--stdlib/source/test/lux/data/collection/sequence.lux36
-rw-r--r--stdlib/source/test/lux/data/collection/stack.lux16
-rw-r--r--stdlib/source/test/lux/data/text.lux4
-rw-r--r--stdlib/source/test/lux/documentation.lux93
-rw-r--r--stdlib/source/test/lux/meta.lux4
-rw-r--r--stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux12
-rw-r--r--stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux24
-rw-r--r--stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux16
-rw-r--r--stdlib/source/test/lux/world/console.lux2
112 files changed, 1485 insertions, 508 deletions
diff --git a/documentation/book/the_lux_programming_language/chapter_13.md b/documentation/book/the_lux_programming_language/chapter_13.md
index e61c3b798..afd08f5fd 100644
--- a/documentation/book/the_lux_programming_language/chapter_13.md
+++ b/documentation/book/the_lux_programming_language/chapter_13.md
@@ -195,5 +195,5 @@ Host platform inter-operation is a feature whose value can never be understated,
We're actually going to explore one such feature in the next chapter, when we abandon our old notions of sequential program execution and explore the curious world of concurrency.
-See you in the next chapter!
+See you in [the next chapter](chapter_14.md)!
diff --git a/documentation/book/the_lux_programming_language/chapter_14.md b/documentation/book/the_lux_programming_language/chapter_14.md
new file mode 100644
index 000000000..8be6afcd5
--- /dev/null
+++ b/documentation/book/the_lux_programming_language/chapter_14.md
@@ -0,0 +1,193 @@
+# Chapter 14: Concurrency
+
+_Where you will harness the power of modern computing._
+
+---
+
+Concurrency is one of the most important subjects in modern programming because of the pressing need to improve the efficiency of programs; coupled with the troublesome limitation that increasing the speed of individual CPUs is becoming harder and harder.
+
+The solution, at the moment, is to increase the number of CPUs in the machine to allow programmers to run their code in parallel.
+
+The problem is that new models of computation which take concurrency into account have had to be developed to address this need, but nobody knows yet which of the many alternatives is _the right one_, or if there is even a right one at all.
+
+Until now, most programmers just thought about their programs in a purely sequential manner; and, as we explore some of these concurrency models, you'll notice that they try to restore some of this feeling, while at the same time _scheduling_ work to happen concurrently, without (almost) any programmer involvement.
+
+Lux takes the approach of providing the means to use multiple concurrency models, since I couldn't decide on which was _the right one_.
+
+Some languages (like _Erlang_ and _Go_) choose to commit themselves to one model or another, but I'm not confident that the software industry (as a whole) is experienced enough with concurrency as to declare any one model the winner.
+
+The result: more variety.
+
+And watch out, because the amount of concurrency models may increase with future Lux releases.
+
+Anyhow, let's quit the chit-chat and dive in!
+
+## Asynchronous computation
+
+This is my favorite one, because it can be used for almost anything, whereas I see the other modules as more specialized tools for certain use cases.
+
+This model is based on concepts you may be familiar with: _futures_ and _promises_.
+
+**Futures** are basically concurrent and asynchronous computations which run and yield a value, which you can later access.
+
+**Promises** are more like storage locations (which may be set only once), which you can use for communication by setting their values in one process, and reading it from another.
+
+Some languages offer both (often used in conjunction), while others only offer one (while also kind of giving it properties of the other).
+
+I pretty much came to the conclusion that, for all intents and purposes, their similarities were much greater than their differences.
+
+So, I just fused them.
+
+And so, Lux implements promises in the `library/lux/control/concurrency/async` module, by means of the `Async` type.
+
+You can run `IO` computations concurrently using the `future` function (which returns an `Async` that will contain the result of the computation).
+
+You can also bind functions to `Async` values in order to be notified when they have been _resolved_ (the term for when the value of the `Async` is set).
+
+By means of this ability to watch `Async` values, it's possible to implement `Functor` and `Monad` for `Async`, which is precisely what is done in the standard library.
+
+The result is that, through the `do` macro, you can implement complex concurrent and asynchronous computations that look and feel just like synchronous ones.
+
+If you're curious about how that looks, take a peek:
+
+```
+(def: .public (and left right)
+ (All [a b] (-> (Async a) (Async b) (Async [a b])))
+ (do monad
+ [a left
+ b right]
+ (in [a b])))
+```
+
+ Oh, and did I mention there are _combinators_ in that module?
+
+If you didn't know there was some magic going on in the `Async` type, you wouldn't have suspected this was concurrent code. It looks just like any other old synchronous code you might have use with any other monad.
+
+Pretty neat, huh?
+
+## Functional Reactive Programming
+
+FRP is based on the idea of _values that change over time_, and structuring your programs to dynamically respond to those changes in a **reactive** way.
+
+The way its implemented in Lux is through the `Channel` type in `library/lux/control/concurrency/frp` (itself implemented on top of `Async`).
+`Channel` instances are (potentially infinite) sequences of values that you can process in various ways as new values come into being.
+`Channel` instances can be closed, but they may also go on forever if you'd like them to.
+
+The `library/lux/control/concurrency/frp` module offers various functions for processing channels in various them (some of them generating new channels), and the `Channel` type also happens to be a monad, so you can write fairly complex and powerful code with it.
+
+## Software Transactional Memory
+
+ Implemented in the `library/lux/control/concurrency/stm` module.
+
+STM is quite a different beast from the other 2 approaches, in that they address the problem of how do I propagate information within the system, while STM deals with how to keep data in one place, where it can be accessed and modified concurrently by multiple processes.
+
+It works by having variables which may be read from and written to, but only within _transactions_, which could be seen as descriptions of changes to be made to one (or more) variables in an atomic, consistent and isolated way.
+
+Let's break down those last 3 terms:
+
+* **Atomic**: This just means that if more than one change needs to be made in a transaction, either all gets done, or none. There is no room for partial results.
+* **Consistent**: This just means that transactional computations will take the set of variables they operate from one valid state to another. This is largely a consecuence of transactions being atomic.
+* **Isolated**: This means that transactions run in isolation (or, without interference) from one another, thereby ensuring no transaction may see or modify any in-trasaction value being computed somewhere else, and they all get the _impression_ that they are the only transaction running at any given time.
+
+For those of you familiar with relational databases, this might remind you of their _ACID_ properties (with the caveat that Lux's STM is non-durable, as it works entirely in memory).
+
+The way it works is by running multiple transactions concurrently, and then committing their results to the affected variables.
+If 2 transactions modify any common variables, the first one to commit wins, and the second one would be re-calculated to take into account the changes to those variables.
+This implies that transactions are sensitive to some "version" of the variables they involve and that is correct.
+That is the mechanism use to avoid collisions and ensure no inconsistencies ever arise.
+
+The relevant types are `Var`, which corresponds to the variables, and `STM` which are computations which transform transactions in some way and yield results.
+
+Like `IO` and unlike `Async`, just writing `STM` computations doesn't actually run them, and you must call the `commit!` function to actually schedule the system to execute them (receiving a `Async` value for the result of the transaction).
+
+You may also `follow!` variables to get `Channel`s of their values if you're interesting in tracking them.
+
+## The Actor Model
+
+The _actor model_ is also very different from the other models in that, while they deal with computations which produce values concurrently, the _actor model_ is all about processes running concurrently and communicating with one another.
+
+You can't run an actor and just wait for it to finish to get the result. For all you know, it may never end and just run forever.
+
+Also, interaction with actors is based on _message-passing_, and an actor may consume an indefinite number of such messages (and send messages to other actors).
+
+The relevant module is the `library/lux/control/concurrency/actor` module, and the relevant type is:
+
+```
+(abstract: .public (Actor s)
+ ...
+ )
+```
+
+`Actor`s have mailboxes for receiving messages, to which they react.
+
+It's also possible to kill an actor (although it can also die _naturally_ if it encounters a failure condition during normal execution).
+
+And if it dies, you'll receive its state at the time of death, a list of unconsumed messages from its mailbox and an error message detailing the cause of death.
+
+Just from this definition, it's easy to see that actors are stateful (a necessity for modeling a variety of complex behaviors).
+
+To create an actor, you must first specify its `Behavior`:
+
+```
+(type: .public (Behavior o s)
+ {#on_init (-> o s)
+ #on_mail (-> (Mail s) s (Actor s) (Async (Try s)))})
+```
+
+These functions know how to initialize an actor, and how to react to incoming mail.
+
+You can then call the `spawn!` function with an initial state and a `Behavior`.
+
+But writing complex actors with multiple options for its messages can be messy with these tools, so a macro was made to simplify that.
+
+```
+... Defines a named actor, with its behavior and internal state.
+... Messages for the actor must be defined after the on_mail handler.
+(actor: .public (stack a)
+ {}
+
+ (List a)
+
+ ((on_mail mail state self)
+ (do (try.with async.monad)
+ [.let [_ (debug.log! "BEFORE")]
+ output (mail state self)
+ .let [_ (debug.log! "AFTER")]]
+ (in output)))
+
+ (message: .public (push {value a} state self)
+ Nat
+ (let [state' (#.Item value state)]
+ (async.resolved (#try.Success [state' (list.size state')])))))
+
+(actor: .public counter
+ {}
+
+ Nat
+
+ (message: .public (count! {increment Nat} state self)
+ Any
+ (let [state' (n.+ increment state)]
+ (async.resolved (#try.Success [state' []]))))
+
+ (message: .public (read! state self)
+ Nat
+ (async.resolved (#try.Success [state state]))))
+```
+
+For every method you define, a function will be defined in your module with the same name, and taking the same arguments, plus the actor.
+That function will always take the actor itself as its last argument, and will return an `Async` of the return type.
+
+You can either die with a `#librarylux/control/try.Failure` value, or continue on to the next message with a `#librarylux/control/try.Success` containing an updated _actor state_, and a _return value_ for the method.
+The type of the return value must match the type following the method signature.
+
+---
+
+In this chapter, you have learned how to use the many tools Lux offers to tap into the multi-processor power of modern computing systems.
+
+But if you think about it, being able to hold onto values or pass them around concurrently is rather useless unless you have some important and complex data to move around in the first place; and so far we have only dealt with fairly simple data-structures.
+
+Well, read the next chapter if you want to learn how to take your data to the next level with the help of persistent data structures.
+
+See you in the next chapter!
+
diff --git a/lux-cl/source/program.lux b/lux-cl/source/program.lux
index 41e588f56..09b9b02cd 100644
--- a/lux-cl/source/program.lux
+++ b/lux-cl/source/program.lux
@@ -202,8 +202,8 @@
[(org/armedbear/lisp/LispObject
[] (<name> self {idx int})
org/armedbear/lisp/LispObject
- (case (array.read (|> idx java/lang/Integer::longValue (:as Nat))
- (:as (Array java/lang/Object) value))
+ (case (array.read! (|> idx java/lang/Integer::longValue (:as Nat))
+ (:as (Array java/lang/Object) value))
(#.Some sub)
(to_sub sub)
diff --git a/lux-js/source/program.lux b/lux-js/source/program.lux
index 03e673af9..f58fa3d40 100644
--- a/lux-js/source/program.lux
+++ b/lux-js/source/program.lux
@@ -198,7 +198,7 @@
(org/openjdk/nashorn/api/scripting/AbstractJSObject
[] (call self {this java/lang/Object} {args [java/lang/Object]}) java/lang/Object
(|> (java/util/Arrays::copyOfRange value
- (|> args (array.read 0) maybe.assume (:as Int))
+ (|> args (array.read! 0) maybe.assume (:as Int))
(.int (array.size value)))
js_object
(:as java/lang/Object)))
@@ -242,10 +242,10 @@
(::slice js_object value))
(^ (static runtime.variant_tag_field))
- (|> value (array.read 0) maybe.assume)
+ (|> value (array.read! 0) maybe.assume)
(^ (static runtime.variant_flag_field))
- (case (array.read 1 value)
+ (case (array.read! 1 value)
(#.Some set!)
set!
@@ -253,7 +253,7 @@
(ffi.null))
(^ (static runtime.variant_value_field))
- (|> value (array.read 2) maybe.assume js_object (:as java/lang/Object))
+ (|> value (array.read! 2) maybe.assume js_object (:as java/lang/Object))
_
(panic! (exception.construct ..unknown_member [(:as Text member) (:as java/lang/Object value)])))
@@ -261,7 +261,7 @@
(org/openjdk/nashorn/api/scripting/AbstractJSObject
[] (getSlot self {idx int}) java/lang/Object
(|> value
- (array.read (|> idx java/lang/Integer::longValue (:as Nat)))
+ (array.read! (|> idx java/lang/Integer::longValue (:as Nat)))
maybe.assume
js_object
(:as java/lang/Object)))
diff --git a/lux-jvm/source/luxc/lang/translation/jvm.lux b/lux-jvm/source/luxc/lang/translation/jvm.lux
index dbf49b552..71dcfa645 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm.lux
@@ -100,7 +100,7 @@
(def: .public bytecode_name
(-> Text Text)
- (text.replace_all ..class_path_separator .module_separator))
+ (text.replaced ..class_path_separator .module_separator))
(def: .public (class_name [module_id artifact_id])
(-> generation.Context Text)
@@ -136,7 +136,7 @@
(def: (execute! library loader [class_name class_bytecode])
(-> Library java/lang/ClassLoader Definition (Try Any))
(io.run! (do (try.with io.monad)
- [existing_class? (|> (atom.read library)
+ [existing_class? (|> (atom.read! library)
(\ io.monad map (function (_ library)
(dictionary.key? library class_name)))
(try.lifted io.monad)
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux
index b25d37fd7..492911d40 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux
@@ -966,7 +966,7 @@
(def: (anonymous_init_method env)
(-> (Environment Synthesis) (Type Method))
(type.method [(list)
- (list.repeat (list.size env) $Object)
+ (list.repeated (list.size env) $Object)
type.void
(list)]))
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/function.lux b/lux-jvm/source/luxc/lang/translation/jvm/function.lux
index e4fb2c65e..9af108496 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/function.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/function.lux
@@ -52,7 +52,7 @@
(def: (captured_args env)
(-> (Environment Synthesis) (List (Type Value)))
- (list.repeat (list.size env) //.$Value))
+ (list.repeated (list.size env) //.$Value))
(def: (init_method env arity)
(-> (Environment Synthesis) Arity (Type Method))
@@ -60,13 +60,13 @@
(type.method [(list)
(list.joined (list (captured_args env)
(list type.int)
- (list.repeat (dec arity) //.$Value)))
+ (list.repeated (dec arity) //.$Value)))
type.void
(list)])
(type.method [(list) (captured_args env) type.void (list)])))
(def: (implementation_method arity)
- (type.method [(list) (list.repeat arity //.$Value) //.$Value (list)]))
+ (type.method [(list) (list.repeated arity //.$Value) //.$Value (list)]))
(def: get_amount_of_partialsI
Inst
@@ -103,7 +103,7 @@
(def: (nullsI amount)
(-> Nat Inst)
(|> _.NULL
- (list.repeat amount)
+ (list.repeated amount)
_.fuse))
(def: (instance generate archive class arity env)
@@ -201,7 +201,7 @@
Def)
(let [num_partials (dec function_arity)
@default ($.new_label [])
- @labels (list@map $.new_label (list.repeat num_partials []))
+ @labels (list@map $.new_label (list.repeated num_partials []))
over_extent (|> (.int function_arity) (i.- (.int apply_arity)))
casesI (|> (list@compose @labels (list @default))
(list.zipped/2 (enum.range n.enum 0 num_partials))
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux b/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux
index 4d97535d1..2808065c6 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux
@@ -115,7 +115,7 @@
(def: .public (apply_signature arity)
(-> Arity (Type Method))
- (type.method [(list) (list.repeat arity $Value) $Value (list)]))
+ (type.method [(list) (list.repeated arity $Value) $Value (list)]))
(def: adt_methods
Def
diff --git a/lux-jvm/test/test/luxc/lang/synthesis/loop.lux b/lux-jvm/test/test/luxc/lang/synthesis/loop.lux
index 0ed3b63fa..63ad3a395 100644
--- a/lux-jvm/test/test/luxc/lang/synthesis/loop.lux
+++ b/lux-jvm/test/test/luxc/lang/synthesis/loop.lux
@@ -62,9 +62,9 @@
#let [bad-bodies (list.repeat num-cases (' []))]
good-body (gen-body arity output)
where-to-set (|> r.nat (:: @ map (n/% num-cases)))
- #let [bodies (list.joined (list (list.take where-to-set bad-bodies)
+ #let [bodies (list.joined (list (list.first where-to-set bad-bodies)
(list good-body)
- (list.drop (n/inc where-to-set) bad-bodies)))]]
+ (list.after (n/inc where-to-set) bad-bodies)))]]
(wrap (` ("lux case" (~ inputA)
(~ (code.record (list.zip2 tests bodies))))))))
(r.either (do r.Monad<Random>
diff --git a/lux-lua/source/program.lux b/lux-lua/source/program.lux
index fc02693cf..ffaf3a8e9 100644
--- a/lux-lua/source/program.lux
+++ b/lux-lua/source/program.lux
@@ -188,7 +188,7 @@
(net/sandius/rembulan/impl/DefaultTable
[] (rawget self {idx long}) java/lang/Object
- (|> value (array.read (|> idx (:as Nat) dec)) maybe.assume re_wrap))
+ (|> value (array.read! (|> idx (:as Nat) dec)) maybe.assume re_wrap))
(net/sandius/rembulan/impl/DefaultTable
[] (rawget self {field java/lang/Object}) java/lang/Object
@@ -196,10 +196,10 @@
(#.Some field)
(case (net/sandius/rembulan/ByteString::decode field)
(^ (static runtime.variant_tag_field))
- (|> value (array.read 0) maybe.assume)
+ (|> value (array.read! 0) maybe.assume)
(^ (static runtime.variant_flag_field))
- (case (array.read 1 value)
+ (case (array.read! 1 value)
(#.Some _)
""
@@ -207,7 +207,7 @@
(ffi.null))
(^ (static runtime.variant_value_field))
- (|> value (array.read 2) maybe.assume re_wrap)
+ (|> value (array.read! 2) maybe.assume re_wrap)
_
(panic! (exception.construct ..unknown_kind_of_object field)))
@@ -215,7 +215,7 @@
#.None
(case (ffi.check java/lang/Long field)
(#.Some idx)
- (|> value (array.read (|> idx (:as Nat) dec)) maybe.assume re_wrap)
+ (|> value (array.read! (|> idx (:as Nat) dec)) maybe.assume re_wrap)
#.None
(panic! (exception.construct ..unknown_kind_of_object field)))))
@@ -319,7 +319,7 @@
... (net/sandius/rembulan/impl/ImmutableTable$Builder::build (net/sandius/rembulan/impl/ImmutableTable$Builder::new))
(:as java/lang/Object (lux_structure (:as (Array java/lang/Object) lux)))))
executor)]
- (|> output (array.read 0) maybe.assume (:as java/lang/Object) ..read)))
+ (|> output (array.read! 0) maybe.assume (:as java/lang/Object) ..read)))
(def: (expander baggage macro inputs lux)
(-> Baggage Expander)
@@ -546,7 +546,7 @@
[lua_function (net/sandius/rembulan/load/ChunkLoader::loadTextChunk variable "lux compilation" (_.code code) loader)
output (net/sandius/rembulan/exec/DirectCallExecutor::call state_context (:as java/lang/Object lua_function) (array.new 0)
executor)]
- (case (array.read 0 output)
+ (case (array.read! 0 output)
#.None
(wrap [])
@@ -749,7 +749,7 @@
(array.write! 4 (..to_host state)))
executor)]
(|> output
- (array.read 0)
+ (array.read! 0)
maybe.assume
(:as java/lang/Object)
..read)))))
diff --git a/lux-mode/lux-mode.el b/lux-mode/lux-mode.el
index c49229be8..0c059874e 100644
--- a/lux-mode/lux-mode.el
+++ b/lux-mode/lux-mode.el
@@ -388,7 +388,7 @@ Called by `imenu--generic-function'."
(actor (altRE "actor:" "message:" "actor"))
(jvm-host (altRE "class:" "interface:" "import:" "object" "do_to" "synchronized" "class_for"))
(alternative-format (altRE "char" "bin" "oct" "hex"))
- (documentation (altRE "example" "comment"))
+ (documentation (altRE "comment" "documentation:"))
(function-application (altRE "|>" "<|" "_\\$" "\\$_"))
(function-definition (altRE "function" "|>>" "<<|" "||>"))
(remember (altRE "remember" "to_do" "fix_me"))
diff --git a/lux-php/source/program.lux b/lux-php/source/program.lux
index dc3d270a7..72a064810 100644
--- a/lux-php/source/program.lux
+++ b/lux-php/source/program.lux
@@ -267,7 +267,7 @@
{index long})
php/runtime/Memory
(|> value
- (array.read index)
+ (array.read! index)
maybe.assume
(..value_wrapper lux_structure)))
@@ -279,13 +279,13 @@
(case (:as Text index)
(^ (static runtime.variant_tag_field))
(|> value
- (array.read 0)
+ (array.read! 0)
maybe.assume
(:as java/lang/Integer)
php/runtime/memory/LongMemory::valueOf)
(^ (static runtime.variant_flag_field))
- (case (array.read 1 value)
+ (case (array.read! 1 value)
#.None
(php/runtime/memory/NullMemory::INSTANCE)
@@ -294,7 +294,7 @@
(^ (static runtime.variant_value_field))
(|> value
- (array.read 2)
+ (array.read! 2)
maybe.assume
(..value_wrapper lux_structure))
diff --git a/lux-ruby/source/program.lux b/lux-ruby/source/program.lux
index 5d8c81858..3e6a4d638 100644
--- a/lux-ruby/source/program.lux
+++ b/lux-ruby/source/program.lux
@@ -383,7 +383,7 @@
(let [member (ffi.array_read 0 args)]
(<| (case (ffi.check org/jruby/RubyFixnum member)
(#.Some member)
- (case (array.read (org/jruby/RubyFixnum::getLongValue member) value)
+ (case (array.read! (org/jruby/RubyFixnum::getLongValue member) value)
(#.Some value)
(wrapped_lux_value lux_structure value)
@@ -396,14 +396,14 @@
(case (:as Text (org/jruby/RubyString::asJavaString member))
(^ (static runtime.variant_tag_field))
(|> value
- (array.read 0)
+ (array.read! 0)
maybe.assume
(:as java/lang/Integer)
java/lang/Integer::longValue
(org/jruby/RubyFixnum::new ..initial_ruby_runtime))
(^ (static runtime.variant_flag_field))
- (case (array.read 1 value)
+ (case (array.read! 1 value)
#.None
..ruby_nil
@@ -411,7 +411,7 @@
..lux_unit)
(^ (static runtime.variant_value_field))
- (case (array.read 2 value)
+ (case (array.read! 2 value)
(#.Some value)
(wrapped_lux_value lux_structure value)
diff --git a/lux-scheme/source/program.lux b/lux-scheme/source/program.lux
index f25a71bbe..7a82b96bb 100644
--- a/lux-scheme/source/program.lux
+++ b/lux-scheme/source/program.lux
@@ -138,7 +138,7 @@
... TODO: Get rid of this coercion ASAP.
(let [array (:as (Array java/lang/Object) array)]
(and (n.= 3 (array.size array))
- (case (array.read 0 array)
+ (case (array.read! 0 array)
(#.Some tag)
(case (ffi.check java/lang/Integer tag)
(#.Some _)
@@ -176,14 +176,14 @@
(gnu/lists/Pair
[] (getCar self) java/lang/Object
(if cdr?
- (case (array.read 1 value)
+ (case (array.read! 1 value)
(#.Some flag_is_set)
true
#.None
false)
(|> value
- (array.read 0)
+ (array.read! 0)
maybe.assume
(:as java/lang/Integer)
gnu/math/IntNum::new)))
@@ -191,7 +191,7 @@
[] (getCdr self) java/lang/Object
(if cdr?
(|> value
- (array.read 2)
+ (array.read! 2)
maybe.assume
lux_value)
(variant_value lux_value true value)))))
@@ -210,7 +210,7 @@
(gnu/lists/SimpleVector
[] (getRaw self {idx int}) java/lang/Object
(|> value
- (array.read (|> idx java/lang/Integer::longValue (:as Nat)))
+ (array.read! (|> idx java/lang/Integer::longValue (:as Nat)))
maybe.assume
lux_value))
(gnu/lists/SimpleVector
diff --git a/stdlib/commands.md b/stdlib/commands.md
index 375800f92..ff590d8a6 100644
--- a/stdlib/commands.md
+++ b/stdlib/commands.md
@@ -34,6 +34,15 @@ cd ~/lux/stdlib/ && mvn deploy:deploy-file \
cd ~/lux/stdlib/ \
&& lein clean \
&& lein with-profile scriptum lux auto build
+
+cd ~/lux/stdlib/ \
+&& lux clean \
+&& lux with documentation auto test
+
+cd ~/lux/stdlib/ \
+&& lux clean \
+&& lux with documentation build \
+&& java -jar target/program.jar > documentation.md
```
---
diff --git a/stdlib/project.lux b/stdlib/project.lux
index 919e9e489..de7325890 100644
--- a/stdlib/project.lux
+++ b/stdlib/project.lux
@@ -1,11 +1,16 @@
-{#identity ["com.github.luxlang" "stdlib" "0.6.0-SNAPSHOT"]
-
- #deploy_repositories {"snapshots" "https://oss.sonatype.org/content/repositories/snapshots/"
- "releases" "https://oss.sonatype.org/service/local/staging/deploy/maven2/"}
+{""
+ {#identity ["com.github.luxlang" "stdlib" "0.6.0-SNAPSHOT"]
+
+ #deploy_repositories {"snapshots" "https://oss.sonatype.org/content/repositories/snapshots/"
+ "releases" "https://oss.sonatype.org/service/local/staging/deploy/maven2/"}
- #repositories ["https://oss.sonatype.org/content/repositories/snapshots/"
- "https://oss.sonatype.org/service/local/staging/deploy/maven2/"]
-
- #compiler ["com.github.luxlang" "lux-jvm" "0.6.0-SNAPSHOT" "jar"]
-
- #test "test/lux"}
+ #repositories ["https://oss.sonatype.org/content/repositories/snapshots/"
+ "https://oss.sonatype.org/service/local/staging/deploy/maven2/"]
+
+ #compiler ["com.github.luxlang" "lux-jvm" "0.6.0-SNAPSHOT" "jar"]
+
+ #test "test/lux"}
+
+ "documentation"
+ {#program "documentation/lux"
+ #test "documentation/lux"}}
diff --git a/stdlib/source/documentation/lux.lux b/stdlib/source/documentation/lux.lux
new file mode 100644
index 000000000..5131a9607
--- /dev/null
+++ b/stdlib/source/documentation/lux.lux
@@ -0,0 +1,31 @@
+(.module:
+ [library
+ [lux
+ [program (#+ program:)]
+ ["$" documentation (#+ documentation:)]
+ ["." debug]
+ [control
+ ["." io]]]]
+ [\\library
+ ["." /]]
+ ["." / #_
+ ["#." abstract]])
+
+(documentation: /.:of
+ "Generates the type corresponding to a given expression."
+ [(let [my_num +123]
+ (:of my_num))
+ "=>"
+ .Int]
+ [(:of +123)
+ "=>"
+ .Int])
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ [..:of]
+ [/abstract.documentation]))
+
+(program: inputs
+ (io.io (debug.log! ($.documentation ..documentation))))
diff --git a/stdlib/source/documentation/lux/abstract.lux b/stdlib/source/documentation/lux/abstract.lux
new file mode 100644
index 000000000..a4e7ec807
--- /dev/null
+++ b/stdlib/source/documentation/lux/abstract.lux
@@ -0,0 +1,42 @@
+(.module:
+ [library
+ [lux #*
+ ["$" documentation (#+ documentation:)]
+ [data
+ [text (#+ \n)
+ ["%" format (#+ format)]]
+ [collection
+ ["." list]]]]]
+ ["." / #_
+ ["#." apply]
+ ["#." codec]
+ ["#." comonad]
+ ["#." enum]
+ ["#." equivalence]
+ ... ["#." hash]
+ ... ["#." fold]
+ ["#." functor]
+ ... ["#." interval]
+ ["#." monad]
+ ... ["#." monoid]
+ ... ["#." order]
+ ... ["#." predicate]
+ ])
+
+(.def: .public documentation
+ (.List $.Module)
+ (list.joined (list
+ /apply.documentation
+ /codec.documentation
+ /comonad.documentation
+ /enum.documentation
+ /equivalence.documentation
+ ... /hash.documentation
+ ... /fold.documentation
+ ... /interval.documentation
+ ... /monoid.documentation
+ ... /order.documentation
+ ... /predicate.documentation
+ /functor.documentation
+ /monad.documentation
+ )))
diff --git a/stdlib/source/documentation/lux/abstract/apply.lux b/stdlib/source/documentation/lux/abstract/apply.lux
new file mode 100644
index 000000000..ba611918d
--- /dev/null
+++ b/stdlib/source/documentation/lux/abstract/apply.lux
@@ -0,0 +1,19 @@
+(.module:
+ [library
+ [lux
+ ["$" documentation (#+ documentation:)]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.Apply
+ "Applicative functors.")
+
+(documentation: /.compose
+ "Applicative functor composition.")
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ [..Apply
+ ..compose]
+ []))
diff --git a/stdlib/source/documentation/lux/abstract/codec.lux b/stdlib/source/documentation/lux/abstract/codec.lux
new file mode 100644
index 000000000..dc83d6fce
--- /dev/null
+++ b/stdlib/source/documentation/lux/abstract/codec.lux
@@ -0,0 +1,24 @@
+(.module:
+ [library
+ [lux
+ ["$" documentation (#+ documentation:)]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.Codec
+ "A way to move back-and-forth between a type and an alternative representation for it.")
+
+(documentation: /.compose
+ "Codec composition."
+ [(: (Codec c a)
+ (compose (: (Codec c b)
+ cb_codec)
+ (: (Codec b a)
+ ba_codec)))])
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ [..Codec
+ ..compose]
+ []))
diff --git a/stdlib/source/documentation/lux/abstract/comonad.lux b/stdlib/source/documentation/lux/abstract/comonad.lux
new file mode 100644
index 000000000..10f39e86d
--- /dev/null
+++ b/stdlib/source/documentation/lux/abstract/comonad.lux
@@ -0,0 +1,29 @@
+(.module:
+ [library
+ [lux
+ ["$" documentation (#+ documentation:)]
+ [data
+ [text (#+ \n)
+ ["%" format (#+ format)]]]]]
+ [\\library
+ ["." /]]
+ ["." / #_
+ ["#." cofree]])
+
+(documentation: /.CoMonad
+ (format "Co-monads are the opposite/complement to monads."
+ \n "Co-monadic structures are often infinite in size and built upon lazily-evaluated functions."))
+
+(documentation: /.be
+ "A co-monadic parallel to the 'do' macro."
+ [(let [square (function (_ n) (* n n))]
+ (be comonad
+ [inputs (iterate inc +2)]
+ (square (out inputs))))])
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ [..CoMonad
+ ..be]
+ [/cofree.documentation]))
diff --git a/stdlib/source/documentation/lux/abstract/comonad/cofree.lux b/stdlib/source/documentation/lux/abstract/comonad/cofree.lux
new file mode 100644
index 000000000..332cae864
--- /dev/null
+++ b/stdlib/source/documentation/lux/abstract/comonad/cofree.lux
@@ -0,0 +1,17 @@
+(.module:
+ [library
+ [lux
+ ["$" documentation (#+ documentation:)]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.CoFree
+ "The CoFree CoMonad.")
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ [..CoFree
+ ($.default /.functor)
+ ($.default /.comonad)]
+ []))
diff --git a/stdlib/source/documentation/lux/abstract/enum.lux b/stdlib/source/documentation/lux/abstract/enum.lux
new file mode 100644
index 000000000..2853ba8ca
--- /dev/null
+++ b/stdlib/source/documentation/lux/abstract/enum.lux
@@ -0,0 +1,20 @@
+(.module:
+ [library
+ [lux
+ ["$" documentation (#+ documentation:)]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.Enum
+ "Enumerable types, with a notion of moving forward and backwards through a type's instances.")
+
+(documentation: /.range
+ "An inclusive [from, to] range of values."
+ [(range enum from to)])
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ [..Enum
+ ..range]
+ []))
diff --git a/stdlib/source/documentation/lux/abstract/equivalence.lux b/stdlib/source/documentation/lux/abstract/equivalence.lux
new file mode 100644
index 000000000..0be66e537
--- /dev/null
+++ b/stdlib/source/documentation/lux/abstract/equivalence.lux
@@ -0,0 +1,24 @@
+(.module:
+ [library
+ [lux
+ ["$" documentation (#+ documentation:)]
+ [data
+ [text (#+ \n)
+ ["%" format (#+ format)]]]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.Equivalence
+ "Equivalence for a type's instances.")
+
+(documentation: /.rec
+ "A recursive equivalence combinator."
+ [(rec recursive_equivalence)])
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ [..Equivalence
+ ..rec
+ ($.default /.functor)]
+ []))
diff --git a/stdlib/source/documentation/lux/abstract/functor.lux b/stdlib/source/documentation/lux/abstract/functor.lux
new file mode 100644
index 000000000..1ca3b082a
--- /dev/null
+++ b/stdlib/source/documentation/lux/abstract/functor.lux
@@ -0,0 +1,33 @@
+(.module:
+ [library
+ [lux
+ ["$" documentation (#+ documentation:)]
+ [data
+ [text (#+ \n)
+ ["%" format (#+ format)]]]]]
+ [\\library
+ ["." /]]
+ ["." / #_
+ ["#." contravariant]])
+
+(documentation: /.sum
+ "Co-product (sum) composition for functors.")
+
+(documentation: /.product
+ "Product composition for functors.")
+
+(documentation: /.compose
+ "Functor composition.")
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ [($.default /.Functor)
+ ($.default /.Fix)
+ ($.default /.Or)
+ ($.default /.And)
+ ($.default /.Then)
+ ..sum
+ ..product
+ ..compose]
+ [/contravariant.documentation]))
diff --git a/stdlib/source/documentation/lux/abstract/functor/contravariant.lux b/stdlib/source/documentation/lux/abstract/functor/contravariant.lux
new file mode 100644
index 000000000..15f2332ed
--- /dev/null
+++ b/stdlib/source/documentation/lux/abstract/functor/contravariant.lux
@@ -0,0 +1,15 @@
+(.module:
+ [library
+ [lux
+ ["$" documentation (#+ documentation:)]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.Functor
+ "The contravariant functor.")
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ [..Functor]
+ []))
diff --git a/stdlib/source/documentation/lux/abstract/monad.lux b/stdlib/source/documentation/lux/abstract/monad.lux
new file mode 100644
index 000000000..7293f9a1d
--- /dev/null
+++ b/stdlib/source/documentation/lux/abstract/monad.lux
@@ -0,0 +1,54 @@
+(.module:
+ [library
+ [lux
+ ["$" documentation (#+ documentation:)]
+ [data
+ [text (#+ \n)
+ ["%" format (#+ format)]]]]]
+ [\\library
+ ["." /]]
+ ["." / #_
+ ["#." free]])
+
+(documentation: /.Monad
+ (format "A monad is a monoid in the category of endofunctors."
+ \n "What's the problem?"))
+
+(documentation: /.do
+ "Macro for easy concatenation of monadic operations."
+ [(do monad
+ [y (f1 x)
+ z (f2 z)]
+ (in (f3 z)))])
+
+(documentation: /.bind
+ "Apply a function with monadic effects to a monadic value and yield a new monadic value."
+ [(bind monad function)])
+
+(documentation: /.seq
+ "Run all the monadic values in the list and produce a list of the base values."
+ [(seq monad)])
+
+(documentation: /.map
+ "Apply a monadic function to all values in a list."
+ [(map monad function items)])
+
+(documentation: /.only
+ "Filter the values in a list with a monadic function."
+ [(only monad predicate items)])
+
+(documentation: /.fold
+ "Fold a list with a monadic function."
+ [(fold monad function initial_value items)])
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ [..Monad
+ ..do
+ ..bind
+ ..seq
+ ..map
+ ..only
+ ..fold]
+ [/free.documentation]))
diff --git a/stdlib/source/documentation/lux/abstract/monad/free.lux b/stdlib/source/documentation/lux/abstract/monad/free.lux
new file mode 100644
index 000000000..c29516a1c
--- /dev/null
+++ b/stdlib/source/documentation/lux/abstract/monad/free.lux
@@ -0,0 +1,18 @@
+(.module:
+ [library
+ [lux
+ ["$" documentation (#+ documentation:)]]]
+ [\\library
+ ["." /]])
+
+(documentation: /.Free
+ "The Free Monad.")
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ [..Free
+ ($.default /.functor)
+ ($.default /.apply)
+ ($.default /.monad)]
+ []))
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux
index 16123c586..f534a51d9 100644
--- a/stdlib/source/library/lux.lux
+++ b/stdlib/source/library/lux.lux
@@ -2496,10 +2496,11 @@
[(def:''' .private (<name> xy)
#End
(All [a b] (-> (Tuple a b) <type>))
- (let' [[x y] xy] <value>))]
+ (let' [[x y] xy]
+ <value>))]
- [first a x]
- [second b y])
+ [product\left a x]
+ [product\right b y])
(def:''' .private (type_declaration type_codes)
#End
@@ -2516,8 +2517,8 @@
(failure "Wrong syntax for variant case.")}
pair)))
pairs)]
- (in_meta [(` (Tuple (~+ (list\map second members))))
- (#Some (list\map first members))]))
+ (in_meta [(` (Tuple (~+ (list\map product\right members))))
+ (#Some (list\map product\left members))]))
(#Item type #End)
({[_ (#Tag "" member_name)]
@@ -2548,8 +2549,8 @@
(failure "Wrong syntax for variant case.")}
case)))
(list& case cases))]
- (in_meta [(` (..Variant (~+ (list\map second members))))
- (#Some (list\map first members))]))
+ (in_meta [(` (..Variant (~+ (list\map product\right members))))
+ (#Some (list\map product\left members))]))
_
(failure "Improper type-definition syntax")}
@@ -3551,7 +3552,7 @@
_
(failure "No tags available for type.")))
.let [tag_mappings (: (List [Text Code])
- (list\map (function (_ tag) [(second tag) (tag$ tag)])
+ (list\map (function (_ tag) [(product\right tag) (tag$ tag)])
tags))]
members (monad\map meta_monad
(: (-> Code (Meta [Code Code]))
@@ -5033,8 +5034,8 @@
[[_ _ column] (#Record pairs)]
(list\fold n/min column
- (list\compose (list\map (|>> first baseline_column) pairs)
- (list\map (|>> second baseline_column) pairs)))
+ (list\compose (list\map (|>> product\left baseline_column) pairs)
+ (list\map (|>> product\right baseline_column) pairs)))
))
(type: Documentation_Fragment
@@ -5086,16 +5087,11 @@
(-> Location Text Location)
[file line ("lux i64 +" column (text\size code_text))])
-(def: (delimiter_updated_location [file line column])
- (-> Location Location)
- [file line (inc column)])
-
(def: un_paired
(-> (List [Code Code]) (List Code))
(let [pair_list (: (-> [Code Code] (List Code))
- (function (_ pair)
- (let [[left right] pair]
- (list left right))))]
+ (function (_ [left right])
+ (list left right)))]
(|>> (list\map pair_list)
list\join)))
@@ -5121,9 +5117,9 @@
(let [[group_location' parts_text] (list\fold (function (_ part [last_location text_accum])
(let [[part_location part_text] (example_documentation last_location baseline part)]
[part_location (text\compose text_accum part_text)]))
- [(delimiter_updated_location group_location) ""]
+ [(update@ #column inc group_location) ""]
(<prep> parts))]
- [(delimiter_updated_location group_location')
+ [(update@ #column inc group_location')
($_ text\compose (location_padding baseline prev_location group_location)
<open>
parts_text
@@ -5136,10 +5132,6 @@
("lux io error" "@example_documentation Undefined behavior.")
))
-(def: (with_baseline baseline [file line column])
- (-> Nat Location Location)
- [file line baseline])
-
(def: (fragment_documentation fragment)
(-> Documentation_Fragment Text)
(case fragment
@@ -5152,7 +5144,7 @@
(#Documentation_Example example)
(let [baseline (baseline_column example)
[location _] example
- [_ text] (..example_documentation (with_baseline baseline location) baseline example)]
+ [_ text] (..example_documentation (set@ #.column baseline location) baseline example)]
(text\compose text __paragraph))))
(macro: .public (example tokens)
@@ -5246,8 +5238,8 @@
(case ?params
(#.Some [name bindings body])
(let [pairs (pairs bindings)
- vars (list\map first pairs)
- inits (list\map second pairs)]
+ vars (list\map product\left pairs)
+ inits (list\map product\right pairs)]
(if (every? identifier? inits)
(do meta_monad
[inits' (: (Meta (List Name))
diff --git a/stdlib/source/library/lux/abstract/apply.lux b/stdlib/source/library/lux/abstract/apply.lux
index 051809cc0..adac4d3a2 100644
--- a/stdlib/source/library/lux/abstract/apply.lux
+++ b/stdlib/source/library/lux/abstract/apply.lux
@@ -6,7 +6,6 @@
["." functor (#+ Functor)]])
(interface: .public (Apply f)
- {#.doc "Applicative functors."}
(: (Functor f)
&functor)
(: (All [a b]
@@ -14,7 +13,6 @@
apply))
(implementation: .public (compose f_monad f_apply g_apply)
- {#.doc "Applicative functor composition."}
(All [F G]
(-> (Monad F) (Apply F) (Apply G)
... TODO: Replace (All [a] (F (G a))) with (functor.Then F G)
diff --git a/stdlib/source/library/lux/abstract/codec.lux b/stdlib/source/library/lux/abstract/codec.lux
index bf6da6f54..0c3901361 100644
--- a/stdlib/source/library/lux/abstract/codec.lux
+++ b/stdlib/source/library/lux/abstract/codec.lux
@@ -8,14 +8,12 @@
["." functor]])
(interface: .public (Codec m a)
- {#.doc "A way to move back-and-forth between a type and an alternative representation for it."}
(: (-> a m)
encode)
(: (-> m (Try a))
decode))
(implementation: .public (compose cb_codec ba_codec)
- {#.doc "Codec composition."}
(All [a b c]
(-> (Codec c b) (Codec b a)
(Codec c a)))
diff --git a/stdlib/source/library/lux/abstract/comonad.lux b/stdlib/source/library/lux/abstract/comonad.lux
index 6de44d5f2..8803eed86 100644
--- a/stdlib/source/library/lux/abstract/comonad.lux
+++ b/stdlib/source/library/lux/abstract/comonad.lux
@@ -13,8 +13,6 @@
[functor (#+ Functor)]])
(interface: .public (CoMonad w)
- {#.doc (example "CoMonads are the opposite/complement to monads."
- "CoMonadic structures are often infinite in size and built upon lazily-evaluated functions.")}
(: (Functor w)
&functor)
(: (All [a]
@@ -25,11 +23,6 @@
split))
(macro: .public (be tokens state)
- {#.doc (example "A co-monadic parallel to the 'do' macro."
- (let [square (function (_ n) (* n n))]
- (be comonad
- [inputs (iterate inc +2)]
- (square (head inputs)))))}
(case (: (Maybe [(Maybe Text) Code (List Code) Code])
(case tokens
(^ (list [_ (#.Record (list [[_ (#.Identifier ["" name])] comonad]))] [_ (#.Tuple bindings)] body))
diff --git a/stdlib/source/library/lux/abstract/comonad/cofree.lux b/stdlib/source/library/lux/abstract/comonad/cofree.lux
index 1431ee3cc..c5d61dbb4 100644
--- a/stdlib/source/library/lux/abstract/comonad/cofree.lux
+++ b/stdlib/source/library/lux/abstract/comonad/cofree.lux
@@ -6,7 +6,6 @@
[functor (#+ Functor)]]])
(type: .public (CoFree F a)
- {#.doc "The CoFree CoMonad."}
[a (F (CoFree F a))])
(implementation: .public (functor dsl)
diff --git a/stdlib/source/library/lux/abstract/enum.lux b/stdlib/source/library/lux/abstract/enum.lux
index 0cb26b8a4..bb82c2936 100644
--- a/stdlib/source/library/lux/abstract/enum.lux
+++ b/stdlib/source/library/lux/abstract/enum.lux
@@ -5,13 +5,11 @@
["." order (#+ Order)]])
(interface: .public (Enum e)
- {#.doc "Enumerable types, with a notion of moving forward and backwards through a type's instances."}
(: (Order e) &order)
(: (-> e e) succ)
(: (-> e e) pred))
(def: .public (range enum from to)
- {#.doc "An inclusive [from, to] range of values."}
(All [a] (-> (Enum a) a a (List a)))
(let [(^open "/\.") enum]
(loop [end to
diff --git a/stdlib/source/library/lux/abstract/equivalence.lux b/stdlib/source/library/lux/abstract/equivalence.lux
index ad3e90d00..43598f09e 100644
--- a/stdlib/source/library/lux/abstract/equivalence.lux
+++ b/stdlib/source/library/lux/abstract/equivalence.lux
@@ -6,12 +6,10 @@
["." contravariant]]])
(interface: .public (Equivalence a)
- {#.doc "Equivalence for a type's instances."}
(: (-> a a Bit)
=))
(def: .public (rec sub)
- {#.doc (example "A recursive equivalence combinator.")}
(All [a] (-> (-> (Equivalence a) (Equivalence a)) (Equivalence a)))
(implementation
(def: (= left right)
diff --git a/stdlib/source/library/lux/abstract/functor.lux b/stdlib/source/library/lux/abstract/functor.lux
index 3d6e38883..d06f82ed7 100644
--- a/stdlib/source/library/lux/abstract/functor.lux
+++ b/stdlib/source/library/lux/abstract/functor.lux
@@ -15,7 +15,6 @@
(All [a] (.Or (f a) (g a))))
(def: .public (sum (^open "f\.") (^open "g\."))
- {#.doc (example "Co-product (sum) composition for functors.")}
(All [F G] (-> (Functor F) (Functor G) (Functor (..Or F G))))
(implementation
(def: (map f fa|ga)
@@ -30,7 +29,6 @@
(All [a] (.And (f a) (g a))))
(def: .public (product (^open "f\.") (^open "g\."))
- {#.doc (example "Product composition for functors.")}
(All [F G] (-> (Functor F) (Functor G) (Functor (..And F G))))
(implementation
(def: (map f [fa ga])
@@ -41,7 +39,6 @@
(All [a] (f (g a))))
(def: .public (compose (^open "f\.") (^open "g\."))
- {#.doc "Functor composition."}
(All [F G] (-> (Functor F) (Functor G) (Functor (..Then F G))))
(implementation
(def: (map f fga)
diff --git a/stdlib/source/library/lux/abstract/monad.lux b/stdlib/source/library/lux/abstract/monad.lux
index 31002b5be..6ba4f74aa 100644
--- a/stdlib/source/library/lux/abstract/monad.lux
+++ b/stdlib/source/library/lux/abstract/monad.lux
@@ -44,9 +44,6 @@
#.End))
(interface: .public (Monad m)
- {#.doc (example "A monad is a monoid in the category of endofunctors."
- "What's the problem?")}
-
(: (Functor m)
&functor)
(: (All [a]
@@ -57,11 +54,6 @@
join))
(macro: .public (do tokens state)
- {#.doc (example "Macro for easy concatenation of monadic operations."
- (do monad
- [y (f1 x)
- z (f2 z)]
- (in (f3 z))))}
(case (: (Maybe [(Maybe Text) Code (List Code) Code])
(case tokens
(^ (list [_ (#.Record (list [[_ (#.Identifier ["" name])] monad]))] [_ (#.Tuple bindings)] body))
@@ -114,7 +106,6 @@
(#.Left "Wrong syntax for 'do'")))
(def: .public (bind monad f)
- {#.doc (example "Apply a function with monadic effects to a monadic value and yield a new monadic value.")}
(All [! a b]
(-> (Monad !) (-> a (! b))
(-> (! a) (! b))))
@@ -122,7 +113,6 @@
(\ monad join)))
(def: .public (seq monad)
- {#.doc "Run all the monadic values in the list and produce a list of the base values."}
(All [M a]
(-> (Monad M) (List (M a))
(M (List a))))
@@ -139,7 +129,6 @@
!\join)))))
(def: .public (map monad f)
- {#.doc "Apply a monadic function to all values in a list."}
(All [M a b]
(-> (Monad M) (-> a (M b)) (List a)
(M (List b))))
@@ -156,7 +145,6 @@
!\join)))))
(def: .public (only monad f)
- {#.doc "Filter the values in a list with a monadic function."}
(All [! a b]
(-> (Monad !) (-> a (! Bit)) (List a)
(! (List a))))
@@ -177,7 +165,6 @@
!\join)))))
(def: .public (fold monad f init xs)
- {#.doc "Fold a list with a monadic function."}
(All [M a b]
(-> (Monad M) (-> b a (M a)) a (List b)
(M a)))
diff --git a/stdlib/source/library/lux/abstract/monad/free.lux b/stdlib/source/library/lux/abstract/monad/free.lux
index d954c5581..67aa94755 100644
--- a/stdlib/source/library/lux/abstract/monad/free.lux
+++ b/stdlib/source/library/lux/abstract/monad/free.lux
@@ -7,7 +7,6 @@
[monad (#+ Monad)]])
(type: .public (Free F a)
- {#.doc "The Free Monad."}
(#Pure a)
(#Effect (F (Free F a))))
diff --git a/stdlib/source/library/lux/control/concurrency/semaphore.lux b/stdlib/source/library/lux/control/concurrency/semaphore.lux
index 789c0a28f..f7f4f5f50 100644
--- a/stdlib/source/library/lux/control/concurrency/semaphore.lux
+++ b/stdlib/source/library/lux/control/concurrency/semaphore.lux
@@ -58,7 +58,7 @@
[[_ state'] (atom.update! (|>> (update@ #open_positions dec)
(if> [<had_open_position?>]
[]
- [(update@ #waiting_list (queue.push sink))]))
+ [(update@ #waiting_list (queue.end sink))]))
semaphore)]
(with_expansions [<go_ahead> (sink [])
<get_in_line> (in false)]
@@ -83,12 +83,12 @@
state
(|> state
(update@ #open_positions inc)
- (update@ #waiting_list queue.pop))))
+ (update@ #waiting_list queue.next))))
semaphore)]
(if (same? pre post)
(in (exception.except ..semaphore_is_maxed_out [(get@ #max_positions pre)]))
(do !
- [_ (case (queue.peek (get@ #waiting_list pre))
+ [_ (case (queue.front (get@ #waiting_list pre))
#.None
(in true)
diff --git a/stdlib/source/library/lux/control/concurrency/stm.lux b/stdlib/source/library/lux/control/concurrency/stm.lux
index 7e57abc62..f3bdbcbb6 100644
--- a/stdlib/source/library/lux/control/concurrency/stm.lux
+++ b/stdlib/source/library/lux/control/concurrency/stm.lux
@@ -37,7 +37,7 @@
(All [a] (-> (Var a) a))
(|>> :representation atom.read! io.run! product.left))
- (def: (un_follow sink var)
+ (def: (un_follow! sink var)
(All [a] (-> (Sink a) (Var a) (IO Any)))
(do io.monad
[_ (atom.update! (function (_ [value observers])
@@ -61,12 +61,12 @@
(in [])
(#try.Failure _)
- (un_follow sink var))))
+ (un_follow! sink var))))
observers)]
(in []))
(write! new_value var))))
- (def: .public (follow target)
+ (def: .public (follow! target)
{#.doc "Creates a channel that will receive all changes to the value of the given var."}
(All [a] (-> (Var a) (IO [(Channel a) (Sink a)])))
(do io.monad
@@ -260,7 +260,7 @@
(in [])))
)))
-(def: .public (commit stm_proc)
+(def: .public (commit! stm_proc)
{#.doc (example "Commits a transaction and returns its result (asynchronously)."
"Note that a transaction may be re-run an indeterminate number of times if other transactions involving the same variables successfully commit first."
"For this reason, it's important to note that transactions must be free from side-effects, such as I/O.")}
diff --git a/stdlib/source/library/lux/control/parser/text.lux b/stdlib/source/library/lux/control/parser/text.lux
index 8ca2af321..ffe6e6f27 100644
--- a/stdlib/source/library/lux/control/parser/text.lux
+++ b/stdlib/source/library/lux/control/parser/text.lux
@@ -39,7 +39,7 @@
(def: (remaining' offset tape)
(-> Offset Text Text)
- (|> tape (/.split offset) maybe.assume product.right))
+ (|> tape (/.split_at offset) maybe.assume product.right))
(exception: .public (unconsumed_input {offset Offset} {tape Text})
(exception.report
@@ -152,7 +152,7 @@
(#try.Success [input []])
(exception.except ..unconsumed_input input))))
-(def: .public peek
+(def: .public next
{#.doc "Yields the next character (without consuming it from the input)."}
(Parser Text)
(function (_ (^@ input [offset tape]))
diff --git a/stdlib/source/library/lux/control/parser/type.lux b/stdlib/source/library/lux/control/parser/type.lux
index 3dfea1a30..619526cdb 100644
--- a/stdlib/source/library/lux/control/parser/type.lux
+++ b/stdlib/source/library/lux/control/parser/type.lux
@@ -109,7 +109,7 @@
(#try.Success [[_ remaining] output])
(#try.Success [[env remaining] output]))))
-(def: .public peek
+(def: .public next
{#.doc (example "Inspect a type in the input stream without consuming it.")}
(Parser Type)
(.function (_ [env inputs])
diff --git a/stdlib/source/library/lux/control/region.lux b/stdlib/source/library/lux/control/region.lux
index d84f0e027..ba3962400 100644
--- a/stdlib/source/library/lux/control/region.lux
+++ b/stdlib/source/library/lux/control/region.lux
@@ -64,7 +64,7 @@
(monad.map ! (function (_ cleaner) (cleaner [])))
(\ ! map (list\fold clean output)))))
-(def: .public (acquire monad cleaner value)
+(def: .public (acquire! monad cleaner value)
{#.doc (example "Acquire a resource while pairing it a function that knows how to reclaim it.")}
(All [! a] (-> (Monad !) (-> a (! (Try Any))) a
(All [r] (Region r ! a))))
diff --git a/stdlib/source/library/lux/control/thread.lux b/stdlib/source/library/lux/control/thread.lux
index c0a8c5955..266c12afc 100644
--- a/stdlib/source/library/lux/control/thread.lux
+++ b/stdlib/source/library/lux/control/thread.lux
@@ -31,7 +31,7 @@
(array.write! 0 init)
:abstraction)))
- (def: .public (read box)
+ (def: .public (read! box)
{#.doc (example "Reads the current value in the box.")}
(All [! a] (-> (Box ! a) (Thread ! a)))
(function (_ !)
@@ -53,7 +53,7 @@
@.php ("php array read" 0 (:representation box))
@.scheme ("scheme array read" 0 (:representation box))})))
- (def: .public (write value box)
+ (def: .public (write! value box)
{#.doc (example "Mutates the value in the box.")}
(All [a] (-> a (All [!] (-> (Box ! a) (Thread ! Any)))))
(function (_ !)
@@ -104,10 +104,10 @@
(function (_ !)
((ffa !) !))))
-(def: .public (update f box)
+(def: .public (update! f box)
{#.doc (example "Update a box's value by applying a function to it.")}
(All [a !] (-> (-> a a) (Box ! a) (Thread ! a)))
(do ..monad
- [old (read box)
- _ (write (f old) box)]
+ [old (read! box)
+ _ (write! (f old) box)]
(in old)))
diff --git a/stdlib/source/library/lux/data/binary.lux b/stdlib/source/library/lux/data/binary.lux
index b1290557f..cff9714e2 100644
--- a/stdlib/source/library/lux/data/binary.lux
+++ b/stdlib/source/library/lux/data/binary.lux
@@ -143,7 +143,7 @@
... Default
(|> binary
- (array.read index)
+ (array.read! index)
(maybe.else (: (I64 Any) 0))
(:as I64)))])
@@ -358,7 +358,7 @@
... Default
(..copy length offset binary 0 (..empty length)))))))
-(def: .public (drop bytes binary)
+(def: .public (after bytes binary)
{#.doc (example "Yields a binary BLOB with at most the specified number of bytes removed.")}
(-> Nat Binary Binary)
(case bytes
diff --git a/stdlib/source/library/lux/data/collection/array.lux b/stdlib/source/library/lux/data/collection/array.lux
index a141fad68..5d306f773 100644
--- a/stdlib/source/library/lux/data/collection/array.lux
+++ b/stdlib/source/library/lux/data/collection/array.lux
@@ -77,13 +77,13 @@
@.php ("php array length" array)
@.scheme ("scheme array length" array)}))
- (template: (!read <read> <null?>)
- [(let [output (<read> index array)]
+ (template: (!read! <read!> <null?>)
+ [(let [output (<read!> index array)]
(if (<null?> output)
#.None
(#.Some output)))])
- (def: .public (read index array)
+ (def: .public (read! index array)
(All [a]
(-> Nat (Array a) (Maybe a)))
(if (n.< (size array) index)
@@ -101,12 +101,12 @@
#.None
(#.Some (:expected value))))
- @.js (!read "js array read" "js object undefined?")
- @.python (!read "python array read" "python object none?")
- @.lua (!read "lua array read" "lua object nil?")
- @.ruby (!read "ruby array read" "ruby object nil?")
- @.php (!read "php array read" "php object null?")
- @.scheme (!read "scheme array read" "scheme object nil?")})
+ @.js (!read! "js array read" "js object undefined?")
+ @.python (!read! "python array read" "python object none?")
+ @.lua (!read! "lua array read" "lua object nil?")
+ @.ruby (!read! "ruby array read" "ruby object nil?")
+ @.php (!read! "php array read" "php object null?")
+ @.scheme (!read! "scheme array read" "scheme object nil?")})
#.None))
(def: .public (write! index value array)
@@ -152,7 +152,7 @@
(def: .public (contains? index array)
(All [a]
(-> Nat (Array a) Bit))
- (case (..read index array)
+ (case (..read! index array)
(#.Some _)
true
@@ -163,7 +163,7 @@
{#.doc (.example "Mutate the array by updating the value at the specified index.")}
(All [a]
(-> Nat (-> a a) (Array a) (Array a)))
- (case (read index array)
+ (case (read! index array)
#.None
array
@@ -176,7 +176,7 @@
(All [a]
(-> Nat a (-> a a) (Array a) (Array a)))
(write! index
- (|> array (read index) (maybe.else default) transform)
+ (|> array (read! index) (maybe.else default) transform)
array))
(def: .public (copy! length src_start src_array dest_start dest_array)
@@ -187,7 +187,7 @@
(if (n.= 0 length)
dest_array
(list\fold (function (_ offset target)
- (case (read (n.+ offset src_start) src_array)
+ (case (read! (n.+ offset src_start) src_array)
#.None
target
@@ -200,7 +200,7 @@
{#.doc "Finds out how many cells in an array are occupied."}
(All [a] (-> (Array a) Nat))
(list\fold (function (_ idx count)
- (case (read idx array)
+ (case (read! idx array)
#.None
count
@@ -219,7 +219,7 @@
(All [a]
(-> (Predicate a) (Array a) (Array a)))
(list\fold (function (_ idx xs')
- (case (read idx xs)
+ (case (read! idx xs)
#.None
xs'
@@ -237,7 +237,7 @@
(let [arr_size (size xs)]
(loop [idx 0]
(if (n.< arr_size idx)
- (case (read idx xs)
+ (case (read! idx xs)
#.None
(recur (inc idx))
@@ -254,7 +254,7 @@
(let [arr_size (size xs)]
(loop [idx 0]
(if (n.< arr_size idx)
- (case (read idx xs)
+ (case (read! idx xs)
#.None
(recur (inc idx))
@@ -269,7 +269,7 @@
(All [a] (-> (Array a) (Array a)))
(let [arr_size (size xs)]
(list\fold (function (_ idx ys)
- (case (read idx xs)
+ (case (read! idx xs)
#.None
ys
@@ -300,7 +300,7 @@
_
(recur (dec idx)
- (case (read idx array)
+ (case (read! idx array)
(#.Some head)
(#.Item head output)
@@ -318,7 +318,7 @@
_
(recur (dec idx)
- (#.Item (maybe.else default (read idx array))
+ (#.Item (maybe.else default (read! idx array))
output)))))
(implementation: .public (equivalence (^open ",\."))
@@ -330,7 +330,7 @@
(and (n.= sxy sxs)
(list\fold (function (_ idx prev)
(and prev
- (case [(read idx xs) (read idx ys)]
+ (case [(read! idx xs) (read! idx ys)]
[#.None #.None]
true
@@ -362,7 +362,7 @@
(if (n.= 0 arr_size)
(empty arr_size)
(list\fold (function (_ idx mb)
- (case (read idx ma)
+ (case (read! idx ma)
#.None
mb
@@ -380,7 +380,7 @@
(loop [so_far init
idx 0]
(if (n.< arr_size idx)
- (case (read idx xs)
+ (case (read! idx xs)
#.None
(recur so_far (inc idx))
@@ -396,7 +396,7 @@
(let [size (..size array)]
(loop [idx 0]
(if (n.< size idx)
- (case (..read idx array)
+ (case (..read! idx array)
(#.Some value)
(<op> (predicate value)
(recur (inc idx)))
diff --git a/stdlib/source/library/lux/data/collection/bits.lux b/stdlib/source/library/lux/data/collection/bits.lux
index ef10e0f6d..e5e85e361 100644
--- a/stdlib/source/library/lux/data/collection/bits.lux
+++ b/stdlib/source/library/lux/data/collection/bits.lux
@@ -52,14 +52,14 @@
(-> Nat Bits Bit)
(let [[chunk_index bit_index] (n./% chunk_size index)]
(.and (n.< (array.size bits) chunk_index)
- (|> (array.read chunk_index bits)
+ (|> (array.read! chunk_index bits)
(maybe.else empty_chunk)
(i64.one? bit_index)))))
(def: (chunk idx bits)
(-> Nat Bits Chunk)
(if (n.< (array.size bits) idx)
- (|> bits (array.read idx) (maybe.else empty_chunk))
+ (|> bits (array.read! idx) (maybe.else empty_chunk))
empty_chunk))
(template [<name> <op>]
diff --git a/stdlib/source/library/lux/data/collection/dictionary.lux b/stdlib/source/library/lux/data/collection/dictionary.lux
index 642b19b57..fb7aaaa83 100644
--- a/stdlib/source/library/lux/data/collection/dictionary.lux
+++ b/stdlib/source/library/lux/data/collection/dictionary.lux
@@ -130,7 +130,7 @@
... Expands a copy of the array, to have 1 extra slot, which is used
... for storing the value.
-(def: (insert! idx value old_array)
+(def: (array\has idx value old_array)
(All [a] (-> Index a (Array a) (Array a)))
(let [old_size (array.size old_array)]
(|> (array.empty (inc old_size))
@@ -139,17 +139,17 @@
(array.copy! (n.- idx old_size) idx old_array (inc idx)))))
... Creates a copy of an array with an index set to a particular value.
-(def: (revised! idx value array)
+(def: (array\revised idx value array)
(All [a] (-> Index a (Array a) (Array a)))
(|> array array.clone (array.write! idx value)))
... Creates a clone of the array, with an empty position at index.
-(def: (vacant! idx array)
+(def: (array\lacks' idx array)
(All [a] (-> Index (Array a) (Array a)))
(|> array array.clone (array.delete! idx)))
... Shrinks a copy of the array by removing the space at index.
-(def: (lacks! idx array)
+(def: (array\lacks idx array)
(All [a] (-> Index (Array a) (Array a)))
(let [new_size (dec (array.size array))]
(|> (array.empty new_size)
@@ -236,7 +236,7 @@
(All [k v] (-> Index (Hierarchy k v) [Bit_Map (Base k v)]))
(product.right (list\fold (function (_ idx [insertion_idx node])
(let [[bitmap base] node]
- (case (array.read idx h_array)
+ (case (array.read! idx h_array)
#.None [insertion_idx node]
(#.Some sub_node) (if (n.= except_idx idx)
[insertion_idx node]
@@ -254,7 +254,7 @@
(List Index)
(list.indices hierarchy_nodes_size))
-(def: (promotion has' key_hash level bitmap base)
+(def: (promotion node\has key_hash level bitmap base)
(All [k v]
(-> (-> Level Hash_Code k v (Hash k) (Node k v) (Node k v))
(Hash k) Level
@@ -264,13 +264,13 @@
(if (with_bit_position? (to_bit_position hierarchy_idx)
bitmap)
[(inc base_idx)
- (case (array.read base_idx base)
+ (case (array.read! base_idx base)
(#.Some (#.Left sub_node))
(array.write! hierarchy_idx sub_node h_array)
(#.Some (#.Right [key' val']))
(array.write! hierarchy_idx
- (has' (level_up level) (\ key_hash hash key') key' val' key_hash empty_node)
+ (node\has (level_up level) (\ key_hash hash key') key' val' key_hash empty_node)
h_array)
#.None
@@ -292,22 +292,22 @@
_
#0)))
-(def: (has' level hash key val key_hash node)
+(def: (node\has level hash key val key_hash node)
(All [k v] (-> Level Hash_Code k v (Hash k) (Node k v) (Node k v)))
(case node
... For #Hierarchy nodes, check whether one can add the element to
... a sub-node. If impossible, introduce a new singleton sub-node.
(#Hierarchy _size hierarchy)
(let [idx (level_index level hash)
- [_size' sub_node] (case (array.read idx hierarchy)
+ [_size' sub_node] (case (array.read! idx hierarchy)
(#.Some sub_node)
[_size sub_node]
_
[(inc _size) empty_node])]
(#Hierarchy _size'
- (revised! idx (has' (level_up level) hash key val key_hash sub_node)
- hierarchy)))
+ (array\revised idx (node\has (level_up level) hash key val key_hash sub_node)
+ hierarchy)))
... For #Base nodes, check if the corresponding Bit_Position has
... already been used.
@@ -316,38 +316,38 @@
(if (with_bit_position? bit bitmap)
... If so...
(let [idx (base_index bit bitmap)]
- (case (array.read idx base)
+ (case (array.read! idx base)
... If it's being used by a node, add the KV to it.
(#.Some (#.Left sub_node))
- (let [sub_node' (has' (level_up level) hash key val key_hash sub_node)]
- (#Base bitmap (revised! idx (#.Left sub_node') base)))
+ (let [sub_node' (node\has (level_up level) hash key val key_hash sub_node)]
+ (#Base bitmap (array\revised idx (#.Left sub_node') base)))
... Otherwise, if it's being used by a KV, compare the keys.
(#.Some (#.Right key' val'))
(if (\ key_hash = key key')
... If the same key is found, replace the value.
- (#Base bitmap (revised! idx (#.Right key val) base))
+ (#Base bitmap (array\revised idx (#.Right key val) base))
... Otherwise, compare the hashes of the keys.
- (#Base bitmap (revised! idx
- (#.Left (let [hash' (\ key_hash hash key')]
- (if (n.= hash hash')
- ... If the hashes are
- ... the same, a new
- ... #Collisions node
- ... is added.
- (#Collisions hash (|> (array.empty 2)
- (array.write! 0 [key' val'])
- (array.write! 1 [key val])))
- ... Otherwise, one can
- ... just keep using
- ... #Base nodes, so
- ... add both KV-pairs
- ... to the empty one.
- (let [next_level (level_up level)]
- (|> empty_node
- (has' next_level hash' key' val' key_hash)
- (has' next_level hash key val key_hash))))))
- base)))
+ (#Base bitmap (array\revised idx
+ (#.Left (let [hash' (\ key_hash hash key')]
+ (if (n.= hash hash')
+ ... If the hashes are
+ ... the same, a new
+ ... #Collisions node
+ ... is added.
+ (#Collisions hash (|> (array.empty 2)
+ (array.write! 0 [key' val'])
+ (array.write! 1 [key val])))
+ ... Otherwise, one can
+ ... just keep using
+ ... #Base nodes, so
+ ... add both KV-pairs
+ ... to the empty one.
+ (let [next_level (level_up level)]
+ (|> empty_node
+ (node\has next_level hash' key' val' key_hash)
+ (node\has next_level hash key val key_hash))))))
+ base)))
#.None
(undefined)))
@@ -359,13 +359,13 @@
... KV-pair as a singleton node to it.
(#Hierarchy (inc base_count)
(|> base
- (promotion has' key_hash level bitmap)
+ (promotion node\has key_hash level bitmap)
(array.write! (level_index level hash)
- (has' (level_up level) hash key val key_hash empty_node))))
+ (node\has (level_up level) hash key val key_hash empty_node))))
... Otherwise, just resize the #Base node to accommodate the
... new KV-pair.
(#Base (with_bit_position bit bitmap)
- (insert! (base_index bit bitmap) (#.Right [key val]) base))))))
+ (array\has (base_index bit bitmap) (#.Right [key val]) base))))))
... For #Collisions nodes, compare the hashes.
(#Collisions _hash _colls)
@@ -376,17 +376,17 @@
... If the key was already present in the collisions-list, its
... value gets updated.
(#.Some coll_idx)
- (#Collisions _hash (revised! coll_idx [key val] _colls))
+ (#Collisions _hash (array\revised coll_idx [key val] _colls))
... Otherwise, the KV-pair is added to the collisions-list.
#.None
- (#Collisions _hash (insert! (array.size _colls) [key val] _colls)))
+ (#Collisions _hash (array\has (array.size _colls) [key val] _colls)))
... If the hashes are not equal, create a new #Base node that
... contains the old #Collisions node, plus the new KV-pair.
(|> (#Base (level_bit_position level _hash)
(|> (array.empty 1)
(array.write! 0 (#.Left node))))
- (has' level hash key val key_hash)))
+ (node\has level hash key val key_hash)))
))
(def: (lacks' level hash key key_hash node)
@@ -396,7 +396,7 @@
... the Hash-Code.
(#Hierarchy h_size h_array)
(let [idx (level_index level hash)]
- (case (array.read idx h_array)
+ (case (array.read! idx h_array)
... If not, there's nothing to remove.
#.None
node
@@ -415,17 +415,17 @@
... If so, perform it.
(#Base (demotion idx [h_size h_array]))
... Otherwise, just clear the space.
- (#Hierarchy (dec h_size) (vacant! idx h_array)))
+ (#Hierarchy (dec h_size) (array\lacks' idx h_array)))
... But if the sub_removal yielded a non_empty node, then
... just update the hiearchy branch.
- (#Hierarchy h_size (revised! idx sub_node' h_array)))))))
+ (#Hierarchy h_size (array\revised idx sub_node' h_array)))))))
... For #Base nodes, check whether the Bit_Position is set.
(#Base bitmap base)
(let [bit (level_bit_position level hash)]
(if (with_bit_position? bit bitmap)
(let [idx (base_index bit bitmap)]
- (case (array.read idx base)
+ (case (array.read! idx base)
... If set, check if it's a sub_node, and remove the KV
... from it.
(#.Some (#.Left sub_node))
@@ -443,11 +443,11 @@
... But if not, then just unset the position and
... remove the node.
(#Base (without_bit_position bit bitmap)
- (lacks! idx base)))
+ (array\lacks idx base)))
... But, if it did not come out empty, then the
... position is kept, and the node gets updated.
(#Base bitmap
- (revised! idx (#.Left sub_node') base)))))
+ (array\revised idx (#.Left sub_node') base)))))
... If, however, there was a KV-pair instead of a sub-node.
(#.Some (#.Right [key' val']))
@@ -455,7 +455,7 @@
(if (\ key_hash = key key')
... If so, remove the KV-pair and unset the Bit_Position.
(#Base (without_bit_position bit bitmap)
- (lacks! idx base))
+ (array\lacks idx base))
... Otherwise, there's nothing to remove.
node)
@@ -478,7 +478,7 @@
... an empty node.
empty_node
... Otherwise, just shrink the array by removing the KV-pair.
- (#Collisions _hash (lacks! idx _colls))))
+ (#Collisions _hash (array\lacks idx _colls))))
))
(def: (value' level hash key key_hash node)
@@ -486,7 +486,7 @@
(case node
... For #Hierarchy nodes, just look-up the key on its children.
(#Hierarchy _size hierarchy)
- (case (array.read (level_index level hash) hierarchy)
+ (case (array.read! (level_index level hash) hierarchy)
#.None #.None
(#.Some sub_node) (value' (level_up level) hash key key_hash sub_node))
@@ -494,7 +494,7 @@
(#Base bitmap base)
(let [bit (level_bit_position level hash)]
(if (with_bit_position? bit bitmap)
- (case (array.read (base_index bit bitmap) base)
+ (case (array.read! (base_index bit bitmap) base)
(#.Some (#.Left sub_node))
(value' (level_up level) hash key key_hash sub_node)
@@ -573,7 +573,7 @@
(def: .public (has key val dict)
(All [k v] (-> k v (Dictionary k v) (Dictionary k v)))
(let [[key_hash node] dict]
- [key_hash (has' root_level (\ key_hash hash key) key val key_hash node)]))
+ [key_hash (node\has root_level (\ key_hash hash key) key val key_hash node)]))
(def: .public (lacks key dict)
(All [k v] (-> k (Dictionary k v) (Dictionary k v)))
@@ -593,7 +593,7 @@
(exception: .public key_already_exists)
-(def: .public (try_put key val dict)
+(def: .public (has' key val dict)
{#.doc "Only puts the KV-pair if the key is not already present."}
(All [k v] (-> k v (Dictionary k v) (Try (Dictionary k v))))
(case (value key dict)
@@ -610,7 +610,7 @@
(#.Some val)
(has key (f val) dict)))
-(def: .public (upsert key default f dict)
+(def: .public (revised' key default f dict)
{#.doc (example "Updates the value at the key; if it exists."
"Otherwise, puts a value by applying the function to a default.")}
(All [k v] (-> k v (-> v v) (Dictionary k v) (Dictionary k v)))
@@ -672,7 +672,7 @@
dict1
(entries dict2)))
-(def: .public (re_bind from_key to_key dict)
+(def: .public (re_bound from_key to_key dict)
{#.doc (example "If there is a value under 'from_key', remove 'from_key' and store the value under 'to_key'.")}
(All [k v] (-> k k (Dictionary k v) (Dictionary k v)))
(case (value from_key dict)
diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux
index ff5a1fe12..7298a5039 100644
--- a/stdlib/source/library/lux/data/collection/list.lux
+++ b/stdlib/source/library/lux/data/collection/list.lux
@@ -100,8 +100,8 @@
<then>)
<else>))]
- [take (#.Item x (take (dec n) xs')) #.End]
- [drop (drop (dec n) xs') xs]
+ [first (#.Item x (first (dec n) xs')) #.End]
+ [after (after (dec n) xs') xs]
)
(template [<name> <then> <else>]
@@ -121,7 +121,7 @@
[until (until predicate xs') xs]
)
-(def: .public (split n xs)
+(def: .public (split_at n xs)
(All [a]
(-> Nat (List a) [(List a) (List a)]))
(if (n.> 0 n)
@@ -130,7 +130,7 @@
[#.End #.End]
(#.Item x xs')
- (let [[tail rest] (split (dec n) xs')]
+ (let [[tail rest] (split_at (dec n) xs')]
[(#.Item x tail) rest]))
[#.End xs]))
@@ -161,7 +161,7 @@
#.End
_
- (let [[pre post] (split size list)]
+ (let [[pre post] (split_at size list)]
(#.Item pre (sub size post)))))
(def: .public (repeated n x)
diff --git a/stdlib/source/library/lux/data/collection/queue.lux b/stdlib/source/library/lux/data/collection/queue.lux
index 04fd1c6b5..3e017d382 100644
--- a/stdlib/source/library/lux/data/collection/queue.lux
+++ b/stdlib/source/library/lux/data/collection/queue.lux
@@ -31,7 +31,7 @@
(let [(^slots [#front #rear]) queue]
(list\compose front (list.reversed rear))))
-(def: .public peek
+(def: .public front
{#.doc (example "Yields the first value in the queue, if any.")}
(All [a] (-> (Queue a) (Maybe a)))
(|>> (get@ #front) list.head))
@@ -52,7 +52,7 @@
(or (list.member? equivalence front member)
(list.member? equivalence rear member))))
-(def: .public (pop queue)
+(def: .public (next queue)
(All [a] (-> (Queue a) (Queue a)))
(case (get@ #front queue)
... Empty...
@@ -70,7 +70,7 @@
(|> queue
(set@ #front front'))))
-(def: .public (push val queue)
+(def: .public (end val queue)
(All [a] (-> a (Queue a) (Queue a)))
(case (get@ #front queue)
#.End
diff --git a/stdlib/source/library/lux/data/collection/queue/priority.lux b/stdlib/source/library/lux/data/collection/queue/priority.lux
index 138b86876..88da217c3 100644
--- a/stdlib/source/library/lux/data/collection/queue/priority.lux
+++ b/stdlib/source/library/lux/data/collection/queue/priority.lux
@@ -46,7 +46,7 @@
Queue
(:abstraction #.None))
- (def: .public (peek queue)
+ (def: .public (front queue)
(All [a] (-> (Queue a) (Maybe a)))
(do maybe.monad
[tree (:representation queue)]
@@ -84,7 +84,7 @@
(or (recur left)
(recur right))))))
- (def: .public (pop queue)
+ (def: .public (next queue)
(All [a] (-> (Queue a) (Queue a)))
(:abstraction
(do maybe.monad
@@ -112,7 +112,7 @@
(#.Some =right)
(#.Some (\ ..builder branch left =right)))))))))
- (def: .public (push priority value queue)
+ (def: .public (end priority value queue)
(All [a] (-> Priority a (Queue a) (Queue a)))
(let [addition (\ ..builder leaf priority value)]
(:abstraction
diff --git a/stdlib/source/library/lux/data/collection/row.lux b/stdlib/source/library/lux/data/collection/row.lux
index c36a5377e..230de34a1 100644
--- a/stdlib/source/library/lux/data/collection/row.lux
+++ b/stdlib/source/library/lux/data/collection/row.lux
@@ -105,7 +105,7 @@
... Just add the tail to it
(#Base tail)
... Otherwise, check whether there's a vacant spot
- (case (array.read sub_idx parent)
+ (case (array.read! sub_idx parent)
... If so, set the path to the tail
#.None
(..path (level_down level) tail)
@@ -129,7 +129,7 @@
(def: (put' level idx val hierarchy)
(All [a] (-> Level Index a (Hierarchy a) (Hierarchy a)))
(let [sub_idx (branch_idx (i64.right_shifted level idx))]
- (case (array.read sub_idx hierarchy)
+ (case (array.read! sub_idx hierarchy)
(#.Some (#Hierarchy sub_node))
(|> (array.clone hierarchy)
(array.write! sub_idx (#Hierarchy (put' (level_down level) idx val sub_node))))
@@ -152,7 +152,7 @@
(n.> branching_exponent level)
(do maybe.monad
- [base|hierarchy (array.read sub_idx hierarchy)
+ [base|hierarchy (array.read! sub_idx hierarchy)
sub (case base|hierarchy
(#Hierarchy sub)
(without_tail size (level_down level) sub)
@@ -254,7 +254,7 @@
(loop [level (get@ #level row)
hierarchy (get@ #root row)]
(case [(n.> branching_exponent level)
- (array.read (branch_idx (i64.right_shifted level idx)) hierarchy)]
+ (array.read! (branch_idx (i64.right_shifted level idx)) hierarchy)]
[#1 (#.Some (#Hierarchy sub))]
(recur (level_down level) sub)
@@ -272,7 +272,7 @@
(All [a] (-> Nat (Row a) (Try a)))
(do try.monad
[base (base_for idx row)]
- (case (array.read (branch_idx idx) base)
+ (case (array.read! (branch_idx idx) base)
(#.Some value)
(#try.Success value)
@@ -324,7 +324,7 @@
root (maybe.else (empty_hierarchy [])
(without_tail row_size init_level (get@ #root row)))]
(if (n.> branching_exponent level)
- (case [(array.read 1 root) (array.read 0 root)]
+ (case [(array.read! 1 root) (array.read! 0 root)]
[#.None (#.Some (#Hierarchy sub_node))]
(recur (level_down level) sub_node)
diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux
index 6264d6083..d60fd99d4 100644
--- a/stdlib/source/library/lux/data/collection/sequence.lux
+++ b/stdlib/source/library/lux/data/collection/sequence.lux
@@ -84,7 +84,7 @@
xs)))]
[while until (-> a Bit) (pred x) pred |>]
- [take drop Nat (n.= 0 pred) (dec pred) not]
+ [first after Nat (n.= 0 pred) (dec pred) not]
)
(template [<splitter> <pred_type> <pred_test> <pred_step>]
@@ -98,7 +98,7 @@
[(#.Item [x tail]) next]))))]
[split_when (-> a Bit) (pred x) pred]
- [split Nat (n.= 0 pred) (dec pred)]
+ [split_at Nat (n.= 0 pred) (dec pred)]
)
(def: .public (unfold step init)
diff --git a/stdlib/source/library/lux/data/collection/set/multi.lux b/stdlib/source/library/lux/data/collection/set/multi.lux
index 46f395b21..b4786c825 100644
--- a/stdlib/source/library/lux/data/collection/set/multi.lux
+++ b/stdlib/source/library/lux/data/collection/set/multi.lux
@@ -37,7 +37,7 @@
0 set
_ (|> set
:representation
- (dictionary.upsert elem 0 (n.+ multiplicity))
+ (dictionary.revised' elem 0 (n.+ multiplicity))
:abstraction)))
(def: .public (lacks multiplicity elem set)
diff --git a/stdlib/source/library/lux/data/collection/stack.lux b/stdlib/source/library/lux/data/collection/stack.lux
index af2b3c3ea..2b9cbc2e4 100644
--- a/stdlib/source/library/lux/data/collection/stack.lux
+++ b/stdlib/source/library/lux/data/collection/stack.lux
@@ -27,7 +27,7 @@
(All [a] (-> (Stack a) Bit))
(|>> :representation //.empty?))
- (def: .public (peek stack)
+ (def: .public (value stack)
{#.doc (example "Yields the top value in the stack, if any.")}
(All [a] (-> (Stack a) (Maybe a)))
(case (:representation stack)
@@ -37,7 +37,7 @@
(#.Item value _)
(#.Some value)))
- (def: .public (pop stack)
+ (def: .public (next stack)
(All [a] (-> (Stack a) (Maybe [a (Stack a)])))
(case (:representation stack)
#.End
@@ -46,7 +46,7 @@
(#.Item top stack')
(#.Some [top (:abstraction stack')])))
- (def: .public (push value stack)
+ (def: .public (top value stack)
(All [a] (-> a (Stack a) (Stack a)))
(:abstraction (#.Item value (:representation stack))))
diff --git a/stdlib/source/library/lux/data/format/binary.lux b/stdlib/source/library/lux/data/format/binary.lux
index f3ce9f830..e16c2cebd 100644
--- a/stdlib/source/library/lux/data/format/binary.lux
+++ b/stdlib/source/library/lux/data/format/binary.lux
@@ -192,7 +192,7 @@
original_count)
value (if (n.= original_count capped_count)
value
- (|> value row.list (list.take capped_count) row.of_list))
+ (|> value row.list (list.first capped_count) row.of_list))
(^open "specification\.") ..monoid
[size mutation] (|> value
(row\map valueW)
diff --git a/stdlib/source/library/lux/data/format/css/value.lux b/stdlib/source/library/lux/data/format/css/value.lux
index a39469994..c2fb914c2 100644
--- a/stdlib/source/library/lux/data/format/css/value.lux
+++ b/stdlib/source/library/lux/data/format/css/value.lux
@@ -61,7 +61,7 @@
(let [raw (%.frac value)]
(if (f.< +0.0 value)
raw
- (|> raw (text.split 1) maybe.assume product.right))))
+ (|> raw (text.split_at 1) maybe.assume product.right))))
(abstract: .public (Value brand)
{}
diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux
index 45ac870c0..7f6ca24a8 100644
--- a/stdlib/source/library/lux/data/format/json.lux
+++ b/stdlib/source/library/lux/data/format/json.lux
@@ -227,7 +227,7 @@
value (let [raw (\ f.decimal encode value)]
(if (f.< +0.0 value)
raw
- (|> raw (text.split 1) maybe.assume product.right))))))
+ (|> raw (text.split_at 1) maybe.assume product.right))))))
(def: escape "\")
(def: escaped_dq (text\compose ..escape text.double_quote))
@@ -372,7 +372,7 @@
(loop [_ []])
(do {! <>.monad}
[chars (<text>.some (<text>.none_of (text\compose "\" text.double_quote)))
- stop <text>.peek])
+ stop <text>.next])
(if (text\= "\" stop)
(do !
[escaped escaped_parser
diff --git a/stdlib/source/library/lux/data/format/markdown.lux b/stdlib/source/library/lux/data/format/markdown.lux
index 08b26a686..281425105 100644
--- a/stdlib/source/library/lux/data/format/markdown.lux
+++ b/stdlib/source/library/lux/data/format/markdown.lux
@@ -52,7 +52,7 @@
(template [<name> <prefix>]
[(def: .public (<name> content)
- (-> Text Markdown)
+ (-> Text (Markdown Block))
(:abstraction (format <prefix> " " (..safe content) ..blank_line)))]
[heading/1 "#"]
@@ -110,10 +110,14 @@
(Markdown Block))
(|>> list.enumeration
(list\map (function (_ [idx [summary detail]])
- (format (%.nat (inc idx)) ". " (:representation summary) text.new_line
+ (format "1. " (:representation summary)
(case detail
(#.Some detail)
- (|> detail :representation ..indent (text.enclosed [text.new_line text.new_line]))
+ (|> detail
+ :representation
+ ..indent
+ (text.enclosed [text.new_line text.new_line])
+ (format text.new_line))
#.None
""))))
@@ -124,10 +128,14 @@
(-> (List [(Markdown Span) (Maybe (Markdown Block))])
(Markdown Block))
(|>> (list\map (function (_ [summary detail])
- (format "*. " (:representation summary) text.new_line
+ (format "* " (:representation summary)
(case detail
(#.Some detail)
- (|> detail :representation ..indent (text.enclosed [text.new_line text.new_line]))
+ (|> detail
+ :representation
+ ..indent
+ (text.enclosed [text.new_line text.new_line])
+ (format text.new_line))
#.None
""))))
@@ -137,7 +145,7 @@
(def: .public snippet
{#.doc "A snippet of code."}
(-> Text (Markdown Span))
- (|>> ..safe (text.enclosed ["`" "`"]) :abstraction))
+ (|>> (text.enclosed ["`` " " ``"]) :abstraction))
(def: .public code
{#.doc "A block of code."}
@@ -180,6 +188,6 @@
)
(def: .public markdown
- (-> (Markdown Any) Text)
+ (All [a] (-> (Markdown a) Text))
(|>> :representation))
)
diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux
index 096a968ee..e2f781d64 100644
--- a/stdlib/source/library/lux/data/text.lux
+++ b/stdlib/source/library/lux/data/text.lux
@@ -154,7 +154,7 @@
(#.Some ("lux text clip" offset (n.- offset size) input))
#.None)))
-(def: .public (split at x)
+(def: .public (split_at at x)
(-> Nat Text (Maybe [Text Text]))
(case [(..clip 0 at x) (..clip' at x)]
[(#.Some pre) (#.Some post)]
@@ -167,8 +167,8 @@
(-> Text Text (Maybe [Text Text]))
(do maybe.monad
[index (index_of token sample)
- [pre post'] (split index sample)
- [_ post] (split (size token) post')]
+ [pre post'] (split_at index sample)
+ [_ post] (split_at (size token) post')]
(in [pre post])))
(def: .public (all_split_by token sample)
diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux
index 234333bd8..488933f58 100644
--- a/stdlib/source/library/lux/debug.lux
+++ b/stdlib/source/library/lux/debug.lux
@@ -158,12 +158,12 @@
(case (ffi.check [java/lang/Object] object)
(#.Some value)
(let [value (:as (array.Array java/lang/Object) value)]
- (case (array.read 0 value)
+ (case (array.read! 0 value)
(^multi (#.Some tag)
{(ffi.check java/lang/Integer tag)
(#.Some tag)}
- {[(array.read 1 value)
- (array.read 2 value)]
+ {[(array.read! 1 value)
+ (array.read! 2 value)]
[last?
(#.Some choice)]})
(let [last? (case last?
diff --git a/stdlib/source/library/lux/documentation.lux b/stdlib/source/library/lux/documentation.lux
new file mode 100644
index 000000000..798bf3056
--- /dev/null
+++ b/stdlib/source/library/lux/documentation.lux
@@ -0,0 +1,366 @@
+(.module:
+ [library
+ [lux (#- Definition Module example type)
+ ["." meta]
+ [abstract
+ [monad (#+ do)]]
+ [control
+ ["." maybe ("#\." functor)]
+ ["." exception (#+ exception:)]
+ ["<>" parser
+ ["<.>" code (#+ Parser)]]]
+ [data
+ ["." product]
+ ["." text (#+ \n) ("#\." order)
+ ["%" format (#+ format)]]
+ [collection
+ ["." list ("#\." monad fold monoid)]
+ ["." set (#+ Set)]]
+ [format
+ ["md" markdown (#+ Markdown Block)]]]
+ [macro
+ [syntax (#+ syntax:)]
+ ["." code]
+ ["." template]]
+ [math
+ [number
+ ["n" nat]]]
+ [tool
+ [compiler
+ [language
+ [lux
+ ["." syntax]]]]]]])
+
+(type: Fragment
+ (#Comment Text)
+ (#Code Code))
+
+(def: fragment
+ (Parser Fragment)
+ (<>.or <code>.text
+ <code>.any))
+
+(def: (reference_column code)
+ (-> Code Nat)
+ (case code
+ (^template [<tag>]
+ [[[_ _ column] (<tag> _)]
+ column])
+ ([#.Bit]
+ [#.Nat]
+ [#.Int]
+ [#.Rev]
+ [#.Frac]
+ [#.Text]
+ [#.Identifier]
+ [#.Tag])
+
+ (^template [<tag>]
+ [[[_ _ column] (<tag> members)]
+ (|> members
+ (list\map reference_column)
+ (list\fold n.min column))])
+ ([#.Form]
+ [#.Tuple])
+
+ [[_ _ column] (#.Record pairs)]
+ (|> (list\compose (list\map (|>> product.left reference_column) pairs)
+ (list\map (|>> product.right reference_column) pairs))
+ (list\fold n.min column))
+ ))
+
+(def: (padding reference_column [_ old_line old_column] [_ new_line new_column])
+ (-> Nat Location Location Text)
+ (if (n.= old_line new_line)
+ (text.joined (list.repeated (n.- old_column new_column) " "))
+ (format (if (n.< new_line old_line)
+ (text.joined (list.repeated (n.- old_line new_line) \n))
+ "")
+ (if (n.< new_column reference_column)
+ (text.joined (list.repeated (n.- reference_column new_column) " "))
+ ""))))
+
+(def: un_paired
+ (All [a] (-> (List [a a]) (List a)))
+ (let [melded (: (All [a] (-> [a a] (List a) (List a)))
+ (function (_ [left right] tail)
+ (list& left right tail)))]
+ (|>> list.reversed
+ (list\fold melded #.End))))
+
+(def: (code_documentation old_location reference_column example)
+ (-> Location Nat Code [Location Text])
+ (case example
+ (^template [<tag> <format>]
+ [[new_location (<tag> value)]
+ (let [documentation (`` (|> value (~~ (template.spliced <format>))))]
+ [(update@ #.column (n.+ (text.size documentation)) new_location)
+ (format (padding reference_column old_location new_location)
+ documentation)])])
+ ([#.Bit [%.bit]]
+ [#.Nat [%.nat]]
+ [#.Int [%.int]]
+ [#.Rev [%.rev]]
+ [#.Frac [%.frac]]
+ [#.Text [%.text]]
+ [#.Identifier [%.name]]
+ [#.Tag [%.name (text.prefix syntax.sigil)]])
+
+ (^template [|<| |>| <tag> <prep>]
+ [[group_location (<tag> members)]
+ (let [[group_location' members_documentation] (list\fold (function (_ part [last_location text_accum])
+ (let [[member_location member_documentation] (code_documentation last_location reference_column part)]
+ [member_location (format text_accum member_documentation)]))
+ [(update@ #.column inc group_location) ""]
+ (<prep> members))]
+ [(update@ #.column inc group_location')
+ (format (padding reference_column old_location group_location)
+ |<| members_documentation |>|)])])
+ ([syntax.open_form syntax.close_form #.Form |>]
+ [syntax.open_tuple syntax.close_tuple #.Tuple |>]
+ [syntax.open_record syntax.close_record #.Record ..un_paired])
+ ))
+
+(def: blank_line
+ Text
+ (format \n \n))
+
+(def: single_line_comment
+ (-> Text Text)
+ (text.prefix "... "))
+
+(def: (fragment_documentation fragment)
+ (-> Fragment Text)
+ (case fragment
+ (#Comment comment)
+ (..single_line_comment comment)
+
+ (#Code example)
+ (let [reference_column (..reference_column example)
+ [location _] example]
+ (|> example
+ (..code_documentation (set@ #.column reference_column location) reference_column)
+ product.right))))
+
+(def: type
+ (-> Type Text)
+ %.type)
+
+(def: description
+ (Parser (Maybe Code))
+ (<>.or (<code>.text! "")
+ <code>.any))
+
+(exception: .public (unqualified_identifier {name Name})
+ (exception.report
+ ["Name" (%.name name)]))
+
+(def: qualified_identifier
+ (Parser Name)
+ (do <>.monad
+ [name <code>.identifier]
+ (case name
+ ["" _]
+ (<>.failure (exception.error ..unqualified_identifier [name]))
+
+ _
+ (in name))))
+
+(def: example_separator
+ Code
+ (let [c/01 "...."
+ c/04 (format c/01 c/01 c/01 c/01)
+ c/16 (format c/04 c/04 c/04 c/04)]
+ (code.text (format blank_line
+ c/16 \n c/16
+ blank_line))))
+
+(type: Example
+ (List Fragment))
+
+(def: example
+ (Parser Example)
+ (<code>.tuple (<>.many ..fragment)))
+
+(def: example_documentation
+ (-> Example Code)
+ (|>> (list\map ..fragment_documentation)
+ (list.interposed ..blank_line)
+ (text.join_with "")
+ code.text))
+
+(syntax: (minimal_definition_documentation
+ [name ..qualified_identifier])
+ (with_expansions [<\n> (~! text.\n)]
+ (in (list (` ($_ ((~! md.then))
+ ... Name
+ (<| ((~! md.heading/3))
+ (~ (code.text (|> name product.right [""] %.name))))
+ ... Type
+ (<| ((~! md.code))
+ ((~! ..type) ("lux in-module"
+ (~ (code.text (product.left name)))
+ (.:of (~ (code.identifier name)))))))
+ )))))
+
+(syntax: (definition_documentation
+ [name ..qualified_identifier
+ description ..description
+ examples (<>.some ..example)])
+ (with_expansions [<\n> (~! text.\n)]
+ (in (list (` ($_ ((~! md.then))
+ ((~! ..minimal_definition_documentation)
+ (~ (code.identifier name)))
+ ... Description
+ (~+ (case description
+ (#.Some description)
+ (list (` (<| ((~! md.paragraph))
+ ((~! md.text))
+ (~ description))))
+
+ #.None
+ (list)))
+ ... Examples
+ (~+ (case examples
+ #.End
+ (list)
+
+ _
+ (list (` (<| ((~! md.code))
+ ((~! %.format)
+ (~+ (|> examples
+ (list\map ..example_documentation)
+ (list.interposed ..example_separator))))))))))
+ )))))
+
+(type: .public Definition
+ {#definition Text
+ #documentation (Markdown Block)})
+
+(type: .public #rec Module
+ {#module Text
+ #expected (Set Text)
+ #definitions (List Definition)})
+
+(syntax: .public (default [name ..qualified_identifier])
+ (let [[_ short] name]
+ (in (list (` (: ..Definition
+ {#..definition (~ (code.text short))
+ #..documentation ((~! ..minimal_definition_documentation)
+ (~ (code.identifier name)))}))))))
+
+(syntax: .public (documentation: [name ..qualified_identifier
+ extra (<>.some <code>.any)])
+ (let [[_ short] name]
+ (in (list (` (.def: .public (~ (code.local_identifier short))
+ ..Definition
+ {#..definition (~ (code.text short))
+ #..documentation ((~! ..definition_documentation)
+ (~ (code.identifier name))
+ (~+ extra))}))))))
+
+(def: definitions_documentation
+ (-> (List Definition) (Markdown Block))
+ (|>> (list.sorted (function (_ left right)
+ (text\< (get@ #definition right)
+ (get@ #definition left))))
+ (list\map (get@ #documentation))
+ (list\fold md.then md.empty)))
+
+(def: expected_separator
+ Text
+ (text.of_char 31))
+
+(def: expected_format
+ (-> (List Text) Text)
+ (list\fold (function (_ short aggregate)
+ (case aggregate
+ "" short
+ _ (format aggregate ..expected_separator short)))
+ ""))
+
+(def: expected
+ (-> Text (Set Text))
+ (|>> (text.all_split_by ..expected_separator)
+ (set.of_list text.hash)))
+
+(def: (module' name expected definitions)
+ (-> Text Text (List Definition) Module)
+ {#module name
+ #expected (..expected expected)
+ #definitions definitions})
+
+(syntax: .public (module [[name _] ..qualified_identifier
+ definitions (<code>.tuple (<>.some <code>.any))
+ subs (<code>.tuple (<>.some <code>.any))])
+ (do meta.monad
+ [expected (meta.exports name)]
+ (in (list (` (: (List Module)
+ (list& ((~! module')
+ (~ (code.text name))
+ (~ (code.text (|> expected
+ (list\map product.left)
+ ..expected_format)))
+ (list (~+ definitions)))
+ ($_ (\ (~! list.monoid) (~' compose))
+ (: (List Module)
+ (\ (~! list.monoid) (~' identity)))
+ (~+ subs)))))))))
+
+(def: listing
+ (-> (List Text) (Markdown Block))
+ (|>> (list.sorted text\<)
+ (list\map (function (_ definition)
+ [(md.snippet definition)
+ #.None]))
+ md.numbered_list))
+
+(def: (module_documentation module)
+ (-> Module (Markdown Block))
+ (let [(^slots [#expected]) module]
+ ($_ md.then
+ ... Name
+ (md.heading/1 (get@ #module module))
+ ... Definitions
+ (md.heading/2 "Definitions")
+ (|> module
+ (get@ #definitions)
+ (list.only (|>> (get@ #definition)
+ (set.member? expected)))
+ ..definitions_documentation)
+ ... Missing documentation
+ (case (|> module
+ (get@ #definitions)
+ (list\fold (function (_ definition missing)
+ (set.lacks (get@ #definition definition) missing))
+ expected)
+ set.list)
+ #.End
+ md.empty
+
+ missing
+ ($_ md.then
+ (md.heading/2 "Missing documentation")
+ (..listing missing)))
+ ... Un-expected documentation
+ (case (|> module
+ (get@ #definitions)
+ (list.only (|>> (get@ #definition) (set.member? expected) not))
+ (list\map (get@ #definition)))
+ #.End
+ md.empty
+
+ un_expected
+ ($_ md.then
+ (md.heading/2 "Un-expected documentation")
+ (..listing un_expected)))
+ )))
+
+(def: .public documentation
+ (-> (List Module) Text)
+ (|>> (list.sorted (function (_ left right)
+ (text\< (get@ #module right) (get@ #module left))))
+ (list\map ..module_documentation)
+ (list.interposed md.horizontal_rule)
+ (list\fold md.then (: (Markdown Block) md.empty))
+ md.markdown))
diff --git a/stdlib/source/library/lux/math/number/rev.lux b/stdlib/source/library/lux/math/number/rev.lux
index 5c0ce4d8e..4eea3ecf7 100644
--- a/stdlib/source/library/lux/math/number/rev.lux
+++ b/stdlib/source/library/lux/math/number/rev.lux
@@ -295,7 +295,7 @@
(def: (digit idx digits)
(-> Nat Digits Nat)
(|> digits
- (array.read idx)
+ (array.read! idx)
(maybe.else 0)))
(def: digits\put!
diff --git a/stdlib/source/library/lux/math/random.lux b/stdlib/source/library/lux/math/random.lux
index 2ba47c5cd..bb66000be 100644
--- a/stdlib/source/library/lux/math/random.lux
+++ b/stdlib/source/library/lux/math/random.lux
@@ -268,7 +268,7 @@
[array Array array.of_list]
[queue Queue queue.of_list]
- [stack Stack (list\fold stack.push stack.empty)]
+ [stack Stack (list\fold stack.top stack.empty)]
)
(def: .public (set hash size value_gen)
diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux
index 8ed6e30f5..72f0b2b51 100644
--- a/stdlib/source/library/lux/meta.lux
+++ b/stdlib/source/library/lux/meta.lux
@@ -284,6 +284,22 @@
#.None
(#try.Failure ($_ text\compose "Unknown variable: " name))))))
+(def: without_lux_runtime
+ (-> (List Text) (List Text))
+ ... The Lux runtime shows up as ""
+ ... so I'm excluding it.
+ (list.only (|>> text.empty? not)))
+
+(def: listing_separator
+ Text
+ ($_ text\compose text.new_line " "))
+
+(def: module_listing
+ (-> (List Text) Text)
+ (|>> ..without_lux_runtime
+ (list.sorted text\<)
+ (text.join_with ..listing_separator)))
+
(def: .public (definition name)
{#.doc "Looks-up a definition's whole data in the available modules (including the current one)."}
(-> Name (Meta Global))
@@ -302,12 +318,10 @@
_
(let [current_module (|> lux (get@ #.current_module) (maybe.else "???"))
- separator ($_ text\compose text.new_line " ")
all_known_modules (|> lux
(get@ #.modules)
(list\map product.left)
- (list.sorted text\<)
- (text.join_with separator))]
+ ..module_listing)]
(#try.Failure ($_ text\compose
"Unknown definition: " (name\encode name) text.new_line
" Current module: " current_module text.new_line
@@ -330,16 +344,15 @@
#.None))))))
list.joined
(list.sorted text\<)
- (text.join_with separator))
+ (text.join_with ..listing_separator))
imports (|> this_module
(get@ #.imports)
- (list.sorted text\<)
- (text.join_with separator))
+ ..module_listing)
aliases (|> this_module
(get@ #.module_aliases)
(list\map (function (_ [alias real]) ($_ text\compose alias " => " real)))
(list.sorted text\<)
- (text.join_with separator))]
+ (text.join_with ..listing_separator))]
($_ text\compose
" Candidates: " candidates text.new_line
" Imports: " imports text.new_line
diff --git a/stdlib/source/library/lux/target/jvm/reflection.lux b/stdlib/source/library/lux/target/jvm/reflection.lux
index 813395886..f68b6b59d 100644
--- a/stdlib/source/library/lux/target/jvm/reflection.lux
+++ b/stdlib/source/library/lux/target/jvm/reflection.lux
@@ -197,8 +197,8 @@
(#.Some reflection)
... TODO: Instead of having single lower/upper bounds, should
... allow for multiple ones.
- (case [(array.read 0 (java/lang/reflect/WildcardType::getLowerBounds reflection))
- (array.read 0 (java/lang/reflect/WildcardType::getUpperBounds reflection))]
+ (case [(array.read! 0 (java/lang/reflect/WildcardType::getLowerBounds reflection))
+ (array.read! 0 (java/lang/reflect/WildcardType::getUpperBounds reflection))]
(^template [<pattern> <kind>]
[<pattern>
(case (ffi.check java/lang/reflect/GenericArrayType bound)
diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux
index 174058fab..f19ec248c 100644
--- a/stdlib/source/library/lux/tool/compiler/default/platform.lux
+++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux
@@ -328,10 +328,10 @@
(function (_ mapping)
(let [with_dependence+transitives
(|> mapping
- (dictionary.upsert source ..empty (set.has target))
+ (dictionary.revised' source ..empty (set.has target))
(dictionary.revised source (set.union forward)))]
(list\fold (function (_ previous)
- (dictionary.upsert previous ..empty (set.has target)))
+ (dictionary.revised' previous ..empty (set.has target)))
with_dependence+transitives
(set.list backward))))))]
(|> dependence
@@ -414,7 +414,7 @@
archive.ID
<Signal>])])
(:expected
- (stm.commit
+ (stm.commit!
(do {! stm.monad}
[dependence (if (text\= archive.runtime_module importer)
(stm.read dependence)
@@ -475,12 +475,12 @@
(in result)
(#try.Success [resulting_archive resulting_state])
- (stm.commit (do stm.monad
- [[_ [merged_archive _]] (stm.update (function (_ [archive state])
- [(archive.merged resulting_archive archive)
- state])
- current)]
- (in (#try.Success [merged_archive resulting_state])))))
+ (stm.commit! (do stm.monad
+ [[_ [merged_archive _]] (stm.update (function (_ [archive state])
+ [(archive.merged resulting_archive archive)
+ state])
+ current)]
+ (in (#try.Success [merged_archive resulting_state])))))
_ (async.future (resolver result))]
(in [])))]
return)))))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux
index 454704918..2188bb54a 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux
@@ -198,11 +198,11 @@
num_tags)
num_sub_patterns (list.size sub_patterns)
matches (cond (n.< num_subs num_sub_patterns)
- (let [[prefix suffix] (list.split (dec num_sub_patterns) subs)]
+ (let [[prefix suffix] (list.split_at (dec num_sub_patterns) subs)]
(list.zipped/2 (list\compose prefix (list (type.tuple suffix))) sub_patterns))
(n.> num_subs num_sub_patterns)
- (let [[prefix suffix] (list.split (dec num_subs) sub_patterns)]
+ (let [[prefix suffix] (list.split_at (dec num_subs) sub_patterns)]
(list.zipped/2 subs (list\compose prefix (list (code.tuple suffix)))))
... (n.= num_subs num_sub_patterns)
@@ -262,7 +262,7 @@
[[testP nextA] (if (and (n.> num_cases size_sum)
(n.= (dec num_cases) idx))
(analyse_pattern #.None
- (type.variant (list.drop (dec num_cases) flat_sum))
+ (type.variant (list.after (dec num_cases) flat_sum))
(` [(~+ values)])
next)
(analyse_pattern #.None caseT (` [(~+ values)]) next))]
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux
index 1a8d43477..af25a5856 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux
@@ -279,7 +279,7 @@
(/.except ..smaller_variant_than_expected [expected_size actual_size])
(n.= boundary tag)
- (let [caseT (type.variant (list.drop boundary cases))]
+ (let [caseT (type.variant (list.after boundary cases))]
(///\in (if (n.= 0 depth)
(type.function (list caseT) currentT)
(let [replace' (replace (|> depth dec (n.* 2)) inferT)]
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux
index ae6034b65..98c36ec05 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux
@@ -23,8 +23,11 @@
["." variable (#+ Register Variable)]]
["#" phase]]]])
-(type: Local (Bindings Text [Type Register]))
-(type: Foreign (Bindings Text [Type Variable]))
+(type: Local
+ (Bindings Text [Type Register]))
+
+(type: Foreign
+ (Bindings Text [Type Variable]))
(def: (local? name scope)
(-> Text Scope Bit)
@@ -79,7 +82,7 @@
(function (_ state)
(let [[inner outer] (|> state
(get@ #.scopes)
- (list.split_when (|>> (reference? name) not)))]
+ (list.split_when (|>> (reference? name))))]
(case outer
#.End
(#.Right [state #.None])
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
index 4913607a6..6fc53dd20 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
@@ -1169,7 +1169,7 @@
[name (index_parameter idx)]))
list.reversed)
num_owner_tvars (list.size owner_tvars)
- owner_tvarsT (|> lux_tvars (list.take num_owner_tvars) (list\map product.right))
+ owner_tvarsT (|> lux_tvars (list.first num_owner_tvars) (list\map product.right))
mapping (dictionary.of_list text.hash lux_tvars)]
[owner_tvarsT mapping]))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux
index b59e5ce37..6a5f40ef7 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux
@@ -5,7 +5,7 @@
["." monad (#+ do)]]
[control
[parser
- ["s" code]]]
+ ["<.>" code]]]
[data
[collection
["." list ("#\." functor)]]]
@@ -21,7 +21,7 @@
[///
["#" phase]]]])
-(syntax: (Vector [size s.nat
+(syntax: (Vector [size <code>.nat
elemT <code>.any])
(in (list (` [(~+ (list.repeated size elemT))]))))
@@ -31,8 +31,8 @@
(type: .public (Trinary of) (-> (Vector 3 of) of))
(type: .public (Variadic of) (-> (List of) of))
-(syntax: (arity: [arity s.nat
- name s.local_identifier
+(syntax: (arity: [arity <code>.nat
+ name <code>.local_identifier
type <code>.any])
(with_identifiers [g!_ g!extension g!name g!phase g!archive g!inputs g!of g!anchor g!expression g!directive]
(do {! meta.monad}
diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux
index 3e797c325..0c7969507 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux
@@ -147,7 +147,7 @@
(if (text.ends_with? ..lux_extension file)
(do !
[source_code (\ fs read file)]
- (async\in (dictionary.try_put (file.name fs file) source_code enumeration)))
+ (async\in (dictionary.has' (file.name fs file) source_code enumeration)))
(in enumeration)))
enumeration))
(\ ! join))]
diff --git a/stdlib/source/library/lux/type/check.lux b/stdlib/source/library/lux/type/check.lux
index 0201a446a..b4aedaef1 100644
--- a/stdlib/source/library/lux/type/check.lux
+++ b/stdlib/source/library/lux/type/check.lux
@@ -222,7 +222,7 @@
#.None
(..except ..unbound_type_var id))))
-(def: (peek id)
+(def: (bound id)
(-> Var (Check Type))
(function (_ context)
(case (|> context (get@ #.var_bindings) (var::get id))
@@ -404,8 +404,8 @@
(if (!n\= idE idA)
(check\in assumptions)
(do {! ..monad}
- [ebound (attempt (peek idE))
- abound (attempt (peek idA))]
+ [ebound (attempt (..bound idE))
+ abound (attempt (..bound idA))]
(case [ebound abound]
... Link the 2 variables circularly
[#.None #.None]
diff --git a/stdlib/source/library/lux/type/implicit.lux b/stdlib/source/library/lux/type/implicit.lux
index d8aeeebb1..6d5195708 100644
--- a/stdlib/source/library/lux/type/implicit.lux
+++ b/stdlib/source/library/lux/type/implicit.lux
@@ -133,7 +133,7 @@
(do meta.monad
[local_batches meta.locals
.let [total_locals (list\fold (function (_ [name type] table)
- (try.else table (dictionary.try_put name type table)))
+ (try.else table (dictionary.has' name type table)))
(: (Dictionary Text Type)
(dictionary.empty text.hash))
(list\join local_batches))]]
diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux
index 293856d25..e6c10352f 100644
--- a/stdlib/source/library/lux/world/file.lux
+++ b/stdlib/source/library/lux/world/file.lux
@@ -88,8 +88,8 @@
(#.Some last_separator)
(do maybe.monad
- [[parent temp] (text.split last_separator path)
- [_ child] (text.split (text.size /) temp)]
+ [[parent temp] (text.split_at last_separator path)
+ [_ child] (text.split_at (text.size /) temp)]
(in [parent child])))))
(def: .public (parent fs path)
@@ -1193,13 +1193,13 @@
(|>> (<retrieve> separator path)
(try\map (function.constant true))
(try.else false)))
- stm.commit))]
+ stm.commit!))]
[file? ..retrieve_mock_file!]
[directory? ..retrieve_mock_directory!]))
(def: (make_directory path)
- (stm.commit
+ (stm.commit!
(do {! stm.monad}
[|store| (stm.read store)]
(case (..make_mock_directory! separator path |store|)
@@ -1213,7 +1213,7 @@
(~~ (template [<method> <tag>]
[(def: (<method> path)
- (stm.commit
+ (stm.commit!
(do stm.monad
[|store| (stm.read store)]
(in (do try.monad
@@ -1233,7 +1233,7 @@
))
(def: (file_size path)
- (stm.commit
+ (stm.commit!
(do stm.monad
[|store| (stm.read store)]
(in (|> |store|
@@ -1243,7 +1243,7 @@
binary.size)))))))
(def: (last_modified path)
- (stm.commit
+ (stm.commit!
(do stm.monad
[|store| (stm.read store)]
(in (|> |store|
@@ -1252,7 +1252,7 @@
(get@ #mock_last_modified))))))))
(def: (can_execute? path)
- (stm.commit
+ (stm.commit!
(do stm.monad
[|store| (stm.read store)]
(in (|> |store|
@@ -1261,7 +1261,7 @@
(get@ #mock_can_execute))))))))
(def: (read path)
- (stm.commit
+ (stm.commit!
(do stm.monad
[|store| (stm.read store)]
(in (|> |store|
@@ -1270,11 +1270,11 @@
(get@ #mock_content))))))))
(def: (delete path)
- (stm.commit
+ (stm.commit!
(..attempt! (..delete_mock_node! separator path) store)))
(def: (modify now path)
- (stm.commit
+ (stm.commit!
(..attempt! (function (_ |store|)
(do try.monad
[[name file] (..retrieve_mock_file! separator path |store|)]
@@ -1284,13 +1284,13 @@
(def: (write content path)
(do async.monad
[now (async.future instant.now)]
- (stm.commit
+ (stm.commit!
(..attempt! (..update_mock_file! separator path now content) store))))
(def: (append content path)
(do async.monad
[now (async.future instant.now)]
- (stm.commit
+ (stm.commit!
(..attempt! (function (_ |store|)
(do try.monad
[[name file] (..retrieve_mock_file! separator path |store|)]
@@ -1302,7 +1302,7 @@
store))))
(def: (move destination origin)
- (stm.commit
+ (stm.commit!
(do {! stm.monad}
[|store| (stm.read store)]
(case (do try.monad
@@ -1333,7 +1333,7 @@
(let [rooted? (text.starts_with? (\ fs separator) path)
segments (text.all_split_by (\ fs separator) path)]
(case (if rooted?
- (list.drop 1 segments)
+ (list.after 1 segments)
segments)
#.End
(\ monad in (exception.except ..cannot_make_directory [path]))
diff --git a/stdlib/source/library/lux/world/file/watch.lux b/stdlib/source/library/lux/world/file/watch.lux
index 0bbc37e35..3a0b98f86 100644
--- a/stdlib/source/library/lux/world/file/watch.lux
+++ b/stdlib/source/library/lux/world/file/watch.lux
@@ -198,17 +198,17 @@
[exists? (\ fs directory? path)]
(if exists?
(do !
- [updated? (stm.commit (..update_watch! new_concern path tracker))]
+ [updated? (stm.commit! (..update_watch! new_concern path tracker))]
(if updated?
(in (#try.Success []))
(do (try.with !)
[file_tracker (..file_tracker fs path)]
(do !
- [_ (stm.commit (stm.update (dictionary.has path [new_concern file_tracker]) tracker))]
+ [_ (stm.commit! (stm.update (dictionary.has path [new_concern file_tracker]) tracker))]
(in (#try.Success []))))))
(in (exception.except ..cannot_poll_a_non_existent_directory [path])))))
(def: (concern path)
- (stm.commit
+ (stm.commit!
(do stm.monad
[@tracker (stm.read tracker)]
(in (case (dictionary.value path @tracker)
@@ -218,7 +218,7 @@
#.None
(exception.except ..not_being_watched [path]))))))
(def: (stop path)
- (stm.commit
+ (stm.commit!
(do {! stm.monad}
[@tracker (stm.read tracker)]
(case (dictionary.value path @tracker)
@@ -231,16 +231,16 @@
(in (exception.except ..not_being_watched [path]))))))
(def: (poll _)
(do async.monad
- [@tracker (stm.commit (stm.read tracker))]
+ [@tracker (stm.commit! (stm.read tracker))]
(do {! (try.with async.monad)}
[changes (|> @tracker
dictionary.entries
(monad.map ! (..available_directory_changes fs)))
_ (do async.monad
- [_ (stm.commit (stm.write (|> changes
- (list\map product.left)
- (dictionary.of_list text.hash))
- tracker))]
+ [_ (stm.commit! (stm.write (|> changes
+ (list\map product.left)
+ (dictionary.of_list text.hash))
+ tracker))]
(in (#try.Success [])))
.let [[creations modifications deletions]
(list\fold (function (_ [_ [creations modifications deletions]]
@@ -425,13 +425,13 @@
stop (: (-> //.Path (Async (Try Concern)))
(function (_ path)
(do {! async.monad}
- [@tracker (stm.commit (stm.read tracker))]
+ [@tracker (stm.commit! (stm.read tracker))]
(case (dictionary.value path @tracker)
(#.Some [concern key])
(do !
[_ (async.future
(java/nio/file/WatchKey::cancel key))
- _ (stm.commit (stm.update (dictionary.lacks path) tracker))]
+ _ (stm.commit! (stm.update (dictionary.lacks path) tracker))]
(in (#try.Success concern)))
#.None
@@ -447,11 +447,11 @@
watcher
path)]
(do async.monad
- [_ (stm.commit (stm.update (dictionary.has path [concern key]) tracker))]
+ [_ (stm.commit! (stm.update (dictionary.has path [concern key]) tracker))]
(in (#try.Success []))))))
(def: (concern path)
(do async.monad
- [@tracker (stm.commit (stm.read tracker))]
+ [@tracker (stm.commit! (stm.read tracker))]
(case (dictionary.value path @tracker)
(#.Some [concern key])
(in (#try.Success concern))
diff --git a/stdlib/source/library/lux/world/net/http/header.lux b/stdlib/source/library/lux/world/net/http/header.lux
index 76e96c815..5b5a20194 100644
--- a/stdlib/source/library/lux/world/net/http/header.lux
+++ b/stdlib/source/library/lux/world/net/http/header.lux
@@ -14,13 +14,13 @@
(def: .public (has name value)
(-> Text Text Header)
- (dictionary.upsert name ""
- (|>> (case>
- ""
- value
-
- previous
- (format previous "," value)))))
+ (dictionary.revised' name ""
+ (|>> (case>
+ ""
+ value
+
+ previous
+ (format previous "," value)))))
(def: .public content_length
(-> Nat Header)
diff --git a/stdlib/source/library/lux/world/program.lux b/stdlib/source/library/lux/world/program.lux
index 488d0ba36..d5195e39f 100644
--- a/stdlib/source/library/lux/world/program.lux
+++ b/stdlib/source/library/lux/world/program.lux
@@ -319,7 +319,7 @@
(#.Some process/env)
(|> (Object::entries [process/env])
array.list
- (list\map (|>> (array.read 0) maybe.assume)))
+ (list\map (|>> (array.read! 0) maybe.assume)))
#.None
(list))
@@ -365,8 +365,8 @@
@.js (io.io (if ffi.on_node_js?
(case (do maybe.monad
[process/env (ffi.constant Object [process env])]
- (array.read (:as Nat name)
- (:as (Array Text) process/env)))
+ (array.read! (:as Nat name)
+ (:as (Array Text) process/env)))
(#.Some value)
(#try.Success value)
diff --git a/stdlib/source/poly/lux/abstract/equivalence.lux b/stdlib/source/poly/lux/abstract/equivalence.lux
index 895c8d1a5..805576e18 100644
--- a/stdlib/source/poly/lux/abstract/equivalence.lux
+++ b/stdlib/source/poly/lux/abstract/equivalence.lux
@@ -45,7 +45,7 @@
(`` (do {! <>.monad}
[.let [g!_ (code.local_identifier "_____________")]
*env* <type>.env
- inputT <type>.peek
+ inputT <type>.next
.let [@Equivalence (: (-> Type Code)
(function (_ type)
(` ((~! /.Equivalence) (~ (poly.code *env* type))))))]]
diff --git a/stdlib/source/poly/lux/abstract/functor.lux b/stdlib/source/poly/lux/abstract/functor.lux
index 842c4b66c..db011ca27 100644
--- a/stdlib/source/poly/lux/abstract/functor.lux
+++ b/stdlib/source/poly/lux/abstract/functor.lux
@@ -30,7 +30,7 @@
funcC (code.local_identifier "____________funcC")
inputC (code.local_identifier "____________inputC")]
*env* <type>.env
- inputT <type>.peek
+ inputT <type>.next
[polyC varsC non_functorT] (<type>.local (list inputT)
(<type>.polymorphic <type>.any))
.let [num_vars (list.size varsC)]
diff --git a/stdlib/source/poly/lux/data/format/json.lux b/stdlib/source/poly/lux/data/format/json.lux
index 3146804e5..a77ef5980 100644
--- a/stdlib/source/poly/lux/data/format/json.lux
+++ b/stdlib/source/poly/lux/data/format/json.lux
@@ -127,7 +127,7 @@
.let [@JSON\encode (: (-> Type Code)
(function (_ type)
(` (-> (~ (poly.code *env* type)) /.JSON))))]
- inputT <type>.peek]
+ inputT <type>.next]
($_ <>.either
<basic>
<time>
@@ -250,7 +250,7 @@
.let [@JSON\decode (: (-> Type Code)
(function (_ type)
(` (</>.Parser (~ (poly.code *env* type))))))]
- inputT <type>.peek]
+ inputT <type>.next]
($_ <>.either
<basic>
<time>
diff --git a/stdlib/source/program/aedifex/hash.lux b/stdlib/source/program/aedifex/hash.lux
index 46a6fc67a..63394c8c9 100644
--- a/stdlib/source/program/aedifex/hash.lux
+++ b/stdlib/source/program/aedifex/hash.lux
@@ -123,7 +123,7 @@
chunk 0
output (binary.empty hash_size)]
(let [index (n.* chunk i64.bytes_per_i64)]
- (case (text.split ..hex_per_chunk input)
+ (case (text.split_at ..hex_per_chunk input)
(#.Some [head tail])
(do try.monad
[head (\ n.hex decode head)
diff --git a/stdlib/source/program/aedifex/repository.lux b/stdlib/source/program/aedifex/repository.lux
index 8d6d63b3a..914cd1420 100644
--- a/stdlib/source/program/aedifex/repository.lux
+++ b/stdlib/source/program/aedifex/repository.lux
@@ -51,7 +51,7 @@
(\ mock the_description))
(def: (download uri)
- (stm.commit
+ (stm.commit!
(do {! stm.monad}
[|state| (stm.read state)]
(case (\ mock on_download uri |state|)
@@ -64,7 +64,7 @@
(in (#try.Failure error))))))
(def: (upload uri content)
- (stm.commit
+ (stm.commit!
(do {! stm.monad}
[|state| (stm.read state)]
(case (\ mock on_upload uri content |state|)
diff --git a/stdlib/source/program/compositor/import.lux b/stdlib/source/program/compositor/import.lux
index ca72f9749..5d1eba51c 100644
--- a/stdlib/source/program/compositor/import.lux
+++ b/stdlib/source/program/compositor/import.lux
@@ -55,7 +55,7 @@
(case entry
(#tar.Normal [path instant mode ownership content])
(let [path (tar.from_path path)]
- (case (dictionary.try_put path (tar.data content) import)
+ (case (dictionary.has' path (tar.data content) import)
(#try.Failure error)
(exception.except ..duplicate [library path])
diff --git a/stdlib/source/specification/compositor/generation/function.lux b/stdlib/source/specification/compositor/generation/function.lux
index ad90dbfa0..f4697bd38 100644
--- a/stdlib/source/specification/compositor/generation/function.lux
+++ b/stdlib/source/specification/compositor/generation/function.lux
@@ -63,8 +63,8 @@
(//case.verify expectation)))
(_.test "Can partially apply functions."
(or (n.= 1 arity)
- (let [preS (list.take partial_arity inputsS)
- postS (list.drop partial_arity inputsS)
+ (let [preS (list.first partial_arity inputsS)
+ postS (list.after partial_arity inputsS)
partialS (synthesis.function/apply {#synthesis.function functionS
#synthesis.arguments preS})]
(|> (synthesis.function/apply {#synthesis.function partialS
diff --git a/stdlib/source/specification/compositor/generation/structure.lux b/stdlib/source/specification/compositor/generation/structure.lux
index 0b4bfe4fe..7cd303c52 100644
--- a/stdlib/source/specification/compositor/generation/structure.lux
+++ b/stdlib/source/specification/compositor/generation/structure.lux
@@ -45,9 +45,9 @@
(case> (#try.Success valueT)
(let [valueT (:as (Array Any) valueT)]
(and (n.= 3 (array.size valueT))
- (let [tag_out (:as java/lang/Integer (maybe.assume (array.read 0 valueT)))
- last?_out (array.read 1 valueT)
- value_out (:as Any (maybe.assume (array.read 2 valueT)))
+ (let [tag_out (:as java/lang/Integer (maybe.assume (array.read! 0 valueT)))
+ last?_out (array.read! 1 valueT)
+ value_out (:as Any (maybe.assume (array.read! 2 valueT)))
same_tag? (|> tag_out ffi.int_to_long (:as Nat) (n.= tag_in))
same_flag? (case last?_out
(#.Some last?_out')
diff --git a/stdlib/source/test/aedifex/command/version.lux b/stdlib/source/test/aedifex/command/version.lux
index 2bdf72078..c1ab3814e 100644
--- a/stdlib/source/test/aedifex/command/version.lux
+++ b/stdlib/source/test/aedifex/command/version.lux
@@ -38,7 +38,7 @@
(try.of_maybe
(do maybe.monad
[head (text.char 0 state)
- [_ tail] (text.split 1 state)]
+ [_ tail] (text.split_at 1 state)]
(in [[open? tail] head])))
(exception.except ..console_is_closed! [])))
(def: (on_read_line [open? state])
diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux
index cf45f0ca5..b2c6790ee 100644
--- a/stdlib/source/test/lux.lux
+++ b/stdlib/source/test/lux.lux
@@ -49,6 +49,7 @@
["#." control]
["#." data]
["#." debug]
+ ["#." documentation]
["#." locale]
["#." macro
["#/." code]]
@@ -85,6 +86,7 @@
/control.test
/data.test
/debug.test
+ /documentation.test
/locale.test
/macro.test
/math.test
diff --git a/stdlib/source/test/lux/abstract/comonad/cofree.lux b/stdlib/source/test/lux/abstract/comonad/cofree.lux
index 541977fc5..916d1953b 100644
--- a/stdlib/source/test/lux/abstract/comonad/cofree.lux
+++ b/stdlib/source/test/lux/abstract/comonad/cofree.lux
@@ -34,8 +34,8 @@
(Comparison (/.CoFree Sequence))
(function (_ == left right)
(\ (list.equivalence ==) =
- (sequence.take 100 (..interpret left))
- (sequence.take 100 (..interpret right)))))
+ (sequence.first 100 (..interpret left))
+ (sequence.first 100 (..interpret right)))))
(def: .public test
Test
diff --git a/stdlib/source/test/lux/control/concurrency/actor.lux b/stdlib/source/test/lux/control/concurrency/actor.lux
index c6b381829..627b294ad 100644
--- a/stdlib/source/test/lux/control/concurrency/actor.lux
+++ b/stdlib/source/test/lux/control/concurrency/actor.lux
@@ -203,7 +203,7 @@
[num_events (\ ! map (|>> (n.% 10) inc) random.nat)
events (random.list num_events random.nat)
num_observations (\ ! map (n.% num_events) random.nat)
- .let [expected (list.take num_observations events)
+ .let [expected (list.first num_observations events)
sink (: (Atom (Row Nat))
(atom.atom row.empty))]]
(in (do async.monad
diff --git a/stdlib/source/test/lux/control/concurrency/stm.lux b/stdlib/source/test/lux/control/concurrency/stm.lux
index 5ac592494..dbe98177f 100644
--- a/stdlib/source/test/lux/control/concurrency/stm.lux
+++ b/stdlib/source/test/lux/control/concurrency/stm.lux
@@ -51,52 +51,52 @@
($monad.spec ..injection ..comparison /.monad))
(in (do async.monad
- [actual (/.commit (\ /.monad in expected))]
- (_.cover' [/.commit]
+ [actual (/.commit! (\ /.monad in expected))]
+ (_.cover' [/.commit!]
(n.= expected actual))))
(in (do async.monad
- [actual (/.commit (/.read (/.var expected)))]
+ [actual (/.commit! (/.read (/.var expected)))]
(_.cover' [/.Var /.var /.read]
(n.= expected actual))))
(in (do async.monad
[actual (let [box (/.var dummy)]
- (/.commit (do /.monad
- [_ (/.write expected box)]
- (/.read box))))
+ (/.commit! (do /.monad
+ [_ (/.write expected box)]
+ (/.read box))))
verdict (let [box (/.var dummy)]
- (/.commit (do /.monad
- [_ (/.write expected box)
- actual (/.read box)]
- (in (n.= expected actual)))))]
+ (/.commit! (do /.monad
+ [_ (/.write expected box)
+ actual (/.read box)]
+ (in (n.= expected actual)))))]
(_.cover' [/.write]
(and (n.= expected actual)
verdict))))
(in (do async.monad
[.let [box (/.var dummy)]
- output (/.commit (do /.monad
- [_ (/.update (n.+ expected) box)]
- (/.read box)))]
+ output (/.commit! (do /.monad
+ [_ (/.update (n.+ expected) box)]
+ (/.read box)))]
(_.cover' [/.update]
(n.= (n.+ expected dummy)
output))))
(in (do async.monad
[.let [box (/.var dummy)
- [follower sink] (io.run! (/.follow box))]
- _ (/.commit (/.write expected box))
- _ (/.commit (/.update (n.* 2) box))
+ [follower sink] (io.run! (/.follow! box))]
+ _ (/.commit! (/.write expected box))
+ _ (/.commit! (/.update (n.* 2) box))
_ (async.future (\ sink close))
- _ (/.commit (/.update (n.* 3) box))
+ _ (/.commit! (/.update (n.* 3) box))
changes (frp.list follower)]
- (_.cover' [/.follow]
+ (_.cover' [/.follow!]
(\ (list.equivalence n.equivalence) =
(list expected (n.* 2 expected))
changes))))
(in (let [var (/.var 0)]
(do {! async.monad}
[_ (|> (list.repeated iterations_per_process [])
- (list\map (function (_ _) (/.commit (/.update inc var))))
+ (list\map (function (_ _) (/.commit! (/.update inc var))))
(monad.seq !))
- cummulative (/.commit (/.read var))]
+ cummulative (/.commit! (/.read var))]
(_.cover' [/.STM]
(n.= iterations_per_process
cummulative)))))
diff --git a/stdlib/source/test/lux/control/parser.lux b/stdlib/source/test/lux/control/parser.lux
index d6fa54ee1..bb81f4383 100644
--- a/stdlib/source/test/lux/control/parser.lux
+++ b/stdlib/source/test/lux/control/parser.lux
@@ -192,7 +192,7 @@
(/.result (/.exactly times <code>.nat))
(match actual
(\ (list.equivalence n.equivalence) =
- (list.take times expected+)
+ (list.first times expected+)
actual)))
(|> (list\map code.nat expected+)
(/.result (/.exactly (inc variadic) <code>.nat))
@@ -212,7 +212,7 @@
(/.result (/.at_most times <code>.nat))
(match actual
(\ (list.equivalence n.equivalence) =
- (list.take times expected+)
+ (list.first times expected+)
actual)))
(|> (list\map code.nat expected+)
(/.result (/.at_most (inc variadic) <code>.nat))
@@ -227,11 +227,11 @@
(\ (list.equivalence n.equivalence) =
expected+
actual)))
- (|> (list\map code.nat (list.take times expected+))
+ (|> (list\map code.nat (list.first times expected+))
(/.result (/.between times (n.- times variadic) <code>.nat))
(match actual
(\ (list.equivalence n.equivalence) =
- (list.take times expected+)
+ (list.first times expected+)
actual)))))
(_.cover [/.separated_by]
(|> (list.interposed (code.text separator) (list\map code.nat expected+))
diff --git a/stdlib/source/test/lux/control/parser/text.lux b/stdlib/source/test/lux/control/parser/text.lux
index a7bbfda92..35c509e00 100644
--- a/stdlib/source/test/lux/control/parser/text.lux
+++ b/stdlib/source/test/lux/control/parser/text.lux
@@ -333,10 +333,10 @@
(..should_fail "" /.any!))))
(do {! random.monad}
[expected (random.unicode 1)]
- (_.cover [/.peek /.cannot_parse]
- (and (..should_pass expected (<>.before /.any /.peek))
+ (_.cover [/.next /.cannot_parse]
+ (and (..should_pass expected (<>.before /.any /.next))
(|> ""
- (/.result (<>.before /.any /.peek))
+ (/.result (<>.before /.any /.next))
(!expect (^multi (#try.Failure error)
(exception.match? /.cannot_parse error)))))))
(do {! random.monad}
diff --git a/stdlib/source/test/lux/control/parser/type.lux b/stdlib/source/test/lux/control/parser/type.lux
index b348c1da2..373d549e9 100644
--- a/stdlib/source/test/lux/control/parser/type.lux
+++ b/stdlib/source/test/lux/control/parser/type.lux
@@ -198,15 +198,15 @@
(type\= expected actual))))))
(do {! random.monad}
[expected ..primitive]
- (_.cover [/.peek /.unconsumed_input]
+ (_.cover [/.next /.unconsumed_input]
(and (|> (/.result (do //.monad
- [actual /.peek
+ [actual /.next
_ /.any]
(in actual))
expected)
(!expect (^multi (#try.Success actual)
(type\= expected actual))))
- (|> (/.result /.peek expected)
+ (|> (/.result /.next expected)
(!expect (^multi (#try.Failure error)
(exception.match? /.unconsumed_input error)))))))
(do {! random.monad}
@@ -221,7 +221,7 @@
(exception.match? /.empty_input error))))]
[/.any]
- [/.peek]
+ [/.next]
))))))
(do {! random.monad}
[expected ..primitive]
diff --git a/stdlib/source/test/lux/control/region.lux b/stdlib/source/test/lux/control/region.lux
index ceda7b3a9..4f135a57d 100644
--- a/stdlib/source/test/lux/control/region.lux
+++ b/stdlib/source/test/lux/control/region.lux
@@ -103,14 +103,14 @@
.let [//@ !
count_clean_up (function (_ value)
(do !
- [_ (thread.update inc clean_up_counter)]
+ [_ (thread.update! inc clean_up_counter)]
(in (#try.Success []))))]
outcome (/.run! !
(do {! (/.monad !)}
- [_ (monad.map ! (/.acquire //@ count_clean_up)
+ [_ (monad.map ! (/.acquire! //@ count_clean_up)
(enum.range n.enum 1 expected_clean_ups))]
(in [])))
- actual_clean_ups (thread.read clean_up_counter)]
+ actual_clean_ups (thread.read! clean_up_counter)]
(in (and (..success? outcome)
(n.= expected_clean_ups
actual_clean_ups))))))
@@ -121,15 +121,15 @@
.let [//@ !
count_clean_up (function (_ value)
(do !
- [_ (thread.update inc clean_up_counter)]
+ [_ (thread.update! inc clean_up_counter)]
(in (#try.Success []))))]
outcome (/.run! !
(do {! (/.monad !)}
- [_ (monad.map ! (/.acquire //@ count_clean_up)
+ [_ (monad.map ! (/.acquire! //@ count_clean_up)
(enum.range n.enum 1 expected_clean_ups))
_ (/.failure //@ (exception.error ..oops []))]
(in [])))
- actual_clean_ups (thread.read clean_up_counter)]
+ actual_clean_ups (thread.read! clean_up_counter)]
(in (and (..throws? ..oops outcome)
(n.= expected_clean_ups
actual_clean_ups))))))
@@ -140,34 +140,34 @@
.let [//@ !
count_clean_up (function (_ value)
(do !
- [_ (thread.update inc clean_up_counter)]
+ [_ (thread.update! inc clean_up_counter)]
(in (#try.Success []))))]
outcome (/.run! !
(do {! (/.monad !)}
- [_ (monad.map ! (/.acquire //@ count_clean_up)
+ [_ (monad.map ! (/.acquire! //@ count_clean_up)
(enum.range n.enum 1 expected_clean_ups))
_ (/.except //@ ..oops [])]
(in [])))
- actual_clean_ups (thread.read clean_up_counter)]
+ actual_clean_ups (thread.read! clean_up_counter)]
(in (and (..throws? ..oops outcome)
(n.= expected_clean_ups
actual_clean_ups))))))
- (_.cover [/.acquire /.clean_up_error]
+ (_.cover [/.acquire! /.clean_up_error]
(thread.result
(do {! thread.monad}
[clean_up_counter (thread.box 0)
.let [//@ !
count_clean_up (function (_ value)
(do !
- [_ (thread.update inc clean_up_counter)]
+ [_ (thread.update! inc clean_up_counter)]
(in (: (Try Any)
(exception.except ..oops [])))))]
outcome (/.run! !
(do {! (/.monad !)}
- [_ (monad.map ! (/.acquire //@ count_clean_up)
+ [_ (monad.map ! (/.acquire! //@ count_clean_up)
(enum.range n.enum 1 expected_clean_ups))]
(in [])))
- actual_clean_ups (thread.read clean_up_counter)]
+ actual_clean_ups (thread.read! clean_up_counter)]
(in (and (or (n.= 0 expected_clean_ups)
(..throws? /.clean_up_error outcome))
(n.= expected_clean_ups
@@ -179,9 +179,9 @@
.let [//@ !]
outcome (/.run! !
(do (/.monad !)
- [_ (/.lift //@ (thread.write expected_clean_ups clean_up_counter))]
+ [_ (/.lift //@ (thread.write! expected_clean_ups clean_up_counter))]
(in [])))
- actual_clean_ups (thread.read clean_up_counter)]
+ actual_clean_ups (thread.read! clean_up_counter)]
(in (and (..success? outcome)
(n.= expected_clean_ups
actual_clean_ups))))))
diff --git a/stdlib/source/test/lux/control/thread.lux b/stdlib/source/test/lux/control/thread.lux
index 4f71c7203..2f93f2349 100644
--- a/stdlib/source/test/lux/control/thread.lux
+++ b/stdlib/source/test/lux/control/thread.lux
@@ -57,26 +57,26 @@
(_.for [/.Box /.box]
($_ _.and
- (_.cover [/.read]
+ (_.cover [/.read!]
(n.= sample
(/.result (: (All [!] (Thread ! Nat))
(do /.monad
[box (/.box sample)]
- (/.read box))))))
+ (/.read! box))))))
- (_.cover [/.write]
+ (_.cover [/.write!]
(n.= factor
(/.result (: (All [!] (Thread ! Nat))
(do /.monad
[box (/.box sample)
- _ (/.write factor box)]
- (/.read box))))))
+ _ (/.write! factor box)]
+ (/.read! box))))))
- (_.cover [/.update]
+ (_.cover [/.update!]
(n.= (n.* factor sample)
(/.result (: (All [!] (Thread ! Nat))
(do /.monad
[box (/.box sample)
- old (/.update (n.* factor) box)]
- (/.read box))))))))
+ old (/.update! (n.* factor) box)]
+ (/.read! box))))))))
))))
diff --git a/stdlib/source/test/lux/data/binary.lux b/stdlib/source/test/lux/data/binary.lux
index d45cc6554..aab56834f 100644
--- a/stdlib/source/test/lux/data/binary.lux
+++ b/stdlib/source/test/lux/data/binary.lux
@@ -134,16 +134,16 @@
(case offset
0 (not verdict)
_ verdict))))
- (_.cover [/.drop]
- (and (\ /.equivalence = sample (/.drop 0 sample))
- (\ /.equivalence = (/.empty 0) (/.drop size sample))
+ (_.cover [/.after]
+ (and (\ /.equivalence = sample (/.after 0 sample))
+ (\ /.equivalence = (/.empty 0) (/.after size sample))
(case (list.reversed (..as_list sample))
#.End
false
(#.Item head tail)
(n.= (list.fold n.+ 0 tail)
- (/.fold n.+ 0 (/.drop 1 sample))))))
+ (/.fold n.+ 0 (/.after 1 sample))))))
(_.cover [/.copy]
(and (case (/.copy size 0 sample 0 (/.empty size))
(#try.Success output)
diff --git a/stdlib/source/test/lux/data/collection/array.lux b/stdlib/source/test/lux/data/collection/array.lux
index c7433632e..c1e1471f8 100644
--- a/stdlib/source/test/lux/data/collection/array.lux
+++ b/stdlib/source/test/lux/data/collection/array.lux
@@ -66,7 +66,7 @@
(n.even? member))
the_array)]
[(#.Some expected) (#.Some [idx actual])]
- (case (/.read idx the_array)
+ (case (/.read! idx the_array)
(#.Some again)
(and (n.= expected actual)
(n.= actual again))
@@ -114,12 +114,12 @@
_
false))
- (_.cover [/.read /.write!]
+ (_.cover [/.read! /.write!]
(let [the_array (|> (/.empty 2)
(: (Array Nat))
(/.write! 0 expected))]
- (case [(/.read 0 the_array)
- (/.read 1 the_array)]
+ (case [(/.read! 0 the_array)
+ (/.read! 1 the_array)]
[(#.Some actual) #.None]
(n.= expected actual)
@@ -129,8 +129,8 @@
(let [the_array (|> (/.empty 1)
(: (Array Nat))
(/.write! 0 expected))]
- (case [(/.read 0 the_array)
- (/.read 0 (/.delete! 0 the_array))]
+ (case [(/.read! 0 the_array)
+ (/.read! 0 (/.delete! 0 the_array))]
[(#.Some actual) #.None]
(n.= expected actual)
@@ -148,7 +148,7 @@
(: (Array Nat))
(/.write! 0 base)
(/.update! 0 (n.+ shift)))]
- (case (/.read 0 the_array)
+ (case (/.read! 0 the_array)
(#.Some actual)
(n.= expected actual)
@@ -160,8 +160,8 @@
(/.write! 0 base)
(/.upsert! 0 dummy (n.+ shift))
(/.upsert! 1 base (n.+ shift)))]
- (case [(/.read 0 the_array)
- (/.read 1 the_array)]
+ (case [(/.read! 0 the_array)
+ (/.read! 1 the_array)]
[(#.Some actual/0) (#.Some actual/1)]
(and (n.= expected actual/0)
(n.= expected actual/1))
@@ -195,7 +195,7 @@
(/.empty size))]
(exec (/.copy! amount 0 the_array 0 copy)
(\ (list.equivalence n.equivalence) =
- (list.take amount (/.list the_array))
+ (list.first amount (/.list the_array))
(/.list copy))))))
(_.cover [/.clone]
(let [clone (/.clone the_array)]
diff --git a/stdlib/source/test/lux/data/collection/dictionary.lux b/stdlib/source/test/lux/data/collection/dictionary.lux
index 7114a2eed..82e421d28 100644
--- a/stdlib/source/test/lux/data/collection/dictionary.lux
+++ b/stdlib/source/test/lux/data/collection/dictionary.lux
@@ -161,9 +161,9 @@
(#.Some v) (n.= test_val v)
_ true)))
- (_.cover [/.try_put /.key_already_exists]
+ (_.cover [/.has' /.key_already_exists]
(let [can_put_new_keys!
- (case (/.try_put non_key test_val dict)
+ (case (/.has' non_key test_val dict)
(#try.Success dict)
(case (/.value non_key dict)
(#.Some v) (n.= test_val v)
@@ -175,7 +175,7 @@
cannot_put_old_keys!
(or (n.= 0 size)
(let [first_key (|> dict /.keys list.head maybe.assume)]
- (case (/.try_put first_key test_val dict)
+ (case (/.has' first_key test_val dict)
(#try.Success _)
false
@@ -206,9 +206,9 @@
_
false)))
- (_.cover [/.upsert]
+ (_.cover [/.revised']
(let [can_upsert_new_key!
- (case (/.value non_key (/.upsert non_key test_val inc dict))
+ (case (/.value non_key (/.revised' non_key test_val inc dict))
(#.Some inserted)
(n.= (inc test_val) inserted)
@@ -221,7 +221,7 @@
true
(#.Some [known_key known_value])
- (case (/.value known_key (/.upsert known_key test_val inc dict))
+ (case (/.value known_key (/.revised' known_key test_val inc dict))
(#.Some updated)
(n.= (inc known_value) updated)
@@ -237,10 +237,10 @@
/.size
(n.= 1)))
- (_.cover [/.re_bind]
+ (_.cover [/.re_bound]
(or (n.= 0 size)
(let [first_key (|> dict /.keys list.head maybe.assume)
- rebound (/.re_bind first_key non_key dict)]
+ rebound (/.re_bound first_key non_key dict)]
(and (n.= (/.size dict) (/.size rebound))
(/.key? rebound non_key)
(not (/.key? rebound first_key))
diff --git a/stdlib/source/test/lux/data/collection/list.lux b/stdlib/source/test/lux/data/collection/list.lux
index 7fb1e8704..ce86a80c7 100644
--- a/stdlib/source/test/lux/data/collection/list.lux
+++ b/stdlib/source/test/lux/data/collection/list.lux
@@ -202,18 +202,18 @@
positives)
(/\= (/.only (bit.complement n.even?) sample)
negatives))))
- (_.cover [/.split]
- (let [[left right] (/.split idx sample)]
+ (_.cover [/.split_at]
+ (let [[left right] (/.split_at idx sample)]
(/\= sample
(/\compose left right))))
(_.cover [/.split_when]
(let [[left right] (/.split_when n.even? sample)]
(/\= sample
(/\compose left right))))
- (_.cover [/.take /.drop]
+ (_.cover [/.first /.after]
(/\= sample
- (/\compose (/.take idx sample)
- (/.drop idx sample))))
+ (/\compose (/.first idx sample)
+ (/.after idx sample))))
(_.cover [/.while /.until]
(/\= sample
(/\compose (/.while n.even? sample)
@@ -292,9 +292,9 @@
(n.min (/.size sample/0) (/.size sample/1)))
can_extract_values!
- (and (/\= (/.take zipped::size sample/0)
+ (and (/\= (/.first zipped::size sample/0)
(/\map product.left zipped))
- (/\= (/.take zipped::size sample/1)
+ (/\= (/.first zipped::size sample/1)
(/\map product.right zipped)))]
(and size_of_smaller_list!
can_extract_values!)))
@@ -310,11 +310,11 @@
(/.size sample/2)))
can_extract_values!
- (and (/\= (/.take zipped::size sample/0)
+ (and (/\= (/.first zipped::size sample/0)
(/\map product.left zipped))
- (/\= (/.take zipped::size sample/1)
+ (/\= (/.first zipped::size sample/1)
(/\map (|>> product.right product.left) zipped))
- (/\= (/.take zipped::size sample/2)
+ (/\= (/.first zipped::size sample/2)
(/\map (|>> product.right product.right) zipped)))]
(and size_of_smaller_list!
can_extract_values!)))
@@ -424,7 +424,7 @@
0)))))
(_.cover [/.folds]
(/\= (/\map (function (_ index)
- (\ /.fold fold n.+ 0 (/.take index sample)))
+ (\ /.fold fold n.+ 0 (/.first index sample)))
(/.indices (inc (/.size sample))))
(/.folds n.+ 0 sample)))
(do random.monad
diff --git a/stdlib/source/test/lux/data/collection/queue.lux b/stdlib/source/test/lux/data/collection/queue.lux
index 33ec7d9ba..5fcec5102 100644
--- a/stdlib/source/test/lux/data/collection/queue.lux
+++ b/stdlib/source/test/lux/data/collection/queue.lux
@@ -58,8 +58,8 @@
/.empty))]
(and empty_is_empty!
all_empty_queues_look_the_same!)))
- (_.cover [/.peek]
- (case [members (/.peek sample)]
+ (_.cover [/.front]
+ (case [members (/.front sample)]
[(#.Item head tail) (#.Some first)]
(n.= head first)
@@ -77,8 +77,8 @@
(not (/.member? n.equivalence sample non_member))]
(and every_member_is_identified!
non_member_is_not_identified!)))
- (_.cover [/.push]
- (let [pushed (/.push non_member sample)
+ (_.cover [/.end]
+ (let [pushed (/.end non_member sample)
size_increases!
(n.= (inc (/.size sample)) (/.size pushed))
@@ -93,10 +93,10 @@
(and size_increases!
new_member_is_identified!
has_expected_order!)))
- (_.cover [/.pop]
+ (_.cover [/.next]
(case members
(#.Item target expected)
- (let [popped (/.pop sample)
+ (let [popped (/.next sample)
size_decreases!
(n.= (dec (/.size sample))
@@ -115,5 +115,5 @@
#.End
(and (/.empty? sample)
- (/.empty? (/.pop sample)))))
+ (/.empty? (/.next sample)))))
))))
diff --git a/stdlib/source/test/lux/data/collection/queue/priority.lux b/stdlib/source/test/lux/data/collection/queue/priority.lux
index 20579c5b6..4faaaf488 100644
--- a/stdlib/source/test/lux/data/collection/queue/priority.lux
+++ b/stdlib/source/test/lux/data/collection/queue/priority.lux
@@ -22,7 +22,7 @@
(monad.fold ! (function (_ head tail)
(do !
[priority random.nat]
- (in (/.push priority head tail))))
+ (in (/.end priority head tail))))
/.empty
inputs)))
@@ -47,28 +47,28 @@
(/.empty? sample)))
(_.cover [/.empty]
(/.empty? /.empty))
- (_.cover [/.peek]
- (case (/.peek sample)
+ (_.cover [/.front]
+ (case (/.front sample)
(#.Some first)
(n.> 0 (/.size sample))
#.None
(/.empty? sample)))
(_.cover [/.member?]
- (case (/.peek sample)
+ (case (/.front sample)
(#.Some first)
(/.member? n.equivalence sample first)
#.None
(/.empty? sample)))
- (_.cover [/.push]
- (let [sample+ (/.push non_member_priority non_member sample)]
+ (_.cover [/.end]
+ (let [sample+ (/.end non_member_priority non_member sample)]
(and (not (/.member? n.equivalence sample non_member))
(n.= (inc (/.size sample))
(/.size sample+))
(/.member? n.equivalence sample+ non_member))))
- (_.cover [/.pop]
- (let [sample- (/.pop sample)]
+ (_.cover [/.next]
+ (let [sample- (/.next sample)]
(or (and (/.empty? sample)
(/.empty? sample-))
(n.= (dec (/.size sample))
@@ -77,17 +77,17 @@
($_ _.and
(_.cover [/.max]
(|> /.empty
- (/.push /.min min_member)
- (/.push /.max max_member)
- /.peek
+ (/.end /.min min_member)
+ (/.end /.max max_member)
+ /.front
(maybe\map (n.= max_member))
(maybe.else false)))
(_.cover [/.min]
(|> /.empty
- (/.push /.max max_member)
- (/.push /.min min_member)
- /.pop
- /.peek
+ (/.end /.max max_member)
+ (/.end /.min min_member)
+ /.next
+ /.front
(maybe\map (n.= min_member))
(maybe.else false)))
))
diff --git a/stdlib/source/test/lux/data/collection/sequence.lux b/stdlib/source/test/lux/data/collection/sequence.lux
index 9a2c78afb..19183f1b1 100644
--- a/stdlib/source/test/lux/data/collection/sequence.lux
+++ b/stdlib/source/test/lux/data/collection/sequence.lux
@@ -26,8 +26,8 @@
(def: (= reference subject)
(\ (list.equivalence super) =
- (/.take 100 reference)
- (/.take 100 subject))))
+ (/.first 100 reference)
+ (/.first 100 subject))))
(def: .public test
Test
@@ -53,18 +53,18 @@
(_.cover [/.repeated]
(n.= repeated
(/.item index (/.repeated repeated))))
- (_.cover [/.take]
+ (_.cover [/.first]
(list\= (enum.range n.enum offset (dec (n.+ size offset)))
- (/.take size (/.iterations inc offset))))
- (_.cover [/.drop]
+ (/.first size (/.iterations inc offset))))
+ (_.cover [/.after]
(list\= (enum.range n.enum offset (dec (n.+ size offset)))
- (/.take size (/.drop offset (/.iterations inc 0)))))
- (_.cover [/.split]
- (let [[drops takes] (/.split size (/.iterations inc 0))]
+ (/.first size (/.after offset (/.iterations inc 0)))))
+ (_.cover [/.split_at]
+ (let [[drops takes] (/.split_at size (/.iterations inc 0))]
(and (list\= (enum.range n.enum 0 (dec size))
drops)
(list\= (enum.range n.enum size (dec (n.* 2 size)))
- (/.take size takes)))))
+ (/.first size takes)))))
(_.cover [/.while]
(list\= (enum.range n.enum 0 (dec size))
(/.while (n.< size) (/.iterations inc 0))))
@@ -83,10 +83,10 @@
(/.head (/.iterations inc offset))))
(_.cover [/.tail]
(list\= (enum.range n.enum (inc offset) (n.+ size offset))
- (/.take size (/.tail (/.iterations inc offset)))))
+ (/.first size (/.tail (/.iterations inc offset)))))
(_.cover [/.only]
(list\= (list\map (n.* 2) (enum.range n.enum 0 (dec size)))
- (/.take size (/.only n.even? (/.iterations inc 0)))))
+ (/.first size (/.only n.even? (/.iterations inc 0)))))
(_.cover [/.partition]
(let [[evens odds] (/.partition n.even? (/.iterations inc 0))]
(and (n.= (n.* 2 offset)
@@ -96,16 +96,16 @@
(_.cover [/.unfold]
(let [(^open "/\.") /.functor
(^open "list\.") (list.equivalence text.equivalence)]
- (list\= (/.take size
- (/\map %.nat (/.iterations inc offset)))
- (/.take size
- (/.unfold (function (_ n) [(inc n) (%.nat n)])
- offset)))))
+ (list\= (/.first size
+ (/\map %.nat (/.iterations inc offset)))
+ (/.first size
+ (/.unfold (function (_ n) [(inc n) (%.nat n)])
+ offset)))))
(_.cover [/.cycle]
(let [cycle (list& cycle_start cycle_next)]
(list\= (list.joined (list.repeated size cycle))
- (/.take (n.* size (list.size cycle))
- (/.cycle [cycle_start cycle_next])))))
+ (/.first (n.* size (list.size cycle))
+ (/.cycle [cycle_start cycle_next])))))
(_.cover [/.^sequence&]
(let [(/.^sequence& first second third next) (/.iterations inc offset)]
(and (n.= offset first)
diff --git a/stdlib/source/test/lux/data/collection/stack.lux b/stdlib/source/test/lux/data/collection/stack.lux
index 591308f56..79355156f 100644
--- a/stdlib/source/test/lux/data/collection/stack.lux
+++ b/stdlib/source/test/lux/data/collection/stack.lux
@@ -20,7 +20,7 @@
(def: (injection value)
(Injection /.Stack)
- (/.push value /.empty))
+ (/.top value /.empty))
(def: .public test
Test
@@ -43,24 +43,24 @@
(/.empty? sample)))
(_.cover [/.empty]
(/.empty? /.empty))
- (_.cover [/.peek]
- (case (/.peek sample)
+ (_.cover [/.value]
+ (case (/.value sample)
#.None
(/.empty? sample)
(#.Some _)
(not (/.empty? sample))))
- (_.cover [/.pop]
- (case (/.pop sample)
+ (_.cover [/.next]
+ (case (/.next sample)
#.None
(/.empty? sample)
(#.Some [top remaining])
(\ (/.equivalence n.equivalence) =
sample
- (/.push top remaining))))
- (_.cover [/.push]
- (case (/.pop (/.push expected_top sample))
+ (/.top top remaining))))
+ (_.cover [/.top]
+ (case (/.next (/.top expected_top sample))
(#.Some [actual_top actual_sample])
(and (same? expected_top actual_top)
(same? sample actual_sample))
diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux
index f95757333..1efa4ebfe 100644
--- a/stdlib/source/test/lux/data/text.lux
+++ b/stdlib/source/test/lux/data/text.lux
@@ -288,8 +288,8 @@
.let [sample (/.joined (list sampleL sampleR))
(^open "/\.") /.equivalence]]
($_ _.and
- (_.cover [/.split]
- (|> (/.split sizeL sample)
+ (_.cover [/.split_at]
+ (|> (/.split_at sizeL sample)
(case> (#.Right [_l _r])
(and (/\= sampleL _l)
(/\= sampleR _r)
diff --git a/stdlib/source/test/lux/documentation.lux b/stdlib/source/test/lux/documentation.lux
new file mode 100644
index 000000000..b8a34a752
--- /dev/null
+++ b/stdlib/source/test/lux/documentation.lux
@@ -0,0 +1,93 @@
+(.module:
+ [library
+ [lux #*
+ ["_" test (#+ Test)]
+ [control
+ ["." try]
+ ["." exception]
+ [parser
+ ["<.>" code]]]
+ [data
+ ["." text ("#\." equivalence)]
+ [format
+ ["md" markdown]]]
+ ["." macro
+ [syntax (#+ syntax:)]
+ ["." template]
+ ["." code]]]]
+ [\\library
+ ["." /]])
+
+(syntax: (macro_error [macro <code>.any])
+ (function (_ compiler)
+ (case ((macro.expansion macro) compiler)
+ (#try.Failure error)
+ (#try.Success [compiler (list (code.text error))])
+
+ (#try.Success _)
+ (#try.Failure "OOPS!"))))
+
+(template.with_locals [g!default
+ g!description]
+ (as_is (def: g!default
+ Nat
+ 123)
+
+ (`` (/.documentation: /.documentation:
+ (~~ (template.text [g!description]))))
+
+ (def: .public test
+ Test
+ (<| (_.covering /._)
+ ($_ _.and
+ (_.for [/.Definition]
+ ($_ _.and
+ (_.cover [/.default]
+ (let [definition (`` (/.default (~~ (template.identifier [.._] [g!default]))))]
+ (and (|> definition
+ (get@ #/.definition)
+ (text\= (template.text [g!default])))
+ (|> definition
+ (get@ #/.documentation)
+ md.markdown
+ (text\= "")
+ not))))
+ (_.cover [/.documentation:]
+ (and (|> ..documentation:
+ (get@ #/.definition)
+ (text\= (template.text [/.documentation:])))
+ (|> ..documentation:
+ (get@ #/.documentation)
+ md.markdown
+ (text.contains? (template.text [g!description]))
+ not)))
+ ))
+ (_.for [/.Module]
+ ($_ _.and
+ (_.cover [/.module /.documentation]
+ (let [sub (/.module /._
+ []
+ [])
+ super (/.module .._
+ [..documentation:]
+ [sub])]
+ (and (text.contains? (/.documentation sub)
+ (/.documentation super))
+ (text.contains? (md.markdown (get@ #/.documentation ..documentation:))
+ (/.documentation super)))))
+ ))
+ (_.cover [/.unqualified_identifier]
+ (`` (and (~~ (template [<example>]
+ [(<| (text.contains? (get@ #exception.label /.unqualified_identifier))
+ macro_error
+ <example>)]
+
+ [(/.default g!default)]
+ [(/.documentation: g!default
+ (~~ (template.text [g!description])))]
+ [(/.module g!default
+ [..documentation:]
+ [sub])]
+ )))))
+ ))))
+ )
diff --git a/stdlib/source/test/lux/meta.lux b/stdlib/source/test/lux/meta.lux
index b8e3e1c76..1403d6ee8 100644
--- a/stdlib/source/test/lux/meta.lux
+++ b/stdlib/source/test/lux/meta.lux
@@ -653,8 +653,8 @@
all_tags (|> random_tag
(random.set name.hash 10)
(\ ! map set.list))
- .let [tags_0 (list.take 5 all_tags)
- tags_1 (list.drop 5 all_tags)
+ .let [tags_0 (list.first 5 all_tags)
+ tags_1 (list.after 5 all_tags)
type_0 (#.Primitive name_0 (list))
type_1 (#.Primitive name_1 (list))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux
index 3f975a006..f694d0629 100644
--- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux
+++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux
@@ -179,8 +179,8 @@
(_.test "Can analyse exhaustive pattern-matching."
(|> (analyse_pm exhaustive_branchesC)
_structure.check_succeeds))
- (let [non_exhaustive_branchesC (list.take (dec (list.size exhaustive_branchesC))
- exhaustive_branchesC)]
+ (let [non_exhaustive_branchesC (list.first (dec (list.size exhaustive_branchesC))
+ exhaustive_branchesC)]
(_.test "Will reject non-exhaustive pattern-matching."
(|> (analyse_pm non_exhaustive_branchesC)
_structure.check_fails)))
@@ -189,9 +189,9 @@
redundancy_idx (|> r.nat (\ ! map (n.% (list.size redundant_patterns))))
.let [redundant_branchesC (<| (list!map (branch outputC))
list.joined
- (list (list.take redundancy_idx redundant_patterns)
+ (list (list.first redundancy_idx redundant_patterns)
(list (maybe.assume (list.item redundancy_idx redundant_patterns)))
- (list.drop redundancy_idx redundant_patterns)))]]
+ (list.after redundancy_idx redundant_patterns)))]]
(_.test "Will reject redundant pattern-matching."
(|> (analyse_pm redundant_branchesC)
_structure.check_fails)))
@@ -199,10 +199,10 @@
[[heterogeneousT heterogeneousC] (r.only (|>> product.left (check.subsumes? outputT) not)
_primitive.primitive)
heterogeneous_idx (|> r.nat (\ ! map (n.% (list.size exhaustive_patterns))))
- .let [heterogeneous_branchesC (list.joined (list (list.take heterogeneous_idx exhaustive_branchesC)
+ .let [heterogeneous_branchesC (list.joined (list (list.first heterogeneous_idx exhaustive_branchesC)
(list (let [[_pattern _body] (maybe.assume (list.item heterogeneous_idx exhaustive_branchesC))]
[_pattern heterogeneousC]))
- (list.drop (inc heterogeneous_idx) exhaustive_branchesC)))]]
+ (list.after (inc heterogeneous_idx) exhaustive_branchesC)))]]
(_.test "Will reject pattern-matching if the bodies of the branches do not all have the same type."
(|> (analyse_pm heterogeneous_branchesC)
_structure.check_fails)))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux
index 3213443a6..b0027b15d 100644
--- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux
+++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux
@@ -61,21 +61,21 @@
($_ _.and
(_.test "Can analyse function."
(and (|> (//type.with_type (All [a] (-> a outputT))
- (/.function _primitive.phase func_name arg_name archive.empty outputC))
+ (/.function _primitive.phase func_name arg_name archive.empty outputC))
_structure.check_succeeds)
(|> (//type.with_type (All [a] (-> a a))
- (/.function _primitive.phase func_name arg_name archive.empty g!arg))
+ (/.function _primitive.phase func_name arg_name archive.empty g!arg))
_structure.check_succeeds)))
(_.test "Generic functions can always be specialized."
(and (|> (//type.with_type (-> inputT outputT)
- (/.function _primitive.phase func_name arg_name archive.empty outputC))
+ (/.function _primitive.phase func_name arg_name archive.empty outputC))
_structure.check_succeeds)
(|> (//type.with_type (-> inputT inputT)
- (/.function _primitive.phase func_name arg_name archive.empty g!arg))
+ (/.function _primitive.phase func_name arg_name archive.empty g!arg))
_structure.check_succeeds)))
(_.test "The function's name is bound to the function's type."
(|> (//type.with_type (Rec self (-> inputT self))
- (/.function _primitive.phase func_name arg_name archive.empty (code.local_identifier func_name)))
+ (/.function _primitive.phase func_name arg_name archive.empty (code.local_identifier func_name)))
_structure.check_succeeds))
))))
@@ -89,15 +89,15 @@
inputsC (list\map product.right inputsTC)]
[outputT outputC] _primitive.primitive
.let [funcT (type.function inputsT outputT)
- partialT (type.function (list.drop partial_args inputsT) outputT)
+ partialT (type.function (list.after partial_args inputsT) outputT)
varT (#.Parameter 1)
polyT (<| (type.univ_q 1)
- (type.function (list.joined (list (list.take var_idx inputsT)
+ (type.function (list.joined (list (list.first var_idx inputsT)
(list varT)
- (list.drop (inc var_idx) inputsT))))
+ (list.after (inc var_idx) inputsT))))
varT)
poly_inputT (maybe.assume (list.item var_idx inputsT))
- partial_poly_inputsT (list.drop (inc var_idx) inputsT)
+ partial_poly_inputsT (list.after (inc var_idx) inputsT)
partial_polyT1 (<| (type.function partial_poly_inputsT)
poly_inputT)
partial_polyT2 (<| (type.univ_q 1)
@@ -110,16 +110,16 @@
(|> (/.apply _primitive.phase inputsC funcT dummy_function archive.empty (' []))
(check_apply outputT full_args)))
(_.test "Can partially apply functions."
- (|> (/.apply _primitive.phase (list.take partial_args inputsC) funcT dummy_function archive.empty (' []))
+ (|> (/.apply _primitive.phase (list.first partial_args inputsC) funcT dummy_function archive.empty (' []))
(check_apply partialT partial_args)))
(_.test "Can apply polymorphic functions."
(|> (/.apply _primitive.phase inputsC polyT dummy_function archive.empty (' []))
(check_apply poly_inputT full_args)))
(_.test "Polymorphic partial application propagates found type-vars."
- (|> (/.apply _primitive.phase (list.take (inc var_idx) inputsC) polyT dummy_function archive.empty (' []))
+ (|> (/.apply _primitive.phase (list.first (inc var_idx) inputsC) polyT dummy_function archive.empty (' []))
(check_apply partial_polyT1 (inc var_idx))))
(_.test "Polymorphic partial application preserves quantification for type-vars."
- (|> (/.apply _primitive.phase (list.take var_idx inputsC) polyT dummy_function archive.empty (' []))
+ (|> (/.apply _primitive.phase (list.first var_idx inputsC) polyT dummy_function archive.empty (' []))
(check_apply partial_polyT2 var_idx)))
))))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux
index 9aa837e50..bc4890efe 100644
--- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux
+++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux
@@ -126,9 +126,9 @@
.let [variantT (type.variant (list\map product.left primitives))
[valueT valueC] (maybe.assume (list.item choice primitives))
+size (inc size)
- +primitives (list.joined (list (list.take choice primitives)
+ +primitives (list.joined (list (list.first choice primitives)
(list [(#.Parameter 1) +valueC])
- (list.drop choice primitives)))
+ (list.after choice primitives)))
[+valueT +valueC] (maybe.assume (list.item +choice +primitives))
+variantT (type.variant (list\map product.left +primitives))]]
(<| (_.context (%.name (name_of /.sum)))
@@ -176,9 +176,9 @@
[_ +valueC] _primitive.primitive
.let [tupleT (type.tuple (list\map product.left primitives))
[singletonT singletonC] (|> primitives (list.item choice) maybe.assume)
- +primitives (list.joined (list (list.take choice primitives)
+ +primitives (list.joined (list (list.first choice primitives)
(list [(#.Parameter 1) +valueC])
- (list.drop choice primitives)))
+ (list.after choice primitives)))
+tupleT (type.tuple (list\map product.left +primitives))]]
(<| (_.context (%.name (name_of /.product)))
($_ _.and
@@ -243,9 +243,9 @@
[choiceT choiceC] (maybe.assume (list.item choice primitives))
[other_choiceT other_choiceC] (maybe.assume (list.item other_choice primitives))
monoT (type.variant primitivesT)
- polyT (|> (type.variant (list.joined (list (list.take choice primitivesT)
+ polyT (|> (type.variant (list.joined (list (list.first choice primitivesT)
(list varT)
- (list.drop (inc choice) primitivesT))))
+ (list.after (inc choice) primitivesT))))
(type.univ_q 1))
choice_tag (maybe.assume (list.item choice tags))
other_choice_tag (maybe.assume (list.item other_choice tags))]]
@@ -288,9 +288,9 @@
primitivesC (list\map product.right primitives)
monoT (#.Named [module_name type_name] (type.tuple primitivesT))
recordC (list.zipped/2 tagsC primitivesC)
- polyT (|> (type.tuple (list.joined (list (list.take choice primitivesT)
+ polyT (|> (type.tuple (list.joined (list (list.first choice primitivesT)
(list varT)
- (list.drop (inc choice) primitivesT))))
+ (list.after (inc choice) primitivesT))))
(type.univ_q 1)
(#.Named [module_name type_name]))]]
(<| (_.context (%.name (name_of /.record)))
diff --git a/stdlib/source/test/lux/world/console.lux b/stdlib/source/test/lux/world/console.lux
index 1198e56bb..5a8c28ad7 100644
--- a/stdlib/source/test/lux/world/console.lux
+++ b/stdlib/source/test/lux/world/console.lux
@@ -26,7 +26,7 @@
(def: (on_read [dead? content])
(do try.monad
[char (try.of_maybe (text.char 0 content))
- [_ content] (try.of_maybe (text.split 1 content))]
+ [_ content] (try.of_maybe (text.split_at 1 content))]
(if dead?
(exception.except ..dead [])
(in [[dead? content] char]))))