From c5b61d2f46ac19bf511197f3a537c4be0f47df33 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 27 Aug 2021 20:59:34 -0400 Subject: Updates to the Ruby compiler. --- .../the_lux_programming_language/appendix_f.md | 68 +++ documentation/bookmark/concurrency/adapton.md | 4 + licentia/source/test/licentia.lux | 2 +- lux-bootstrapper/src/lux/analyser.clj | 4 +- lux-bootstrapper/src/lux/analyser/lux.clj | 11 +- lux-bootstrapper/src/lux/compiler/jvm.clj | 2 +- lux-bootstrapper/src/lux/optimizer.clj | 41 ++ lux-jvm/source/luxc/lang/directive/jvm.lux | 2 +- lux-jvm/source/luxc/lang/host/jvm/inst.lux | 4 +- .../source/luxc/lang/translation/jvm/common.lux | 2 +- .../luxc/lang/translation/jvm/extension/common.lux | 2 +- .../luxc/lang/translation/jvm/extension/host.lux | 4 +- .../source/luxc/lang/translation/jvm/runtime.lux | 2 +- lux-jvm/source/program.lux | 4 +- lux-jvm/test/test/luxc/lang/analysis/host.jvm.lux | 2 +- lux-lua/source/program.lux | 2 +- lux-python/source/program.lux | 2 +- lux-ruby/commands.md | 4 +- lux-ruby/project.lux | 15 + lux-ruby/source/program.lux | 153 +++--- stdlib/commands.md | 4 + stdlib/project.lux | 3 + stdlib/source/documentation/lux.lux | 16 +- .../documentation/lux/control/concatenative.lux | 8 +- .../documentation/lux/control/security/policy.lux | 2 +- stdlib/source/documentation/lux/ffi.jvm.lux | 336 ++++++++++++ stdlib/source/documentation/lux/ffi.lux | 336 ------------ stdlib/source/documentation/lux/ffi.old.lux | 265 +++++++++ stdlib/source/documentation/lux/ffi.rb.lux | 46 ++ stdlib/source/documentation/lux/type/abstract.lux | 10 +- stdlib/source/library/lux.lux | 590 ++++++++++++-------- stdlib/source/library/lux/abstract/apply.lux | 8 +- stdlib/source/library/lux/abstract/codec.lux | 2 +- stdlib/source/library/lux/abstract/comonad.lux | 4 +- .../source/library/lux/abstract/comonad/cofree.lux | 4 +- stdlib/source/library/lux/abstract/enum.lux | 2 +- stdlib/source/library/lux/abstract/equivalence.lux | 3 +- stdlib/source/library/lux/abstract/functor.lux | 14 +- .../library/lux/abstract/functor/contravariant.lux | 2 +- stdlib/source/library/lux/abstract/interval.lux | 36 +- stdlib/source/library/lux/abstract/mix.lux | 4 +- stdlib/source/library/lux/abstract/monad.lux | 22 +- stdlib/source/library/lux/abstract/monad/free.lux | 6 +- .../source/library/lux/abstract/monad/indexed.lux | 6 +- stdlib/source/library/lux/abstract/monoid.lux | 2 +- stdlib/source/library/lux/abstract/predicate.lux | 10 +- .../source/library/lux/control/concatenative.lux | 77 +-- .../library/lux/control/concurrency/actor.lux | 28 +- .../library/lux/control/concurrency/async.lux | 26 +- .../library/lux/control/concurrency/atom.lux | 10 +- .../source/library/lux/control/concurrency/frp.lux | 26 +- .../library/lux/control/concurrency/semaphore.lux | 6 +- .../source/library/lux/control/concurrency/stm.lux | 34 +- stdlib/source/library/lux/control/continuation.lux | 18 +- stdlib/source/library/lux/control/exception.lux | 20 +- stdlib/source/library/lux/control/function.lux | 12 +- .../source/library/lux/control/function/memo.lux | 8 +- .../source/library/lux/control/function/mixin.lux | 14 +- stdlib/source/library/lux/control/io.lux | 4 +- stdlib/source/library/lux/control/lazy.lux | 6 +- stdlib/source/library/lux/control/maybe.lux | 14 +- stdlib/source/library/lux/control/parser.lux | 58 +- .../source/library/lux/control/parser/analysis.lux | 4 +- .../source/library/lux/control/parser/binary.lux | 14 +- stdlib/source/library/lux/control/parser/cli.lux | 10 +- stdlib/source/library/lux/control/parser/code.lux | 32 +- .../library/lux/control/parser/environment.lux | 2 +- stdlib/source/library/lux/control/parser/json.lux | 12 +- .../library/lux/control/parser/synthesis.lux | 8 +- stdlib/source/library/lux/control/parser/text.lux | 10 +- stdlib/source/library/lux/control/parser/tree.lux | 8 +- stdlib/source/library/lux/control/parser/type.lux | 20 +- stdlib/source/library/lux/control/parser/xml.lux | 8 +- stdlib/source/library/lux/control/reader.lux | 16 +- stdlib/source/library/lux/control/region.lux | 34 +- .../library/lux/control/security/capability.lux | 37 +- .../source/library/lux/control/security/policy.lux | 12 +- stdlib/source/library/lux/control/state.lux | 32 +- stdlib/source/library/lux/control/thread.lux | 22 +- stdlib/source/library/lux/control/try.lux | 17 +- stdlib/source/library/lux/control/writer.lux | 12 +- stdlib/source/library/lux/data/binary.lux | 2 +- stdlib/source/library/lux/data/bit.lux | 2 +- .../source/library/lux/data/collection/array.lux | 44 +- .../library/lux/data/collection/dictionary.lux | 68 +-- .../lux/data/collection/dictionary/ordered.lux | 42 +- .../lux/data/collection/dictionary/plist.lux | 18 +- stdlib/source/library/lux/data/collection/list.lux | 74 +-- .../source/library/lux/data/collection/queue.lux | 18 +- .../library/lux/data/collection/queue/priority.lux | 12 +- stdlib/source/library/lux/data/collection/row.lux | 52 +- .../library/lux/data/collection/sequence.lux | 20 +- stdlib/source/library/lux/data/collection/set.lux | 36 +- .../library/lux/data/collection/set/multi.lux | 36 +- .../library/lux/data/collection/set/ordered.lux | 26 +- .../source/library/lux/data/collection/stack.lux | 12 +- stdlib/source/library/lux/data/collection/tree.lux | 8 +- .../library/lux/data/collection/tree/finger.lux | 18 +- .../library/lux/data/collection/tree/zipper.lux | 52 +- stdlib/source/library/lux/data/format/binary.lux | 16 +- .../source/library/lux/data/format/css/style.lux | 2 +- stdlib/source/library/lux/data/format/html.lux | 4 +- stdlib/source/library/lux/data/format/markdown.lux | 2 +- stdlib/source/library/lux/data/format/xml.lux | 2 +- stdlib/source/library/lux/data/product.lux | 16 +- stdlib/source/library/lux/data/store.lux | 14 +- stdlib/source/library/lux/data/sum.lux | 14 +- stdlib/source/library/lux/data/text/format.lux | 6 +- stdlib/source/library/lux/data/text/regex.lux | 6 +- .../source/library/lux/data/text/unicode/block.lux | 2 +- stdlib/source/library/lux/data/trace.lux | 6 +- stdlib/source/library/lux/documentation.lux | 216 ++++++-- stdlib/source/library/lux/ffi.js.lux | 8 +- stdlib/source/library/lux/ffi.jvm.lux | 56 +- stdlib/source/library/lux/ffi.old.lux | 200 ++----- stdlib/source/library/lux/ffi.rb.lux | 19 - stdlib/source/library/lux/macro/local.lux | 2 +- stdlib/source/library/lux/macro/syntax.lux | 4 +- stdlib/source/library/lux/macro/syntax/export.lux | 2 +- stdlib/source/library/lux/math/logic/fuzzy.lux | 16 +- stdlib/source/library/lux/math/modular.lux | 20 +- stdlib/source/library/lux/math/modulus.lux | 8 +- stdlib/source/library/lux/math/number/frac.lux | 2 +- stdlib/source/library/lux/math/number/i64.lux | 22 +- stdlib/source/library/lux/math/number/int.lux | 2 +- stdlib/source/library/lux/math/random.lux | 28 +- stdlib/source/library/lux/meta.lux | 12 +- stdlib/source/library/lux/static.lux | 4 +- stdlib/source/library/lux/target/js.lux | 2 +- stdlib/source/library/lux/target/jvm/attribute.lux | 4 +- .../library/lux/target/jvm/attribute/code.lux | 6 +- .../library/lux/target/jvm/attribute/constant.lux | 4 +- stdlib/source/library/lux/target/jvm/bytecode.lux | 12 +- stdlib/source/library/lux/target/jvm/constant.lux | 4 +- .../library/lux/target/jvm/constant/pool.lux | 4 +- .../library/lux/target/jvm/encoding/signed.lux | 4 +- .../library/lux/target/jvm/encoding/unsigned.lux | 4 +- stdlib/source/library/lux/target/jvm/index.lux | 6 +- stdlib/source/library/lux/target/jvm/modifier.lux | 8 +- stdlib/source/library/lux/target/jvm/type.lux | 10 +- .../library/lux/target/jvm/type/descriptor.lux | 2 +- stdlib/source/library/lux/target/jvm/type/lux.lux | 2 +- .../library/lux/target/jvm/type/reflection.lux | 2 +- .../library/lux/target/jvm/type/signature.lux | 4 +- stdlib/source/library/lux/target/lua.lux | 4 +- stdlib/source/library/lux/target/php.lux | 4 +- stdlib/source/library/lux/target/python.lux | 10 +- stdlib/source/library/lux/target/r.lux | 2 +- stdlib/source/library/lux/target/ruby.lux | 8 +- stdlib/source/library/lux/target/scheme.lux | 4 +- .../library/lux/tool/compiler/default/init.lux | 28 +- .../library/lux/tool/compiler/default/platform.lux | 30 +- .../lux/tool/compiler/language/lux/analysis.lux | 22 +- .../compiler/language/lux/analysis/evaluation.lux | 2 +- .../lux/tool/compiler/language/lux/directive.lux | 6 +- .../lux/tool/compiler/language/lux/generation.lux | 42 +- .../compiler/language/lux/phase/analysis/case.lux | 8 +- .../language/lux/phase/analysis/module.lux | 2 +- .../compiler/language/lux/phase/analysis/scope.lux | 4 +- .../compiler/language/lux/phase/analysis/type.lux | 8 +- .../tool/compiler/language/lux/phase/extension.lux | 22 +- .../language/lux/phase/extension/analysis/jvm.lux | 2 +- .../language/lux/phase/extension/analysis/lux.lux | 2 +- .../language/lux/phase/extension/bundle.lux | 4 +- .../language/lux/phase/extension/directive/lux.lux | 32 +- .../extension/generation/common_lisp/common.lux | 2 +- .../lux/phase/extension/generation/js/common.lux | 2 +- .../lux/phase/extension/generation/jvm/common.lux | 2 +- .../lux/phase/extension/generation/jvm/host.lux | 2 +- .../lux/phase/extension/generation/lua/common.lux | 2 +- .../lux/phase/extension/generation/php/common.lux | 2 +- .../phase/extension/generation/python/common.lux | 2 +- .../lux/phase/extension/generation/r/common.lux | 2 +- .../lux/phase/extension/generation/ruby/common.lux | 88 ++- .../phase/extension/generation/scheme/common.lux | 2 +- .../language/lux/phase/generation/extension.lux | 4 +- .../language/lux/phase/generation/jvm/function.lux | 2 +- .../language/lux/phase/generation/jvm/runtime.lux | 2 +- .../language/lux/phase/generation/reference.lux | 8 +- .../language/lux/phase/generation/ruby.lux | 39 +- .../language/lux/phase/generation/ruby/case.lux | 5 +- .../lux/phase/generation/ruby/function.lux | 2 +- .../lux/phase/generation/ruby/structure.lux | 2 +- .../compiler/language/lux/phase/synthesis/case.lux | 8 +- .../language/lux/phase/synthesis/variable.lux | 2 +- .../lux/tool/compiler/language/lux/synthesis.lux | 26 +- .../lux/tool/compiler/meta/archive/document.lux | 10 +- .../library/lux/tool/compiler/meta/archive/key.lux | 2 +- .../source/library/lux/tool/compiler/meta/io.lux | 2 +- .../library/lux/tool/compiler/meta/io/archive.lux | 18 +- .../library/lux/tool/compiler/meta/io/context.lux | 4 +- .../lux/tool/compiler/meta/packager/script.lux | 4 +- stdlib/source/library/lux/tool/compiler/phase.lux | 24 +- stdlib/source/library/lux/tool/interpreter.lux | 16 +- stdlib/source/library/lux/type.lux | 32 +- stdlib/source/library/lux/type/abstract.lux | 8 +- stdlib/source/library/lux/type/check.lux | 16 +- stdlib/source/library/lux/type/implicit.lux | 2 +- stdlib/source/library/lux/type/quotient.lux | 10 +- stdlib/source/library/lux/type/refinement.lux | 12 +- stdlib/source/library/lux/type/resource.lux | 24 +- stdlib/source/library/lux/type/unit.lux | 20 +- stdlib/source/library/lux/world/console.lux | 4 +- stdlib/source/library/lux/world/db/jdbc.lux | 6 +- stdlib/source/library/lux/world/db/jdbc/input.lux | 4 +- stdlib/source/library/lux/world/db/jdbc/output.lux | 6 +- stdlib/source/library/lux/world/db/sql.lux | 26 +- stdlib/source/library/lux/world/file.lux | 20 +- stdlib/source/library/lux/world/file/watch.lux | 4 +- .../source/library/lux/world/net/http/client.lux | 2 +- .../source/library/lux/world/net/http/request.lux | 8 +- stdlib/source/library/lux/world/program.lux | 12 +- .../source/library/lux/world/service/journal.lux | 2 +- stdlib/source/library/lux/world/shell.lux | 8 +- stdlib/source/poly/lux/abstract/equivalence.lux | 2 +- stdlib/source/poly/lux/abstract/functor.lux | 5 +- stdlib/source/poly/lux/data/format/json.lux | 20 +- stdlib/source/program/aedifex.lux | 4 +- stdlib/source/program/aedifex/command/auto.lux | 2 +- stdlib/source/program/aedifex/command/build.lux | 6 +- .../program/aedifex/dependency/deployment.lux | 2 +- .../program/aedifex/dependency/resolution.lux | 2 +- stdlib/source/program/aedifex/format.lux | 8 +- stdlib/source/program/aedifex/hash.lux | 6 +- stdlib/source/program/aedifex/input.lux | 2 +- stdlib/source/program/aedifex/parser.lux | 4 +- stdlib/source/program/aedifex/repository.lux | 2 +- .../source/program/aedifex/repository/remote.lux | 2 +- stdlib/source/program/compositor.lux | 6 +- stdlib/source/program/compositor/import.lux | 2 +- stdlib/source/program/scriptum.lux | 606 ++++++++++----------- stdlib/source/specification/compositor.lux | 2 +- stdlib/source/specification/compositor/common.lux | 4 +- stdlib/source/specification/lux/abstract/apply.lux | 10 +- stdlib/source/specification/lux/abstract/codec.lux | 2 +- .../source/specification/lux/abstract/comonad.lux | 8 +- stdlib/source/specification/lux/abstract/enum.lux | 2 +- .../specification/lux/abstract/equivalence.lux | 2 +- .../source/specification/lux/abstract/functor.lux | 12 +- .../lux/abstract/functor/contravariant.lux | 4 +- stdlib/source/specification/lux/abstract/hash.lux | 2 +- .../source/specification/lux/abstract/interval.lux | 2 +- stdlib/source/specification/lux/abstract/mix.lux | 2 +- stdlib/source/specification/lux/abstract/monad.lux | 8 +- .../source/specification/lux/abstract/monoid.lux | 2 +- stdlib/source/specification/lux/abstract/order.lux | 4 +- stdlib/source/test/aedifex/hash.lux | 2 +- stdlib/source/test/aedifex/parser.lux | 4 +- stdlib/source/test/aedifex/profile.lux | 6 +- stdlib/source/test/lux.lux | 46 +- stdlib/source/test/lux/abstract/comonad/cofree.lux | 2 +- stdlib/source/test/lux/abstract/monad/free.lux | 2 +- .../source/test/lux/control/concurrency/actor.lux | 2 +- stdlib/source/test/lux/control/concurrency/frp.lux | 2 +- stdlib/source/test/lux/control/continuation.lux | 2 +- stdlib/source/test/lux/control/function/memo.lux | 2 +- stdlib/source/test/lux/control/lazy.lux | 2 +- stdlib/source/test/lux/control/parser.lux | 12 +- stdlib/source/test/lux/control/parser/code.lux | 18 + stdlib/source/test/lux/control/parser/text.lux | 4 +- stdlib/source/test/lux/control/reader.lux | 4 +- stdlib/source/test/lux/control/region.lux | 14 +- stdlib/source/test/lux/control/remember.lux | 2 +- stdlib/source/test/lux/control/security/policy.lux | 10 +- stdlib/source/test/lux/control/state.lux | 4 +- stdlib/source/test/lux/control/thread.lux | 10 +- stdlib/source/test/lux/control/try.lux | 2 +- stdlib/source/test/lux/control/writer.lux | 4 +- stdlib/source/test/lux/data/binary.lux | 2 +- .../lux/data/collection/dictionary/ordered.lux | 2 +- .../test/lux/data/collection/dictionary/plist.lux | 2 +- stdlib/source/test/lux/data/collection/row.lux | 2 +- .../source/test/lux/data/collection/sequence.lux | 4 +- .../source/test/lux/data/collection/set/multi.lux | 2 +- .../test/lux/data/collection/set/ordered.lux | 2 +- stdlib/source/test/lux/data/collection/tree.lux | 2 +- stdlib/source/test/lux/data/text/format.lux | 6 +- stdlib/source/test/lux/data/text/regex.lux | 2 +- stdlib/source/test/lux/ffi.js.lux | 4 +- stdlib/source/test/lux/ffi.lua.lux | 4 +- stdlib/source/test/lux/ffi.py.lux | 4 +- stdlib/source/test/lux/ffi.rb.lux | 2 +- stdlib/source/test/lux/locale/language.lux | 8 +- stdlib/source/test/lux/locale/territory.lux | 8 +- stdlib/source/test/lux/macro/code.lux | 4 +- stdlib/source/test/lux/math/modular.lux | 2 +- stdlib/source/test/lux/math/modulus.lux | 2 +- stdlib/source/test/lux/math/number/i64.lux | 2 +- stdlib/source/test/lux/meta/annotation.lux | 4 +- stdlib/source/test/lux/static.lux | 98 ++-- stdlib/source/test/lux/target/jvm.lux | 10 +- .../language/lux/phase/analysis/function.lux | 4 +- .../language/lux/phase/analysis/structure.lux | 4 +- .../compiler/language/lux/phase/synthesis/case.lux | 2 +- stdlib/source/test/lux/type/check.lux | 54 +- stdlib/source/test/lux/type/poly/json.lux | 2 +- stdlib/source/test/lux/type/quotient.lux | 2 +- stdlib/source/test/lux/type/variance.lux | 2 +- 298 files changed, 3312 insertions(+), 2668 deletions(-) create mode 100644 documentation/book/the_lux_programming_language/appendix_f.md create mode 100644 documentation/bookmark/concurrency/adapton.md create mode 100644 lux-ruby/project.lux create mode 100644 stdlib/source/documentation/lux/ffi.jvm.lux delete mode 100644 stdlib/source/documentation/lux/ffi.lux create mode 100644 stdlib/source/documentation/lux/ffi.old.lux create mode 100644 stdlib/source/documentation/lux/ffi.rb.lux diff --git a/documentation/book/the_lux_programming_language/appendix_f.md b/documentation/book/the_lux_programming_language/appendix_f.md new file mode 100644 index 000000000..b977623a8 --- /dev/null +++ b/documentation/book/the_lux_programming_language/appendix_f.md @@ -0,0 +1,68 @@ +# Appendix F: Implicit polymorphism + +If you've used Lux's interfaces and implementations already (with the `\` macro), you've probably noticed that you need to pass around the specific implementations you need every time you want to call some interface's method, or access some constant value. + +That can become tiresome if you need to do it all the time, and specially if you come from languages that do method-selection for you automatically. + +Object-oriented languages do polymorphism in an easy way, because they link objects to the method table of their associated classes, and when you call a method on an object, the run-time system can figure out where the code that needs to be run lies within the program's memory. + +Languages with type-classes, such as Haskell, perform that look-up at compile-time, by using the type-information present in the compilation context to figure out which implementation (or _instance_) of a type-class is suitable to each particular circumstance. + +Lux, on the other hand, forces you to be specific about the implementations that you're going to use. + +While that gives you a level of power and flexibility you wouldn't otherwise have in other languages, it also introduces the problem that when what you want doesn't warrant that level of power, you have to pay the tax it involves nonetheless. + +But, that sounds like a raw deal. + +Why do you have to pay for something you're not taking advantage of? + +Clearly, there is an asymmetry here. + +It is a feature that is most useful in the few instances when you want full power. +At any other point, it's a hindrance. + +Well... there is an alternative. + +The Lux Standard Library includes a module called `library/lux/type/implicit`, which provides a macro called `\\`, that serves as an easier-to-use alternative to the `\` macro. + +What it does is that instead of requiring the implementation you want to use, it only requires the name of the function you want to call and the arguments. + +Then, at compile-time, it does some type-checking and some look-ups and selects an implementation for you that will satisfy those requirements. + +That implementation can come from the local-var environment, from the definitions in your own module, or even from the exported definitions of the modules you're importing. + +That way, you can use `\` whenever you need precision and power, and use `\\` whenever you're doing more lightweight programming. + +Fantastic! + +This is how you'd use it: + +``` +... Equality for nats +(\ nat.equivalence = x y) +## vs +(\\ = x y) +``` + +``` +... Equality for lists of nats +(\ (list.equivalence nat.equivalence) = + (list.indices 10) + (list.indices 10)) +... vs +(\\ = (list.indices 10) (list.indices 10)) +``` + +``` +... Functor mapping +(\ list.functor each nat.inc (list.indices 10)) +... vs +(\\ each nat.inc (list.indices 10)) +``` + +--- + +Thanks to implicit polymorphism, you don't have to choose between power and ease of use. + +Just do a static-import of the `library/lux/type/implicit` module, and you'll get the `\\` available and ready for action. + diff --git a/documentation/bookmark/concurrency/adapton.md b/documentation/bookmark/concurrency/adapton.md new file mode 100644 index 000000000..71f044303 --- /dev/null +++ b/documentation/bookmark/concurrency/adapton.md @@ -0,0 +1,4 @@ +# Reference + +1. [Adapton: Programming Language Abstractions for Incremental Computation](http://adapton.org/) + diff --git a/licentia/source/test/licentia.lux b/licentia/source/test/licentia.lux index ec8fc04a9..e9178a996 100644 --- a/licentia/source/test/licentia.lux +++ b/licentia/source/test/licentia.lux @@ -107,7 +107,7 @@ (random.ascii 10)) (def: (variable_list max_size gen_element) - (All [a] (-> Nat (Random a) (Random (List a)))) + (All (_ a) (-> Nat (Random a) (Random (List a)))) (do {! random.monad} [amount (\ ! each (n.% (n.max 1 max_size)) random.nat)] diff --git a/lux-bootstrapper/src/lux/analyser.clj b/lux-bootstrapper/src/lux/analyser.clj index ae16eb42c..e139e085f 100644 --- a/lux-bootstrapper/src/lux/analyser.clj +++ b/lux-bootstrapper/src/lux/analyser.clj @@ -114,7 +114,7 @@ (&/$Item ?value (&/$End))) parameters] (&/with-analysis-meta location exo-type - (&&lux/analyse-type-check analyse eval! exo-type ?type ?value))) + (&&lux/analyse-type-check analyse optimize eval! exo-type ?type ?value))) "lux type check type" (|let [(&/$Item ?value (&/$End)) parameters] @@ -125,7 +125,7 @@ (&/$Item ?value (&/$End))) parameters] (&/with-analysis-meta location exo-type - (&&lux/analyse-type-as analyse eval! exo-type ?type ?value))) + (&&lux/analyse-type-as analyse optimize eval! exo-type ?type ?value))) "lux def" (|let [(&/$Item [_ (&/$Identifier "" ?name)] diff --git a/lux-bootstrapper/src/lux/analyser/lux.clj b/lux-bootstrapper/src/lux/analyser/lux.clj index 857f65e00..769b85e30 100644 --- a/lux-bootstrapper/src/lux/analyser/lux.clj +++ b/lux-bootstrapper/src/lux/analyser/lux.clj @@ -705,19 +705,18 @@ (&&/|meta new-type _location _analysis))) -(defn analyse-type-check [analyse eval! exo-type ?type ?value] +(defn analyse-type-check [analyse optimize eval! exo-type ?type ?value] (|do [=type (&&/analyse-1 analyse &type/Type ?type) - ==type (eval! =type) + ==type (eval! (optimize =type)) _ (&type/check exo-type ==type) =value (&&/analyse-1 analyse ==type ?value) _location &/location] (return (&/|list (&&/|meta ==type _location - (&&/$ann =value =type) - ))))) + (&&/$ann =value =type)))))) -(defn analyse-type-as [analyse eval! exo-type ?type ?value] +(defn analyse-type-as [analyse optimize eval! exo-type ?type ?value] (|do [=type (&&/analyse-1 analyse &type/Type ?type) - ==type (eval! =type) + ==type (eval! (optimize =type)) _ (&type/check exo-type ==type) =value (&&/analyse-1+ analyse ?value)] (return (&/|list (coerce ==type =value))))) diff --git a/lux-bootstrapper/src/lux/compiler/jvm.clj b/lux-bootstrapper/src/lux/compiler/jvm.clj index d5c490a97..7a547dcd3 100644 --- a/lux-bootstrapper/src/lux/compiler/jvm.clj +++ b/lux-bootstrapper/src/lux/compiler/jvm.clj @@ -113,7 +113,7 @@ (&&proc-common/compile-proc (partial compile-expression $begin) ?proc-category ?proc-name ?args special-args)) _ - (assert false (prn-str 'compile-expression (&/adt->text syntax))) + (assert false (prn-str 'compile-expression (&o/show syntax))) )) )) diff --git a/lux-bootstrapper/src/lux/optimizer.clj b/lux-bootstrapper/src/lux/optimizer.clj index 5910d98db..b8095fa22 100644 --- a/lux-bootstrapper/src/lux/optimizer.clj +++ b/lux-bootstrapper/src/lux/optimizer.clj @@ -1161,3 +1161,44 @@ [analysis] (->> analysis (pass-0 true))) + +(defn show [synthesis] + (|let [[[?type [_file-name _line _]] ?form] synthesis] + (|case ?form + ;; 0 + ($bit it) `(~'$bit ~it) + ;; 1 + ($nat it) `(~'$nat ~it) + ;; 2 + ($int it) `(~'$int ~it) + ;; 3 + ($rev it) `(~'$rev ~it) + ;; 4 + ($frac it) `(~'$frac ~it) + ;; 5 + ($text it) `(~'$text ~it) + ;; 6 + ($variant idx is-last? value) `(~'$variant ~idx ~is-last? ~(show value)) + ;; 7 + ($tuple it) `[~@(&/->seq (&/|map show it))] + ;; 8 + ($apply func args) `(~(show func) ~@(&/->seq (&/|map show args))) + ;; 9 + ($case ?value [?pm ?bodies]) `(~'$case ~(show ?value) [?pm ?bodies]) + ;; 10 + ($function _register-offset arity scope captured body*) `(~'$function ~_register-offset ~arity ~(show body*)) + ;; 11 + ($ann value-expr type-expr) `(~'$ann ~(show value-expr) ~(show type-expr)) + ;; 12 + ($var (&/$Local ?idx)) `(~'$var ~?idx) + ;; ("captured" 3) + ;; ("proc" 3) + ;; ("loop" 3) ;; {register-offset Int, inits (List Optimized), body Optimized} + ;; ("iter" 2) ;; {register-offset Int, vals (List Optimized)} + ($let value register body) `(~'$let ~(show value) ~register ~(show body)) + ;; ("record-get" 2) + ($if test then else) `(~'$if ~(show test) ~(show then) ~(show else)) + + _ + (&/adt->text synthesis) + ))) diff --git a/lux-jvm/source/luxc/lang/directive/jvm.lux b/lux-jvm/source/luxc/lang/directive/jvm.lux index b52d4b63e..22715276b 100644 --- a/lux-jvm/source/luxc/lang/directive/jvm.lux +++ b/lux-jvm/source/luxc/lang/directive/jvm.lux @@ -581,7 +581,7 @@ (phase.except extension.invalid_syntax [extension_name %.code inputsC+])))) (def: .public (custom [parser handler]) - (All [i] + (All (_ i) (-> [(Parser i) (-> Text ..Phase Archive i (..Operation Requirements))] ..Handler)) diff --git a/lux-jvm/source/luxc/lang/host/jvm/inst.lux b/lux-jvm/source/luxc/lang/host/jvm/inst.lux index 2dac20c54..296baf8d4 100644 --- a/lux-jvm/source/luxc/lang/host/jvm/inst.lux +++ b/lux-jvm/source/luxc/lang/host/jvm/inst.lux @@ -150,12 +150,12 @@ ... [Insts] (def: .public make_label - (All [s] (Operation s org/objectweb/asm/Label)) + (All (_ s) (Operation s org/objectweb/asm/Label)) (function (_ state) (#try.Success [state (org/objectweb/asm/Label::new)]))) (def: .public (with_label action) - (All [a] (-> (-> org/objectweb/asm/Label a) a)) + (All (_ a) (-> (-> org/objectweb/asm/Label a) a)) (action (org/objectweb/asm/Label::new))) (template [ ] diff --git a/lux-jvm/source/luxc/lang/translation/jvm/common.lux b/lux-jvm/source/luxc/lang/translation/jvm/common.lux index cfdadecb5..f1dc4ae24 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/common.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/common.lux @@ -29,7 +29,7 @@ ) ... (def: .public (with-artifacts action) -... (All [a] (-> (Meta a) (Meta [Artifacts a]))) +... (All (_ a) (-> (Meta a) (Meta [Artifacts a]))) ... (function (_ state) ... (case (action (revised@ #.host ... (|>> (:coerce Host) diff --git a/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux b/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux index 96fdefe31..5de412695 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux @@ -42,7 +42,7 @@ ["." runtime]]) (def: .public (custom [parser handler]) - (All [s] + (All (_ s) (-> [(Parser s) (-> Text Phase Archive s (Operation Inst))] Handler)) 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 826c45f1a..e132e9eb9 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux @@ -80,11 +80,11 @@ ) (def: signature - (All [a] (-> (Type a) Text)) + (All (_ a) (-> (Type a) Text)) (|>> type.signature signature.signature)) (def: descriptor - (All [a] (-> (Type a) Text)) + (All (_ a) (-> (Type a) Text)) (|>> type.descriptor descriptor.descriptor)) (exception: .public (not_an_object_array {arrayJT (Type Array)}) diff --git a/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux b/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux index 0e758f149..5b1743157 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux @@ -332,7 +332,7 @@ ))) (def: reflection - (All [category] + (All (_ category) (-> (Type (<| Return' Value' category)) Text)) (|>> type.reflection reflection.reflection)) diff --git a/lux-jvm/source/program.lux b/lux-jvm/source/program.lux index 242d0553e..ac4da1255 100644 --- a/lux-jvm/source/program.lux +++ b/lux-jvm/source/program.lux @@ -134,7 +134,7 @@ java/lang/Object (jvm/type.class "java.lang.Object" (list)) (jvm/type.array java/lang/Object) - jvm_type (: (All [c] (-> (jvm/type.Type c) Synthesis)) + jvm_type (: (All (_ c) (-> (jvm/type.Type c) Synthesis)) (|>> jvm/type.format $.text)) class_type (: (-> Text Synthesis) @@ -170,7 +170,7 @@ (class_type "java.lang.Class") object (list))))) - input (: (All [c] (-> (jvm/type.Type c) Synthesis Synthesis)) + input (: (All (_ c) (-> (jvm/type.Type c) Synthesis Synthesis)) (function (_ value_type value) ($.tuple (list (jvm_type value_type) value)))) diff --git a/lux-jvm/test/test/luxc/lang/analysis/host.jvm.lux b/lux-jvm/test/test/luxc/lang/analysis/host.jvm.lux index 5d1fd5d7d..4858d9359 100644 --- a/lux-jvm/test/test/luxc/lang/analysis/host.jvm.lux +++ b/lux-jvm/test/test/luxc/lang/analysis/host.jvm.lux @@ -545,5 +545,5 @@ (success' (` ("jvm member invoke constructor" "java.util.ArrayList" ["int" ("jvm object cast" (~ intC))])) - (All [a] (#.Primitive "java.util.ArrayList" (list a))))) + (All (_ a) (#.Primitive "java.util.ArrayList" (list a))))) ))) diff --git a/lux-lua/source/program.lux b/lux-lua/source/program.lux index c5c03f32a..0018181cc 100644 --- a/lux-lua/source/program.lux +++ b/lux-lua/source/program.lux @@ -644,7 +644,7 @@ (net/sandius/rembulan/runtime/ReturnBuffer::setTo (:as java/lang/Object value)))) (def: (host_phase partial_application phase) - (All [s i o] + (All (_ s i o) (-> (List Any) (Phase [extension.Bundle s] i o) java/lang/Object)) (ffi.object [] net/sandius/rembulan/runtime/LuaFunction [] diff --git a/lux-python/source/program.lux b/lux-python/source/program.lux index bf154a7e7..8049d94a6 100644 --- a/lux-python/source/program.lux +++ b/lux-python/source/program.lux @@ -357,7 +357,7 @@ ["Arity" (%.nat arity)])) (def: (host_phase partial_application phase) - (All [s i o] + (All (_ s i o) (-> (List Any) (Phase [extension.Bundle s] i o) org/python/core/PyObject)) (<| (ffi.:as org/python/core/PyObject) diff --git a/lux-ruby/commands.md b/lux-ruby/commands.md index 2fb1588b0..2b2be3a06 100644 --- a/lux-ruby/commands.md +++ b/lux-ruby/commands.md @@ -26,7 +26,7 @@ cd ~/lux/lux-ruby/ \ ## Compile Lux's Standard Library's tests using a JVM-based compiler. cd ~/lux/stdlib/ \ && lein clean \ -&& java -jar ~/lux/lux-ruby/jvm_based_compiler.jar build --source ~/lux/stdlib/source --target ~/lux/stdlib/target --module test/lux \ +&& java -jar ~/lux/lux-ruby/target/program.jar build --source ~/lux/stdlib/source --target ~/lux/stdlib/target --module test/lux \ && RUBY_THREAD_VM_STACK_SIZE=15700000 ruby ~/lux/stdlib/target/program.rb ``` @@ -34,6 +34,6 @@ cd ~/lux/stdlib/ \ ``` cd ~/lux/lux-ruby/ \ -&& mvn install:install-file -Dfile=jvm_based_compiler.jar -DgroupId=com.github.luxlang -DartifactId=lux-ruby -Dversion=0.6.0-SNAPSHOT -Dpackaging=jar +&& mvn install:install-file -Dfile=target/program.jar -DgroupId=com.github.luxlang -DartifactId=lux-ruby -Dversion=0.6.0-SNAPSHOT -Dpackaging=jar ``` diff --git a/lux-ruby/project.lux b/lux-ruby/project.lux new file mode 100644 index 000000000..99f794bc8 --- /dev/null +++ b/lux-ruby/project.lux @@ -0,0 +1,15 @@ +{"" + {#identity ["com.github.luxlang" "lux-ruby" "0.6.0-SNAPSHOT"] + #description "A Ruby compiler for Lux." + + #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"] + #dependencies [["com.github.luxlang" "stdlib" "0.6.0-SNAPSHOT" "tar"] + ["org.jruby" "jruby-complete" "9.2.15.0" "jar"]] + + #program "program"}} diff --git a/lux-ruby/source/program.lux b/lux-ruby/source/program.lux index 50253a545..a138f0c10 100644 --- a/lux-ruby/source/program.lux +++ b/lux-ruby/source/program.lux @@ -125,23 +125,19 @@ (first [org/jruby/runtime/ThreadContext] org/jruby/runtime/builtin/IRubyObject) (size [org/jruby/runtime/ThreadContext] org/jruby/runtime/builtin/IRubyObject)]) -(template [] - [(ffi.interface: - (getValue [] java/lang/Object)) +(ffi.interface: StructureValue + (getValue [] java/lang/Object)) - (`` (import: (~~ (template.identifier ["program/" ])) - ["#::." - (getValue [] java/lang/Object)]))] - - [StructureValue] - ) +(import: program/StructureValue + ["#::." + (getValue [] java/lang/Object)]) (syntax: (method_inputs [input_classes (.tuple (<>.some .any))]) (monad.each meta.monad (function (_ class) (do meta.monad [var (macro.identifier "input")] - (wrap (code.record (list [var class]))))) + (in (code.record (list [var class]))))) input_classes)) (import: org/jruby/runtime/JavaSites$CheckedSites) @@ -164,13 +160,13 @@ (org/jruby/embed/ScriptingContainer::new)) (template: (!ruby_runtime) - (|> ..interpreter - org/jruby/embed/ScriptingContainer::getProvider - org/jruby/embed/internal/LocalContextProvider::getRuntime)) + [(|> ..interpreter + org/jruby/embed/ScriptingContainer::getProvider + org/jruby/embed/internal/LocalContextProvider::getRuntime)]) (template: (!ruby_thread_context) - (|> (!ruby_runtime) - org/jruby/Ruby::getCurrentContext)) + [(|> (!ruby_runtime) + org/jruby/Ruby::getCurrentContext)]) (def: initial_ruby_runtime (!ruby_runtime)) @@ -239,7 +235,8 @@ (-> Translator org/jruby/RubyArray (Try Any)) (let [size (:as Nat (org/jruby/RubyArray::getLength host_object))] (loop [idx 0 - output (:as (Array Any) (array.new size))] + output (: (Array Any) + (array.empty size))] (if (n.< size idx) (case (org/jruby/RubyArray::get (.int idx) host_object) #.None @@ -261,31 +258,31 @@ (def: (read_variant read host_object) (-> Translator org/jruby/RubyHash (Try Any)) - (case [(org/jruby/RubyHash::get runtime.variant_tag_field host_object) - (org/jruby/RubyHash::get runtime.variant_flag_field host_object) - (org/jruby/RubyHash::get runtime.variant_value_field host_object)] + (case [(org/jruby/RubyHash::get (:as java/lang/String runtime.variant_tag_field) host_object) + (org/jruby/RubyHash::get (:as java/lang/String runtime.variant_flag_field) host_object) + (org/jruby/RubyHash::get (:as java/lang/String runtime.variant_value_field) host_object)] (^multi [(#.Some tag) ?flag (#.Some value)] {(read value) - (#.Some value)}) - (#try.Success [(java/lang/Long::intValue (:as java/lang/Long tag)) - (: Any - (case ?flag - (#.Some _) - "" + (#try.Success value)}) + (#try.Success [(:as Any (java/lang/Long::intValue (:as java/lang/Long tag))) + (:as Any + (case ?flag + (#.Some _) + "" - #.None - (ffi.null))) - value]) + #.None + (ffi.null))) + (:as Any value)]) _ - (exception.throw ..unknown_kind_of_object [host_object]))) + (exception.except ..unknown_kind_of_object [(:as java/lang/Object host_object)]))) (exception: .public nil_has_no_lux_representation) (def: (read host_object) Translator (`` (<| (if (ffi.null? host_object) - (exception.throw ..nil_has_no_lux_representation [])) + (exception.except ..nil_has_no_lux_representation [])) (~~ (template [ ] [(case (ffi.check host_object) (#.Some typed_object) @@ -304,7 +301,7 @@ [org/jruby/RubyProc [#try.Success]] [org/jruby/java/proxies/JavaProxy [org/jruby/java/proxies/JavaProxy::getObject #try.Success]] )) - (exception.throw ..unknown_kind_of_object [host_object]) + (exception.except ..unknown_kind_of_object [host_object]) ))) (def: ruby_nil @@ -388,7 +385,7 @@ (wrapped_lux_value lux_structure value) #.None - (panic! (exception.construct ..invalid_tuple_access [(org/jruby/RubyFixnum::getLongValue member)]))) + (panic! (exception.error ..invalid_tuple_access [(org/jruby/RubyFixnum::getLongValue member)]))) #.None) (case (ffi.check org/jruby/RubyString member) @@ -416,10 +413,10 @@ (wrapped_lux_value lux_structure value) #.None - (panic! (exception.construct ..nil_has_no_lux_representation []))) + (panic! (exception.error ..nil_has_no_lux_representation []))) field - (panic! (exception.construct ..invalid_variant_access [field]))) + (panic! (exception.error ..invalid_variant_access [field]))) #.None) (case (ffi.check org/jruby/RubyRange member) @@ -432,10 +429,10 @@ (lux_structure (java/util/Arrays::copyOfRange value first (i.+ first size)))) _ - (panic! (exception.construct ..invalid_index (:as java/lang/Object member)))) + (panic! (exception.error ..invalid_index (:as java/lang/Object member)))) #.None) - (panic! (exception.construct ..invalid_index (:as java/lang/Object member)))))))) + (panic! (exception.error ..invalid_index (:as java/lang/Object member)))))))) (def: (lux_wrapper_equality value) (-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod) @@ -532,7 +529,7 @@ (org/jruby/RubyBoolean::newBoolean ..initial_ruby_runtime)) #.None - (panic! (exception.construct ..invalid_operation ["respond_to?"])))))) + (panic! (exception.error ..invalid_operation ["respond_to?"])))))) (exception: (unknown_method {method Text}) (exception.report @@ -565,7 +562,7 @@ (org/jruby/runtime/callsite/CacheEntry::new (..lux_wrapper_respond_to? value) 4) _ - (panic! (exception.construct ..unknown_method [(:as Text method)])))))] + (panic! (exception.error ..unknown_method [(:as Text method)])))))] (org/jruby/java/proxies/JavaProxy::new ..initial_ruby_runtime meta_class (:as java/lang/Object value)))) (exception: (cannot_apply_a_non_function {object java/lang/Object}) @@ -607,7 +604,7 @@ (#try.Failure error)) #.None - (exception.throw ..cannot_apply_a_non_function [(:as java/lang/Object macro)]))) + (exception.except ..cannot_apply_a_non_function [(:as java/lang/Object macro)]))) (def: host (IO (Host _.Expression _.Statement)) @@ -615,8 +612,8 @@ (function (_ code) (do try.monad [output (org/jruby/embed/ScriptingContainer::runScriptlet (_.code code) ..interpreter)] - (..read (maybe.default (:as java/lang/Object []) - output)))))] + (..read (maybe.else (:as java/lang/Object []) + output)))))] (: (Host _.Expression _.Statement) (implementation (def: (evaluate! context code) @@ -625,13 +622,13 @@ (def: execute! run!) (def: (define! context custom input) - (let [global (maybe.default (reference.artifact context) - custom) + (let [global (maybe.else (reference.artifact context) + custom) @global (_.global global)] (do try.monad - [#let [definition (_.set (list @global) input)] + [.let [definition (_.set (list @global) input)] value (run! definition)] - (wrap [global value definition])))) + (in [global value definition])))) (def: (ingest context content) (|> content @@ -687,7 +684,7 @@ ..dummy_static_scope))) (def: (host_phase partial_application phase) - (All [s i o] + (All (_ s i o) (-> (List Any) (Phase [extension.Bundle s] i o) org/jruby/RubyProc)) (let [block (ffi.object [] org/jruby/runtime/Block [] @@ -700,7 +697,7 @@ {_ org/jruby/runtime/Block}) org/jruby/runtime/builtin/IRubyObject (<| try.trusted - (let [inputs (array.to_list inputs)]) + (let [inputs (array.list #.None inputs)]) (case inputs (^ (list)) (#try.Success (host_phase partial_application phase)) @@ -710,19 +707,19 @@ [input/0 (..read (:as java/lang/Object input/0))] (case partial_application (^ (list)) - (wrap (host_phase (list input/0) phase)) + (in (host_phase (list input/0) phase)) (^ (list partial/0)) - (wrap (host_phase (list partial/0 input/0) phase)) + (in (host_phase (list partial/0 input/0) phase)) (^ (list partial/0 partial/1)) - (wrap (..to_host ((:as (-> Any Any Any Any) phase) - partial/0 - partial/1 - input/0))) + (in (..to_host ((:as (-> Any Any Any Any) phase) + partial/0 + partial/1 + input/0))) _ - (exception.throw ..invaid_phase_application [partial_application (list.size inputs)]))) + (exception.except ..invaid_phase_application [partial_application (list.size inputs)]))) (^ (list input/0 input/1)) (do try.monad @@ -730,16 +727,16 @@ input/1 (..read (:as java/lang/Object input/1))] (case partial_application (^ (list)) - (wrap (host_phase (list input/0 input/1) phase)) + (in (host_phase (list input/0 input/1) phase)) (^ (list partial/0)) - (wrap (..to_host ((:as (-> Any Any Any Any) phase) - partial/0 - input/0 - input/1))) + (in (..to_host ((:as (-> Any Any Any Any) phase) + partial/0 + input/0 + input/1))) _ - (exception.throw ..invaid_phase_application [partial_application (list.size inputs)]))) + (exception.except ..invaid_phase_application [partial_application (list.size inputs)]))) (^ (list input/0 input/1 input/2)) (do try.monad @@ -748,20 +745,20 @@ input/2 (..read (:as java/lang/Object input/2))] (case partial_application (^ (list)) - (wrap (..to_host ((:as (-> Any Any Any Any) phase) - input/0 - input/1 - input/2))) + (in (..to_host ((:as (-> Any Any Any Any) phase) + input/0 + input/1 + input/2))) _ - (exception.throw ..invaid_phase_application [partial_application (list.size inputs)]))) + (exception.except ..invaid_phase_application [partial_application (list.size inputs)]))) _ - (exception.throw ..invaid_phase_application [partial_application (list.size inputs)])))))] + (exception.except ..invaid_phase_application [partial_application (list.size inputs)])))))] (org/jruby/RubyProc::newProc (!ruby_runtime) block ..proc_type))) (def: (extender phase_wrapper) - (-> platform.Phase_Wrapper Extender) + (-> phase.Wrapper Extender) ... TODO: Stop relying on coercions ASAP. (<| (:as Extender) (function (@self handler)) @@ -788,27 +785,27 @@ @.ruby (def: (extender phase_wrapper handler) - (-> platform.Phase_Wrapper Extender) + (-> phase.Wrapper Extender) (:expected handler))}) (def: (phase_wrapper archive) - (-> Archive (runtime.Operation platform.Phase_Wrapper)) + (-> Archive (runtime.Operation phase.Wrapper)) (do phase.monad [] - (wrap (:as platform.Phase_Wrapper - (for {@.old (..host_phase (list)) - @.ruby (|>>)}))))) + (in (:as phase.Wrapper + (for {@.old (..host_phase (list)) + @.ruby (|>>)}))))) (def: platform (IO (Platform Register _.Expression _.Statement)) (do io.monad [host ..host] - (wrap {#platform.&file_system (file.async file.default) - #platform.host host - #platform.phase ruby.generate - #platform.runtime runtime.generate - #platform.phase_wrapper ..phase_wrapper - #platform.write (|>> _.code (\ utf8.codec encoded))}))) + (in {#platform.&file_system (file.async file.default) + #platform.host host + #platform.phase ruby.generate + #platform.runtime runtime.generate + #platform.phase_wrapper ..phase_wrapper + #platform.write (|>> _.code (\ utf8.codec encoded))}))) (def: (program context program) (Program _.Expression _.Statement) diff --git a/stdlib/commands.md b/stdlib/commands.md index 21f6dc09e..5bee8823d 100644 --- a/stdlib/commands.md +++ b/stdlib/commands.md @@ -18,6 +18,10 @@ cd ~/lux/stdlib/ \ cd ~/lux/stdlib/ \ && lux clean \ && lux with lua with bibliotheca auto test + +cd ~/lux/stdlib/ \ +&& lux clean \ +&& lux with ruby with bibliotheca auto test ``` ## Deploy diff --git a/stdlib/project.lux b/stdlib/project.lux index fe3cfb227..26ea4061b 100644 --- a/stdlib/project.lux +++ b/stdlib/project.lux @@ -16,6 +16,9 @@ "lua" {#compiler ["com.github.luxlang" "lux-lua" "0.6.0-SNAPSHOT" "jar"]} + "ruby" + {#compiler ["com.github.luxlang" "lux-ruby" "0.6.0-SNAPSHOT" "jar"]} + "bibliotheca" {#description "Standard library for the Lux programming language." #test "test/lux"} diff --git a/stdlib/source/documentation/lux.lux b/stdlib/source/documentation/lux.lux index b1d7ae466..712814250 100644 --- a/stdlib/source/documentation/lux.lux +++ b/stdlib/source/documentation/lux.lux @@ -150,19 +150,19 @@ (documentation: /.All "Universal quantification." - [(All [a] + [(All (_ a) (-> a a))] ["A name can be provided, to specify a recursive type." - (All List [a] + (All (List a) (Or Any [a (List a)]))]) (documentation: /.Ex "Existential quantification." - [(Ex [a] + [(Ex (_ a) [(Codec Text a) a])] ["A name can be provided, to specify a recursive type." - (Ex Self [a] + (Ex (Self a) [(Codec Text a) a (List (Self a))])]) @@ -304,7 +304,7 @@ (documentation: /.type "Takes a type expression and returns its representation as data-structure." - [(type (All [a] + [(type (All (_ a) (Maybe (List a))))]) (documentation: /.: @@ -400,7 +400,7 @@ (documentation: /.function "Syntax for creating functions." - [(: (All [a b] + [(: (All (_ a b) (-> a b a)) (function (_ x y) x))] @@ -533,7 +533,7 @@ (format "Same as the 'open' macro, but meant to be used as a pattern-matching macro for generating local bindings." \n "Takes an 'alias' text for the generated local bindings.") [(def: .public (range enum from to) - (All [a] (-> (Enum a) a a (List a))) + (All (_ a) (-> (Enum a) a a (List a))) (let [(^open ".") enum] (loop [end to output #.End] @@ -777,7 +777,7 @@ "Allows you to refer to the type-variables in a polymorphic function's type, by their index.") ["In the example below, 0 corresponds to the 'a' variable." (def: .public (of_list list) - (All [a] (-> (List a) (Row a))) + (All (_ a) (-> (List a) (Row a))) (list\mix add (: (Row (:parameter 0)) empty) diff --git a/stdlib/source/documentation/lux/control/concatenative.lux b/stdlib/source/documentation/lux/control/concatenative.lux index 6c97e056f..a1163c241 100644 --- a/stdlib/source/documentation/lux/control/concatenative.lux +++ b/stdlib/source/documentation/lux/control/concatenative.lux @@ -21,13 +21,13 @@ (documentation: /.=> "Concatenative function types." [(=> [Nat] [Nat])] - [(All [a] + [(All (_ a) (-> a (=> [] [a])))] - [(All [t] + [(All (_ t) (=> [t] []))] - [(All [a b c] + [(All (_ a b c) (=> [a b c] [b c a]))] - [(All [___a ___z] + [(All (_ ___a ___z) (=> {then (=> ___a ___z) else (=> ___a ___z)} ___a [Bit then else] ___z))]) diff --git a/stdlib/source/documentation/lux/control/security/policy.lux b/stdlib/source/documentation/lux/control/security/policy.lux index 8f7b100b7..37d499014 100644 --- a/stdlib/source/documentation/lux/control/security/policy.lux +++ b/stdlib/source/documentation/lux/control/security/policy.lux @@ -45,7 +45,7 @@ unsafe))) (def: (policy _) - (Ex [%] (-> Any (Policy %))) + (Ex (_ %) (-> Any (Policy %))) (with_policy (: (Context Privacy Policy) (function (_ (^open "%::.")) diff --git a/stdlib/source/documentation/lux/ffi.jvm.lux b/stdlib/source/documentation/lux/ffi.jvm.lux new file mode 100644 index 000000000..a781e10ff --- /dev/null +++ b/stdlib/source/documentation/lux/ffi.jvm.lux @@ -0,0 +1,336 @@ +(.module: + [library + [lux (#- int char type :as) + ["$" documentation (#+ documentation:)] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(template [] + [(`` (documentation: + (format "The type of a (boxed) " (~~ (template.text [])) " object.")))] + + [/.Boolean] + [/.Byte] + [/.Short] + [/.Integer] + [/.Long] + [/.Float] + [/.Double] + [/.Character] + ) + +(template [] + [(`` (documentation: + (format "The type of an (unboxed) " (~~ (template.text [])) " value.")))] + + [/.boolean] + [/.byte] + [/.short] + [/.int] + [/.long] + [/.float] + [/.double] + [/.char] + ) + +(template [ ] + [(`` (documentation: + "Type converter." + [(: + ( (: foo)))]))] + + [/.byte_to_long Byte Long] + + [/.short_to_long Short Long] + + [/.double_to_int Double Integer] + [/.double_to_long Double Long] + [/.double_to_float Double Float] + + [/.float_to_int Float Integer] + [/.float_to_long Float Long] + [/.float_to_double Float Double] + + [/.int_to_byte Integer Byte] + [/.int_to_short Integer Short] + [/.int_to_long Integer Long] + [/.int_to_float Integer Float] + [/.int_to_double Integer Double] + [/.int_to_char Integer Character] + + [/.long_to_byte Long Byte] + [/.long_to_short Long Short] + [/.long_to_int Long Integer] + [/.long_to_float Long Float] + [/.long_to_double Long Double] + + [/.char_to_byte Character Byte] + [/.char_to_short Character Short] + [/.char_to_int Character Integer] + [/.char_to_long Character Long] + + [/.long_to_char Long Character] + [/.byte_to_int Byte Integer] + [/.short_to_int Short Integer] + [/.byte_to_char Byte Character] + [/.short_to_char Short Character] + ) + +(documentation: /.class: + "Allows defining JVM classes in Lux code." + [(class: #final (TestClass A) [Runnable] + ... Fields + (#private foo boolean) + (#private bar A) + (#private baz java/lang/Object) + ... Methods + (#public [] (new [value A]) [] + (exec + (:= ::foo #1) + (:= ::bar value) + (:= ::baz "") + [])) + (#public (virtual) java/lang/Object + "") + (#public #static (static) java/lang/Object + "") + (Runnable [] (run) void + []) + ) + + "The tuple corresponds to parent interfaces." + "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed." + "Fields and methods defined in the class can be used with special syntax." + "For example:" + "::resolved, for accessing the 'resolved' field." + "(:= ::resolved #1) for modifying it." + "(::new! []) for calling the class's constructor." + "(::resolve! container [value]) for calling the 'resolve' method."]) + +(documentation: /.interface: + "Allows defining JVM interfaces." + [(interface: TestInterface + ([] foo [boolean String] void #throws [Exception]))]) + +(documentation: /.object + "Allows defining anonymous classes." + ["The 1st tuple corresponds to class-level type-variables." + "The 2nd tuple corresponds to parent interfaces." + "The 3rd tuple corresponds to arguments to the super class constructor." + "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed." + (object [] [Runnable] + [] + (Runnable [] (run self) void + (exec + (do_something some_value) + [])))]) + +(documentation: /.null + "The null pointer." + [(null)]) + +(documentation: /.null? + "Test for the null pointer." + [(= true + (null? (null)))] + [(= false + (null? "YOLO"))]) + +(documentation: /.??? + "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it." + [(= (??? (: java/lang/String (null))) + #.None)] + [(= (??? "YOLO") + (#.Some "YOLO"))]) + +(documentation: /.!!! + (format "Takes a (Maybe ObjectType) and returns a ObjectType." + \n "A #.None would get translated into a (null).") + [(= (null) + (!!! (??? (: java/lang/Thread (null)))))] + [(= "foo" + (!!! (??? "foo")))]) + +(documentation: /.check + (format "Checks whether an object is an instance of a particular class." + \n "Caveat emptor: Cannot check for polymorphism, so avoid using parameterized classes.") + [(case (check String "YOLO") + (#.Some value_as_string) + #.None)]) + +(documentation: /.synchronized + "Evaluates body, while holding a lock on a given object." + [(synchronized object_to_be_locked + (exec + (do something) + (dosomething else) + (finish the computation)))]) + +(documentation: /.do_to + "Call a variety of methods on an object. Then, return the object." + [(do_to object + (ClassName::method1 arg0 arg1 arg2) + (ClassName::method2 arg3 arg4 arg5))]) + +(documentation: /.import: + "Allows importing JVM classes, and using them as types." + ["Their methods, fields and enum options can also be imported." + (import: java/lang/Object + ["#::." + (new []) + (equals [java/lang/Object] boolean) + (wait [int] #io #try void)])] + ["Special options can also be given for the return values." + "#? means that the values will be returned inside a Maybe type. That way, null becomes #.None." + "#try means that the computation might throw an exception, and the return value will be wrapped by the Try type." + "#io means the computation has side effects, and will be wrapped by the IO type." + "These options must show up in the following order [#io #try #?] (although, each option can be used independently)." + (import: java/lang/String + ["#::." + (new [[byte]]) + (#static valueOf [char] java/lang/String) + (#static valueOf #as int_valueOf [int] java/lang/String)]) + + (import: (java/util/List e) + ["#::." + (size [] int) + (get [int] e)]) + + (import: (java/util/ArrayList a) + ["#::." + ([T] toArray [[T]] [T])])] + ["The class-type that is generated is of the fully-qualified name." + "This avoids a clash between the java.util.List type, and Lux's own List type." + "All enum options to be imported must be specified." + (import: java/lang/Character$UnicodeScript + ["#::." + (#enum ARABIC CYRILLIC LATIN)])] + ["It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-vars." + "Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes)." + (import: (lux/concurrency/async/JvmAsync A) + ["#::." + (resolve [A] boolean) + (poll [] A) + (wasResolved [] boolean) + (waitOn [lux/Function] void) + (#static [A] make [A] (lux/concurrency/async/JvmAsync A))])] + ["Also, the names of the imported members will look like Class::member" + (java/lang/Object::new []) + (java/lang/Object::equals [other_object] my_object) + (java/util/List::size [] my_list) + java/lang/Character$UnicodeScript::LATIN]) + +(documentation: /.array + "Create an array of the given type, with the given size." + [(array java/lang/Object 10)]) + +(documentation: /.length + "Gives the length of an array." + [(length my_array)]) + +(documentation: /.read! + "Loads an element from an array." + [(read! 10 my_array)]) + +(documentation: /.write! + "Stores an element into an array." + [(write! 10 my_object my_array)]) + +(documentation: /.class_for + "Loads the class as a java.lang.Class object." + [(class_for java/lang/String)]) + +(documentation: /.type + "" + [(: Type + (type java/lang/String))]) + +(documentation: /.:as + "" + [(:as java/lang/Object + (: java/lang/String + ???))]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Boolean + ..Byte + ..Short + ..Integer + ..Long + ..Float + ..Double + ..Character + + ..boolean + ..byte + ..short + ..int + ..long + ..float + ..double + ..char + + ..byte_to_long + ..short_to_long + ..double_to_int + ..double_to_long + ..double_to_float + ..float_to_int + ..float_to_long + ..float_to_double + ..int_to_byte + ..int_to_short + ..int_to_long + ..int_to_float + ..int_to_double + ..int_to_char + ..long_to_byte + ..long_to_short + ..long_to_int + ..long_to_float + ..long_to_double + ..char_to_byte + ..char_to_short + ..char_to_int + ..char_to_long + ..long_to_char + ..byte_to_int + ..short_to_int + ..byte_to_char + ..short_to_char + + ..class: + ..interface: + ..object + ..null + ..null? + ..??? + ..!!! + ..check + ..synchronized + ..do_to + ..import: + ..array + ..length + ..read! + ..write! + ..class_for + ..type + ..:as + ($.default /.Privacy) + ($.default /.State) + ($.default /.Inheritance) + ($.default /.class_names_cannot_contain_periods) + ($.default /.class_name_cannot_be_a_type_variable) + ($.default /.unexpected_type_variable) + ($.default /.cannot_convert_to_jvm_type) + ($.default /.cannot_cast_to_non_object)] + [])) diff --git a/stdlib/source/documentation/lux/ffi.lux b/stdlib/source/documentation/lux/ffi.lux deleted file mode 100644 index a781e10ff..000000000 --- a/stdlib/source/documentation/lux/ffi.lux +++ /dev/null @@ -1,336 +0,0 @@ -(.module: - [library - [lux (#- int char type :as) - ["$" documentation (#+ documentation:)] - [data - ["." text (#+ \n) - ["%" format (#+ format)]]] - [macro - ["." template]]]] - [\\library - ["." /]]) - -(template [] - [(`` (documentation: - (format "The type of a (boxed) " (~~ (template.text [])) " object.")))] - - [/.Boolean] - [/.Byte] - [/.Short] - [/.Integer] - [/.Long] - [/.Float] - [/.Double] - [/.Character] - ) - -(template [] - [(`` (documentation: - (format "The type of an (unboxed) " (~~ (template.text [])) " value.")))] - - [/.boolean] - [/.byte] - [/.short] - [/.int] - [/.long] - [/.float] - [/.double] - [/.char] - ) - -(template [ ] - [(`` (documentation: - "Type converter." - [(: - ( (: foo)))]))] - - [/.byte_to_long Byte Long] - - [/.short_to_long Short Long] - - [/.double_to_int Double Integer] - [/.double_to_long Double Long] - [/.double_to_float Double Float] - - [/.float_to_int Float Integer] - [/.float_to_long Float Long] - [/.float_to_double Float Double] - - [/.int_to_byte Integer Byte] - [/.int_to_short Integer Short] - [/.int_to_long Integer Long] - [/.int_to_float Integer Float] - [/.int_to_double Integer Double] - [/.int_to_char Integer Character] - - [/.long_to_byte Long Byte] - [/.long_to_short Long Short] - [/.long_to_int Long Integer] - [/.long_to_float Long Float] - [/.long_to_double Long Double] - - [/.char_to_byte Character Byte] - [/.char_to_short Character Short] - [/.char_to_int Character Integer] - [/.char_to_long Character Long] - - [/.long_to_char Long Character] - [/.byte_to_int Byte Integer] - [/.short_to_int Short Integer] - [/.byte_to_char Byte Character] - [/.short_to_char Short Character] - ) - -(documentation: /.class: - "Allows defining JVM classes in Lux code." - [(class: #final (TestClass A) [Runnable] - ... Fields - (#private foo boolean) - (#private bar A) - (#private baz java/lang/Object) - ... Methods - (#public [] (new [value A]) [] - (exec - (:= ::foo #1) - (:= ::bar value) - (:= ::baz "") - [])) - (#public (virtual) java/lang/Object - "") - (#public #static (static) java/lang/Object - "") - (Runnable [] (run) void - []) - ) - - "The tuple corresponds to parent interfaces." - "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed." - "Fields and methods defined in the class can be used with special syntax." - "For example:" - "::resolved, for accessing the 'resolved' field." - "(:= ::resolved #1) for modifying it." - "(::new! []) for calling the class's constructor." - "(::resolve! container [value]) for calling the 'resolve' method."]) - -(documentation: /.interface: - "Allows defining JVM interfaces." - [(interface: TestInterface - ([] foo [boolean String] void #throws [Exception]))]) - -(documentation: /.object - "Allows defining anonymous classes." - ["The 1st tuple corresponds to class-level type-variables." - "The 2nd tuple corresponds to parent interfaces." - "The 3rd tuple corresponds to arguments to the super class constructor." - "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed." - (object [] [Runnable] - [] - (Runnable [] (run self) void - (exec - (do_something some_value) - [])))]) - -(documentation: /.null - "The null pointer." - [(null)]) - -(documentation: /.null? - "Test for the null pointer." - [(= true - (null? (null)))] - [(= false - (null? "YOLO"))]) - -(documentation: /.??? - "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it." - [(= (??? (: java/lang/String (null))) - #.None)] - [(= (??? "YOLO") - (#.Some "YOLO"))]) - -(documentation: /.!!! - (format "Takes a (Maybe ObjectType) and returns a ObjectType." - \n "A #.None would get translated into a (null).") - [(= (null) - (!!! (??? (: java/lang/Thread (null)))))] - [(= "foo" - (!!! (??? "foo")))]) - -(documentation: /.check - (format "Checks whether an object is an instance of a particular class." - \n "Caveat emptor: Cannot check for polymorphism, so avoid using parameterized classes.") - [(case (check String "YOLO") - (#.Some value_as_string) - #.None)]) - -(documentation: /.synchronized - "Evaluates body, while holding a lock on a given object." - [(synchronized object_to_be_locked - (exec - (do something) - (dosomething else) - (finish the computation)))]) - -(documentation: /.do_to - "Call a variety of methods on an object. Then, return the object." - [(do_to object - (ClassName::method1 arg0 arg1 arg2) - (ClassName::method2 arg3 arg4 arg5))]) - -(documentation: /.import: - "Allows importing JVM classes, and using them as types." - ["Their methods, fields and enum options can also be imported." - (import: java/lang/Object - ["#::." - (new []) - (equals [java/lang/Object] boolean) - (wait [int] #io #try void)])] - ["Special options can also be given for the return values." - "#? means that the values will be returned inside a Maybe type. That way, null becomes #.None." - "#try means that the computation might throw an exception, and the return value will be wrapped by the Try type." - "#io means the computation has side effects, and will be wrapped by the IO type." - "These options must show up in the following order [#io #try #?] (although, each option can be used independently)." - (import: java/lang/String - ["#::." - (new [[byte]]) - (#static valueOf [char] java/lang/String) - (#static valueOf #as int_valueOf [int] java/lang/String)]) - - (import: (java/util/List e) - ["#::." - (size [] int) - (get [int] e)]) - - (import: (java/util/ArrayList a) - ["#::." - ([T] toArray [[T]] [T])])] - ["The class-type that is generated is of the fully-qualified name." - "This avoids a clash between the java.util.List type, and Lux's own List type." - "All enum options to be imported must be specified." - (import: java/lang/Character$UnicodeScript - ["#::." - (#enum ARABIC CYRILLIC LATIN)])] - ["It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-vars." - "Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes)." - (import: (lux/concurrency/async/JvmAsync A) - ["#::." - (resolve [A] boolean) - (poll [] A) - (wasResolved [] boolean) - (waitOn [lux/Function] void) - (#static [A] make [A] (lux/concurrency/async/JvmAsync A))])] - ["Also, the names of the imported members will look like Class::member" - (java/lang/Object::new []) - (java/lang/Object::equals [other_object] my_object) - (java/util/List::size [] my_list) - java/lang/Character$UnicodeScript::LATIN]) - -(documentation: /.array - "Create an array of the given type, with the given size." - [(array java/lang/Object 10)]) - -(documentation: /.length - "Gives the length of an array." - [(length my_array)]) - -(documentation: /.read! - "Loads an element from an array." - [(read! 10 my_array)]) - -(documentation: /.write! - "Stores an element into an array." - [(write! 10 my_object my_array)]) - -(documentation: /.class_for - "Loads the class as a java.lang.Class object." - [(class_for java/lang/String)]) - -(documentation: /.type - "" - [(: Type - (type java/lang/String))]) - -(documentation: /.:as - "" - [(:as java/lang/Object - (: java/lang/String - ???))]) - -(.def: .public documentation - (.List $.Module) - ($.module /._ - "" - [..Boolean - ..Byte - ..Short - ..Integer - ..Long - ..Float - ..Double - ..Character - - ..boolean - ..byte - ..short - ..int - ..long - ..float - ..double - ..char - - ..byte_to_long - ..short_to_long - ..double_to_int - ..double_to_long - ..double_to_float - ..float_to_int - ..float_to_long - ..float_to_double - ..int_to_byte - ..int_to_short - ..int_to_long - ..int_to_float - ..int_to_double - ..int_to_char - ..long_to_byte - ..long_to_short - ..long_to_int - ..long_to_float - ..long_to_double - ..char_to_byte - ..char_to_short - ..char_to_int - ..char_to_long - ..long_to_char - ..byte_to_int - ..short_to_int - ..byte_to_char - ..short_to_char - - ..class: - ..interface: - ..object - ..null - ..null? - ..??? - ..!!! - ..check - ..synchronized - ..do_to - ..import: - ..array - ..length - ..read! - ..write! - ..class_for - ..type - ..:as - ($.default /.Privacy) - ($.default /.State) - ($.default /.Inheritance) - ($.default /.class_names_cannot_contain_periods) - ($.default /.class_name_cannot_be_a_type_variable) - ($.default /.unexpected_type_variable) - ($.default /.cannot_convert_to_jvm_type) - ($.default /.cannot_cast_to_non_object)] - [])) diff --git a/stdlib/source/documentation/lux/ffi.old.lux b/stdlib/source/documentation/lux/ffi.old.lux new file mode 100644 index 000000000..ac2dd546c --- /dev/null +++ b/stdlib/source/documentation/lux/ffi.old.lux @@ -0,0 +1,265 @@ +(.module: + [library + [lux (#- int char type :as) + ["$" documentation (#+ documentation:)] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(template [ ] + [(documentation: + "Type converter." + [(: (primitive ) + ( (: (primitive ) + it)))])] + + [/.byte_to_long "java.lang.Byte" "java.lang.Long"] + + [/.short_to_long "java.lang.Short" "java.lang.Long"] + + [/.double_to_int "java.lang.Double" "java.lang.Integer"] + [/.double_to_long "java.lang.Double" "java.lang.Long"] + [/.double_to_float "java.lang.Double" "java.lang.Float"] + + [/.float_to_int "java.lang.Float" "java.lang.Integer"] + [/.float_to_long "java.lang.Float" "java.lang.Long"] + [/.float_to_double "java.lang.Float" "java.lang.Double"] + + [/.int_to_byte "java.lang.Integer" "java.lang.Byte"] + [/.int_to_short "java.lang.Integer" "java.lang.Short"] + [/.int_to_long "java.lang.Integer" "java.lang.Long"] + [/.int_to_float "java.lang.Integer" "java.lang.Float"] + [/.int_to_double "java.lang.Integer" "java.lang.Double"] + [/.int_to_char "java.lang.Integer" "java.lang.Character"] + + [/.long_to_byte "java.lang.Long" "java.lang.Byte"] + [/.long_to_short "java.lang.Long" "java.lang.Short"] + [/.long_to_int "java.lang.Long" "java.lang.Integer"] + [/.long_to_float "java.lang.Long" "java.lang.Float"] + [/.long_to_double "java.lang.Long" "java.lang.Double"] + + [/.char_to_byte "java.lang.Character" "java.lang.Byte"] + [/.char_to_short "java.lang.Character" "java.lang.Short"] + [/.char_to_int "java.lang.Character" "java.lang.Integer"] + [/.char_to_long "java.lang.Character" "java.lang.Long"] + ) + +(documentation: /.class: + "Allows defining JVM classes in Lux code." + [(class: #final (TestClass A) [Runnable] + ... Fields + (#private foo boolean) + (#private bar A) + (#private baz java/lang/Object) + ... Methods + (#public [] (new [value A]) [] + (exec + (:= ::foo #1) + (:= ::bar value) + (:= ::baz "") + [])) + (#public (virtual) java/lang/Object + "") + (#public #static (static) java/lang/Object + "") + (Runnable [] (run) void + [])) + "The tuple corresponds to parent interfaces." + "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed." + "Fields and methods defined in the class can be used with special syntax." + "For example:" + "::resolved, for accessing the 'resolved' field." + "(:= ::resolved #1) for modifying it." + "(::new! []) for calling the class's constructor." + "(::resolve! container [value]) for calling the 'resolve' method."]) + +(documentation: /.interface: + "Allows defining JVM interfaces." + [(interface: TestInterface + ([] foo [boolean String] void #throws [Exception]))]) + +(documentation: /.object + "Allows defining anonymous classes." + ["The 1st tuple corresponds to class-level type-variables." + "The 2nd tuple corresponds to parent interfaces." + "The 3rd tuple corresponds to arguments to the super class constructor." + "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed." + (object [] [Runnable] + [] + (Runnable [] (run self) void + (exec (do_something some_value) + [])))]) + +(documentation: /.null + "Null object reference." + (null)) + +(documentation: /.null? + "Test for null object reference." + [(= (null? (null)) + true)] + [(= (null? "YOLO") + false)]) + +(documentation: /.??? + "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it." + [(= (??? (: java/lang/String (null))) + #.None)] + [(= (??? "YOLO") + (#.Some "YOLO"))]) + +(documentation: /.!!! + "Takes a (Maybe ObjectType) and returns a ObjectType." + [(= "foo" + (!!! (??? "foo")))] + ["A #.None would get translated into a (null)." + (= (null) + (!!! (??? (: java/lang/Thread (null)))))]) + +(documentation: /.check + (format "Checks whether an object is an instance of a particular class." + \n "Caveat emptor: Cannot check for polymorphism, so avoid using parameterized classes.") + [(case (check java/lang/String "YOLO") + (#.Some value_as_string) + #.None)]) + +(documentation: /.synchronized + "Evaluates body, while holding a lock on a given object." + [(synchronized object_to_be_locked + (exec + (do something) + (do_something else) + (finish the computation)))]) + +(documentation: /.do_to + "Call a variety of methods on an object. Then, return the object." + [(do_to object + (ClassName::method0 arg0 arg1 arg2) + (ClassName::method1 arg3 arg4 arg5))]) + +(documentation: /.import: + (format "Allows importing JVM classes, and using them as types." + \n "Their methods, fields and enum options can also be imported.") + [(import: java/lang/Object + ["#::." + (new []) + (equals [java/lang/Object] boolean) + (wait [int] #io #try void)])] + ["Special options can also be given for the return values." + "#? means that the values will be returned inside a Maybe type. That way, null becomes #.None." + "#try means that the computation might throw an exception, and the return value will be wrapped by the Try type." + "#io means the computation has side effects, and will be wrapped by the IO type." + "These options must show up in the following order [#io #try #?] (although, each option can be used independently)." + (import: java/lang/String + ["#::." + (new [[byte]]) + (#static valueOf [char] java/lang/String) + (#static valueOf #as int_valueOf [int] java/lang/String)]) + + (import: (java/util/List e) + ["#::." + (size [] int) + (get [int] e)]) + + (import: (java/util/ArrayList a) + ["#::." + ([T] toArray [[T]] [T])])] + ["The class-type that is generated is of the fully-qualified name." + "This avoids a clash between the java.util.List type, and Lux's own List type." + "All enum options to be imported must be specified." + (import: java/lang/Character$UnicodeScript + ["#::." + (#enum ARABIC CYRILLIC LATIN)])] + ["It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-parameters." + "Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes)." + (import: (lux/concurrency/async/JvmAsync A) + ["#::." + (resolve [A] boolean) + (poll [] A) + (wasResolved [] boolean) + (waitOn [lux/Function] void) + (#static [A] make [A] (lux/concurrency/async/JvmAsync A))])] + ["Also, the names of the imported members will look like Class::member" + (java/lang/Object::new []) + (java/lang/Object::equals [other_object] my_object) + (java/util/List::size [] my_list) + java/lang/Character$UnicodeScript::LATIN]) + +(documentation: /.array + "Create an array of the given type, with the given size." + [(array java/lang/Object 10)]) + +(documentation: /.length + "Gives the length of an array." + [(length my_array)]) + +(documentation: /.read! + "Loads an element from an array." + [(read! 10 my_array)]) + +(documentation: /.write! + "Stores an element into an array." + [(write! 10 my_object my_array)]) + +(documentation: /.class_for + "Loads the class as a java.lang.Class object." + [(: (primitive "java.lang.Class" ["java.lang.Object"]) + (class_for java/lang/String))]) + +(documentation: /.type + "" + [(: .Type + (type java/lang/String))]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..byte_to_long + ..short_to_long + ..double_to_int + ..double_to_long + ..double_to_float + ..float_to_int + ..float_to_long + ..float_to_double + ..int_to_byte + ..int_to_short + ..int_to_long + ..int_to_float + ..int_to_double + ..int_to_char + ..long_to_byte + ..long_to_short + ..long_to_int + ..long_to_float + ..long_to_double + ..char_to_byte + ..char_to_short + ..char_to_int + ..char_to_long + ..class: + ..interface: + ..object + ..null + ..null? + ..??? + ..!!! + ..check + ..synchronized + ..do_to + ..import: + ..array + ..length + ..read! + ..write! + ..class_for + ..type + ($.default /.Privacy) + ($.default /.State) + ($.default /.Inheritance)] + [])) diff --git a/stdlib/source/documentation/lux/ffi.rb.lux b/stdlib/source/documentation/lux/ffi.rb.lux new file mode 100644 index 000000000..9109e9253 --- /dev/null +++ b/stdlib/source/documentation/lux/ffi.rb.lux @@ -0,0 +1,46 @@ +(.module: + [library + [lux (#- int char type :as) + ["$" documentation (#+ documentation:)] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.import: + "Easily import types, methods, functions and constants." + [(import: Stat + ["#::." + (executable? [] Bit) + (size Int)]) + + (import: File #as RubyFile + ["#::." + (#static SEPARATOR ..String) + (#static open [Path ..String] #io #try RubyFile) + (#static stat [Path] #io #try Stat) + (#static delete [Path] #io #try Int) + (#static file? [Path] #io #try Bit) + (#static directory? [Path] #io #try Bit) + + (read [] #io #try Binary) + (write [Binary] #io #try Int) + (flush [] #io #try #? Any) + (close [] #io #try #? Any)])]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..import: + ($.default /.Object) + ($.default /.Nil) + ($.default /.Function) + ($.default /.Function) + ($.default /.Integer) + ($.default /.Float) + ($.default /.String)] + [])) diff --git a/stdlib/source/documentation/lux/type/abstract.lux b/stdlib/source/documentation/lux/type/abstract.lux index 8b1bf10ca..e77660aa0 100644 --- a/stdlib/source/documentation/lux/type/abstract.lux +++ b/stdlib/source/documentation/lux/type/abstract.lux @@ -55,7 +55,7 @@ [a a] (def: (duplicate value) - (All [a] (-> a (Duplicate a))) + (All (_ a) (-> a (Duplicate a))) (:abstraction [value value])))] ["Definitions can be nested." (abstract: (Single a) @@ -64,7 +64,7 @@ a (def: (single value) - (All [a] (-> a (Single a))) + (All (_ a) (-> a (Single a))) (:abstraction value)) (abstract: (Double a) @@ -73,11 +73,11 @@ [a a] (def: (double value) - (All [a] (-> a (Double a))) + (All (_ a) (-> a (Double a))) (:abstraction [value value])) (def: (single' value) - (All [a] (-> a (Single a))) + (All (_ a) (-> a (Single a))) (:abstraction Single [value value])) (let [value 0123] @@ -130,7 +130,7 @@ (documentation: /.^:representation "Pattern-matching macro to easily extract a representation." [(def: (computation abstraction) - (All [a] (-> (Abstract a) ???)) + (All (_ a) (-> (Abstract a) ???)) (let [(^:representation value) abstraction] (foo (bar (baz value)))))]) diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index c87b674f0..20614dc2f 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -19,7 +19,7 @@ #1) ... (type: .public Any -... (Ex [a] a)) +... (Ex (_ a) a)) ("lux def" Any ("lux type check type" (9 #1 ["library/lux" "Any"] @@ -29,7 +29,7 @@ #1) ... (type: .public Nothing -... (All [a] a)) +... (All (_ a) a)) ("lux def" Nothing ("lux type check type" (9 #1 ["library/lux" "Nothing"] @@ -1014,54 +1014,9 @@ ("lux type as" Int param) ("lux type as" Int subject)))) -(def:'' .private (nested_quantification code) - #End - (#Function Code Code) - ({[_ (#Tuple members)] - (tuple$ (list\each nested_quantification members)) - - [_ (#Record pairs)] - (record$ (list\each ("lux type check" (#Function (#Product Code Code) (#Product Code Code)) - (function'' [pair] - (let'' [name val] pair - [name (nested_quantification val)]))) - pairs)) - - [_ (#Form (#Item [_ (#Tag "library/lux" "Parameter")] (#Item [_ (#Nat idx)] #End)))] - (form$ (#Item (tag$ ["library/lux" "Parameter"]) (#Item (nat$ ("lux i64 +" 2 idx)) #End))) - - [_ (#Form members)] - (form$ (list\each nested_quantification members)) - - _ - code} - code)) - -(def:'' .private (quantified_args_parser args next) - #End - ... (-> (List Code) (-> (List Text) (Meta (List Code))) (Meta (List Code))) - (#Function ($' List Code) - (#Function (#Function ($' List Text) (#Apply ($' List Code) Meta)) - (#Apply ($' List Code) Meta) - )) - ({#End - (next #End) - - (#Item [_ (#Identifier "" arg_name)] args') - (quantified_args_parser args' (function'' [names] (next (#Item arg_name names)))) - - _ - (failure "Expected identifier.")} - args)) - -(def:'' .private (type_parameter idx) - #End - (#Function Nat Code) - (form$ (#Item (tag$ ["library/lux" "Parameter"]) (#Item (nat$ idx) #End)))) - (def:'' .private (list\mix f init xs) #End - ... (All [a b] (-> (-> b a a) a (List b) a)) + ... (All (_ a b) (-> (-> b a a) a (List b) a)) (#UnivQ #End (#UnivQ #End (#Function (#Function (#Parameter 1) (#Function (#Parameter 3) (#Parameter 3))) @@ -1081,84 +1036,231 @@ (#Function ($' List (#Parameter 1)) Nat)) (list\mix (function'' [_ acc] ("lux i64 +" 1 acc)) 0 list)) -(macro:' .public (All tokens) +(def:'' .private (let$ binding value body) + #End + (#Function Code (#Function Code (#Function Code Code))) + (form$ (#Item (record$ (#Item [binding body] #End)) + (#Item value #End)))) + +(def:'' .private (UnivQ$ body) + #End + (#Function Code Code) + (form$ (#Item (tag$ ["library/lux" "UnivQ"]) (#Item (tag$ ["library/lux" "End"]) (#Item body #End))))) + +(def:'' .private (ExQ$ body) + #End + (#Function Code Code) + (form$ (#Item (tag$ ["library/lux" "ExQ"]) (#Item (tag$ ["library/lux" "End"]) (#Item body #End))))) + +(def:'' .private quantification_level + #End + Text + ("lux text concat" double_quote + ("lux text concat" "quantification_level" + double_quote))) + +(def:'' .private quantified + #End + (#Function Code Code) + (let$ (local_identifier$ ..quantification_level) (nat$ 0))) + +(def:'' .private (quantified_type_parameter idx) + #End + (#Function Nat Code) + (form$ (#Item (tag$ ["library/lux" "Parameter"]) + (#Item (form$ (#Item (text$ "lux i64 +") + (#Item (local_identifier$ ..quantification_level) + (#Item (nat$ idx) + #End)))) + #End)))) + +(def:'' .private (next_level depth) + #End + (#Function Nat Nat) + ("lux i64 +" 2 depth)) + +(def:'' .private (self_id? id) + #End + (#Function Nat Bit) + ("lux i64 =" id ("lux type as" Nat + ("lux i64 *" +2 + ("lux i64 /" +2 + ("lux type as" Int + id)))))) + +(def:'' .public (__adjusted_quantified_type__ permission depth type) + #End + (#Function Nat (#Function Nat (#Function Type Type))) + ({0 + ({... Jackpot! + (#Parameter id) + ({id' + ({#0 (#Parameter id') + #1 (#Parameter ("lux i64 -" 2 id'))} + (self_id? id))} + ("lux i64 -" ("lux i64 -" depth id) 0)) + + ... Recur + (#Primitive name parameters) + (#Primitive name (list\each (__adjusted_quantified_type__ permission depth) + parameters)) + + (#Sum left right) + (#Sum (__adjusted_quantified_type__ permission depth left) + (__adjusted_quantified_type__ permission depth right)) + + (#Product left right) + (#Product (__adjusted_quantified_type__ permission depth left) + (__adjusted_quantified_type__ permission depth right)) + + (#Function input output) + (#Function (__adjusted_quantified_type__ permission depth input) + (__adjusted_quantified_type__ permission depth output)) + + (#UnivQ environment body) + (#UnivQ environment + (__adjusted_quantified_type__ permission (next_level depth) body)) + + (#ExQ environment body) + (#ExQ environment + (__adjusted_quantified_type__ permission (next_level depth) body)) + + (#Apply parameter function) + (#Apply (__adjusted_quantified_type__ permission depth parameter) + (__adjusted_quantified_type__ permission depth function)) + + ... Leave these alone. + (#Named name anonymous) type + (#Var id) type + (#Ex id) type} + type) + + _ + type} + permission)) + +(def:'' .private (with_correct_quantification body) + #End + (#Function Code Code) + (form$ (#Item (identifier$ [prelude_module "__adjusted_quantified_type__"]) + (#Item (local_identifier$ ..quantification_level) + (#Item (nat$ 0) + (#Item body + #End)))))) + +(def:'' .private (with_quantification depth body) + #End + (#Function Nat (#Function Code Code)) + ({g!level + (let$ g!level + (form$ (#Item (text$ "lux i64 +") + (#Item g!level + (#Item (nat$ ("lux type as" Nat + ("lux i64 *" +2 + ("lux type as" Int + depth)))) + #End)))) + body)} + (local_identifier$ ..quantification_level))) + +(def:'' .private (initialized_quantification? lux) + #End + (#Function Lux Bit) + ({{#info _ #source _ #current_module _ #modules _ + #scopes scopes #type_context _ #host _ + #seed _ #expected _ #location _ #extensions _ + #scope_type_vars _ #eval _} + (list\mix (function'' [scope verdict] + ({#1 #1 + _ ({{#name _ #inner _ #captured _ + #locals {#counter _ + #mappings locals}} + (list\mix (function'' [local verdict] + ({[local _] + ({#1 #1 + _ ("lux text =" ..quantification_level local)} + verdict)} + local)) + #0 + locals)} + scope)} + verdict)) + #0 + scopes)} + lux)) + +(macro:' .public (All tokens lux) #End - (let'' [self_name tokens] ({(#Item [_ (#Identifier "" self_name)] tokens) - [self_name tokens] - - _ - ["" tokens]} - tokens) - ({(#Item [_ (#Tuple args)] (#Item body #End)) - (quantified_args_parser args - (function'' [names] - (let'' body' (list\mix ("lux type check" (#Function Text (#Function Code Code)) - (function'' [name' body'] - (form$ (#Item (tag$ ["library/lux" "UnivQ"]) - (#Item (tag$ ["library/lux" "End"]) - (#Item (with_replacements (#Item [name' (type_parameter 1)] #End) - (nested_quantification body')) - #End)))))) - body - names) - (in_meta (#Item ({[#1 _] - body' - - [_ #End] - body' - - [#0 _] - (with_replacements (#Item [self_name (type_parameter (n/* 2 ("lux i64 -" 1 (list\size names))))] - #End) - body')} - [(text\= "" self_name) names]) - #End))))) - - _ - (failure "Wrong syntax for All")} - tokens))) + ({(#Item [_ (#Form (#Item self_name args))] + (#Item body #End)) + (#Right [lux + (#Item ({raw + ({#1 raw + #0 (..quantified raw)} + (initialized_quantification? lux))} + ({#End + body + + (#Item head tail) + (with_correct_quantification + (let$ self_name (quantified_type_parameter 0) + ({[_ raw] + raw} + (list\mix (function'' [parameter offset,body'] + ({[offset body'] + [("lux i64 +" 2 offset) + (let$ parameter (quantified_type_parameter ("lux i64 +" offset 1)) + (UnivQ$ body'))]} + offset,body')) + [0 (with_quantification (list\size args) + body)] + args))))} + args)) + #End)]) + + _ + (#Left "Wrong syntax for All")} + tokens)) -(macro:' .public (Ex tokens) +(macro:' .public (Ex tokens lux) #End - (let'' [self_name tokens] ({(#Item [_ (#Identifier "" self_name)] tokens) - [self_name tokens] - - _ - ["" tokens]} - tokens) - ({(#Item [_ (#Tuple args)] (#Item body #End)) - (quantified_args_parser args - (function'' [names] - (let'' body' (list\mix ("lux type check" (#Function Text (#Function Code Code)) - (function'' [name' body'] - (form$ (#Item (tag$ ["library/lux" "ExQ"]) - (#Item (tag$ ["library/lux" "End"]) - (#Item (with_replacements (#Item [name' (type_parameter 1)] #End) - (nested_quantification body')) - #End)))))) - body - names) - (in_meta (#Item ({[#1 _] - body' - - [_ #End] - body' - - [#0 _] - (with_replacements (#Item [self_name (type_parameter (n/* 2 ("lux i64 -" 1 (list\size names))))] - #End) - body')} - [(text\= "" self_name) names]) - #End))))) - - _ - (failure "Wrong syntax for Ex")} - tokens))) + ({(#Item [_ (#Form (#Item self_name args))] + (#Item body #End)) + (#Right [lux + (#Item ({raw + ({#1 raw + #0 (..quantified raw)} + (initialized_quantification? lux))} + ({#End + body + + (#Item head tail) + (with_correct_quantification + (let$ self_name (quantified_type_parameter 0) + ({[_ raw] + raw} + (list\mix (function'' [parameter offset,body'] + ({[offset body'] + [("lux i64 +" 2 offset) + (let$ parameter (quantified_type_parameter ("lux i64 +" offset 1)) + (ExQ$ body'))]} + offset,body')) + [0 (with_quantification (list\size args) + body)] + args))))} + args)) + #End)]) + + _ + (#Left "Wrong syntax for Ex")} + tokens)) (def:'' .private (list\reversed list) #End - (All [a] (#Function ($' List a) ($' List a))) - (list\mix ("lux type check" (All [a] (#Function a (#Function ($' List a) ($' List a)))) + (All (_ a) + (#Function ($' List a) ($' List a))) + (list\mix ("lux type check" (All (_ a) + (#Function a (#Function ($' List a) ($' List a)))) (function'' [head tail] (#Item head tail))) #End list)) @@ -1291,7 +1393,7 @@ (def:''' .private (pairs xs) #End - (All [a] (-> ($' List a) ($' List (Tuple a a)))) + (All (_ a) (-> ($' List a) ($' List (Tuple a a)))) ({(#Item x (#Item y xs')) (#Item [x y] (pairs xs')) @@ -1316,7 +1418,7 @@ (def:''' .private (any? p xs) #End - (All [a] + (All (_ a) (-> (-> a Bit) ($' List a) Bit)) ({#End #0 @@ -1345,7 +1447,7 @@ (def:''' .private (list\composite xs ys) #End - (All [a] (-> ($' List a) ($' List a) ($' List a))) + (All (_ a) (-> ($' List a) ($' List a) ($' List a))) ({(#Item x xs') (#Item x (list\composite xs' ys)) @@ -1365,7 +1467,7 @@ (def:''' .private (function\flipped func) #End - (All [a b c] + (All (_ a b c) (-> (-> a b c) (-> b a c))) (function' [right left] (func left right))) @@ -1400,17 +1502,19 @@ ... (type: (Monad m) ... (Interface -... (: (All [a] (-> a (m a))) +... (: (All (_ a) (-> a (m a))) ... in) -... (: (All [a b] (-> (-> a (m b)) (m a) (m b))) +... (: (All (_ a b) (-> (-> a (m b)) (m a) (m b))) ... then))) ("lux def type tagged" Monad (#Named ["library/lux" "Monad"] - (All [m] - (Tuple (All [a] (-> a ($' m a))) - (All [a b] (-> (-> a ($' m b)) - ($' m a) - ($' m b)))))) + (All (_ !) + (Tuple (All (_ a) + (-> a ($' ! a))) + (All (_ a b) + (-> (-> a ($' ! b)) + ($' ! a) + ($' ! b)))))) (record$ (list)) ["in" "then"] #0) @@ -1480,9 +1584,7 @@ (def:''' .private (monad\each m f xs) #End - ... (All [m a b] - ... (-> (Monad m) (-> a (m b)) (List a) (m (List b)))) - (All [m a b] + (All (_ m a b) (-> ($' Monad m) (-> a ($' m b)) ($' List a) @@ -1500,9 +1602,7 @@ (def:''' .private (monad\mix m f y xs) #End - ... (All [m a b] - ... (-> (Monad m) (-> a b (m b)) b (List a) (m b))) - (All [m a b] + (All (_ m a b) (-> ($' Monad m) (-> a b ($' m b)) b @@ -1532,11 +1632,11 @@ (def:''' .private PList #End Type - (All [a] ($' List (Tuple Text a)))) + (All (_ a) ($' List (Tuple Text a)))) (def:''' .private (plist\value k plist) #End - (All [a] + (All (_ a) (-> Text ($' PList a) ($' Maybe a))) ({(#Item [[k' v] plist']) (if (text\= k k') @@ -1837,7 +1937,7 @@ (def:''' .private (function\composite f g) (list [(tag$ ["library/lux" "doc"]) (text$ "Function composition.")]) - (All [a b c] + (All (_ a b c) (-> (-> b c) (-> a b) (-> a c))) (function' [x] (f (g x)))) @@ -1911,7 +2011,7 @@ (def:''' .private (every? p xs) #End - (All [a] + (All (_ a) (-> (-> a Bit) ($' List a) Bit)) (list\mix (function' [_2 _1] (if _1 (p _2) #0)) #1 xs)) @@ -1945,7 +2045,7 @@ (def:''' .private (list\conjoint xs) #End - (All [a] + (All (_ a) (-> ($' List ($' List a)) ($' List a))) (list\mix list\composite #End (list\reversed xs))) @@ -2150,7 +2250,7 @@ (def:''' .private (list\interposed sep xs) #End - (All [a] + (All (_ a) (-> a ($' List a) ($' List a))) ({#End xs @@ -2327,6 +2427,24 @@ [_ (#Form (#Item [_ (#Identifier ["" ":~"])] (#Item expression #End)))] expression + [_0 (#Form (#Item [_1 (#Record (#Item [binding body] #End))] + (#Item value + #End)))] + [_0 (#Form (#Item [_1 (#Record (#Item [binding (normal_type body)] #End))] + (#Item value + #End)))] + + [_0 (#Form (#Item [_1 (#Identifier ["library/lux" "__adjusted_quantified_type__"])] + (#Item _permission + (#Item _level + (#Item body + #End)))))] + [_0 (#Form (#Item [_1 (#Identifier ["library/lux" "__adjusted_quantified_type__"])] + (#Item _permission + (#Item _level + (#Item (normal_type body) + #End)))))] + [_ (#Form (#Item type_fn args))] (list\mix ("lux type check" (-> Code Code Code) (function' [arg type_fn] (` (#.Apply (~ arg) (~ type_fn))))) @@ -2341,13 +2459,17 @@ (list) ({(#Item type #End) (do meta_monad - [type+ (full_expansion type)] - ({(#Item type' #End) - (in (list (normal_type type'))) + [initialized_quantification? (function' [lux] (#Right [lux (initialized_quantification? lux)]))] + (if initialized_quantification? + (do meta_monad + [type+ (full_expansion type)] + ({(#Item type' #End) + (in (list (normal_type type'))) - _ - (failure "The expansion of the type-syntax had to yield a single element.")} - type+)) + _ + (failure "The expansion of the type-syntax had to yield a single element.")} + type+)) + (in (list (..quantified (` (..type (~ type)))))))) _ (failure "Wrong syntax for type")} @@ -2356,7 +2478,9 @@ (macro:' .public (: tokens) (list) ({(#Item type (#Item value #End)) - (in_meta (list (` ("lux type check" (type (~ type)) (~ value))))) + (in_meta (list (` ("lux type check" + (..type (~ type)) + (~ value))))) _ (failure "Wrong syntax for :")} @@ -2365,7 +2489,9 @@ (macro:' .public (:as tokens) (list) ({(#Item type (#Item value #End)) - (in_meta (list (` ("lux type as" (type (~ type)) (~ value))))) + (in_meta (list (` ("lux type as" + (..type (~ type)) + (~ value))))) _ (failure "Wrong syntax for :as")} @@ -2373,7 +2499,8 @@ (def:''' .private (empty? xs) #End - (All [a] (-> ($' List a) Bit)) + (All (_ a) + (-> ($' List a) Bit)) ({#End #1 _ #0} xs)) @@ -2381,7 +2508,8 @@ (template [ ] [(def:''' .private ( xy) #End - (All [a b] (-> (Tuple a b) )) + (All (_ a b) + (-> (Tuple a b) )) (let' [[x y] xy] ))] @@ -2931,7 +3059,7 @@ (failure "Wrong syntax for macro:"))) (def: (list\one f xs) - (All [a b] + (All (_ a b) (-> (-> a (Maybe b)) (List a) (Maybe b))) (case xs #End @@ -2999,7 +3127,7 @@ ("lux text clip" after_offset after_length input)))))) (def: (item idx xs) - (All [a] + (All (_ a) (-> Nat (List a) (Maybe a))) (case xs #End @@ -3199,6 +3327,52 @@ #None (#Left "Not expecting any type."))))) +(def: (type\encoded type) + (-> Type Text) + (case type + (#Primitive name params) + (case params + #End + name + + _ + ($_ text\composite "(" name " " (|> params (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) ")")) + + (#Sum _) + ($_ text\composite "(Or " (|> (flat_variant type) (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) ")") + + (#Product _) + ($_ text\composite "[" (|> (flat_tuple type) (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) "]") + + (#Function _) + ($_ text\composite "(-> " (|> (flat_lambda type) (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) ")") + + (#Parameter id) + (nat\encoded id) + + (#Var id) + ($_ text\composite "⌈v:" (nat\encoded id) "⌋") + + (#Ex id) + ($_ text\composite "⟨e:" (nat\encoded id) "⟩") + + (#UnivQ env body) + ($_ text\composite "(All " (type\encoded body) ")") + + (#ExQ env body) + ($_ text\composite "(Ex " (type\encoded body) ")") + + (#Apply _) + (let [[func args] (flat_application type)] + ($_ text\composite + "(" (type\encoded func) " " + (|> args (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) + ")")) + + (#Named name _) + (name\encoded name) + )) + (macro: .public (implementation tokens) (do meta_monad [tokens' (monad\each meta_monad expansion tokens) @@ -3210,7 +3384,9 @@ (in_meta tags) _ - (failure "No tags available for type."))) + (failure ($_ text\composite + "No tags available for type: " + (type\encoded struct_type))))) .let [tag_mappings (: (List [Text Code]) (list\each (function (_ tag) [(product\right tag) (tag$ tag)]) tags))] @@ -3304,12 +3480,14 @@ (failure "Wrong syntax for implementation:"))) (def: (function\identity value) - (All [a] (-> a a)) + (All (_ a) + (-> a a)) value) (def: (everyP itP tokens) - (All [a] (-> (-> (List Code) (Maybe [(List Code) a])) - (-> (List Code) (Maybe (List a))))) + (All (_ a) + (-> (-> (List Code) (Maybe [(List Code) a])) + (-> (List Code) (Maybe (List a))))) (case tokens (#Item _) (do maybe_monad @@ -3475,7 +3653,8 @@ (#Some type) _ - (#Some (` (.All (~ type_name) [(~+ (list\each local_identifier$ args))] (~ type)))))) + (#Some (` (.All ((~ type_name) (~+ (list\each local_identifier$ args))) + (~ type)))))) total_meta (let [meta (definition_annotations meta)] (` [(~ location_code) (#.Record (~ meta))]))]] @@ -3676,7 +3855,7 @@ relatives))) (def: (list\after amount list) - (All [a] (-> Nat (List a) (List a))) + (All (_ a) (-> Nat (List a) (List a))) (case [amount list] (^or [0 _] [_ #End]) list @@ -3829,7 +4008,8 @@ )) (def: (list\only p xs) - (All [a] (-> (-> a Bit) (List a) (List a))) + (All (_ a) + (-> (-> a Bit) (List a) (List a))) (case xs #End (list) @@ -3849,7 +4029,7 @@ output)) (def: (on_either f x1 x2) - (All [a b] + (All (_ a b) (-> (-> a (Maybe b)) a a (Maybe b))) (case (f x1) #None (f x2) @@ -3980,7 +4160,8 @@ ))) (def: (zipped/2 xs ys) - (All [a b] (-> (List a) (List b) (List [a b]))) + (All (_ a b) + (-> (List a) (List b) (List [a b]))) (case xs (#Item x xs') (case ys @@ -3993,52 +4174,6 @@ _ (list))) -(def: (type\encoded type) - (-> Type Text) - (case type - (#Primitive name params) - (case params - #End - name - - _ - ($_ text\composite "(" name " " (|> params (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) ")")) - - (#Sum _) - ($_ text\composite "(Or " (|> (flat_variant type) (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) ")") - - (#Product _) - ($_ text\composite "[" (|> (flat_tuple type) (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) "]") - - (#Function _) - ($_ text\composite "(-> " (|> (flat_lambda type) (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) ")") - - (#Parameter id) - (nat\encoded id) - - (#Var id) - ($_ text\composite "⌈v:" (nat\encoded id) "⌋") - - (#Ex id) - ($_ text\composite "⟨e:" (nat\encoded id) "⟩") - - (#UnivQ env body) - ($_ text\composite "(All " (type\encoded body) ")") - - (#ExQ env body) - ($_ text\composite "(Ex " (type\encoded body) ")") - - (#Apply _) - (let [[func args] (flat_application type)] - ($_ text\composite - "(" (type\encoded func) " " - (|> args (list\each type\encoded) (list\interposed " ") list\reversed (list\mix text\composite "")) - ")")) - - (#Named name _) - (name\encoded name) - )) - (macro: .public (^open tokens) (case tokens (^ (list& [_ (#Form (list [_ (#Text alias)]))] body branches)) @@ -4100,7 +4235,8 @@ (failure "Wrong syntax for cond")))) (def: (enumeration' idx xs) - (All [a] (-> Nat (List a) (List [Nat a]))) + (All (_ a) + (-> Nat (List a) (List [Nat a]))) (case xs (#Item x xs') (#Item [idx x] (enumeration' ("lux i64 +" 1 idx) xs')) @@ -4109,7 +4245,8 @@ #End)) (def: (enumeration xs) - (All [a] (-> (List a) (List [Nat a]))) + (All (_ a) + (-> (List a) (List [Nat a]))) (enumeration' 0 xs)) (macro: .public (value@ tokens) @@ -4547,7 +4684,8 @@ (template [ ] [(def: .public - (All [s] (-> (I64 s) (I64 s))) + (All (_ s) + (-> (I64 s) (I64 s))) (|>> ( 1)))] [++ "lux i64 +"] @@ -4555,7 +4693,8 @@ ) (def: (interleaved xs ys) - (All [a] (-> (List a) (List a) (List a))) + (All (_ a) + (-> (List a) (List a) (List a))) (case xs #End #End @@ -4943,7 +5082,8 @@ (failure (..wrong_syntax_error (name_of ..$))))) (def: .public (same? reference sample) - (All [a] (-> a a Bit)) + (All (_ a) + (-> a a Bit)) ("lux is" reference sample)) (macro: .public (^@ tokens) @@ -5354,24 +5494,26 @@ #None (failure "Wrong syntax for Interface")))) -(def: (recursive_type name body) - (-> Text Code Code) - (let [body' (|> body - nested_quantification - (with_replacements (list [name (` (#.Apply .Nothing (~ (type_parameter 0))))])))] - (` (#.Apply .Nothing (#.UnivQ #.End (~ body')))))) +(def: (recursive_type g!self g!dummy name body) + (-> Code Code Text Code Code) + (` ((.All ((~ g!self) (~ g!dummy)) + (~ (let$ (local_identifier$ name) (` (#.Apply .Nothing (~ g!self))) + body))) + .Nothing))) (macro: .public (Rec tokens) (case tokens (^ (list [_ (#Identifier "" name)] body)) (do meta_monad - [body' (expansion body)] + [body' (expansion body) + g!self (identifier "g!self") + g!dummy (identifier "g!dummy")] (case body' (^ (list body' labels)) - (in (list (..recursive_type name body') labels)) + (in (list (..recursive_type g!self g!dummy name body') labels)) (^ (list body')) - (in (list (..recursive_type name body'))) + (in (list (..recursive_type g!self g!dummy name body'))) _ (failure "Wrong syntax for Rec"))) diff --git a/stdlib/source/library/lux/abstract/apply.lux b/stdlib/source/library/lux/abstract/apply.lux index c47951e89..c6f6a18a6 100644 --- a/stdlib/source/library/lux/abstract/apply.lux +++ b/stdlib/source/library/lux/abstract/apply.lux @@ -10,15 +10,15 @@ (Interface (: (Functor f) &functor) - (: (All [a b] + (: (All (_ a b) (-> (f a) (f (-> a b)) (f b))) on))) (implementation: .public (composite f_monad f_apply g_apply) - (All [F G] + (All (_ F G) (-> (Monad F) (Apply F) (Apply G) - ... TODO: Replace (All [a] (F (G a))) with (functor.Then F G) - (Apply (All [a] (F (G a)))))) + ... TODO: Replace (All (_ a) (F (G a))) with (functor.Then F G) + (Apply (All (_ a) (F (G a)))))) (def: &functor (functor.composite (value@ #&functor f_apply) diff --git a/stdlib/source/library/lux/abstract/codec.lux b/stdlib/source/library/lux/abstract/codec.lux index 0a1f8b2ba..e5cb66d50 100644 --- a/stdlib/source/library/lux/abstract/codec.lux +++ b/stdlib/source/library/lux/abstract/codec.lux @@ -15,7 +15,7 @@ decoded))) (implementation: .public (composite cb_codec ba_codec) - (All [a b c] + (All (_ a b c) (-> (Codec c b) (Codec b a) (Codec c a))) (def: encoded diff --git a/stdlib/source/library/lux/abstract/comonad.lux b/stdlib/source/library/lux/abstract/comonad.lux index 3e0422762..06d8640e4 100644 --- a/stdlib/source/library/lux/abstract/comonad.lux +++ b/stdlib/source/library/lux/abstract/comonad.lux @@ -16,10 +16,10 @@ (Interface (: (Functor w) &functor) - (: (All [a] + (: (All (_ a) (-> (w a) a)) out) - (: (All [a] + (: (All (_ a) (-> (w a) (w (w a)))) disjoint))) diff --git a/stdlib/source/library/lux/abstract/comonad/cofree.lux b/stdlib/source/library/lux/abstract/comonad/cofree.lux index e7d9cea7f..f9bfc2dd1 100644 --- a/stdlib/source/library/lux/abstract/comonad/cofree.lux +++ b/stdlib/source/library/lux/abstract/comonad/cofree.lux @@ -9,13 +9,13 @@ [a (F (CoFree F a))]) (implementation: .public (functor dsl) - (All [F] (-> (Functor F) (Functor (CoFree F)))) + (All (_ F) (-> (Functor F) (Functor (CoFree F)))) (def: (each f [head tail]) [(f head) (\ dsl each (each f) tail)])) (implementation: .public (comonad dsl) - (All [F] (-> (Functor F) (CoMonad (CoFree F)))) + (All (_ F) (-> (Functor F) (CoMonad (CoFree F)))) (def: &functor (..functor dsl)) diff --git a/stdlib/source/library/lux/abstract/enum.lux b/stdlib/source/library/lux/abstract/enum.lux index fd987f070..509669587 100644 --- a/stdlib/source/library/lux/abstract/enum.lux +++ b/stdlib/source/library/lux/abstract/enum.lux @@ -11,7 +11,7 @@ (: (-> e e) pred))) (def: .public (range enum from to) - (All [a] (-> (Enum a) a a (List a))) + (All (_ a) (-> (Enum a) a a (List a))) (let [(^open ".") enum] (loop [end to output #.End] diff --git a/stdlib/source/library/lux/abstract/equivalence.lux b/stdlib/source/library/lux/abstract/equivalence.lux index bfbe87a2d..d51ef9d9a 100644 --- a/stdlib/source/library/lux/abstract/equivalence.lux +++ b/stdlib/source/library/lux/abstract/equivalence.lux @@ -11,7 +11,8 @@ =))) (def: .public (rec sub) - (All [a] (-> (-> (Equivalence a) (Equivalence a)) (Equivalence a))) + (All (_ a) + (-> (-> (Equivalence a) (Equivalence a)) (Equivalence a))) (implementation (def: (= left right) (sub = left right)))) diff --git a/stdlib/source/library/lux/abstract/functor.lux b/stdlib/source/library/lux/abstract/functor.lux index 78b647a59..a43110453 100644 --- a/stdlib/source/library/lux/abstract/functor.lux +++ b/stdlib/source/library/lux/abstract/functor.lux @@ -4,7 +4,7 @@ (type: .public (Functor f) (Interface - (: (All [a b] + (: (All (_ a b) (-> (-> a b) (-> (f a) (f b)))) each))) @@ -13,10 +13,10 @@ (f (Fix f))) (type: .public (Or f g) - (All [a] (.Or (f a) (g a)))) + (All (_ a) (.Or (f a) (g a)))) (def: .public (sum (^open "f\.") (^open "g\.")) - (All [F G] (-> (Functor F) (Functor G) (Functor (..Or F G)))) + (All (_ F G) (-> (Functor F) (Functor G) (Functor (..Or F G)))) (implementation (def: (each f fa|ga) (case fa|ga @@ -27,20 +27,20 @@ (#.Right (g\each f ga)))))) (type: .public (And f g) - (All [a] (.And (f a) (g a)))) + (All (_ a) (.And (f a) (g a)))) (def: .public (product (^open "f\.") (^open "g\.")) - (All [F G] (-> (Functor F) (Functor G) (Functor (..And F G)))) + (All (_ F G) (-> (Functor F) (Functor G) (Functor (..And F G)))) (implementation (def: (each f [fa ga]) [(f\each f fa) (g\each f ga)]))) (type: .public (Then f g) - (All [a] (f (g a)))) + (All (_ a) (f (g a)))) (def: .public (composite (^open "f\.") (^open "g\.")) - (All [F G] (-> (Functor F) (Functor G) (Functor (..Then F G)))) + (All (_ F G) (-> (Functor F) (Functor G) (Functor (..Then F G)))) (implementation (def: (each f fga) (f\each (g\each f) fga)))) diff --git a/stdlib/source/library/lux/abstract/functor/contravariant.lux b/stdlib/source/library/lux/abstract/functor/contravariant.lux index 374cb9a80..15b8053e6 100644 --- a/stdlib/source/library/lux/abstract/functor/contravariant.lux +++ b/stdlib/source/library/lux/abstract/functor/contravariant.lux @@ -4,7 +4,7 @@ (type: .public (Functor f) (Interface - (: (All [a b] + (: (All (_ a b) (-> (-> b a) (-> (f a) (f b)))) each))) diff --git a/stdlib/source/library/lux/abstract/interval.lux b/stdlib/source/library/lux/abstract/interval.lux index d97e9fcbb..d2af3e21c 100644 --- a/stdlib/source/library/lux/abstract/interval.lux +++ b/stdlib/source/library/lux/abstract/interval.lux @@ -19,14 +19,14 @@ top))) (def: .public (between enum bottom top) - (All [a] (-> (Enum a) a a (Interval a))) + (All (_ a) (-> (Enum a) a a (Interval a))) (implementation (def: &enum enum) (def: bottom bottom) (def: top top))) (def: .public (singleton enum elem) - (All [a] (-> (Enum a) a (Interval a))) + (All (_ a) (-> (Enum a) a (Interval a))) (implementation (def: &enum enum) (def: bottom elem) @@ -34,7 +34,7 @@ (template [ ] [(def: .public ( interval) - (All [a] (-> (Interval a) Bit)) + (All (_ a) (-> (Interval a) Bit)) (let [(^open ",\.") interval] ( ,\bottom ,\top)))] @@ -44,7 +44,7 @@ ) (def: .public (within? interval elem) - (All [a] (-> (Interval a) a Bit)) + (All (_ a) (-> (Interval a) a Bit)) (let [(^open ",\.") interval] (cond (inner? interval) (and (order.>= ,\&order ,\bottom elem) @@ -60,7 +60,7 @@ (template [ ] [(def: .public ( elem interval) - (All [a] (-> a (Interval a) Bit)) + (All (_ a) (-> a (Interval a) Bit)) (let [(^open ".") interval] (= elem)))] @@ -69,45 +69,45 @@ ) (def: .public (borders? interval elem) - (All [a] (-> (Interval a) a Bit)) + (All (_ a) (-> (Interval a) a Bit)) (or (starts_with? elem interval) (ends_with? elem interval))) (implementation: .public (union left right) - (All [a] (-> (Interval a) (Interval a) (Interval a))) + (All (_ a) (-> (Interval a) (Interval a) (Interval a))) (def: &enum (value@ #&enum right)) (def: bottom (order.min (\ right &order) (\ left bottom) (\ right bottom))) (def: top (order.max (\ right &order) (\ left top) (\ right top)))) (implementation: .public (intersection left right) - (All [a] (-> (Interval a) (Interval a) (Interval a))) + (All (_ a) (-> (Interval a) (Interval a) (Interval a))) (def: &enum (value@ #&enum right)) (def: bottom (order.max (\ right &order) (\ left bottom) (\ right bottom))) (def: top (order.min (\ right &order) (\ left top) (\ right top)))) (implementation: .public (complement interval) - (All [a] (-> (Interval a) (Interval a))) + (All (_ a) (-> (Interval a) (Interval a))) (def: &enum (value@ #&enum interval)) (def: bottom (\ interval succ (\ interval top))) (def: top (\ interval pred (\ interval bottom)))) (def: .public (precedes? reference sample) - (All [a] (-> (Interval a) (Interval a) Bit)) + (All (_ a) (-> (Interval a) (Interval a) Bit)) (let [(^open ".") reference limit (\ reference bottom)] (and (< limit (\ sample bottom)) (< limit (\ sample top))))) (def: .public (succeeds? reference sample) - (All [a] (-> (Interval a) (Interval a) Bit)) + (All (_ a) (-> (Interval a) (Interval a) Bit)) (precedes? sample reference)) (template [ ] [(def: .public ( reference sample) - (All [a] (-> a (Interval a) Bit)) + (All (_ a) (-> a (Interval a) Bit)) (let [(^open ",\.") sample] (and ( reference ,\bottom) ( reference ,\top))))] @@ -117,20 +117,20 @@ ) (def: .public (meets? reference sample) - (All [a] (-> (Interval a) (Interval a) Bit)) + (All (_ a) (-> (Interval a) (Interval a) Bit)) (let [(^open ",\.") reference limit (\ reference bottom)] (and (,\= limit (\ sample top)) (order.<= ,\&order limit (\ sample bottom))))) (def: .public (touches? reference sample) - (All [a] (-> (Interval a) (Interval a) Bit)) + (All (_ a) (-> (Interval a) (Interval a) Bit)) (or (meets? reference sample) (meets? sample reference))) (template [ ] [(def: .public ( reference sample) - (All [a] (-> (Interval a) (Interval a) Bit)) + (All (_ a) (-> (Interval a) (Interval a) Bit)) (let [(^open ",\.") reference] (and (,\= (\ reference ) (\ sample )) @@ -143,7 +143,7 @@ ) (implementation: .public equivalence - (All [a] (Equivalence (Interval a))) + (All (_ a) (Equivalence (Interval a))) (def: (= reference sample) (let [(^open ",\.") reference] @@ -151,7 +151,7 @@ (,\= ,\top (\ sample top)))))) (def: .public (nested? reference sample) - (All [a] (-> (Interval a) (Interval a) Bit)) + (All (_ a) (-> (Interval a) (Interval a) Bit)) (cond (or (singleton? sample) (and (inner? reference) (inner? sample)) (and (outer? reference) (outer? sample))) @@ -172,7 +172,7 @@ )) (def: .public (overlaps? reference sample) - (All [a] (-> (Interval a) (Interval a) Bit)) + (All (_ a) (-> (Interval a) (Interval a) Bit)) (let [(^open ",\.") reference] (and (not (\ ..equivalence = reference sample)) (cond (singleton? sample) diff --git a/stdlib/source/library/lux/abstract/mix.lux b/stdlib/source/library/lux/abstract/mix.lux index 9733066df..432fa6472 100644 --- a/stdlib/source/library/lux/abstract/mix.lux +++ b/stdlib/source/library/lux/abstract/mix.lux @@ -6,12 +6,12 @@ (type: .public (Mix F) (Interface - (: (All [a b] + (: (All (_ a b) (-> (-> b a a) a (F b) a)) mix))) (def: .public (with_monoid monoid mix value) - (All [F a] + (All (_ F a) (-> (Monoid a) (Mix F) (F a) a)) (let [(^open "/\.") monoid] (mix /\composite /\identity value))) diff --git a/stdlib/source/library/lux/abstract/monad.lux b/stdlib/source/library/lux/abstract/monad.lux index ab03e9a18..b4d2eb7ed 100644 --- a/stdlib/source/library/lux/abstract/monad.lux +++ b/stdlib/source/library/lux/abstract/monad.lux @@ -7,7 +7,7 @@ [functor (#+ Functor)]]) (def: (list\mix f init xs) - (All [a b] + (All (_ a b) (-> (-> b a a) a (List b) a)) (case xs #.End @@ -17,7 +17,7 @@ (list\mix f (f x init) xs'))) (def: (list\size xs) - (All [a] (-> (List a) Nat)) + (All (_ a) (-> (List a) Nat)) (loop [counter 0 xs xs] (case xs @@ -28,14 +28,14 @@ (recur (++ counter) xs')))) (def: (reversed xs) - (All [a] + (All (_ a) (-> (List a) (List a))) (list\mix (function (_ head tail) (#.Item head tail)) #.End xs)) (def: (pairs xs) - (All [a] (-> (List a) (List [a a]))) + (All (_ a) (-> (List a) (List [a a]))) (case xs (#.Item x1 (#.Item x2 xs')) (#.Item [x1 x2] (pairs xs')) @@ -47,10 +47,10 @@ (Interface (: (Functor m) &functor) - (: (All [a] + (: (All (_ a) (-> a (m a))) in) - (: (All [a] + (: (All (_ a) (-> (m (m a)) (m a))) conjoint))) @@ -107,14 +107,14 @@ (#.Left "Wrong syntax for 'do'"))) (def: .public (then monad f) - (All [! a b] + (All (_ ! a b) (-> (Monad !) (-> a (! b)) (-> (! a) (! b)))) (|>> (\ monad each f) (\ monad conjoint))) (def: .public (all monad) - (All [! a] + (All (_ ! a) (-> (Monad !) (List (! a)) (! (List a)))) (let [(^open "!\.") monad] @@ -130,7 +130,7 @@ !\conjoint))))) (def: .public (each monad f) - (All [M a b] + (All (_ M a b) (-> (Monad M) (-> a (M b)) (List a) (M (List b)))) (let [(^open "!\.") monad] @@ -146,7 +146,7 @@ !\conjoint))))) (def: .public (only monad f) - (All [! a b] + (All (_ ! a b) (-> (Monad !) (-> a (! Bit)) (List a) (! (List a)))) (let [(^open "!\.") monad] @@ -166,7 +166,7 @@ !\conjoint))))) (def: .public (mix monad f init xs) - (All [M a b] + (All (_ M a b) (-> (Monad M) (-> b a (M a)) a (List b) (M a))) (case xs diff --git a/stdlib/source/library/lux/abstract/monad/free.lux b/stdlib/source/library/lux/abstract/monad/free.lux index 101a23d87..3dde675a6 100644 --- a/stdlib/source/library/lux/abstract/monad/free.lux +++ b/stdlib/source/library/lux/abstract/monad/free.lux @@ -12,7 +12,7 @@ (#Effect (F (Free F a))))) (implementation: .public (functor dsl) - (All [F] (-> (Functor F) (Functor (Free F)))) + (All (_ F) (-> (Functor F) (Functor (Free F)))) (def: (each f ea) (case ea @@ -23,7 +23,7 @@ (#Effect (\ dsl each (each f) value))))) (implementation: .public (apply dsl) - (All [F] (-> (Functor F) (Apply (Free F)))) + (All (_ F) (-> (Functor F) (Apply (Free F)))) (def: &functor (..functor dsl)) @@ -43,7 +43,7 @@ ))) (implementation: .public (monad dsl) - (All [F] (-> (Functor F) (Monad (Free F)))) + (All (_ F) (-> (Functor F) (Monad (Free F)))) (def: &functor (..functor dsl)) diff --git a/stdlib/source/library/lux/abstract/monad/indexed.lux b/stdlib/source/library/lux/abstract/monad/indexed.lux index 98acab0e1..58e7e4633 100644 --- a/stdlib/source/library/lux/abstract/monad/indexed.lux +++ b/stdlib/source/library/lux/abstract/monad/indexed.lux @@ -14,11 +14,11 @@ (type: .public (IxMonad m) (Interface - (: (All [p a] + (: (All (_ p a) (-> a (m p p a))) in) - (: (All [ii it io vi vo] + (: (All (_ ii it io vi vo) (-> (-> vi (m it io vo)) (m ii it vi) (m ii io vo))) @@ -50,7 +50,7 @@ binding)) (def: (pair_list [binding value]) - (All [a] (-> [a a] (List a))) + (All (_ a) (-> [a a] (List a))) (list binding value)) (def: named_monad diff --git a/stdlib/source/library/lux/abstract/monoid.lux b/stdlib/source/library/lux/abstract/monoid.lux index 3012bd4bd..b8a31a356 100644 --- a/stdlib/source/library/lux/abstract/monoid.lux +++ b/stdlib/source/library/lux/abstract/monoid.lux @@ -10,7 +10,7 @@ composite))) (def: .public (and left right) - (All [l r] (-> (Monoid l) (Monoid r) (Monoid [l r]))) + (All (_ l r) (-> (Monoid l) (Monoid r) (Monoid [l r]))) (implementation (def: identity [(\ left identity) (\ right identity)]) diff --git a/stdlib/source/library/lux/abstract/predicate.lux b/stdlib/source/library/lux/abstract/predicate.lux index 5c5cde91b..16c927ac4 100644 --- a/stdlib/source/library/lux/abstract/predicate.lux +++ b/stdlib/source/library/lux/abstract/predicate.lux @@ -17,7 +17,7 @@ (function.constant )) (def: .public ( left right) - (All [a] (-> (Predicate a) (Predicate a) (Predicate a))) + (All (_ a) (-> (Predicate a) (Predicate a) (Predicate a))) (function (_ value) ( (left value) (right value))))] @@ -28,7 +28,7 @@ (template [ ] [(implementation: .public - (All [a] (Monoid (Predicate a))) + (All (_ a) (Monoid (Predicate a))) (def: identity ) (def: composite ))] @@ -38,17 +38,17 @@ ) (def: .public (complement predicate) - (All [a] (-> (Predicate a) (Predicate a))) + (All (_ a) (-> (Predicate a) (Predicate a))) (|>> predicate not)) (def: .public (difference sub base) - (All [a] (-> (Predicate a) (Predicate a) (Predicate a))) + (All (_ a) (-> (Predicate a) (Predicate a) (Predicate a))) (function (_ value) (.and (base value) (not (sub value))))) (def: .public (rec predicate) - (All [a] + (All (_ a) (-> (-> (Predicate a) (Predicate a)) (Predicate a))) (function (recur input) diff --git a/stdlib/source/library/lux/control/concatenative.lux b/stdlib/source/library/lux/control/concatenative.lux index 9cc286c29..6f3f64403 100644 --- a/stdlib/source/library/lux/control/concatenative.lux +++ b/stdlib/source/library/lux/control/concatenative.lux @@ -31,7 +31,7 @@ (type: Stack (Record - {#bottom (Maybe Nat) + {#bottom (Maybe Code) #top (List Code)})) (def: aliases^ @@ -41,15 +41,19 @@ .record (<>.else (list)))) +(def: top^ + (Parser (List Code)) + (.tuple (<>.some .any))) + (def: bottom^ - (Parser Nat) - (.form (<>.after (.this! (` #.Parameter)) .nat))) + (Parser Code) + (.not ..top^)) (def: stack^ (Parser Stack) (<>.either (<>.and (<>.maybe bottom^) - (.tuple (<>.some .any))) - (<>.and (|> bottom^ (<>\each (|>> #.Some))) + ..top^) + (<>.and (<>\each (|>> #.Some) bottom^) (<>\in (list))))) (def: (stack_mix tops bottom) @@ -79,8 +83,8 @@ (code.replaced (code.local_identifier from) to pre)) aliased aliases))] - (case [(|> inputs (value@ #bottom) (maybe\each (|>> code.nat (~) #.Parameter (`)))) - (|> outputs (value@ #bottom) (maybe\each (|>> code.nat (~) #.Parameter (`))))] + (case [(value@ #bottom inputs) + (value@ #bottom outputs)] [(#.Some bottomI) (#.Some bottomO)] (monad.do meta.monad [inputC (singleton (macro.full_expansion (stack_mix (value@ #top inputs) bottomI))) @@ -93,16 +97,17 @@ (monad.do meta.monad [inputC (singleton (macro.full_expansion (stack_mix (value@ #top inputs) (maybe.else g!stack ?bottomI)))) outputC (singleton (macro.full_expansion (stack_mix (value@ #top outputs) (maybe.else g!stack ?bottomO))))] - (in (list (` (All [(~ g!stack)] - (-> (~ (de_alias inputC)) - (~ (de_alias outputC)))))))))))) + (with_identifiers [g!_] + (in (list (` (All ((~ g!_) (~ g!stack)) + (-> (~ (de_alias inputC)) + (~ (de_alias outputC))))))))))))) (def: begin! Any []) (def: end! - (All [a] (-> [Any a] a)) + (All (_ a) (-> [Any a] a)) (function (_ [_ top]) top)) @@ -129,14 +134,14 @@ (|>> (~+ commands))))))) (syntax: .public (apply [arity (<>.only (n.> 0) .nat)]) - (with_identifiers [g! g!func g!stack g!output] + (with_identifiers [g!_ g!func g!stack g!output] (monad.do {! meta.monad} [g!inputs (|> (macro.identifier "input") (list.repeated arity) (monad.all !))] - (in (list (` (: (All [(~+ g!inputs) (~ g!output)] + (in (list (` (: (All ((~ g!_) (~+ g!inputs) (~ g!output)) (-> (-> (~+ g!inputs) (~ g!output)) (=> [(~+ g!inputs)] [(~ g!output)]))) - (function ((~ g!) (~ g!func)) - (function ((~ g!) (~ (stack_mix g!inputs g!stack))) + (function ((~ g!_) (~ g!func)) + (function ((~ g!_) (~ (stack_mix g!inputs g!stack))) [(~ g!stack) ((~ g!func) (~+ g!inputs))]))))))))) (template [] @@ -148,52 +153,52 @@ ) (def: .public (push x) - (All [a] (-> a (=> [] [a]))) + (All (_ a) (-> a (=> [] [a]))) (function (_ stack) [stack x])) (def: .public drop - (All [t] (=> [t] [])) + (All (_ t) (=> [t] [])) (function (_ [stack top]) stack)) (def: .public nip - (All [_ a] (=> [_ a] [a])) + (All (_ _ a) (=> [_ a] [a])) (function (_ [[stack _] top]) [stack top])) (def: .public dup - (All [a] (=> [a] [a a])) + (All (_ a) (=> [a] [a a])) (function (_ [stack top]) [[stack top] top])) (def: .public swap - (All [a b] (=> [a b] [b a])) + (All (_ a b) (=> [a b] [b a])) (function (_ [[stack l] r]) [[stack r] l])) (def: .public rotL - (All [a b c] (=> [a b c] [b c a])) + (All (_ a b c) (=> [a b c] [b c a])) (function (_ [[[stack a] b] c]) [[[stack b] c] a])) (def: .public rotR - (All [a b c] (=> [a b c] [c a b])) + (All (_ a b c) (=> [a b c] [c a b])) (function (_ [[[stack a] b] c]) [[[stack c] a] b])) (def: .public && - (All [a b] (=> [a b] [(Tuple a b)])) + (All (_ a b) (=> [a b] [(Tuple a b)])) (function (_ [[stack l] r]) [stack [l r]])) (def: .public ||L - (All [a b] (=> [a] [(Or a b)])) + (All (_ a b) (=> [a] [(Or a b)])) (function (_ [stack l]) [stack (0 #0 l)])) (def: .public ||R - (All [a b] (=> [b] [(Or a b)])) + (All (_ a b) (=> [b] [(Or a b)])) (function (_ [stack r]) [stack (0 #1 r)])) @@ -249,7 +254,7 @@ ) (def: .public if - (All [___a ___z] + (All (_ ___a ___z) (=> {then (=> ___a ___z) else (=> ___a ___z)} ___a [Bit then else] ___z)) @@ -259,14 +264,14 @@ (else stack)))) (def: .public call - (All [___a ___z] + (All (_ ___a ___z) (=> {quote (=> ___a ___z)} ___a [quote] ___z)) (function (_ [stack quote]) (quote stack))) (def: .public loop - (All [___] + (All (_ ___) (=> {test (=> ___ ___ [Bit])} ___ [test] ___)) (function (loop [stack pred]) @@ -276,21 +281,21 @@ stack')))) (def: .public dip - (All [___ a] + (All (_ ___ a) (=> ___ [a (=> ___ ___)] ___ [a])) (function (_ [[stack a] quote]) [(quote stack) a])) (def: .public dip/2 - (All [___ a b] + (All (_ ___ a b) (=> ___ [a b (=> ___ ___)] ___ [a b])) (function (_ [[[stack a] b] quote]) [[(quote stack) a] b])) (def: .public do - (All [___a ___z] + (All (_ ___a ___z) (=> {body (=> ___a ___z) pred (=> ___z ___a [Bit])} ___a [pred body] @@ -299,7 +304,7 @@ [[(body stack) pred] body])) (def: .public while - (All [___a ___z] + (All (_ ___a ___z) (=> {body (=> ___z ___a) pred (=> ___a ___z [Bit])} ___a [pred body] @@ -311,21 +316,21 @@ stack')))) (def: .public compose - (All [___a ___ ___z] + (All (_ ___a ___ ___z) (=> [(=> ___a ___) (=> ___ ___z)] [(=> ___a ___z)])) (function (_ [[stack f] g]) [stack (|>> f g)])) (def: .public partial - (All [___a ___z a] + (All (_ ___a ___z a) (=> ___a [a (=> ___a [a] ___z)] ___a [(=> ___a ___z)])) (function (_ [[stack arg] quote]) [stack (|>> (push arg) quote)])) (word: .public when - (All [___] + (All (_ ___) (=> {body (=> ___ ___)} ___ [Bit body] ___)) @@ -335,7 +340,7 @@ if) (word: .public ? - (All [a] + (All (_ a) (=> [Bit a a] [a])) rotL (push ..drop) diff --git a/stdlib/source/library/lux/control/concurrency/actor.lux b/stdlib/source/library/lux/control/concurrency/actor.lux index f7f5644d3..6d47288df 100644 --- a/stdlib/source/library/lux/control/concurrency/actor.lux +++ b/stdlib/source/library/lux/control/concurrency/actor.lux @@ -47,7 +47,7 @@ (Resolver [ Mailbox])]))] (def: (pending [read write]) - (All [a] + (All (_ a) (-> (Rec Mailbox [(Async [a Mailbox]) (Resolver [a Mailbox])]) @@ -82,7 +82,7 @@ #on_mail (-> (Mail s) s (Actor s) (Async (Try s)))})) (def: .public (spawn! behavior init) - (All [o s] (-> (Behavior o s) o (IO (Actor s)))) + (All (_ o s) (-> (Behavior o s) o (IO (Actor s)))) (io (let [[on_init on_mail] behavior self (:sharing [o s] (Behavior o s) @@ -110,7 +110,7 @@ self))) (def: .public (alive? actor) - (All [s] (-> (Actor s) (IO Bit))) + (All (_ s) (-> (Actor s) (IO Bit))) (let [[obituary _] (value@ #obituary (:representation actor))] (|> obituary async.value @@ -122,18 +122,18 @@ bit.no)))))) (def: .public (obituary' actor) - (All [s] (-> (Actor s) (IO (Maybe (Obituary s))))) + (All (_ s) (-> (Actor s) (IO (Maybe (Obituary s))))) (let [[obituary _] (value@ #obituary (:representation actor))] (async.value obituary))) (def: .public obituary - (All [s] (-> (Actor s) (Async (Obituary s)))) + (All (_ s) (-> (Actor s) (Async (Obituary s)))) (|>> :representation (value@ #obituary) product.left)) (def: .public (mail! mail actor) - (All [s] (-> (Mail s) (Actor s) (IO (Try Any)))) + (All (_ s) (-> (Mail s) (Actor s) (IO (Try Any)))) (do {! io.monad} [alive? (..alive? actor)] (if alive? @@ -161,7 +161,7 @@ (-> s (Actor s) (Async (Try [s o])))) (def: (mail message) - (All [s o] (-> (Message s o) [(Async (Try o)) (Mail s)])) + (All (_ s o) (-> (Message s o) [(Async (Try o)) (Mail s)])) (let [[async resolve] (:sharing [s o] (Message s o) message @@ -185,7 +185,7 @@ (async.resolved (#try.Failure error))))))])) (def: .public (tell! message actor) - (All [s o] (-> (Message s o) (Actor s) (Async (Try o)))) + (All (_ s o) (-> (Message s o) (Actor s) (Async (Try o)))) (let [[async mail] (..mail message)] (do async.monad [outcome (async.future (..mail! mail actor))] @@ -199,16 +199,16 @@ ) (def: (default_on_mail mail state self) - (All [s] (-> (Mail s) s (Actor s) (Async (Try s)))) + (All (_ s) (-> (Mail s) s (Actor s) (Async (Try s)))) (mail state self)) (def: .public default - (All [s] (Behavior s s)) + (All (_ s) (Behavior s s)) {#on_init function.identity #on_mail ..default_on_mail}) (def: .public (poison! actor) - (All [s] (-> (Actor s) (IO (Try Any)))) + (All (_ s) (-> (Actor s) (IO (Try Any)))) (..mail! (function (_ state self) (async.resolved (exception.except ..poisoned []))) actor)) @@ -272,7 +272,7 @@ (~ state_type) (def: (~ export_policy) (~ g!actor) - (All [(~+ g!vars)] + (All ((~ g!_) (~+ g!vars)) (..Behavior (~ state_type) ((~ g!type) (~+ g!vars)))) {#..on_init (|>> ((~! abstract.:abstraction) (~ g!type))) #..on_mail (~ (..on_mail g!_ ?on_mail))}) @@ -336,7 +336,7 @@ g!self (|> signature (value@ #self) code.local_identifier)]] (in (list (` (def: (~ export_policy) ((~ g!message) (~+ g!inputsC)) (~ (|annotations|.format annotations)) - (All [(~+ g!all_vars)] + (All ((~ g!_) (~+ g!all_vars)) (-> (~+ g!inputsT) (..Message (~ (value@ #abstract.abstraction actor_scope)) (~ output_type)))) @@ -357,7 +357,7 @@ (def: stop! false) (def: .public (observe! action channel actor) - (All [e s] (-> (-> e Stop (Mail s)) (Channel e) (Actor s) (IO Any))) + (All (_ e s) (-> (-> e Stop (Mail s)) (Channel e) (Actor s) (IO Any))) (let [signal (: (Atom Bit) (atom.atom ..continue!)) stop (: Stop diff --git a/stdlib/source/library/lux/control/concurrency/async.lux b/stdlib/source/library/lux/control/concurrency/async.lux index c996e1dcc..90229a9f5 100644 --- a/stdlib/source/library/lux/control/concurrency/async.lux +++ b/stdlib/source/library/lux/control/concurrency/async.lux @@ -27,7 +27,7 @@ ... Sets an async's value if it has not been done yet. (def: (resolver async) - (All [a] (-> (Async a) (Resolver a))) + (All (_ a) (-> (Async a) (Resolver a))) (function (resolve value) (let [async (:representation async)] (do {! io.monad} @@ -48,22 +48,22 @@ (resolve value)))))))) (def: .public (resolved value) - (All [a] (-> a (Async a))) + (All (_ a) (-> a (Async a))) (:abstraction (atom [(#.Some value) (list)]))) (def: .public (async _) - (All [a] (-> Any [(Async a) (Resolver a)])) + (All (_ a) (-> Any [(Async a) (Resolver a)])) (let [async (:abstraction (atom [#.None (list)]))] [async (..resolver async)])) (def: .public value - (All [a] (-> (Async a) (IO (Maybe a)))) + (All (_ a) (-> (Async a) (IO (Maybe a)))) (|>> :representation atom.read! (\ io.functor each product.left))) (def: .public (upon! f async) - (All [a] (-> (-> a (IO Any)) (Async a) (IO Any))) + (All (_ a) (-> (-> a (IO Any)) (Async a) (IO Any))) (do {! io.monad} [.let [async (:representation async)] (^@ old [_value _observers]) (atom.read! async)] @@ -81,7 +81,7 @@ ) (def: .public resolved? - (All [a] (-> (Async a) (IO Bit))) + (All (_ a) (-> (Async a) (IO Bit))) (|>> ..value (\ io.functor each (|>> (case> #.None @@ -126,7 +126,7 @@ ma)))) (def: .public (and left right) - (All [a b] (-> (Async a) (Async b) (Async [a b]))) + (All (_ a b) (-> (Async a) (Async b) (Async [a b]))) (let [[read! write!] (:sharing [a b] [(Async a) (Async b)] [left right] @@ -142,7 +142,7 @@ read!)) (def: .public (or left right) - (All [a b] (-> (Async a) (Async b) (Async (Or a b)))) + (All (_ a b) (-> (Async a) (Async b) (Async (Or a b)))) (let [[a|b resolve] (..async [])] (with_expansions [ (template [ ] @@ -156,7 +156,7 @@ a|b)))) (def: .public (either left right) - (All [a] (-> (Async a) (Async a) (Async a))) + (All (_ a) (-> (Async a) (Async a) (Async a))) (let [[left||right resolve] (..async [])] (`` (exec (~~ (template [] @@ -167,7 +167,7 @@ left||right)))) (def: .public (schedule! milli_seconds computation) - (All [a] (-> Nat (IO a) (Async a))) + (All (_ a) (-> Nat (IO a) (Async a))) (let [[!out resolve] (..async [])] (exec (|> (do io.monad @@ -178,11 +178,11 @@ !out))) (def: .public future - (All [a] (-> (IO a) (Async a))) + (All (_ a) (-> (IO a) (Async a))) (..schedule! 0)) (def: .public (after milli_seconds value) - (All [a] (-> Nat a (Async a))) + (All (_ a) (-> Nat a (Async a))) (..schedule! milli_seconds (io value))) (def: .public (delay milli_seconds) @@ -190,6 +190,6 @@ (..after milli_seconds [])) (def: .public (within milli_seconds async) - (All [a] (-> Nat (Async a) (Async (Maybe a)))) + (All (_ a) (-> Nat (Async a) (Async (Maybe a)))) (..or (..delay milli_seconds) async)) diff --git a/stdlib/source/library/lux/control/concurrency/atom.lux b/stdlib/source/library/lux/control/concurrency/atom.lux index 5be4a9059..963400278 100644 --- a/stdlib/source/library/lux/control/concurrency/atom.lux +++ b/stdlib/source/library/lux/control/concurrency/atom.lux @@ -55,21 +55,21 @@ (array.Array a))) (def: .public (atom value) - (All [a] (-> a (Atom a))) + (All (_ a) (-> a (Atom a))) (:abstraction (with_expansions [ (java/util/concurrent/atomic/AtomicReference::new value)] (for {@.old @.jvm } ( 0 value ( 1)))))) (def: .public (read! atom) - (All [a] (-> (Atom a) (IO a))) + (All (_ a) (-> (Atom a) (IO a))) (io.io (with_expansions [ (java/util/concurrent/atomic/AtomicReference::get (:representation atom))] (for {@.old @.jvm } ( 0 (:representation atom)))))) (def: .public (compare_and_swap! current new atom) - (All [a] (-> a a (Atom a) (IO Bit))) + (All (_ a) (-> a a (Atom a) (IO Bit))) (io.io (with_expansions [ (java/util/concurrent/atomic/AtomicReference::compareAndSet current new (:representation atom))] (for {@.old @.jvm } @@ -81,7 +81,7 @@ )) (def: .public (update! f atom) - (All [a] (-> (-> a a) (Atom a) (IO [a a]))) + (All (_ a) (-> (-> a a) (Atom a) (IO [a a]))) (loop [_ []] (do io.monad [old (read! atom) @@ -92,7 +92,7 @@ (recur []))))) (def: .public (write! value atom) - (All [a] (-> a (Atom a) (IO a))) + (All (_ a) (-> a (Atom a) (IO a))) (|> atom (..update! (function.constant value)) (io\each product.left))) diff --git a/stdlib/source/library/lux/control/concurrency/frp.lux b/stdlib/source/library/lux/control/concurrency/frp.lux index c31908da3..7c13df0f4 100644 --- a/stdlib/source/library/lux/control/concurrency/frp.lux +++ b/stdlib/source/library/lux/control/concurrency/frp.lux @@ -30,7 +30,7 @@ feed))) (def: (sink resolve) - (All [a] + (All (_ a) (-> (async.Resolver (Maybe [a (Channel a)])) (Sink a))) (let [sink (atom.atom resolve)] @@ -79,7 +79,7 @@ (recur [])))))))))) (def: .public (channel _) - (All [a] (-> Any [(Channel a) (Sink a)])) + (All (_ a) (-> Any [(Channel a) (Sink a)])) (let [[async resolve] (async.async [])] [async (..sink resolve)])) @@ -151,7 +151,7 @@ (-> a (IO (Maybe Any)))) (def: .public (subscribe! subscriber channel) - (All [a] (-> (Subscriber a) (Channel a) (IO Any))) + (All (_ a) (-> (Subscriber a) (Channel a) (IO Any))) (io (exec (: (Async Any) (loop [channel channel] @@ -171,7 +171,7 @@ []))) (def: .public (only pass? channel) - (All [a] (-> (-> a Bit) (Channel a) (Channel a))) + (All (_ a) (-> (-> a Bit) (Channel a) (Channel a))) (do async.monad [item channel] (case item @@ -185,13 +185,13 @@ (in #.None)))) (def: .public (of_async async) - (All [a] (-> (Async a) (Channel a))) + (All (_ a) (-> (Async a) (Channel a))) (async\each (function (_ value) (#.Some [value ..empty])) async)) (def: .public (mix f init channel) - (All [a b] + (All (_ a b) (-> (-> b a (Async a)) a (Channel b) (Async a))) (do {! async.monad} @@ -206,7 +206,7 @@ (mix f init' tail))))) (def: .public (mixes f init channel) - (All [a b] + (All (_ a b) (-> (-> b a (Async a)) a (Channel b) (Channel a))) (do {! async.monad} @@ -221,7 +221,7 @@ (in (#.Some [init (mixes f init' tail)])))))) (def: .public (poll milli_seconds action) - (All [a] + (All (_ a) (-> Nat (IO a) [(Channel a) (Sink a)])) (let [[output sink] (channel [])] (exec @@ -237,7 +237,7 @@ (..poll milli_seconds (io []))) (def: .public (iterations f init) - (All [s o] (-> (-> s (Async (Maybe [s o]))) s (Channel o))) + (All (_ s o) (-> (-> s (Async (Maybe [s o]))) s (Channel o))) (do async.monad [?next (f init)] (case ?next @@ -248,7 +248,7 @@ (in #.None)))) (def: (distinct' equivalence previous channel) - (All [a] (-> (Equivalence a) a (Channel a) (Channel a))) + (All (_ a) (-> (Equivalence a) a (Channel a) (Channel a))) (do async.monad [item channel] (case item @@ -261,7 +261,7 @@ (in #.None)))) (def: .public (distinct equivalence channel) - (All [a] (-> (Equivalence a) (Channel a) (Channel a))) + (All (_ a) (-> (Equivalence a) (Channel a) (Channel a))) (do async.monad [item channel] (in (case item @@ -272,7 +272,7 @@ #.None)))) (def: .public (list channel) - (All [a] (-> (Channel a) (Async (List a)))) + (All (_ a) (-> (Channel a) (Async (List a)))) (do {! async.monad} [item channel] (case item @@ -284,7 +284,7 @@ (in #.End)))) (def: .public (sequential milli_seconds values) - (All [a] (-> Nat (List a) (Channel a))) + (All (_ a) (-> Nat (List a) (Channel a))) (case values #.End ..empty diff --git a/stdlib/source/library/lux/control/concurrency/semaphore.lux b/stdlib/source/library/lux/control/concurrency/semaphore.lux index 8f2378d3d..f0ff9d7ba 100644 --- a/stdlib/source/library/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/library/lux/control/concurrency/semaphore.lux @@ -47,7 +47,7 @@ #waiting_list queue.empty})))) (def: .public (wait! semaphore) - (Ex [k] (-> Semaphore (Async Any))) + (Ex (_ k) (-> Semaphore (Async Any))) (let [semaphore (:representation semaphore) [signal sink] (: [(Async Any) (Resolver Any)] (async.async []))] @@ -72,7 +72,7 @@ ["Max Positions" (%.nat max_positions)])) (def: .public (signal! semaphore) - (Ex [k] (-> Semaphore (Async (Try Int)))) + (Ex (_ k) (-> Semaphore (Async (Try Int)))) (let [semaphore (:representation semaphore)] (async.future (do {! io.monad} @@ -114,7 +114,7 @@ (|>> :representation ..signal!)) (def: .public (synchronize! mutex procedure) - (All [a] (-> Mutex (IO (Async a)) (Async a))) + (All (_ a) (-> Mutex (IO (Async a)) (Async a))) (do async.monad [_ (..acquire! mutex) output (io.run! procedure) diff --git a/stdlib/source/library/lux/control/concurrency/stm.lux b/stdlib/source/library/lux/control/concurrency/stm.lux index cb6a1e702..d8bb2568b 100644 --- a/stdlib/source/library/lux/control/concurrency/stm.lux +++ b/stdlib/source/library/lux/control/concurrency/stm.lux @@ -29,15 +29,15 @@ (Atom [a (List (Sink a))]) (def: .public (var value) - (All [a] (-> a (Var a))) + (All (_ a) (-> a (Var a))) (:abstraction (atom.atom [value (list)]))) (def: read! - (All [a] (-> (Var a) a)) + (All (_ a) (-> (Var a) a)) (|>> :representation atom.read! io.run! product.left)) (def: (un_follow! sink var) - (All [a] (-> (Sink a) (Var a) (IO Any))) + (All (_ a) (-> (Sink a) (Var a) (IO Any))) (do io.monad [_ (atom.update! (function (_ [value observers]) [value (list.only (|>> (same? sink) not) observers)]) @@ -45,7 +45,7 @@ (in []))) (def: (write! new_value var) - (All [a] (-> a (Var a) (IO Any))) + (All (_ a) (-> a (Var a) (IO Any))) (do {! io.monad} [.let [var' (:representation var)] (^@ old [old_value observers]) (atom.read! var') @@ -66,7 +66,7 @@ (write! new_value var)))) (def: .public (follow! target) - (All [a] (-> (Var a) (IO [(Channel a) (Sink a)]))) + (All (_ a) (-> (Var a) (IO [(Channel a) (Sink a)]))) (do io.monad [.let [[channel sink] (frp.channel [])] _ (atom.update! (function (_ [value observers]) @@ -82,13 +82,13 @@ #current a})) (type: Tx - (List (Ex [a] (Tx_Frame a)))) + (List (Ex (_ a) (Tx_Frame a)))) (type: .public (STM a) (-> Tx [Tx a])) (def: (var_value var tx) - (All [a] (-> (Var a) Tx (Maybe a))) + (All (_ a) (-> (Var a) Tx (Maybe a))) (|> tx (list.example (function (_ [_var _original _current]) (same? (:as (Var Any) var) @@ -98,7 +98,7 @@ :expected)) (def: .public (read var) - (All [a] (-> (Var a) (STM a))) + (All (_ a) (-> (Var a) (STM a))) (function (_ tx) (case (var_value var tx) (#.Some value) @@ -110,7 +110,7 @@ value])))) (def: (with_updated_var var value tx) - (All [a] (-> (Var a) a Tx Tx)) + (All (_ a) (-> (Var a) a Tx Tx)) (case tx #.End #.End @@ -128,7 +128,7 @@ (with_updated_var var value tx'))))) (def: .public (write value var) - (All [a] (-> a (Var a) (STM Any))) + (All (_ a) (-> a (Var a) (STM Any))) (function (_ tx) (case (var_value var tx) (#.Some _) @@ -173,7 +173,7 @@ (ma tx'))))) (def: .public (update f var) - (All [a] (-> (-> a a) (Var a) (STM [a a]))) + (All (_ a) (-> (-> a a) (Var a) (STM [a a]))) (do ..monad [a (..read var) .let [a' (f a)] @@ -187,7 +187,7 @@ tx)) (def: (commit_var! [_var _original _current]) - (-> (Ex [a] (Tx_Frame a)) (IO Any)) + (-> (Ex (_ a) (Tx_Frame a)) (IO Any)) (if (same? _original _current) (io []) (..write! _current _var))) @@ -201,8 +201,8 @@ (def: pending_commits (Atom (Rec Commits - [(Async [(Ex [a] (Commit a)) Commits]) - (Resolver [(Ex [a] (Commit a)) Commits])])) + [(Async [(Ex (_ a) (Commit a)) Commits]) + (Resolver [(Ex (_ a) (Commit a)) Commits])])) (atom (async.async []))) (def: commit_processor_flag @@ -210,7 +210,7 @@ (atom #0)) (def: (issue_commit! commit) - (All [a] (-> (Commit a) (IO Any))) + (All (_ a) (-> (Commit a) (IO Any))) (let [entry [commit (async.async [])]] (do {! io.monad} [|commits|&resolve (atom.read! pending_commits)] @@ -229,7 +229,7 @@ (recur tail))))))) (def: (process_commit! commit) - (All [a] (-> (Commit a) (IO Any))) + (All (_ a) (-> (Commit a) (IO Any))) (let [[stm_proc output resolve] commit [finished_tx value] (stm_proc fresh_tx)] (if (can_commit? finished_tx) @@ -258,7 +258,7 @@ ))) (def: .public (commit! stm_proc) - (All [a] (-> (STM a) (Async a))) + (All (_ a) (-> (STM a) (Async a))) (let [[output resolver] (async.async [])] (exec (io.run! (do io.monad diff --git a/stdlib/source/library/lux/control/continuation.lux b/stdlib/source/library/lux/control/continuation.lux index f56d127c7..ab9ec5ad7 100644 --- a/stdlib/source/library/lux/control/continuation.lux +++ b/stdlib/source/library/lux/control/continuation.lux @@ -17,15 +17,15 @@ (-> (-> i o) o)) (def: .public (continued next cont) - (All [i o] (-> (-> i o) (Cont i o) o)) + (All (_ i o) (-> (-> i o) (Cont i o) o)) (cont next)) (def: .public result - (All [a] (-> (Cont a a) a)) + (All (_ a) (-> (Cont a a) a)) (..continued function.identity)) (def: .public (with_current f) - (All [a b z] + (All (_ a b z) (-> (-> (-> a (Cont b z)) (Cont a z)) (Cont a z))) @@ -38,12 +38,12 @@ (in (list (` (.function ((~ g!_) (~ g!k)) ((~ g!k) (~ expr)))))))) (def: .public (reset scope) - (All [i o] (-> (Cont i i) (Cont i o))) + (All (_ i o) (-> (Cont i i) (Cont i o))) (function (_ k) (k (result scope)))) (def: .public (shift f) - (All [a] + (All (_ a) (-> (-> (-> a (Cont a a)) (Cont a a)) (Cont a a))) @@ -52,14 +52,14 @@ function.identity))) (implementation: .public functor - (All [o] (Functor (All [i] (Cont i o)))) + (All (_ o) (Functor (All (_ i) (Cont i o)))) (def: (each f fv) (function (_ k) (fv (function.composite k f))))) (implementation: .public apply - (All [o] (Apply (All [i] (Cont i o)))) + (All (_ o) (Apply (All (_ i) (Cont i o)))) (def: &functor ..functor) @@ -70,7 +70,7 @@ (function (_ f)) ff)))) (implementation: .public monad - (All [o] (Monad (All [i] (Cont i o)))) + (All (_ o) (Monad (All (_ i) (Cont i o)))) (def: &functor ..functor) @@ -82,7 +82,7 @@ (ffa (continued k))))) (def: .public (portal init) - (All [i o z] + (All (_ i o z) (-> i (Cont [(-> i (Cont o z)) i] diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux index bdca98684..4998142f7 100644 --- a/stdlib/source/library/lux/control/exception.lux +++ b/stdlib/source/library/lux/control/exception.lux @@ -32,11 +32,11 @@ #constructor (-> a Text)})) (def: .public (match? exception error) - (All [e] (-> (Exception e) Text Bit)) + (All (_ e) (-> (Exception e) Text Bit)) (text.starts_with? (value@ #label exception) error)) (def: .public (when exception then try) - (All [e a] + (All (_ e a) (-> (Exception e) (-> Text a) (Try a) (Try a))) (case try @@ -53,7 +53,7 @@ (#//.Failure error))))) (def: .public (otherwise else try) - (All [a] + (All (_ a) (-> (-> Text a) (Try a) a)) (case try (#//.Success output) @@ -63,15 +63,15 @@ (else error))) (def: .public (error exception message) - (All [e] (-> (Exception e) e Text)) + (All (_ e) (-> (Exception e) e Text)) ((value@ #..constructor exception) message)) (def: .public (except exception message) - (All [e a] (-> (Exception e) e (Try a))) + (All (_ e a) (-> (Exception e) e (Try a))) (#//.Failure (..error exception message))) (def: .public (assertion exception message test) - (All [e] (-> (Exception e) e Bit (Try Any))) + (All (_ e) (-> (Exception e) e Bit (Try Any))) (if test (#//.Success []) (..except exception message))) @@ -91,14 +91,14 @@ ))) (syntax: .public (exception: [[export_policy t_vars [name inputs] body] ..exception]) - (macro.with_identifiers [g!descriptor] + (macro.with_identifiers [g!_ g!descriptor] (do meta.monad [current_module meta.current_module_name .let [descriptor ($_ text\composite "{" current_module "." name "}" text.new_line) g!self (code.local_identifier name)]] (in (list (` (def: (~ export_policy) (~ g!self) - (All [(~+ (list\each |type_variable|.format t_vars))] + (All ((~ g!_) (~+ (list\each |type_variable|.format t_vars))) (..Exception [(~+ (list\each (value@ #|input|.type) inputs))])) (let [(~ g!descriptor) (~ (code.text descriptor))] {#..label (~ g!descriptor) @@ -143,7 +143,7 @@ (` [(~ header) (~ message)]))))))))))) (def: .public (listing format entries) - (All [a] + (All (_ a) (-> (-> a Text) (List a) Text)) (|> entries (list\mix (function (_ entry [index next]) @@ -171,7 +171,7 @@ error)) (def: .public (with exception message computation) - (All [e a] (-> (Exception e) e (Try a) (Try a))) + (All (_ e a) (-> (Exception e) e (Try a) (Try a))) (case computation (#//.Failure error) (#//.Failure (case error diff --git a/stdlib/source/library/lux/control/function.lux b/stdlib/source/library/lux/control/function.lux index 3bbcd1bce..41ac6eeeb 100644 --- a/stdlib/source/library/lux/control/function.lux +++ b/stdlib/source/library/lux/control/function.lux @@ -5,30 +5,30 @@ [monoid (#+ Monoid)]]]]) (def: .public identity - (All [a] (-> a a)) + (All (_ a) (-> a a)) (|>>)) (def: .public (composite f g) - (All [a b c] + (All (_ a b c) (-> (-> b c) (-> a b) (-> a c))) (|>> g f)) (def: .public (constant value) - (All [o] (-> o (All [i] (-> i o)))) + (All (_ o) (-> o (All (_ i) (-> i o)))) (function (_ _) value)) (def: .public (flipped f) - (All [a b c] + (All (_ a b c) (-> (-> a b c) (-> b a c))) (function (_ x y) (f y x))) (def: .public (on input function) - (All [i o] + (All (_ i o) (-> i (-> i o) o)) (function input)) (implementation: .public monoid - (All [a] (Monoid (-> a a))) + (All (_ a) (Monoid (-> a a))) (def: identity ..identity) (def: composite ..composite)) diff --git a/stdlib/source/library/lux/control/function/memo.lux b/stdlib/source/library/lux/control/function/memo.lux index 6245dea04..233ee8d07 100644 --- a/stdlib/source/library/lux/control/function/memo.lux +++ b/stdlib/source/library/lux/control/function/memo.lux @@ -16,7 +16,7 @@ ["#" mixin (#+ Mixin Recursive)]]) (def: .public memoization - (All [i o] + (All (_ i o) (Mixin i (State (Dictionary i o) o))) (function (_ delegate recur) (function (_ input) @@ -36,7 +36,7 @@ (Recursive i (State (Dictionary i o) o))) (def: .public (open memo) - (All [i o] + (All (_ i o) (:let [Memory (Dictionary i o)] (-> (Memo i o) (-> [Memory i] [Memory o])))) (let [memo (//.fixed (//.mixed ..memoization (//.of_recursive memo)))] @@ -44,14 +44,14 @@ (|> input memo (state.result memory))))) (def: .public (closed hash memo) - (All [i o] + (All (_ i o) (-> (Hash i) (Memo i o) (-> i o))) (let [memo (//.fixed (//.mixed ..memoization (//.of_recursive memo))) empty (dictionary.empty hash)] (|>> memo (state.result empty) product.right))) (def: .public (none hash memo) - (All [i o] + (All (_ i o) (-> (Hash i) (Memo i o) (-> i o))) (let [memo (//.fixed (//.of_recursive memo)) empty (dictionary.empty hash)] diff --git a/stdlib/source/library/lux/control/function/mixin.lux b/stdlib/source/library/lux/control/function/mixin.lux index 68d2e4bf0..357fdb7c1 100644 --- a/stdlib/source/library/lux/control/function/mixin.lux +++ b/stdlib/source/library/lux/control/function/mixin.lux @@ -13,7 +13,7 @@ (-> (-> i o) (-> i o) (-> i o))) (def: .public (fixed f) - (All [i o] (-> (Mixin i o) (-> i o))) + (All (_ i o) (-> (Mixin i o) (-> i o))) (function (mix input) ((f mix mix) input))) @@ -23,32 +23,32 @@ delegate)) (def: .public (mixed parent child) - (All [i o] (-> (Mixin i o) (Mixin i o) (Mixin i o))) + (All (_ i o) (-> (Mixin i o) (Mixin i o) (Mixin i o))) (function (_ delegate recur) (parent (child delegate recur) recur))) (implementation: .public monoid - (All [i o] (Monoid (Mixin i o))) + (All (_ i o) (Monoid (Mixin i o))) (def: identity ..nothing) (def: composite ..mixed)) (def: .public (advice when then) - (All [i o] (-> (Predicate i) (Mixin i o) (Mixin i o))) + (All (_ i o) (-> (Predicate i) (Mixin i o) (Mixin i o))) (function (_ delegate recur input) (if (when input) ((then delegate recur) input) (delegate input)))) (def: .public (before monad action) - (All [! i o] (-> (Monad !) (-> i (! Any)) (Mixin i (! o)))) + (All (_ ! i o) (-> (Monad !) (-> i (! Any)) (Mixin i (! o)))) (function (_ delegate recur input) (do monad [_ (action input)] (delegate input)))) (def: .public (after monad action) - (All [! i o] (-> (Monad !) (-> i o (! Any)) (Mixin i (! o)))) + (All (_ ! i o) (-> (Monad !) (-> i o (! Any)) (Mixin i (! o)))) (function (_ delegate recur input) (do monad [output (delegate input) @@ -59,6 +59,6 @@ (-> (-> i o) (-> i o))) (def: .public (of_recursive recursive) - (All [i o] (-> (Recursive i o) (Mixin i o))) + (All (_ i o) (-> (Recursive i o) (Mixin i o))) (function (_ delegate recur) (recursive recur))) diff --git a/stdlib/source/library/lux/control/io.lux b/stdlib/source/library/lux/control/io.lux index b418d435f..c72bffa73 100644 --- a/stdlib/source/library/lux/control/io.lux +++ b/stdlib/source/library/lux/control/io.lux @@ -20,7 +20,7 @@ (-> Any a) (def: label - (All [a] (-> (-> Any a) (IO a))) + (All (_ _ a) (-> (-> Any a) (IO a))) (|>> :abstraction)) (template: (!io computation) @@ -38,7 +38,7 @@ (~ computation)))))))) (def: .public run! - (All [a] (-> (IO a) a)) + (All (_ _ a) (-> (IO a) a)) (|>> ..run!')) (implementation: .public functor diff --git a/stdlib/source/library/lux/control/lazy.lux b/stdlib/source/library/lux/control/lazy.lux index c3a351c71..4539fdc15 100644 --- a/stdlib/source/library/lux/control/lazy.lux +++ b/stdlib/source/library/lux/control/lazy.lux @@ -23,7 +23,7 @@ (-> [] a) (def: (lazy' generator) - (All [a] (-> (-> [] a) (Lazy a))) + (All (_ a) (-> (-> [] a) (Lazy a))) (let [cache (atom.atom #.None)] (:abstraction (function (_ _) (case (io.run! (atom.read! cache)) @@ -37,7 +37,7 @@ value))))))) (def: .public (value lazy) - (All [a] (-> (Lazy a) a)) + (All (_ a) (-> (Lazy a) a)) ((:representation lazy) []))) (syntax: .public (lazy [expression .any]) @@ -45,7 +45,7 @@ (in (list (` ((~! ..lazy') (function ((~ g!_) (~ g!_)) (~ expression)))))))) (implementation: .public (equivalence (^open "\.")) - (All [a] (-> (Equivalence a) (Equivalence (Lazy a)))) + (All (_ a) (-> (Equivalence a) (Equivalence (Lazy a)))) (def: (= left right) (\= (..value left) diff --git a/stdlib/source/library/lux/control/maybe.lux b/stdlib/source/library/lux/control/maybe.lux index 6fbc4b294..cccf64ddf 100644 --- a/stdlib/source/library/lux/control/maybe.lux +++ b/stdlib/source/library/lux/control/maybe.lux @@ -16,7 +16,7 @@ ... (#.Some a)) (implementation: .public monoid - (All [a] (Monoid (Maybe a))) + (All (_ a) (Monoid (Maybe a))) (def: identity #.None) @@ -66,7 +66,7 @@ mx))) (implementation: .public (equivalence super) - (All [a] (-> (Equivalence a) (Equivalence (Maybe a)))) + (All (_ a) (-> (Equivalence a) (Equivalence (Maybe a)))) (def: (= mx my) (case [mx my] @@ -80,7 +80,7 @@ #0))) (implementation: .public (hash super) - (All [a] (-> (Hash a) (Hash (Maybe a)))) + (All (_ a) (-> (Hash a) (Hash (Maybe a)))) (def: &equivalence (..equivalence (\ super &equivalence))) @@ -94,7 +94,7 @@ (\ super hash value)))) (implementation: .public (with monad) - (All [M] (-> (Monad M) (Monad (All [a] (M (Maybe a)))))) + (All (_ M) (-> (Monad M) (Monad (All (_ a) (M (Maybe a)))))) (def: &functor (functor.composite (value@ #monad.&functor monad) @@ -113,7 +113,7 @@ Mma)))) (def: .public (lifted monad) - (All [M a] (-> (Monad M) (-> (M a) (M (Maybe a))))) + (All (_ M a) (-> (Monad M) (-> (M a) (M (Maybe a))))) (\ monad each (\ ..monad in))) (macro: .public (else tokens state) @@ -131,11 +131,11 @@ (#.Left "Wrong syntax for else"))) (def: .public trusted - (All [a] (-> (Maybe a) a)) + (All (_ a) (-> (Maybe a) a)) (|>> (..else (undefined)))) (def: .public (list value) - (All [a] (-> (Maybe a) (List a))) + (All (_ a) (-> (Maybe a) (List a))) (case value #.None #.End diff --git a/stdlib/source/library/lux/control/parser.lux b/stdlib/source/library/lux/control/parser.lux index 4d32c8df6..376ca3f53 100644 --- a/stdlib/source/library/lux/control/parser.lux +++ b/stdlib/source/library/lux/control/parser.lux @@ -20,7 +20,7 @@ (-> s (Try [s a]))) (implementation: .public functor - (All [s] (Functor (Parser s))) + (All (_ s) (Functor (Parser s))) (def: (each f ma) (function (_ input) @@ -32,7 +32,7 @@ (#try.Success [input' (f a)]))))) (implementation: .public apply - (All [s] (Apply (Parser s))) + (All (_ s) (Apply (Parser s))) (def: &functor ..functor) @@ -51,7 +51,7 @@ (#try.Failure msg))))) (implementation: .public monad - (All [s] (Monad (Parser s))) + (All (_ s) (Monad (Parser s))) (def: &functor ..functor) @@ -69,14 +69,14 @@ (ma input'))))) (def: .public (assertion message test) - (All [s] (-> Text Bit (Parser s Any))) + (All (_ s) (-> Text Bit (Parser s Any))) (function (_ input) (if test (#try.Success [input []]) (#try.Failure message)))) (def: .public (maybe parser) - (All [s a] + (All (_ s a) (-> (Parser s a) (Parser s (Maybe a)))) (function (_ input) (case (parser input) @@ -87,19 +87,19 @@ (#try.Success [input' (#.Some x)])))) (def: .public (result parser input) - (All [s a] + (All (_ s a) (-> (Parser s a) s (Try [s a]))) (parser input)) (def: .public (and first second) - (All [s a b] + (All (_ s a b) (-> (Parser s a) (Parser s b) (Parser s [a b]))) (do {! ..monad} [head first] (\ ! each (|>> [head]) second))) (def: .public (or left right) - (All [s a b] + (All (_ s a b) (-> (Parser s a) (Parser s b) (Parser s (Or a b)))) (function (_ tokens) (case (left tokens) @@ -115,7 +115,7 @@ (#try.Failure error))))) (def: .public (either this that) - (All [s a] + (All (_ s a) (-> (Parser s a) (Parser s a) (Parser s a))) (function (_ tokens) (case (this tokens) @@ -126,7 +126,7 @@ output))) (def: .public (some parser) - (All [s a] + (All (_ s a) (-> (Parser s a) (Parser s (List a)))) (function (_ input) (case (parser input) @@ -139,14 +139,14 @@ input')))) (def: .public (many parser) - (All [s a] + (All (_ s a) (-> (Parser s a) (Parser s (List a)))) (|> (..some parser) (..and parser) (\ ..monad each (|>> #.Item)))) (def: .public (exactly amount parser) - (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) + (All (_ s a) (-> Nat (Parser s a) (Parser s (List a)))) (case amount 0 (\ ..monad in (list)) _ (do {! ..monad} @@ -156,13 +156,13 @@ (\ ! each (|>> (#.Item x))))))) (def: .public (at_least amount parser) - (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) + (All (_ s a) (-> Nat (Parser s a) (Parser s (List a)))) (do {! ..monad} [minimum (..exactly amount parser)] (\ ! each (list\composite minimum) (..some parser)))) (def: .public (at_most amount parser) - (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) + (All (_ s a) (-> Nat (Parser s a) (Parser s (List a)))) (case amount 0 (\ ..monad in (list)) _ (function (_ input) @@ -176,7 +176,7 @@ input'))))) (def: .public (between minimum additional parser) - (All [s a] (-> Nat Nat (Parser s a) (Parser s (List a)))) + (All (_ s a) (-> Nat Nat (Parser s a) (Parser s (List a)))) (do {! ..monad} [minimum (..exactly minimum parser)] (case additional @@ -185,7 +185,7 @@ (..at_most additional parser))))) (def: .public (separated_by separator parser) - (All [s a b] (-> (Parser s b) (Parser s a) (Parser s (List a)))) + (All (_ s a b) (-> (Parser s b) (Parser s a) (Parser s (List a)))) (do {! ..monad} [?x (..maybe parser)] (case ?x @@ -199,7 +199,7 @@ (\ ! each (|>> (list\each product.right) (#.Item x))))))) (def: .public (not parser) - (All [s a] (-> (Parser s a) (Parser s Any))) + (All (_ s a) (-> (Parser s a) (Parser s Any))) (function (_ input) (case (parser input) (#try.Failure msg) @@ -209,12 +209,12 @@ (#try.Failure "Expected to fail; yet succeeded.")))) (def: .public (failure message) - (All [s a] (-> Text (Parser s a))) + (All (_ s a) (-> Text (Parser s a))) (function (_ input) (#try.Failure message))) (def: .public (lifted operation) - (All [s a] (-> (Try a) (Parser s a))) + (All (_ s a) (-> (Try a) (Parser s a))) (function (_ input) (case operation (#try.Success output) @@ -224,7 +224,7 @@ (#try.Failure error)))) (def: .public (else value parser) - (All [s a] (-> a (Parser s a) (Parser s a))) + (All (_ s a) (-> a (Parser s a) (Parser s a))) (function (_ input) (case (parser input) (#try.Failure error) @@ -234,37 +234,37 @@ (#try.Success [input' output])))) (def: .public remaining - (All [s] (Parser s s)) + (All (_ s) (Parser s s)) (function (_ inputs) (#try.Success [inputs inputs]))) (def: .public (rec parser) - (All [s a] (-> (-> (Parser s a) (Parser s a)) (Parser s a))) + (All (_ s a) (-> (-> (Parser s a) (Parser s a)) (Parser s a))) (function (_ inputs) (..result (parser (rec parser)) inputs))) (def: .public (after param subject) - (All [s _ a] (-> (Parser s _) (Parser s a) (Parser s a))) + (All (_ s _ a) (-> (Parser s _) (Parser s a) (Parser s a))) (do ..monad [_ param] subject)) (def: .public (before param subject) - (All [s _ a] (-> (Parser s _) (Parser s a) (Parser s a))) + (All (_ s _ a) (-> (Parser s _) (Parser s a) (Parser s a))) (do ..monad [output subject _ param] (in output))) (def: .public (only test parser) - (All [s a] (-> (-> a Bit) (Parser s a) (Parser s a))) + (All (_ s a) (-> (-> a Bit) (Parser s a) (Parser s a))) (do ..monad [output parser _ (..assertion "Constraint failed." (test output))] (in output))) (def: .public (parses? parser) - (All [s a] (-> (Parser s a) (Parser s Bit))) + (All (_ s a) (-> (Parser s a) (Parser s Bit))) (function (_ input) (case (parser input) (#try.Failure error) @@ -274,7 +274,7 @@ (#try.Success [input' true])))) (def: .public (parses parser) - (All [s a] (-> (Parser s a) (Parser s Any))) + (All (_ s a) (-> (Parser s a) (Parser s Any))) (function (_ input) (case (parser input) (#try.Failure error) @@ -284,7 +284,7 @@ (#try.Success [input' []])))) (def: .public (speculative parser) - (All [s a] (-> (Parser s a) (Parser s a))) + (All (_ s a) (-> (Parser s a) (Parser s a))) (function (_ input) (case (parser input) (#try.Success [input' output]) @@ -294,7 +294,7 @@ output))) (def: .public (codec codec parser) - (All [s a z] (-> (Codec a z) (Parser s a) (Parser s z))) + (All (_ s a z) (-> (Codec a z) (Parser s a) (Parser s z))) (function (_ input) (case (parser input) (#try.Failure error) diff --git a/stdlib/source/library/lux/control/parser/analysis.lux b/stdlib/source/library/lux/control/parser/analysis.lux index 27caea2af..e069d4e9f 100644 --- a/stdlib/source/library/lux/control/parser/analysis.lux +++ b/stdlib/source/library/lux/control/parser/analysis.lux @@ -51,7 +51,7 @@ (//.Parser (List Analysis))) (def: .public (result parser input) - (All [a] (-> (Parser a) (List Analysis) (Try a))) + (All (_ a) (-> (Parser a) (List Analysis) (Try a))) (case (parser input) (#try.Failure error) (#try.Failure error) @@ -122,7 +122,7 @@ ) (def: .public (tuple parser) - (All [a] (-> (Parser a) (Parser a))) + (All (_ a) (-> (Parser a) (Parser a))) (function (_ input) (case input (^ (list& (/.tuple head) tail)) diff --git a/stdlib/source/library/lux/control/parser/binary.lux b/stdlib/source/library/lux/control/parser/binary.lux index 220dd5ea2..409d2a872 100644 --- a/stdlib/source/library/lux/control/parser/binary.lux +++ b/stdlib/source/library/lux/control/parser/binary.lux @@ -38,7 +38,7 @@ ["Bytes read" (%.nat bytes_read)])) (def: .public (result parser input) - (All [a] (-> (Parser a) Binary (Try a))) + (All (_ a) (-> (Parser a) Binary (Try a))) (case (parser [0 input]) (#try.Failure msg) (#try.Failure msg) @@ -117,12 +117,12 @@ _ (//.lifted (exception.except ..invalid_tag [(~~ (template.amount +)) flag])))))]) (def: .public (or left right) - (All [l r] (-> (Parser l) (Parser r) (Parser (Or l r)))) + (All (_ l r) (-> (Parser l) (Parser r) (Parser (Or l r)))) (!variant [[0 #.Left left] [1 #.Right right]])) (def: .public (rec body) - (All [a] (-> (-> (Parser a) (Parser a)) (Parser a))) + (All (_ a) (-> (-> (Parser a) (Parser a)) (Parser a))) (function (_ input) (let [parser (body (rec body))] (parser input)))) @@ -185,7 +185,7 @@ (template [ ] [(def: .public ( valueP) - (All [v] (-> (Parser v) (Parser (Row v)))) + (All (_ v) (-> (Parser v) (Parser (Row v)))) (do //.monad [amount (: (Parser Nat) )] @@ -210,11 +210,11 @@ ) (def: .public maybe - (All [a] (-> (Parser a) (Parser (Maybe a)))) + (All (_ a) (-> (Parser a) (Parser (Maybe a)))) (..or ..any)) (def: .public (list value) - (All [a] (-> (Parser a) (Parser (List a)))) + (All (_ a) (-> (Parser a) (Parser (List a)))) (..rec (|>> (//.and value) (..or ..any)))) @@ -222,7 +222,7 @@ (exception: .public set_elements_are_not_unique) (def: .public (set hash value) - (All [a] (-> (Hash a) (Parser a) (Parser (Set a)))) + (All (_ a) (-> (Hash a) (Parser a) (Parser (Set a)))) (do //.monad [raw (..list value) .let [output (set.of_list hash raw)] diff --git a/stdlib/source/library/lux/control/parser/cli.lux b/stdlib/source/library/lux/control/parser/cli.lux index d9b4928ab..75ab5ab4b 100644 --- a/stdlib/source/library/lux/control/parser/cli.lux +++ b/stdlib/source/library/lux/control/parser/cli.lux @@ -14,7 +14,7 @@ (//.Parser (List Text) a)) (def: .public (result parser inputs) - (All [a] (-> (Parser a) (List Text) (Try a))) + (All (_ a) (-> (Parser a) (List Text) (Try a))) (case (//.result parser inputs) (#try.Success [remaining output]) (case remaining @@ -38,7 +38,7 @@ (#try.Failure "Cannot parse empty arguments.")))) (def: .public (parse parser) - (All [a] (-> (-> Text (Try a)) (Parser a))) + (All (_ a) (-> (-> Text (Try a)) (Parser a))) (function (_ inputs) (do try.monad [[remaining raw] (any inputs) @@ -55,7 +55,7 @@ (#try.Failure (format "Missing token: '" reference "'")))))) (def: .public (somewhere cli) - (All [a] (-> (Parser a) (Parser a))) + (All (_ a) (-> (Parser a) (Parser a))) (function (_ inputs) (loop [immediate inputs] (case (//.result cli immediate) @@ -81,13 +81,13 @@ _ (#try.Failure (format "Unknown parameters: " (text.interposed " " inputs)))))) (def: .public (named name value) - (All [a] (-> Text (Parser a) (Parser a))) + (All (_ a) (-> Text (Parser a) (Parser a))) (|> value (//.after (..this name)) ..somewhere)) (def: .public (parameter [short long] value) - (All [a] (-> [Text Text] (Parser a) (Parser a))) + (All (_ a) (-> [Text Text] (Parser a) (Parser a))) (|> value (//.after (//.either (..this short) (..this long))) ..somewhere)) diff --git a/stdlib/source/library/lux/control/parser/code.lux b/stdlib/source/library/lux/control/parser/code.lux index 9b83d835a..63b33e341 100644 --- a/stdlib/source/library/lux/control/parser/code.lux +++ b/stdlib/source/library/lux/control/parser/code.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- nat int rev local) + [lux (#- nat int rev local not) [abstract ["." monad (#+ do)]] [control @@ -22,7 +22,7 @@ ["." //]) (def: (un_paired pairs) - (All [a] (-> (List [a a]) (List a))) + (All (_ a) (-> (List [a a]) (List a))) (case pairs #.End #.End (#.Item [[x y] pairs']) (list& x y (un_paired pairs')))) @@ -46,6 +46,16 @@ (#.Item [t tokens']) (#try.Success [tokens' t])))) +(def: .public next + (Parser Code) + (function (_ tokens) + (case tokens + #.End + (#try.Failure "There are no tokens to parse!") + + (#.Item next _) + (#try.Success [tokens next])))) + (template [ ] [(with_expansions [ (as_is (#try.Failure ($_ text\composite "Cannot parse " (remaining_inputs tokens))))] (def: .public @@ -123,7 +133,7 @@ (template [ ] [(def: .public ( p) - (All [a] + (All (_ a) (-> (Parser a) (Parser a))) (function (_ tokens) (case tokens @@ -140,7 +150,7 @@ ) (def: .public (record p) - (All [a] + (All (_ a) (-> (Parser a) (Parser a))) (function (_ tokens) (case tokens @@ -167,7 +177,7 @@ _ false)]))) (def: .public (result parser inputs) - (All [a] (-> (Parser a) (List Code) (Try a))) + (All (_ a) (-> (Parser a) (List Code) (Try a))) (case (parser inputs) (#try.Failure error) (#try.Failure error) @@ -184,8 +194,18 @@ (text\composite "Unconsumed inputs: ")))))) (def: .public (local inputs parser) - (All [a] (-> (List Code) (Parser a) (Parser a))) + (All (_ a) (-> (List Code) (Parser a) (Parser a))) (function (_ real) (do try.monad [value (..result parser inputs)] (in [real value])))) + +(def: .public (not parser) + (All (_ a) (-> (Parser a) (Parser Code))) + (do //.monad + [sample ..next + result (//.or parser + ..any)] + (case result + (#.Left _) (//.failure (text\composite "Did NOT expect to parse code: " (code.format sample))) + (#.Right output) (in output)))) diff --git a/stdlib/source/library/lux/control/parser/environment.lux b/stdlib/source/library/lux/control/parser/environment.lux index fbb7335f5..8ca8e2890 100644 --- a/stdlib/source/library/lux/control/parser/environment.lux +++ b/stdlib/source/library/lux/control/parser/environment.lux @@ -40,5 +40,5 @@ (exception.except ..unknown_property [name])))) (def: .public (result parser environment) - (All [a] (-> (Parser a) Environment (Try a))) + (All (_ a) (-> (Parser a) Environment (Try a))) (\ try.monad each product.right (parser environment))) diff --git a/stdlib/source/library/lux/control/parser/json.lux b/stdlib/source/library/lux/control/parser/json.lux index dcbda6f71..f73bf4ce8 100644 --- a/stdlib/source/library/lux/control/parser/json.lux +++ b/stdlib/source/library/lux/control/parser/json.lux @@ -32,7 +32,7 @@ (exception: .public empty_input) (def: .public (result parser json) - (All [a] (-> (Parser a) JSON (Try a))) + (All (_ a) (-> (Parser a) JSON (Try a))) (case (//.result parser (list json)) (#try.Success [remainder output]) (case remainder @@ -113,12 +113,12 @@ ) (def: .public (nullable parser) - (All [a] (-> (Parser a) (Parser (Maybe a)))) + (All (_ a) (-> (Parser a) (Parser (Maybe a)))) (//.or ..null parser)) (def: .public (array parser) - (All [a] (-> (Parser a) (Parser a))) + (All (_ a) (-> (Parser a) (Parser a))) (do //.monad [head ..any] (case head @@ -139,7 +139,7 @@ (//.failure (exception.error ..unexpected_value [head]))))) (def: .public (object parser) - (All [a] (-> (Parser a) (Parser a))) + (All (_ a) (-> (Parser a) (Parser a))) (do //.monad [head ..any] (case head @@ -165,7 +165,7 @@ (//.failure (exception.error ..unexpected_value [head]))))) (def: .public (field field_name parser) - (All [a] (-> Text (Parser a) (Parser a))) + (All (_ a) (-> Text (Parser a) (Parser a))) (function (recur inputs) (case inputs (^ (list& (#/.String key) value inputs')) @@ -191,7 +191,7 @@ (exception.except ..unconsumed_input inputs)))) (def: .public dictionary - (All [a] (-> (Parser a) (Parser (Dictionary Text a)))) + (All (_ a) (-> (Parser a) (Parser (Dictionary Text a)))) (|>> (//.and ..string) //.some ..object diff --git a/stdlib/source/library/lux/control/parser/synthesis.lux b/stdlib/source/library/lux/control/parser/synthesis.lux index d6c6fbeca..07406f1d9 100644 --- a/stdlib/source/library/lux/control/parser/synthesis.lux +++ b/stdlib/source/library/lux/control/parser/synthesis.lux @@ -50,7 +50,7 @@ (//.Parser (List Synthesis))) (def: .public (result parser input) - (All [a] (-> (Parser a) (List Synthesis) (Try a))) + (All (_ a) (-> (Parser a) (List Synthesis) (Try a))) (case (parser input) (#try.Failure error) (#try.Failure error) @@ -118,7 +118,7 @@ ) (def: .public (tuple parser) - (All [a] (-> (Parser a) (Parser a))) + (All (_ a) (-> (Parser a) (Parser a))) (.function (_ input) (case input (^ (list& (/.tuple head) tail)) @@ -130,7 +130,7 @@ (exception.except ..cannot_parse input)))) (def: .public (function expected parser) - (All [a] (-> Arity (Parser a) (Parser [(Environment Synthesis) a]))) + (All (_ a) (-> Arity (Parser a) (Parser [(Environment Synthesis) a]))) (.function (_ input) (case input (^ (list& (/.function/abstraction [environment actual body]) tail)) @@ -144,7 +144,7 @@ (exception.except ..cannot_parse input)))) (def: .public (loop init_parsers iteration_parser) - (All [a b] (-> (Parser a) (Parser b) (Parser [Register a b]))) + (All (_ a b) (-> (Parser a) (Parser b) (Parser [Register a b]))) (.function (_ input) (case input (^ (list& (/.loop/scope [start inits iteration]) tail)) diff --git a/stdlib/source/library/lux/control/parser/text.lux b/stdlib/source/library/lux/control/parser/text.lux index 2dda427e6..5943fba26 100644 --- a/stdlib/source/library/lux/control/parser/text.lux +++ b/stdlib/source/library/lux/control/parser/text.lux @@ -54,7 +54,7 @@ (exception: .public cannot_slice) (def: .public (result parser input) - (All [a] (-> (Parser a) Text (Try a))) + (All (_ a) (-> (Parser a) Text (Try a))) (case (parser [start_offset input]) (#try.Failure msg) (#try.Failure msg) @@ -105,7 +105,7 @@ (template [ ] [(`` (def: .public ( parser) - (All [a] (-> (Parser a) (Parser ))) + (All (_ a) (-> (Parser a) (Parser ))) (function (_ input) (case (parser input) (#try.Failure msg) @@ -328,13 +328,13 @@ (//.between minimum additional parser))) (def: .public (enclosed [start end] parser) - (All [a] (-> [Text Text] (Parser a) (Parser a))) + (All (_ a) (-> [Text Text] (Parser a) (Parser a))) (|> parser (//.before (this end)) (//.after (this start)))) (def: .public (local local_input parser) - (All [a] (-> Text (Parser a) (Parser a))) + (All (_ a) (-> Text (Parser a) (Parser a))) (function (_ real_input) (case (..result parser local_input) (#try.Failure error) @@ -356,7 +356,7 @@ (exception.except ..cannot_slice []))))) (def: .public (then structured text) - (All [s a] + (All (_ s a) (-> (Parser a) (//.Parser s Text) (//.Parser s a))) diff --git a/stdlib/source/library/lux/control/parser/tree.lux b/stdlib/source/library/lux/control/parser/tree.lux index 0208134a3..4c87f17f3 100644 --- a/stdlib/source/library/lux/control/parser/tree.lux +++ b/stdlib/source/library/lux/control/parser/tree.lux @@ -16,17 +16,17 @@ (//.Parser (Zipper t) a)) (def: .public (result' parser zipper) - (All [t a] (-> (Parser t a) (Zipper t) (Try a))) + (All (_ t a) (-> (Parser t a) (Zipper t) (Try a))) (do try.monad [[zipper output] (//.result parser zipper)] (in output))) (def: .public (result parser tree) - (All [t a] (-> (Parser t a) (Tree t) (Try a))) + (All (_ t a) (-> (Parser t a) (Tree t) (Try a))) (result' parser (zipper.zipper tree))) (def: .public value - (All [t] (Parser t t)) + (All (_ t) (Parser t t)) (function (_ zipper) (#try.Success [zipper (zipper.value zipper)]))) @@ -34,7 +34,7 @@ (template [ ] [(def: .public - (All [t] (Parser t [])) + (All (_ t) (Parser t [])) (function (_ zipper) (case ( zipper) #.None diff --git a/stdlib/source/library/lux/control/parser/type.lux b/stdlib/source/library/lux/control/parser/type.lux index d51ebc152..96a2c6230 100644 --- a/stdlib/source/library/lux/control/parser/type.lux +++ b/stdlib/source/library/lux/control/parser/type.lux @@ -68,7 +68,7 @@ (dictionary.empty n.hash)) (def: (result' env poly types) - (All [a] (-> Env (Parser a) (List Type) (Try a))) + (All (_ a) (-> Env (Parser a) (List Type) (Try a))) (case (//.result poly [env types]) (#try.Failure error) (#try.Failure error) @@ -82,7 +82,7 @@ (exception.except ..unconsumed_input remaining)))) (def: .public (result poly type) - (All [a] (-> (Parser a) Type (Try a))) + (All (_ a) (-> (Parser a) Type (Try a))) (result' ..fresh poly (list type))) (def: .public env @@ -91,7 +91,7 @@ (#try.Success [[env inputs] env]))) (def: (with_env temp poly) - (All [a] (-> Env (Parser a) (Parser a))) + (All (_ a) (-> Env (Parser a) (Parser a))) (.function (_ [env inputs]) (case (//.result poly [temp inputs]) (#try.Failure error) @@ -121,7 +121,7 @@ (#try.Success [[env tail] headT])))) (def: .public (local types poly) - (All [a] (-> (List Type) (Parser a) (Parser a))) + (All (_ a) (-> (List Type) (Parser a) (Parser a))) (.function (_ [env pass_through]) (case (result' env poly types) (#try.Failure error) @@ -135,7 +135,7 @@ (code.local_identifier ($_ text\composite "label" text.tab (n\encoded idx)))) (def: .public (with_extension type poly) - (All [a] (-> Type (Parser a) (Parser [Code a]))) + (All (_ a) (-> Type (Parser a) (Parser [Code a]))) (.function (_ [env inputs]) (let [current_id (dictionary.size env) g!var (label current_id)] @@ -150,7 +150,7 @@ (template [ ] [(`` (def: .public ( poly) - (All [a] (-> (Parser a) (Parser a))) + (All (_ a) (-> (Parser a) (Parser a))) (do //.monad [headT ..any] (let [members ( (type.anonymous headT))] @@ -172,7 +172,7 @@ (in [num_arg bodyT])))) (def: .public (polymorphic poly) - (All [a] (-> (Parser a) (Parser [Code (List Code) a]))) + (All (_ a) (-> (Parser a) (Parser [Code (List Code) a]))) (do {! //.monad} [headT any funcI (\ ! each dictionary.size ..env) @@ -209,7 +209,7 @@ (in [funcL all_varsL output]))))) (def: .public (function in_poly out_poly) - (All [i o] (-> (Parser i) (Parser o) (Parser [i o]))) + (All (_ i o) (-> (Parser i) (Parser o) (Parser [i o]))) (do //.monad [headT any .let [[inputsT outputT] (type.flat_function (type.anonymous headT))]] @@ -219,7 +219,7 @@ (//.failure (exception.error ..not_function headT))))) (def: .public (applied poly) - (All [a] (-> (Parser a) (Parser a))) + (All (_ a) (-> (Parser a) (Parser a))) (do //.monad [headT any .let [[funcT paramsT] (type.flat_application (type.anonymous headT))]] @@ -307,7 +307,7 @@ (#.Parameter 1)))])) (def: .public (recursive poly) - (All [a] (-> (Parser a) (Parser [Code a]))) + (All (_ a) (-> (Parser a) (Parser [Code a]))) (do {! //.monad} [headT any] (case (type.anonymous headT) diff --git a/stdlib/source/library/lux/control/parser/xml.lux b/stdlib/source/library/lux/control/parser/xml.lux index 6be4241d0..4a41dd75d 100644 --- a/stdlib/source/library/lux/control/parser/xml.lux +++ b/stdlib/source/library/lux/control/parser/xml.lux @@ -38,7 +38,7 @@ ["Inputs" (exception.listing (\ /.codec encoded) inputs)])) (def: (result' parser attrs documents) - (All [a] (-> (Parser a) Attrs (List XML) (Try a))) + (All (_ a) (-> (Parser a) Attrs (List XML) (Try a))) (case (//.result parser [attrs documents]) (#try.Success [[attrs' remaining] output]) (if (list.empty? remaining) @@ -49,7 +49,7 @@ (#try.Failure error))) (def: .public (result parser documents) - (All [a] (-> (Parser a) (List XML) (Try a))) + (All (_ a) (-> (Parser a) (List XML) (Try a))) (..result' parser /.attributes documents)) (def: .public text @@ -93,7 +93,7 @@ (#try.Success [[attrs documents] value])))) (def: .public (node expected parser) - (All [a] (-> Tag (Parser a) (Parser a))) + (All (_ a) (-> Tag (Parser a) (Parser a))) (function (_ [attrs documents]) (case documents #.End @@ -124,7 +124,7 @@ (exception: .public nowhere) (def: .public (somewhere parser) - (All [a] (-> (Parser a) (Parser a))) + (All (_ a) (-> (Parser a) (Parser a))) (function (recur [attrs input]) (case (//.result parser [attrs input]) (#try.Success [[attrs remaining] output]) diff --git a/stdlib/source/library/lux/control/reader.lux b/stdlib/source/library/lux/control/reader.lux index b5b6c3e6e..6800a5e3c 100644 --- a/stdlib/source/library/lux/control/reader.lux +++ b/stdlib/source/library/lux/control/reader.lux @@ -10,26 +10,26 @@ (-> r a)) (def: .public read - (All [r] (Reader r r)) + (All (_ r) (Reader r r)) (function (_ env) env)) (def: .public (local change proc) - (All [r a] (-> (-> r r) (Reader r a) (Reader r a))) + (All (_ r a) (-> (-> r r) (Reader r a) (Reader r a))) (|>> change proc)) (def: .public (result env proc) - (All [r a] (-> r (Reader r a) a)) + (All (_ r a) (-> r (Reader r a) a)) (proc env)) (implementation: .public functor - (All [r] (Functor (Reader r))) + (All (_ r) (Functor (Reader r))) (def: (each f fa) (function (_ env) (f (fa env))))) (implementation: .public apply - (All [r] (Apply (Reader r))) + (All (_ r) (Apply (Reader r))) (def: &functor ..functor) @@ -38,7 +38,7 @@ ((ff env) (fa env))))) (implementation: .public monad - (All [r] (Monad (Reader r))) + (All (_ r) (Monad (Reader r))) (def: &functor ..functor) @@ -50,7 +50,7 @@ (mma env env)))) (implementation: .public (with monad) - (All [M] (-> (Monad M) (All [e] (Monad (All [a] (Reader e (M a))))))) + (All (_ M) (-> (Monad M) (All (_ e) (Monad (All (_ a) (Reader e (M a))))))) (def: &functor (functor.composite ..functor (value@ #monad.&functor monad))) @@ -65,5 +65,5 @@ (result env eMa))))) (def: .public lifted - (All [M e a] (-> (M a) (Reader e (M a)))) + (All (_ M e a) (-> (M a) (Reader e (M a)))) (\ ..monad in)) diff --git a/stdlib/source/library/lux/control/region.lux b/stdlib/source/library/lux/control/region.lux index a8a30cfd2..e07656688 100644 --- a/stdlib/source/library/lux/control/region.lux +++ b/stdlib/source/library/lux/control/region.lux @@ -43,7 +43,7 @@ error|output)))) (def: (clean clean_up output) - (All [a] (-> (Try Any) (Try a) (Try a))) + (All (_ a) (-> (Try Any) (Try a) (Try a))) (case clean_up (#try.Success _) output @@ -52,8 +52,8 @@ (exception.except ..clean_up_error [error output]))) (def: .public (run! monad computation) - (All [! a] - (-> (Monad !) (All [r] (Region r ! a)) + (All (_ ! a) + (-> (Monad !) (All (_ r) (Region r ! a)) (! (Try a)))) (do {! monad} [[cleaners output] (computation [[] (list)])] @@ -62,17 +62,17 @@ (\ ! each (list\mix clean output))))) (def: .public (acquire! monad cleaner value) - (All [! a] (-> (Monad !) (-> a (! (Try Any))) a - (All [r] (Region r ! a)))) + (All (_ ! a) (-> (Monad !) (-> a (! (Try Any))) a + (All (_ r) (Region r ! a)))) (function (_ [region cleaners]) (\ monad in [(#.Item (function (_ region) (cleaner value)) cleaners) (#try.Success value)]))) (implementation: .public (functor super) - (All [!] + (All (_ !) (-> (Functor !) - (All [r] (Functor (Region r !))))) + (All (_ r) (Functor (Region r !))))) (def: (each f) (function (_ fa) @@ -88,9 +88,9 @@ (fa region+cleaners)))))) (implementation: .public (apply super) - (All [!] + (All (_ !) (-> (Monad !) - (All [r] (Apply (Region r !))))) + (All (_ r) (Apply (Region r !))))) (def: &functor (..functor (value@ #monad.&functor super))) @@ -113,9 +113,9 @@ (in [cleaners (#try.Failure error)])))))) (implementation: .public (monad super) - (All [!] + (All (_ !) (-> (Monad !) - (All [r] (Monad (Region r !))))) + (All (_ r) (Monad (Region r !))))) (def: &functor (..functor (value@ #monad.&functor super))) @@ -136,22 +136,22 @@ (in [cleaners (#try.Failure error)])))))) (def: .public (failure monad error) - (All [! a] + (All (_ ! a) (-> (Monad !) Text - (All [r] (Region r ! a)))) + (All (_ r) (Region r ! a)))) (function (_ [region cleaners]) (\ monad in [cleaners (#try.Failure error)]))) (def: .public (except monad exception message) - (All [! e a] + (All (_ ! e a) (-> (Monad !) (Exception e) e - (All [r] (Region r ! a)))) + (All (_ r) (Region r ! a)))) (failure monad (exception.error exception message))) (def: .public (lifted monad operation) - (All [! a] + (All (_ ! a) (-> (Monad !) (! a) - (All [r] (Region r ! a)))) + (All (_ r) (Region r ! a)))) (function (_ [region cleaners]) (\ monad each (|>> #try.Success [cleaners]) diff --git a/stdlib/source/library/lux/control/security/capability.lux b/stdlib/source/library/lux/control/security/capability.lux index ec84db916..e6d2617c9 100644 --- a/stdlib/source/library/lux/control/security/capability.lux +++ b/stdlib/source/library/lux/control/security/capability.lux @@ -30,13 +30,13 @@ (-> input output) (def: capability - (All [brand input output] + (All (_ brand input output) (-> (-> input output) (Capability brand input output))) (|>> :abstraction)) (def: .public (use capability input) - (All [brand input output] + (All (_ brand input output) (-> (Capability brand input output) input output)) @@ -48,24 +48,25 @@ |declaration|.parser (<>.maybe |annotations|.parser) (.form ($_ <>.and .local_identifier .any .any))))]) - (do {! meta.monad} - [this_module meta.current_module_name - .let [[name vars] declaration] - g!brand (\ ! each (|>> %.code code.text) - (macro.identifier (format (%.name [this_module name])))) - .let [capability (` (..Capability (.primitive (~ g!brand)) (~ input) (~ output)))]] - (in (list (` (type: (~ export_policy) - (~ (|declaration|.format declaration)) - (~ capability))) - (` (def: (~ (code.local_identifier forger)) - (All [(~+ (list\each code.local_identifier vars))] - (-> (-> (~ input) (~ output)) - (~ capability))) - (~! ..capability))) - )))) + (macro.with_identifiers [g!_] + (do {! meta.monad} + [this_module meta.current_module_name + .let [[name vars] declaration] + g!brand (\ ! each (|>> %.code code.text) + (macro.identifier (format (%.name [this_module name])))) + .let [capability (` (..Capability (.primitive (~ g!brand)) (~ input) (~ output)))]] + (in (list (` (type: (~ export_policy) + (~ (|declaration|.format declaration)) + (~ capability))) + (` (def: (~ (code.local_identifier forger)) + (All ((~ g!_) (~+ (list\each code.local_identifier vars))) + (-> (-> (~ input) (~ output)) + (~ capability))) + (~! ..capability))) + ))))) (def: .public (async capability) - (All [brand input output] + (All (_ brand input output) (-> (Capability brand input (IO output)) (Capability brand input (Async output)))) (..capability (|>> ((:representation capability)) async.future))) diff --git a/stdlib/source/library/lux/control/security/policy.lux b/stdlib/source/library/lux/control/security/policy.lux index 1087cf751..c9e840698 100644 --- a/stdlib/source/library/lux/control/security/policy.lux +++ b/stdlib/source/library/lux/control/security/policy.lux @@ -25,12 +25,12 @@ #can_downgrade (Can_Downgrade brand label)})) (type: .public (Delegation brand from to) - (All [value] + (All (_ value) (-> (Policy brand value from) (Policy brand value to)))) (def: .public (delegation downgrade upgrade) - (All [brand from to] + (All (_ brand from to) (-> (Can_Downgrade brand from) (Can_Upgrade brand to) (Delegation brand from to))) (|>> downgrade upgrade)) @@ -45,16 +45,16 @@ #can_downgrade (|>> :representation)}) (def: .public (with_policy context) - (All [brand scope] - (Ex [label] + (All (_ brand scope) + (Ex (_ label) (-> (Context brand scope label) (scope label)))) (context ..privilege)) (def: (of_policy constructor) (-> Type Type) - (type (All [brand label] - (constructor (All [value] (Policy brand value label)))))) + (type (All (_ brand label) + (constructor (All (_ value) (Policy brand value label)))))) (implementation: .public functor (:~ (..of_policy Functor)) diff --git a/stdlib/source/library/lux/control/state.lux b/stdlib/source/library/lux/control/state.lux index 4b3a64a08..a056cb49b 100644 --- a/stdlib/source/library/lux/control/state.lux +++ b/stdlib/source/library/lux/control/state.lux @@ -10,37 +10,37 @@ (-> s [s a])) (def: .public get - (All [s] (State s s)) + (All (_ s) (State s s)) (function (_ state) [state state])) (def: .public (put new_state) - (All [s] (-> s (State s Any))) + (All (_ s) (-> s (State s Any))) (function (_ state) [new_state []])) (def: .public (update change) - (All [s] (-> (-> s s) (State s Any))) + (All (_ s) (-> (-> s s) (State s Any))) (function (_ state) [(change state) []])) (def: .public (use user) - (All [s a] (-> (-> s a) (State s a))) + (All (_ s a) (-> (-> s a) (State s a))) (function (_ state) [state (user state)])) (def: .public (local change action) - (All [s a] (-> (-> s s) (State s a) (State s a))) + (All (_ s a) (-> (-> s s) (State s a) (State s a))) (function (_ state) (let [[state' output] (action (change state))] [state output]))) (def: .public (result state action) - (All [s a] (-> s (State s a) [s a])) + (All (_ s a) (-> s (State s a) [s a])) (action state)) (implementation: .public functor - (All [s] (Functor (State s))) + (All (_ s) (Functor (State s))) (def: (each f ma) (function (_ state) @@ -48,7 +48,7 @@ [state' (f a)])))) (implementation: .public apply - (All [s] (Apply (State s))) + (All (_ s) (Apply (State s))) (def: &functor ..functor) @@ -59,7 +59,7 @@ [state'' (f a)])))) (implementation: .public monad - (All [s] (Monad (State s))) + (All (_ s) (Monad (State s))) (def: &functor ..functor) @@ -73,7 +73,7 @@ (ma state'))))) (def: .public (while condition body) - (All [s] (-> (State s Bit) (State s Any) (State s Any))) + (All (_ s) (-> (State s Bit) (State s Any) (State s Any))) (do {! ..monad} [execute? condition] (if execute? @@ -83,13 +83,13 @@ (in [])))) (def: .public (do_while condition body) - (All [s] (-> (State s Bit) (State s Any) (State s Any))) + (All (_ s) (-> (State s Bit) (State s Any) (State s Any))) (do ..monad [_ body] (while condition body))) (implementation: (with//functor functor) - (All [M s] (-> (Functor M) (Functor (All [a] (-> s (M [s a])))))) + (All (_ M s) (-> (Functor M) (Functor (All (_ a) (-> s (M [s a])))))) (def: (each f sfa) (function (_ state) @@ -97,7 +97,7 @@ (sfa state))))) (implementation: (with//apply monad) - (All [M s] (-> (Monad M) (Apply (All [a] (-> s (M [s a])))))) + (All (_ M s) (-> (Monad M) (Apply (All (_ a) (-> s (M [s a])))))) (def: &functor (with//functor (\ monad &functor))) @@ -112,11 +112,11 @@ (-> s (M [s a]))) (def: .public (result' state action) - (All [M s a] (-> s (+State M s a) (M [s a]))) + (All (_ M s a) (-> s (+State M s a) (M [s a]))) (action state)) (implementation: .public (with monad) - (All [M s] (-> (Monad M) (Monad (+State M s)))) + (All (_ M s) (-> (Monad M) (Monad (+State M s)))) (def: &functor (with//functor (\ monad &functor))) @@ -131,7 +131,7 @@ (sMa state'))))) (def: .public (lifted monad ma) - (All [M s a] (-> (Monad M) (M a) (+State M s a))) + (All (_ M s a) (-> (Monad M) (M a) (+State M s a))) (function (_ state) (do monad [a ma] diff --git a/stdlib/source/library/lux/control/thread.lux b/stdlib/source/library/lux/control/thread.lux index a7acf841e..d938ddb88 100644 --- a/stdlib/source/library/lux/control/thread.lux +++ b/stdlib/source/library/lux/control/thread.lux @@ -23,14 +23,14 @@ (Array v) (def: .public (box init) - (All [a] (-> a (All [!] (Thread ! (Box ! a))))) + (All (_ a) (-> a (All (_ !) (Thread ! (Box ! a))))) (function (_ !) (|> (array.empty 1) (array.write! 0 init) :abstraction))) (def: .public (read! box) - (All [! a] (-> (Box ! a) (Thread ! a))) + (All (_ ! a) (-> (Box ! a) (Thread ! a))) (function (_ !) (for {@.old ("jvm aaload" (:representation box) 0) @@ -51,25 +51,25 @@ @.scheme ("scheme array read" 0 (:representation box))}))) (def: .public (write! value box) - (All [a] (-> a (All [!] (-> (Box ! a) (Thread ! Any))))) + (All (_ a) (-> a (All (_ !) (-> (Box ! a) (Thread ! Any))))) (function (_ !) (|> box :representation (array.write! 0 value) :abstraction))) ) (def: .public (result thread) - (All [a] - (-> (All [!] (Thread ! a)) + (All (_ a) + (-> (All (_ !) (Thread ! a)) a)) (thread [])) (def: .public io - (All [a] - (-> (All [!] (Thread ! a)) + (All (_ a) + (-> (All (_ !) (Thread ! a)) (IO a))) (|>> ..result io.io)) (implementation: .public functor - (All [!] (Functor (Thread !))) + (All (_ !) (Functor (Thread !))) (def: (each f) (function (_ fa) @@ -77,7 +77,7 @@ (f (fa !)))))) (implementation: .public apply - (All [!] (Apply (Thread !))) + (All (_ !) (Apply (Thread !))) (def: &functor ..functor) @@ -86,7 +86,7 @@ ((ff !) (fa !))))) (implementation: .public monad - (All [!] (Monad (Thread !))) + (All (_ !) (Monad (Thread !))) (def: &functor ..functor) @@ -99,7 +99,7 @@ ((ffa !) !)))) (def: .public (update! f box) - (All [a !] (-> (-> a a) (Box ! a) (Thread ! a))) + (All (_ a !) (-> (-> a a) (Box ! a) (Thread ! a))) (do ..monad [old (read! box) _ (write! (f old) box)] diff --git a/stdlib/source/library/lux/control/try.lux b/stdlib/source/library/lux/control/try.lux index 48ee21443..a4ceae85d 100644 --- a/stdlib/source/library/lux/control/try.lux +++ b/stdlib/source/library/lux/control/try.lux @@ -60,8 +60,8 @@ ma))) (implementation: .public (with monad) - ... TODO: Replace (All [a] (! (Try a))) with (functor.Then ! Try) - (All [!] (-> (Monad !) (Monad (All [a] (! (Try a)))))) + ... TODO: Replace (All (_ a) (! (Try a))) with (functor.Then ! Try) + (All (_ !) (-> (Monad !) (Monad (All (_ a) (! (Try a)))))) (def: &functor (functor.composite (value@ #monad.&functor monad) ..functor)) @@ -81,11 +81,11 @@ Mea)))) (def: .public (lifted monad) - (All [! a] (-> (Monad !) (-> (! a) (! (Try a))))) + (All (_ ! a) (-> (Monad !) (-> (! a) (! (Try a))))) (\ monad each (\ ..monad in))) (implementation: .public (equivalence (^open "_\.")) - (All [a] (-> (Equivalence a) (Equivalence (Try a)))) + (All (_ a) (-> (Equivalence a) (Equivalence (Try a)))) (def: (= reference sample) (case [reference sample] @@ -100,7 +100,8 @@ ))) (def: .public (trusted try) - (All [a] (-> (Try a) a)) + (All (_ a) + (-> (Try a) a)) (case try (#Success value) value @@ -109,7 +110,8 @@ (panic! message))) (def: .public (maybe try) - (All [a] (-> (Try a) (Maybe a))) + (All (_ a) + (-> (Try a) (Maybe a))) (case try (#Success value) (#.Some value) @@ -118,7 +120,8 @@ #.None)) (def: .public (of_maybe maybe) - (All [a] (-> (Maybe a) (Try a))) + (All (_ a) + (-> (Maybe a) (Try a))) (case maybe (#.Some value) (#Success value) diff --git a/stdlib/source/library/lux/control/writer.lux b/stdlib/source/library/lux/control/writer.lux index 825700d8f..b933c4388 100644 --- a/stdlib/source/library/lux/control/writer.lux +++ b/stdlib/source/library/lux/control/writer.lux @@ -14,11 +14,11 @@ #value value})) (def: .public (write message) - (All [log] (-> log (Writer log Any))) + (All (_ log) (-> log (Writer log Any))) [message []]) (implementation: .public functor - (All [l] + (All (_ l) (Functor (Writer l))) (def: (each f fa) @@ -26,7 +26,7 @@ [log (f datum)]))) (implementation: .public (apply monoid) - (All [l] + (All (_ l) (-> (Monoid l) (Apply (Writer l)))) (def: &functor ..functor) @@ -37,7 +37,7 @@ [(\ monoid composite log1 log2) (f a)]))) (implementation: .public (monad monoid) - (All [l] + (All (_ l) (-> (Monoid l) (Monad (Writer l)))) (def: &functor ..functor) @@ -50,7 +50,7 @@ [(\ monoid composite log1 log2) a]))) (implementation: .public (with monoid monad) - (All [l M] (-> (Monoid l) (Monad M) (Monad (All [a] (M (Writer l a)))))) + (All (_ l M) (-> (Monoid l) (Monad M) (Monad (All (_ a) (M (Writer l a)))))) (def: &functor (functor.composite (value@ #monad.&functor monad) @@ -71,7 +71,7 @@ (in [(\ monoid composite l1 l2) a])))) (def: .public (lifted monoid monad) - (All [l M a] + (All (_ l M a) (-> (Monoid l) (Monad M) (-> (M a) (M (Writer l a))))) (\ monad each (|>> [(\ monoid identity)]))) diff --git a/stdlib/source/library/lux/data/binary.lux b/stdlib/source/library/lux/data/binary.lux index ada9bc855..c87d157ea 100644 --- a/stdlib/source/library/lux/data/binary.lux +++ b/stdlib/source/library/lux/data/binary.lux @@ -184,7 +184,7 @@ (array.empty size))) (def: .public (aggregate f init binary) - (All [a] (-> (-> I64 a a) a Binary a)) + (All (_ a) (-> (-> I64 a a) a Binary a)) (let [size (..!size binary)] (loop [index 0 output init] diff --git a/stdlib/source/library/lux/data/bit.lux b/stdlib/source/library/lux/data/bit.lux index 6efecceb7..238f87e5d 100644 --- a/stdlib/source/library/lux/data/bit.lux +++ b/stdlib/source/library/lux/data/bit.lux @@ -61,5 +61,5 @@ _ (#.Left "Wrong syntax for Bit.")))) (def: .public complement - (All [a] (-> (-> a Bit) (-> a Bit))) + (All (_ a) (-> (-> a Bit) (-> a Bit))) (function.composite not)) diff --git a/stdlib/source/library/lux/data/collection/array.lux b/stdlib/source/library/lux/data/collection/array.lux index 73e8a209b..92586e228 100644 --- a/stdlib/source/library/lux/data/collection/array.lux +++ b/stdlib/source/library/lux/data/collection/array.lux @@ -36,7 +36,7 @@ (as_is)) (def: .public (empty size) - (All [a] (-> Nat (Array a))) + (All (_ a) (-> Nat (Array a))) (for {@.old (:expected ("jvm anewarray" "(java.lang.Object )" size)) @@ -55,7 +55,7 @@ @.scheme ("scheme array new" size)})) (def: .public (size array) - (All [a] (-> (Array a) Nat)) + (All (_ a) (-> (Array a) Nat)) (for {@.old ("jvm arraylength" array) @@ -82,7 +82,7 @@ (#.Some output)))]) (def: .public (read! index array) - (All [a] + (All (_ a) (-> Nat (Array a) (Maybe a))) (if (n.< (size array) index) (for {@.old @@ -108,7 +108,7 @@ #.None)) (def: .public (write! index value array) - (All [a] + (All (_ a) (-> Nat a (Array a) (Array a))) (for {@.old ("jvm aastore" array index value) @@ -127,7 +127,7 @@ @.scheme ("scheme array write" index value array)})) (def: .public (delete! index array) - (All [a] + (All (_ a) (-> Nat (Array a) (Array a))) (if (n.< (size array) index) (for {@.old @@ -146,7 +146,7 @@ ) (def: .public (contains? index array) - (All [a] + (All (_ a) (-> Nat (Array a) Bit)) (case (..read! index array) (#.Some _) @@ -156,7 +156,7 @@ false)) (def: .public (update! index transform array) - (All [a] + (All (_ a) (-> Nat (-> a a) (Array a) (Array a))) (case (read! index array) #.None @@ -166,14 +166,14 @@ (write! index (transform value) array))) (def: .public (upsert! index default transform array) - (All [a] + (All (_ a) (-> Nat a (-> a a) (Array a) (Array a))) (write! index (|> array (read! index) (maybe.else default) transform) array)) (def: .public (copy! length src_start src_array dest_start dest_array) - (All [a] + (All (_ a) (-> Nat Nat (Array a) Nat (Array a) (Array a))) (if (n.= 0 length) @@ -189,7 +189,7 @@ (list.indices length)))) (def: .public (occupancy array) - (All [a] (-> (Array a) Nat)) + (All (_ a) (-> (Array a) Nat)) (list\mix (function (_ idx count) (case (read! idx array) #.None @@ -201,11 +201,11 @@ (list.indices (size array)))) (def: .public (vacancy array) - (All [a] (-> (Array a) Nat)) + (All (_ a) (-> (Array a) Nat)) (n.- (..occupancy array) (..size array))) (def: .public (filter! p xs) - (All [a] + (All (_ a) (-> (Predicate a) (Array a) (Array a))) (list\mix (function (_ idx xs') (case (read! idx xs) @@ -220,7 +220,7 @@ (list.indices (size xs)))) (def: .public (example p xs) - (All [a] + (All (_ a) (-> (Predicate a) (Array a) (Maybe a))) (let [arr_size (size xs)] (loop [idx 0] @@ -236,7 +236,7 @@ #.None)))) (def: .public (example+ p xs) - (All [a] + (All (_ a) (-> (-> Nat a Bit) (Array a) (Maybe [Nat a]))) (let [arr_size (size xs)] (loop [idx 0] @@ -252,7 +252,7 @@ #.None)))) (def: .public (clone xs) - (All [a] (-> (Array a) (Array a))) + (All (_ a) (-> (Array a) (Array a))) (let [arr_size (size xs)] (list\mix (function (_ idx ys) (case (read! idx xs) @@ -265,7 +265,7 @@ (list.indices arr_size)))) (def: .public (of_list xs) - (All [a] (-> (List a) (Array a))) + (All (_ a) (-> (List a) (Array a))) (product.right (list\mix (function (_ x [idx arr]) [(++ idx) (write! idx x arr)]) [0 (empty (list.size xs))] @@ -276,7 +276,7 @@ (-- 0)) (def: (list|-default array) - (All [a] (-> (Array a) (List a))) + (All (_ a) (-> (Array a) (List a))) (loop [idx (-- (size array)) output #.End] (case idx @@ -293,7 +293,7 @@ output))))) (def: (list|+default default array) - (All [a] (-> a (Array a) (List a))) + (All (_ a) (-> a (Array a) (List a))) (loop [idx (-- (size array)) output #.End] (case idx @@ -306,7 +306,7 @@ output))))) (def: .public (list default array) - (All [a] (-> (Maybe a) (Array a) (List a))) + (All (_ a) (-> (Maybe a) (Array a) (List a))) (case default (#.Some default) (list|+default default array) @@ -315,7 +315,7 @@ (list|-default array))) (implementation: .public (equivalence (^open ",\.")) - (All [a] (-> (Equivalence a) (Equivalence (Array a)))) + (All (_ a) (-> (Equivalence a) (Equivalence (Array a)))) (def: (= xs ys) (let [sxs (size xs) @@ -336,7 +336,7 @@ (list.indices sxs)))))) (implementation: .public monoid - (All [a] (Monoid (Array a))) + (All (_ a) (Monoid (Array a))) (def: identity (empty 0)) @@ -383,7 +383,7 @@ (template [ ] [(def: .public ( predicate) - (All [a] + (All (_ a) (-> (Predicate a) (Predicate (Array a)))) (function (_ array) (let [size (..size array)] diff --git a/stdlib/source/library/lux/data/collection/dictionary.lux b/stdlib/source/library/lux/data/collection/dictionary.lux index 0828d54e2..ad65dabbd 100644 --- a/stdlib/source/library/lux/data/collection/dictionary.lux +++ b/stdlib/source/library/lux/data/collection/dictionary.lux @@ -132,7 +132,7 @@ ... Expands a copy of the array, to have 1 extra slot, which is used ... for storing the value. (def: (array\has idx value old_array) - (All [a] (-> Index a (Array a) (Array a))) + (All (_ a) (-> Index a (Array a) (Array a))) (let [old_size (array.size old_array)] (|> (array.empty (++ old_size)) (array.copy! idx 0 old_array 0) @@ -141,19 +141,19 @@ ... Creates a copy of an array with an index set to a particular value. (def: (array\revised idx value array) - (All [a] (-> Index a (Array a) (Array a))) + (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: (array\clear idx array) - (All [a] (-> Index (Array a) (Array a))) + (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: (array\lacks idx array) - (All [a] (-> Index (Array a) (Array a))) + (All (_ a) (-> Index (Array a) (Array a))) (let [new_size (-- (array.size array))] (|> (array.empty new_size) (array.copy! idx 0 array 0) @@ -227,7 +227,7 @@ ... Produces the index of a KV-pair within a #Collisions node. (def: (collision_index key_hash key colls) - (All [k v] (-> (Hash k) k (Collisions k v) (Maybe Index))) + (All (_ k v) (-> (Hash k) k (Collisions k v) (Maybe Index))) (\ maybe.monad each product.left (array.example+ (function (_ idx [key' val']) (\ key_hash = key key')) @@ -236,7 +236,7 @@ ... When #Hierarchy nodes grow too small, they're demoted to #Base ... nodes to save space. (def: (demotion except_idx [h_size h_array]) - (All [k v] (-> Index (Hierarchy k v) [Bit_Map (Base k v)])) + (All (_ k v) (-> Index (Hierarchy k v) [Bit_Map (Base k v)])) (product.right (list\mix (function (_ idx [insertion_idx node]) (let [[bitmap base] node] (case (array.read! idx h_array) @@ -258,7 +258,7 @@ (list.indices hierarchy_nodes_size)) (def: (promotion node\has key_hash level bitmap base) - (All [k v] + (All (_ k v) (-> (-> Level Hash_Code k v (Hash k) (Node k v) (Node k v)) (Hash k) Level Bit_Map (Base k v) @@ -287,7 +287,7 @@ ... used). ... So, this test is introduced to detect them. (def: (node\empty? node) - (All [k v] (-> (Node k v) Bit)) + (All (_ k v) (-> (Node k v) Bit)) (`` (case node (#Base (~~ (static ..clean_bitmap)) _) #1 @@ -296,7 +296,7 @@ #0))) (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))) + (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. @@ -393,7 +393,7 @@ )) (def: (node\lacks level hash key key_hash node) - (All [k v] (-> Level Hash_Code k (Hash k) (Node k v) (Node k v))) + (All (_ k v) (-> Level Hash_Code k (Hash k) (Node k v) (Node k v))) (case node ... For #Hierarchy nodes, find out if there's a valid sub-node for ... the Hash-Code. @@ -485,7 +485,7 @@ )) (def: (node\value level hash key key_hash node) - (All [k v] (-> Level Hash_Code k (Hash k) (Node k v) (Maybe v))) + (All (_ k v) (-> Level Hash_Code k (Hash k) (Node k v) (Maybe v))) (case node ... For #Hierarchy nodes, just look-up the key on its children. (#Hierarchy _size hierarchy) @@ -518,7 +518,7 @@ )) (def: (node\size node) - (All [k v] (-> (Node k v) Nat)) + (All (_ k v) (-> (Node k v) Nat)) (case node (#Hierarchy _size hierarchy) (array\mix n.+ 0 (array\each node\size hierarchy)) @@ -535,7 +535,7 @@ )) (def: (node\entries node) - (All [k v] (-> (Node k v) (List [k v]))) + (All (_ k v) (-> (Node k v) (List [k v]))) (case node (#Hierarchy _size hierarchy) (array\mix (function (_ sub_node tail) (list\composite (node\entries sub_node) tail)) @@ -564,31 +564,31 @@ #root (Node k v)})) (def: .public key_hash - (All [k v] (-> (Dictionary k v) (Hash k))) + (All (_ k v) (-> (Dictionary k v) (Hash k))) (value@ #..hash)) (def: .public (empty key_hash) - (All [k v] (-> (Hash k) (Dictionary k v))) + (All (_ k v) (-> (Hash k) (Dictionary k v))) {#hash key_hash #root empty_node}) (def: .public (has key val dict) - (All [k v] (-> k v (Dictionary k v) (Dictionary k v))) + (All (_ k v) (-> k v (Dictionary k v) (Dictionary k v))) (let [[key_hash node] dict] [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))) + (All (_ k v) (-> k (Dictionary k v) (Dictionary k v))) (let [[key_hash node] dict] [key_hash (node\lacks root_level (\ key_hash hash key) key key_hash node)])) (def: .public (value key dict) - (All [k v] (-> k (Dictionary k v) (Maybe v))) + (All (_ k v) (-> k (Dictionary k v) (Maybe v))) (let [[key_hash node] dict] (node\value root_level (\ key_hash hash key) key key_hash node))) (def: .public (key? dict key) - (All [k v] (-> (Dictionary k v) k Bit)) + (All (_ k v) (-> (Dictionary k v) k Bit)) (case (value key dict) #.None #0 (#.Some _) #1)) @@ -596,13 +596,13 @@ (exception: .public key_already_exists) (def: .public (has' key val dict) - (All [k v] (-> k v (Dictionary k v) (Try (Dictionary k v)))) + (All (_ k v) (-> k v (Dictionary k v) (Try (Dictionary k v)))) (case (value key dict) #.None (#try.Success (has key val dict)) (#.Some _) (exception.except ..key_already_exists []))) (def: .public (revised key f dict) - (All [k v] (-> k (-> v v) (Dictionary k v) (Dictionary k v))) + (All (_ k v) (-> k (-> v v) (Dictionary k v) (Dictionary k v))) (case (value key dict) #.None dict @@ -611,26 +611,26 @@ (has key (f val) dict))) (def: .public (revised' key default f dict) - (All [k v] (-> k v (-> v v) (Dictionary k v) (Dictionary k v))) + (All (_ k v) (-> k v (-> v v) (Dictionary k v) (Dictionary k v))) (..has key (f (maybe.else default (..value key dict))) dict)) (def: .public size - (All [k v] (-> (Dictionary k v) Nat)) + (All (_ k v) (-> (Dictionary k v) Nat)) (|>> product.right ..node\size)) (def: .public empty? - (All [k v] (-> (Dictionary k v) Bit)) + (All (_ k v) (-> (Dictionary k v) Bit)) (|>> size (n.= 0))) (def: .public entries - (All [k v] (-> (Dictionary k v) (List [k v]))) + (All (_ k v) (-> (Dictionary k v) (List [k v]))) (|>> product.right ..node\entries)) (def: .public (of_list key_hash kvs) - (All [k v] (-> (Hash k) (List [k v]) (Dictionary k v))) + (All (_ k v) (-> (Hash k) (List [k v]) (Dictionary k v))) (list\mix (function (_ [k v] dict) (..has k v dict)) (empty key_hash) @@ -638,7 +638,7 @@ (template [ ] [(def: .public - (All [k v] (-> (Dictionary k v) (List ))) + (All (_ k v) (-> (Dictionary k v) (List ))) (|>> ..entries (list\mix (function (_ [k v] bundle) (#.Item bundle)) @@ -649,13 +649,13 @@ ) (def: .public (merged dict2 dict1) - (All [k v] (-> (Dictionary k v) (Dictionary k v) (Dictionary k v))) + (All (_ k v) (-> (Dictionary k v) (Dictionary k v) (Dictionary k v))) (list\mix (function (_ [key val] dict) (has key val dict)) dict1 (entries dict2))) (def: .public (merged_with f dict2 dict1) - (All [k v] (-> (-> v v v) (Dictionary k v) (Dictionary k v) (Dictionary k v))) + (All (_ k v) (-> (-> v v v) (Dictionary k v) (Dictionary k v) (Dictionary k v))) (list\mix (function (_ [key val2] dict) (case (value key dict) #.None @@ -667,7 +667,7 @@ (entries dict2))) (def: .public (re_bound from_key to_key dict) - (All [k v] (-> k k (Dictionary k v) (Dictionary k v))) + (All (_ k v) (-> k k (Dictionary k v) (Dictionary k v))) (case (value from_key dict) #.None dict @@ -678,7 +678,7 @@ (has to_key val)))) (def: .public (sub keys dict) - (All [k v] (-> (List k) (Dictionary k v) (Dictionary k v))) + (All (_ k v) (-> (List k) (Dictionary k v) (Dictionary k v))) (let [[key_hash _] dict] (list\mix (function (_ key new_dict) (case (value key dict) @@ -688,7 +688,7 @@ keys))) (implementation: .public (equivalence (^open ",\.")) - (All [k v] (-> (Equivalence v) (Equivalence (Dictionary k v)))) + (All (_ k v) (-> (Equivalence v) (Equivalence (Dictionary k v)))) (def: (= reference subject) (and (n.= (..size reference) @@ -703,7 +703,7 @@ (..entries reference))))) (implementation: node_functor - (All [k] (Functor (Node k))) + (All (_ k) (Functor (Node k))) (def: (each f fa) (case fa @@ -726,7 +726,7 @@ collisions))))) (implementation: .public functor - (All [k] (Functor (Dictionary k))) + (All (_ k) (Functor (Dictionary k))) (def: (each f fa) (revised@ #root (\ ..node_functor each f) fa))) diff --git a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux index ef9e53973..acb2599f2 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux @@ -33,7 +33,7 @@ (template [ ] [(def: ( key value left right) - (All [k v] (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) + (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) {#color #key key #value value @@ -50,14 +50,14 @@ #root (Maybe (Node k v))})) (def: .public (empty order) - (All [k v] (-> (Order k) (Dictionary k v))) + (All (_ k v) (-> (Order k) (Dictionary k v))) {#&order order #root #.None}) ... TODO: Doing inneficient access of Order functions due to compiler bug. ... TODO: Must improve it as soon as bug is fixed. (def: .public (value key dict) - (All [k v] (-> k (Dictionary k v) (Maybe v))) + (All (_ k v) (-> k (Dictionary k v) (Maybe v))) (let [... (^open "_\.") (value@ #&order dict) ] (loop [node (value@ #root dict)] @@ -82,7 +82,7 @@ ... TODO: Doing inneficient access of Order functions due to compiler bug. ... TODO: Must improve it as soon as bug is fixed. (def: .public (key? dict key) - (All [k v] (-> (Dictionary k v) k Bit)) + (All (_ k v) (-> (Dictionary k v) k Bit)) (let [... (^open "_\.") (value@ #&order dict) ] (loop [node (value@ #root dict)] @@ -101,7 +101,7 @@ (template [ ] [(def: .public ( dict) - (All [k v] (-> (Dictionary k v) (Maybe v))) + (All (_ k v) (-> (Dictionary k v) (Maybe v))) (case (value@ #root dict) #.None #.None @@ -120,7 +120,7 @@ ) (def: .public (size dict) - (All [k v] (-> (Dictionary k v) Nat)) + (All (_ k v) (-> (Dictionary k v) Nat)) (loop [node (value@ #root dict)] (case node #.None @@ -131,12 +131,12 @@ (recur (value@ #right node))))))) (def: .public empty? - (All [k v] (-> (Dictionary k v) Bit)) + (All (_ k v) (-> (Dictionary k v) Bit)) (|>> ..size (n.= 0))) (template [ ] [(def: ( self) - (All [k v] (-> (Node k v) (Node k v))) + (All (_ k v) (-> (Node k v) (Node k v))) (case (value@ #color self) (with@ #color self) @@ -150,7 +150,7 @@ ) (def: (with_left addition center) - (All [k v] (-> (Node k v) (Node k v) (Node k v))) + (All (_ k v) (-> (Node k v) (Node k v) (Node k v))) (case (value@ #color center) #Red (red (value@ #key center) @@ -199,7 +199,7 @@ )))) (def: (with_right addition center) - (All [k v] (-> (Node k v) (Node k v) (Node k v))) + (All (_ k v) (-> (Node k v) (Node k v) (Node k v))) (case (value@ #color center) #Red (red (value@ #key center) @@ -248,7 +248,7 @@ )))) (def: .public (has key value dict) - (All [k v] (-> k v (Dictionary k v) (Dictionary k v))) + (All (_ k v) (-> k v (Dictionary k v) (Dictionary k v))) (let [(^open "_\.") (value@ #&order dict) root' (loop [?root (value@ #root dict)] (case ?root @@ -277,7 +277,7 @@ (with@ #root root' dict))) (def: (left_balanced key value ?left ?right) - (All [k v] (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) + (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?left (^multi (#.Some left) {(value@ #color left) #Red} @@ -306,7 +306,7 @@ (black key value ?left ?right))) (def: (right_balanced key value ?left ?right) - (All [k v] (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) + (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?right (^multi (#.Some right) {(value@ #color right) #Red} @@ -333,7 +333,7 @@ (black key value ?left ?right))) (def: (without_left key value ?left ?right) - (All [k v] (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) + (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?left (^multi (#.Some left) {(value@ #color left) #Red}) @@ -362,7 +362,7 @@ )) (def: (without_right key value ?left ?right) - (All [k v] (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) + (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?right (^multi (#.Some right) {(value@ #color right) #Red}) @@ -391,7 +391,7 @@ ))) (def: (prepended ?left ?right) - (All [k v] (-> (Maybe (Node k v)) (Maybe (Node k v)) (Maybe (Node k v)))) + (All (_ k v) (-> (Maybe (Node k v)) (Maybe (Node k v)) (Maybe (Node k v)))) (case [?left ?right] [#.None _] ?right @@ -471,7 +471,7 @@ (undefined))) (def: .public (lacks key dict) - (All [k v] (-> k (Dictionary k v) (Dictionary k v))) + (All (_ k v) (-> k (Dictionary k v) (Dictionary k v))) (let [(^open "_\.") (value@ #&order dict) [?root found?] (loop [?root (value@ #root dict)] (case ?root @@ -526,7 +526,7 @@ ))) (def: .public (revised key transform dict) - (All [k v] (-> k (-> v v) (Dictionary k v) (Dictionary k v))) + (All (_ k v) (-> k (-> v v) (Dictionary k v) (Dictionary k v))) (case (..value key dict) (#.Some old) (..has key (transform old) dict) @@ -535,7 +535,7 @@ dict)) (def: .public (of_list order list) - (All [k v] (-> (Order k) (List [k v]) (Dictionary k v))) + (All (_ k v) (-> (Order k) (List [k v]) (Dictionary k v))) (list\mix (function (_ [key value] dict) (has key value dict)) (empty order) @@ -543,7 +543,7 @@ (template [ ] [(def: .public ( dict) - (All [k v] (-> (Dictionary k v) (List ))) + (All (_ k v) (-> (Dictionary k v) (List ))) (loop [node (value@ #root dict)] (case node #.None @@ -561,7 +561,7 @@ ) (implementation: .public (equivalence (^open ",\.")) - (All [k v] (-> (Equivalence v) (Equivalence (Dictionary k v)))) + (All (_ k v) (-> (Equivalence v) (Equivalence (Dictionary k v)))) (def: (= reference sample) (let [(^open "/\.") (value@ #&order reference)] diff --git a/stdlib/source/library/lux/data/collection/dictionary/plist.lux b/stdlib/source/library/lux/data/collection/dictionary/plist.lux index df834ae4c..b5f04aa4a 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/plist.lux @@ -21,15 +21,15 @@ #.End) (def: .public size - (All [a] (-> (PList a) Nat)) + (All (_ a) (-> (PList a) Nat)) list.size) (def: .public empty? - (All [a] (-> (PList a) Bit)) + (All (_ a) (-> (PList a) Bit)) (|>> ..size (n.= 0))) (def: .public (value key properties) - (All [a] (-> Text (PList a) (Maybe a))) + (All (_ a) (-> Text (PList a) (Maybe a))) (case properties #.End #.None @@ -41,7 +41,7 @@ (template [ ] [(def: .public - (All [a] (-> (PList a) (List ))) + (All (_ a) (-> (PList a) (List ))) (list\each ))] [keys Text product.left] @@ -49,7 +49,7 @@ ) (def: .public (contains? key properties) - (All [a] (-> Text (PList a) Bit)) + (All (_ a) (-> Text (PList a) Bit)) (case (..value key properties) (#.Some _) true @@ -58,7 +58,7 @@ false)) (def: .public (has key val properties) - (All [a] (-> Text a (PList a) (PList a))) + (All (_ a) (-> Text a (PList a) (PList a))) (case properties #.End (list [key val]) @@ -71,7 +71,7 @@ (has key val properties'))))) (def: .public (revised key f properties) - (All [a] (-> Text (-> a a) (PList a) (PList a))) + (All (_ a) (-> Text (-> a a) (PList a) (PList a))) (case properties #.End #.End @@ -82,7 +82,7 @@ (#.Item [k' v'] (revised key f properties'))))) (def: .public (lacks key properties) - (All [a] (-> Text (PList a) (PList a))) + (All (_ a) (-> Text (PList a) (PList a))) (case properties #.End properties @@ -94,6 +94,6 @@ (lacks key properties'))))) (def: .public equivalence - (All [a] (-> (Equivalence a) (Equivalence (PList a)))) + (All (_ a) (-> (Equivalence a) (Equivalence (PList a)))) (|>> (product.equivalence text.equivalence) list.equivalence)) diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux index 9ea9c3132..5649dacec 100644 --- a/stdlib/source/library/lux/data/collection/list.lux +++ b/stdlib/source/library/lux/data/collection/list.lux @@ -35,7 +35,7 @@ (mix f (f x init) xs')))) (def: .public (mixes f init inputs) - (All [a b] (-> (-> a b b) b (List a) (List b))) + (All (_ a b) (-> (-> a b b) b (List a) (List b))) (case inputs #.End (list init) @@ -44,14 +44,14 @@ (#.Item [init (mixes f (f head init) tail)]))) (def: .public (reversed xs) - (All [a] + (All (_ a) (-> (List a) (List a))) (mix (function (_ head tail) (#.Item head tail)) #.End xs)) (def: .public (only keep? xs) - (All [a] + (All (_ a) (-> (Predicate a) (List a) (List a))) (case xs #.End @@ -63,7 +63,7 @@ (only keep? xs')))) (def: .public (partition satisfies? list) - (All [a] (-> (Predicate a) (List a) [(List a) (List a)])) + (All (_ a) (-> (Predicate a) (List a) [(List a) (List a)])) (case list #.End [#.End #.End] @@ -75,7 +75,7 @@ [in (#.Item head out)])))) (def: .public (pairs xs) - (All [a] (-> (List a) (List [a a]))) + (All (_ a) (-> (List a) (List [a a]))) (case xs (^ (list& x1 x2 xs')) (#.Item [x1 x2] (pairs xs')) @@ -85,7 +85,7 @@ (template [ ] [(def: .public ( n xs) - (All [a] + (All (_ a) (-> Nat (List a) (List a))) (if (n.> 0 n) (case xs @@ -102,7 +102,7 @@ (template [ ] [(def: .public ( predicate xs) - (All [a] + (All (_ a) (-> (Predicate a) (List a) (List a))) (case xs #.End @@ -118,7 +118,7 @@ ) (def: .public (split_at n xs) - (All [a] + (All (_ a) (-> Nat (List a) [(List a) (List a)])) (if (n.> 0 n) (case xs @@ -131,7 +131,7 @@ [#.End xs])) (def: (split_when' predicate ys xs) - (All [a] + (All (_ a) (-> (Predicate a) (List a) (List a) [(List a) (List a)])) (case xs #.End @@ -143,13 +143,13 @@ (split_when' predicate (#.Item x ys) xs')))) (def: .public (split_when predicate xs) - (All [a] + (All (_ a) (-> (Predicate a) (List a) [(List a) (List a)])) (let [[ys' xs'] (split_when' predicate #.End xs)] [(reversed ys') xs'])) (def: .public (sub size list) - (All [a] (-> Nat (List a) (List (List a)))) + (All (_ a) (-> Nat (List a) (List (List a)))) (case list #.End #.End @@ -159,14 +159,14 @@ (#.Item pre (sub size post))))) (def: .public (repeated n x) - (All [a] + (All (_ a) (-> Nat a (List a))) (case n 0 #.End _ (#.Item x (repeated (-- n) x)))) (def: (iterations' f x) - (All [a] + (All (_ a) (-> (-> a (Maybe a)) a (List a))) (case (f x) (#.Some x') @@ -176,7 +176,7 @@ (list))) (def: .public (iterations f x) - (All [a] + (All (_ a) (-> (-> a (Maybe a)) a (List a))) (case (f x) (#.Some x') @@ -186,7 +186,7 @@ (list x))) (def: .public (one check xs) - (All [a b] + (All (_ a b) (-> (-> a (Maybe b)) (List a) (Maybe b))) (case xs #.End @@ -201,7 +201,7 @@ (one check xs')))) (def: .public (all check xs) - (All [a b] + (All (_ a b) (-> (-> a (Maybe b)) (List a) (List b))) (for {... TODO: Stop relying on this ASAP. @.js @@ -227,7 +227,7 @@ (all check xs'))))) (def: .public (example predicate xs) - (All [a] + (All (_ a) (-> (Predicate a) (List a) (Maybe a))) (..one (function (_ value) (if (predicate value) @@ -236,7 +236,7 @@ xs)) (def: .public (interposed sep xs) - (All [a] + (All (_ a) (-> a (List a) (List a))) (case xs #.End @@ -249,12 +249,12 @@ (list& x sep (interposed sep xs')))) (def: .public (size list) - (All [a] (-> (List a) Nat)) + (All (_ a) (-> (List a) Nat)) (mix (function (_ _ acc) (n.+ 1 acc)) 0 list)) (template [ ] [(def: .public ( predicate items) - (All [a] + (All (_ a) (-> (Predicate a) (List a) Bit)) (case items #.End @@ -269,7 +269,7 @@ ) (def: .public (item i xs) - (All [a] + (All (_ a) (-> Nat (List a) (Maybe a))) (case xs #.End @@ -281,7 +281,7 @@ _ (item (-- i) xs')))) (implementation: .public (equivalence Equivalence) - (All [a] (-> (Equivalence a) (Equivalence (List a)))) + (All (_ a) (-> (Equivalence a) (Equivalence (List a)))) (def: (= xs ys) (case [xs ys] @@ -297,7 +297,7 @@ ))) (implementation: .public (hash super) - (All [a] (-> (Hash a) (Hash (List a)))) + (All (_ a) (-> (Hash a) (Hash (List a)))) (def: &equivalence (..equivalence (\ super &equivalence))) @@ -309,7 +309,7 @@ 0))) (implementation: .public monoid - (All [a] (Monoid (List a))) + (All (_ a) (Monoid (List a))) (def: identity #.End) (def: (composite xs ys) @@ -362,7 +362,7 @@ (|>> reversed (mix composite identity)))) (def: .public (sorted < xs) - (All [a] (-> (-> a a Bit) (List a) (List a))) + (All (_ a) (-> (-> a a Bit) (List a) (List a))) (case xs #.End (list) @@ -377,7 +377,7 @@ ($_ composite (sorted < pre) (list x) (sorted < post))))) (def: .public (empty? xs) - (All [a] (Predicate (List a))) + (All (_ a) (Predicate (List a))) (case xs #.End true @@ -386,7 +386,7 @@ false)) (def: .public (member? eq xs x) - (All [a] (-> (Equivalence a) (List a) a Bit)) + (All (_ a) (-> (Equivalence a) (List a) a Bit)) (case xs #.End #0 @@ -397,7 +397,7 @@ (template [ ] [(def: .public ( xs) - (All [a] (-> (List a) (Maybe ))) + (All (_ a) (-> (List a) (Maybe ))) (case xs #.End #.None @@ -410,7 +410,7 @@ ) (def: .public (indices size) - (All [a] (-> Nat (List Nat))) + (All (_ a) (-> Nat (List Nat))) (case size 0 (list) _ (|> size -- (enum.range n.enum 0)))) @@ -448,7 +448,7 @@ (let [(^open ".") ..functor indices (..indices num_lists) type_vars (: (List Code) (each (|>> nat\encoded identifier$) indices)) - zipped_type (` (All [(~+ type_vars)] + zipped_type (` (.All ((~ (identifier$ "0_")) (~+ type_vars)) (-> (~+ (each (: (-> Code Code) (function (_ var) (` (List (~ var))))) type_vars)) (List [(~+ type_vars)])))) @@ -490,7 +490,7 @@ g!return_type (identifier$ "0return_type0") g!func (identifier$ "0func0") type_vars (: (List Code) (each (|>> nat\encoded identifier$) indices)) - zipped_type (` (All [(~+ type_vars) (~ g!return_type)] + zipped_type (` (All ((~ (identifier$ "0_")) (~+ type_vars) (~ g!return_type)) (-> (-> (~+ type_vars) (~ g!return_type)) (~+ (each (: (-> Code Code) (function (_ var) (` (List (~ var))))) type_vars)) @@ -525,7 +525,7 @@ (def: .public zipped_with/3 (zipped_with 3)) (def: .public (last xs) - (All [a] (-> (List a) (Maybe a))) + (All (_ a) (-> (List a) (Maybe a))) (case xs #.End #.None @@ -537,7 +537,7 @@ (last xs'))) (def: .public (inits xs) - (All [a] (-> (List a) (Maybe (List a)))) + (All (_ a) (-> (List a) (Maybe (List a)))) (case xs #.End #.None @@ -555,11 +555,11 @@ )) (def: .public together - (All [a] (-> (List (List a)) (List a))) + (All (_ a) (-> (List (List a)) (List a))) (\ ..monad conjoint)) (implementation: .public (with monad) - (All [M] (-> (Monad M) (Monad (All [a] (M (List a)))))) + (All (_ M) (-> (Monad M) (Monad (All (_ a) (M (List a)))))) (def: &functor (functor.composite (value@ #monad.&functor monad) @@ -579,11 +579,11 @@ (in (..together lla))))) (def: .public (lifted monad) - (All [M a] (-> (Monad M) (-> (M a) (M (List a))))) + (All (_ M a) (-> (Monad M) (-> (M a) (M (List a))))) (\ monad each (\ ..monad in))) (def: .public (enumeration xs) - (All [a] (-> (List a) (List [Nat a]))) + (All (_ a) (-> (List a) (List [Nat a]))) (loop [idx 0 xs xs] (case xs diff --git a/stdlib/source/library/lux/data/collection/queue.lux b/stdlib/source/library/lux/data/collection/queue.lux index ca41352b6..524c14067 100644 --- a/stdlib/source/library/lux/data/collection/queue.lux +++ b/stdlib/source/library/lux/data/collection/queue.lux @@ -22,37 +22,37 @@ #rear (.list)}) (def: .public (of_list entries) - (All [a] (-> (List a) (Queue a))) + (All (_ a) (-> (List a) (Queue a))) {#front entries #rear (.list)}) (def: .public (list queue) - (All [a] (-> (Queue a) (List a))) + (All (_ a) (-> (Queue a) (List a))) (let [(^slots [#front #rear]) queue] (list\composite front (list.reversed rear)))) (def: .public front - (All [a] (-> (Queue a) (Maybe a))) + (All (_ a) (-> (Queue a) (Maybe a))) (|>> (value@ #front) list.head)) (def: .public (size queue) - (All [a] (-> (Queue a) Nat)) + (All (_ a) (-> (Queue a) Nat)) (let [(^slots [#front #rear]) queue] (n.+ (list.size front) (list.size rear)))) (def: .public empty? - (All [a] (-> (Queue a) Bit)) + (All (_ a) (-> (Queue a) Bit)) (|>> (value@ #front) list.empty?)) (def: .public (member? equivalence queue member) - (All [a] (-> (Equivalence a) (Queue a) a Bit)) + (All (_ a) (-> (Equivalence a) (Queue a) a Bit)) (let [(^slots [#front #rear]) queue] (or (list.member? equivalence front member) (list.member? equivalence rear member)))) (def: .public (next queue) - (All [a] (-> (Queue a) (Queue a))) + (All (_ a) (-> (Queue a) (Queue a))) (case (value@ #front queue) ... Empty... (^ (.list)) @@ -70,7 +70,7 @@ (with@ #front front')))) (def: .public (end val queue) - (All [a] (-> a (Queue a) (Queue a))) + (All (_ a) (-> a (Queue a) (Queue a))) (case (value@ #front queue) #.End (with@ #front (.list val) queue) @@ -79,7 +79,7 @@ (revised@ #rear (|>> (#.Item val)) queue))) (implementation: .public (equivalence super) - (All [a] (-> (Equivalence a) (Equivalence (Queue a)))) + (All (_ a) (-> (Equivalence a) (Equivalence (Queue a)))) (def: (= reference subject) (\ (list.equivalence super) = diff --git a/stdlib/source/library/lux/data/collection/queue/priority.lux b/stdlib/source/library/lux/data/collection/queue/priority.lux index 88da217c3..d3fb97cbb 100644 --- a/stdlib/source/library/lux/data/collection/queue/priority.lux +++ b/stdlib/source/library/lux/data/collection/queue/priority.lux @@ -47,14 +47,14 @@ (:abstraction #.None)) (def: .public (front queue) - (All [a] (-> (Queue a) (Maybe a))) + (All (_ a) (-> (Queue a) (Maybe a))) (do maybe.monad [tree (:representation queue)] (tree.one (n.= (tree.tag tree)) tree))) (def: .public (size queue) - (All [a] (-> (Queue a) Nat)) + (All (_ a) (-> (Queue a) Nat)) (case (:representation queue) #.None 0 @@ -69,7 +69,7 @@ (n.+ (recur left) (recur right)))))) (def: .public (member? equivalence queue member) - (All [a] (-> (Equivalence a) (Queue a) a Bit)) + (All (_ a) (-> (Equivalence a) (Queue a) a Bit)) (case (:representation queue) #.None false @@ -85,7 +85,7 @@ (recur right)))))) (def: .public (next queue) - (All [a] (-> (Queue a) (Queue a))) + (All (_ a) (-> (Queue a) (Queue a))) (:abstraction (do maybe.monad [tree (:representation queue) @@ -113,7 +113,7 @@ (#.Some (\ ..builder branch left =right))))))))) (def: .public (end priority value queue) - (All [a] (-> Priority a (Queue a) (Queue a))) + (All (_ a) (-> Priority a (Queue a) (Queue a))) (let [addition (\ ..builder leaf priority value)] (:abstraction (case (:representation queue) @@ -125,5 +125,5 @@ ) (def: .public empty? - (All [a] (-> (Queue a) Bit)) + (All (_ a) (-> (Queue a) Bit)) (|>> ..size (n.= 0))) diff --git a/stdlib/source/library/lux/data/collection/row.lux b/stdlib/source/library/lux/data/collection/row.lux index 30a2323c4..59f48d867 100644 --- a/stdlib/source/library/lux/data/collection/row.lux +++ b/stdlib/source/library/lux/data/collection/row.lux @@ -79,7 +79,7 @@ (i64.and branch_idx_mask)) (def: (empty_hierarchy _) - (All [a] (-> Any (Hierarchy a))) + (All (_ a) (-> Any (Hierarchy a))) (array.empty ..full_node_size)) (def: (tail_off row_size) @@ -91,7 +91,7 @@ (i64.left_shifted branching_exponent)))) (def: (path level tail) - (All [a] (-> Level (Base a) (Node a))) + (All (_ a) (-> Level (Base a) (Node a))) (if (n.= 0 level) (#Base tail) (|> (empty_hierarchy []) @@ -99,12 +99,12 @@ #Hierarchy))) (def: (tail singleton) - (All [a] (-> a (Base a))) + (All (_ a) (-> a (Base a))) (|> (array.empty 1) (array.write! 0 singleton))) (def: (with_tail size level tail parent) - (All [a] (-> Nat Level (Base a) (Hierarchy a) (Hierarchy a))) + (All (_ a) (-> Nat Level (Base a) (Hierarchy a) (Hierarchy a))) (let [sub_idx (branch_idx (i64.right_shifted level (-- size))) ... If we're currently on a bottom node sub_node (if (n.= branching_exponent level) @@ -126,14 +126,14 @@ (array.write! sub_idx sub_node)))) (def: (expanded_tail val tail) - (All [a] (-> a (Base a) (Base a))) + (All (_ a) (-> a (Base a) (Base a))) (let [tail_size (array.size tail)] (|> (array.empty (++ tail_size)) (array.copy! tail_size 0 tail 0) (array.write! tail_size val)))) (def: (hierarchy\has level idx val hierarchy) - (All [a] (-> Level Index a (Hierarchy a) (Hierarchy a))) + (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) (#.Some (#Hierarchy sub_node)) @@ -151,7 +151,7 @@ (undefined)))) (def: (without_tail size level hierarchy) - (All [a] (-> Nat Level (Hierarchy a) (Maybe (Hierarchy a)))) + (All (_ a) (-> Nat Level (Hierarchy a) (Maybe (Hierarchy a)))) (let [sub_idx (branch_idx (i64.right_shifted level (n.- 2 size)))] (cond (n.= 0 sub_idx) #.None @@ -176,7 +176,7 @@ ))) (def: (node\list node) - (All [a] (-> (Node a) (List a))) + (All (_ a) (-> (Node a) (List a))) (case node (#Base base) (array.list #.None base) @@ -204,11 +204,11 @@ #tail (array.empty 0)}) (def: .public (size row) - (All [a] (-> (Row a) Nat)) + (All (_ a) (-> (Row a) Nat)) (value@ #size row)) (def: .public (suffix val row) - (All [a] (-> a (Row a) (Row a))) + (All (_ a) (-> a (Row a) (Row a))) ... Check if there is room in the tail. (let [row_size (value@ #size row)] (if (|> row_size (n.- (tail_off row_size)) (n.< full_node_size)) @@ -249,11 +249,11 @@ (exception: base_was_not_found) (def: .public (within_bounds? row idx) - (All [a] (-> (Row a) Nat Bit)) + (All (_ a) (-> (Row a) Nat Bit)) (n.< (value@ #size row) idx)) (def: (base_for idx row) - (All [a] (-> Index (Row a) (Try (Base a)))) + (All (_ a) (-> Index (Row a) (Try (Base a)))) (if (within_bounds? row idx) (if (n.< (tail_off (value@ #size row)) idx) (loop [level (value@ #level row) @@ -275,7 +275,7 @@ (exception.except ..index_out_of_bounds [row idx]))) (def: .public (item idx row) - (All [a] (-> Nat (Row a) (Try a))) + (All (_ a) (-> Nat (Row a) (Try a))) (do try.monad [base (base_for idx row)] (case (array.read! (branch_idx idx) base) @@ -286,7 +286,7 @@ (exception.except ..incorrect_row_structure [])))) (def: .public (has idx val row) - (All [a] (-> Nat a (Row a) (Try (Row a)))) + (All (_ a) (-> Nat a (Row a) (Try (Row a)))) (let [row_size (value@ #size row)] (if (within_bounds? row idx) (#try.Success (if (n.< (tail_off row_size) idx) @@ -300,13 +300,13 @@ (exception.except ..index_out_of_bounds [row idx])))) (def: .public (revised idx f row) - (All [a] (-> Nat (-> a a) (Row a) (Try (Row a)))) + (All (_ a) (-> Nat (-> a a) (Row a) (Try (Row a)))) (do try.monad [val (..item idx row)] (..has idx (f val) row))) (def: .public (prefix row) - (All [a] (-> (Row a) (Row a))) + (All (_ a) (-> (Row a) (Row a))) (case (value@ #size row) 0 empty @@ -348,27 +348,27 @@ )) (def: .public (list row) - (All [a] (-> (Row a) (List a))) + (All (_ a) (-> (Row a) (List a))) (list\composite (node\list (#Hierarchy (value@ #root row))) (node\list (#Base (value@ #tail row))))) (def: .public of_list - (All [a] (-> (List a) (Row a))) + (All (_ a) (-> (List a) (Row a))) (list\mix ..suffix ..empty)) (def: .public (member? equivalence row val) - (All [a] (-> (Equivalence a) (Row a) a Bit)) + (All (_ a) (-> (Equivalence a) (Row a) a Bit)) (list.member? equivalence (list row) val)) (def: .public empty? - (All [a] (-> (Row a) Bit)) + (All (_ a) (-> (Row a) Bit)) (|>> (value@ #size) (n.= 0))) (syntax: .public (row [elems (<>.some .any)]) (in (.list (` (..of_list (.list (~+ elems))))))) (implementation: (node_equivalence Equivalence) - (All [a] (-> (Equivalence a) (Equivalence (Node a)))) + (All (_ a) (-> (Equivalence a) (Equivalence (Node a)))) (def: (= v1 v2) (case [v1 v2] @@ -382,7 +382,7 @@ #0))) (implementation: .public (equivalence Equivalence) - (All [a] (-> (Equivalence a) (Equivalence (Row a)))) + (All (_ a) (-> (Equivalence a) (Equivalence (Row a)))) (def: (= v1 v2) (and (n.= (value@ #size v1) (value@ #size v2)) @@ -417,7 +417,7 @@ (#Base (value@ #tail xs)))))) (implementation: .public monoid - (All [a] (Monoid (Row a))) + (All (_ a) (Monoid (Row a))) (def: identity ..empty) @@ -471,16 +471,16 @@ (mix (function (_ post pre) (composite pre post)) identity)))) (def: .public reversed - (All [a] (-> (Row a) (Row a))) + (All (_ a) (-> (Row a) (Row a))) (|>> ..list list.reversed (list\mix suffix ..empty))) (template [ ] [(def: .public - (All [a] + (All (_ a) (-> (Predicate a) (Row a) Bit)) - (let [help (: (All [a] + (let [help (: (All (_ a) (-> (Predicate a) (Node a) Bit)) (function (help predicate node) (case node diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux index 8efb47cce..72821bf95 100644 --- a/stdlib/source/library/lux/data/collection/sequence.lux +++ b/stdlib/source/library/lux/data/collection/sequence.lux @@ -23,18 +23,18 @@ (Cont [a (Sequence a)])) (def: .public (iterations step init) - (All [a b] + (All (_ a b) (-> (-> a [a b]) a (Sequence b))) (let [[next x] (step init)] (//.pending [x (iterations step next)]))) (def: .public (repeated x) - (All [a] + (All (_ a) (-> a (Sequence a))) (//.pending [x (repeated x)])) (def: .public (cycle [start next]) - (All [a] + (All (_ a) (-> [a (List a)] (Sequence a))) (loop [head start tail next] @@ -47,7 +47,7 @@ (template [ ] [(def: .public ( sequence) - (All [a] (-> (Sequence a) )) + (All (_ a) (-> (Sequence a) )) (let [[head tail] (//.result sequence)] ))] @@ -56,7 +56,7 @@ ) (def: .public (item idx sequence) - (All [a] (-> Nat (Sequence a) a)) + (All (_ a) (-> Nat (Sequence a) a)) (let [[head tail] (//.result sequence)] (case idx 0 head @@ -64,7 +64,7 @@ (template [ ] [(def: .public ( pred xs) - (All [a] + (All (_ a) (-> (Sequence a) (List a))) (let [[x xs'] (//.result xs)] (if ( ) @@ -72,7 +72,7 @@ (list)))) (def: .public ( pred xs) - (All [a] + (All (_ a) (-> (Sequence a) (Sequence a))) (let [[x xs'] (//.result xs)] (if ( ) @@ -85,7 +85,7 @@ (template [ ] [(def: .public ( pred xs) - (All [a] + (All (_ a) (-> (Sequence a) [(List a) (Sequence a)])) (let [[x xs'] (//.result xs)] (if @@ -98,14 +98,14 @@ ) (def: .public (only predicate sequence) - (All [a] (-> (-> a Bit) (Sequence a) (Sequence a))) + (All (_ a) (-> (-> a Bit) (Sequence a) (Sequence a))) (let [[head tail] (//.result sequence)] (if (predicate head) (//.pending [head (only predicate tail)]) (only predicate tail)))) (def: .public (partition left? xs) - (All [a] (-> (-> a Bit) (Sequence a) [(Sequence a) (Sequence a)])) + (All (_ a) (-> (-> a Bit) (Sequence a) [(Sequence a) (Sequence a)])) [(..only left? xs) (..only (bit.complement left?) xs)]) diff --git a/stdlib/source/library/lux/data/collection/set.lux b/stdlib/source/library/lux/data/collection/set.lux index d9c18877b..62e155534 100644 --- a/stdlib/source/library/lux/data/collection/set.lux +++ b/stdlib/source/library/lux/data/collection/set.lux @@ -19,48 +19,48 @@ (Dictionary a Any)) (def: .public member_hash - (All [a] (-> (Set a) (Hash a))) + (All (_ a) (-> (Set a) (Hash a))) //.key_hash) (def: .public empty - (All [a] (-> (Hash a) (Set a))) + (All (_ a) (-> (Hash a) (Set a))) //.empty) (def: .public size - (All [a] (-> (Set a) Nat)) + (All (_ a) (-> (Set a) Nat)) //.size) (def: .public (has elem set) - (All [a] (-> a (Set a) (Set a))) + (All (_ a) (-> a (Set a) (Set a))) (|> set (//.has elem []))) (def: .public lacks - (All [a] (-> a (Set a) (Set a))) + (All (_ a) (-> a (Set a) (Set a))) //.lacks) (def: .public member? - (All [a] (-> (Set a) a Bit)) + (All (_ a) (-> (Set a) a Bit)) //.key?) (def: .public list - (All [a] (-> (Set a) (List a))) + (All (_ a) (-> (Set a) (List a))) //.keys) (def: .public union - (All [a] (-> (Set a) (Set a) (Set a))) + (All (_ a) (-> (Set a) (Set a) (Set a))) //.merged) (def: .public (difference sub base) - (All [a] (-> (Set a) (Set a) (Set a))) + (All (_ a) (-> (Set a) (Set a) (Set a))) (list\mix ..lacks base (..list sub))) (def: .public (intersection filter base) - (All [a] (-> (Set a) (Set a) (Set a))) + (All (_ a) (-> (Set a) (Set a) (Set a))) (//.sub (//.keys filter) base)) (implementation: .public equivalence - (All [a] (Equivalence (Set a))) + (All (_ a) (Equivalence (Set a))) (def: (= (^@ reference [hash _]) sample) (and (n.= (..size reference) @@ -69,7 +69,7 @@ (..list sample))))) (implementation: .public hash - (All [a] (Hash (Set a))) + (All (_ a) (Hash (Set a))) (def: &equivalence ..equivalence) @@ -79,27 +79,27 @@ (\ (list.hash (..member_hash set)) hash)))) (implementation: .public (monoid hash) - (All [a] (-> (Hash a) (Monoid (Set a)))) + (All (_ a) (-> (Hash a) (Monoid (Set a)))) (def: identity (..empty hash)) (def: composite ..union)) (def: .public empty? - (All [a] (-> (Set a) Bit)) + (All (_ a) (-> (Set a) Bit)) (|>> ..size (n.= 0))) (def: .public (of_list hash elements) - (All [a] (-> (Hash a) (List a) (Set a))) + (All (_ a) (-> (Hash a) (List a) (Set a))) (list\mix ..has (..empty hash) elements)) (def: .public (sub? super sub) - (All [a] (-> (Set a) (Set a) Bit)) + (All (_ a) (-> (Set a) (Set a) Bit)) (list.every? (..member? super) (..list sub))) (def: .public (super? sub super) - (All [a] (-> (Set a) (Set a) Bit)) + (All (_ a) (-> (Set a) (Set a) Bit)) (..sub? super sub)) (def: .public predicate - (All [a] (-> (Set a) (Predicate a))) + (All (_ a) (-> (Set a) (Predicate a))) ..member?) diff --git a/stdlib/source/library/lux/data/collection/set/multi.lux b/stdlib/source/library/lux/data/collection/set/multi.lux index 73964bc7a..62aa7a52f 100644 --- a/stdlib/source/library/lux/data/collection/set/multi.lux +++ b/stdlib/source/library/lux/data/collection/set/multi.lux @@ -24,15 +24,15 @@ (Dictionary a Nat) (def: .public empty - (All [a] (-> (Hash a) (Set a))) + (All (_ a) (-> (Hash a) (Set a))) (|>> dictionary.empty :abstraction)) (def: .public size - (All [a] (-> (Set a) Nat)) + (All (_ a) (-> (Set a) Nat)) (|>> :representation dictionary.values (list\mix n.+ 0))) (def: .public (has multiplicity elem set) - (All [a] (-> Nat a (Set a) (Set a))) + (All (_ a) (-> Nat a (Set a) (Set a))) (case multiplicity 0 set _ (|> set @@ -41,7 +41,7 @@ :abstraction))) (def: .public (lacks multiplicity elem set) - (All [a] (-> Nat a (Set a) (Set a))) + (All (_ a) (-> Nat a (Set a) (Set a))) (case multiplicity 0 set _ (case (dictionary.value elem (:representation set)) @@ -55,11 +55,11 @@ set))) (def: .public (multiplicity set elem) - (All [a] (-> (Set a) a Nat)) + (All (_ a) (-> (Set a) a Nat)) (|> set :representation (dictionary.value elem) (maybe.else 0))) (def: .public list - (All [a] (-> (Set a) (List a))) + (All (_ a) (-> (Set a) (List a))) (|>> :representation dictionary.entries (list\mix (function (_ [elem multiplicity] output) @@ -68,7 +68,7 @@ (template [ ] [(def: .public ( parameter subject) - (All [a] (-> (Set a) (Set a) (Set a))) + (All (_ a) (-> (Set a) (Set a) (Set a))) (:abstraction (dictionary.merged_with (:representation parameter) (:representation subject))))] [union n.max] @@ -76,7 +76,7 @@ ) (def: .public (intersection parameter (^:representation subject)) - (All [a] (-> (Set a) (Set a) (Set a))) + (All (_ a) (-> (Set a) (Set a) (Set a))) (list\mix (function (_ [elem multiplicity] output) (..has (n.min (..multiplicity parameter elem) multiplicity) @@ -86,7 +86,7 @@ (dictionary.entries subject))) (def: .public (difference parameter subject) - (All [a] (-> (Set a) (Set a) (Set a))) + (All (_ a) (-> (Set a) (Set a) (Set a))) (|> parameter :representation dictionary.entries @@ -95,7 +95,7 @@ subject))) (def: .public (sub? reference subject) - (All [a] (-> (Set a) (Set a) Bit)) + (All (_ a) (-> (Set a) (Set a) Bit)) (|> subject :representation dictionary.entries @@ -105,14 +105,14 @@ (n.>= multiplicity)))))) (def: .public (support set) - (All [a] (-> (Set a) (//.Set a))) + (All (_ a) (-> (Set a) (//.Set a))) (let [(^@ set [hash _]) (:representation set)] (|> set dictionary.keys (//.of_list hash)))) (implementation: .public equivalence - (All [a] (Equivalence (Set a))) + (All (_ a) (Equivalence (Set a))) (def: (= (^:representation reference) sample) (and (n.= (dictionary.size reference) @@ -125,7 +125,7 @@ (n.= multiplicity)))))))) (implementation: .public hash - (All [a] (Hash (Set a))) + (All (_ a) (Hash (Set a))) (def: &equivalence ..equivalence) @@ -138,22 +138,22 @@ ) (def: .public (member? set elem) - (All [a] (-> (Set a) a Bit)) + (All (_ a) (-> (Set a) a Bit)) (|> elem (..multiplicity set) (n.> 0))) (def: .public empty? - (All [a] (-> (Set a) Bit)) + (All (_ a) (-> (Set a) Bit)) (|>> ..size (n.= 0))) (def: .public (of_list hash subject) - (All [a] (-> (Hash a) (List a) (Set a))) + (All (_ a) (-> (Hash a) (List a) (Set a))) (list\mix (..has 1) (..empty hash) subject)) (def: .public (of_set subject) - (All [a] (-> (//.Set a) (Set a))) + (All (_ a) (-> (//.Set a) (Set a))) (..of_list (//.member_hash subject) (//.list subject))) (def: .public super? - (All [a] (-> (Set a) (Set a) Bit)) + (All (_ a) (-> (Set a) (Set a) Bit)) (function.flipped sub?)) diff --git a/stdlib/source/library/lux/data/collection/set/ordered.lux b/stdlib/source/library/lux/data/collection/set/ordered.lux index eeb66fa5e..ac8c54ac0 100644 --- a/stdlib/source/library/lux/data/collection/set/ordered.lux +++ b/stdlib/source/library/lux/data/collection/set/ordered.lux @@ -18,16 +18,16 @@ (/.Dictionary a a) (def: .public empty - (All [a] (-> (Order a) (Set a))) + (All (_ a) (-> (Order a) (Set a))) (|>> /.empty :abstraction)) (def: .public (member? set elem) - (All [a] (-> (Set a) a Bit)) + (All (_ a) (-> (Set a) a Bit)) (/.key? (:representation set) elem)) (template [ ] [(def: .public - (All [a] (-> (Set a) )) + (All (_ a) (-> (Set a) )) (|>> :representation ))] [(Maybe a) min /.min] @@ -37,39 +37,39 @@ ) (def: .public (has elem set) - (All [a] (-> a (Set a) (Set a))) + (All (_ a) (-> a (Set a) (Set a))) (|> set :representation (/.has elem elem) :abstraction)) (def: .public (lacks elem set) - (All [a] (-> a (Set a) (Set a))) + (All (_ a) (-> a (Set a) (Set a))) (|> set :representation (/.lacks elem) :abstraction)) (def: .public list - (All [a] (-> (Set a) (List a))) + (All (_ a) (-> (Set a) (List a))) (|>> :representation /.keys)) (def: .public (of_list &order list) - (All [a] (-> (Order a) (List a) (Set a))) + (All (_ a) (-> (Order a) (List a) (Set a))) (list\mix has (..empty &order) list)) (def: .public (union left right) - (All [a] (-> (Set a) (Set a) (Set a))) + (All (_ a) (-> (Set a) (Set a) (Set a))) (list\mix ..has right (..list left))) (def: .public (intersection left right) - (All [a] (-> (Set a) (Set a) (Set a))) + (All (_ a) (-> (Set a) (Set a) (Set a))) (|> (..list right) (list.only (..member? left)) (..of_list (value@ #/.&order (:representation right))))) (def: .public (difference param subject) - (All [a] (-> (Set a) (Set a) (Set a))) + (All (_ a) (-> (Set a) (Set a) (Set a))) (|> (..list subject) (list.only (|>> (..member? param) not)) (..of_list (value@ #/.&order (:representation subject))))) (implementation: .public equivalence - (All [a] (Equivalence (Set a))) + (All (_ a) (Equivalence (Set a))) (def: (= reference sample) (\ (list.equivalence (\ (:representation reference) &equivalence)) @@ -77,11 +77,11 @@ ) (def: .public (sub? super sub) - (All [a] (-> (Set a) (Set a) Bit)) + (All (_ a) (-> (Set a) (Set a) Bit)) (|> sub ..list (list.every? (..member? super)))) (def: .public (super? sub super) - (All [a] (-> (Set a) (Set a) Bit)) + (All (_ a) (-> (Set a) (Set a) Bit)) (sub? super sub)) diff --git a/stdlib/source/library/lux/data/collection/stack.lux b/stdlib/source/library/lux/data/collection/stack.lux index 549450cbd..8bb20bff3 100644 --- a/stdlib/source/library/lux/data/collection/stack.lux +++ b/stdlib/source/library/lux/data/collection/stack.lux @@ -20,15 +20,15 @@ (:abstraction (list))) (def: .public size - (All [a] (-> (Stack a) Nat)) + (All (_ a) (-> (Stack a) Nat)) (|>> :representation //.size)) (def: .public empty? - (All [a] (-> (Stack a) Bit)) + (All (_ a) (-> (Stack a) Bit)) (|>> :representation //.empty?)) (def: .public (value stack) - (All [a] (-> (Stack a) (Maybe a))) + (All (_ a) (-> (Stack a) (Maybe a))) (case (:representation stack) #.End #.None @@ -37,7 +37,7 @@ (#.Some value))) (def: .public (next stack) - (All [a] (-> (Stack a) (Maybe [a (Stack a)]))) + (All (_ a) (-> (Stack a) (Maybe [a (Stack a)]))) (case (:representation stack) #.End #.None @@ -46,11 +46,11 @@ (#.Some [top (:abstraction stack')]))) (def: .public (top value stack) - (All [a] (-> a (Stack a) (Stack a))) + (All (_ a) (-> a (Stack a) (Stack a))) (:abstraction (#.Item value (:representation stack)))) (implementation: .public (equivalence super) - (All [a] + (All (_ a) (-> (Equivalence a) (Equivalence (Stack a)))) diff --git a/stdlib/source/library/lux/data/collection/tree.lux b/stdlib/source/library/lux/data/collection/tree.lux index 47a4c8957..d16d02c74 100644 --- a/stdlib/source/library/lux/data/collection/tree.lux +++ b/stdlib/source/library/lux/data/collection/tree.lux @@ -22,7 +22,7 @@ #children (List (Tree a))})) (def: .public (flat tree) - (All [a] (-> (Tree a) (List a))) + (All (_ a) (-> (Tree a) (List a))) (|> tree (value@ #children) (list\each flat) @@ -30,12 +30,12 @@ (#.Item (value@ #value tree)))) (def: .public (leaf value) - (All [a] (-> a (Tree a))) + (All (_ a) (-> a (Tree a))) {#value value #children (list)}) (def: .public (branch value children) - (All [a] (-> a (List (Tree a)) (Tree a))) + (All (_ a) (-> a (List (Tree a)) (Tree a))) {#value value #children children}) @@ -60,7 +60,7 @@ #children (list (~+ (list\each recur children)))}))))))) (implementation: .public (equivalence super) - (All [a] (-> (Equivalence a) (Equivalence (Tree a)))) + (All (_ a) (-> (Equivalence a) (Equivalence (Tree a)))) (def: (= tx ty) (and (\ super = (value@ #value tx) (value@ #value ty)) diff --git a/stdlib/source/library/lux/data/collection/tree/finger.lux b/stdlib/source/library/lux/data/collection/tree/finger.lux index 3f807f49f..b8313112c 100644 --- a/stdlib/source/library/lux/data/collection/tree/finger.lux +++ b/stdlib/source/library/lux/data/collection/tree/finger.lux @@ -22,10 +22,10 @@ (type: .public (Builder @ t) (Interface - (: (All [v] + (: (All (_ v) (-> t v (Tree @ t v))) leaf) - (: (All [v] + (: (All (_ v) (-> (Tree @ t v) (Tree @ t v) (Tree @ t v))) @@ -33,7 +33,7 @@ (template [ ] [(def: .public - (All [@ t v] (-> (Tree @ t v) )) + (All (_ @ t v) (-> (Tree @ t v) )) (|>> :representation (value@ )))] [tag #tag t] @@ -41,7 +41,7 @@ ) (implementation: .public (builder monoid) - (All [t] (Ex [@] (-> (Monoid t) (Builder @ t)))) + (All (_ t) (Ex (_ @) (-> (Monoid t) (Builder @ t)))) (def: (leaf tag value) (:abstraction @@ -56,7 +56,7 @@ #root (0 #1 [left right])}))) (def: .public (value tree) - (All [@ t v] (-> (Tree @ t v) v)) + (All (_ @ t v) (-> (Tree @ t v) v)) (case (value@ #root (:representation tree)) (0 #0 value) value @@ -65,7 +65,7 @@ (value left))) (def: .public (tags tree) - (All [@ t v] (-> (Tree @ t v) (List t))) + (All (_ @ t v) (-> (Tree @ t v) (List t))) (case (value@ #root (:representation tree)) (0 #0 value) (list (value@ #tag (:representation tree))) @@ -75,7 +75,7 @@ (tags right)))) (def: .public (values tree) - (All [@ t v] (-> (Tree @ t v) (List v))) + (All (_ @ t v) (-> (Tree @ t v) (List v))) (case (value@ #root (:representation tree)) (0 #0 value) (list value) @@ -85,7 +85,7 @@ (values right)))) (def: .public (one predicate tree) - (All [@ t v] (-> (Predicate t) (Tree @ t v) (Maybe v))) + (All (_ @ t v) (-> (Predicate t) (Tree @ t v) (Maybe v))) (let [[monoid tag root] (:representation tree)] (if (predicate tag) (let [(^open "tag//.") monoid] @@ -104,7 +104,7 @@ ) (def: .public (exists? predicate tree) - (All [@ t v] (-> (Predicate t) (Tree @ t v) Bit)) + (All (_ @ t v) (-> (Predicate t) (Tree @ t v) Bit)) (case (..one predicate tree) (#.Some _) true diff --git a/stdlib/source/library/lux/data/collection/tree/zipper.lux b/stdlib/source/library/lux/data/collection/tree/zipper.lux index cec25e125..7f168c2d3 100644 --- a/stdlib/source/library/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/library/lux/data/collection/tree/zipper.lux @@ -30,7 +30,7 @@ #node (Tree a)})) (implementation: .public (equivalence super) - (All [a] + (All (_ a) (-> (Equivalence a) (Equivalence (Zipper a)))) @@ -45,40 +45,40 @@ (== reference sample)))) (def: .public (zipper tree) - (All [a] (-> (Tree a) (Zipper a))) + (All (_ a) (-> (Tree a) (Zipper a))) {#family #.None #node tree}) (def: .public tree - (All [a] (-> (Zipper a) (Tree a))) + (All (_ a) (-> (Zipper a) (Tree a))) (value@ #node)) (def: .public value - (All [a] (-> (Zipper a) a)) + (All (_ a) (-> (Zipper a) a)) (value@ [#node #//.value])) (def: .public (set value zipper) - (All [a] (-> a (Zipper a) (Zipper a))) + (All (_ a) (-> a (Zipper a) (Zipper a))) (with@ [#node #//.value] value zipper)) (def: .public (update transform zipper) - (All [a] (-> (-> a a) (Zipper a) (Zipper a))) + (All (_ a) (-> (-> a a) (Zipper a) (Zipper a))) (revised@ [#node #//.value] transform zipper)) (def: children - (All [a] (-> (Zipper a) (List (Tree a)))) + (All (_ a) (-> (Zipper a) (List (Tree a)))) (value@ [#node #//.children])) (def: .public leaf? - (All [a] (-> (Zipper a) Bit)) + (All (_ a) (-> (Zipper a) Bit)) (|>> ..children list.empty?)) (def: .public branch? - (All [a] (-> (Zipper a) Bit)) + (All (_ a) (-> (Zipper a) Bit)) (|>> ..leaf? not)) (def: .public (start? zipper) - (All [a] (-> (Zipper a) Bit)) + (All (_ a) (-> (Zipper a) Bit)) (case (value@ #family zipper) #.None true @@ -87,7 +87,7 @@ false)) (def: .public (down zipper) - (All [a] (-> (Zipper a) (Maybe (Zipper a)))) + (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (..children zipper) #.End #.None @@ -99,7 +99,7 @@ #node head}))) (def: .public (up zipper) - (All [a] (-> (Zipper a) (Maybe (Zipper a)))) + (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (do maybe.monad [family (value@ #family zipper)] (in (let [(^slots [#parent #lefts #rights]) family] @@ -118,7 +118,7 @@ (template [ ] [(def: .public ( zipper) - (All [a] (-> (Zipper a) (Maybe (Zipper a)))) + (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (value@ #family zipper) (#.Some family) (case (value@ family) @@ -128,7 +128,7 @@ (with@ side') (revised@ (|>> (#.Item (value@ #node zipper)))))) #node next}} - (let [move (: (All [a] (-> (List (Tree a)) (Zipper a) (Family Zipper a) (Family Zipper a))) + (let [move (: (All (_ a) (-> (List (Tree a)) (Zipper a) (Family Zipper a) (Family Zipper a))) (function (_ side' zipper) (|>> (with@ side') (revised@ (|>> (#.Item (value@ #node zipper)))))))] @@ -142,7 +142,7 @@ #.None)) (def: .public ( zipper) - (All [a] (-> (Zipper a) (Maybe (Zipper a)))) + (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (value@ #family zipper) #.None #.None @@ -158,7 +158,7 @@ (revised@ (|>> (#.Item (value@ #node zipper)) (list\composite prevs))))) #node last}} - (let [move (: (All [a] (-> (List (Tree a)) (Zipper a) (Family Zipper a) (Family Zipper a))) + (let [move (: (All (_ a) (-> (List (Tree a)) (Zipper a) (Family Zipper a) (Family Zipper a))) (function (_ prevs zipper) (|>> (with@ #.End) (revised@ (|>> (#.Item (value@ #node zipper)) @@ -171,7 +171,7 @@ ) (def: .public (next zipper) - (All [a] (-> (Zipper a) (Maybe (Zipper a)))) + (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (..down zipper) (#.Some forward) (#.Some forward) @@ -188,7 +188,7 @@ (recur @)))))) (def: (bottom zipper) - (All [a] (-> (Zipper a) (Zipper a))) + (All (_ a) (-> (Zipper a) (Zipper a))) (case (..right zipper) (#.Some forward) (bottom forward) @@ -202,7 +202,7 @@ zipper))) (def: .public (previous zipper) - (All [a] (-> (Zipper a) (Maybe (Zipper a)))) + (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (..left zipper) #.None (..up zipper) @@ -217,7 +217,7 @@ (template [ ] [(def: .public ( zipper) - (All [a] (-> (Zipper a) (Maybe (Zipper a)))) + (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case ( zipper) #.None #.None @@ -236,7 +236,7 @@ ) (def: .public (end? zipper) - (All [a] (-> (Zipper a) Bit)) + (All (_ a) (-> (Zipper a) Bit)) (case (..end zipper) #.None true @@ -245,19 +245,19 @@ false)) (def: .public (interpose value zipper) - (All [a] (-> a (Zipper a) (Zipper a))) + (All (_ a) (-> a (Zipper a) (Zipper a))) (revised@ [#node #//.children] (|>> (//.branch value) list) zipper)) (def: .public (adopt value zipper) - (All [a] (-> a (Zipper a) (Zipper a))) + (All (_ a) (-> a (Zipper a) (Zipper a))) (revised@ [#node #//.children] (|>> (#.Item (//.leaf value))) zipper)) (def: .public (remove zipper) - (All [a] (-> (Zipper a) (Maybe (Zipper a)))) + (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (do maybe.monad [family (value@ #family zipper)] (case (value@ #lefts family) @@ -275,7 +275,7 @@ (template [ ] [(def: .public ( value zipper) - (All [a] (-> a (Zipper a) (Maybe (Zipper a)))) + (All (_ a) (-> a (Zipper a) (Maybe (Zipper a)))) (case (value@ #family zipper) #.None #.None @@ -308,7 +308,7 @@ (def: out (value@ [#node #//.value])) (def: (disjoint (^slots [#family #node])) - (let [tree_splitter (: (All [a] (-> (Tree a) (Tree (Zipper a)))) + (let [tree_splitter (: (All (_ a) (-> (Tree a) (Tree (Zipper a)))) (function (tree_splitter tree) {#//.value (..zipper tree) #//.children (|> tree diff --git a/stdlib/source/library/lux/data/format/binary.lux b/stdlib/source/library/lux/data/format/binary.lux index 1e0ca5937..109b1c19d 100644 --- a/stdlib/source/library/lux/data/format/binary.lux +++ b/stdlib/source/library/lux/data/format/binary.lux @@ -60,7 +60,7 @@ (-> a Specification)) (def: .public (result writer value) - (All [a] (-> (Writer a) a Binary)) + (All (_ a) (-> (Writer a) a Binary)) (..instance (writer value))) (template [ ] @@ -81,7 +81,7 @@ ) (def: .public (or left right) - (All [l r] (-> (Writer l) (Writer r) (Writer (Or l r)))) + (All (_ l r) (-> (Writer l) (Writer r) (Writer (Or l r)))) (function (_ altV) (case altV (^template [ ] @@ -99,12 +99,12 @@ ))) (def: .public (and pre post) - (All [a b] (-> (Writer a) (Writer b) (Writer [a b]))) + (All (_ a b) (-> (Writer a) (Writer b) (Writer [a b]))) (function (_ [preV postV]) (\ ..monoid composite (pre preV) (post postV)))) (def: .public (rec body) - (All [a] (-> (-> (Writer a) (Writer a)) (Writer a))) + (All (_ a) (-> (-> (Writer a) (Writer a)) (Writer a))) (function (recur value) (body recur value))) @@ -177,7 +177,7 @@ (template [ ] [(def: .public ( valueW) - (All [v] (-> (Writer v) (Writer (Row v)))) + (All (_ v) (-> (Writer v) (Writer (Row v)))) (function (_ value) (let [original_count (row.size value) capped_count (i64.and (..mask ) @@ -206,17 +206,17 @@ ) (def: .public maybe - (All [a] (-> (Writer a) (Writer (Maybe a)))) + (All (_ a) (-> (Writer a) (Writer (Maybe a)))) (..or ..any)) (def: .public (list value) - (All [a] (-> (Writer a) (Writer (List a)))) + (All (_ a) (-> (Writer a) (Writer (List a)))) (..rec (|>> (..and value) (..or ..any)))) (def: .public (set value) - (All [a] (-> (Writer a) (Writer (Set a)))) + (All (_ a) (-> (Writer a) (Writer (Set a)))) (|>> set.list (..list value))) (def: .public name diff --git a/stdlib/source/library/lux/data/format/css/style.lux b/stdlib/source/library/lux/data/format/css/style.lux index a8ad45203..5aae7d013 100644 --- a/stdlib/source/library/lux/data/format/css/style.lux +++ b/stdlib/source/library/lux/data/format/css/style.lux @@ -23,7 +23,7 @@ " ") (def: .public (with [property value]) - (All [brand] + (All (_ brand) (-> [(Property brand) (Value brand)] (-> Style Style))) (|>> :representation diff --git a/stdlib/source/library/lux/data/format/html.lux b/stdlib/source/library/lux/data/format/html.lux index ffd4ab75a..bc17e00f6 100644 --- a/stdlib/source/library/lux/data/format/html.lux +++ b/stdlib/source/library/lux/data/format/html.lux @@ -126,11 +126,11 @@ (|>> :representation)) (def: .public (and pre post) - (All [brand] (-> (HTML brand) (HTML brand) (HTML brand))) + (All (_ brand) (-> (HTML brand) (HTML brand) (HTML brand))) (:abstraction (format (:representation pre) (:representation post)))) (def: .public (comment content node) - (All [brand] (-> Text (HTML brand) (HTML brand))) + (All (_ brand) (-> Text (HTML brand) (HTML brand))) (:abstraction (format (text.enclosed [""] content) (:representation node)))) diff --git a/stdlib/source/library/lux/data/format/markdown.lux b/stdlib/source/library/lux/data/format/markdown.lux index fdbfd4b69..a2df019bb 100644 --- a/stdlib/source/library/lux/data/format/markdown.lux +++ b/stdlib/source/library/lux/data/format/markdown.lux @@ -188,6 +188,6 @@ ) (def: .public markdown - (All [a] (-> (Markdown a) Text)) + (All (_ a) (-> (Markdown a) Text)) (|>> :representation)) ) diff --git a/stdlib/source/library/lux/data/format/xml.lux b/stdlib/source/library/lux/data/format/xml.lux index 9c29b086a..ab5981b4f 100644 --- a/stdlib/source/library/lux/data/format/xml.lux +++ b/stdlib/source/library/lux/data/format/xml.lux @@ -102,7 +102,7 @@ (def: attr_name^ namespaced_symbol^) (def: spaced^ - (All [a] (-> (Parser a) (Parser a))) + (All (_ a) (-> (Parser a) (Parser a))) (let [white_space^ (<>.some .space)] (|>> (<>.before white_space^) (<>.after white_space^)))) diff --git a/stdlib/source/library/lux/data/product.lux b/stdlib/source/library/lux/data/product.lux index 1e0bc9c96..3ad1ba207 100644 --- a/stdlib/source/library/lux/data/product.lux +++ b/stdlib/source/library/lux/data/product.lux @@ -7,7 +7,7 @@ (template [] [(def: .public ( [left right]) - (All [left right] + (All (_ left right) (-> [left right] )) )] @@ -17,14 +17,14 @@ ... https://en.wikipedia.org/wiki/Currying (def: .public (curried f) - (All [a b c] + (All (_ a b c) (-> (-> [a b] c) (-> a b c))) (function (_ x y) (f [x y]))) (def: .public (uncurried f) - (All [a b c] + (All (_ a b c) (-> (-> a b c) (-> [a b] c))) (function (_ xy) @@ -32,32 +32,32 @@ (f x y)))) (def: .public (swapped [left right]) - (All [left right] (-> [left right] [right left])) + (All (_ left right) (-> [left right] [right left])) [right left]) (def: .public (then f g) - (All [a b c d] + (All (_ a b c d) (-> (-> a c) (-> b d) (-> [a b] [c d]))) (function (_ [x y]) [(f x) (g y)])) (def: .public (forked f g) - (All [a l r] + (All (_ a l r) (-> (-> a l) (-> a r) (-> a [l r]))) (function (_ x) [(f x) (g x)])) (implementation: .public (equivalence left right) - (All [l r] (-> (Equivalence l) (Equivalence r) (Equivalence [l r]))) + (All (_ l r) (-> (Equivalence l) (Equivalence r) (Equivalence [l r]))) (def: (= [rl rr] [sl sr]) (and (\ left = rl sl) (\ right = rr sr)))) (def: .public (hash left right) - (All [l r] (-> (Hash l) (Hash r) (Hash [l r]))) + (All (_ l r) (-> (Hash l) (Hash r) (Hash [l r]))) (implementation (def: &equivalence (..equivalence (\ left &equivalence) diff --git a/stdlib/source/library/lux/data/store.lux b/stdlib/source/library/lux/data/store.lux index 5fc594957..24f7005fd 100644 --- a/stdlib/source/library/lux/data/store.lux +++ b/stdlib/source/library/lux/data/store.lux @@ -13,12 +13,12 @@ #peek (-> s a)})) (def: (extend f wa) - (All [s a b] (-> (-> (Store s a) b) (Store s a) (Store s b))) + (All (_ s a b) (-> (-> (Store s a) b) (Store s a) (Store s b))) {#cursor (value@ #cursor wa) #peek (function (_ s) (f (with@ #cursor s wa)))}) (implementation: .public functor - (All [s] (Functor (Store s))) + (All (_ s) (Functor (Store s))) (def: (each f fa) (extend (function (_ store) @@ -26,7 +26,7 @@ fa))) (implementation: .public comonad - (All [s] (CoMonad (Store s))) + (All (_ s) (CoMonad (Store s))) (def: &functor ..functor) @@ -38,17 +38,17 @@ (extend id))) (def: .public (peeks trans store) - (All [s a] (-> (-> s s) (Store s a) a)) + (All (_ s a) (-> (-> s s) (Store s a) a)) (|> (\\ cursor) trans (\\ peek))) (def: .public (seek cursor store) - (All [s a] (-> s (Store s a) (Store s a))) + (All (_ s a) (-> s (Store s a) (Store s a))) (\ (\\ disjoint store) peek cursor)) (def: .public (seeks change store) - (All [s a] (-> (-> s s) (Store s a) (Store s a))) + (All (_ s a) (-> (-> s s) (Store s a) (Store s a))) (|> store (\\ disjoint) (peeks change))) (def: .public (experiment Functor change store) - (All [f s a] (-> (Functor f) (-> s (f s)) (Store s a) (f a))) + (All (_ f s a) (-> (Functor f) (-> s (f s)) (Store s a) (f a))) (\ Functor each (\\ peek) (change (\\ cursor)))) diff --git a/stdlib/source/library/lux/data/sum.lux b/stdlib/source/library/lux/data/sum.lux index 193f25a05..7c8696012 100644 --- a/stdlib/source/library/lux/data/sum.lux +++ b/stdlib/source/library/lux/data/sum.lux @@ -7,7 +7,7 @@ (template [ ] [(def: .public ( value) - (All [left right] + (All (_ left right) (-> (Or left right))) (0 value))] @@ -15,7 +15,7 @@ [#1 right]) (def: .public (either on_left on_right) - (All [a b c] + (All (_ a b c) (-> (-> a c) (-> b c) (-> (Or a b) c))) (function (_ input) @@ -24,7 +24,7 @@ (0 #1 r) (on_right r)))) (def: .public (then on_left on_right) - (All [l l' r r'] + (All (_ l l' r r') (-> (-> l l') (-> r r') (-> (Or l r) (Or l' r')))) (function (_ input) @@ -34,7 +34,7 @@ (template [ ] [(def: .public ( items) - (All [a b] (-> (List (Or a b)) (List ))) + (All (_ a b) (-> (List (Or a b)) (List ))) (case items #.End #.End @@ -50,7 +50,7 @@ ) (def: .public (partition xs) - (All [a b] (-> (List (Or a b)) [(List a) (List b)])) + (All (_ a b) (-> (List (Or a b)) [(List a) (List b)])) (case xs #.End [#.End #.End] @@ -62,7 +62,7 @@ (0 #1 x') [lefts (#.Item x' rights)])))) (def: .public (equivalence left right) - (All [l r] (-> (Equivalence l) (Equivalence r) (Equivalence (Or l r)))) + (All (_ l r) (-> (Equivalence l) (Equivalence r) (Equivalence (Or l r)))) (implementation (def: (= reference sample) (case [reference sample] @@ -76,7 +76,7 @@ false)))) (def: .public (hash left right) - (All [l r] (-> (Hash l) (Hash r) (Hash (Or l r)))) + (All (_ l r) (-> (Hash l) (Hash r) (Hash (Or l r)))) (implementation (def: &equivalence (..equivalence (\ left &equivalence) diff --git a/stdlib/source/library/lux/data/text/format.lux b/stdlib/source/library/lux/data/text/format.lux index 11d1523e8..a41022153 100644 --- a/stdlib/source/library/lux/data/text/format.lux +++ b/stdlib/source/library/lux/data/text/format.lux @@ -111,18 +111,18 @@ ) (def: .public (mod modular) - (All [m] (Format (modular.Mod m))) + (All (_ m) (Format (modular.Mod m))) (let [codec (modular.codec (modular.modulus modular))] (\ codec encoded modular))) (def: .public (list formatter) - (All [a] (-> (Format a) (Format (List a)))) + (All (_ a) (-> (Format a) (Format (List a)))) (|>> (list\each (|>> formatter (format " "))) text.together (text.enclosed ["(list" ")"]))) (def: .public (maybe format) - (All [a] (-> (Format a) (Format (Maybe a)))) + (All (_ a) (-> (Format a) (Format (Maybe a)))) (function (_ value) (case value #.None diff --git a/stdlib/source/library/lux/data/text/regex.lux b/stdlib/source/library/lux/data/text/regex.lux index fcfb718ab..bdab7c6a1 100644 --- a/stdlib/source/library/lux/data/text/regex.lux +++ b/stdlib/source/library/lux/data/text/regex.lux @@ -37,7 +37,7 @@ regex_char^))) (def: (refine^ refinement^ base^) - (All [a] (-> (Parser a) (Parser Text) (Parser Text))) + (All (_ a) (-> (Parser a) (Parser Text) (Parser Text))) (do <>.monad [output base^ _ (.local output refinement^)] @@ -330,7 +330,7 @@ (<>.and lexer (\ <>.monad in []))) (def: (|||^ left right) - (All [l r] (-> (Parser [Text l]) (Parser [Text r]) (Parser [Text (Or l r)]))) + (All (_ l r) (-> (Parser [Text l]) (Parser [Text r]) (Parser [Text (Or l r)]))) (function (_ input) (case (left input) (#try.Success [input' [lt lv]]) @@ -345,7 +345,7 @@ (#try.Failure error))))) (def: (|||_^ left right) - (All [l r] (-> (Parser [Text l]) (Parser [Text r]) (Parser Text))) + (All (_ l r) (-> (Parser [Text l]) (Parser [Text r]) (Parser Text))) (function (_ input) (case (left input) (#try.Success [input' [lt lv]]) diff --git a/stdlib/source/library/lux/data/text/unicode/block.lux b/stdlib/source/library/lux/data/text/unicode/block.lux index 7c473d64d..a4f4d9eb2 100644 --- a/stdlib/source/library/lux/data/text/unicode/block.lux +++ b/stdlib/source/library/lux/data/text/unicode/block.lux @@ -56,7 +56,7 @@ (|> end (n.- start) ++))) (def: .public (within? block char) - (All [a] (-> Block Char Bit)) + (All (_ a) (-> Block Char Bit)) (interval.within? (:representation block) char)) ) diff --git a/stdlib/source/library/lux/data/trace.lux b/stdlib/source/library/lux/data/trace.lux index f07c533d9..35d97e9f9 100644 --- a/stdlib/source/library/lux/data/trace.lux +++ b/stdlib/source/library/lux/data/trace.lux @@ -13,13 +13,13 @@ #trace (-> t a)})) (implementation: .public functor - (All [t] (Functor (Trace t))) + (All (_ t) (Functor (Trace t))) (def: (each f fa) (revised@ #trace (composite f) fa))) (implementation: .public comonad - (All [t] (CoMonad (Trace t))) + (All (_ t) (CoMonad (Trace t))) (def: &functor ..functor) @@ -37,5 +37,5 @@ (\ monoid composite t1 t2)))})}))) (def: .public (result context tracer) - (All [t a] (-> t (Trace t a) a)) + (All (_ t a) (-> t (Trace t a) a)) (\ tracer trace context)) diff --git a/stdlib/source/library/lux/documentation.lux b/stdlib/source/library/lux/documentation.lux index 937401d5d..c73a71cd2 100644 --- a/stdlib/source/library/lux/documentation.lux +++ b/stdlib/source/library/lux/documentation.lux @@ -4,7 +4,8 @@ ["." meta] ["." type ("#\." equivalence)] [abstract - [monad (#+ do)]] + [monad (#+ do)] + ["." enum]] [control ["." maybe ("#\." functor)] ["." exception (#+ exception:)] @@ -16,7 +17,8 @@ ["%" format (#+ format)]] [collection ["." list ("#\." monad mix monoid)] - ["." set (#+ Set)]] + ["." set (#+ Set)] + ["." sequence (#+ Sequence)]] [format ["md" markdown (#+ Markdown Block)]]] ["." macro @@ -85,16 +87,29 @@ (text.together (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))) + (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\mix melded #.End)))) -(def: (code_documentation old_location reference_column example) - (-> Location Nat Code [Location Text]) +(def: (code_documentation expected_module old_location reference_column example) + (-> Text Location Nat Code [Location Text]) (case example + [new_location (#.Identifier [module short])] + (let [documentation (cond (text\= expected_module module) + short + + (text\= .prelude_module module) + (format "." short) + + ... else + (%.name [module short]))] + [(revised@ #.column (n.+ (text.size documentation)) new_location) + (format (padding reference_column old_location new_location) + documentation)]) + (^template [ ] [[new_location ( value)] (let [documentation (`` (|> value (~~ (template.spliced ))))] @@ -107,13 +122,12 @@ [#.Rev [%.rev]] [#.Frac [%.frac]] [#.Text [%.text]] - [#.Identifier [%.name]] [#.Tag [%.name (text.prefix syntax.sigil)]]) (^template [|<| |>| ] [[group_location ( members)] (let [[group_location' members_documentation] (list\mix (function (_ part [last_location text_accum]) - (let [[member_location member_documentation] (code_documentation last_location reference_column part)] + (let [[member_location member_documentation] (code_documentation expected_module last_location reference_column part)] [member_location (format text_accum member_documentation)])) [(revised@ #.column ++ group_location) ""] ( members))] @@ -133,8 +147,8 @@ (-> Text Text) (text.prefix "... ")) -(def: (fragment_documentation fragment) - (-> Fragment Text) +(def: (fragment_documentation module fragment) + (-> Text Fragment Text) (case fragment (#Comment comment) (..single_line_comment comment) @@ -143,12 +157,130 @@ (let [reference_column (..reference_column example) [location _] example] (|> example - (..code_documentation (with@ #.column reference_column location) reference_column) + (..code_documentation module (with@ #.column reference_column location) reference_column) product.right)))) +(def: parameter_name_options "abcdefghijklmnopqrstuvwxyz") +(def: parameter_name_options_count (text.size parameter_name_options)) + +(def: (parameter_type_name id) + (-> Nat Text) + (case (text.char id ..parameter_name_options) + (#.Some char) + (text.of_char char) + + #.None + (format (parameter_type_name (n./ parameter_name_options_count id)) + (parameter_type_name (n.% parameter_name_options_count id))))) + +(def: type_variable_names + (Sequence Text) + (sequence.iterations (product.forked ++ parameter_type_name) + 0)) + +(template [ ] + [(def: ( id) + (-> Nat Bit) + ( id))] + + [type_function? n.even?] + [type_parameter? n.odd?] + ) + +(def: (parameter_id level id) + (-> Nat Nat Nat) + (n.- (n./ 2 id) level)) + +(def: (parameter_name [type_function_name type_function_arguments] level id) + (-> [Text (List Text)] Nat Nat Text) + (if (type_parameter? id) + (let [parameter_id (..parameter_id level id)] + (case (list.item parameter_id type_function_arguments) + (#.Some found) + found + + _ + (|> type_variable_names + (sequence.only (function (_ var_name) + (not (list.member? text.equivalence type_function_arguments var_name)))) + (sequence.item parameter_id)))) + type_function_name)) + +(def: (level_parameters offset level) + (-> Nat Nat (List Text)) + (if (n.= 0 level) + (list) + (|> level + -- + (enum.range n.enum 0) + (list\each (|>> (n.+ (++ offset)) parameter_type_name))))) + +(def: (%type' level type_function_name module type) + (-> Nat Text Text Type Text) + (case type + (#.Primitive name params) + (|> params + (list\each (|>> (%type' level type_function_name module) + (format " "))) + (#.Item (%.text name)) + text.together + (text.enclosed ["(primitive " ")"])) + + (#.Sum _) + (|> type + type.flat_variant + (list\each (%type' level type_function_name module)) + (text.interposed " ") + (text.enclosed ["(Or " ")"])) + + (#.Product _) + (|> type + type.flat_tuple + (list\each (%type' level type_function_name module)) + (text.interposed " ") + (text.enclosed ["[" "]"])) + + (#.Function input output) + (let [[ins out] (type.flat_function type)] + (format "(-> " + (|> ins (list\each (%type' level type_function_name module)) (text.interposed " ")) + " " + (%type' level type_function_name module out) + ")")) + + (#.Parameter idx) + (parameter_name [type_function_name (list)] level idx) + + (^template [
 ]
+      [( id)
+       (format 
 (%.nat id) )])
+    ([#.Var "⌈" "⌋"]
+     [#.Ex  "⟨" "⟩"])
+
+    (^template [  ]
+      [( _)
+       (let [[level' body] ( type)
+             args (level_parameters level level')
+             body_doc (%type' (n.+ level level') type_function_name module body)]
+         (format "("  " " "(_ " (|> args (text.interposed " ")) ")"
+                 (format " " body_doc)
+                 ")"))])
+    ([#.UnivQ "All" type.flat_univ_q]
+     [#.ExQ   "Ex"  type.flat_ex_q])
+
+    (#.Apply param fun)
+    (let [[type_func type_arguments] (type.flat_application type)]
+      (format  "(" (%type' level type_function_name module type_func) " " (|> type_arguments (list\each (%type' level type_function_name module)) (text.interposed " ")) ")"))
+
+    (#.Named [_module _name] type)
+    (if (text\= module _module)
+      _name
+      (%.name [_module _name]))
+    ))
+
 (def: type
-  (-> Type Text)
-  %.type)
+  (-> Text Type Text)
+  (%type' (-- 0) "?"))
 
 (def: description
   (Parser (Maybe Code))
@@ -186,36 +318,38 @@
   (Parser Example)
   (.tuple (<>.many ..fragment)))
 
-(def: example_documentation
-  (-> Example Code)
-  (|>> (list\each ..fragment_documentation)
-       (list.interposed ..blank_line)
-       (text.interposed "")
-       code.text))
+(def: (example_documentation module example)
+  (-> Text Example Code)
+  (|> example
+      (list\each (..fragment_documentation module))
+      (list.interposed ..blank_line)
+      (text.interposed "")
+      code.text))
 
 (syntax: (minimal_definition_documentation
           [name ..qualified_identifier])
-  (with_expansions [<\n> (~! text.\n)]
-    (macro.with_identifiers [g!type]
-      (in (list (` ($_ ((~! md.then))
-                       ... Name
-                       (<| ((~! md.heading/3))
-                           (~ (code.text (|> name product.right [""] %.name))))
-                       ... Type
-                       (let [(~ g!type) ("lux in-module"
-                                         (~ (code.text (product.left name)))
-                                         (.:of (~ (code.identifier name))))]
-                         ((~! md.code)
-                          (if ((~! type\=) .Type (~ g!type))
-                            (|> (~ (code.identifier name))
-                                (:as .Type)
-                                ((~! type.anonymous))
-                                ((~! ..type))
-                                ((~! %.format)
-                                 ((~! ..single_line_comment) ((~! ..type) (~ g!type)))
-                                 <\n>))
-                            ((~! ..type) (~ g!type))))))
-                   ))))))
+  (let [g!module (code.text (product.left name))]
+    (with_expansions [<\n> (~! text.\n)]
+      (macro.with_identifiers [g!type]
+        (in (list (` ($_ ((~! md.then))
+                         ... Name
+                         (<| ((~! md.heading/3))
+                             (~ (code.text (|> name product.right [""] %.name))))
+                         ... Type
+                         (let [(~ g!type) ("lux in-module"
+                                           (~ g!module)
+                                           (.:of (~ (code.identifier name))))]
+                           ((~! md.code)
+                            (if ((~! type\=) .Type (~ g!type))
+                              (|> (~ (code.identifier name))
+                                  (:as .Type)
+                                  ((~! type.anonymous))
+                                  ((~! ..type) (~ g!module))
+                                  ((~! %.format)
+                                   ((~! ..single_line_comment) ((~! ..type) (~ g!module) (~ g!type)))
+                                   <\n>))
+                              ((~! ..type) (~ g!module) (~ g!type))))))
+                     )))))))
 
 (syntax: (definition_documentation
           [name ..qualified_identifier
@@ -243,7 +377,7 @@
                            (list (` (<| ((~! md.code))
                                         ((~! %.format)
                                          (~+ (|> examples
-                                                 (list\each ..example_documentation)
+                                                 (list\each (..example_documentation (product.left name)))
                                                  (list.interposed ..example_separator))))))))))
                  )))))
 
diff --git a/stdlib/source/library/lux/ffi.js.lux b/stdlib/source/library/lux/ffi.js.lux
index 6d1867dfc..cb2fafe6f 100644
--- a/stdlib/source/library/lux/ffi.js.lux
+++ b/stdlib/source/library/lux/ffi.js.lux
@@ -250,7 +250,7 @@
                     ["#::."
                      (new [..String])
                      (decode [..String] String)]))}
-  (with_identifiers [g!temp]
+  (with_identifiers [g!temp g!_]
     (case import
       (#Class [[class_name class_parameters] format members])
       (with_identifiers [g!object]
@@ -272,7 +272,7 @@
                                     (let [g!inputs (input_variables inputsT)]
                                       (` (def: ((~ (qualify "new"))
                                                 [(~+ (list\each product.right g!inputs))])
-                                           (All [(~+ class_parameters)]
+                                           (All ((~ g!_) (~+ class_parameters))
                                              (-> [(~+ (list\each nullable_type inputsT))]
                                                  (~ declaration)))
                                            (:expected
@@ -288,7 +288,7 @@
                                                             ("js constant" (~ (code.text (%.format real_class "." field))))))))))
                                       (` (def: ((~ (qualify field))
                                                 (~ g!object))
-                                           (All [(~+ class_parameters)]
+                                           (All ((~ g!_) (~+ class_parameters))
                                              (-> (~ declaration)
                                                  (~ (nullable_type fieldT))))
                                            (:expected
@@ -310,7 +310,7 @@
                                         (` (def: ((~ (qualify (maybe.else method alias)))
                                                   [(~+ (list\each product.right g!inputs))]
                                                   (~ g!object))
-                                             (All [(~+ class_parameters)]
+                                             (All ((~ g!_) (~+ class_parameters))
                                                (-> [(~+ (list\each nullable_type inputsT))]
                                                    (~ declaration)
                                                    (~ (|> (nullable_type outputT)
diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux
index 363effd18..d01286a1a 100644
--- a/stdlib/source/library/lux/ffi.jvm.lux
+++ b/stdlib/source/library/lux/ffi.jvm.lux
@@ -45,12 +45,12 @@
        name.read))
 
 (def: signature
-  (All [category]
+  (All (_ category)
     (-> (Type category) Text))
   (|>> type.signature signature.signature))
 
 (def: reflection
-  (All [category]
+  (All (_ category)
     (-> (Type (<| Return' Value' category)) Text))
   (|>> type.reflection reflection.reflection))
 
@@ -561,7 +561,7 @@
    ["Type Variables" (exception.listing parser.name type_vars)]))
 
 (def: (assertion exception payload test)
-  (All [e] (-> (Exception e) e Bit (Parser Any)))
+  (All (_ e) (-> (Exception e) e Bit (Parser Any)))
   (<>.assertion (exception.error exception payload)
                 test))
 
@@ -634,7 +634,7 @@
            )))))
 
 (def: (itself^ type)
-  (All [category]
+  (All (_ category)
     (-> (Type (<| Return' Value' category))
         (Parser (Type (<| Return' Value' category)))))
   (do <>.monad
@@ -1319,12 +1319,13 @@
   (let [[full_name params] (parser.declaration declaration)
         def_name (..internal full_name)
         params' (list\each ..var$' params)]
-    (` (def: (~ (code.identifier ["" def_name]))
-         {#..jvm_class (~ (code.text (..internal full_name)))}
-         .Type
-         (All [(~+ params')]
-           (primitive (~ (code.text full_name))
-                      [(~+ params')]))))))
+    (template.with_locals [g!_]
+      (` (def: (~ (code.identifier ["" def_name]))
+           {#..jvm_class (~ (code.text (..internal full_name)))}
+           .Type
+           (All ((~ (' g!_)) (~+ params'))
+             (primitive (~ (code.text full_name))
+                        [(~+ params')])))))))
 
 (def: (member_type_vars class_tvars member)
   (-> (List (Type Var)) Import_Member_Declaration (List (Type Var)))
@@ -1506,22 +1507,23 @@
   (let [[full_name class_tvars] (parser.declaration class)]
     (case member
       (#EnumDecl enum_members)
-      (do meta.monad
-        [.let [enum_type (: Code
-                            (case class_tvars
-                              #.End
-                              (` (primitive (~ (code.text full_name))))
-
-                              _
-                              (let [=class_tvars (list\each ..var$' class_tvars)]
-                                (` (All [(~+ =class_tvars)] (primitive (~ (code.text full_name)) [(~+ =class_tvars)]))))))
-               getter_interop (: (-> Text Code)
-                                 (function (_ name)
-                                   (let [getter_name (code.identifier ["" (..import_name import_format method_prefix name)])]
-                                     (` (def: (~ getter_name)
-                                          (~ enum_type)
-                                          (~ (get_static_field full_name name)))))))]]
-        (in (list\each getter_interop enum_members)))
+      (with_identifiers [g!_]
+        (do meta.monad
+          [.let [enum_type (: Code
+                              (case class_tvars
+                                #.End
+                                (` (primitive (~ (code.text full_name))))
+
+                                _
+                                (let [=class_tvars (list\each ..var$' class_tvars)]
+                                  (` (All ((~ g!_) (~+ =class_tvars)) (primitive (~ (code.text full_name)) [(~+ =class_tvars)]))))))
+                 getter_interop (: (-> Text Code)
+                                   (function (_ name)
+                                     (let [getter_name (code.identifier ["" (..import_name import_format method_prefix name)])]
+                                       (` (def: (~ getter_name)
+                                            (~ enum_type)
+                                            (~ (get_static_field full_name name)))))))]]
+          (in (list\each getter_interop enum_members))))
       
       (#ConstructorDecl [commons _])
       (do meta.monad
@@ -1652,7 +1654,7 @@
       (member_def_interop vars kind class =args member method_prefix import_format))))
 
 (def: interface?
-  (All [a] (-> (primitive "java.lang.Class" [a]) Bit))
+  (All (_ a) (-> (primitive "java.lang.Class" [a]) Bit))
   (|>> ("jvm member invoke virtual" [] "java.lang.Class" "isInterface" [])
        "jvm object cast"
        (: ..Boolean)
diff --git a/stdlib/source/library/lux/ffi.old.lux b/stdlib/source/library/lux/ffi.old.lux
index 8e8c03e53..016bce2b5 100644
--- a/stdlib/source/library/lux/ffi.old.lux
+++ b/stdlib/source/library/lux/ffi.old.lux
@@ -20,17 +20,15 @@
      [collection
       ["." array (#+ Array)]
       ["." list ("#\." monad mix monoid)]]]
-    [macro (#+ with_identifiers)
+    ["." macro (#+ with_identifiers)
      [syntax (#+ syntax:)]
-     ["." code]]
+     ["." code]
+     ["." template]]
     ["." meta
      ["." annotation]]]])
 
 (template [   ]
   [(def: .public ( value)
-     {#.doc (example "Type converter."
-                     (: 
-                        ( (:  foo))))}
      (-> (primitive ) (primitive ))
      ( value))]
 
@@ -1203,36 +1201,6 @@
                           annotations ..annotations^
                           fields (<>.some (..field_decl^ class_vars))
                           methods (<>.some (..method_def^ class_vars))])
-  {#.doc (example "Allows defining JVM classes in Lux code."
-                  "For example:"
-                  (class: #final (TestClass A) [Runnable]
-                    ... Fields
-                    (#private foo boolean)
-                    (#private bar A)
-                    (#private baz java/lang/Object)
-                    ... Methods
-                    (#public [] (new [value A]) []
-                             (exec (:= ::foo #1)
-                               (:= ::bar value)
-                               (:= ::baz "")
-                               []))
-                    (#public (virtual) java/lang/Object
-                             "")
-                    (#public #static (static) java/lang/Object
-                             "")
-                    (Runnable [] (run) void
-                              [])
-                    )
-
-                  "The tuple corresponds to parent interfaces."
-                  "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed."
-                  "Fields and methods defined in the class can be used with special syntax."
-                  "For example:"
-                  "::resolved, for accessing the 'resolved' field."
-                  "(:= ::resolved #1) for modifying it."
-                  "(::new! []) for calling the class's constructor."
-                  "(::resolve! container [value]) for calling the 'resolve' method."
-                  )}
   (do meta.monad
     [current_module meta.current_module_name
      .let [fully_qualified_class_name (format (safe current_module) "." full_class_name)
@@ -1257,16 +1225,12 @@
                                               (.tuple (<>.some (..super_class_decl^ class_vars))))
                               annotations ..annotations^
                               members (<>.some (..method_decl^ class_vars))])
-  {#.doc (example "Allows defining JVM interfaces."
-                  (interface: TestInterface
-                    ([] foo [boolean String] void #throws [Exception])))}
   (let [def_code (format "jvm interface:"
                          (spaced (list (class_decl$ class_decl)
                                        (with_brackets (spaced (list\each super_class_decl$ supers)))
                                        (with_brackets (spaced (list\each annotation$ annotations)))
                                        (spaced (list\each method_decl$ members)))))]
-    (in (list (` ((~ (code.text def_code))))))
-    ))
+    (in (list (` ((~ (code.text def_code))))))))
 
 (syntax: .public (object [class_vars (.tuple (<>.some ..type_param^))
                           super (<>.else object_super_class
@@ -1275,17 +1239,6 @@
                                               (.tuple (<>.some (..super_class_decl^ class_vars))))
                           constructor_args (..constructor_args^ class_vars)
                           methods (<>.some ..overriden_method_def^)])
-  {#.doc (example "Allows defining anonymous classes."
-                  "The 1st tuple corresponds to class-level type-variables."
-                  "The 2nd tuple corresponds to parent interfaces."
-                  "The 3rd tuple corresponds to arguments to the super class constructor."
-                  "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed."
-                  (object [] [Runnable]
-                    []
-                    (Runnable [] (run self) void
-                              (exec (do_something some_value)
-                                [])))
-                  )}
   (let [def_code (format "jvm anon-class:"
                          (spaced (list (super_class_decl$ super)
                                        (with_brackets (spaced (list\each super_class_decl$ interfaces)))
@@ -1294,25 +1247,13 @@
     (in (list (` ((~ (code.text def_code))))))))
 
 (syntax: .public (null [])
-  {#.doc (example "Null object reference."
-                  (null))}
   (in (list (` ("jvm object null")))))
 
 (def: .public (null? obj)
-  {#.doc (example "Test for null object reference."
-                  (= (null? (null))
-                     true)
-                  (= (null? "YOLO")
-                     false))}
   (-> (primitive "java.lang.Object") Bit)
   ("jvm object null?" obj))
 
 (syntax: .public (??? [expr .any])
-  {#.doc (example "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it."
-                  (= (??? (: java/lang/String (null)))
-                     #.None)
-                  (= (??? "YOLO")
-                     (#.Some "YOLO")))}
   (with_identifiers [g!temp]
     (in (list (` (let [(~ g!temp) (~ expr)]
                    (if ("jvm object null?" (~ g!temp))
@@ -1320,12 +1261,6 @@
                      (#.Some (~ g!temp)))))))))
 
 (syntax: .public (!!! [expr .any])
-  {#.doc (example "Takes a (Maybe ObjectType) and returns a ObjectType."
-                  "A #.None would get translated into a (null)."
-                  (= (null)
-                     (!!! (??? (: java/lang/Thread (null)))))
-                  (= "foo"
-                     (!!! (??? "foo"))))}
   (with_identifiers [g!value]
     (in (list (` ({(#.Some (~ g!value))
                    (~ g!value)
@@ -1336,11 +1271,6 @@
 
 (syntax: .public (check [class (..generic_type^ (list))
                          unchecked (<>.maybe .any)])
-  {#.doc (example "Checks whether an object is an instance of a particular class."
-                  "Caveat emptor: Cannot check for polymorphism, so avoid using parameterized classes."
-                  (case (check java/lang/String "YOLO")
-                    (#.Some value_as_string)
-                    #.None))}
   (with_identifiers [g!_ g!unchecked]
     (let [class_name (simple_class$ (list) class)
           class_type (` (.primitive (~ (code.text class_name))))
@@ -1363,19 +1293,10 @@
 
 (syntax: .public (synchronized [lock .any
                                 body .any])
-  {#.doc (example "Evaluates body, while holding a lock on a given object."
-                  (synchronized object_to_be_locked
-                    (exec (do_something ___)
-                      (do_something_else ___)
-                      (finish_the_computation ___))))}
   (in (list (` ("jvm object synchronized" (~ lock) (~ body))))))
 
 (syntax: .public (do_to [obj .any
                          methods (<>.some partial_call^)])
-  {#.doc (example "Call a variety of methods on an object. Then, return the object."
-                  (do_to object
-                    (ClassName::method1 arg0 arg1 arg2)
-                    (ClassName::method2 arg3 arg4 arg5)))}
   (with_identifiers [g!obj]
     (in (list (` (let [(~ g!obj) (~ obj)]
                    (exec (~+ (list\each (complete_call$ g!obj) methods))
@@ -1384,12 +1305,13 @@
 (def: (class_import$ [full_name params])
   (-> Class_Declaration Code)
   (let [params' (list\each (|>> product.left code.local_identifier) params)]
-    (` (def: (~ (code.identifier ["" full_name]))
-         {#..jvm_class (~ (code.text full_name))}
-         Type
-         (All [(~+ params')]
-           (primitive (~ (code.text (safe full_name)))
-                      [(~+ params')]))))))
+    (template.with_locals [g!_]
+      (` (def: (~ (code.identifier ["" full_name]))
+           {#..jvm_class (~ (code.text full_name))}
+           Type
+           (All ((~ (' g!_)) (~+ params'))
+             (primitive (~ (code.text (safe full_name)))
+                        [(~+ params')])))))))
 
 (def: (member_type_vars class_tvars member)
   (-> (List Type_Parameter) Import_Member_Declaration (List Type_Parameter))
@@ -1533,24 +1455,25 @@
                        (list\each lux_type_parameter))]
     (case member
       (#EnumDecl enum_members)
-      (do {! meta.monad}
-        [.let [enum_type (: Code
-                            (case class_tvars
-                              #.End
-                              (` (primitive (~ (code.text full_name))))
-
-                              _
-                              (let [=class_tvars (|> class_tvars
-                                                     (list.only free_type_param?)
-                                                     (list\each lux_type_parameter))]
-                                (` (All [(~+ =class_tvars)] (primitive (~ (code.text full_name)) [(~+ =class_tvars)]))))))
-               getter_interop (: (-> Text Code)
-                                 (function (_ name)
-                                   (let [getter_name (code.identifier ["" (..import_name import_format method_prefix name)])]
-                                     (` (def: (~ getter_name)
-                                          (~ enum_type)
-                                          ((~ (code.text (format "jvm getstatic" ":" full_name ":" name)))))))))]]
-        (in (list\each getter_interop enum_members)))
+      (macro.with_identifiers [g!_]
+        (do {! meta.monad}
+          [.let [enum_type (: Code
+                              (case class_tvars
+                                #.End
+                                (` (primitive (~ (code.text full_name))))
+
+                                _
+                                (let [=class_tvars (|> class_tvars
+                                                       (list.only free_type_param?)
+                                                       (list\each lux_type_parameter))]
+                                  (` (All ((~ g!_) (~+ =class_tvars)) (primitive (~ (code.text full_name)) [(~+ =class_tvars)]))))))
+                 getter_interop (: (-> Text Code)
+                                   (function (_ name)
+                                     (let [getter_name (code.identifier ["" (..import_name import_format method_prefix name)])]
+                                       (` (def: (~ getter_name)
+                                            (~ enum_type)
+                                            ((~ (code.text (format "jvm getstatic" ":" full_name ":" name)))))))))]]
+          (in (list\each getter_interop enum_members))))
       
       (#ConstructorDecl [commons _])
       (do meta.monad
@@ -1666,7 +1589,7 @@
   (primitive "java.lang.Class" [a]))
 
 (def: interface?
-  (All [a] (-> (java/lang/Class a) Bit))
+  (All (_ a) (-> (java/lang/Class a) Bit))
   (|>> "jvm invokevirtual:java.lang.Class:isInterface:"))
 
 (def: (load_class class_name)
@@ -1688,57 +1611,6 @@
 
 (syntax: .public (import: [class_decl ..class_decl^
                            bundles (<>.some (..bundle (product.right class_decl)))])
-  {#.doc (example "Allows importing JVM classes, and using them as types."
-                  "Their methods, fields and enum options can also be imported."
-                  (import: java/lang/Object
-                    ["#::."
-                     (new [])
-                     (equals [java/lang/Object] boolean)
-                     (wait [int] #io #try void)])
-                  
-                  "Special options can also be given for the return values."
-                  "#? means that the values will be returned inside a Maybe type. That way, null becomes #.None."
-                  "#try means that the computation might throw an exception, and the return value will be wrapped by the Try type."
-                  "#io means the computation has side effects, and will be wrapped by the IO type."
-                  "These options must show up in the following order [#io #try #?] (although, each option can be used independently)."
-                  (import: java/lang/String
-                    ["#::."
-                     (new [[byte]])
-                     (#static valueOf [char] java/lang/String)
-                     (#static valueOf #as int_valueOf [int] java/lang/String)])
-
-                  (import: (java/util/List e)
-                    ["#::."
-                     (size [] int)
-                     (get [int] e)])
-
-                  (import: (java/util/ArrayList a)
-                    ["#::."
-                     ([T] toArray [[T]] [T])])
-                  
-                  "The class-type that is generated is of the fully-qualified name."
-                  "This avoids a clash between the java.util.List type, and Lux's own List type."
-                  "All enum options to be imported must be specified."
-                  (import: java/lang/Character$UnicodeScript
-                    ["#::."
-                     (#enum ARABIC CYRILLIC LATIN)])
-
-                  "It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-parameters."
-                  "Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes)."
-                  (import: (lux/concurrency/async/JvmAsync A)
-                    ["#::."
-                     (resolve [A] boolean)
-                     (poll [] A)
-                     (wasResolved [] boolean)
-                     (waitOn [lux/Function] void)
-                     (#static [A] make [A] (lux/concurrency/async/JvmAsync A))])
-                  
-                  "Also, the names of the imported members will look like Class::member"
-                  (java/lang/Object::new [])
-                  (java/lang/Object::equals [other_object] my_object)
-                  (java/util/List::size [] my_list)
-                  java/lang/Character$UnicodeScript::LATIN
-                  )}
   (do {! meta.monad}
     [kind (class_kind class_decl)
      =members (|> bundles
@@ -1750,8 +1622,6 @@
 
 (syntax: .public (array [type (..generic_type^ (list))
                          size .any])
-  {#.doc (example "Create an array of the given type, with the given size."
-                  (array java/lang/Object 10))}
   (case type
     (^template [ ]
       [(^ (#GenericClass  (list)))
@@ -1769,8 +1639,6 @@
     (in (list (` ("jvm anewarray" (~ (code.text (generic_type$ type))) (~ size)))))))
 
 (syntax: .public (length [array .any])
-  {#.doc (example "Gives the length of an array."
-                  (length my_array))}
   (in (list (` ("jvm arraylength" (~ array))))))
 
 (def: (type_class_name type)
@@ -1797,8 +1665,6 @@
 
 (syntax: .public (read! [idx .any
                          array .any])
-  {#.doc (example "Loads an element from an array."
-                  (read! 10 my_array))}
   (case array
     [_ (#.Identifier array_name)]
     (do meta.monad
@@ -1828,8 +1694,6 @@
 (syntax: .public (write! [idx .any
                           value .any
                           array .any])
-  {#.doc (example "Stores an element into an array."
-                  (write! 10 my_object my_array))}
   (case array
     [_ (#.Identifier array_name)]
     (do meta.monad
@@ -1857,8 +1721,6 @@
                      (..write! (~ idx) (~ value) (~ g!array)))))))))
 
 (syntax: .public (class_for [type (..generic_type^ (list))])
-  {#.doc (example "Loads the class as a java.lang.Class object."
-                  (class_for java/lang/String))}
   (in (list (` ("jvm object class" (~ (code.text (simple_class$ (list) type))))))))
 
 (syntax: .public (type [type (..generic_type^ (list))])
diff --git a/stdlib/source/library/lux/ffi.rb.lux b/stdlib/source/library/lux/ffi.rb.lux
index 060b3dfea..3c1da5d57 100644
--- a/stdlib/source/library/lux/ffi.rb.lux
+++ b/stdlib/source/library/lux/ffi.rb.lux
@@ -232,25 +232,6 @@
                      (~+ (list\each (with_nil g!temp) g!inputs)))))))))))
 
 (syntax: .public (import: [[?module import] ..import])
-  {#.doc (example "Easily import types, methods, functions and constants."
-                  (import: Stat
-                    ["#::."
-                     (executable? [] Bit)
-                     (size Int)])
-
-                  (import: File #as RubyFile
-                    ["#::."
-                     (#static SEPARATOR ..String)
-                     (#static open [Path ..String] #io #try RubyFile)
-                     (#static stat [Path] #io #try Stat)
-                     (#static delete [Path] #io #try Int)
-                     (#static file? [Path] #io #try Bit)
-                     (#static directory? [Path] #io #try Bit)
-
-                     (read [] #io #try Binary)
-                     (write [Binary] #io #try Int)
-                     (flush [] #io #try #? Any)
-                     (close [] #io #try #? Any)]))}
   (with_identifiers [g!temp]
     (case import
       (#Class [class alias format members])
diff --git a/stdlib/source/library/lux/macro/local.lux b/stdlib/source/library/lux/macro/local.lux
index 68e22410e..edf8ca784 100644
--- a/stdlib/source/library/lux/macro/local.lux
+++ b/stdlib/source/library/lux/macro/local.lux
@@ -32,7 +32,7 @@
   )
 
 (def: (with_module name body)
-  (All [a] (-> Text (-> Module (Try [Module a])) (Meta a)))
+  (All (_ a) (-> Text (-> Module (Try [Module a])) (Meta a)))
   (function (_ compiler)
     (case (|> compiler (value@ #.modules) (plist.value name))
       (#.Some module)
diff --git a/stdlib/source/library/lux/macro/syntax.lux b/stdlib/source/library/lux/macro/syntax.lux
index c77d67feb..106048f90 100644
--- a/stdlib/source/library/lux/macro/syntax.lux
+++ b/stdlib/source/library/lux/macro/syntax.lux
@@ -24,7 +24,7 @@
    ["." code]])
 
 (def: (self_documenting binding parser)
-  (All [a] (-> Code (Parser a) (Parser a)))
+  (All (_ a) (-> Code (Parser a) (Parser a)))
   (function (_ tokens)
     (case (parser tokens)
       (#try.Success [tokens output])
@@ -36,7 +36,7 @@
                         error)))))
 
 (def: (un_paired pairs)
-  (All [a] (-> (List [a a]) (List a)))
+  (All (_ a) (-> (List [a a]) (List a)))
   (case pairs
     #.End                   #.End
     (#.Item [[x y] pairs']) (list& x y (un_paired pairs'))))
diff --git a/stdlib/source/library/lux/macro/syntax/export.lux b/stdlib/source/library/lux/macro/syntax/export.lux
index e4cb2ddac..445e8ae23 100644
--- a/stdlib/source/library/lux/macro/syntax/export.lux
+++ b/stdlib/source/library/lux/macro/syntax/export.lux
@@ -10,6 +10,6 @@
   (` .private))
 
 (def: .public (parser un_exported)
-  (All [a] (-> (Parser a) (Parser [Code a])))
+  (All (_ a) (-> (Parser a) (Parser [Code a])))
   (<>.either (<>.and .any un_exported)
              (<>.and (<>\in ..default_policy) un_exported)))
diff --git a/stdlib/source/library/lux/math/logic/fuzzy.lux b/stdlib/source/library/lux/math/logic/fuzzy.lux
index 4c3745470..36277f723 100644
--- a/stdlib/source/library/lux/math/logic/fuzzy.lux
+++ b/stdlib/source/library/lux/math/logic/fuzzy.lux
@@ -36,12 +36,12 @@
   )
 
 (def: .public (membership set elem)
-  (All [a] (-> (Fuzzy a) a Rev))
+  (All (_ a) (-> (Fuzzy a) a Rev))
   (set elem))
 
 (template [ ]
   [(def: .public ( left right)
-     (All [a] (-> (Fuzzy a) (Fuzzy a) (Fuzzy a)))
+     (All (_ a) (-> (Fuzzy a) (Fuzzy a) (Fuzzy a)))
      (function (_ elem)
        ( (left elem)
                                  (right elem))))]
@@ -51,27 +51,27 @@
   )
 
 (def: .public (complement set)
-  (All [a] (-> (Fuzzy a) (Fuzzy a)))
+  (All (_ a) (-> (Fuzzy a) (Fuzzy a)))
   (|>> set //.not))
 
 (def: .public (difference sub base)
-  (All [a] (-> (Fuzzy a) (Fuzzy a) (Fuzzy a)))
+  (All (_ a) (-> (Fuzzy a) (Fuzzy a) (Fuzzy a)))
   (..intersection (..complement sub) base))
 
 (def: .public (of_predicate predicate)
-  (All [a] (-> (Predicate a) (Fuzzy a)))
+  (All (_ a) (-> (Predicate a) (Fuzzy a)))
   (function (_ elem)
     (if (predicate elem)
       //.true
       //.false)))
 
 (def: .public (predicate treshold set)
-  (All [a] (-> Rev (Fuzzy a) (Predicate a)))
+  (All (_ a) (-> Rev (Fuzzy a) (Predicate a)))
   (function (_ elem)
     (/.> treshold (set elem))))
 
 (def: .public of_set
-  (All [a] (-> (Set a) (Fuzzy a)))
+  (All (_ a) (-> (Set a) (Fuzzy a)))
   (|>> set.member? ..of_predicate))
 
 (def: (ascending from to)
@@ -125,7 +125,7 @@
                     (..descending middle_top' top'))))
 
 (def: .public (cut treshold set)
-  (All [a] (-> Rev (Fuzzy a) (Fuzzy a)))
+  (All (_ a) (-> Rev (Fuzzy a) (Fuzzy a)))
   (function (_ elem)
     (let [membership (set elem)]
       (if (/.< treshold membership)
diff --git a/stdlib/source/library/lux/math/modular.lux b/stdlib/source/library/lux/math/modular.lux
index acfdbab2d..5b462ccfd 100644
--- a/stdlib/source/library/lux/math/modular.lux
+++ b/stdlib/source/library/lux/math/modular.lux
@@ -35,13 +35,13 @@
     #value Int})
 
   (def: .public (modular modulus value)
-    (All [%] (-> (Modulus %) Int (Mod %)))
+    (All (_ %) (-> (Modulus %) Int (Mod %)))
     (:abstraction {#modulus modulus
                    #value (i.mod (//.divisor modulus) value)}))
 
   (template [  ]
     [(def: .public 
-       (All [%] (-> (Mod %) ))
+       (All (_ %) (-> (Mod %) ))
        (|>> :representation ))]
 
     [modulus (Modulus %) product.left]
@@ -63,7 +63,7 @@
               (.and (.one_of "-+") (.many .decimal))))
 
   (implementation: .public (codec expected)
-    (All [%] (-> (Modulus %) (Codec Text (Mod %))))
+    (All (_ %) (-> (Modulus %) (Codec Text (Mod %))))
 
     (def: (encoded modular)
       (let [[_ value] (:representation modular)]
@@ -82,7 +82,7 @@
 
   (template [ ]
     [(def: .public ( reference subject)
-       (All [%] (-> (Mod %) (Mod %) Bit))
+       (All (_ %) (-> (Mod %) (Mod %) Bit))
        (let [[_ reference] (:representation reference)
              [_ subject] (:representation subject)]
          ( reference subject)))]
@@ -95,19 +95,19 @@
     )
 
   (implementation: .public equivalence
-    (All [%] (Equivalence (Mod %)))
+    (All (_ %) (Equivalence (Mod %)))
 
     (def: = ..=))
 
   (implementation: .public order
-    (All [%] (Order (Mod %)))
+    (All (_ %) (Order (Mod %)))
 
     (def: &equivalence ..equivalence)
     (def: < ..<))
 
   (template [ ]
     [(def: .public ( param subject)
-       (All [%] (-> (Mod %) (Mod %) (Mod %)))
+       (All (_ %) (-> (Mod %) (Mod %) (Mod %)))
        (let [[modulus param] (:representation param)
              [_ subject] (:representation subject)]
          (:abstraction {#modulus modulus
@@ -122,7 +122,7 @@
 
   (template [  ]
     [(implementation: .public ( modulus)
-       (All [%] (-> (Modulus %) (Monoid (Mod %))))
+       (All (_ %) (-> (Modulus %) (Monoid (Mod %))))
 
        (def: identity
          (..modular modulus ))
@@ -134,7 +134,7 @@
     )
   
   (def: .public (inverse modular)
-    (All [%] (-> (Mod %) (Maybe (Mod %))))
+    (All (_ %) (-> (Mod %) (Maybe (Mod %))))
     (let [[modulus value] (:representation modular)
           [[vk mk] gcd] (i.extended_gcd value (//.divisor modulus))]
       (case gcd
@@ -149,7 +149,7 @@
    ["Subject" (i\encoded (//.divisor subject))]))
 
 (def: .public (adapter reference subject)
-  (All [r% s%]
+  (All (_ r% s%)
     (-> (Modulus r%) (Modulus s%)
         (Try (-> (Mod s%) (Mod r%)))))
   (if (//.= reference subject)
diff --git a/stdlib/source/library/lux/math/modulus.lux b/stdlib/source/library/lux/math/modulus.lux
index f52210e24..6ca5a9033 100644
--- a/stdlib/source/library/lux/math/modulus.lux
+++ b/stdlib/source/library/lux/math/modulus.lux
@@ -26,22 +26,22 @@
   Int
 
   (def: .public (modulus value)
-    (Ex [%] (-> Int (Try (Modulus %))))
+    (Ex (_ %) (-> Int (Try (Modulus %))))
     (if (i.= +0 value)
       (exception.except ..zero_cannot_be_a_modulus [])
       (#try.Success (:abstraction value))))
 
   (def: .public divisor
-    (All [%] (-> (Modulus %) Int))
+    (All (_ %) (-> (Modulus %) Int))
     (|>> :representation))
 
   (def: .public (= reference subject)
-    (All [%r %s] (-> (Modulus %r) (Modulus %s) Bit))
+    (All (_ %r %s) (-> (Modulus %r) (Modulus %s) Bit))
     (i.= (:representation reference)
          (:representation subject)))
 
   (def: .public (congruent? modulus reference subject)
-    (All [%] (-> (Modulus %) Int Int Bit))
+    (All (_ %) (-> (Modulus %) Int Int Bit))
     (|> subject
         (i.- reference)
         (i.% (:representation modulus))
diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux
index 7c4f1d8b1..4f510366c 100644
--- a/stdlib/source/library/lux/math/number/frac.lux
+++ b/stdlib/source/library/lux/math/number/frac.lux
@@ -431,7 +431,7 @@
       (..< margin_of_error)))
 
 (def: .public (mod divisor dividend)
-  (All [m] (-> Frac Frac Frac))
+  (All (_ m) (-> Frac Frac Frac))
   (let [remainder (..% divisor dividend)]
     (if (or (and (..< +0.0 divisor)
                  (..> +0.0 remainder))
diff --git a/stdlib/source/library/lux/math/number/i64.lux b/stdlib/source/library/lux/math/number/i64.lux
index ecad8a4ec..475ad82d6 100644
--- a/stdlib/source/library/lux/math/number/i64.lux
+++ b/stdlib/source/library/lux/math/number/i64.lux
@@ -23,7 +23,7 @@
 
 (template [  ]
   [(def: .public ( parameter subject)
-     (All [s] (->  (I64 s) (I64 s)))
+     (All (_ s) (->  (I64 s) (I64 s)))
      ( parameter subject))]
 
   [(I64 Any) or          "lux i64 or"]
@@ -47,7 +47,7 @@
   (..bit (-- ..width)))
 
 (def: .public not
-  (All [s] (-> (I64 s) (I64 s)))
+  (All (_ s) (-> (I64 s) (I64 s)))
   (..xor (.i64 (-- 0))))
 
 (def: .public false
@@ -83,12 +83,12 @@
         (..and 127))))
 
 (def: .public (zero index input)
-  (All [s] (-> Nat (I64 s) (I64 s)))
+  (All (_ s) (-> Nat (I64 s) (I64 s)))
   (|> index ..bit ..not (..and input)))
 
 (template [ ]
   [(def: .public ( index input)
-     (All [s] (-> Nat (I64 s) (I64 s)))
+     (All (_ s) (-> Nat (I64 s) (I64 s)))
      (|> index ..bit ( input)))]
 
   [one     ..or]
@@ -105,7 +105,7 @@
 
 (template [  ]
   [(def: .public ( distance input)
-     (All [s] (-> Nat (I64 s) (I64 s)))
+     (All (_ s) (-> Nat (I64 s) (I64 s)))
      (..or ( distance input)
            ( (n.- (n.% ..width distance) ..width) input)))]
 
@@ -118,13 +118,13 @@
   (..left_rotated offset (..mask size)))
 
 (implementation: .public equivalence
-  (All [a] (Equivalence (I64 a)))
+  (All (_ a) (Equivalence (I64 a)))
 
   (def: (= reference sample)
     ("lux i64 =" reference sample)))
 
 (implementation: .public hash
-  (All [a] (Hash (I64 a)))
+  (All (_ a) (Hash (I64 a)))
 
   (def: &equivalence ..equivalence)
 
@@ -132,7 +132,7 @@
 
 (template [  ]
   [(implementation: .public 
-     (All [a] (Monoid (I64 a)))
+     (All (_ a) (Monoid (I64 a)))
 
      (def: identity )
      (def: composite ))]
@@ -142,8 +142,8 @@
   )
 
 (def: .public reversed
-  (All [a] (-> (I64 a) (I64 a)))
-  (let [swapper (: (-> Nat (All [a] (-> (I64 a) (I64 a))))
+  (All (_ a) (-> (I64 a) (I64 a)))
+  (let [swapper (: (-> Nat (All (_ a) (-> (I64 a) (I64 a))))
                    (function (_ power)
                      (let [size (..left_shifted power 1)
                            repetitions (: (-> Nat Text Text)
@@ -190,7 +190,7 @@
       wide)))
 
 (def: .public (sub width)
-  (Ex [size] (-> Nat (Maybe (Sub size))))
+  (Ex (_ size) (-> Nat (Maybe (Sub size))))
   (if (.and (n.> 0 width)
             (n.< ..width width))
     (let [sign_shift (n.- width ..width)
diff --git a/stdlib/source/library/lux/math/number/int.lux b/stdlib/source/library/lux/math/number/int.lux
index 91eaa9de4..02430432b 100644
--- a/stdlib/source/library/lux/math/number/int.lux
+++ b/stdlib/source/library/lux/math/number/int.lux
@@ -100,7 +100,7 @@
 
 ... https://rob.conery.io/2018/08/21/mod-and-remainder-are-not-the-same/
 (def: .public (mod divisor dividend)
-  (All [m] (-> Int Int Int))
+  (All (_ m) (-> Int Int Int))
   (let [remainder (..% divisor dividend)]
     (if (or (and (..< +0 divisor)
                  (..> +0 remainder))
diff --git a/stdlib/source/library/lux/math/random.lux b/stdlib/source/library/lux/math/random.lux
index b416d2c8a..8803ab037 100644
--- a/stdlib/source/library/lux/math/random.lux
+++ b/stdlib/source/library/lux/math/random.lux
@@ -78,7 +78,7 @@
         (fa state')))))
 
 (def: .public (only pred gen)
-  (All [a] (-> (-> a Bit) (Random a) (Random a)))
+  (All (_ a) (-> (-> a Bit) (Random a) (Random a)))
   (do ..monad
     [sample gen]
     (if (pred sample)
@@ -86,7 +86,7 @@
       (only pred gen))))
 
 (def: .public (one check random)
-  (All [a b]
+  (All (_ a b)
     (-> (-> a (Maybe b)) (Random a) (Random b)))
   (do ..monad
     [sample random]
@@ -98,7 +98,7 @@
       (one check random))))
 
 (def: .public (refined refiner gen)
-  (All [t r] (-> (Refiner t r) (Random t) (Random (Refined t r))))
+  (All (_ t r) (-> (Refiner t r) (Random t) (Random (Refined t r))))
   (do ..monad
     [sample gen]
     (case (refiner sample)
@@ -194,14 +194,14 @@
   )
 
 (def: .public (and left right)
-  (All [a b] (-> (Random a) (Random b) (Random [a b])))
+  (All (_ a b) (-> (Random a) (Random b) (Random [a b])))
   (do ..monad
     [=left left
      =right right]
     (in [=left =right])))
 
 (def: .public (or left right)
-  (All [a b] (-> (Random a) (Random b) (Random (Or a b))))
+  (All (_ a b) (-> (Random a) (Random b) (Random (Or a b))))
   (do {! ..monad}
     [? bit]
     (if ?
@@ -213,7 +213,7 @@
         (in (0 #1 =right))))))
 
 (def: .public (either left right)
-  (All [a] (-> (Random a) (Random a) (Random a)))
+  (All (_ a) (-> (Random a) (Random a) (Random a)))
   (do ..monad
     [? bit]
     (if ?
@@ -221,13 +221,13 @@
       right)))
 
 (def: .public (rec gen)
-  (All [a] (-> (-> (Random a) (Random a)) (Random a)))
+  (All (_ a) (-> (-> (Random a) (Random a)) (Random a)))
   (function (_ state)
     (let [gen' (gen (rec gen))]
       (gen' state))))
 
 (def: .public (maybe value_gen)
-  (All [a] (-> (Random a) (Random (Maybe a))))
+  (All (_ a) (-> (Random a) (Random (Maybe a))))
   (do {! ..monad}
     [some? bit]
     (if some?
@@ -238,7 +238,7 @@
 
 (template [   ]
   [(def: .public ( size value_gen)
-     (All [a] (-> Nat (Random a) (Random ( a))))
+     (All (_ a) (-> Nat (Random a) (Random ( a))))
      (if (n.> 0 size)
        (do ..monad
          [x value_gen
@@ -252,7 +252,7 @@
 
 (template [  ]
   [(def: .public ( size value_gen)
-     (All [a] (-> Nat (Random a) (Random ( a))))
+     (All (_ a) (-> Nat (Random a) (Random ( a))))
      (do ..monad
        [values (list size value_gen)]
        (in (|> values ))))]
@@ -263,7 +263,7 @@
   )
 
 (def: .public (set hash size value_gen)
-  (All [a] (-> (Hash a) Nat (Random a) (Random (Set a))))
+  (All (_ a) (-> (Hash a) Nat (Random a) (Random (Set a))))
   (if (n.> 0 size)
     (do {! ..monad}
       [xs (set hash (-- size) value_gen)]
@@ -277,7 +277,7 @@
     (\ ..monad in (set.empty hash))))
 
 (def: .public (dictionary hash size key_gen value_gen)
-  (All [k v] (-> (Hash k) Nat (Random k) (Random v) (Random (Dictionary k v))))
+  (All (_ k v) (-> (Hash k) Nat (Random k) (Random v) (Random (Dictionary k v))))
   (if (n.> 0 size)
     (do {! ..monad}
       [kv (dictionary hash (-- size) key_gen value_gen)]
@@ -335,11 +335,11 @@
                                   (\in #day.Saturday))))))
 
 (def: .public (result prng calc)
-  (All [a] (-> PRNG (Random a) [PRNG a]))
+  (All (_ a) (-> PRNG (Random a) [PRNG a]))
   (calc prng))
 
 (def: .public (prng update return)
-  (All [a] (-> (-> a a) (-> a I64) (-> a PRNG)))
+  (All (_ a) (-> (-> a a) (-> a I64) (-> a PRNG)))
   (function (recur state)
     (function (_ _)
       [(recur (update state))
diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux
index c51425fcc..208663367 100644
--- a/stdlib/source/library/lux/meta.lux
+++ b/stdlib/source/library/lux/meta.lux
@@ -78,11 +78,11 @@
         (ma lux')))))
 
 (def: .public (result' lux action)
-  (All [a] (-> Lux (Meta a) (Try [Lux a])))
+  (All (_ a) (-> Lux (Meta a) (Try [Lux a])))
   (action lux))
 
 (def: .public (result lux action)
-  (All [a] (-> Lux (Meta a) (Try a)))
+  (All (_ a) (-> Lux (Meta a) (Try a)))
   (case (action lux)
     (#try.Failure error)
     (#try.Failure error)
@@ -91,7 +91,7 @@
     (#try.Success output)))
 
 (def: .public (either left right)
-  (All [a] (-> (Meta a) (Meta a) (Meta a)))
+  (All (_ a) (-> (Meta a) (Meta a) (Meta a)))
   (function (_ lux)
     (case (left lux)
       (#try.Failure error)
@@ -108,7 +108,7 @@
       (#try.Failure message))))
 
 (def: .public (failure error)
-  (All [a]
+  (All (_ a)
     (-> Text (Meta a)))
   (function (_ state)
     (#try.Failure (location.with (value@ #.location state) error))))
@@ -208,7 +208,7 @@
                          #0)])))
 
 (def: (on_either f x1 x2)
-  (All [a b]
+  (All (_ a b)
     (-> (-> a (Maybe b)) a a (Maybe b)))
   (case (f x1)
     #.None     (f x2)
@@ -553,7 +553,7 @@
     (#try.Success [lux (value@ #.type_context lux)])))
 
 (def: .public (lifted result)
-  (All [a] (-> (Try a) (Meta a)))
+  (All (_ a) (-> (Try a) (Meta a)))
   (case result
     (#try.Success output)
     (\ ..monad in output)
diff --git a/stdlib/source/library/lux/static.lux b/stdlib/source/library/lux/static.lux
index a332842ed..668a23331 100644
--- a/stdlib/source/library/lux/static.lux
+++ b/stdlib/source/library/lux/static.lux
@@ -31,7 +31,7 @@
   Nat
   (hex "FEDCBA9876543210"))
 
-(with_expansions [ (Ex [a]
+(with_expansions [ (Ex (_ a)
                            [(-> a Code)
                             a])]
   (syntax: .public (literal [format .any
@@ -56,7 +56,7 @@
   [random_frac random.frac code.frac]
   )
 
-(with_expansions [ (Ex [a]
+(with_expansions [ (Ex (_ a)
                            [(-> a Code)
                             (Random a)])]
   (syntax: .public (random [format .any
diff --git a/stdlib/source/library/lux/target/js.lux b/stdlib/source/library/lux/target/js.lux
index a2b83491d..07318b451 100644
--- a/stdlib/source/library/lux/target/js.lux
+++ b/stdlib/source/library/lux/target/js.lux
@@ -393,7 +393,7 @@
     )
 
   (def: .public (comment commentary on)
-    (All [kind] (-> Text (Code kind) (Code kind)))
+    (All (_ kind) (-> Text (Code kind) (Code kind)))
     (:abstraction (format "/* "  commentary " */" " " (:representation on))))
 
   (def: .public (switch input cases default)
diff --git a/stdlib/source/library/lux/target/jvm/attribute.lux b/stdlib/source/library/lux/target/jvm/attribute.lux
index 658b53a06..4d79cfb86 100644
--- a/stdlib/source/library/lux/target/jvm/attribute.lux
+++ b/stdlib/source/library/lux/target/jvm/attribute.lux
@@ -32,7 +32,7 @@
     #info about}))
 
 (def: .public (info_equivalence Equivalence)
-  (All [about]
+  (All (_ about)
     (-> (Equivalence about)
         (Equivalence (Info about))))
   ($_ product.equivalence
@@ -41,7 +41,7 @@
       Equivalence))
 
 (def: (info_writer writer)
-  (All [about]
+  (All (_ about)
     (-> (Writer about)
         (Writer (Info about))))
   (function (_ [name length info])
diff --git a/stdlib/source/library/lux/target/jvm/attribute/code.lux b/stdlib/source/library/lux/target/jvm/attribute/code.lux
index d63057a68..a36208054 100644
--- a/stdlib/source/library/lux/target/jvm/attribute/code.lux
+++ b/stdlib/source/library/lux/target/jvm/attribute/code.lux
@@ -30,7 +30,7 @@
     #attributes (Row Attribute)}))
 
 (def: .public (length length code)
-  (All [Attribute] (-> (-> Attribute Nat) (Code Attribute) Nat))
+  (All (_ Attribute) (-> (-> Attribute Nat) (Code Attribute) Nat))
   ($_ n.+
       ... u2 max_stack;
       ... u2 max_locals;
@@ -55,7 +55,7 @@
           (row\mix n.+ 0))))
 
 (def: .public (equivalence attribute_equivalence)
-  (All [attribute]
+  (All (_ attribute)
     (-> (Equivalence attribute) (Equivalence (Code attribute))))
   ($_ product.equivalence
       ///limit.equivalence
@@ -66,7 +66,7 @@
 
 ... https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3
 (def: .public (writer writer code)
-  (All [Attribute] (-> (Writer Attribute) (Writer (Code Attribute))))
+  (All (_ Attribute) (-> (Writer Attribute) (Writer (Code Attribute))))
   ($_ binaryF\composite
       ... u2 max_stack;
       ... u2 max_locals;
diff --git a/stdlib/source/library/lux/target/jvm/attribute/constant.lux b/stdlib/source/library/lux/target/jvm/attribute/constant.lux
index 8d7a0a26a..d9242dc89 100644
--- a/stdlib/source/library/lux/target/jvm/attribute/constant.lux
+++ b/stdlib/source/library/lux/target/jvm/attribute/constant.lux
@@ -16,12 +16,12 @@
   (Index (Value a)))
 
 (def: .public equivalence
-  (All [a] (Equivalence (Constant a)))
+  (All (_ a) (Equivalence (Constant a)))
   ///index.equivalence)
 
 (def: .public length
   ///index.length)
 
 (def: .public writer
-  (All [a] (Writer (Constant a)))
+  (All (_ a) (Writer (Constant a)))
   ///index.writer)
diff --git a/stdlib/source/library/lux/target/jvm/bytecode.lux b/stdlib/source/library/lux/target/jvm/bytecode.lux
index 1fe22ef1a..9c106e442 100644
--- a/stdlib/source/library/lux/target/jvm/bytecode.lux
+++ b/stdlib/source/library/lux/target/jvm/bytecode.lux
@@ -170,11 +170,11 @@
   (|>> #try.Failure function.constant))
 
 (def: .public (except exception value)
-  (All [e] (-> (exception.Exception e) e Bytecode))
+  (All (_ e) (-> (exception.Exception e) e Bytecode))
   (..failure (exception.error exception value)))
 
 (def: .public (resolve environment bytecode)
-  (All [a] (-> Environment (Bytecode a) (Resource [Environment (Row Exception) Instruction a])))
+  (All (_ a) (-> Environment (Bytecode a) (Resource [Environment (Row Exception) Instruction a])))
   (function (_ pool)
     (do try.monad
       [[[pool environment tracker] [relative output]] (bytecode [pool environment ..fresh])
@@ -186,7 +186,7 @@
   (/address.move (estimator counter) counter))
 
 (def: (bytecode consumption production registry [estimator bytecode] input)
-  (All [a] (-> U2 U2 Registry [Estimator (-> [a] Instruction)] [a] (Bytecode Any)))
+  (All (_ a) (-> U2 U2 Registry [Estimator (-> [a] Instruction)] [a] (Bytecode Any)))
   (function (_ [pool environment tracker])
     (do {! try.monad}
       [environment' (|> environment
@@ -440,7 +440,7 @@
   (..bytecode $0 $1 @_ _.bipush [byte]))
 
 (def: (lifted resource)
-  (All [a]
+  (All (_ a)
     (-> (Resource a)
         (Bytecode a)))
   (function (_ [pool environment tracker])
@@ -920,7 +920,7 @@
                 []]]))))))
 
 (def: reflection
-  (All [category]
+  (All (_ category)
     (-> (Type (<| Return' Value' category)) Text))
   (|>> type.reflection reflection.reflection))
 
@@ -1044,7 +1044,7 @@
          []]]))))
 
 (def: .public (composite pre post)
-  (All [pre post]
+  (All (_ pre post)
     (-> (Bytecode pre) (Bytecode post) (Bytecode post)))
   (do ..monad
     [_ pre]
diff --git a/stdlib/source/library/lux/target/jvm/constant.lux b/stdlib/source/library/lux/target/jvm/constant.lux
index c2756715e..0775af818 100644
--- a/stdlib/source/library/lux/target/jvm/constant.lux
+++ b/stdlib/source/library/lux/target/jvm/constant.lux
@@ -91,11 +91,11 @@
   kind
 
   (def: .public value
-    (All [kind] (-> (Value kind) kind))
+    (All (_ kind) (-> (Value kind) kind))
     (|>> :representation))
 
   (def: .public (value_equivalence Equivalence)
-    (All [kind]
+    (All (_ kind)
       (-> (Equivalence kind)
           (Equivalence (Value kind))))
     (\ equivalence.functor each
diff --git a/stdlib/source/library/lux/target/jvm/constant/pool.lux b/stdlib/source/library/lux/target/jvm/constant/pool.lux
index 50872e835..d71b3727e 100644
--- a/stdlib/source/library/lux/target/jvm/constant/pool.lux
+++ b/stdlib/source/library/lux/target/jvm/constant/pool.lux
@@ -114,7 +114,7 @@
     (!add #//.Class //.class_equivalence value)))
 
 (def: .public (descriptor value)
-  (All [kind]
+  (All (_ kind)
     (-> (Descriptor kind)
         (Resource (Index (Descriptor kind)))))
   (let [value (//descriptor.descriptor value)]
@@ -126,7 +126,7 @@
     #descriptor (Descriptor of)}))
 
 (def: .public (name_and_type [name descriptor])
-  (All [of]
+  (All (_ of)
     (-> (Member of) (Resource (Index (Name_And_Type of)))))
   (do ..monad
     [@name (utf8 name)
diff --git a/stdlib/source/library/lux/target/jvm/encoding/signed.lux b/stdlib/source/library/lux/target/jvm/encoding/signed.lux
index 1c03a5c47..5a687eaba 100644
--- a/stdlib/source/library/lux/target/jvm/encoding/signed.lux
+++ b/stdlib/source/library/lux/target/jvm/encoding/signed.lux
@@ -32,12 +32,12 @@
     (|>> :representation))
 
   (implementation: .public equivalence
-    (All [brand] (Equivalence (Signed brand)))
+    (All (_ brand) (Equivalence (Signed brand)))
     (def: (= reference sample)
       (i.= (:representation reference) (:representation sample))))
 
   (implementation: .public order
-    (All [brand] (Order (Signed brand)))
+    (All (_ brand) (Order (Signed brand)))
     
     (def: &equivalence ..equivalence)
     (def: (< reference sample)
diff --git a/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux b/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux
index c294201b6..2b38774f5 100644
--- a/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux
+++ b/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux
@@ -31,13 +31,13 @@
     (|>> :representation))
 
   (implementation: .public equivalence
-    (All [brand] (Equivalence (Unsigned brand)))
+    (All (_ brand) (Equivalence (Unsigned brand)))
     (def: (= reference sample)
       (n.= (:representation reference)
            (:representation sample))))
 
   (implementation: .public order
-    (All [brand] (Order (Unsigned brand)))
+    (All (_ brand) (Order (Unsigned brand)))
     
     (def: &equivalence ..equivalence)
     (def: (< reference sample)
diff --git a/stdlib/source/library/lux/target/jvm/index.lux b/stdlib/source/library/lux/target/jvm/index.lux
index 07ae1e85d..5651ac589 100644
--- a/stdlib/source/library/lux/target/jvm/index.lux
+++ b/stdlib/source/library/lux/target/jvm/index.lux
@@ -21,7 +21,7 @@
   U2
 
   (def: .public index
-    (All [kind] (-> U2 (Index kind)))
+    (All (_ kind) (-> U2 (Index kind)))
     (|>> :abstraction))
 
   (def: .public value
@@ -29,12 +29,12 @@
     (|>> :representation))
 
   (def: .public equivalence
-    (All [kind] (Equivalence (Index kind)))
+    (All (_ kind) (Equivalence (Index kind)))
     (\ equivalence.functor each
        ..value
        //unsigned.equivalence))
 
   (def: .public writer
-    (All [kind] (Writer (Index kind)))
+    (All (_ kind) (Writer (Index kind)))
     (|>> :representation //unsigned.writer/2))
   )
diff --git a/stdlib/source/library/lux/target/jvm/modifier.lux b/stdlib/source/library/lux/target/jvm/modifier.lux
index 64359dea1..b50127bc2 100644
--- a/stdlib/source/library/lux/target/jvm/modifier.lux
+++ b/stdlib/source/library/lux/target/jvm/modifier.lux
@@ -33,7 +33,7 @@
     (|>> :representation))
 
   (implementation: .public equivalence
-    (All [of] (Equivalence (Modifier of)))
+    (All (_ of) (Equivalence (Modifier of)))
     
     (def: (= reference sample)
       (\ //unsigned.equivalence =
@@ -52,14 +52,14 @@
          //unsigned.value)])
 
   (def: .public (has? sub super)
-    (All [of] (-> (Modifier of) (Modifier of) Bit))
+    (All (_ of) (-> (Modifier of) (Modifier of) Bit))
     (let [sub (!unwrap sub)]
       (|> (!unwrap super)
           (i64.and sub)
           (\ i64.equivalence = sub))))
 
   (implementation: .public monoid
-    (All [of] (Monoid (Modifier of)))
+    (All (_ of) (Monoid (Modifier of)))
 
     (def: identity
       (!wrap (hex "0000")))
@@ -72,7 +72,7 @@
     (\ ..monoid identity))
 
   (def: .public writer
-    (All [of] (Writer (Modifier of)))
+    (All (_ of) (Writer (Modifier of)))
     (|>> :representation //unsigned.writer/2))
 
   (def: modifier
diff --git a/stdlib/source/library/lux/target/jvm/type.lux b/stdlib/source/library/lux/target/jvm/type.lux
index 1eeccbe72..0b89649c3 100644
--- a/stdlib/source/library/lux/target/jvm/type.lux
+++ b/stdlib/source/library/lux/target/jvm/type.lux
@@ -44,7 +44,7 @@
   
   (template [