From f621a133e6e0a516c0586270fea8eaffb4829d82 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 8 Aug 2021 17:56:15 -0400 Subject: No more #export magic syntax. --- stdlib/source/library/lux.lux | 1436 +++++++++++--------- stdlib/source/library/lux/abstract/algebra.lux | 8 +- stdlib/source/library/lux/abstract/apply.lux | 4 +- stdlib/source/library/lux/abstract/codec.lux | 4 +- stdlib/source/library/lux/abstract/comonad.lux | 4 +- .../source/library/lux/abstract/comonad/cofree.lux | 6 +- stdlib/source/library/lux/abstract/enum.lux | 4 +- stdlib/source/library/lux/abstract/equivalence.lux | 6 +- stdlib/source/library/lux/abstract/fold.lux | 4 +- stdlib/source/library/lux/abstract/functor.lux | 16 +- .../library/lux/abstract/functor/contravariant.lux | 2 +- stdlib/source/library/lux/abstract/hash.lux | 4 +- stdlib/source/library/lux/abstract/interval.lux | 38 +- stdlib/source/library/lux/abstract/monad.lux | 14 +- stdlib/source/library/lux/abstract/monad/free.lux | 8 +- .../source/library/lux/abstract/monad/indexed.lux | 4 +- stdlib/source/library/lux/abstract/monoid.lux | 4 +- stdlib/source/library/lux/abstract/order.lux | 18 +- stdlib/source/library/lux/abstract/predicate.lux | 16 +- .../source/library/lux/control/concatenative.lux | 86 +- .../library/lux/control/concurrency/actor.lux | 103 +- .../library/lux/control/concurrency/async.lux | 40 +- .../library/lux/control/concurrency/atom.lux | 16 +- .../source/library/lux/control/concurrency/frp.lux | 38 +- .../library/lux/control/concurrency/semaphore.lux | 38 +- .../source/library/lux/control/concurrency/stm.lux | 26 +- .../library/lux/control/concurrency/thread.lux | 8 +- stdlib/source/library/lux/control/continuation.lux | 22 +- stdlib/source/library/lux/control/exception.lux | 53 +- stdlib/source/library/lux/control/function.lux | 12 +- .../library/lux/control/function/contract.lux | 4 +- .../source/library/lux/control/function/memo.lux | 10 +- .../source/library/lux/control/function/mixin.lux | 20 +- .../source/library/lux/control/function/mutual.lux | 23 +- stdlib/source/library/lux/control/io.lux | 24 +- stdlib/source/library/lux/control/parser.lux | 60 +- .../source/library/lux/control/parser/analysis.lux | 22 +- .../source/library/lux/control/parser/binary.lux | 86 +- stdlib/source/library/lux/control/parser/cli.lux | 18 +- stdlib/source/library/lux/control/parser/code.lux | 28 +- .../library/lux/control/parser/environment.lux | 14 +- stdlib/source/library/lux/control/parser/json.lux | 30 +- .../library/lux/control/parser/synthesis.lux | 32 +- stdlib/source/library/lux/control/parser/text.lux | 82 +- stdlib/source/library/lux/control/parser/tree.lux | 12 +- stdlib/source/library/lux/control/parser/type.lux | 60 +- stdlib/source/library/lux/control/parser/xml.lux | 28 +- stdlib/source/library/lux/control/pipe.lux | 20 +- stdlib/source/library/lux/control/reader.lux | 20 +- stdlib/source/library/lux/control/region.lux | 20 +- stdlib/source/library/lux/control/remember.lux | 6 +- .../library/lux/control/security/capability.lux | 12 +- .../source/library/lux/control/security/policy.lux | 38 +- stdlib/source/library/lux/control/state.lux | 34 +- stdlib/source/library/lux/control/thread.lux | 26 +- stdlib/source/library/lux/control/try.lux | 22 +- stdlib/source/library/lux/control/writer.lux | 14 +- stdlib/source/library/lux/data/binary.lux | 148 +- stdlib/source/library/lux/data/bit.lux | 14 +- .../source/library/lux/data/collection/array.lux | 66 +- stdlib/source/library/lux/data/collection/bits.lux | 26 +- .../library/lux/data/collection/dictionary.lux | 44 +- .../lux/data/collection/dictionary/ordered.lux | 26 +- .../lux/data/collection/dictionary/plist.lux | 22 +- stdlib/source/library/lux/data/collection/list.lux | 96 +- .../source/library/lux/data/collection/queue.lux | 24 +- .../library/lux/data/collection/queue/priority.lux | 24 +- stdlib/source/library/lux/data/collection/row.lux | 46 +- .../library/lux/data/collection/sequence.lux | 30 +- stdlib/source/library/lux/data/collection/set.lux | 38 +- .../library/lux/data/collection/set/multi.lux | 42 +- .../library/lux/data/collection/set/ordered.lux | 32 +- .../source/library/lux/data/collection/stack.lux | 22 +- stdlib/source/library/lux/data/collection/tree.lux | 16 +- .../library/lux/data/collection/tree/finger.lux | 22 +- .../library/lux/data/collection/tree/zipper.lux | 48 +- stdlib/source/library/lux/data/color.lux | 74 +- stdlib/source/library/lux/data/color/named.lux | 2 +- stdlib/source/library/lux/data/format/binary.lux | 54 +- stdlib/source/library/lux/data/format/css.lux | 32 +- stdlib/source/library/lux/data/format/css/font.lux | 4 +- .../library/lux/data/format/css/property.lux | 10 +- .../source/library/lux/data/format/css/query.lux | 28 +- .../library/lux/data/format/css/selector.lux | 62 +- .../source/library/lux/data/format/css/style.lux | 14 +- .../source/library/lux/data/format/css/value.lux | 162 ++- stdlib/source/library/lux/data/format/html.lux | 102 +- stdlib/source/library/lux/data/format/json.lux | 26 +- stdlib/source/library/lux/data/format/markdown.lux | 44 +- stdlib/source/library/lux/data/format/tar.lux | 92 +- stdlib/source/library/lux/data/format/xml.lux | 18 +- stdlib/source/library/lux/data/identity.lux | 10 +- stdlib/source/library/lux/data/lazy.lux | 18 +- stdlib/source/library/lux/data/maybe.lux | 24 +- stdlib/source/library/lux/data/name.lux | 10 +- 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.lux | 74 +- stdlib/source/library/lux/data/text/buffer.lux | 14 +- stdlib/source/library/lux/data/text/encoding.lux | 8 +- .../source/library/lux/data/text/encoding/utf8.lux | 2 +- stdlib/source/library/lux/data/text/escape.lux | 14 +- stdlib/source/library/lux/data/text/format.lux | 16 +- stdlib/source/library/lux/data/text/regex.lux | 6 +- .../source/library/lux/data/text/unicode/block.lux | 22 +- .../source/library/lux/data/text/unicode/set.lux | 24 +- stdlib/source/library/lux/data/trace.lux | 8 +- stdlib/source/library/lux/debug.lux | 20 +- stdlib/source/library/lux/extension.lux | 2 +- stdlib/source/library/lux/ffi.js.lux | 22 +- stdlib/source/library/lux/ffi.jvm.lux | 74 +- stdlib/source/library/lux/ffi.lua.lux | 10 +- stdlib/source/library/lux/ffi.old.lux | 42 +- stdlib/source/library/lux/ffi.php.lux | 12 +- stdlib/source/library/lux/ffi.py.lux | 10 +- stdlib/source/library/lux/ffi.rb.lux | 8 +- stdlib/source/library/lux/ffi.scm.lux | 12 +- stdlib/source/library/lux/locale.lux | 12 +- stdlib/source/library/lux/locale/language.lux | 16 +- stdlib/source/library/lux/locale/territory.lux | 16 +- stdlib/source/library/lux/macro.lux | 18 +- stdlib/source/library/lux/macro/code.lux | 10 +- stdlib/source/library/lux/macro/local.lux | 6 +- stdlib/source/library/lux/macro/poly.lux | 60 +- stdlib/source/library/lux/macro/syntax.lux | 38 +- .../library/lux/macro/syntax/annotations.lux | 10 +- stdlib/source/library/lux/macro/syntax/check.lux | 8 +- .../library/lux/macro/syntax/declaration.lux | 8 +- .../source/library/lux/macro/syntax/definition.lux | 12 +- stdlib/source/library/lux/macro/syntax/export.lux | 4 +- stdlib/source/library/lux/macro/syntax/input.lux | 8 +- .../library/lux/macro/syntax/type/variable.lux | 8 +- stdlib/source/library/lux/macro/template.lux | 16 +- stdlib/source/library/lux/math.lux | 82 +- stdlib/source/library/lux/math/infix.lux | 2 +- .../source/library/lux/math/logic/continuous.lux | 14 +- stdlib/source/library/lux/math/logic/fuzzy.lux | 34 +- stdlib/source/library/lux/math/modular.lux | 30 +- stdlib/source/library/lux/math/modulus.lux | 18 +- stdlib/source/library/lux/math/number.lux | 2 +- stdlib/source/library/lux/math/number/complex.lux | 70 +- stdlib/source/library/lux/math/number/frac.lux | 62 +- stdlib/source/library/lux/math/number/i16.lux | 10 +- stdlib/source/library/lux/math/number/i32.lux | 10 +- stdlib/source/library/lux/math/number/i64.lux | 48 +- stdlib/source/library/lux/math/number/i8.lux | 10 +- stdlib/source/library/lux/math/number/int.lux | 56 +- stdlib/source/library/lux/math/number/nat.lux | 48 +- stdlib/source/library/lux/math/number/ratio.lux | 36 +- stdlib/source/library/lux/math/number/rev.lux | 46 +- stdlib/source/library/lux/math/random.lux | 74 +- stdlib/source/library/lux/meta.lux | 76 +- stdlib/source/library/lux/meta/annotation.lux | 14 +- stdlib/source/library/lux/meta/location.lux | 10 +- stdlib/source/library/lux/program.lux | 2 +- stdlib/source/library/lux/target.lux | 4 +- stdlib/source/library/lux/target/common_lisp.lux | 108 +- stdlib/source/library/lux/target/js.lux | 112 +- stdlib/source/library/lux/target/jvm.lux | 60 +- stdlib/source/library/lux/target/jvm/attribute.lux | 16 +- .../library/lux/target/jvm/attribute/code.lux | 8 +- .../lux/target/jvm/attribute/code/exception.lux | 8 +- .../library/lux/target/jvm/attribute/constant.lux | 8 +- stdlib/source/library/lux/target/jvm/bytecode.lux | 86 +- .../library/lux/target/jvm/bytecode/address.lux | 20 +- .../lux/target/jvm/bytecode/environment.lux | 24 +- .../lux/target/jvm/bytecode/environment/limit.lux | 10 +- .../jvm/bytecode/environment/limit/registry.lux | 20 +- .../jvm/bytecode/environment/limit/stack.lux | 18 +- .../lux/target/jvm/bytecode/instruction.lux | 24 +- .../library/lux/target/jvm/bytecode/jump.lux | 10 +- stdlib/source/library/lux/target/jvm/class.lux | 10 +- stdlib/source/library/lux/target/jvm/constant.lux | 40 +- .../library/lux/target/jvm/constant/pool.lux | 84 +- .../source/library/lux/target/jvm/constant/tag.lux | 10 +- .../library/lux/target/jvm/encoding/name.lux | 20 +- .../library/lux/target/jvm/encoding/signed.lux | 28 +- .../library/lux/target/jvm/encoding/unsigned.lux | 34 +- stdlib/source/library/lux/target/jvm/field.lux | 10 +- stdlib/source/library/lux/target/jvm/index.lux | 14 +- stdlib/source/library/lux/target/jvm/loader.lux | 18 +- stdlib/source/library/lux/target/jvm/magic.lux | 6 +- stdlib/source/library/lux/target/jvm/method.lux | 10 +- stdlib/source/library/lux/target/jvm/modifier.lux | 34 +- .../library/lux/target/jvm/modifier/inner.lux | 2 +- .../source/library/lux/target/jvm/reflection.lux | 34 +- stdlib/source/library/lux/target/jvm/type.lux | 46 +- .../source/library/lux/target/jvm/type/alias.lux | 6 +- stdlib/source/library/lux/target/jvm/type/box.lux | 2 +- .../library/lux/target/jvm/type/category.lux | 28 +- .../library/lux/target/jvm/type/descriptor.lux | 34 +- stdlib/source/library/lux/target/jvm/type/lux.lux | 20 +- .../source/library/lux/target/jvm/type/parser.lux | 40 +- .../library/lux/target/jvm/type/reflection.lux | 24 +- .../library/lux/target/jvm/type/signature.lux | 46 +- stdlib/source/library/lux/target/jvm/version.lux | 12 +- stdlib/source/library/lux/target/lua.lux | 96 +- stdlib/source/library/lux/target/php.lux | 120 +- stdlib/source/library/lux/target/python.lux | 110 +- stdlib/source/library/lux/target/r.lux | 90 +- stdlib/source/library/lux/target/ruby.lux | 100 +- stdlib/source/library/lux/target/scheme.lux | 82 +- stdlib/source/library/lux/test.lux | 40 +- stdlib/source/library/lux/time.lux | 34 +- stdlib/source/library/lux/time/date.lux | 30 +- stdlib/source/library/lux/time/day.lux | 22 +- stdlib/source/library/lux/time/duration.lux | 40 +- stdlib/source/library/lux/time/instant.lux | 36 +- stdlib/source/library/lux/time/month.lux | 26 +- stdlib/source/library/lux/time/year.lux | 30 +- stdlib/source/library/lux/tool/compiler.lux | 14 +- stdlib/source/library/lux/tool/compiler/arity.lux | 4 +- .../library/lux/tool/compiler/default/init.lux | 6 +- .../library/lux/tool/compiler/default/platform.lux | 14 +- .../library/lux/tool/compiler/language/lux.lux | 6 +- .../lux/tool/compiler/language/lux/analysis.lux | 134 +- .../compiler/language/lux/analysis/evaluation.lux | 4 +- .../tool/compiler/language/lux/analysis/macro.lux | 10 +- .../lux/tool/compiler/language/lux/directive.lux | 20 +- .../lux/tool/compiler/language/lux/generation.lux | 64 +- .../tool/compiler/language/lux/phase/analysis.lux | 4 +- .../compiler/language/lux/phase/analysis/case.lux | 14 +- .../language/lux/phase/analysis/case/coverage.lux | 16 +- .../language/lux/phase/analysis/function.lux | 8 +- .../language/lux/phase/analysis/inference.lux | 16 +- .../language/lux/phase/analysis/module.lux | 36 +- .../language/lux/phase/analysis/primitive.lux | 4 +- .../language/lux/phase/analysis/reference.lux | 6 +- .../compiler/language/lux/phase/analysis/scope.lux | 16 +- .../language/lux/phase/analysis/structure.lux | 28 +- .../compiler/language/lux/phase/analysis/type.lux | 10 +- .../tool/compiler/language/lux/phase/directive.lux | 8 +- .../tool/compiler/language/lux/phase/extension.lux | 48 +- .../language/lux/phase/extension/analysis.lux | 2 +- .../lux/phase/extension/analysis/common_lisp.lux | 2 +- .../language/lux/phase/extension/analysis/js.lux | 2 +- .../language/lux/phase/extension/analysis/jvm.lux | 104 +- .../language/lux/phase/extension/analysis/lua.lux | 2 +- .../language/lux/phase/extension/analysis/lux.lux | 14 +- .../language/lux/phase/extension/analysis/php.lux | 2 +- .../lux/phase/extension/analysis/python.lux | 2 +- .../language/lux/phase/extension/analysis/r.lux | 2 +- .../language/lux/phase/extension/analysis/ruby.lux | 2 +- .../lux/phase/extension/analysis/scheme.lux | 2 +- .../language/lux/phase/extension/bundle.lux | 6 +- .../language/lux/phase/extension/directive/jvm.lux | 2 +- .../language/lux/phase/extension/directive/lux.lux | 45 +- .../lux/phase/extension/generation/common_lisp.lux | 2 +- .../extension/generation/common_lisp/common.lux | 4 +- .../extension/generation/common_lisp/host.lux | 2 +- .../language/lux/phase/extension/generation/js.lux | 2 +- .../lux/phase/extension/generation/js/common.lux | 4 +- .../lux/phase/extension/generation/js/host.lux | 2 +- .../lux/phase/extension/generation/jvm.lux | 2 +- .../lux/phase/extension/generation/jvm/common.lux | 4 +- .../lux/phase/extension/generation/jvm/host.lux | 8 +- .../lux/phase/extension/generation/lua.lux | 2 +- .../lux/phase/extension/generation/lua/common.lux | 4 +- .../lux/phase/extension/generation/lua/host.lux | 2 +- .../lux/phase/extension/generation/php.lux | 2 +- .../lux/phase/extension/generation/php/common.lux | 4 +- .../lux/phase/extension/generation/php/host.lux | 2 +- .../lux/phase/extension/generation/python.lux | 2 +- .../phase/extension/generation/python/common.lux | 4 +- .../lux/phase/extension/generation/python/host.lux | 2 +- .../language/lux/phase/extension/generation/r.lux | 2 +- .../lux/phase/extension/generation/r/common.lux | 4 +- .../lux/phase/extension/generation/r/host.lux | 2 +- .../lux/phase/extension/generation/ruby.lux | 2 +- .../lux/phase/extension/generation/ruby/common.lux | 4 +- .../lux/phase/extension/generation/ruby/host.lux | 2 +- .../lux/phase/extension/generation/scheme.lux | 2 +- .../phase/extension/generation/scheme/common.lux | 4 +- .../lux/phase/extension/generation/scheme/host.lux | 2 +- .../language/lux/phase/extension/synthesis.lux | 2 +- .../language/lux/phase/generation/common_lisp.lux | 2 +- .../lux/phase/generation/common_lisp/case.lux | 12 +- .../lux/phase/generation/common_lisp/extension.lux | 2 +- .../generation/common_lisp/extension/common.lux | 2 +- .../lux/phase/generation/common_lisp/function.lux | 4 +- .../lux/phase/generation/common_lisp/loop.lux | 4 +- .../lux/phase/generation/common_lisp/primitive.lux | 8 +- .../lux/phase/generation/common_lisp/reference.lux | 2 +- .../lux/phase/generation/common_lisp/runtime.lux | 24 +- .../lux/phase/generation/common_lisp/structure.lux | 4 +- .../language/lux/phase/generation/extension.lux | 14 +- .../compiler/language/lux/phase/generation/js.lux | 4 +- .../language/lux/phase/generation/js/case.lux | 16 +- .../language/lux/phase/generation/js/function.lux | 4 +- .../language/lux/phase/generation/js/loop.lux | 6 +- .../language/lux/phase/generation/js/primitive.lux | 8 +- .../language/lux/phase/generation/js/reference.lux | 2 +- .../language/lux/phase/generation/js/runtime.lux | 38 +- .../language/lux/phase/generation/js/structure.lux | 4 +- .../compiler/language/lux/phase/generation/jvm.lux | 2 +- .../language/lux/phase/generation/jvm/case.lux | 8 +- .../language/lux/phase/generation/jvm/debug.lux | 2 +- .../language/lux/phase/generation/jvm/function.lux | 6 +- .../lux/phase/generation/jvm/function/abstract.lux | 6 +- .../generation/jvm/function/field/constant.lux | 2 +- .../jvm/function/field/constant/arity.lux | 10 +- .../generation/jvm/function/field/variable.lux | 10 +- .../jvm/function/field/variable/foreign.lux | 8 +- .../jvm/function/field/variable/partial.lux | 10 +- .../jvm/function/field/variable/partial/count.lux | 8 +- .../lux/phase/generation/jvm/function/method.lux | 2 +- .../phase/generation/jvm/function/method/apply.lux | 2 +- .../jvm/function/method/implementation.lux | 8 +- .../phase/generation/jvm/function/method/init.lux | 8 +- .../phase/generation/jvm/function/method/new.lux | 6 +- .../phase/generation/jvm/function/method/reset.lux | 6 +- .../language/lux/phase/generation/jvm/host.lux | 8 +- .../language/lux/phase/generation/jvm/loop.lux | 4 +- .../lux/phase/generation/jvm/primitive.lux | 8 +- .../language/lux/phase/generation/jvm/program.lux | 16 +- .../lux/phase/generation/jvm/reference.lux | 8 +- .../language/lux/phase/generation/jvm/runtime.lux | 64 +- .../lux/phase/generation/jvm/structure.lux | 8 +- .../language/lux/phase/generation/jvm/type.lux | 22 +- .../language/lux/phase/generation/jvm/value.lux | 6 +- .../compiler/language/lux/phase/generation/lua.lux | 4 +- .../language/lux/phase/generation/lua/case.lux | 20 +- .../language/lux/phase/generation/lua/function.lux | 4 +- .../language/lux/phase/generation/lua/loop.lux | 6 +- .../lux/phase/generation/lua/primitive.lux | 2 +- .../lux/phase/generation/lua/reference.lux | 2 +- .../language/lux/phase/generation/lua/runtime.lux | 34 +- .../lux/phase/generation/lua/structure.lux | 4 +- .../compiler/language/lux/phase/generation/php.lux | 6 +- .../language/lux/phase/generation/php/case.lux | 20 +- .../lux/phase/generation/php/extension.lux | 2 +- .../lux/phase/generation/php/extension/common.lux | 2 +- .../language/lux/phase/generation/php/function.lux | 4 +- .../language/lux/phase/generation/php/loop.lux | 6 +- .../lux/phase/generation/php/primitive.lux | 8 +- .../lux/phase/generation/php/reference.lux | 2 +- .../language/lux/phase/generation/php/runtime.lux | 40 +- .../lux/phase/generation/php/structure.lux | 4 +- .../language/lux/phase/generation/python.lux | 6 +- .../language/lux/phase/generation/python/case.lux | 22 +- .../lux/phase/generation/python/function.lux | 6 +- .../language/lux/phase/generation/python/loop.lux | 8 +- .../lux/phase/generation/python/primitive.lux | 2 +- .../lux/phase/generation/python/reference.lux | 2 +- .../lux/phase/generation/python/runtime.lux | 28 +- .../lux/phase/generation/python/structure.lux | 4 +- .../compiler/language/lux/phase/generation/r.lux | 2 +- .../language/lux/phase/generation/r/case.lux | 12 +- .../language/lux/phase/generation/r/function.lux | 4 +- .../language/lux/phase/generation/r/loop.lux | 4 +- .../language/lux/phase/generation/r/primitive.lux | 2 +- .../lux/phase/generation/r/procedure/common.lux | 30 +- .../lux/phase/generation/r/procedure/host.lux | 2 +- .../language/lux/phase/generation/r/reference.lux | 2 +- .../language/lux/phase/generation/r/runtime.lux | 44 +- .../language/lux/phase/generation/r/structure.lux | 4 +- .../language/lux/phase/generation/reference.lux | 14 +- .../language/lux/phase/generation/ruby.lux | 4 +- .../language/lux/phase/generation/ruby/case.lux | 20 +- .../lux/phase/generation/ruby/function.lux | 6 +- .../language/lux/phase/generation/ruby/loop.lux | 8 +- .../lux/phase/generation/ruby/primitive.lux | 2 +- .../lux/phase/generation/ruby/reference.lux | 2 +- .../language/lux/phase/generation/ruby/runtime.lux | 34 +- .../lux/phase/generation/ruby/structure.lux | 4 +- .../language/lux/phase/generation/scheme.lux | 2 +- .../language/lux/phase/generation/scheme/case.lux | 12 +- .../lux/phase/generation/scheme/extension.lux | 2 +- .../phase/generation/scheme/extension/common.lux | 16 +- .../lux/phase/generation/scheme/function.lux | 4 +- .../language/lux/phase/generation/scheme/loop.lux | 4 +- .../lux/phase/generation/scheme/primitive.lux | 2 +- .../lux/phase/generation/scheme/reference.lux | 2 +- .../lux/phase/generation/scheme/runtime.lux | 24 +- .../lux/phase/generation/scheme/structure.lux | 4 +- .../tool/compiler/language/lux/phase/synthesis.lux | 2 +- .../compiler/language/lux/phase/synthesis/case.lux | 20 +- .../language/lux/phase/synthesis/function.lux | 8 +- .../compiler/language/lux/phase/synthesis/loop.lux | 6 +- .../language/lux/phase/synthesis/variable.lux | 4 +- .../lux/tool/compiler/language/lux/program.lux | 8 +- .../lux/tool/compiler/language/lux/syntax.lux | 184 +-- .../lux/tool/compiler/language/lux/synthesis.lux | 158 +-- .../lux/tool/compiler/language/lux/version.lux | 2 +- stdlib/source/library/lux/tool/compiler/meta.lux | 2 +- .../library/lux/tool/compiler/meta/archive.lux | 50 +- .../lux/tool/compiler/meta/archive/artifact.lux | 28 +- .../lux/tool/compiler/meta/archive/descriptor.lux | 8 +- .../lux/tool/compiler/meta/archive/document.lux | 18 +- .../library/lux/tool/compiler/meta/archive/key.lux | 8 +- .../lux/tool/compiler/meta/archive/signature.lux | 10 +- .../lux/tool/compiler/meta/cache/dependency.lux | 10 +- .../source/library/lux/tool/compiler/meta/io.lux | 8 +- .../library/lux/tool/compiler/meta/io/archive.lux | 16 +- .../library/lux/tool/compiler/meta/io/context.lux | 14 +- .../library/lux/tool/compiler/meta/packager.lux | 6 +- .../lux/tool/compiler/meta/packager/jvm.lux | 2 +- .../lux/tool/compiler/meta/packager/scheme.lux | 2 +- .../lux/tool/compiler/meta/packager/script.lux | 2 +- stdlib/source/library/lux/tool/compiler/phase.lux | 30 +- .../source/library/lux/tool/compiler/reference.lux | 28 +- .../lux/tool/compiler/reference/variable.lux | 16 +- .../source/library/lux/tool/compiler/version.lux | 10 +- stdlib/source/library/lux/tool/interpreter.lux | 6 +- stdlib/source/library/lux/tool/mediator.lux | 6 +- stdlib/source/library/lux/type.lux | 44 +- stdlib/source/library/lux/type/abstract.lux | 78 +- stdlib/source/library/lux/type/check.lux | 52 +- stdlib/source/library/lux/type/dynamic.lux | 14 +- stdlib/source/library/lux/type/implicit.lux | 8 +- stdlib/source/library/lux/type/quotient.lux | 18 +- stdlib/source/library/lux/type/refinement.lux | 20 +- stdlib/source/library/lux/type/resource.lux | 40 +- stdlib/source/library/lux/type/unit.lux | 94 +- stdlib/source/library/lux/type/variance.lux | 6 +- stdlib/source/library/lux/world/console.lux | 14 +- stdlib/source/library/lux/world/db/jdbc.lux | 22 +- stdlib/source/library/lux/world/db/jdbc/input.lux | 14 +- stdlib/source/library/lux/world/db/jdbc/output.lux | 18 +- stdlib/source/library/lux/world/db/sql.lux | 90 +- stdlib/source/library/lux/world/file.lux | 48 +- stdlib/source/library/lux/world/file/watch.lux | 22 +- stdlib/source/library/lux/world/input/keyboard.lux | 8 +- stdlib/source/library/lux/world/net.lux | 8 +- stdlib/source/library/lux/world/net/http.lux | 34 +- .../source/library/lux/world/net/http/client.lux | 10 +- .../source/library/lux/world/net/http/cookie.lux | 16 +- .../source/library/lux/world/net/http/header.lux | 8 +- stdlib/source/library/lux/world/net/http/mime.lux | 12 +- stdlib/source/library/lux/world/net/http/query.lux | 2 +- .../source/library/lux/world/net/http/request.lux | 10 +- .../source/library/lux/world/net/http/response.lux | 16 +- stdlib/source/library/lux/world/net/http/route.lux | 8 +- .../source/library/lux/world/net/http/status.lux | 2 +- .../source/library/lux/world/net/http/version.lux | 2 +- stdlib/source/library/lux/world/net/uri.lux | 4 +- .../library/lux/world/output/video/resolution.lux | 8 +- stdlib/source/library/lux/world/program.lux | 12 +- .../library/lux/world/service/authentication.lux | 10 +- stdlib/source/library/lux/world/service/crud.lux | 14 +- .../source/library/lux/world/service/inventory.lux | 14 +- .../source/library/lux/world/service/journal.lux | 14 +- stdlib/source/library/lux/world/service/mail.lux | 6 +- stdlib/source/library/lux/world/shell.lux | 22 +- stdlib/source/poly/lux/abstract/equivalence.lux | 2 +- stdlib/source/poly/lux/abstract/functor.lux | 2 +- stdlib/source/poly/lux/data/format/json.lux | 2 +- stdlib/source/program/aedifex/action.lux | 4 +- stdlib/source/program/aedifex/artifact.lux | 24 +- .../source/program/aedifex/artifact/extension.lux | 8 +- .../source/program/aedifex/artifact/snapshot.lux | 8 +- .../program/aedifex/artifact/snapshot/build.lux | 8 +- .../program/aedifex/artifact/snapshot/stamp.lux | 8 +- .../program/aedifex/artifact/snapshot/time.lux | 8 +- .../program/aedifex/artifact/snapshot/version.lux | 8 +- .../aedifex/artifact/snapshot/version/value.lux | 8 +- stdlib/source/program/aedifex/artifact/time.lux | 14 +- .../source/program/aedifex/artifact/time/date.lux | 20 +- .../source/program/aedifex/artifact/time/time.lux | 6 +- stdlib/source/program/aedifex/artifact/type.lux | 4 +- .../source/program/aedifex/artifact/versioning.lux | 10 +- stdlib/source/program/aedifex/cli.lux | 8 +- stdlib/source/program/aedifex/command.lux | 2 +- stdlib/source/program/aedifex/command/auto.lux | 4 +- stdlib/source/program/aedifex/command/build.lux | 24 +- stdlib/source/program/aedifex/command/clean.lux | 4 +- stdlib/source/program/aedifex/command/deploy.lux | 4 +- stdlib/source/program/aedifex/command/deps.lux | 2 +- stdlib/source/program/aedifex/command/install.lux | 6 +- stdlib/source/program/aedifex/command/pom.lux | 4 +- stdlib/source/program/aedifex/command/test.lux | 8 +- stdlib/source/program/aedifex/command/version.lux | 2 +- stdlib/source/program/aedifex/dependency.lux | 8 +- .../program/aedifex/dependency/deployment.lux | 4 +- .../program/aedifex/dependency/resolution.lux | 16 +- .../source/program/aedifex/dependency/status.lux | 6 +- stdlib/source/program/aedifex/format.lux | 6 +- stdlib/source/program/aedifex/hash.lux | 20 +- stdlib/source/program/aedifex/input.lux | 2 +- stdlib/source/program/aedifex/local.lux | 4 +- stdlib/source/program/aedifex/metadata.lux | 8 +- .../source/program/aedifex/metadata/artifact.lux | 14 +- .../source/program/aedifex/metadata/snapshot.lux | 14 +- stdlib/source/program/aedifex/package.lux | 12 +- stdlib/source/program/aedifex/parser.lux | 2 +- stdlib/source/program/aedifex/pom.lux | 6 +- stdlib/source/program/aedifex/profile.lux | 42 +- stdlib/source/program/aedifex/project.lux | 16 +- stdlib/source/program/aedifex/repository.lux | 8 +- .../source/program/aedifex/repository/identity.lux | 10 +- stdlib/source/program/aedifex/repository/local.lux | 2 +- .../source/program/aedifex/repository/origin.lux | 4 +- .../source/program/aedifex/repository/remote.lux | 10 +- stdlib/source/program/aedifex/runtime.lux | 8 +- stdlib/source/program/compositor.lux | 2 +- stdlib/source/program/compositor/cli.lux | 18 +- stdlib/source/program/compositor/export.lux | 4 +- stdlib/source/program/compositor/import.lux | 8 +- stdlib/source/program/compositor/static.lux | 2 +- stdlib/source/program/scriptum.lux | 4 +- stdlib/source/specification/aedifex/repository.lux | 2 +- stdlib/source/specification/compositor.lux | 2 +- .../specification/compositor/analysis/type.lux | 2 +- stdlib/source/specification/compositor/common.lux | 8 +- .../specification/compositor/generation/case.lux | 4 +- .../specification/compositor/generation/common.lux | 2 +- .../compositor/generation/function.lux | 2 +- .../compositor/generation/primitive.lux | 2 +- .../compositor/generation/reference.lux | 2 +- .../compositor/generation/structure.lux | 2 +- stdlib/source/specification/lux/abstract/apply.lux | 2 +- stdlib/source/specification/lux/abstract/codec.lux | 2 +- .../source/specification/lux/abstract/comonad.lux | 2 +- stdlib/source/specification/lux/abstract/enum.lux | 2 +- .../specification/lux/abstract/equivalence.lux | 2 +- stdlib/source/specification/lux/abstract/fold.lux | 2 +- .../source/specification/lux/abstract/functor.lux | 6 +- .../lux/abstract/functor/contravariant.lux | 2 +- stdlib/source/specification/lux/abstract/hash.lux | 2 +- .../source/specification/lux/abstract/interval.lux | 2 +- stdlib/source/specification/lux/abstract/monad.lux | 2 +- .../source/specification/lux/abstract/monoid.lux | 2 +- stdlib/source/specification/lux/abstract/order.lux | 2 +- stdlib/source/specification/lux/world/console.lux | 2 +- stdlib/source/specification/lux/world/file.lux | 2 +- stdlib/source/specification/lux/world/program.lux | 2 +- stdlib/source/specification/lux/world/shell.lux | 2 +- stdlib/source/test/aedifex/artifact.lux | 4 +- stdlib/source/test/aedifex/artifact/extension.lux | 2 +- stdlib/source/test/aedifex/artifact/snapshot.lux | 4 +- .../test/aedifex/artifact/snapshot/build.lux | 4 +- .../test/aedifex/artifact/snapshot/stamp.lux | 4 +- .../source/test/aedifex/artifact/snapshot/time.lux | 4 +- .../test/aedifex/artifact/snapshot/version.lux | 4 +- .../aedifex/artifact/snapshot/version/value.lux | 4 +- stdlib/source/test/aedifex/artifact/time.lux | 4 +- stdlib/source/test/aedifex/artifact/time/date.lux | 4 +- stdlib/source/test/aedifex/artifact/time/time.lux | 4 +- stdlib/source/test/aedifex/artifact/type.lux | 4 +- stdlib/source/test/aedifex/artifact/versioning.lux | 4 +- stdlib/source/test/aedifex/cache.lux | 2 +- stdlib/source/test/aedifex/cli.lux | 2 +- stdlib/source/test/aedifex/command.lux | 2 +- stdlib/source/test/aedifex/command/auto.lux | 2 +- stdlib/source/test/aedifex/command/build.lux | 10 +- stdlib/source/test/aedifex/command/clean.lux | 2 +- stdlib/source/test/aedifex/command/deploy.lux | 2 +- stdlib/source/test/aedifex/command/deps.lux | 2 +- stdlib/source/test/aedifex/command/install.lux | 4 +- stdlib/source/test/aedifex/command/pom.lux | 2 +- stdlib/source/test/aedifex/command/test.lux | 2 +- stdlib/source/test/aedifex/command/version.lux | 6 +- stdlib/source/test/aedifex/dependency.lux | 4 +- .../source/test/aedifex/dependency/deployment.lux | 2 +- .../source/test/aedifex/dependency/resolution.lux | 6 +- stdlib/source/test/aedifex/dependency/status.lux | 4 +- stdlib/source/test/aedifex/hash.lux | 4 +- stdlib/source/test/aedifex/input.lux | 2 +- stdlib/source/test/aedifex/local.lux | 2 +- stdlib/source/test/aedifex/metadata.lux | 2 +- stdlib/source/test/aedifex/metadata/artifact.lux | 4 +- stdlib/source/test/aedifex/metadata/snapshot.lux | 4 +- stdlib/source/test/aedifex/package.lux | 4 +- stdlib/source/test/aedifex/parser.lux | 2 +- stdlib/source/test/aedifex/pom.lux | 2 +- stdlib/source/test/aedifex/profile.lux | 4 +- stdlib/source/test/aedifex/project.lux | 4 +- stdlib/source/test/aedifex/repository.lux | 6 +- stdlib/source/test/aedifex/repository/identity.lux | 4 +- stdlib/source/test/aedifex/repository/local.lux | 2 +- stdlib/source/test/aedifex/repository/origin.lux | 4 +- stdlib/source/test/aedifex/repository/remote.lux | 2 +- stdlib/source/test/aedifex/runtime.lux | 4 +- stdlib/source/test/lux.lux | 21 +- stdlib/source/test/lux/abstract.lux | 2 +- stdlib/source/test/lux/abstract/apply.lux | 2 +- stdlib/source/test/lux/abstract/codec.lux | 2 +- stdlib/source/test/lux/abstract/comonad.lux | 2 +- stdlib/source/test/lux/abstract/comonad/cofree.lux | 2 +- stdlib/source/test/lux/abstract/enum.lux | 2 +- stdlib/source/test/lux/abstract/equivalence.lux | 2 +- stdlib/source/test/lux/abstract/fold.lux | 2 +- stdlib/source/test/lux/abstract/functor.lux | 2 +- .../test/lux/abstract/functor/contravariant.lux | 2 +- stdlib/source/test/lux/abstract/hash.lux | 2 +- stdlib/source/test/lux/abstract/interval.lux | 8 +- stdlib/source/test/lux/abstract/monad.lux | 2 +- stdlib/source/test/lux/abstract/monad/free.lux | 2 +- stdlib/source/test/lux/abstract/monoid.lux | 2 +- stdlib/source/test/lux/abstract/order.lux | 2 +- stdlib/source/test/lux/abstract/predicate.lux | 2 +- stdlib/source/test/lux/control.lux | 2 +- stdlib/source/test/lux/control/concatenative.lux | 46 +- .../source/test/lux/control/concurrency/actor.lux | 4 +- .../source/test/lux/control/concurrency/async.lux | 2 +- .../source/test/lux/control/concurrency/atom.lux | 2 +- stdlib/source/test/lux/control/concurrency/frp.lux | 2 +- .../test/lux/control/concurrency/semaphore.lux | 2 +- stdlib/source/test/lux/control/concurrency/stm.lux | 2 +- .../source/test/lux/control/concurrency/thread.lux | 2 +- stdlib/source/test/lux/control/continuation.lux | 2 +- stdlib/source/test/lux/control/exception.lux | 2 +- stdlib/source/test/lux/control/function.lux | 2 +- .../source/test/lux/control/function/contract.lux | 2 +- stdlib/source/test/lux/control/function/memo.lux | 2 +- stdlib/source/test/lux/control/function/mixin.lux | 2 +- stdlib/source/test/lux/control/function/mutual.lux | 2 +- stdlib/source/test/lux/control/io.lux | 2 +- stdlib/source/test/lux/control/parser.lux | 2 +- stdlib/source/test/lux/control/parser/analysis.lux | 12 +- stdlib/source/test/lux/control/parser/binary.lux | 12 +- stdlib/source/test/lux/control/parser/cli.lux | 14 +- stdlib/source/test/lux/control/parser/code.lux | 14 +- .../source/test/lux/control/parser/environment.lux | 2 +- stdlib/source/test/lux/control/parser/json.lux | 14 +- .../source/test/lux/control/parser/synthesis.lux | 14 +- stdlib/source/test/lux/control/parser/text.lux | 14 +- stdlib/source/test/lux/control/parser/tree.lux | 50 +- stdlib/source/test/lux/control/parser/type.lux | 14 +- stdlib/source/test/lux/control/parser/xml.lux | 32 +- stdlib/source/test/lux/control/pipe.lux | 2 +- stdlib/source/test/lux/control/reader.lux | 2 +- stdlib/source/test/lux/control/region.lux | 2 +- stdlib/source/test/lux/control/remember.lux | 2 +- .../test/lux/control/security/capability.lux | 2 +- stdlib/source/test/lux/control/security/policy.lux | 2 +- stdlib/source/test/lux/control/state.lux | 2 +- stdlib/source/test/lux/control/thread.lux | 2 +- stdlib/source/test/lux/control/try.lux | 4 +- stdlib/source/test/lux/control/writer.lux | 2 +- stdlib/source/test/lux/data.lux | 10 +- stdlib/source/test/lux/data/binary.lux | 4 +- stdlib/source/test/lux/data/bit.lux | 2 +- stdlib/source/test/lux/data/collection.lux | 2 +- stdlib/source/test/lux/data/collection/array.lux | 2 +- stdlib/source/test/lux/data/collection/bits.lux | 4 +- .../source/test/lux/data/collection/dictionary.lux | 2 +- .../lux/data/collection/dictionary/ordered.lux | 4 +- .../test/lux/data/collection/dictionary/plist.lux | 4 +- stdlib/source/test/lux/data/collection/list.lux | 2 +- stdlib/source/test/lux/data/collection/queue.lux | 2 +- .../test/lux/data/collection/queue/priority.lux | 4 +- stdlib/source/test/lux/data/collection/row.lux | 2 +- .../source/test/lux/data/collection/sequence.lux | 2 +- stdlib/source/test/lux/data/collection/set.lux | 2 +- .../source/test/lux/data/collection/set/multi.lux | 4 +- .../test/lux/data/collection/set/ordered.lux | 4 +- stdlib/source/test/lux/data/collection/stack.lux | 2 +- stdlib/source/test/lux/data/collection/tree.lux | 4 +- .../test/lux/data/collection/tree/finger.lux | 2 +- .../test/lux/data/collection/tree/zipper.lux | 2 +- stdlib/source/test/lux/data/color.lux | 4 +- stdlib/source/test/lux/data/color/named.lux | 2 +- stdlib/source/test/lux/data/format/binary.lux | 2 +- stdlib/source/test/lux/data/format/json.lux | 4 +- stdlib/source/test/lux/data/format/tar.lux | 2 +- stdlib/source/test/lux/data/format/xml.lux | 4 +- stdlib/source/test/lux/data/identity.lux | 2 +- stdlib/source/test/lux/data/lazy.lux | 4 +- stdlib/source/test/lux/data/maybe.lux | 2 +- stdlib/source/test/lux/data/name.lux | 4 +- stdlib/source/test/lux/data/product.lux | 2 +- stdlib/source/test/lux/data/sum.lux | 2 +- stdlib/source/test/lux/data/text.lux | 2 +- stdlib/source/test/lux/data/text/buffer.lux | 2 +- stdlib/source/test/lux/data/text/encoding.lux | 4 +- stdlib/source/test/lux/data/text/encoding/utf8.lux | 2 +- stdlib/source/test/lux/data/text/escape.lux | 2 +- stdlib/source/test/lux/data/text/format.lux | 2 +- stdlib/source/test/lux/data/text/regex.lux | 2 +- stdlib/source/test/lux/data/text/unicode/block.lux | 4 +- stdlib/source/test/lux/data/text/unicode/set.lux | 4 +- stdlib/source/test/lux/debug.lux | 2 +- stdlib/source/test/lux/extension.lux | 2 +- stdlib/source/test/lux/ffi.js.lux | 2 +- stdlib/source/test/lux/ffi.jvm.lux | 2 +- stdlib/source/test/lux/ffi.lua.lux | 2 +- stdlib/source/test/lux/ffi.old.lux | 2 +- stdlib/source/test/lux/ffi.php.lux | 2 +- stdlib/source/test/lux/ffi.py.lux | 2 +- stdlib/source/test/lux/ffi.rb.lux | 2 +- stdlib/source/test/lux/ffi.scm.lux | 2 +- stdlib/source/test/lux/locale.lux | 2 +- stdlib/source/test/lux/locale/language.lux | 10 +- stdlib/source/test/lux/locale/territory.lux | 10 +- stdlib/source/test/lux/macro.lux | 14 +- stdlib/source/test/lux/macro/code.lux | 4 +- stdlib/source/test/lux/macro/local.lux | 2 +- stdlib/source/test/lux/macro/poly.lux | 2 +- stdlib/source/test/lux/macro/poly/equivalence.lux | 2 +- stdlib/source/test/lux/macro/poly/functor.lux | 2 +- stdlib/source/test/lux/macro/poly/json.lux | 2 +- stdlib/source/test/lux/macro/syntax.lux | 2 +- .../source/test/lux/macro/syntax/annotations.lux | 4 +- stdlib/source/test/lux/macro/syntax/check.lux | 4 +- .../source/test/lux/macro/syntax/declaration.lux | 4 +- stdlib/source/test/lux/macro/syntax/definition.lux | 4 +- stdlib/source/test/lux/macro/syntax/export.lux | 2 +- stdlib/source/test/lux/macro/syntax/input.lux | 4 +- .../source/test/lux/macro/syntax/type/variable.lux | 4 +- stdlib/source/test/lux/macro/template.lux | 2 +- stdlib/source/test/lux/math.lux | 2 +- stdlib/source/test/lux/math/infix.lux | 2 +- stdlib/source/test/lux/math/logic/continuous.lux | 2 +- stdlib/source/test/lux/math/logic/fuzzy.lux | 2 +- stdlib/source/test/lux/math/modular.lux | 4 +- stdlib/source/test/lux/math/modulus.lux | 4 +- stdlib/source/test/lux/math/number.lux | 2 +- stdlib/source/test/lux/math/number/complex.lux | 4 +- stdlib/source/test/lux/math/number/frac.lux | 2 +- stdlib/source/test/lux/math/number/i16.lux | 4 +- stdlib/source/test/lux/math/number/i32.lux | 4 +- stdlib/source/test/lux/math/number/i64.lux | 2 +- stdlib/source/test/lux/math/number/i8.lux | 4 +- stdlib/source/test/lux/math/number/int.lux | 2 +- stdlib/source/test/lux/math/number/nat.lux | 2 +- stdlib/source/test/lux/math/number/ratio.lux | 4 +- stdlib/source/test/lux/math/number/rev.lux | 2 +- stdlib/source/test/lux/meta.lux | 8 +- stdlib/source/test/lux/meta/annotation.lux | 8 +- stdlib/source/test/lux/meta/location.lux | 4 +- stdlib/source/test/lux/program.lux | 2 +- stdlib/source/test/lux/target.lux | 2 +- stdlib/source/test/lux/target/jvm.lux | 52 +- stdlib/source/test/lux/test.lux | 4 +- stdlib/source/test/lux/time.lux | 2 +- stdlib/source/test/lux/time/date.lux | 2 +- stdlib/source/test/lux/time/day.lux | 4 +- stdlib/source/test/lux/time/duration.lux | 2 +- stdlib/source/test/lux/time/instant.lux | 2 +- stdlib/source/test/lux/time/month.lux | 4 +- stdlib/source/test/lux/time/year.lux | 4 +- stdlib/source/test/lux/tool.lux | 2 +- .../tool/compiler/language/lux/phase/analysis.lux | 2 +- .../compiler/language/lux/phase/analysis/case.lux | 6 +- .../language/lux/phase/analysis/function.lux | 2 +- .../language/lux/phase/analysis/primitive.lux | 12 +- .../language/lux/phase/analysis/reference.lux | 2 +- .../language/lux/phase/analysis/structure.lux | 4 +- .../language/lux/phase/extension/analysis/lux.lux | 2 +- .../tool/compiler/language/lux/phase/synthesis.lux | 2 +- .../compiler/language/lux/phase/synthesis/case.lux | 2 +- .../language/lux/phase/synthesis/function.lux | 2 +- .../compiler/language/lux/phase/synthesis/loop.lux | 2 +- .../language/lux/phase/synthesis/primitive.lux | 6 +- .../language/lux/phase/synthesis/structure.lux | 2 +- .../language/lux/phase/synthesis/variable.lux | 2 +- .../test/lux/tool/compiler/language/lux/syntax.lux | 2 +- stdlib/source/test/lux/type.lux | 4 +- stdlib/source/test/lux/type/abstract.lux | 6 +- stdlib/source/test/lux/type/check.lux | 2 +- stdlib/source/test/lux/type/dynamic.lux | 2 +- stdlib/source/test/lux/type/implicit.lux | 2 +- stdlib/source/test/lux/type/quotient.lux | 4 +- stdlib/source/test/lux/type/refinement.lux | 2 +- stdlib/source/test/lux/type/resource.lux | 2 +- stdlib/source/test/lux/type/unit.lux | 2 +- stdlib/source/test/lux/type/variance.lux | 2 +- stdlib/source/test/lux/world.lux | 2 +- stdlib/source/test/lux/world/console.lux | 2 +- stdlib/source/test/lux/world/file.lux | 2 +- stdlib/source/test/lux/world/file/watch.lux | 2 +- stdlib/source/test/lux/world/input/keyboard.lux | 4 +- stdlib/source/test/lux/world/net/http/client.lux | 2 +- stdlib/source/test/lux/world/net/http/status.lux | 2 +- .../test/lux/world/output/video/resolution.lux | 4 +- stdlib/source/test/lux/world/program.lux | 2 +- stdlib/source/test/lux/world/shell.lux | 2 +- 769 files changed, 6452 insertions(+), 6111 deletions(-) (limited to 'stdlib') diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index e9b0278e5..ec1eac721 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -23,7 +23,7 @@ [dummy_location (9 #1 (0 #0))] #1) -## (type: #export Any +## (type: .public Any ## (Ex [a] a)) ("lux def" Any ("lux type check type" @@ -37,7 +37,7 @@ (0 #0)))] #1) -## (type: #export Nothing +## (type: .public Nothing ## (All [a] a)) ("lux def" Nothing ("lux type check type" @@ -51,7 +51,7 @@ (0 #0)))] #1) -## (type: #export (List a) +## (type: .public (List a) ## #End ## (#Item a (List a))) ("lux def type tagged" List @@ -156,7 +156,7 @@ #End))] #1) -## (type: #export (Maybe a) +## (type: .public (Maybe a) ## #None ## (#Some a)) ("lux def type tagged" Maybe @@ -175,7 +175,7 @@ ["None" "Some"] #1) -## (type: #export #rec Type +## (type: .public #rec Type ## (#Primitive Text (List Type)) ## (#Sum Type Type) ## (#Product Type Type) @@ -229,7 +229,7 @@ ["Primitive" "Sum" "Product" "Function" "Parameter" "Var" "Ex" "UnivQ" "ExQ" "Apply" "Named"] #1) -## (type: #export Location +## (type: .public Location ## {#module Text ## #line Nat ## #column Nat}) @@ -243,7 +243,7 @@ ["module" "line" "column"] #1) -## (type: #export (Ann m v) +## (type: .public (Ann m v) ## {#meta m ## #datum v}) ("lux def type tagged" Ann @@ -261,7 +261,7 @@ ["meta" "datum"] #1) -## (type: #export (Code' w) +## (type: .public (Code' w) ## (#Bit Bit) ## (#Nat Nat) ## (#Int Int) @@ -313,7 +313,7 @@ ["Bit" "Nat" "Int" "Rev" "Frac" "Text" "Identifier" "Tag" "Form" "Tuple" "Record"] #1) -## (type: #export Code +## (type: .public Code ## (Ann Location (Code' (Ann Location)))) ("lux def" Code (#Named ["library/lux" "Code"] @@ -326,6 +326,38 @@ #End))] #1) +("lux def" private + #0 + [dummy_location + (#Record (#Item [[dummy_location (#Tag ["library/lux" "doc"])] + [dummy_location (#Text "The export policy for private/local definitions.")]] + #End))] + #1) + +("lux def" public + #1 + [dummy_location + (#Record (#Item [[dummy_location (#Tag ["library/lux" "doc"])] + [dummy_location (#Text "The export policy for public/global definitions.")]] + #End))] + #1) + +("lux def" local + #0 + [dummy_location + (#Record (#Item [[dummy_location (#Tag ["library/lux" "doc"])] + [dummy_location (#Text "The export policy for private/local definitions.")]] + #End))] + #1) + +("lux def" global + #1 + [dummy_location + (#Record (#Item [[dummy_location (#Tag ["library/lux" "doc"])] + [dummy_location (#Text "The export policy for public/global definitions.")]] + #End))] + #1) + ("lux def" _ann ("lux type check" (#Function (#Apply (#Apply Location Ann) @@ -414,7 +446,7 @@ [dummy_location (#Record #End)] #0) -## (type: #export Definition +## (type: .public Definition ## [Bit Type Code Any]) ("lux def" Definition ("lux type check type" @@ -425,7 +457,7 @@ #End)) #1) -## (type: #export Alias +## (type: .public Alias ## Name) ("lux def" Alias ("lux type check type" @@ -434,7 +466,7 @@ (record$ #End) #1) -## (type: #export Global +## (type: .public Global ## (#Alias Alias) ## (#Definition Definition)) ("lux def type tagged" Global @@ -447,7 +479,7 @@ ["Alias" "Definition"] #1) -## (type: #export (Bindings k v) +## (type: .public (Bindings k v) ## {#counter Nat ## #mappings (List [k v])}) ("lux def type tagged" Bindings @@ -466,7 +498,7 @@ ["counter" "mappings"] #1) -## (type: #export Ref +## (type: .public Ref ## (#Local Nat) ## (#Captured Nat)) ("lux def type tagged" Ref @@ -479,7 +511,7 @@ ["Local" "Captured"] #1) -## (type: #export Scope +## (type: .public Scope ## {#name (List Text) ## #inner Nat ## #locals (Bindings Text [Type Nat]) @@ -504,7 +536,7 @@ (record$ #End) #0) -## (type: #export (Either l r) +## (type: .public (Either l r) ## (#Left l) ## (#Right r)) ("lux def type tagged" Either @@ -523,7 +555,7 @@ ["Left" "Right"] #1) -## (type: #export Source +## (type: .public Source ## [Location Nat Text]) ("lux def" Source ("lux type check type" @@ -532,7 +564,7 @@ (record$ #End) #1) -## (type: #export Module_State +## (type: .public Module_State ## #Active ## #Compiled ## #Cached) @@ -550,7 +582,7 @@ ["Active" "Compiled" "Cached"] #1) -## (type: #export Module +## (type: .public Module ## {#module_hash Nat ## #module_aliases (List [Text Text]) ## #definitions (List [Text Global]) @@ -592,7 +624,7 @@ ["module_hash" "module_aliases" "definitions" "imports" "tags" "types" "module_annotations" "module_state"] #1) -## (type: #export Type_Context +## (type: .public Type_Context ## {#ex_counter Nat ## #var_counter Nat ## #var_bindings (List [Nat (Maybe Type)])}) @@ -609,7 +641,7 @@ ["ex_counter" "var_counter" "var_bindings"] #1) -## (type: #export Mode +## (type: .public Mode ## #Build ## #Eval ## #Interpreter) @@ -627,7 +659,7 @@ ["Build" "Eval" "Interpreter"] #1) -## (type: #export Info +## (type: .public Info ## {#target Text ## #version Text ## #mode Mode}) @@ -647,7 +679,7 @@ ["target" "version" "mode"] #1) -## (type: #export Lux +## (type: .public Lux ## {#info Info ## #source Source ## #location Location @@ -696,7 +728,7 @@ ["info" "source" "location" "current_module" "modules" "scopes" "type_context" "expected" "seed" "scope_type_vars" "extensions" "host"] #1) -## (type: #export (Meta a) +## (type: .public (Meta a) ## (-> Lux (Either Text [Lux a]))) ("lux def" Meta ("lux type check type" @@ -714,7 +746,7 @@ #End))) #1) -## (type: #export Macro' +## (type: .public Macro' ## (-> (List Code) (Meta (List Code)))) ("lux def" Macro' ("lux type check type" @@ -723,7 +755,7 @@ (record$ #End) #1) -## (type: #export Macro +## (type: .public Macro ## (primitive "#Macro")) ("lux def" Macro ("lux type check type" @@ -839,9 +871,9 @@ #0) ("lux def" as_def - ("lux type check" (#Function Code (#Function Code (#Function Code (#Function Bit Code)))) - (function'' [name value annotations exported?] - (form$ (#Item (text$ "lux def") (#Item name (#Item value (#Item annotations (#Item (bit$ exported?) #End)))))))) + ("lux type check" (#Function Code (#Function Code (#Function Code (#Function Code Code)))) + (function'' [name value annotations export_policy] + (form$ (#Item (text$ "lux def") (#Item name (#Item value (#Item annotations (#Item export_policy #End)))))))) (record$ #End) #0) @@ -874,39 +906,22 @@ ("lux def" def:'' ("lux macro" (function'' [tokens] - ({(#Item [[_ (#Tag ["" "export"])] + ({(#Item [export_policy (#Item [[_ (#Form (#Item [name args]))] (#Item [meta (#Item [type (#Item [body #End])])])])]) (in_meta (#Item [(as_def name (as_checked type (as_function name args body)) (form$ (#Item (identifier$ ["library/lux" "record$"]) (#Item meta #End))) - #1) + export_policy) #End])) - (#Item [[_ (#Tag ["" "export"])] (#Item [name (#Item [meta (#Item [type (#Item [body #End])])])])]) + (#Item [export_policy (#Item [name (#Item [meta (#Item [type (#Item [body #End])])])])]) (in_meta (#Item [(as_def name (as_checked type body) (form$ (#Item (identifier$ ["library/lux" "record$"]) (#Item meta #End))) - #1) - #End])) - - (#Item [[_ (#Form (#Item [name args]))] - (#Item [meta (#Item [type (#Item [body #End])])])]) - (in_meta (#Item [(as_def name (as_checked type (as_function name args body)) - (form$ (#Item (identifier$ ["library/lux" "record$"]) - (#Item meta - #End))) - #0) - #End])) - - (#Item [name (#Item [meta (#Item [type (#Item [body #End])])])]) - (in_meta (#Item [(as_def name (as_checked type body) - (form$ (#Item (identifier$ ["library/lux" "record$"]) - (#Item meta - #End))) - #0) + export_policy) #End])) _ @@ -918,28 +933,20 @@ ("lux def" macro:' ("lux macro" (function'' [tokens] - ({(#Item [_ (#Form (#Item name args))] (#Item body #End)) + ({(#Item export_policy (#Item [_ (#Form (#Item name args))] (#Item body #End))) (in_meta (#Item (as_def name (as_macro (as_function name args body)) (form$ (#Item (identifier$ ["library/lux" "record$"]) (#Item (tag$ ["library/lux" "End"]) #End))) - #0) + export_policy) #End)) - (#Item [_ (#Tag ["" "export"])] (#Item [_ (#Form (#Item name args))] (#Item body #End))) - (in_meta (#Item (as_def name (as_macro (as_function name args body)) - (form$ (#Item (identifier$ ["library/lux" "record$"]) - (#Item (tag$ ["library/lux" "End"]) - #End))) - #1) - #End)) - - (#Item [_ (#Tag ["" "export"])] (#Item [_ (#Form (#Item name args))] (#Item meta_data (#Item body #End)))) + (#Item export_policy (#Item [_ (#Form (#Item name args))] (#Item meta_data (#Item body #End)))) (in_meta (#Item (as_def name (as_macro (as_function name args body)) (form$ (#Item (identifier$ ["library/lux" "record$"]) (#Item meta_data #End))) - #1) + export_policy) #End)) _ @@ -948,7 +955,7 @@ (record$ #.End) #0) -(macro:' #export (comment tokens) +(macro:' .public (comment tokens) (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "## Throws away any code given to it." __paragraph) @@ -958,7 +965,7 @@ #End) (in_meta #End)) -(macro:' ($' tokens) +(macro:' .private ($' tokens) ({(#Item x #End) (in_meta tokens) @@ -973,7 +980,7 @@ (failure "Wrong syntax for $'")} tokens)) -(def:'' (list\map f xs) +(def:'' .private (list\map f xs) #End (#UnivQ #End (#UnivQ #End @@ -987,12 +994,12 @@ (#Item (f x) (list\map f xs'))} xs)) -(def:'' Replacement_Environment +(def:'' .private Replacement_Environment #End Type ($' List (#Product Text Code))) -(def:'' (replacement_environment xs ys) +(def:'' .private (replacement_environment xs ys) #End (#Function ($' List Text) (#Function ($' List Code) Replacement_Environment)) ({[(#Item x xs') (#Item y ys')] @@ -1002,12 +1009,12 @@ #End} [xs ys])) -(def:'' (text\= reference sample) +(def:'' .private (text\= reference sample) #End (#Function Text (#Function Text Bit)) ("lux text =" reference sample)) -(def:'' (replacement for environment) +(def:'' .private (replacement for environment) #End (#Function Text (#Function Replacement_Environment ($' Maybe Code))) ({#End @@ -1022,7 +1029,7 @@ (text\= k for))} environment)) -(def:'' (with_replacements reps syntax) +(def:'' .private (with_replacements reps syntax) #End (#Function Replacement_Environment (#Function Code Code)) ({[_ (#Identifier "" name)] @@ -1051,7 +1058,7 @@ syntax} syntax)) -(def:'' (n/* param subject) +(def:'' .private (n/* param subject) #.End (#Function Nat (#Function Nat Nat)) ("lux type as" Nat @@ -1059,7 +1066,7 @@ ("lux type as" Int param) ("lux type as" Int subject)))) -(def:'' (nested_quantification code) +(def:'' .private (nested_quantification code) #End (#Function Code Code) ({[_ (#Tuple members)] @@ -1082,7 +1089,7 @@ code} code)) -(def:'' (quantified_args_parser args next) +(def:'' .private (quantified_args_parser args next) #End ## (-> (List Code) (-> (List Text) (Meta (List Code))) (Meta (List Code))) (#Function ($' List Code) @@ -1099,12 +1106,12 @@ (failure "Expected identifier.")} args)) -(def:'' (type_parameter idx) +(def:'' .private (type_parameter idx) #End (#Function Nat Code) (form$ (#Item (tag$ ["library/lux" "Parameter"]) (#Item (nat$ idx) #End)))) -(def:'' (list\fold f init xs) +(def:'' .private (list\fold f init xs) #End ## (All [a b] (-> (-> b a a) a (List b) a)) (#UnivQ #End (#UnivQ #End (#Function (#Function (#Parameter 1) @@ -1120,13 +1127,13 @@ (list\fold f (f x init) xs')} xs)) -(def:'' (list\size list) +(def:'' .private (list\size list) #End (#UnivQ #End (#Function ($' List (#Parameter 1)) Nat)) (list\fold (function'' [_ acc] ("lux i64 +" 1 acc)) 0 list)) -(macro:' #export (All tokens) +(macro:' .public (All tokens) (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "## Universal quantification." __paragraph) @@ -1171,7 +1178,7 @@ (failure "Wrong syntax for All")} tokens))) -(macro:' #export (Ex tokens) +(macro:' .public (Ex tokens) (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "## Existential quantification." __paragraph) @@ -1216,7 +1223,7 @@ (failure "Wrong syntax for Ex")} tokens))) -(def:'' (list\reverse list) +(def:'' .private (list\reverse list) #End (All [a] (#Function ($' List a) ($' List a))) (list\fold ("lux type check" (All [a] (#Function a (#Function ($' List a) ($' List a)))) @@ -1224,7 +1231,7 @@ #End list)) -(macro:' #export (-> tokens) +(macro:' .public (-> tokens) (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "## Function types:" __paragraph) @@ -1243,7 +1250,7 @@ (failure "Wrong syntax for ->")} (list\reverse tokens))) -(macro:' #export (list xs) +(macro:' .public (list xs) (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "## List-construction macro." __paragraph) @@ -1257,7 +1264,7 @@ (list\reverse xs)) #End))) -(macro:' #export (list& xs) +(macro:' .public (list& xs) (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "## List-construction macro, with the last element being a tail-list." __paragraph) @@ -1276,7 +1283,7 @@ (failure "Wrong syntax for list&")} (list\reverse xs))) -(macro:' #export (Tuple tokens) +(macro:' .public (Tuple tokens) (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "## Tuple types:" __paragraph) @@ -1295,7 +1302,7 @@ prevs)))} (list\reverse tokens))) -(macro:' #export (Variant tokens) +(macro:' .public (Variant tokens) (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "## Variant types:" __paragraph) @@ -1314,7 +1321,7 @@ prevs)))} (list\reverse tokens))) -(macro:' (function' tokens) +(macro:' .private (function' tokens) (let'' [name tokens'] ({(#Item [[_ (#Identifier ["" name])] tokens']) [name tokens'] @@ -1340,8 +1347,8 @@ (failure "Wrong syntax for function'")} tokens'))) -(macro:' (def:''' tokens) - ({(#Item [[_ (#Tag ["" "export"])] +(macro:' .private (def:''' tokens) + ({(#Item [export_policy (#Item [[_ (#Form (#Item [name args]))] (#Item [meta (#Item [type (#Item [body #End])])])])]) (in_meta (list (form$ (list (text$ "lux def") @@ -1355,9 +1362,9 @@ (form$ (#Item (identifier$ ["library/lux" "record$"]) (#Item meta #End))) - (bit$ #1))))) + export_policy)))) - (#Item [[_ (#Tag ["" "export"])] (#Item [name (#Item [meta (#Item [type (#Item [body #End])])])])]) + (#Item [export_policy (#Item [name (#Item [meta (#Item [type (#Item [body #End])])])])]) (in_meta (list (form$ (list (text$ "lux def") name (form$ (list (text$ "lux type check") @@ -1366,47 +1373,23 @@ (form$ (#Item (identifier$ ["library/lux" "record$"]) (#Item meta #End))) - (bit$ #1))))) - - (#Item [[_ (#Form (#Item [name args]))] - (#Item [meta (#Item [type (#Item [body #End])])])]) - (in_meta (list (form$ (list (text$ "lux def") - name - (form$ (list (text$ "lux type check") - type - (form$ (list (identifier$ ["library/lux" "function'"]) - name - (tuple$ args) - body)))) - (form$ (#Item (identifier$ ["library/lux" "record$"]) - (#Item meta - #End))) - (bit$ #0))))) - - (#Item [name (#Item [meta (#Item [type (#Item [body #End])])])]) - (in_meta (list (form$ (list (text$ "lux def") - name - (form$ (list (text$ "lux type check") type body)) - (form$ (#Item (identifier$ ["library/lux" "record$"]) - (#Item meta - #End))) - (bit$ #0))))) + export_policy)))) _ (failure "Wrong syntax for def:'''")} tokens)) -(def:''' #export Or +(def:''' .public Or #End Macro ..Variant) -(def:''' #export And +(def:''' .public And #End Macro ..Tuple) -(def:''' (pairs xs) +(def:''' .private (pairs xs) #End (All [a] (-> ($' List a) ($' List (Tuple a a)))) ({(#Item x (#Item y xs')) @@ -1416,7 +1399,7 @@ #End} xs)) -(macro:' (let' tokens) +(macro:' .private (let' tokens) ({(#Item [[_ (#Tuple bindings)] (#Item [body #End])]) (in_meta (list (list\fold ("lux type check" (-> (Tuple Code Code) Code Code) @@ -1431,7 +1414,7 @@ (failure "Wrong syntax for let'")} tokens)) -(def:''' (any? p xs) +(def:''' .private (any? p xs) #End (All [a] (-> (-> a Bit) ($' List a) Bit)) @@ -1444,13 +1427,13 @@ (p x))} xs)) -(def:''' (with_location content) +(def:''' .private (with_location content) #End (-> Code Code) (tuple$ (list (tuple$ (list (text$ "") (nat$ 0) (nat$ 0))) content))) -(def:''' (untemplated_list tokens) +(def:''' .private (untemplated_list tokens) #End (-> ($' List Code) Code) ({#End @@ -1460,7 +1443,7 @@ (_ann (#Form (list (_ann (#Tag ["library/lux" "Item"])) token (untemplated_list tokens'))))} tokens)) -(def:''' (list\compose xs ys) +(def:''' .private (list\compose xs ys) #End (All [a] (-> ($' List a) ($' List a) ($' List a))) ({(#Item x xs') @@ -1470,7 +1453,7 @@ ys} xs)) -(def:''' (right_associativity op a1 a2) +(def:''' .private (right_associativity op a1 a2) #End (-> Code Code Code Code) ({[_ (#Form parts)] @@ -1480,14 +1463,14 @@ (form$ (list op a1 a2))} op)) -(def:''' (function\flip func) +(def:''' .private (function\flip func) #End (All [a b c] (-> (-> a b c) (-> b a c))) (function' [right left] (func left right))) -(macro:' #export (_$ tokens) +(macro:' .public (_$ tokens) (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "## Left-association for the application of binary functions over variadic arguments." ..\n) @@ -1509,7 +1492,7 @@ (failure "Wrong syntax for _$")} tokens)) -(macro:' #export ($_ tokens) +(macro:' .public ($_ tokens) (#Item [(tag$ ["library/lux" "doc"]) (text$ ("lux text concat" ("lux text concat" "## Right-association for the application of binary functions over variadic arguments." ..\n) @@ -1547,7 +1530,7 @@ ["in" "bind"] #0) -(def:''' maybe_monad +(def:''' .private maybe_monad #End ($' Monad Maybe) {#in @@ -1559,7 +1542,7 @@ (#Some a) (f a)} ma))}) -(def:''' meta_monad +(def:''' .private meta_monad #End ($' Monad Meta) {#in @@ -1577,7 +1560,7 @@ (f a state')} (ma state))))}) -(macro:' (do tokens) +(macro:' .private (do tokens) ({(#Item monad (#Item [_ (#Tuple bindings)] (#Item body #End))) (let' [g!in (local_identifier$ "in") g!bind (local_identifier$ " bind ") @@ -1610,7 +1593,7 @@ (failure "Wrong syntax for do")} tokens)) -(def:''' (monad\map m f xs) +(def:''' .private (monad\map m f xs) #End ## (All [m a b] ## (-> (Monad m) (-> a (m b)) (List a) (m (List b)))) @@ -1630,7 +1613,7 @@ (in (#Item y ys)))} xs))) -(def:''' (monad\fold m f y xs) +(def:''' .private (monad\fold m f y xs) #End ## (All [m a b] ## (-> (Monad m) (-> a b (m b)) b (List a) (m b))) @@ -1650,7 +1633,7 @@ (monad\fold m f y' xs'))} xs))) -(macro:' #export (if tokens) +(macro:' .public (if tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "Picks which expression to evaluate based on a bit test value." __paragraph @@ -1665,12 +1648,12 @@ (failure "Wrong syntax for if")} tokens)) -(def:''' PList +(def:''' .private PList #End Type (All [a] ($' List (Tuple Text a)))) -(def:''' (get k plist) +(def:''' .private (get k plist) #End (All [a] (-> Text ($' PList a) ($' Maybe a))) @@ -1683,7 +1666,7 @@ #None} plist)) -(def:''' (put k v dict) +(def:''' .private (put k v dict) #End (All [a] (-> Text a ($' PList a) ($' PList a))) @@ -1696,12 +1679,12 @@ (#Item [[k' v'] (put k v dict')]))} dict)) -(def:''' (text\compose x y) +(def:''' .private (text\compose x y) #End (-> Text Text Text) ("lux text concat" x y)) -(def:''' (name\encode full_name) +(def:''' .private (name\encode full_name) #End (-> Name Text) (let' [[module name] full_name] @@ -1709,7 +1692,7 @@ _ ($_ text\compose module "." name)} module))) -(def:''' (get_meta tag def_meta) +(def:''' .private (get_meta tag def_meta) #End (-> Name Code ($' Maybe Code)) (let' [[prefix name] tag] @@ -1736,7 +1719,7 @@ #None} def_meta))) -(def:''' (global_identifier full_name state) +(def:''' .private (global_identifier full_name state) #End (-> Name ($' Meta Name)) (let' [[module name] full_name @@ -1761,7 +1744,7 @@ (#Left ($_ text\compose "Unknown module: " module " @ " (name\encode full_name)))} (get module modules)))) -(def:''' (code_list expression) +(def:''' .private (code_list expression) #End (-> Code Code) (let' [type (form$ (list (tag$ ["library/lux" "Apply"]) @@ -1769,7 +1752,7 @@ (identifier$ ["library/lux" "List"])))] (form$ (list (text$ "lux type check") type expression)))) -(def:''' (spliced replace? untemplate elems) +(def:''' .private (spliced replace? untemplate elems) #End (-> Bit (-> Code ($' Meta Code)) ($' List Code) ($' Meta Code)) ({#1 @@ -1809,12 +1792,12 @@ (in (untemplated_list =elems)))} replace?)) -(def:''' (untemplated_text value) +(def:''' .private (untemplated_text value) #End (-> Text Code) (with_location (form$ (list (tag$ ["library/lux" "Text"]) (text$ value))))) -(def:''' (untemplate replace? subst token) +(def:''' .private (untemplate replace? subst token) #End (-> Bit Text Code ($' Meta Code)) ({[_ [_ (#Bit value)]] @@ -1905,7 +1888,7 @@ (in (with_location (form$ (list (tag$ ["library/lux" "Record"]) (untemplated_list =fields))))))} [replace? token])) -(macro:' #export (primitive tokens) +(macro:' .public (primitive tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "## Macro to treat define new primitive types." __paragraph @@ -1921,7 +1904,7 @@ (failure "Wrong syntax for primitive")} tokens)) -(def:'' (current_module_name state) +(def:'' .private (current_module_name state) #End ($' Meta Text) ({{#info info #source source #current_module current_module #modules modules @@ -1936,7 +1919,7 @@ current_module)} state)) -(macro:' #export (` tokens) +(macro:' .public (` tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "## Hygienic quasi-quotation as a macro. Unquote (~) and unquote-splice (~+) must also be used as forms." __paragraph @@ -1954,7 +1937,7 @@ (failure "Wrong syntax for `")} tokens)) -(macro:' #export (`' tokens) +(macro:' .public (`' tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "## Unhygienic quasi-quotation as a macro. Unquote (~) and unquote-splice (~+) must also be used as forms." __paragraph @@ -1968,7 +1951,7 @@ (failure "Wrong syntax for `")} tokens)) -(macro:' #export (' tokens) +(macro:' .public (' tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "## Quotation as a macro." __paragraph @@ -1982,7 +1965,7 @@ (failure "Wrong syntax for '")} tokens)) -(macro:' #export (|> tokens) +(macro:' .public (|> tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "## Piping macro." __paragraph @@ -2008,7 +1991,7 @@ (failure "Wrong syntax for |>")} tokens)) -(macro:' #export (<| tokens) +(macro:' .public (<| tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "## Reverse piping macro." __paragraph @@ -2034,14 +2017,14 @@ (failure "Wrong syntax for <|")} (list\reverse tokens))) -(def:''' (compose f g) +(def:''' .private (compose f g) (list [(tag$ ["library/lux" "doc"]) (text$ "Function composition.")]) (All [a b c] (-> (-> b c) (-> a b) (-> a c))) (function' [x] (f (g x)))) -(def:''' (get_name x) +(def:''' .private (get_name x) #End (-> Code ($' Maybe Name)) ({[_ (#Identifier sname)] @@ -2051,7 +2034,7 @@ #None} x)) -(def:''' (get_tag x) +(def:''' .private (get_tag x) #End (-> Code ($' Maybe Name)) ({[_ (#Tag sname)] @@ -2061,7 +2044,7 @@ #None} x)) -(def:''' (get_short x) +(def:''' .private (get_short x) #End (-> Code ($' Maybe Text)) ({[_ (#Identifier "" sname)] @@ -2071,7 +2054,7 @@ #None} x)) -(def:''' (tuple_list tuple) +(def:''' .private (tuple_list tuple) #End (-> Code ($' Maybe ($' List Code))) ({[_ (#Tuple members)] @@ -2081,7 +2064,7 @@ #None} tuple)) -(def:''' (apply_template env template) +(def:''' .private (apply_template env template) #End (-> Replacement_Environment Code Code) ({[_ (#Identifier "" sname)] @@ -2109,28 +2092,28 @@ template} template)) -(def:''' (every? p xs) +(def:''' .private (every? p xs) #End (All [a] (-> (-> a Bit) ($' List a) Bit)) (list\fold (function' [_2 _1] (if _1 (p _2) #0)) #1 xs)) -(def:''' (high_bits value) +(def:''' .private (high_bits value) (list) (-> ($' I64 Any) I64) ("lux i64 right-shift" 32 value)) -(def:''' low_mask +(def:''' .private low_mask (list) I64 (|> 1 ("lux i64 left-shift" 32) ("lux i64 -" 1))) -(def:''' (low_bits value) +(def:''' .private (low_bits value) (list) (-> ($' I64 Any) I64) ("lux i64 and" low_mask value)) -(def:''' (n/< reference sample) +(def:''' .private (n/< reference sample) (list) (-> Nat Nat Bit) (let' [referenceH (high_bits reference) @@ -2143,25 +2126,25 @@ (low_bits sample)) #0)))) -(def:''' (n/<= reference sample) +(def:''' .private (n/<= reference sample) (list) (-> Nat Nat Bit) (if (n/< reference sample) #1 ("lux i64 =" reference sample))) -(def:''' (list\join xs) +(def:''' .private (list\join xs) #End (All [a] (-> ($' List ($' List a)) ($' List a))) (list\fold list\compose #End (list\reverse xs))) -(macro:' #export (template tokens) +(macro:' .public (template tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "## By specifying a pattern (with holes), and the input data to fill those holes, repeats the pattern as many times as necessary." __paragraph "(template [ ]" ..\n - " " "[(def: #export (-> Int Int) (+ ))]" __paragraph + " " "[(def: .public (-> Int Int) (+ ))]" __paragraph " " "[inc +1]" ..\n " " "[dec -1]"))]) ({(#Item [[_ (#Tuple bindings)] (#Item [[_ (#Tuple templates)] data])]) @@ -2186,7 +2169,7 @@ (failure "Wrong syntax for template")} tokens)) -(def:''' (n// param subject) +(def:''' .private (n// param subject) (list) (-> Nat Nat Nat) (if ("lux i64 <" +0 ("lux type as" Int param)) @@ -2205,7 +2188,7 @@ quotient ("lux i64 +" 1 quotient))))) -(def:''' (n/% param subject) +(def:''' .private (n/% param subject) (list) (-> Nat Nat Nat) (let' [flat ("lux i64 *" @@ -2213,19 +2196,19 @@ ("lux type as" Int (n// param subject)))] ("lux i64 -" flat subject))) -(def:''' (n/min left right) +(def:''' .private (n/min left right) (list) (-> Nat Nat Nat) (if (n/< right left) left right)) -(def:''' (bit\encode x) +(def:''' .private (bit\encode x) #End (-> Bit Text) (if x "#1" "#0")) -(def:''' (digit::format digit) +(def:''' .private (digit::format digit) #End (-> Nat Text) ({0 "0" @@ -2235,7 +2218,7 @@ _ ("lux io error" "@digit::format Undefined behavior.")} digit)) -(def:''' (nat\encode value) +(def:''' .private (nat\encode value) #End (-> Nat Text) ({0 @@ -2252,14 +2235,14 @@ (loop value ""))} value)) -(def:''' (int\abs value) +(def:''' .private (int\abs value) #End (-> Int Int) (if ("lux i64 <" +0 value) ("lux i64 *" -1 value) value)) -(def:''' (int\encode value) +(def:''' .private (int\encode value) #End (-> Int Text) (if ("lux i64 =" +0 value) @@ -2277,17 +2260,17 @@ (|> value ("lux i64 /" +10) int\abs) (|> value ("lux i64 %" +10) int\abs ("lux type as" Nat) digit::format))))) -(def:''' (frac\encode x) +(def:''' .private (frac\encode x) #End (-> Frac Text) ("lux f64 encode" x)) -(def:''' (multiple? div n) +(def:''' .private (multiple? div n) #End (-> Nat Nat Bit) (|> n (n/% div) ("lux i64 =" 0))) -(def:''' #export (not x) +(def:''' .public (not x) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "## Bit negation." __paragraph @@ -2296,7 +2279,7 @@ (-> Bit Bit) (if x #0 #1)) -(def:''' (macro_type? type) +(def:''' .private (macro_type? type) (list) (-> Type Bit) ({(#Named ["library/lux" "Macro"] (#Primitive "#Macro" #End)) @@ -2306,7 +2289,7 @@ #0} type)) -(def:''' (macro' modules current_module module name) +(def:''' .private (macro' modules current_module module name) #End (-> ($' List (Tuple Text Module)) Text Text Text @@ -2328,7 +2311,7 @@ #None)} ("lux type check" Global gdef)))) -(def:''' (normal name) +(def:''' .private (normal name) #End (-> Name ($' Meta Name)) ({["" name] @@ -2340,7 +2323,7 @@ (in_meta name)} name)) -(def:''' (macro full_name) +(def:''' .private (macro full_name) #End (-> Name ($' Meta ($' Maybe Macro))) (do meta_monad @@ -2355,7 +2338,7 @@ (#Right state (macro' modules current_module module name))} state))))) -(def:''' (macro? name) +(def:''' .private (macro? name) #End (-> Name ($' Meta Bit)) (do meta_monad @@ -2365,7 +2348,7 @@ #None #0} output)))) -(def:''' (interpose sep xs) +(def:''' .private (interpose sep xs) #End (All [a] (-> a ($' List a) ($' List a))) @@ -2379,7 +2362,7 @@ (list& x sep (interpose sep xs'))} xs)) -(def:''' (single_expansion token) +(def:''' .private (single_expansion token) #End (-> Code ($' Meta ($' List Code))) ({[_ (#Form (#Item [_ (#Identifier name)] args))] @@ -2397,7 +2380,7 @@ (in_meta (list token))} token)) -(def:''' (expansion token) +(def:''' .private (expansion token) #End (-> Code ($' Meta ($' List Code))) ({[_ (#Form (#Item [_ (#Identifier name)] args))] @@ -2418,7 +2401,7 @@ (in_meta (list token))} token)) -(def:''' (full_expansion syntax) +(def:''' .private (full_expansion syntax) #End (-> Code ($' Meta ($' List Code))) ({[_ (#Form (#Item [_ (#Identifier name)] args))] @@ -2467,7 +2450,7 @@ (in_meta (list syntax))} syntax)) -(def:''' (normal_type type) +(def:''' .private (normal_type type) #End (-> Code Code) ({[_ (#Form (#Item [_ (#Tag tag)] parts))] @@ -2495,7 +2478,7 @@ type} type)) -(macro:' #export (type tokens) +(macro:' .public (type tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "## Takes a type expression and returns its representation as data-structure." __paragraph @@ -2514,7 +2497,7 @@ (failure "Wrong syntax for type")} tokens)) -(macro:' #export (: tokens) +(macro:' .public (: tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "## The type-annotation macro." __paragraph @@ -2526,7 +2509,7 @@ (failure "Wrong syntax for :")} tokens)) -(macro:' #export (:as tokens) +(macro:' .public (:as tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "## The type-coercion macro." __paragraph @@ -2538,7 +2521,7 @@ (failure "Wrong syntax for :as")} tokens)) -(def:''' (empty? xs) +(def:''' .private (empty? xs) #End (All [a] (-> ($' List a) Bit)) ({#End #1 @@ -2546,7 +2529,7 @@ xs)) (template [ ] - [(def:''' ( xy) + [(def:''' .private ( xy) #End (All [a b] (-> (Tuple a b) )) (let' [[x y] xy] ))] @@ -2554,7 +2537,7 @@ [first a x] [second b y]) -(def:''' (type_declaration type_codes) +(def:''' .private (type_declaration type_codes) #End (-> ($' List Code) ($' Meta (Tuple Code ($' Maybe ($' List Text))))) ({(#Item [_ (#Record pairs)] #End) @@ -2608,7 +2591,7 @@ (failure "Improper type-definition syntax")} type_codes)) -(def:''' (gensym prefix state) +(def:''' .private (gensym prefix state) #End (-> Text ($' Meta Code)) ({{#info info #source source #current_module _ #modules modules @@ -2624,7 +2607,7 @@ (local_identifier$ ($_ text\compose "__gensym__" prefix (nat\encode seed))))} state)) -(macro:' #export (Rec tokens) +(macro:' .public (Rec tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "## Parameter-less recursive types." __paragraph @@ -2640,7 +2623,7 @@ (failure "Wrong syntax for Rec")} tokens)) -(macro:' #export (exec tokens) +(macro:' .public (exec tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "## Sequential execution of expressions (great for side-effects)." __paragraph @@ -2661,30 +2644,24 @@ (failure "Wrong syntax for exec")} (list\reverse tokens))) -(macro:' (def:' tokens) - (let' [[export? tokens'] ({(#Item [_ (#Tag ["" "export"])] tokens') - [#1 tokens'] - - _ - [#0 tokens]} - tokens) - parts (: (Maybe [Code (List Code) (Maybe Code) Code]) - ({(#Item [_ (#Form (#Item name args))] (#Item type (#Item body #End))) - (#Some name args (#Some type) body) +(macro:' .private (def:' tokens) + (let' [parts (: (Maybe [Code Code (List Code) (Maybe Code) Code]) + ({(#Item export_policy (#Item [_ (#Form (#Item name args))] (#Item type (#Item body #End)))) + (#Some [export_policy name args (#Some type) body]) - (#Item name (#Item type (#Item body #End))) - (#Some name #End (#Some type) body) + (#Item export_policy (#Item name (#Item type (#Item body #End)))) + (#Some [export_policy name #End (#Some type) body]) - (#Item [_ (#Form (#Item name args))] (#Item body #End)) - (#Some name args #None body) + (#Item export_policy (#Item [_ (#Form (#Item name args))] (#Item body #End))) + (#Some [export_policy name args #None body]) - (#Item name (#Item body #End)) - (#Some name #End #None body) + (#Item export_policy (#Item name (#Item body #End))) + (#Some [export_policy name #End #None body]) _ #None} - tokens'))] - ({(#Some name args ?type body) + tokens))] + ({(#Some [export_policy name args ?type body]) (let' [body' ({#End body @@ -2701,17 +2678,17 @@ (~ body'') [(~ location_code) (#.Record #.End)] - (~ (bit$ export?))))))) + (~ export_policy)))))) #None (failure "Wrong syntax for def'")} parts))) -(def:' (text\encode original) +(def:' .private (text\encode original) (-> Text Text) ($_ text\compose ..double_quote original ..double_quote)) -(def:' (code\encode code) +(def:' .private (code\encode code) (-> Code Text) ({[_ (#Bit value)] (bit\encode value) @@ -2764,7 +2741,7 @@ (list\fold text\compose "")) "}")} code)) -(def:' (expander branches) +(def:' .private (expander branches) (-> (List Code) (Meta (List Code))) ({(#Item [_ (#Form (#Item [_ (#Identifier name)] args))] (#Item body @@ -2797,7 +2774,7 @@ (list\fold text\compose ""))))} branches)) -(macro:' #export (case tokens) +(macro:' .public (case tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "## The pattern-matching macro." ..\n @@ -2816,7 +2793,7 @@ (failure "Wrong syntax for case")} tokens)) -(macro:' #export (^ tokens) +(macro:' .public (^ tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "## Macro-expanding patterns." ..\n @@ -2841,7 +2818,7 @@ _ (failure "Wrong syntax for ^ macro"))) -(macro:' #export (^or tokens) +(macro:' .public (^or tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "## Or-patterns." ..\n @@ -2870,7 +2847,7 @@ _ (failure "Wrong syntax for ^or"))) -(def:' (identifier? code) +(def:' .private (identifier? code) (-> Code Bit) (case code [_ (#Identifier _)] @@ -2879,7 +2856,7 @@ _ #0)) -(macro:' #export (let tokens) +(macro:' .public (let tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "## Creates local bindings." ..\n @@ -2905,7 +2882,7 @@ _ (failure "Wrong syntax for let"))) -(macro:' #export (function tokens) +(macro:' .public (function tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "## Syntax for creating functions." ..\n @@ -2937,7 +2914,7 @@ #None (failure "Wrong syntax for function"))) -(def:' (definition_annotation_value code) +(def:' .private (definition_annotation_value code) (-> Code Code) (case code [_ (#Bit value)] @@ -2980,7 +2957,7 @@ (meta_code ["library/lux" "Record"])) )) -(def:' (definition_annotations kvs) +(def:' .private (definition_annotations kvs) (-> (List [Code Code]) Code) (untemplated_list (list\map (: (-> [Code Code] Code) (function (_ [k v]) @@ -2988,40 +2965,189 @@ (~ (definition_annotation_value v))]))) kvs))) -(def:' (with_func_args args meta) +(def:' .private (with_function_parameters parameters meta) (-> (List Code) Code Code) - (case args + (case parameters #End meta _ (` (#.Item [[(~ location_code) (#.Tag ["library/lux" "func_args"])] - [(~ location_code) (#.Tuple (.list (~+ (list\map (function (_ arg) - (` [(~ location_code) (#.Text (~ (text$ (code\encode arg))))])) - args))))]] + [(~ location_code) (#.Tuple (.list (~+ (list\map (function (_ parameter) + (` [(~ location_code) (#.Text (~ (text$ (code\encode parameter))))])) + parameters))))]] (~ meta))))) -(def:' (with_type_args args) +(def:' .private (with_type_args args) (-> (List Code) Code) (` {#.type_args [(~+ (list\map (function (_ arg) (text$ (code\encode arg))) args))]})) -(def:' (export^ tokens) - (-> (List Code) [Bit (List Code)]) +(def:' .private (endP tokens) + (-> (List Code) (Maybe Any)) + (case tokens + (^ (list)) + (#.Some []) + + _ + #None)) + +(def:' .private (anyP tokens) + (-> (List Code) (Maybe [(List Code) Code])) + (case tokens + (^ (list& code tokens')) + (#Some [tokens' code]) + + _ + #.None)) + +(def:' .private (local_identifierP tokens) + (-> (List Code) (Maybe [(List Code) Text])) + (case tokens + (^ (list& [_ (#Identifier ["" local_identifier])] tokens')) + (#Some [tokens' local_identifier]) + + _ + #.None)) + +(template [ ] + [(def:' .private ( tokens) + (-> (List Code) (Maybe (List ))) + (case tokens + #End + (#.Some #End) + + _ + (do maybe_monad + [% ( tokens) + .let' [[tokens head] %] + tail ( tokens)] + (in (#Item head tail)))))] + + [parametersP Text local_identifierP] + [enhanced_parametersP Code anyP] + ) + +(template [ ] + [(def:' .private ( tokens) + (-> (List Code) (Maybe [(List Code) [Text (List )]])) + (case tokens + (^ (list& [_ (#Form local_declaration)] tokens')) + (do maybe_monad + [% (local_identifierP local_declaration) + .let' [[local_declaration name] %] + parameters ( local_declaration)] + (in [tokens' [name parameters]])) + + _ + (do maybe_monad + [% (local_identifierP tokens) + .let' [[tokens' name] %]] + (in [tokens' [name #End]]))))] + + [local_declarationP Text parametersP] + [enhanced_local_declarationP Code enhanced_parametersP] + ) + +(template [ ] + [(def:' .private ( tokens) + (-> (List Code) (Maybe [(List Code) [Code Text (List )]])) + (do maybe_monad + [% (anyP tokens) + .let' [[tokens export_policy] %] + % ( tokens) + .let' [[tokens [name parameters]] %]] + (in [tokens [export_policy name parameters]])))] + + [declarationP Text local_declarationP] + [enhanced_declarationP Code enhanced_local_declarationP] + ) + +(def:' .private (annotationsP tokens) + (-> (List Code) (Maybe [(List Code) (List [Code Code])])) (case tokens - (#Item [_ (#Tag [_ "export"])] tokens') - [#1 tokens'] + (^ (list& [_ (#Record annotations)] tokens')) + (#Some [tokens' annotations]) + + tokens' + #None)) + +(def:' .private (bodyP tokens) + (-> (List Code) (Maybe [(List Code) [(Maybe Code) Code]])) + (case tokens + ## TB + (^ (list& type body tokens')) + (#Some [tokens' [(#Some type) body]]) + + ## B + (^ (list& body tokens')) + (#Some [tokens' [#None body]]) _ - [#0 tokens])) + #None)) + +(macro:' .private (maybe\else' tokens) + (case tokens + (^ (list else then)) + (do meta_monad + [g!_ (gensym "g!_")] + (in (list (` (..case (~ then) + (#..Some (~ g!_)) + (#..Some (~ g!_)) -(def:' (export ?) - (-> Bit (List Code)) - (if ? - (list (' #export)) - (list))) + #..None + (~ else)))))) -(macro:' #export (def: tokens) + _ + (failure "Wrong syntax for maybe\else'"))) + +(def:' .private (definitionP tokens) + (-> (List Code) (Maybe [Code Text (List Code) (List [Code Code]) (Maybe Code) Code])) + (|> (do maybe_monad + [% (anyP tokens) + .let' [[tokens export_policy] %] + % (enhanced_local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (annotationsP tokens) + .let' [[tokens annotations] %] + % (bodyP tokens) + .let' [[tokens [?type body]] %] + _ (endP tokens)] + (in [export_policy name parameters annotations ?type body])) + ## (^ (list _export_policy _declaration _annotations _type _body)) + ## (^ (list _export_policy _declaration _annotations _body)) + (maybe\else' (do maybe_monad + [% (enhanced_local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (bodyP tokens) + .let' [[tokens [?type body]] %] + _ (endP tokens)] + (in [(` ..private) name parameters #End ?type body]))) + ## (^ (list _declaration _type _body)) + ## (^ (list _declaration _body)) + (maybe\else' (do maybe_monad + [% (enhanced_local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (annotationsP tokens) + .let' [[tokens annotations] %] + % (bodyP tokens) + .let' [[tokens [?type body]] %] + _ (endP tokens)] + (in [(` ..private) name parameters annotations ?type body]))) + ## (^ (list _declaration _annotations _type _body)) + ## (^ (list _declaration _annotations _body)) + (maybe\else' (do maybe_monad + [% (enhanced_declarationP tokens) + .let' [[tokens [export_policy name parameters]] %] + % (bodyP tokens) + .let' [[tokens [?type body]] %] + _ (endP tokens)] + (in [export_policy name parameters #End ?type body]))) + ## (^ (list _export_policy _declaration _type _body)) + ## (^ (list _export_policy _declaration _body)) + )) + +(macro:' .public (def: tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "## Defines global constants/functions." ..\n @@ -3033,67 +3159,40 @@ "(def: branching_exponent" ..\n " Int" ..\n " +5)"))]) - (let [[exported? tokens'] (export^ tokens) - parts (: (Maybe [Code (List Code) (Maybe Code) Code (List [Code Code])]) - (case tokens' - (^ (list [_ (#Form (#Item name args))] [_ (#Record meta_kvs)] type body)) - (#Some [name args (#Some type) body meta_kvs]) - - (^ (list name [_ (#Record meta_kvs)] type body)) - (#Some [name #End (#Some type) body meta_kvs]) - - (^ (list [_ (#Form (#Item name args))] [_ (#Record meta_kvs)] body)) - (#Some [name args #None body meta_kvs]) - - (^ (list name [_ (#Record meta_kvs)] body)) - (#Some [name #End #None body meta_kvs]) - - (^ (list [_ (#Form (#Item name args))] type body)) - (#Some [name args (#Some type) body #End]) - - (^ (list name type body)) - (#Some [name #End (#Some type) body #End]) - - (^ (list [_ (#Form (#Item name args))] body)) - (#Some [name args #None body #End]) - - (^ (list name body)) - (#Some [name #End #None body #End]) + (case (definitionP tokens) + (#Some [export_policy name parameters annotations ?type body]) + (let [body (case parameters + #End + body - _ - #None))] - (case parts - (#Some name args ?type body meta) - (let [body (case args - #End - body - - _ - (` (function ((~ name) (~+ args)) (~ body)))) - body (case ?type - (#Some type) - (` (: (~ type) (~ body))) - - #None - body) - =meta (definition_annotations meta)] - (in_meta (list (` ("lux def" (~ name) - (~ body) - [(~ location_code) - (#.Record (~ (with_func_args args =meta)))] - (~ (bit$ exported?))))))) - - #None - (failure "Wrong syntax for def:")))) + _ + (` (function ((~ (..local_identifier$ name)) (~+ parameters)) + (~ body)))) + body (case ?type + (#Some type) + (` (: (~ type) + (~ body))) + + #None + body) + =annotations (definition_annotations annotations)] + (in_meta (list (` ("lux def" (~ (..local_identifier$ name)) + (~ body) + [(~ location_code) + (#.Record (~ (with_function_parameters parameters =annotations)))] + (~ export_policy)))))) + + #None + (failure "Wrong syntax for def:"))) -(def: (with_definition_annotation addition meta) +(def: (with_definition_annotation addition annotations) (-> [Code Code] Code Code) - (case [addition meta] + (case [addition annotations] [[name value] [location (#Record pairs)]] [location (#Record (#Item [name value] pairs))] _ - meta)) + annotations)) (def: (merged_definition_annotations addition base) (-> Code Code Code) @@ -3104,11 +3203,53 @@ _ base)) -(macro:' #export (macro: tokens) +(def:' .private (macroP tokens) + (-> (List Code) (Maybe [Code Text (List Text) (List [Code Code]) Code])) + (|> (do maybe_monad + [% (anyP tokens) + .let' [[tokens export_policy] %] + % (local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (annotationsP tokens) + .let' [[tokens annotations] %] + % (anyP tokens) + .let' [[tokens body] %] + _ (endP tokens)] + (in [export_policy name parameters annotations body])) + ## (^ (list _export_policy _declaration _annotations _body)) + (maybe\else' (do maybe_monad + [% (local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (anyP tokens) + .let' [[tokens body] %] + _ (endP tokens)] + (in [(` ..private) name parameters #End body]))) + ## (^ (list _declaration _body)) + (maybe\else' (do maybe_monad + [% (local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (annotationsP tokens) + .let' [[tokens annotations] %] + % (anyP tokens) + .let' [[tokens body] %] + _ (endP tokens)] + (in [(` ..private) name parameters annotations body]))) + ## (^ (list _declaration _annotations _body)) + (maybe\else' (do maybe_monad + [% (declarationP tokens) + .let' [[tokens [export_policy name parameters]] %] + % (anyP tokens) + .let' [[tokens body] %] + _ (endP tokens)] + (in [export_policy name parameters #End body]))) + ## (^ (list _export_policy _declaration _body)) + )) + +(macro:' .public (macro: tokens) (list [(tag$ ["library/lux" "doc"]) (text$ ($_ "lux text concat" "## Macro-definition macro." ..\n - "(macro: #export (name_of tokens)" ..\n + "(macro: .public (name_of tokens)" ..\n " (case tokens" ..\n " (^template []" ..\n " [(^ (list [_ ( [prefix name])]))" ..\n @@ -3117,108 +3258,25 @@ __paragraph " _" ..\n " (failure ''Wrong syntax for name_of'')))"))]) - (let [[exported? tokens] (export^ tokens) - name+args+meta+body?? (: (Maybe [Name (List Code) (List [Code Code]) Code]) - (case tokens - (^ (list [_ (#Form (list& [_ (#Identifier name)] args))] body)) - (#Some [name args (list) body]) - - (^ (list [_ (#Identifier name)] body)) - (#Some [name #End (list) body]) - - (^ (list [_ (#Form (list& [_ (#Identifier name)] args))] [_ (#Record meta_rec_parts)] body)) - (#Some [name args meta_rec_parts body]) - - (^ (list [_ (#Identifier name)] [_ (#Record meta_rec_parts)] body)) - (#Some [name #End meta_rec_parts body]) - - _ - #None))] - (case name+args+meta+body?? - (#Some [name args meta body]) - (let [name (identifier$ name) - body (case args - #End - body + (case (macroP tokens) + (#Some [export_policy name args annotations body]) + (let [name (local_identifier$ name) + body (case args + #End + body - _ - (` ("lux macro" - (function ((~ name) (~+ args)) (~ body))))) - =meta (definition_annotations meta)] - (in_meta (list (` ("lux def" (~ name) - (~ body) - [(~ location_code) - (#Record (~ =meta))] - (~ (bit$ exported?))))))) - - #None - (failure "Wrong syntax for macro:")))) - -(macro: #export (interface: tokens) - {#.doc (text$ ($_ "lux text concat" - "## Definition of signatures ala ML." ..\n - "(interface: #export (Ord a)" ..\n - " (: (Equivalence a)" ..\n - " eq)" ..\n - " (: (-> a a Bit)" ..\n - " <)" ..\n - " (: (-> a a Bit)" ..\n - " <=)" ..\n - " (: (-> a a Bit)" ..\n - " >)" ..\n - " (: (-> a a Bit)" ..\n - " >=))"))} - (let [[exported? tokens'] (export^ tokens) - ?parts (: (Maybe [Name (List Code) Code (List Code)]) - (case tokens' - (^ (list& [_ (#Form (list& [_ (#Identifier name)] args))] [meta_rec_location (#Record meta_rec_parts)] sigs)) - (#Some name args [meta_rec_location (#Record meta_rec_parts)] sigs) - - (^ (list& [_ (#Identifier name)] [meta_rec_location (#Record meta_rec_parts)] sigs)) - (#Some name #End [meta_rec_location (#Record meta_rec_parts)] sigs) - - (^ (list& [_ (#Form (list& [_ (#Identifier name)] args))] sigs)) - (#Some name args (` {}) sigs) - - (^ (list& [_ (#Identifier name)] sigs)) - (#Some name #End (` {}) sigs) - - _ - #None))] - (case ?parts - (#Some name args meta sigs) - (do meta_monad - [name+ (normal name) - sigs' (monad\map meta_monad expansion sigs) - members (: (Meta (List [Text Code])) - (monad\map meta_monad - (: (-> Code (Meta [Text Code])) - (function (_ token) - (case token - (^ [_ (#Form (list [_ (#Text "lux type check")] type [_ (#Identifier ["" name])]))]) - (in [name type]) - - _ - (failure "Signatures require typed members!")))) - (list\join sigs'))) - .let [[_module _name] name+ - def_name (identifier$ name) - sig_type (record$ (list\map (: (-> [Text Code] [Code Code]) - (function (_ [module_name m_type]) - [(local_tag$ module_name) m_type])) - members)) - sig_meta (merged_definition_annotations (` {#.interface? #1}) - meta) - usage (case args - #End - def_name - - _ - (` ((~ def_name) (~+ args))))]] - (in_meta (list (` (..type: (~+ (export exported?)) (~ usage) (~ sig_meta) (~ sig_type)))))) - - #None - (failure "Wrong syntax for interface:")))) + _ + (` ("lux macro" + (function ((~ name) (~+ (list\map local_identifier$ args))) (~ body))))) + =annotations (definition_annotations annotations)] + (in_meta (list (` ("lux def" (~ name) + (~ body) + [(~ location_code) + (#Record (~ =annotations))] + (~ export_policy)))))) + + #.None + (failure "Wrong syntax for macro:"))) (def: (find f xs) (All [a b] @@ -3236,7 +3294,7 @@ (#Some y)))) (template [
] - [(macro: #export ( tokens) + [(macro: .public ( tokens) {#.doc } (case (list\reverse tokens) (^ (list& last init)) @@ -3255,7 +3313,7 @@ (-> Text Text (Maybe Nat)) ("lux text index" 0 part text)) -(def: #export (error! message) +(def: .public (error! message) {#.doc (text$ ($_ "lux text concat" "## Causes an error, with the given error message." ..\n "(error! ''OH NO!'')"))} @@ -3506,7 +3564,7 @@ #None (#Left "Not expecting any type."))))) -(macro: #export (implementation tokens) +(macro: .public (implementation tokens) {#.doc "Not meant to be used directly. Prefer 'implementation:'."} (do meta_monad [tokens' (monad\map meta_monad expansion tokens) @@ -3526,7 +3584,7 @@ (: (-> Code (Meta [Code Code])) (function (_ token) (case token - (^ [_ (#Form (list [_ (#Text "lux def")] [_ (#Identifier "" tag_name)] value meta [_ (#Bit #0)]))]) + (^ [_ (#Form (list [_ (#Text "lux def")] [_ (#Identifier "" tag_name)] value meta export_policy))]) (case (get tag_name tag_mappings) (#Some tag) (in [tag value]) @@ -3551,10 +3609,53 @@ head tail))) -(macro: #export (implementation: tokens) +(def: (remainderP tokens) + (-> (List Code) (Maybe (List Code))) + (case tokens + #End + #None + + _ + (#Item tokens))) + +(def:' .private (implementationP tokens) + (-> (List Code) (Maybe [Code Text (List Code) (List [Code Code]) Code (List Code)])) + (|> (do maybe_monad + [% (enhanced_declarationP tokens) + .let' [[tokens [export_policy name parameters]] %] + % (annotationsP tokens) + .let' [[tokens annotations] %] + % (anyP tokens) + .let' [[tokens type] %] + tokens (remainderP tokens)] + (in [export_policy name parameters annotations type tokens])) + ## (^ (list _export_policy _declaration _annotations _type _body)) + ## (^ (list _declaration _annotations _type _body)) + (maybe\else' (do maybe_monad + [% (enhanced_local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (anyP tokens) + .let' [[tokens type] %] + tokens (remainderP tokens)] + (in [(` ..private) name parameters #End type tokens]))) + ## (^ (list _declaration _type _body)) + (maybe\else' (do maybe_monad + [% (anyP tokens) + .let' [[tokens export_policy] %] + % (enhanced_local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (anyP tokens) + .let' [[tokens type] %] + tokens (remainderP tokens)] + (in [export_policy name parameters #End type tokens]))) + ## (^ (list _export_policy _declaration _type _body)) + )) + +(macro: .public (implementation: tokens) {#.doc (text$ ($_ "lux text concat" "## Definition of structures ala ML." ..\n - "(implementation: #export order (Order Int)" ..\n + "(implementation: .public order" ..\n + " (Order Int)" ..\n " (def: &equivalence equivalence)" ..\n " (def: (< test subject)" ..\n " (< test subject))" ..\n @@ -3566,135 +3667,207 @@ " (def: (>= test subject)" ..\n " (or (> test subject)" ..\n " (= test subject))))"))} - (let [[exported? tokens'] (export^ tokens) - ?parts (: (Maybe [Code (List Code) Code Code (List Code)]) - (case tokens' - (^ (list& [_ (#Form (list& name args))] [meta_rec_location (#Record meta_rec_parts)] type definitions)) - (#Some name args type [meta_rec_location (#Record meta_rec_parts)] definitions) - - (^ (list& name [meta_rec_location (#Record meta_rec_parts)] type definitions)) - (#Some name #End type [meta_rec_location (#Record meta_rec_parts)] definitions) + (case (implementationP tokens) + (#Some [export_policy name args annotations type definitions]) + (let [usage (case args + #End + (local_identifier$ name) - (^ (list& [_ (#Form (list& name args))] type definitions)) - (#Some name args type (` {}) definitions) - - (^ (list& name type definitions)) - (#Some name #End type (` {}) definitions) - - _ - #None))] - (case ?parts - (#Some [name args type meta definitions]) - (let [usage (case args - #End - name - - _ - (` ((~ name) (~+ args))))] - (in_meta (list (` (..def: (~+ (export exported?)) (~ usage) - (~ (merged_definition_annotations (` {#.implementation? #1}) - meta)) - (~ type) - (implementation (~+ definitions))))))) + _ + (` ((~ (local_identifier$ name)) (~+ args))))] + (in_meta (list (` (..def: (~ export_policy) (~ usage) + (~ (merged_definition_annotations (` {#.implementation? #1}) + (record$ annotations))) + (~ type) + (implementation (~+ definitions))))))) - #None - (failure "Wrong syntax for implementation:")))) + #None + (failure "Wrong syntax for implementation:"))) (def: (function\identity value) (All [a] (-> a a)) value) -(macro: #export (type: tokens) +(def: (recP tokens) + (-> (List Code) [(List Code) Bit]) + (case tokens + (^ (list& [_ (#Tag ["" "rec"])] tokens')) + [tokens' #1] + + _ + [tokens #0])) + +(def:' .private (typeP tokens) + (-> (List Code) (Maybe [Code Bit Text (List Text) (List [Code Code]) (List Code)])) + (|> (do maybe_monad + [% (anyP tokens) + .let' [[tokens export_policy] %] + .let' [[tokens rec?] (recP tokens)] + % (local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (annotationsP tokens) + .let' [[tokens annotations] %] + tokens (remainderP tokens)] + (in [export_policy rec? name parameters annotations tokens])) + ## (^ (list _export_policy _rec _declaration _annotations _body)) + ## (^ (list _export_policy _declaration _annotations _body)) + (maybe\else' (do maybe_monad + [.let' [[tokens rec?] (recP tokens)] + % (local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (annotationsP tokens) + .let' [[tokens annotations] %] + tokens (remainderP tokens)] + (in [(` ..private) rec? name parameters annotations tokens]))) + ## (^ (list _rec _declaration _annotations _body)) + ## (^ (list _declaration _annotations _body)) + (maybe\else' (do maybe_monad + [.let' [[tokens rec?] (recP tokens)] + % (local_declarationP tokens) + .let' [[tokens [name parameters]] %] + tokens (remainderP tokens)] + (in [(` ..private) rec? name parameters #End tokens]))) + ## (^ (list _rec _declaration _body)) + ## (^ (list _declaration _body)) + (maybe\else' (do maybe_monad + [% (anyP tokens) + .let' [[tokens export_policy] %] + .let' [[tokens rec?] (recP tokens)] + % (local_declarationP tokens) + .let' [[tokens [name parameters]] %] + tokens (remainderP tokens)] + (in [export_policy rec? name parameters #End tokens]))) + ## (^ (list _export_policy _rec _declaration _body)) + ## (^ (list _export_policy _declaration _body)) + )) + +(macro: .public (type: tokens) {#.doc (text$ ($_ "lux text concat" "## The type-definition macro." ..\n - "(type: (List a) #End (#Item a (List a)))"))} - (let [[exported? tokens'] (export^ tokens) - [rec? tokens'] (case tokens' - (#Item [_ (#Tag [_ "rec"])] tokens') - [#1 tokens'] + "(type: (List a)" ..\n + " {#.doc (doc (: (List Nat) (list 0 1 2 3)))}" ..\n + " #End" ..\n + " (#Item a (List a)))"))} + (case (typeP tokens) + (#Some [export_policy rec? name args meta type_codes]) + (do meta_monad + [type+tags?? (..type_declaration type_codes) + module_name current_module_name] + (let [type_name (local_identifier$ name) + [type tags??] type+tags?? + type' (: (Maybe Code) + (if rec? + (if (empty? args) + (let [g!param (local_identifier$ "") + prime_name (local_identifier$ name) + type+ (with_replacements (list [name (` ((~ prime_name) .Nothing))]) + type)] + (#Some (` ((All (~ prime_name) [(~ g!param)] (~ type+)) + .Nothing)))) + #None) + (case args + #End + (#Some type) _ - [#0 tokens']) - parts (: (Maybe [Text (List Code) (List [Code Code]) (List Code)]) - (case tokens' - (^ (list [_ (#Identifier "" name)] [meta_location (#Record meta_parts)] [type_location (#Record type_parts)])) - (#Some [name #End meta_parts (list [type_location (#Record type_parts)])]) - - (^ (list& [_ (#Identifier "" name)] [meta_location (#Record meta_parts)] type_code1 type_codes)) - (#Some [name #End meta_parts (#Item type_code1 type_codes)]) - - (^ (list& [_ (#Identifier "" name)] type_codes)) - (#Some [name #End (list) type_codes]) - - (^ (list [_ (#Form (#Item [_ (#Identifier "" name)] args))] [meta_location (#Record meta_parts)] [type_location (#Record type_parts)])) - (#Some [name args meta_parts (list [type_location (#Record type_parts)])]) - - (^ (list& [_ (#Form (#Item [_ (#Identifier "" name)] args))] [meta_location (#Record meta_parts)] type_code1 type_codes)) - (#Some [name args meta_parts (#Item type_code1 type_codes)]) + (#Some (` (.All (~ type_name) [(~+ (list\map local_identifier$ args))] (~ type))))))) + total_meta (let [meta (definition_annotations meta) + meta (if rec? + (` (#.Item (~ (flag_meta "type_rec?")) (~ meta))) + meta)] + (` [(~ location_code) + (#.Record (~ meta))]))] + (case type' + (#Some type'') + (let [typeC (` (#.Named [(~ (text$ module_name)) + (~ (text$ name))] + (.type (~ type''))))] + (in_meta (list (case tags?? + (#Some tags) + (` ("lux def type tagged" (~ type_name) + (~ typeC) + (~ total_meta) + [(~+ (list\map text$ tags))] + (~ export_policy))) + + _ + (` ("lux def" (~ type_name) + ("lux type check type" + (~ typeC)) + (~ total_meta) + (~ export_policy))))))) - (^ (list& [_ (#Form (#Item [_ (#Identifier "" name)] args))] type_codes)) - (#Some [name args (list) type_codes]) + #None + (failure "Wrong syntax for type:")))) - _ - #None))] - (case parts - (#Some name args meta type_codes) - (do meta_monad - [type+tags?? (..type_declaration type_codes) - module_name current_module_name] - (let [type_name (local_identifier$ name) - [type tags??] type+tags?? - type' (: (Maybe Code) - (if rec? - (if (empty? args) - (let [g!param (local_identifier$ "") - prime_name (local_identifier$ name) - type+ (with_replacements (list [name (` ((~ prime_name) .Nothing))]) - type)] - (#Some (` ((All (~ prime_name) [(~ g!param)] (~ type+)) - .Nothing)))) - #None) - (case args - #End - (#Some type) + #None + (failure "Wrong syntax for type:"))) + +(def:' .private (interfaceP tokens) + (-> (List Code) (Maybe [Code Text (List Text) (List [Code Code]) (List Code)])) + (|> (do maybe_monad + [% (declarationP tokens) + .let' [[tokens [export_policy name parameters]] %] + % (annotationsP tokens) + .let' [[tokens annotations] %]] + (in [export_policy name parameters annotations tokens])) + ## (^ (list _export_policy _declaration _annotations _body)) + ## (^ (list _declaration _annotations _body)) + (maybe\else' (do maybe_monad + [% (local_declarationP tokens) + .let' [[tokens [name parameters]] %]] + (in [(` ..private) name parameters #End tokens]))) + ## (^ (list _declaration _body)) + (maybe\else' (do maybe_monad + [% (declarationP tokens) + .let' [[tokens [export_policy name parameters]] %]] + (in [export_policy name parameters #End tokens]))) + ## (^ (list _export_policy _declaration _body)) + )) + +(macro: .public (interface: tokens) + {#.doc (text$ ($_ "lux text concat" + "## Definition of interfaces/signatures ala ML." ..\n + "(interface: .public (Order a)" ..\n + " (: (Equivalence a)" ..\n + " &equivalence)" ..\n + " (: (-> a a Bit)" ..\n + " <))"))} + (case (interfaceP tokens) + (#Some [export_policy name args annotations methods]) + (do meta_monad + [methods' (monad\map meta_monad expansion methods) + members (: (Meta (List [Text Code])) + (monad\map meta_monad + (: (-> Code (Meta [Text Code])) + (function (_ token) + (case token + (^ [_ (#Form (list [_ (#Text "lux type check")] type [_ (#Identifier ["" name])]))]) + (in [name type]) - _ - (#Some (` (.All (~ type_name) [(~+ args)] (~ type))))))) - total_meta (let [meta (definition_annotations meta) - meta (if rec? - (` (#.Item (~ (flag_meta "type_rec?")) (~ meta))) - meta)] - (` [(~ location_code) - (#.Record (~ meta))]))] - (case type' - (#Some type'') - (let [typeC (` (#.Named [(~ (text$ module_name)) - (~ (text$ name))] - (.type (~ type''))))] - (in_meta (list (case tags?? - (#Some tags) - (` ("lux def type tagged" (~ type_name) - (~ typeC) - (~ total_meta) - [(~+ (list\map text$ tags))] - (~ (bit$ exported?)))) - - _ - (` ("lux def" (~ type_name) - ("lux type check type" - (~ typeC)) - (~ total_meta) - (~ (bit$ exported?)))))))) + _ + (failure "Interfaces require typed members!")))) + (list\join methods'))) + .let [def_name (local_identifier$ name) + interface_type (record$ (list\map (: (-> [Text Code] [Code Code]) + (function (_ [module_name m_type]) + [(local_tag$ module_name) m_type])) + members)) + interface_annotations (merged_definition_annotations (` {#.interface? #1}) + (record$ annotations)) + usage (case args + #End + def_name - #None - (failure "Wrong syntax for type:")))) + _ + (` ((~ def_name) (~+ (list\map local_identifier$ args)))))]] + (in_meta (list (` (..type: (~ export_policy) (~ usage) (~ interface_annotations) (~ interface_type)))))) - #None - (failure "Wrong syntax for type:")) - )) + #None + (failure "Wrong syntax for interface:"))) (template [ ] - [(def: #export ( value) + [(def: .public ( value) (-> (I64 Any) ) (:as value))] @@ -3821,7 +3994,7 @@ (replace_all ..self_reference self) (replace_all ..contextual_reference context))) -(def: #export module_separator +(def: .public module_separator "/") (def: parallel_hierarchy_sigil @@ -4234,11 +4407,11 @@ (name\encode name) )) -(macro: #export (^open tokens) +(macro: .public (^open tokens) {#.doc (text$ ($_ "lux text concat" "## 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." ..\n - "(def: #export (range (^open ''.'') minimum additional)" ..\n + "(def: .public (range (^open ''.'') minimum additional)" ..\n " (All [a] (-> (Enum a) a a (List a)))" ..\n " (range' <= succ minimum additional))"))} (case tokens @@ -4285,7 +4458,7 @@ _ (failure "Wrong syntax for ^open"))) -(macro: #export (cond tokens) +(macro: .public (cond tokens) {#.doc (text$ ($_ "lux text concat" "## Branching structures with multiple test conditions." ..\n "(cond (even? num) ''even''" ..\n @@ -4320,7 +4493,7 @@ (All [a] (-> (List a) (List [Nat a]))) (enumeration' 0 xs)) -(macro: #export (get@ tokens) +(macro: .public (get@ tokens) {#.doc (text$ ($_ "lux text concat" "## Accesses the value of a record at a given tag." ..\n "(get@ #field my_record)" @@ -4399,7 +4572,7 @@ [(~ location_code) (#.Record #End)] #0))))))) -(macro: #export (open: tokens) +(macro: .public (open: tokens) {#.doc (text$ ($_ "lux text concat" "## Opens a implementation and generates a definition for each of its members (including nested members)." __paragraph @@ -4442,7 +4615,7 @@ _ (failure "Wrong syntax for open:"))) -(macro: #export (|>> tokens) +(macro: .public (|>> tokens) {#.doc (text$ ($_ "lux text concat" "## Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it." ..\n "(|>> (list\map int\encode) (interpose '' '') (fold text\compose ''''))" ..\n @@ -4453,7 +4626,7 @@ g!arg (gensym "arg")] (in_meta (list (` (function ((~ g!_) (~ g!arg)) (|> (~ g!arg) (~+ tokens)))))))) -(macro: #export (<<| tokens) +(macro: .public (<<| tokens) {#.doc (text$ ($_ "lux text concat" "## Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it." ..\n "(<<| (fold text\compose '''') (interpose '' '') (list\map int\encode))" ..\n @@ -4538,7 +4711,7 @@ list\join)]] (in (list\compose defs openings)))) -(macro: #export (refer tokens) +(macro: .public (refer tokens) (case tokens (^ (list& [_ (#Text module_name)] options)) (do meta_monad @@ -4575,7 +4748,7 @@ (~+ localizations) (~+ openings))))) -(macro: #export (module: tokens) +(macro: .public (module: tokens) {#.doc (text$ ($_ "lux text concat" "## Module_definition macro." __paragraph @@ -4617,7 +4790,7 @@ (~ =imports)))]] (in (#Item =module =refers)))) -(macro: #export (\ tokens) +(macro: .public (\ tokens) {#.doc (text$ ($_ "lux text concat" "## Allows accessing the value of a implementation's member." ..\n "(\ codec encode)" @@ -4634,7 +4807,7 @@ _ (failure "Wrong syntax for \"))) -(macro: #export (set@ tokens) +(macro: .public (set@ tokens) {#.doc (text$ ($_ "lux text concat" "## Sets the value of a record at a given tag." ..\n "(set@ #name ''Lux'' lang)" @@ -4723,7 +4896,7 @@ _ (failure "Wrong syntax for set@"))) -(macro: #export (update@ tokens) +(macro: .public (update@ tokens) {#.doc (text$ ($_ "lux text concat" "## Modifies the value of a record at a given tag, based on some function." ..\n "(update@ #age inc person)" @@ -4798,7 +4971,7 @@ _ (failure "Wrong syntax for update@"))) -(macro: #export (^template tokens) +(macro: .public (^template tokens) {#.doc (text$ ($_ "lux text concat" "## It's similar to template, but meant to be used during pattern-matching." ..\n "(def: (reduced env type)" ..\n @@ -4902,7 +5075,7 @@ (#Documentation_Example code))) (template [ ] - [(def: #export + [(def: .public {#.doc } (All [s] (-> (I64 s) (I64 s))) (|>> ( 1)))] @@ -5006,7 +5179,7 @@ [_ text] (..example_documentation (with_baseline baseline location) baseline example)] (text\compose text __paragraph)))) -(macro: #export (doc tokens) +(macro: .public (doc tokens) {#.doc (text$ ($_ "lux text concat" "## Creates code documentation, embedding text as comments and properly formatting the forms it's being given." __paragraph @@ -5069,7 +5242,7 @@ ## (~ (type_code anonymous)))) (identifier$ [module name]))) -(macro: #export (loop tokens) +(macro: .public (loop tokens) {#.doc (doc "Allows arbitrary looping, using the 'recur' form to re-start the loop." "Can be used in monadic code to create monadic loops." (loop [count +0 @@ -5126,7 +5299,7 @@ #.None (failure "Wrong syntax for loop")))) -(macro: #export (^slots tokens) +(macro: .public (^slots tokens) {#.doc (doc "Allows you to extract record members as local variables with the same names." "For example:" (let [(^slots [#foo #bar #baz]) quux] @@ -5204,7 +5377,7 @@ pairs)] (in (list [location (#Record =pairs)]))))) -(macro: #export (with_expansions tokens) +(macro: .public (with_expansions tokens) {#.doc (doc "Controlled macro-expansion." "Bind an arbitraty number of Code nodes resulting from macro-expansion to local bindings." "Wherever a binding appears, the bound Code nodes will be spliced in there." @@ -5322,7 +5495,7 @@ ## (\ meta_monad in token) )) -(macro: #export (static tokens) +(macro: .public (static tokens) (case tokens (^ (list pattern)) (do meta_monad @@ -5376,7 +5549,7 @@ (: (List [Code Code]) (list\reverse levels)))] (list init_pattern inner_pattern_body))) -(macro: #export (^multi tokens) +(macro: .public (^multi tokens) {#.doc (doc "Multi-level pattern matching." "Useful in situations where the result of a branch depends on further refinements on the values being matched." "For example:" @@ -5436,7 +5609,7 @@ (|>> name\encode (text\compose "Wrong syntax for "))) -(macro: #export (name_of tokens) +(macro: .public (name_of tokens) {#.doc (doc "Given an identifier or a tag, gives back a 2 tuple with the prefix and name parts, both as Text." (name_of #.doc) "=>" @@ -5460,10 +5633,10 @@ (#Right state scope_type_vars) )) -(macro: #export (:parameter tokens) +(macro: .public (:parameter tokens) {#.doc (doc "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: #export (of_list list) + (def: .public (of_list list) (All [a] (-> (List a) (Row a))) (list\fold add (: (Row (:parameter 0)) @@ -5483,7 +5656,7 @@ _ (failure (..wrong_syntax_error (name_of ..$))))) -(def: #export (is? reference sample) +(def: .public (is? reference sample) {#.doc (doc "Tests whether the 2 values are identical (not just 'equal')." "This one should succeed:" (let [value +5] @@ -5494,7 +5667,7 @@ (All [a] (-> a a Bit)) ("lux is" reference sample)) -(macro: #export (^@ tokens) +(macro: .public (^@ tokens) {#.doc (doc "Allows you to simultaneously bind and de-structure a value." (def: (hash (^@ set [Hash _])) (list\fold (function (_ elem acc) (+ (\ Hash hash elem) acc)) @@ -5510,7 +5683,7 @@ _ (failure (..wrong_syntax_error (name_of ..^@))))) -(macro: #export (^|> tokens) +(macro: .public (^|> tokens) {#.doc (doc "Pipes the value being pattern-matched against prior to binding it to a variable." (case input (^|> value [inc (% 10) (max 1)]) @@ -5526,7 +5699,7 @@ _ (failure (..wrong_syntax_error (name_of ..^|>))))) -(macro: #export (:assume tokens) +(macro: .public (:assume tokens) {#.doc (doc "Coerces the given expression to the type of whatever is expected." (: Dinosaur (:assume (list +1 +2 +3))))} (case tokens @@ -5544,7 +5717,7 @@ (function (_ compiler) (#Right [compiler (get@ #location compiler)]))) -(macro: #export (undefined tokens) +(macro: .public (undefined tokens) {#.doc (doc "Meant to be used as a stand-in for functions with undefined implementations." "Undefined expressions will type-check against everything, so they make good dummy implementations." "However, if an undefined expression is ever evaluated, it will raise a runtime error." @@ -5563,7 +5736,7 @@ _ (failure (..wrong_syntax_error (name_of ..undefined))))) -(macro: #export (:of tokens) +(macro: .public (:of tokens) {#.doc (doc "Generates the type corresponding to a given expression." "Example #1:" (let [my_num +123] @@ -5590,107 +5763,82 @@ _ (failure (..wrong_syntax_error (name_of ..:of))))) -(def: (complex_declaration_parser tokens) - (-> (List Code) (Meta [[Text (List Text)] (List Code)])) - (case tokens - (^ (list& [_ (#Form (list& [_ (#Identifier ["" name])] args'))] tokens')) - (do meta_monad - [args (monad\map meta_monad - (function (_ arg') - (case arg' - [_ (#Identifier ["" arg_name])] - (in arg_name) - - _ - (failure "Could not parse an argument."))) - args')] - (in [[name args] tokens'])) - - _ - (failure "Could not parse a complex declaration.") - )) - -(def: (any_parser tokens) - (-> (List Code) (Meta [Code (List Code)])) +(def: (tupleP tokens) + (-> (List Code) (Maybe [(List Code) (List Code)])) (case tokens - (^ (list& token tokens')) - (in_meta [token tokens']) - - _ - (failure "Could not parse anything.") - )) - -(def: (many_parser tokens) - (-> (List Code) (Meta [(List Code) (List Code)])) - (case tokens - (^ (list& head tail)) - (in_meta [tokens (list)]) - - _ - (failure "Could not parse anything.") - )) + (^ (list& [_ (#Tuple tuple)] tokens')) + (#Some [tokens' tuple]) -(def: (end_parser tokens) - (-> (List Code) (Meta Any)) - (case tokens - (^ (list)) - (in_meta []) - _ - (failure "Expected input Codes to be empty.") - )) - -(def: (anns_parser tokens) - (-> (List Code) (Meta [Code (List Code)])) - (case tokens - (^ (list& [_ (#Record _anns)] tokens')) - (in_meta [(record$ _anns) tokens']) - - _ - (in_meta [(' {}) tokens]) - )) + #None)) -(macro: #export (template: tokens) +(def:' .private (templateP tokens) + (-> (List Code) (Maybe [Code Text (List Text) (List [Code Code]) (List Code)])) + (|> (do maybe_monad + [% (declarationP tokens) + .let' [[tokens [export_policy name parameters]] %] + % (annotationsP tokens) + .let' [[tokens annotations] %] + % (tupleP tokens) + .let' [[tokens templates] %] + _ (endP tokens)] + (in [export_policy name parameters annotations templates])) + ## (^ (list _export_policy _declaration _annotations _body)) + ## (^ (list _declaration _annotations _body)) + (maybe\else' (do maybe_monad + [% (declarationP tokens) + .let' [[tokens [export_policy name parameters]] %] + % (tupleP tokens) + .let' [[tokens templates] %] + _ (endP tokens)] + (in [export_policy name parameters #End templates]))) + ## (^ (list _export_policy _declaration _body)) + (maybe\else' (do maybe_monad + [% (local_declarationP tokens) + .let' [[tokens [name parameters]] %] + % (tupleP tokens) + .let' [[tokens templates] %] + _ (endP tokens)] + (in [(` ..private) name parameters #End templates]))) + ## (^ (list _declaration _body)) + )) + +(macro: .public (template: tokens) {#.doc (doc "Define macros in the style of template and ^template." "For simple macros that do not need any fancy features." (template: (square x) (* x x)))} - (do meta_monad - [.let [[export? tokens] (export^ tokens)] - name+args|tokens (complex_declaration_parser tokens) - .let [[[name args] tokens] name+args|tokens] - anns|tokens (anns_parser tokens) - .let [[anns tokens] anns|tokens] - input_templates|tokens (many_parser tokens) - .let [[input_templates tokens] input_templates|tokens] - _ (end_parser tokens) - g!tokens (gensym "tokens") - g!compiler (gensym "compiler") - g!_ (gensym "_") - .let [rep_env (list\map (function (_ arg) - [arg (` ((~' ~) (~ (local_identifier$ arg))))]) - args)] - this_module current_module_name] - (in (list (` (macro: (~+ (export export?)) - ((~ (local_identifier$ name)) (~ g!tokens) (~ g!compiler)) - (~ anns) - (case (~ g!tokens) - (^ (list (~+ (list\map local_identifier$ args)))) - (#.Right [(~ g!compiler) - (list (~+ (list\map (function (_ template) - (` (`' (~ (with_replacements rep_env - template))))) - input_templates)))]) - - (~ g!_) - (#.Left (~ (text$ (..wrong_syntax_error [this_module name])))) - ))))) - )) - -(macro: #export (as_is tokens compiler) + (case (templateP tokens) + (#.Some [export_policy name args anns input_templates]) + (do meta_monad + [g!tokens (gensym "tokens") + g!compiler (gensym "compiler") + g!_ (gensym "_") + .let [rep_env (list\map (function (_ arg) + [arg (` ((~' ~) (~ (local_identifier$ arg))))]) + args)] + this_module current_module_name] + (in (list (` (macro: (~ export_policy) + ((~ (local_identifier$ name)) (~ g!tokens) (~ g!compiler)) + (~ (record$ anns)) + (case (~ g!tokens) + (^ (list (~+ (list\map local_identifier$ args)))) + (#.Right [(~ g!compiler) + (list (~+ (list\map (function (_ template) + (` (`' (~ (with_replacements rep_env + template))))) + input_templates)))]) + + (~ g!_) + (#.Left (~ (text$ (..wrong_syntax_error [this_module name])))))))))) + + #.None + (failure (..wrong_syntax_error (name_of ..template:))))) + +(macro: .public (as_is tokens compiler) (#Right [compiler tokens])) -(macro: #export (char tokens compiler) +(macro: .public (char tokens compiler) (case tokens (^multi (^ (list [_ (#Text input)])) (|> input "lux text size" ("lux i64 =" 1))) @@ -5750,7 +5898,7 @@ (in_meta (list pick)) (target_pick target options' default))))) -(macro: #export (for tokens) +(macro: .public (for tokens) (do meta_monad [target ..target] (case tokens @@ -5804,7 +5952,7 @@ _ (in_meta [(list) code]))) -(macro: #export (`` tokens) +(macro: .public (`` tokens) (case tokens (^ (list raw)) (do meta_monad @@ -5897,7 +6045,7 @@ (..untemplated_record g!meta untemplated_pattern fields) ))) -(macro: #export (^code tokens) +(macro: .public (^code tokens) (case tokens (^ (list& [_meta (#Form (list template))] body branches)) (do meta_monad @@ -5912,15 +6060,15 @@ _ (failure (..wrong_syntax_error (name_of ..^code))))) -(def: #export false +(def: .public false Bit #0) -(def: #export true +(def: .public true Bit #1) -(macro: #export (:let tokens) +(macro: .public (:let tokens) (case tokens (^ (list [_ (#Tuple bindings)] bodyT)) (if (multiple? 2 (list\size bindings)) @@ -5935,7 +6083,7 @@ _ (..failure (..wrong_syntax_error (name_of ..:let))))) -(macro: #export (try tokens) +(macro: .public (try tokens) {#.doc (doc (case (try (risky_computation input)) (#.Right success) (do_something success) diff --git a/stdlib/source/library/lux/abstract/algebra.lux b/stdlib/source/library/lux/abstract/algebra.lux index ca126b064..9a4ea848d 100644 --- a/stdlib/source/library/lux/abstract/algebra.lux +++ b/stdlib/source/library/lux/abstract/algebra.lux @@ -4,14 +4,14 @@ [control [functor (#+ Fix)]]]]) -(type: #export (Algebra f a) +(type: .public (Algebra f a) (-> (f a) a)) -(type: #export (CoAlgebra f a) +(type: .public (CoAlgebra f a) (-> a (f a))) -(type: #export (RAlgebra f a) +(type: .public (RAlgebra f a) (-> (f (Tuple (Fix f) a)) a)) -(type: #export (RCoAlgebra f a) +(type: .public (RCoAlgebra f a) (-> a (f (Or (Fix f) a)))) diff --git a/stdlib/source/library/lux/abstract/apply.lux b/stdlib/source/library/lux/abstract/apply.lux index 38e4772e4..dc9d71f0f 100644 --- a/stdlib/source/library/lux/abstract/apply.lux +++ b/stdlib/source/library/lux/abstract/apply.lux @@ -5,7 +5,7 @@ [monad (#+ Monad)] ["." functor (#+ Functor)]]) -(interface: #export (Apply f) +(interface: .public (Apply f) {#.doc "Applicative functors."} (: (Functor f) &functor) @@ -13,7 +13,7 @@ (-> (f (-> a b)) (f a) (f b))) apply)) -(implementation: #export (compose f_monad f_apply g_apply) +(implementation: .public (compose f_monad f_apply g_apply) {#.doc "Applicative functor composition."} (All [F G] (-> (Monad F) (Apply F) (Apply G) diff --git a/stdlib/source/library/lux/abstract/codec.lux b/stdlib/source/library/lux/abstract/codec.lux index 097c8ca84..bf6da6f54 100644 --- a/stdlib/source/library/lux/abstract/codec.lux +++ b/stdlib/source/library/lux/abstract/codec.lux @@ -7,14 +7,14 @@ [monad (#+ do)] ["." functor]]) -(interface: #export (Codec m a) +(interface: .public (Codec m a) {#.doc "A way to move back-and-forth between a type and an alternative representation for it."} (: (-> a m) encode) (: (-> m (Try a)) decode)) -(implementation: #export (compose cb_codec ba_codec) +(implementation: .public (compose cb_codec ba_codec) {#.doc "Codec composition."} (All [a b c] (-> (Codec c b) (Codec b a) diff --git a/stdlib/source/library/lux/abstract/comonad.lux b/stdlib/source/library/lux/abstract/comonad.lux index 869eb3de5..589ed47f2 100644 --- a/stdlib/source/library/lux/abstract/comonad.lux +++ b/stdlib/source/library/lux/abstract/comonad.lux @@ -12,7 +12,7 @@ [// [functor (#+ Functor)]]) -(interface: #export (CoMonad w) +(interface: .public (CoMonad w) {#.doc (doc "CoMonads are the opposite/complement to monads." "CoMonadic structures are often infinite in size and built upon lazily-evaluated functions.")} (: (Functor w) @@ -24,7 +24,7 @@ (-> (w a) (w (w a)))) split)) -(macro: #export (be tokens state) +(macro: .public (be tokens state) {#.doc (doc "A co-monadic parallel to the 'do' macro." (let [square (function (_ n) (* n n))] (be comonad diff --git a/stdlib/source/library/lux/abstract/comonad/cofree.lux b/stdlib/source/library/lux/abstract/comonad/cofree.lux index 096a48feb..271795e14 100644 --- a/stdlib/source/library/lux/abstract/comonad/cofree.lux +++ b/stdlib/source/library/lux/abstract/comonad/cofree.lux @@ -5,17 +5,17 @@ [// [functor (#+ Functor)]]]) -(type: #export (CoFree F a) +(type: .public (CoFree F a) {#.doc (doc "The CoFree CoMonad.")} [a (F (CoFree F a))]) -(implementation: #export (functor dsl) +(implementation: .public (functor dsl) (All [F] (-> (Functor F) (Functor (CoFree F)))) (def: (map f [head tail]) [(f head) (\ dsl map (map f) tail)])) -(implementation: #export (comonad dsl) +(implementation: .public (comonad dsl) (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 4cb27558a..d1fec7f7f 100644 --- a/stdlib/source/library/lux/abstract/enum.lux +++ b/stdlib/source/library/lux/abstract/enum.lux @@ -4,13 +4,13 @@ [// ["." order (#+ Order)]]) -(interface: #export (Enum e) +(interface: .public (Enum e) {#.doc "Enumerable types, with a notion of moving forward and backwards through a type's instances."} (: (Order e) &order) (: (-> e e) succ) (: (-> e e) pred)) -(def: #export (range enum from to) +(def: .public (range enum from to) {#.doc "An inclusive [from, to] range of values."} (All [a] (-> (Enum a) a a (List a))) (let [(^open "/\.") enum] diff --git a/stdlib/source/library/lux/abstract/equivalence.lux b/stdlib/source/library/lux/abstract/equivalence.lux index b1e570713..7834363bf 100644 --- a/stdlib/source/library/lux/abstract/equivalence.lux +++ b/stdlib/source/library/lux/abstract/equivalence.lux @@ -5,19 +5,19 @@ [functor ["." contravariant]]]) -(interface: #export (Equivalence a) +(interface: .public (Equivalence a) {#.doc "Equivalence for a type's instances."} (: (-> a a Bit) =)) -(def: #export (rec sub) +(def: .public (rec sub) {#.doc (doc "A recursive equivalence combinator.")} (All [a] (-> (-> (Equivalence a) (Equivalence a)) (Equivalence a))) (implementation (def: (= left right) (sub = left right)))) -(implementation: #export functor +(implementation: .public functor (contravariant.Functor Equivalence) (def: (map f equivalence) diff --git a/stdlib/source/library/lux/abstract/fold.lux b/stdlib/source/library/lux/abstract/fold.lux index fca10ecb2..b2ce974da 100644 --- a/stdlib/source/library/lux/abstract/fold.lux +++ b/stdlib/source/library/lux/abstract/fold.lux @@ -4,13 +4,13 @@ [// [monoid (#+ Monoid)]]) -(interface: #export (Fold F) +(interface: .public (Fold F) {#.doc "Iterate over a structure's values to build a summary value."} (: (All [a b] (-> (-> b a a) a (F b) a)) fold)) -(def: #export (with_monoid monoid fold value) +(def: .public (with_monoid monoid fold value) {#.doc (doc "Fold over a foldable structure using the monoid's identity as the initial value.")} (All [F a] (-> (Monoid a) (Fold F) (F a) a)) diff --git a/stdlib/source/library/lux/abstract/functor.lux b/stdlib/source/library/lux/abstract/functor.lux index 140376477..32e1c6671 100644 --- a/stdlib/source/library/lux/abstract/functor.lux +++ b/stdlib/source/library/lux/abstract/functor.lux @@ -2,19 +2,19 @@ [library [lux (#- Or And)]]) -(interface: #export (Functor f) +(interface: .public (Functor f) (: (All [a b] (-> (-> a b) (-> (f a) (f b)))) map)) -(type: #export (Fix f) +(type: .public (Fix f) (f (Fix f))) -(type: #export (Or f g) +(type: .public (Or f g) (All [a] (.Or (f a) (g a)))) -(def: #export (sum (^open "f\.") (^open "g\.")) +(def: .public (sum (^open "f\.") (^open "g\.")) {#.doc (doc "Co-product (sum) composition for functors.")} (All [F G] (-> (Functor F) (Functor G) (Functor (..Or F G)))) (implementation @@ -26,10 +26,10 @@ (#.Right ga) (#.Right (g\map f ga)))))) -(type: #export (And f g) +(type: .public (And f g) (All [a] (.And (f a) (g a)))) -(def: #export (product (^open "f\.") (^open "g\.")) +(def: .public (product (^open "f\.") (^open "g\.")) {#.doc (doc "Product composition for functors.")} (All [F G] (-> (Functor F) (Functor G) (Functor (..And F G)))) (implementation @@ -37,10 +37,10 @@ [(f\map f fa) (g\map f ga)]))) -(type: #export (Then f g) +(type: .public (Then f g) (All [a] (f (g a)))) -(def: #export (compose (^open "f\.") (^open "g\.")) +(def: .public (compose (^open "f\.") (^open "g\.")) {#.doc "Functor composition."} (All [F G] (-> (Functor F) (Functor G) (Functor (..Then F G)))) (implementation diff --git a/stdlib/source/library/lux/abstract/functor/contravariant.lux b/stdlib/source/library/lux/abstract/functor/contravariant.lux index f7df0a73d..659105afa 100644 --- a/stdlib/source/library/lux/abstract/functor/contravariant.lux +++ b/stdlib/source/library/lux/abstract/functor/contravariant.lux @@ -2,7 +2,7 @@ [library [lux #*]]) -(interface: #export (Functor f) +(interface: .public (Functor f) {#.doc (doc "The contravariant functor.")} (: (All [a b] diff --git a/stdlib/source/library/lux/abstract/hash.lux b/stdlib/source/library/lux/abstract/hash.lux index 2cc18f3e4..84f80723c 100644 --- a/stdlib/source/library/lux/abstract/hash.lux +++ b/stdlib/source/library/lux/abstract/hash.lux @@ -6,7 +6,7 @@ [functor ["." contravariant]]]) -(interface: #export (Hash a) +(interface: .public (Hash a) {#.doc (doc "A way to produce hash-codes for a type's instances." "A necessity when working with some data-structures, such as dictionaries or sets.")} (: (Equivalence a) @@ -14,7 +14,7 @@ (: (-> a Nat) hash)) -(implementation: #export functor +(implementation: .public functor (contravariant.Functor Hash) (def: (map f super) diff --git a/stdlib/source/library/lux/abstract/interval.lux b/stdlib/source/library/lux/abstract/interval.lux index 4d4e5f643..7c2b2ca35 100644 --- a/stdlib/source/library/lux/abstract/interval.lux +++ b/stdlib/source/library/lux/abstract/interval.lux @@ -7,7 +7,7 @@ ["." order] [enum (#+ Enum)]]) -(interface: #export (Interval a) +(interface: .public (Interval a) {#.doc "A representation of top and bottom boundaries for an ordered type."} (: (Enum a) &enum) @@ -18,14 +18,14 @@ (: a top)) -(def: #export (between enum bottom top) +(def: .public (between enum bottom top) (All [a] (-> (Enum a) a a (Interval a))) (implementation (def: &enum enum) (def: bottom bottom) (def: top top))) -(def: #export (singleton enum elem) +(def: .public (singleton enum elem) {#.doc (doc "An interval where both top and bottom are the same value.")} (All [a] (-> (Enum a) a (Interval a))) (implementation @@ -34,7 +34,7 @@ (def: top elem))) (template [ ] - [(def: #export ( interval) + [(def: .public ( interval) (All [a] (-> (Interval a) Bit)) (let [(^open ",\.") interval] ( ,\bottom ,\top)))] @@ -44,7 +44,7 @@ [singleton? ,\=] ) -(def: #export (within? interval elem) +(def: .public (within? interval elem) (All [a] (-> (Interval a) a Bit)) (let [(^open ",\.") interval] (cond (inner? interval) @@ -60,7 +60,7 @@ (,\= ,\top elem))))) (template [ ] - [(def: #export ( elem interval) + [(def: .public ( elem interval) (All [a] (-> a (Interval a) Bit)) (let [(^open ".") interval] (= elem)))] @@ -69,13 +69,13 @@ [ends_with? top] ) -(def: #export (borders? interval elem) +(def: .public (borders? interval elem) {#.doc (doc "Where a value is at the border of an interval.")} (All [a] (-> (Interval a) a Bit)) (or (starts_with? elem interval) (ends_with? elem interval))) -(implementation: #export (union left right) +(implementation: .public (union left right) {#.doc (doc "An interval that spans both predecessors.")} (All [a] (-> (Interval a) (Interval a) (Interval a))) @@ -83,7 +83,7 @@ (def: bottom (order.min (\ right &order) (\ left bottom) (\ right bottom))) (def: top (order.max (\ right &order) (\ left top) (\ right top)))) -(implementation: #export (intersection left right) +(implementation: .public (intersection left right) {#.doc (doc "An interval spanned by both predecessors.")} (All [a] (-> (Interval a) (Interval a) (Interval a))) @@ -91,7 +91,7 @@ (def: bottom (order.max (\ right &order) (\ left bottom) (\ right bottom))) (def: top (order.min (\ right &order) (\ left top) (\ right top)))) -(implementation: #export (complement interval) +(implementation: .public (complement interval) {#.doc (doc "The inverse of an interval.")} (All [a] (-> (Interval a) (Interval a))) @@ -99,19 +99,19 @@ (def: bottom (\ interval succ (\ interval top))) (def: top (\ interval pred (\ interval bottom)))) -(def: #export (precedes? reference sample) +(def: .public (precedes? reference sample) (All [a] (-> (Interval a) (Interval a) Bit)) (let [(^open ".") reference limit (\ reference bottom)] (and (< limit (\ sample bottom)) (< limit (\ sample top))))) -(def: #export (succeeds? reference sample) +(def: .public (succeeds? reference sample) (All [a] (-> (Interval a) (Interval a) Bit)) (precedes? sample reference)) (template [ ] - [(def: #export ( reference sample) + [(def: .public ( reference sample) (All [a] (-> a (Interval a) Bit)) (let [(^open ",\.") sample] (and ( reference ,\bottom) @@ -121,7 +121,7 @@ [after? (order.> ,\&order)] ) -(def: #export (meets? reference sample) +(def: .public (meets? reference sample) {#.doc (doc "Whether an interval meets another one on its bottom/lower side.")} (All [a] (-> (Interval a) (Interval a) Bit)) (let [(^open ",\.") reference @@ -129,13 +129,13 @@ (and (,\= limit (\ sample top)) (order.<= ,\&order limit (\ sample bottom))))) -(def: #export (touches? reference sample) +(def: .public (touches? reference sample) (All [a] (-> (Interval a) (Interval a) Bit)) (or (meets? reference sample) (meets? sample reference))) (template [ ] - [(def: #export ( reference sample) + [(def: .public ( reference sample) (All [a] (-> (Interval a) (Interval a) Bit)) (let [(^open ",\.") reference] (and (,\= (\ reference ) @@ -148,7 +148,7 @@ [finishes? ,\top order.>= ,\bottom] ) -(implementation: #export equivalence +(implementation: .public equivalence (All [a] (Equivalence (Interval a))) (def: (= reference sample) @@ -156,7 +156,7 @@ (and (,\= ,\bottom (\ sample bottom)) (,\= ,\top (\ sample top)))))) -(def: #export (nested? reference sample) +(def: .public (nested? reference sample) (All [a] (-> (Interval a) (Interval a) Bit)) (cond (or (singleton? sample) (and (inner? reference) (inner? sample)) @@ -177,7 +177,7 @@ (order.<= ,\&order (\ reference top) (\ sample top))))) )) -(def: #export (overlaps? reference sample) +(def: .public (overlaps? reference sample) (All [a] (-> (Interval a) (Interval a) Bit)) (let [(^open ",\.") reference] (and (not (\ ..equivalence = reference sample)) diff --git a/stdlib/source/library/lux/abstract/monad.lux b/stdlib/source/library/lux/abstract/monad.lux index 0bbb58149..01e22b7a7 100644 --- a/stdlib/source/library/lux/abstract/monad.lux +++ b/stdlib/source/library/lux/abstract/monad.lux @@ -43,7 +43,7 @@ _ #.End)) -(interface: #export (Monad m) +(interface: .public (Monad m) {#.doc (doc "A monad is a monoid in the category of endofunctors." "What's the problem?")} @@ -56,7 +56,7 @@ (-> (m (m a)) (m a))) join)) -(macro: #export (do tokens state) +(macro: .public (do tokens state) {#.doc (doc "Macro for easy concatenation of monadic operations." (do monad [y (f1 x) @@ -113,7 +113,7 @@ #.None (#.Left "Wrong syntax for 'do'"))) -(def: #export (bind monad f) +(def: .public (bind monad f) {#.doc (doc "Apply a function with monadic effects to a monadic value and yield a new monadic value.")} (All [! a b] (-> (Monad !) (-> a (! b)) @@ -121,7 +121,7 @@ (|>> (\ monad map f) (\ monad join))) -(def: #export (seq monad) +(def: .public (seq monad) {#.doc "Run all the monadic values in the list and produce a list of the base values."} (All [M a] (-> (Monad M) (List (M a)) @@ -138,7 +138,7 @@ (!\map (|>> (#.Item _x)) (recur xs')))) !\join))))) -(def: #export (map monad f) +(def: .public (map monad f) {#.doc "Apply a monadic function to all values in a list."} (All [M a b] (-> (Monad M) (-> a (M b)) (List a) @@ -155,7 +155,7 @@ (!\map (|>> (#.Item _x)) (recur xs')))) !\join))))) -(def: #export (only monad f) +(def: .public (only monad f) {#.doc "Filter the values in a list with a monadic function."} (All [! a b] (-> (Monad !) (-> a (! Bit)) (List a) @@ -176,7 +176,7 @@ (recur xs')))) !\join))))) -(def: #export (fold monad f init xs) +(def: .public (fold monad f init xs) {#.doc "Fold a list with a monadic function."} (All [M a b] (-> (Monad M) (-> b a (M a)) a (List b) diff --git a/stdlib/source/library/lux/abstract/monad/free.lux b/stdlib/source/library/lux/abstract/monad/free.lux index a4f5733df..d954c5581 100644 --- a/stdlib/source/library/lux/abstract/monad/free.lux +++ b/stdlib/source/library/lux/abstract/monad/free.lux @@ -6,12 +6,12 @@ [apply (#+ Apply)] [monad (#+ Monad)]]) -(type: #export (Free F a) +(type: .public (Free F a) {#.doc "The Free Monad."} (#Pure a) (#Effect (F (Free F a)))) -(implementation: #export (functor dsl) +(implementation: .public (functor dsl) (All [F] (-> (Functor F) (Functor (Free F)))) (def: (map f ea) @@ -22,7 +22,7 @@ (#Effect value) (#Effect (\ dsl map (map f) value))))) -(implementation: #export (apply dsl) +(implementation: .public (apply dsl) (All [F] (-> (Functor F) (Apply (Free F)))) (def: &functor (..functor dsl)) @@ -43,7 +43,7 @@ ff)) ))) -(implementation: #export (monad dsl) +(implementation: .public (monad dsl) (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 120e33a7d..290db1419 100644 --- a/stdlib/source/library/lux/abstract/monad/indexed.lux +++ b/stdlib/source/library/lux/abstract/monad/indexed.lux @@ -12,7 +12,7 @@ ["." code]]]] ["." //]) -(interface: #export (IxMonad m) +(interface: .public (IxMonad m) (: (All [p a] (-> a (m p p a))) in) @@ -59,7 +59,7 @@ (\ <>.monad map (|>> [#.None]) .any))) -(syntax: #export (do {[?name monad] ..named_monad} +(syntax: .public (do {[?name monad] ..named_monad} {context (.tuple (<>.some context))} expression) (macro.with_gensyms [g!_ g!bind] diff --git a/stdlib/source/library/lux/abstract/monoid.lux b/stdlib/source/library/lux/abstract/monoid.lux index 87f155848..800a14c50 100644 --- a/stdlib/source/library/lux/abstract/monoid.lux +++ b/stdlib/source/library/lux/abstract/monoid.lux @@ -2,7 +2,7 @@ [library [lux #*]]) -(interface: #export (Monoid a) +(interface: .public (Monoid a) {#.doc (doc "A way to compose values." "Includes an identity value which does not alter any other value when combined with.")} (: a @@ -10,7 +10,7 @@ (: (-> a a a) compose)) -(def: #export (compose left right) +(def: .public (compose left right) (All [l r] (-> (Monoid l) (Monoid r) (Monoid [l r]))) (implementation (def: identity diff --git a/stdlib/source/library/lux/abstract/order.lux b/stdlib/source/library/lux/abstract/order.lux index 280226ccd..2dbd078e3 100644 --- a/stdlib/source/library/lux/abstract/order.lux +++ b/stdlib/source/library/lux/abstract/order.lux @@ -8,7 +8,7 @@ [functor ["." contravariant]]]) -(interface: #export (Order a) +(interface: .public (Order a) {#.doc "A signature for types that possess some sense of ordering among their elements."} (: (Equivalence a) @@ -18,42 +18,42 @@ <) ) -(type: #export (Comparison a) +(type: .public (Comparison a) {#.doc (doc "An arbitrary comparison between two values, with the knowledge of how to order them.")} (-> (Order a) a a Bit)) -(def: #export (<= order parameter subject) +(def: .public (<= order parameter subject) {#.doc (doc "Less than or equal.")} Comparison (or (\ order < parameter subject) (\ order = parameter subject))) -(def: #export (> order parameter subject) +(def: .public (> order parameter subject) {#.doc (doc "Greater than.")} Comparison (\ order < subject parameter)) -(def: #export (>= order parameter subject) +(def: .public (>= order parameter subject) {#.doc (doc "Greater than or equal.")} Comparison (or (\ order < subject parameter) (\ order = subject parameter))) -(type: #export (Choice a) +(type: .public (Choice a) {#.doc (doc "A choice comparison between two values, with the knowledge of how to order them.")} (-> (Order a) a a a)) -(def: #export (min order x y) +(def: .public (min order x y) {#.doc (doc "Minimum.")} Choice (if (\ order < y x) x y)) -(def: #export (max order x y) +(def: .public (max order x y) {#.doc (doc "Maximum.")} Choice (if (\ order < y x) y x)) -(implementation: #export functor +(implementation: .public functor (contravariant.Functor Order) (def: (map f order) diff --git a/stdlib/source/library/lux/abstract/predicate.lux b/stdlib/source/library/lux/abstract/predicate.lux index 1d1bfd848..625cd42ec 100644 --- a/stdlib/source/library/lux/abstract/predicate.lux +++ b/stdlib/source/library/lux/abstract/predicate.lux @@ -8,18 +8,18 @@ [functor ["." contravariant]]]) -(type: #export (Predicate a) +(type: .public (Predicate a) {#.doc (doc "A question that can be asked of a value, yield either false (#0) or true (#1).")} (-> a Bit)) (template [ ] - [(def: #export + [(def: .public {#.doc } Predicate (function.constant )) - (def: #export ( left right) + (def: .public ( left right) {#.doc } (All [a] (-> (Predicate a) (Predicate a) (Predicate a))) (function (_ value) @@ -35,7 +35,7 @@ ) (template [ ] - [(implementation: #export + [(implementation: .public (All [a] (Monoid (Predicate a))) (def: identity ) @@ -45,19 +45,19 @@ [intersection ..all ..and] ) -(def: #export (complement predicate) +(def: .public (complement predicate) {#.doc (doc "The opposite of a predicate.")} (All [a] (-> (Predicate a) (Predicate a))) (|>> predicate not)) -(def: #export (difference sub base) +(def: .public (difference sub base) {#.doc (doc "A predicate that meeds 'base', but not 'sub'.")} (All [a] (-> (Predicate a) (Predicate a) (Predicate a))) (function (_ value) (.and (base value) (not (sub value))))) -(def: #export (rec predicate) +(def: .public (rec predicate) {#.doc (doc "Ties the knot for a recursive predicate.")} (All [a] (-> (-> (Predicate a) (Predicate a)) @@ -65,7 +65,7 @@ (function (recur input) (predicate recur input))) -(implementation: #export functor +(implementation: .public functor (contravariant.Functor Predicate) (def: (map f fb) diff --git a/stdlib/source/library/lux/control/concatenative.lux b/stdlib/source/library/lux/control/concatenative.lux index 2cf1c5e10..3005596ee 100644 --- a/stdlib/source/library/lux/control/concatenative.lux +++ b/stdlib/source/library/lux/control/concatenative.lux @@ -14,7 +14,6 @@ ["." code] ["." template] [syntax (#+ syntax:) - ["|.|" export] ["|.|" annotations]]] [math [number @@ -24,7 +23,7 @@ ["f" frac]]]]] [// ["<>" parser ("#\." monad) - ["" code (#+ Parser)]]]) + ["<.>" code (#+ Parser)]]]) (type: Alias [Text Code]) @@ -34,19 +33,19 @@ (def: aliases^ (Parser (List Alias)) - (|> (<>.and .local_identifier .any) + (|> (<>.and .local_identifier .any) <>.some - .record + .record (<>.else (list)))) (def: bottom^ (Parser Nat) - (.form (<>.after (.this! (` #.Parameter)) .nat))) + (.form (<>.after (.this! (` #.Parameter)) .nat))) (def: stack^ (Parser Stack) (<>.either (<>.and (<>.maybe bottom^) - (.tuple (<>.some .any))) + (.tuple (<>.some .any))) (<>.and (|> bottom^ (<>\map (|>> #.Some))) (<>\in (list))))) @@ -69,7 +68,7 @@ (meta.failure (format "Cannot expand to more than a single AST/Code node:" text.new_line (|> expansion (list\map %.code) (text.join_with " "))))))) -(syntax: #export (=> {aliases aliases^} +(syntax: .public (=> {aliases aliases^} {inputs stack^} {outputs stack^}) {#.doc (doc "Concatenative function types." @@ -111,7 +110,7 @@ (function (_ [_ top]) top)) -(syntax: #export (||> {commands (<>.some .any)}) +(syntax: .public (||> {commands (<>.some .any)}) {#.doc (doc "A self-contained sequence of concatenative instructions." (is? value (||> (..push sample))) @@ -121,24 +120,33 @@ n/=))} (in (list (` (|> (~! ..begin!) (~+ commands) ((~! ..end!))))))) -(syntax: #export (word: - {export |export|.parser} - {name .local_identifier} - {annotations (<>.else |annotations|.empty |annotations|.parser)} - type - {commands (<>.some .any)}) +(def: word + (Parser [Code Text |annotations|.Annotations Code (List Code)]) + (let [private (: (Parser [Text |annotations|.Annotations Code (List Code)]) + ($_ <>.and + .local_identifier + (<>.else |annotations|.empty |annotations|.parser) + .any + (<>.many .any)))] + ($_ <>.either + (<>.and .any private) + (<>.and (<>\in (` .private)) private) + ))) + +(syntax: .public (word: + {[export_policy name annotations type commands] ..word}) {#.doc (doc "A named concatenative function." (word: square (=> [Nat] [Nat]) dup (apply/2 n.*)))} - (in (list (` (def: (~+ (|export|.format export)) (~ (code.local_identifier name)) + (in (list (` (def: (~ export_policy) (~ (code.local_identifier name)) (~ (|annotations|.format annotations)) (~ type) (|>> (~+ commands))))))) -(syntax: #export (apply {arity (|> .nat (<>.only (n.> 0)))}) +(syntax: .public (apply {arity (<>.only (n.> 0) .nat)}) {#.doc (doc "A generator for functions that turn arity N functions into arity N concatenative functions." (: (=> [Nat] [Nat]) ((apply 1) inc)))} @@ -156,7 +164,7 @@ [(with_expansions [ (template.identifier ["apply/" ]) (template.text ["Lift a function of arity " " into a concatenative function of arity " "."])] - (def: #export + (def: .public {#.doc (doc )} (apply )))] @@ -164,68 +172,68 @@ [5] [6] [7] [8] ) -(def: #export (push x) +(def: .public (push x) {#.doc (doc "Push a value onto the stack.")} (All [a] (-> a (=> [] [a]))) (function (_ stack) [stack x])) -(def: #export drop +(def: .public drop {#.doc (doc "Drop/pop a value from the top of the stack.")} (All [t] (=> [t] [])) (function (_ [stack top]) stack)) -(def: #export nip +(def: .public nip {#.doc (doc "Drop the second-to-last value from the top of the stack.")} (All [_ a] (=> [_ a] [a])) (function (_ [[stack _] top]) [stack top])) -(def: #export dup +(def: .public dup {#.doc (doc "Duplicate the top of the stack.")} (All [a] (=> [a] [a a])) (function (_ [stack top]) [[stack top] top])) -(def: #export swap +(def: .public swap {#.doc (doc "Swaps the 2 topmost stack values.")} (All [a b] (=> [a b] [b a])) (function (_ [[stack l] r]) [[stack r] l])) -(def: #export rotL +(def: .public rotL {#.doc (doc "Rotes the 3 topmost stack values to the left.")} (All [a b c] (=> [a b c] [b c a])) (function (_ [[[stack a] b] c]) [[[stack b] c] a])) -(def: #export rotR +(def: .public rotR {#.doc (doc "Rotes the 3 topmost stack values to the right.")} (All [a b c] (=> [a b c] [c a b])) (function (_ [[[stack a] b] c]) [[[stack c] a] b])) -(def: #export && +(def: .public && {#.doc (doc "Groups the 2 topmost stack values as a 2-tuple.")} (All [a b] (=> [a b] [(Tuple a b)])) (function (_ [[stack l] r]) [stack [l r]])) -(def: #export ||L +(def: .public ||L {#.doc (doc "Left-injects the top into sum.")} (All [a b] (=> [a] [(Or a b)])) (function (_ [stack l]) [stack (0 #0 l)])) -(def: #export ||R +(def: .public ||R {#.doc (doc "Right-injects the top into sum.")} (All [a b] (=> [b] [(Or a b)])) (function (_ [stack r]) [stack (0 #1 r)])) (template [ ] - [(`` (def: #export + [(`` (def: .public {#.doc (doc (~~ (template.text [ " for " " arithmetic."])))} (=> [ ] []) (function (_ [[stack subject] param]) @@ -276,7 +284,7 @@ [Frac Bit f/>= f.>=] ) -(def: #export if +(def: .public if {#.doc (doc "If expression." (is? "then" (||> (push true) @@ -292,7 +300,7 @@ (then stack) (else stack)))) -(def: #export call +(def: .public call {#.doc (doc "Executes an anonymous block on the stack.")} (All [___a ___z] (=> {quote (=> ___a ___z)} @@ -300,7 +308,7 @@ (function (_ [stack quote]) (quote stack))) -(def: #export loop +(def: .public loop {#.doc (doc "Executes a block as a loop until it yields #0 to stop.")} (All [___] (=> {test (=> ___ ___ [Bit])} @@ -311,7 +319,7 @@ (loop [stack' pred]) stack')))) -(def: #export dip +(def: .public dip {#.doc (doc "Executes a block on the stack, save for the topmost value.")} (All [___ a] (=> ___ [a (=> ___ ___)] @@ -319,7 +327,7 @@ (function (_ [[stack a] quote]) [(quote stack) a])) -(def: #export dip/2 +(def: .public dip/2 {#.doc (doc "Executes a block on the stack, save for the 2 topmost values.")} (All [___ a b] (=> ___ [a b (=> ___ ___)] @@ -327,7 +335,7 @@ (function (_ [[[stack a] b] quote]) [[(quote stack) a] b])) -(def: #export do +(def: .public do {#.doc (doc "Do-while loop expression." (n.= (inc sample) (||> (push sample) @@ -342,7 +350,7 @@ (function (_ [[stack pred] body]) [[(body stack) pred] body])) -(def: #export while +(def: .public while {#.doc (doc "While loop expression." (n.= (n.+ distance start) (||> (push start) @@ -362,7 +370,7 @@ (while [[(body stack') pred] body]) stack')))) -(def: #export compose +(def: .public compose {#.doc (doc "Function composition." (n.= (n.+ 2 sample) (||> (push sample) @@ -376,7 +384,7 @@ (function (_ [[stack f] g]) [stack (|>> f g)])) -(def: #export partial +(def: .public partial {#.doc (doc "Partial application." (n.= (n.+ sample sample) (||> (push sample) @@ -390,7 +398,7 @@ (function (_ [[stack arg] quote]) [stack (|>> (push arg) quote)])) -(word: #export when +(word: .public when {#.doc (doc "Only execute the block when #1.")} (All [___] (=> {body (=> ___ ___)} @@ -401,7 +409,7 @@ (push ..drop) if) -(word: #export ? +(word: .public ? {#.doc (doc "Choose the top value when #0 and the second-to-top when #1.")} (All [a] (=> [Bit a a] [a])) diff --git a/stdlib/source/library/lux/control/concurrency/actor.lux b/stdlib/source/library/lux/control/concurrency/actor.lux index eff114796..74dab7eda 100644 --- a/stdlib/source/library/lux/control/concurrency/actor.lux +++ b/stdlib/source/library/lux/control/concurrency/actor.lux @@ -11,7 +11,7 @@ ["." try (#+ Try)] ["." exception (#+ exception:)] ["." io (#+ IO io)] - ["<>" parser + ["<>" parser ("#\." monad) ["<.>" code (#+ Parser)]]] [data ["." bit] @@ -24,7 +24,6 @@ ["." code] [syntax (#+ syntax:) ["|.|" input] - ["|.|" export] ["|.|" annotations]]] [math [number @@ -38,8 +37,8 @@ ["." async (#+ Async Resolver) ("#\." monad)] ["." frp (#+ Channel)]]) -(exception: #export poisoned) -(exception: #export dead) +(exception: .public poisoned) +(exception: .public dead) (with_expansions [ (as_is (-> s (Actor s) (Async (Try s)))) @@ -64,27 +63,27 @@ #.None (in #.End)))) - (abstract: #export (Actor s) + (abstract: .public (Actor s) + {#.doc (doc "An entity that can react to messages (mail) sent to it concurrently.")} + {#obituary [(Async ) (Resolver )] #mailbox (Atom )} - {#.doc (doc "An entity that can react to messages (mail) sent to it concurrently.")} - - (type: #export (Mail s) + (type: .public (Mail s) {#.doc (doc "A one-way message sent to an actor, without expecting a reply.")} ) - (type: #export (Obituary s) + (type: .public (Obituary s) {#.doc (doc "Details on the death of an actor.")} ) - (type: #export (Behavior o s) + (type: .public (Behavior o s) {#.doc (doc "An actor's behavior when mail is received and when a fatal error occurs.")} {#on_init (-> o s) #on_mail (-> (Mail s) s (Actor s) (Async (Try s)))}) - (def: #export (spawn! behavior init) + (def: .public (spawn! behavior init) {#.doc (doc "Given a behavior and initial state, spawns an actor and returns it.")} (All [o s] (-> (Behavior o s) o (IO (Actor s)))) (io (let [[on_init on_mail] behavior @@ -113,7 +112,7 @@ (recur state' tail))))] self))) - (def: #export (alive? actor) + (def: .public (alive? actor) (All [s] (-> (Actor s) (IO Bit))) (let [[obituary _] (get@ #obituary (:representation actor))] (|> obituary @@ -125,19 +124,19 @@ _ bit.no)))))) - (def: #export (obituary actor) + (def: .public (obituary actor) (All [s] (-> (Actor s) (IO (Maybe (Obituary s))))) (let [[obituary _] (get@ #obituary (:representation actor))] (async.poll obituary))) - (def: #export await + (def: .public await {#.doc (doc "Await for an actor to end working.")} (All [s] (-> (Actor s) (Async (Obituary s)))) (|>> :representation (get@ #obituary) product.left)) - (def: #export (mail! mail actor) + (def: .public (mail! mail actor) {#.doc (doc "Send mail to an actor.")} (All [s] (-> (Mail s) (Actor s) (IO (Try Any)))) (do {! io.monad} @@ -163,7 +162,7 @@ (recur |mailbox|')))))) (in (exception.except ..dead []))))) - (type: #export (Message s o) + (type: .public (Message s o) {#.doc (doc "A two-way message sent to an actor, expecting a reply.")} (-> s (Actor s) (Async (Try [s o])))) @@ -189,7 +188,7 @@ (exec (io.run (resolve (#try.Failure error))) (async.resolved (#try.Failure error))))))])) - (def: #export (tell! message actor) + (def: .public (tell! message actor) {#.doc (doc "Communicate with an actor through message-passing.")} (All [s o] (-> (Message s o) (Actor s) (Async (Try o)))) (let [[async mail] (..mail message)] @@ -208,13 +207,13 @@ (All [s] (-> (Mail s) s (Actor s) (Async (Try s)))) (mail state self)) -(def: #export default +(def: .public default {#.doc (doc "Default actor behavior.")} (All [s] (Behavior s s)) {#on_init function.identity #on_mail ..default_on_mail}) -(def: #export (poison! actor) +(def: .public (poison! actor) {#.doc (doc "Kills the actor by sending mail that will kill it upon processing," "but allows the actor to handle previous mail.")} (All [s] (-> (Actor s) (IO (Try Any)))) @@ -258,7 +257,20 @@ (~ (code.local_identifier selfN))) (~ bodyC))))) -(with_expansions [ (as_is (actor: #export (Stack a) +(def: actorP + (Parser [Code [Text (List Text)] |annotations|.Annotations Code BehaviorC]) + (let [private ($_ <>.and + ..actor_decl^ + |annotations|.parser + .any + behavior^)] + ($_ <>.either + (<>.and .any private) + (<>.and (<>\in (` .private)) private)))) + +(with_expansions [ (as_is (actor: .public (stack a) + {} + (List a) ((on_mail mail state self) @@ -268,28 +280,26 @@ .let [_ (debug.log! "AFTER")]] (in output))) - (message: #export (push {value a} state self) + (message: .public (push {value a} state self) (List a) (let [state' (#.Item value state)] (async.resolved (#try.Success [state' state']))))) - (actor: #export Counter + (actor: .public counter + {} + Nat - (message: #export (count! {increment Nat} state self) + (message: .public (count! {increment Nat} state self) Any (let [state' (n.+ increment state)] (async.resolved (#try.Success [state' state'])))) - (message: #export (read! state self) + (message: .public (read! state self) Nat (async.resolved (#try.Success [state state])))))] - (syntax: #export (actor: - {export |export|.parser} - {[name vars] actor_decl^} - {annotations (<>.else |annotations|.empty |annotations|.parser)} - state_type - {[?on_mail messages] behavior^}) + (syntax: .public (actor: + {[export_policy [name vars] annotations state_type [?on_mail messages]] ..actorP}) {#.doc (doc "Defines a named actor, with its behavior and internal state." "Messages for the actor must be defined after the on_mail handler." )} @@ -298,10 +308,12 @@ [g!type (macro.gensym (format name "_abstract_type")) .let [g!actor (code.local_identifier name) g!vars (list\map code.local_identifier vars)]] - (in (list (` ((~! abstract:) (~+ (|export|.format export)) ((~ g!type) (~+ g!vars)) + (in (list (` ((~! abstract:) (~ export_policy) ((~ g!type) (~+ g!vars)) + {} + (~ state_type) - (def: (~+ (|export|.format export)) (~ g!actor) + (def: (~ export_policy) (~ g!actor) (All [(~+ g!vars)] (..Behavior (~ state_type) ((~ g!type) (~+ g!vars)))) {#..on_init (|>> ((~! abstract.:abstraction) (~ g!type))) @@ -309,7 +321,7 @@ (~+ messages)))))))) - (syntax: #export (actor {[state_type init] (.record (<>.and .any .any))} + (syntax: .public (actor {[state_type init] (.record (<>.and .any .any))} {[?on_mail messages] behavior^}) {#.doc (doc "Defines an anonymous actor, with its behavior and internal state." "Messages for the actor must be defined after the on_mail handler." @@ -346,12 +358,19 @@ (<>.either (.form (<>.and .identifier (<>.some .local_identifier))) (<>.and .identifier (\ <>.monad in (list))))) - (syntax: #export (message: - {export |export|.parser} - {signature signature^} - {annotations (<>.else |annotations|.empty |annotations|.parser)} - output_type - body) + (def: messageP + (Parser [Code Signature |annotations|.Annotations Code Code]) + (let [private ($_ <>.and + ..signature^ + (<>.else |annotations|.empty |annotations|.parser) + .any + .any)] + ($_ <>.either + (<>.and .any private) + (<>.and (<>\in (` .private)) private)))) + + (syntax: .public (message: + {[export_policy signature annotations output_type body] ..messageP}) {#.doc (doc "A message can access the actor's state through the state parameter." "A message can also access the actor itself through the self parameter." "A message's output must be an async containing a 2-tuple with the updated state and a return value." @@ -369,7 +388,7 @@ g!inputsT (|> signature (get@ #inputs) (list\map product.right)) g!state (|> signature (get@ #state) code.local_identifier) g!self (|> signature (get@ #self) code.local_identifier)]] - (in (list (` (def: (~+ (|export|.format export)) ((~ g!message) (~+ g!inputsC)) + (in (list (` (def: (~ export_policy) ((~ g!message) (~+ g!inputsC)) (~ (|annotations|.format annotations)) (All [(~+ g!all_vars)] (-> (~+ g!inputsT) @@ -385,14 +404,14 @@ (~ output_type)])))))))) )))))) -(type: #export Stop +(type: .public Stop {#.doc (doc "A signal to stop an actor from observing a channel.")} (IO Any)) (def: continue! true) (def: stop! false) -(def: #export (observe action channel actor) +(def: .public (observe action channel actor) {#.doc (doc "Use an actor to observe a channel by transforming each datum" "flowing through the channel into mail the actor can process." "Can stop observing the channel by executing the Stop value.")} diff --git a/stdlib/source/library/lux/control/concurrency/async.lux b/stdlib/source/library/lux/control/concurrency/async.lux index 243d7327f..cc1757a31 100644 --- a/stdlib/source/library/lux/control/concurrency/async.lux +++ b/stdlib/source/library/lux/control/concurrency/async.lux @@ -17,12 +17,12 @@ ["." thread] ["." atom (#+ Atom atom)]]) -(abstract: #export (Async a) - (Atom [(Maybe a) (List (-> a (IO Any)))]) - +(abstract: .public (Async a) {#.doc "Represents values produced by asynchronous computations (unlike IO, which is synchronous)."} - (type: #export (Resolver a) + (Atom [(Maybe a) (List (-> a (IO Any)))]) + + (type: .public (Resolver a) {#.doc (doc "The function used to give a value to an async." "Will signal 'true' if the async has been resolved for the 1st time, 'false' otherwise.")} (-> a (IO Bit))) @@ -49,25 +49,25 @@ (in #1)) (resolve value)))))))) - (def: #export (resolved value) + (def: .public (resolved value) {#.doc (doc "Produces an async that has already been resolved to the given value.")} (All [a] (-> a (Async a))) (:abstraction (atom [(#.Some value) (list)]))) - (def: #export (async _) + (def: .public (async _) {#.doc (doc "Creates a fresh async that has not been resolved yet.")} (All [a] (-> Any [(Async a) (Resolver a)])) (let [async (:abstraction (atom [#.None (list)]))] [async (..resolver async)])) - (def: #export poll + (def: .public poll {#.doc "Polls an async for its value."} (All [a] (-> (Async a) (IO (Maybe a)))) (|>> :representation atom.read (\ io.functor map product.left))) - (def: #export (await f async) + (def: .public (await f async) {#.doc (doc "Executes the given function as soon as the async has been resolved.")} (All [a] (-> (-> a (IO Any)) (Async a) (IO Any))) (do {! io.monad} @@ -86,7 +86,7 @@ (await f (:abstraction async)))))))) ) -(def: #export resolved? +(def: .public resolved? {#.doc "Checks whether an async's value has already been resolved."} (All [a] (-> (Async a) (IO Bit))) (|>> ..poll @@ -97,7 +97,7 @@ (#.Some _) #1))))) -(implementation: #export functor +(implementation: .public functor (Functor Async) (def: (map f fa) @@ -105,7 +105,7 @@ (exec (io.run (..await (|>> f resolve) fa)) fb)))) -(implementation: #export apply +(implementation: .public apply (Apply Async) (def: &functor ..functor) @@ -117,7 +117,7 @@ ff)) fb)))) -(implementation: #export monad +(implementation: .public monad (Monad Async) (def: &functor ..functor) @@ -129,7 +129,7 @@ (exec (io.run (..await (..await resolve) mma)) ma)))) -(def: #export (and left right) +(def: .public (and left right) {#.doc (doc "Combines the results of both asyncs, in-order.")} (All [a b] (-> (Async a) (Async b) (Async [a b]))) (let [[read! write!] (:sharing [a b] @@ -146,7 +146,7 @@ left))] read!)) -(def: #export (or left right) +(def: .public (or left right) {#.doc (doc "Yields the results of whichever async gets resolved first." "You can tell which one was resolved first through pattern-matching.")} (All [a b] (-> (Async a) (Async b) (Async (Or a b)))) @@ -161,7 +161,7 @@ (exec a|b)))) -(def: #export (either left right) +(def: .public (either left right) {#.doc (doc "Yields the results of whichever async gets resolved first." "You cannot tell which one was resolved first.")} (All [a] (-> (Async a) (Async a) (Async a))) @@ -173,7 +173,7 @@ [right])) left||right)))) -(def: #export (schedule millis_delay computation) +(def: .public (schedule millis_delay computation) {#.doc (doc "Runs an I/O computation on its own thread (after a specified delay)." "Returns a aromise that will eventually host its result.")} (All [a] (-> Nat (IO a) (Async a))) @@ -185,23 +185,23 @@ io.run) !out))) -(def: #export future +(def: .public future {#.doc (doc "Runs an I/O computation on its own thread." "Returns an async that will eventually host its result.")} (All [a] (-> (IO a) (Async a))) (..schedule 0)) -(def: #export (delay time_millis value) +(def: .public (delay time_millis value) {#.doc "Delivers a value after a certain period has passed."} (All [a] (-> Nat a (Async a))) (..schedule time_millis (io value))) -(def: #export (wait time_millis) +(def: .public (wait time_millis) {#.doc "Returns an async that will be resolved after the specified amount of milliseconds."} (-> Nat (Async Any)) (..delay time_millis [])) -(def: #export (time_out time_millis async) +(def: .public (time_out time_millis async) {#.doc "Wait for an async to be resolved within the specified amount of milliseconds."} (All [a] (-> Nat (Async a) (Async (Maybe a)))) (..or (wait time_millis) async)) diff --git a/stdlib/source/library/lux/control/concurrency/atom.lux b/stdlib/source/library/lux/control/concurrency/atom.lux index 9a86f191b..c6c993561 100644 --- a/stdlib/source/library/lux/control/concurrency/atom.lux +++ b/stdlib/source/library/lux/control/concurrency/atom.lux @@ -46,29 +46,29 @@ @.php "php array read" @.scheme "scheme array read"} (as_is))] - (abstract: #export (Atom a) + (abstract: .public (Atom a) + {#.doc "Atomic references that are safe to mutate concurrently."} + (with_expansions [ (java/util/concurrent/atomic/AtomicReference a)] (for {@.old @.jvm } (array.Array a))) - {#.doc "Atomic references that are safe to mutate concurrently."} - - (def: #export (atom value) + (def: .public (atom value) (All [a] (-> a (Atom a))) (:abstraction (with_expansions [ (java/util/concurrent/atomic/AtomicReference::new value)] (for {@.old @.jvm } ( 0 value ( 1)))))) - (def: #export (read atom) + (def: .public (read atom) (All [a] (-> (Atom a) (IO a))) (io (with_expansions [ (java/util/concurrent/atomic/AtomicReference::get (:representation atom))] (for {@.old @.jvm } ( 0 (:representation atom)))))) - (def: #export (compare_and_swap current new atom) + (def: .public (compare_and_swap current new atom) {#.doc (doc "Only mutates an atom if you can present its current value." "That guarantees that atom was not updated since you last read from it.")} (All [a] (-> a a (Atom a) (IO Bit))) @@ -82,7 +82,7 @@ false)))))) )) -(def: #export (update f atom) +(def: .public (update f atom) {#.doc (doc "Updates an atom by applying a function to its current value." "If it fails to update it (because some other process wrote to it first), it will retry until it succeeds." "The retries will be done with the new values of the atom, as they show up.")} @@ -96,7 +96,7 @@ (in [old new]) (recur []))))) -(def: #export (write value atom) +(def: .public (write value atom) {#.doc (doc "Writes the given value to an atom." "If it fails to write it (because some other process wrote to it first), it will retry until it succeeds.")} (All [a] (-> a (Atom a) (IO a))) diff --git a/stdlib/source/library/lux/control/concurrency/frp.lux b/stdlib/source/library/lux/control/concurrency/frp.lux index 14b4013d3..3b1a0a4bd 100644 --- a/stdlib/source/library/lux/control/concurrency/frp.lux +++ b/stdlib/source/library/lux/control/concurrency/frp.lux @@ -18,13 +18,13 @@ ["." atom (#+ Atom)] ["." async (#+ Async) ("#\." functor)]]) -(type: #export (Channel a) +(type: .public (Channel a) {#.doc "An asynchronous channel to distribute values."} (Async (Maybe [a (Channel a)]))) -(exception: #export channel_is_already_closed) +(exception: .public channel_is_already_closed) -(interface: #export (Sink a) +(interface: .public (Sink a) {#.doc (doc "The tail-end of a channel, which can be written-to to fee the channel.")} (: (IO (Try Any)) close) @@ -80,13 +80,13 @@ ## Someone else fed the sink. (recur [])))))))))) -(def: #export (channel _) +(def: .public (channel _) {#.doc (doc "Creates a brand-new channel and hands it over, along with the sink to write to it.")} (All [a] (-> Any [(Channel a) (Sink a)])) (let [[async resolve] (async.async [])] [async (..sink resolve)])) -(implementation: #export functor +(implementation: .public functor (Functor Channel) (def: (map f) @@ -95,7 +95,7 @@ (function (_ [head tail]) [(f head) (map f tail)]))))) -(implementation: #export apply +(implementation: .public apply (Apply Channel) (def: &functor ..functor) @@ -115,7 +115,7 @@ Channel (async.resolved #.None)) -(implementation: #export monad +(implementation: .public monad (Monad Channel) (def: &functor ..functor) @@ -148,11 +148,11 @@ (in (: Any (io.run (\ sink close)))))))) output)))) -(type: #export (Subscriber a) +(type: .public (Subscriber a) {#.doc (doc "A function that can receive every value fed into a channel.")} (-> a (IO (Maybe Any)))) -(def: #export (subscribe subscriber channel) +(def: .public (subscribe subscriber channel) (All [a] (-> (Subscriber a) (Channel a) (IO Any))) (io (exec (: (Async Any) (loop [channel channel] @@ -171,7 +171,7 @@ (in []))))) []))) -(def: #export (only pass? channel) +(def: .public (only pass? channel) {#.doc (doc "Produces a new channel based on the old one, only with values" "that pass the test.")} (All [a] (-> (-> a Bit) (Channel a) (Channel a))) @@ -187,14 +187,14 @@ #.None (in #.None)))) -(def: #export (of_async async) +(def: .public (of_async async) {#.doc (doc "A one-element channel containing the output from an async.")} (All [a] (-> (Async a) (Channel a))) (async\map (function (_ value) (#.Some [value ..empty])) async)) -(def: #export (fold f init channel) +(def: .public (fold f init channel) {#.doc "Asynchronous fold over channels."} (All [a b] (-> (-> b a (Async a)) a (Channel b) @@ -210,7 +210,7 @@ [init' (f head init)] (fold f init' tail))))) -(def: #export (folds f init channel) +(def: .public (folds f init channel) (All [a b] (-> (-> b a (Async a)) a (Channel b) (Channel a))) @@ -225,7 +225,7 @@ [init' (f head init)] (in (#.Some [init (folds f init' tail)])))))) -(def: #export (poll milli_seconds action) +(def: .public (poll milli_seconds action) (All [a] (-> Nat (IO a) [(Channel a) (Sink a)])) (let [[output sink] (channel [])] @@ -236,11 +236,11 @@ (async.await recur (async.wait milli_seconds))))) [output sink]))) -(def: #export (periodic milli_seconds) +(def: .public (periodic milli_seconds) (-> Nat [(Channel Any) (Sink Any)]) (..poll milli_seconds (io []))) -(def: #export (iterations f init) +(def: .public (iterations f init) (All [s o] (-> (-> s (Async (Maybe [s o]))) s (Channel o))) (do async.monad [?next (f init)] @@ -264,7 +264,7 @@ #.None (in #.None)))) -(def: #export (distinct equivalence channel) +(def: .public (distinct equivalence channel) (All [a] (-> (Equivalence a) (Channel a) (Channel a))) (do async.monad [item channel] @@ -275,7 +275,7 @@ #.None (in #.None)))) -(def: #export (consume channel) +(def: .public (consume channel) (All [a] (-> (Channel a) (Async (List a)))) (do {! async.monad} [item channel] @@ -287,7 +287,7 @@ #.None (in #.End)))) -(def: #export (sequential milli_seconds values) +(def: .public (sequential milli_seconds values) {#.doc (doc "Transforms the given list into a channel with the same elements.")} (All [a] (-> Nat (List a) (Channel a))) (case values diff --git a/stdlib/source/library/lux/control/concurrency/semaphore.lux b/stdlib/source/library/lux/control/concurrency/semaphore.lux index f4e094d3b..f01af9336 100644 --- a/stdlib/source/library/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/library/lux/control/concurrency/semaphore.lux @@ -29,15 +29,15 @@ #open_positions Int #waiting_list (Queue (Resolver Any))}) -(abstract: #export Semaphore - (Atom State) - +(abstract: .public Semaphore {#.doc "A tool for controlling access to resources by multiple concurrent processes."} + (Atom State) + (def: most_positions_possible (.nat (\ i.interval top))) - (def: #export (semaphore initial_open_positions) + (def: .public (semaphore initial_open_positions) (-> Nat Semaphore) (let [max_positions (n.min initial_open_positions ..most_positions_possible)] @@ -45,7 +45,7 @@ #open_positions (.int max_positions) #waiting_list queue.empty})))) - (def: #export (wait semaphore) + (def: .public (wait semaphore) {#.doc (doc "Wait on a semaphore until there are open positions." "After finishing your work, you must 'signal' to the semaphore that you're done.")} (Ex [k] (-> Semaphore (Async Any))) @@ -67,11 +67,11 @@ ))))) signal))) - (exception: #export (semaphore_is_maxed_out {max_positions Nat}) + (exception: .public (semaphore_is_maxed_out {max_positions Nat}) (exception.report ["Max Positions" (%.nat max_positions)])) - (def: #export (signal semaphore) + (def: .public (signal semaphore) {#.doc (doc "Signal to a semaphore that you're done with your work, and that there is a new open position.")} (Ex [k] (-> Semaphore (Async (Try Int)))) (let [semaphore (:representation semaphore)] @@ -97,12 +97,12 @@ (in (#try.Success (get@ #open_positions post))))))))) ) -(abstract: #export Mutex - Semaphore - +(abstract: .public Mutex {#.doc "A mutual-exclusion lock that can only be acquired by one process at a time."} - (def: #export (mutex _) + Semaphore + + (def: .public (mutex _) {#.doc (doc "Creates a brand-new mutex.")} (-> Any Mutex) (:abstraction (semaphore 1))) @@ -115,7 +115,7 @@ (-> Mutex (Async Any)) (|>> :representation ..signal)) - (def: #export (synchronize mutex procedure) + (def: .public (synchronize mutex procedure) {#.doc (doc "Runs the procedure with exclusive control of the mutex.")} (All [a] (-> Mutex (IO (Async a)) (Async a))) (do async.monad @@ -125,23 +125,23 @@ (in output))) ) -(def: #export limit +(def: .public limit {#.doc (doc "Produce a limit for a barrier.")} (refinement.refinement (n.> 0))) -(type: #export Limit +(type: .public Limit {#.doc (doc "A limit for barriers.")} (:~ (refinement.type limit))) -(abstract: #export Barrier +(abstract: .public Barrier + {#.doc "A barrier that blocks all processes from proceeding until a given number of processes are parked at the barrier."} + {#limit Limit #count (Atom Nat) #start_turnstile Semaphore #end_turnstile Semaphore} - {#.doc "A barrier that blocks all processes from proceeding until a given number of processes are parked at the barrier."} - - (def: #export (barrier limit) + (def: .public (barrier limit) (-> Limit Barrier) (:abstraction {#limit limit #count (atom.atom 0) @@ -173,7 +173,7 @@ [end dec 0 #end_turnstile] ) - (def: #export (block barrier) + (def: .public (block barrier) {#.doc (doc "Wait on a barrier until all processes have arrived and met the barrier's limit.")} (-> Barrier (Async Any)) (do async.monad diff --git a/stdlib/source/library/lux/control/concurrency/stm.lux b/stdlib/source/library/lux/control/concurrency/stm.lux index 29979e17e..6308a2c84 100644 --- a/stdlib/source/library/lux/control/concurrency/stm.lux +++ b/stdlib/source/library/lux/control/concurrency/stm.lux @@ -23,12 +23,12 @@ (type: (Observer a) (-> a (IO Any))) -(abstract: #export (Var a) - (Atom [a (List (Sink a))]) - +(abstract: .public (Var a) {#.doc "A mutable cell containing a value, and observers that will be alerted of any change to it."} - (def: #export (var value) + (Atom [a (List (Sink a))]) + + (def: .public (var value) {#.doc "Creates a new STM var, with a default value."} (All [a] (-> a (Var a))) (:abstraction (atom.atom [value (list)]))) @@ -66,7 +66,7 @@ (in [])) (write! new_value var)))) - (def: #export (follow target) + (def: .public (follow target) {#.doc "Creates a channel that will receive all changes to the value of the given var."} (All [a] (-> (Var a) (IO [(Channel a) (Sink a)]))) (do io.monad @@ -85,7 +85,7 @@ (type: Tx (List (Ex [a] (Tx_Frame a)))) -(type: #export (STM a) +(type: .public (STM a) {#.doc "A computation which updates a transaction and produces a value."} (-> Tx [Tx a])) @@ -100,7 +100,7 @@ (:assume) )) -(def: #export (read var) +(def: .public (read var) (All [a] (-> (Var a) (STM a))) (function (_ tx) (case (var_value var tx) @@ -130,7 +130,7 @@ #current _current} (update_tx_value var value tx'))))) -(def: #export (write value var) +(def: .public (write value var) (All [a] (-> a (Var a) (STM Any))) (function (_ tx) (case (var_value var tx) @@ -142,7 +142,7 @@ [(#.Item [var (..read! var) value] tx) []]))) -(implementation: #export functor +(implementation: .public functor (Functor STM) (def: (map f fa) @@ -150,7 +150,7 @@ (let [[tx' a] (fa tx)] [tx' (f a)])))) -(implementation: #export apply +(implementation: .public apply (Apply STM) (def: &functor ..functor) @@ -161,7 +161,7 @@ [tx'' a] (fa tx')] [tx'' (f a)])))) -(implementation: #export monad +(implementation: .public monad (Monad STM) (def: &functor ..functor) @@ -175,7 +175,7 @@ (let [[tx' ma] (mma tx)] (ma tx'))))) -(def: #export (update f var) +(def: .public (update f var) {#.doc "Update a var's value, and return a tuple with the old and the new values."} (All [a] (-> (-> a a) (Var a) (STM [a a]))) (do ..monad @@ -261,7 +261,7 @@ (in []))) ))) -(def: #export (commit stm_proc) +(def: .public (commit stm_proc) {#.doc (doc "Commits a transaction and returns its result (asynchronously)." "Note that a transaction may be re-run an indeterminate number of times if other transactions involving the same variables successfully commit first." "For this reason, it's important to note that transactions must be free from side-effects, such as I/O.")} diff --git a/stdlib/source/library/lux/control/concurrency/thread.lux b/stdlib/source/library/lux/control/concurrency/thread.lux index 0a2a2c547..8c3a273d4 100644 --- a/stdlib/source/library/lux/control/concurrency/thread.lux +++ b/stdlib/source/library/lux/control/concurrency/thread.lux @@ -64,7 +64,7 @@ #action (IO Any)}) )) -(def: #export parallelism +(def: .public parallelism {#.doc (doc "How many processes can run in parallel.")} Nat (with_expansions [ (|> (java/lang/Runtime::getRuntime) @@ -101,7 +101,7 @@ (#try.Success _) [])) -(def: #export (schedule milli_seconds action) +(def: .public (schedule milli_seconds action) {#.doc (doc "Executes an I/O procedure after some milli-seconds.")} (-> Nat (IO Any) (IO Any)) (with_expansions [ (as_is (let [runnable (ffi.object [] [java/lang/Runnable] @@ -142,10 +142,10 @@ @.python (as_is)} ## Default - (as_is (exception: #export cannot_continue_running_threads) + (as_is (exception: .public cannot_continue_running_threads) ## https://en.wikipedia.org/wiki/Event_loop - (def: #export run! + (def: .public run! {#.doc (doc "Starts the event-loop.")} (IO Any) (loop [_ []] diff --git a/stdlib/source/library/lux/control/continuation.lux b/stdlib/source/library/lux/control/continuation.lux index 16f789010..ef0392fe9 100644 --- a/stdlib/source/library/lux/control/continuation.lux +++ b/stdlib/source/library/lux/control/continuation.lux @@ -13,21 +13,21 @@ [syntax (#+ syntax:)] ["." code]]]]) -(type: #export (Cont i o) +(type: .public (Cont i o) {#.doc "Continuations."} (-> (-> i o) o)) -(def: #export (continue next cont) +(def: .public (continue next cont) {#.doc "Continues a continuation thunk."} (All [i o] (-> (-> i o) (Cont i o) o)) (cont next)) -(def: #export (run cont) +(def: .public (run cont) {#.doc "Forces a continuation thunk to be evaluated."} (All [a] (-> (Cont a a) a)) (cont function.identity)) -(def: #export (call/cc f) +(def: .public (call/cc f) {#.doc "Call with current continuation."} (All [a b z] (-> (-> (-> a (Cont b z)) @@ -37,18 +37,18 @@ (f (function (_ a) (function (_ _) (k a))) k))) -(syntax: #export (pending expr) +(syntax: .public (pending expr) {#.doc (doc "Turns any expression into a function that is pending a continuation." (pending (some_function some_input)))} (with_gensyms [g!_ g!k] (in (list (` (.function ((~ g!_) (~ g!k)) ((~ g!k) (~ expr)))))))) -(def: #export (reset scope) +(def: .public (reset scope) (All [i o] (-> (Cont i i) (Cont i o))) (function (_ k) (k (run scope)))) -(def: #export (shift f) +(def: .public (shift f) (All [a] (-> (-> (-> a (Cont a a)) (Cont a a)) @@ -57,13 +57,13 @@ (f (function (_ a) (function (_ ic) (ic (oc a)))) function.identity))) -(implementation: #export functor +(implementation: .public functor (All [o] (Functor (All [i] (Cont i o)))) (def: (map f fv) (function (_ k) (fv (function.compose k f))))) -(implementation: #export apply +(implementation: .public apply (All [o] (Apply (All [i] (Cont i o)))) (def: &functor ..functor) @@ -74,7 +74,7 @@ (function (_ v)) fv (function (_ f)) ff)))) -(implementation: #export monad +(implementation: .public monad (All [o] (Monad (All [i] (Cont i o)))) (def: &functor ..functor) @@ -86,7 +86,7 @@ (function (_ k) (ffa (continue k))))) -(def: #export (portal init) +(def: .public (portal init) (All [i o z] (-> i (Cont [(-> i (Cont o z)) diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux index 7515cb9fb..a7d5a5871 100644 --- a/stdlib/source/library/lux/control/exception.lux +++ b/stdlib/source/library/lux/control/exception.lux @@ -7,8 +7,8 @@ [abstract [monad (#+ do)]] [control - ["p" parser - ["s" code (#+ Parser)]]] + ["<>" parser ("#\." monad) + ["<.>" code (#+ Parser)]]] [data ["." maybe] ["." product] @@ -18,7 +18,6 @@ [macro ["." code] [syntax (#+ syntax:) - ["|.|" export] ["|.|" input] ["." type #_ ["|#_.|" variable]]]] @@ -28,17 +27,17 @@ [// ["//" try (#+ Try)]]) -(type: #export (Exception a) +(type: .public (Exception a) {#.doc "An exception provides a way to decorate error messages."} {#label Text #constructor (-> a Text)}) -(def: #export (match? exception error) +(def: .public (match? exception error) {#.doc (doc "Is this exception the cause of the error message?")} (All [e] (-> (Exception e) Text Bit)) (text.starts_with? (get@ #label exception) error)) -(def: #export (catch exception then try) +(def: .public (catch exception then try) {#.doc (doc "If a particular exception is detected on a possibly-erroneous value, handle it." "If no exception was detected, or a different one from the one being checked, then pass along the original value.")} (All [e a] @@ -57,7 +56,7 @@ then)) (#//.Failure error))))) -(def: #export (otherwise else try) +(def: .public (otherwise else try) {#.doc "If no handler could be found to catch the exception, then run a function as a last-resort measure."} (All [a] (-> (-> Text a) (Try a) a)) @@ -68,47 +67,57 @@ (#//.Failure error) (else error))) -(def: #export (return value) +(def: .public (return value) {#.doc "A way to lift normal values into the error-handling context."} (All [a] (-> a (Try a))) (#//.Success value)) -(def: #export (error exception message) +(def: .public (error exception message) {#.doc "Constructs an error message from an exception."} (All [e] (-> (Exception e) e Text)) ((get@ #..constructor exception) message)) -(def: #export (except exception message) +(def: .public (except exception message) {#.doc "Decorate an error message with an Exception and lift it into the error-handling context."} (All [e a] (-> (Exception e) e (Try a))) (#//.Failure (..error exception message))) -(def: #export (assertion exception message test) +(def: .public (assertion exception message test) (All [e] (-> (Exception e) e Bit (Try Any))) (if test (#//.Success []) (..except exception message))) -(syntax: #export (exception: {export |export|.parser} - {t_vars (p.else (list) (s.tuple (p.some |type_variable|.parser)))} - {[name inputs] (p.either (p.and s.local_identifier (in (list))) - (s.form (p.and s.local_identifier (p.some |input|.parser))))} - {body (p.maybe s.any)}) +(def: exception + (Parser [Code (List |type_variable|.Variable) [Text (List |input|.Input)] (Maybe Code)]) + (let [private (: (Parser [(List |type_variable|.Variable) [Text (List |input|.Input)] (Maybe Code)]) + ($_ <>.and + (<>.else (list) (.tuple (<>.some |type_variable|.parser))) + (<>.either (.form (<>.and .local_identifier (<>.some |input|.parser))) + (<>.and .local_identifier (<>\in (list)))) + (<>.maybe .any) + ))] + ($_ <>.either + (<>.and .any private) + (<>.and (<>\in (` .private)) private) + ))) + +(syntax: .public (exception: {[export_policy t_vars [name inputs] body] ..exception}) {#.doc (doc "Define a new exception type." "It mostly just serves as a way to tag error messages for later catching." "" "Simple case:" - (exception: #export some_exception) + (exception: .public some_exception) "" "Complex case:" - (exception: #export [arbitrary type variables] (some_exception {optional Text} {arguments Int}) + (exception: .public [arbitrary type variables] (some_exception {optional Text} {arguments Int}) optional_body))} (macro.with_gensyms [g!descriptor] (do meta.monad [current_module meta.current_module_name .let [descriptor ($_ text\compose "{" current_module "." name "}" text.new_line) g!self (code.local_identifier name)]] - (in (list (` (def: (~+ (|export|.format export)) + (in (list (` (def: (~ export_policy) (~ g!self) (All [(~+ (list\map |type_variable|.format t_vars))] (..Exception [(~+ (list\map (get@ #|input|.type) inputs))])) @@ -149,7 +158,7 @@ (on_entry head) tail)))) -(syntax: #export (report {entries (p.many (s.tuple (p.and s.any s.any)))}) +(syntax: .public (report {entries (<>.many (.tuple (<>.and .any .any)))}) {#.doc (doc "An error report." (: Text (report ["Row 0" value/0] @@ -160,7 +169,7 @@ (list\map (function (_ [header message]) (` [(~ header) (~ message)]))))))))))) -(def: #export (listing format entries) +(def: .public (listing format entries) {#.doc (doc "A numbered report of the entries on a list." "NOTE: 0-based numbering.")} (All [a] @@ -190,7 +199,7 @@ ..separator error)) -(def: #export (with exception message computation) +(def: .public (with exception message computation) {#.doc (doc "If a computation fails, prepends the exception to the error.")} (All [e a] (-> (Exception e) e (Try a) (Try a))) (case computation diff --git a/stdlib/source/library/lux/control/function.lux b/stdlib/source/library/lux/control/function.lux index 32d3633ef..3e0669133 100644 --- a/stdlib/source/library/lux/control/function.lux +++ b/stdlib/source/library/lux/control/function.lux @@ -4,7 +4,7 @@ [abstract [monoid (#+ Monoid)]]]]) -(def: #export identity +(def: .public identity {#.doc (doc "Identity function." "Does nothing to its argument and just returns it." (is? (identity value) @@ -12,7 +12,7 @@ (All [a] (-> a a)) (|>>)) -(def: #export (compose f g) +(def: .public (compose f g) {#.doc (doc "Function composition." (= ((compose f g) "foo") (f (g "foo"))))} @@ -20,14 +20,14 @@ (-> (-> b c) (-> a b) (-> a c))) (|>> g f)) -(def: #export (constant value) +(def: .public (constant value) {#.doc (doc "Create constant functions." (= ((constant "foo") "bar") "foo"))} (All [o] (-> o (All [i] (-> i o)))) (function (_ _) value)) -(def: #export (flip f) +(def: .public (flip f) {#.doc (doc "Flips the order of the arguments of a function." (= ((flip f) "foo" "bar") (f "bar" "foo")))} @@ -35,13 +35,13 @@ (-> (-> a b c) (-> b a c))) (function (_ x y) (f y x))) -(def: #export (apply input function) +(def: .public (apply input function) {#.doc (doc "Simple 1-argument function application.")} (All [i o] (-> i (-> i o) o)) (function input)) -(implementation: #export monoid +(implementation: .public monoid (All [a] (Monoid (-> a a))) (def: identity ..identity) diff --git a/stdlib/source/library/lux/control/function/contract.lux b/stdlib/source/library/lux/control/function/contract.lux index 59ad5b681..8b0baca0f 100644 --- a/stdlib/source/library/lux/control/function/contract.lux +++ b/stdlib/source/library/lux/control/function/contract.lux @@ -28,7 +28,7 @@ [] (error! message))) -(syntax: #export (pre test expr) +(syntax: .public (pre test expr) {#.doc (doc "Pre-conditions." "Given a test and an expression to run, only runs the expression if the test passes." "Otherwise, an error is raised." @@ -39,7 +39,7 @@ (~ test)) (~ expr)))))) -(syntax: #export (post test expr) +(syntax: .public (post test expr) {#.doc (doc "Post-conditions." "Given a predicate and an expression to run, evaluates the expression and then tests the output with the predicate." "If the predicate returns #1, returns the value of the expression." diff --git a/stdlib/source/library/lux/control/function/memo.lux b/stdlib/source/library/lux/control/function/memo.lux index 9b66afa50..311f1e433 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: #export memoization +(def: .public memoization (All [i o] (Mixin i (State (Dictionary i o) o))) (function (_ delegate recur) @@ -33,10 +33,10 @@ _ (state.update (dictionary.put input output))] (in output))))))) -(type: #export (Memo i o) +(type: .public (Memo i o) (Recursive i (State (Dictionary i o) o))) -(def: #export (open memo) +(def: .public (open memo) {#.doc (doc "Memoization where the memoized results can be re-used accross invocations.")} (All [i o] (:let [Memory (Dictionary i o)] @@ -45,7 +45,7 @@ (function (_ [memory input]) (|> input memo (state.run memory))))) -(def: #export (closed hash memo) +(def: .public (closed hash memo) {#.doc (doc "Memoization confined to a single invocation to the function (not counting any subsequent recursive invocations)." "Memoized results will be re-used during recursive invocations, but cannot be accessed after the main invocation has ended.")} (All [i o] @@ -54,7 +54,7 @@ empty (dictionary.empty hash)] (|>> memo (state.run empty) product.right))) -(def: #export (none hash memo) +(def: .public (none hash memo) {#.doc (doc "No memoization at all." "This is useful as a test control when measuring the effect of using memoization.")} (All [i o] diff --git a/stdlib/source/library/lux/control/function/mixin.lux b/stdlib/source/library/lux/control/function/mixin.lux index 796c04057..50e26ef55 100644 --- a/stdlib/source/library/lux/control/function/mixin.lux +++ b/stdlib/source/library/lux/control/function/mixin.lux @@ -9,35 +9,35 @@ [predicate (#+ Predicate)] [monad (#+ Monad do)]]]]) -(type: #export (Mixin i o) +(type: .public (Mixin i o) {#.doc (doc "A function which can be mixed with others to inherit their behavior.")} (-> (-> i o) (-> i o) (-> i o))) -(def: #export (mixin f) +(def: .public (mixin f) {#.doc (doc "Given a mixin, produces a normal function.")} (All [i o] (-> (Mixin i o) (-> i o))) (function (mix input) ((f mix mix) input))) -(def: #export nothing +(def: .public nothing {#.doc (doc "A mixin that does nothing and just delegates work to the next mixin.")} Mixin (function (_ delegate recur) delegate)) -(def: #export (inherit parent child) +(def: .public (inherit parent child) {#.doc (doc "Produces a new mixin, where the behavior of the child can make use of the behavior of the parent.")} (All [i o] (-> (Mixin i o) (Mixin i o) (Mixin i o))) (function (_ delegate recur) (parent (child delegate recur) recur))) -(implementation: #export monoid +(implementation: .public monoid (All [i o] (Monoid (Mixin i o))) (def: identity ..nothing) (def: compose ..inherit)) -(def: #export (advice when then) +(def: .public (advice when then) {#.doc (doc "Only apply then mixin when the input meets some criterion.")} (All [i o] (-> (Predicate i) (Mixin i o) (Mixin i o))) (function (_ delegate recur input) @@ -45,7 +45,7 @@ ((then delegate recur) input) (delegate input)))) -(def: #export (before monad action) +(def: .public (before monad action) {#.doc (doc "Executes an action before doing the main work.")} (All [! i o] (-> (Monad !) (-> i (! Any)) (Mixin i (! o)))) (function (_ delegate recur input) @@ -53,7 +53,7 @@ [_ (action input)] (delegate input)))) -(def: #export (after monad action) +(def: .public (after monad action) {#.doc (doc "Executes an action after doing the main work.")} (All [! i o] (-> (Monad !) (-> i o (! Any)) (Mixin i (! o)))) (function (_ delegate recur input) @@ -62,11 +62,11 @@ _ (action input output)] (in output)))) -(type: #export (Recursive i o) +(type: .public (Recursive i o) {#.doc (doc "An indirectly recursive function.")} (-> (-> i o) (-> i o))) -(def: #export (of_recursive recursive) +(def: .public (of_recursive recursive) {#.doc (doc "Transform an indirectly recursive function into a mixin.")} (All [i o] (-> (Recursive i o) (Mixin i o))) (function (_ delegate recur) diff --git a/stdlib/source/library/lux/control/function/mutual.lux b/stdlib/source/library/lux/control/function/mutual.lux index e292f19ee..6f0479cc6 100644 --- a/stdlib/source/library/lux/control/function/mutual.lux +++ b/stdlib/source/library/lux/control/function/mutual.lux @@ -22,7 +22,6 @@ ["." local] ["." code] [syntax (#+ syntax:) - ["." export] ["." declaration (#+ Declaration)]]]]] ["." //]) @@ -53,7 +52,7 @@ (function (_ parameters) (\ meta.monad in (list (` (((~ g!self) (~ g!context)) (~+ parameters)))))))) -(syntax: #export (let {functions (.tuple (<>.some ..mutual))} +(syntax: .public (let {functions (.tuple (<>.some ..mutual))} body) {#.doc (doc "Locally-defined mutually-recursive functions." (let [(even? number) @@ -111,24 +110,24 @@ (~ g!output)))))))))) (type: Definition - {#exported? Bit + {#export_policy Code #mutual Mutual}) (.def: definition (Parser Definition) - (.tuple (<>.and export.parser - ..mutual))) + (.tuple (<>.either (<>.and .any ..mutual) + (<>.and (<>\in (` .private)) ..mutual)))) -(syntax: #export (def: {functions (<>.many ..definition)}) +(syntax: .public (def: {functions (<>.many ..definition)}) {#.doc (doc "Globally-defined mutually-recursive functions." (def: - [#export (even? number) + [.public (even? number) (-> Nat Bit) (case number 0 true _ (odd? (dec number)))] - [#export (odd? number) + [.public (odd? number) (-> Nat Bit) (case number 0 false @@ -138,11 +137,9 @@ (in (list)) (#.Item definition #.End) - (.let [(^slots [#exported? #mutual]) definition + (.let [(^slots [#export_policy #mutual]) definition (^slots [#declaration #type #body]) mutual] - (in (list (` (.def: - (~+ (export.format exported?)) - (~ (declaration.format declaration)) + (in (list (` (.def: (~ export_policy) (~ (declaration.format declaration)) (~ type) (~ body)))))) @@ -178,7 +175,7 @@ (list\map (function (_ mutual) (.let [g!name (|> mutual (get@ [#mutual #declaration #declaration.name]) code.local_identifier)] (` (.def: - (~+ (export.format (get@ #exported? mutual))) + (~ (get@ #export_policy mutual)) (~ g!name) (~ (get@ [#mutual #type] mutual)) (.let [[(~+ user_names)] (~ g!context)] diff --git a/stdlib/source/library/lux/control/io.lux b/stdlib/source/library/lux/control/io.lux index b3d5893bd..843170c4c 100644 --- a/stdlib/source/library/lux/control/io.lux +++ b/stdlib/source/library/lux/control/io.lux @@ -15,25 +15,25 @@ [syntax (#+ syntax:)] ["." template]]]]) -(abstract: #export (IO a) - (-> Any a) - +(abstract: .public (IO a) {#.doc "A type that represents synchronous, effectful computations that may interact with the outside world."} + (-> Any a) + (def: label (All [a] (-> (-> Any a) (IO a))) (|>> :abstraction)) (template: (!io computation) - (:abstraction (template.with_locals [g!func g!arg] - (function (g!func g!arg) - computation)))) + [(:abstraction (template.with_locals [g!func g!arg] + (function (g!func g!arg) + computation)))]) (template: (!run io) ## creatio ex nihilo - ((:representation io) [])) + [((:representation io) [])]) - (syntax: #export (io computation) + (syntax: .public (io computation) {#.doc (doc "Delays the evaluation of an expression, by wrapping it in an IO 'thunk'." "Great for wrapping effectful computations (which will not be performed until the IO is 'run')." (io (exec @@ -43,18 +43,18 @@ (in (list (` ((~! ..label) (function ((~ g!func) (~ g!arg)) (~ computation)))))))) - (def: #export run + (def: .public run {#.doc "A way to execute IO computations and perform their side-effects."} (All [a] (-> (IO a) a)) (|>> !run)) - (implementation: #export functor + (implementation: .public functor (Functor IO) (def: (map f) (|>> !run f !io))) - (implementation: #export apply + (implementation: .public apply (Apply IO) (def: &functor ..functor) @@ -62,7 +62,7 @@ (def: (apply ff fa) (!io ((!run ff) (!run fa))))) - (implementation: #export monad + (implementation: .public monad (Monad IO) (def: &functor ..functor) diff --git a/stdlib/source/library/lux/control/parser.lux b/stdlib/source/library/lux/control/parser.lux index ad639f00f..8ddce370f 100644 --- a/stdlib/source/library/lux/control/parser.lux +++ b/stdlib/source/library/lux/control/parser.lux @@ -16,11 +16,11 @@ [number ["n" nat]]]]]) -(type: #export (Parser s a) +(type: .public (Parser s a) {#.doc "A generic parser."} (-> s (Try [s a]))) -(implementation: #export functor +(implementation: .public functor (All [s] (Functor (Parser s))) (def: (map f ma) @@ -32,7 +32,7 @@ (#try.Success [input' a]) (#try.Success [input' (f a)]))))) -(implementation: #export apply +(implementation: .public apply (All [s] (Apply (Parser s))) (def: &functor ..functor) @@ -51,7 +51,7 @@ (#try.Failure msg) (#try.Failure msg))))) -(implementation: #export monad +(implementation: .public monad (All [s] (Monad (Parser s))) (def: &functor ..functor) @@ -69,7 +69,7 @@ (#try.Success [input' ma]) (ma input'))))) -(def: #export (assertion message test) +(def: .public (assertion message test) {#.doc "Fails with the given message if the test is #0."} (All [s] (-> Text Bit (Parser s Any))) (function (_ input) @@ -77,7 +77,7 @@ (#try.Success [input []]) (#try.Failure message)))) -(def: #export (maybe parser) +(def: .public (maybe parser) {#.doc "Optionality combinator."} (All [s a] (-> (Parser s a) (Parser s (Maybe a)))) @@ -89,7 +89,7 @@ (#try.Success [input' x]) (#try.Success [input' (#.Some x)])))) -(def: #export (run parser input) +(def: .public (run parser input) {#.doc (doc "Executes the parser on the input." "Does not verify that all of the input has been consumed by the parser." "Returns both the parser's output, and a value that represents the remaining input.")} @@ -97,7 +97,7 @@ (-> (Parser s a) s (Try [s a]))) (parser input)) -(def: #export (and first second) +(def: .public (and first second) {#.doc "Sequencing combinator."} (All [s a b] (-> (Parser s a) (Parser s b) (Parser s [a b]))) @@ -105,7 +105,7 @@ [head first] (\ ! map (|>> [head]) second))) -(def: #export (or left right) +(def: .public (or left right) {#.doc "Heterogeneous alternative combinator."} (All [s a b] (-> (Parser s a) (Parser s b) (Parser s (Or a b)))) @@ -122,7 +122,7 @@ (#try.Failure error) (#try.Failure error))))) -(def: #export (either this that) +(def: .public (either this that) {#.doc "Homogeneous alternative combinator."} (All [s a] (-> (Parser s a) (Parser s a) (Parser s a))) @@ -134,7 +134,7 @@ output output))) -(def: #export (some parser) +(def: .public (some parser) {#.doc "0-or-more combinator."} (All [s a] (-> (Parser s a) (Parser s (List a)))) @@ -148,7 +148,7 @@ (some parser)) input')))) -(def: #export (many parser) +(def: .public (many parser) {#.doc "1-or-more combinator."} (All [s a] (-> (Parser s a) (Parser s (List a)))) @@ -156,7 +156,7 @@ (..and parser) (\ ..monad map (|>> #.Item)))) -(def: #export (exactly amount parser) +(def: .public (exactly amount parser) {#.doc "Parse exactly N times."} (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) (case amount @@ -167,14 +167,14 @@ (exactly (dec amount)) (\ ! map (|>> (#.Item x))))))) -(def: #export (at_least amount parser) +(def: .public (at_least amount parser) {#.doc "Parse at least N times."} (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) (do {! ..monad} [minimum (..exactly amount parser)] (\ ! map (list\compose minimum) (..some parser)))) -(def: #export (at_most amount parser) +(def: .public (at_most amount parser) {#.doc "Parse at most N times."} (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) (case amount @@ -189,7 +189,7 @@ (at_most (dec amount) parser)) input'))))) -(def: #export (between minimum additional parser) +(def: .public (between minimum additional parser) (All [s a] (-> Nat Nat (Parser s a) (Parser s (List a)))) (do {! ..monad} [minimum (..exactly minimum parser)] @@ -198,7 +198,7 @@ _ (\ ! map (list\compose minimum) (..at_most additional parser))))) -(def: #export (separated_by separator parser) +(def: .public (separated_by separator parser) {#.doc "Parses instances of 'parser' that are separated by instances of 'separator'."} (All [s a b] (-> (Parser s b) (Parser s a) (Parser s (List a)))) (do {! ..monad} @@ -213,7 +213,7 @@ ..some (\ ! map (|>> (list\map product.right) (#.Item x))))))) -(def: #export (not parser) +(def: .public (not parser) {#.doc (doc "Only succeeds when the underlying parser fails.")} (All [s a] (-> (Parser s a) (Parser s Any))) (function (_ input) @@ -224,13 +224,13 @@ _ (#try.Failure "Expected to fail; yet succeeded.")))) -(def: #export (failure message) +(def: .public (failure message) {#.doc (doc "Always fail with this 'message'.")} (All [s a] (-> Text (Parser s a))) (function (_ input) (#try.Failure message))) -(def: #export (lift operation) +(def: .public (lift operation) {#.doc (doc "Lift a potentially failed computation into a parser.")} (All [s a] (-> (Try a) (Parser s a))) (function (_ input) @@ -241,7 +241,7 @@ (#try.Failure error) (#try.Failure error)))) -(def: #export (else value parser) +(def: .public (else value parser) {#.doc "If the given parser fails, returns the default value."} (All [s a] (-> a (Parser s a) (Parser s a))) (function (_ input) @@ -252,26 +252,26 @@ (#try.Success [input' output]) (#try.Success [input' output])))) -(def: #export remaining +(def: .public remaining {#.doc (doc "Yield the remaining input (without consuming it).")} (All [s] (Parser s s)) (function (_ inputs) (#try.Success [inputs inputs]))) -(def: #export (rec parser) +(def: .public (rec parser) {#.doc "Combinator for recursive parsers."} (All [s a] (-> (-> (Parser s a) (Parser s a)) (Parser s a))) (function (_ inputs) (..run (parser (rec parser)) inputs))) -(def: #export (after param subject) +(def: .public (after param subject) {#.doc (doc "Run the parser after another one (whose output is ignored).")} (All [s _ a] (-> (Parser s _) (Parser s a) (Parser s a))) (do ..monad [_ param] subject)) -(def: #export (before param subject) +(def: .public (before param subject) {#.doc (doc "Run the parser before another one (whose output is ignored).")} (All [s _ a] (-> (Parser s _) (Parser s a) (Parser s a))) (do ..monad @@ -279,7 +279,7 @@ _ param] (in output))) -(def: #export (only test parser) +(def: .public (only test parser) {#.doc (doc "Only succeed when the parser's output passes a test.")} (All [s a] (-> (-> a Bit) (Parser s a) (Parser s a))) (do ..monad @@ -287,7 +287,7 @@ _ (..assertion "Constraint failed." (test output))] (in output))) -(def: #export (parses? parser) +(def: .public (parses? parser) {#.doc (doc "Ignore a parser's output and just verify that it succeeds.")} (All [s a] (-> (Parser s a) (Parser s Bit))) (function (_ input) @@ -298,7 +298,7 @@ (#try.Success [input' _]) (#try.Success [input' true])))) -(def: #export (parses parser) +(def: .public (parses parser) {#.doc (doc "Ignore a parser's output and just execute it.")} (All [s a] (-> (Parser s a) (Parser s Any))) (function (_ input) @@ -309,7 +309,7 @@ (#try.Success [input' _]) (#try.Success [input' []])))) -(def: #export (speculative parser) +(def: .public (speculative parser) {#.doc (doc "Executes a parser, without actually consuming the input." "That way, the same input can be consumed again by another parser.")} (All [s a] (-> (Parser s a) (Parser s a))) @@ -321,7 +321,7 @@ output output))) -(def: #export (codec codec parser) +(def: .public (codec codec parser) {#.doc (doc "Decode the output of a parser using a codec.")} (All [s a z] (-> (Codec a z) (Parser s a) (Parser s z))) (function (_ input) diff --git a/stdlib/source/library/lux/control/parser/analysis.lux b/stdlib/source/library/lux/control/parser/analysis.lux index 738960e55..7d64289bc 100644 --- a/stdlib/source/library/lux/control/parser/analysis.lux +++ b/stdlib/source/library/lux/control/parser/analysis.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Variant Tuple nat int rev) + [lux (#- Variant Tuple nat int rev local) [abstract [monad (#+ do)]] [control @@ -40,19 +40,19 @@ (list.interpose " ") (text.join_with "")))) -(exception: #export (cannot_parse {input (List Analysis)}) +(exception: .public (cannot_parse {input (List Analysis)}) (exception.report ["Input" (exception.listing /.%analysis input)])) -(exception: #export (unconsumed_input {input (List Analysis)}) +(exception: .public (unconsumed_input {input (List Analysis)}) (exception.report ["Input" (exception.listing /.%analysis input)])) -(type: #export Parser +(type: .public Parser {#.doc (doc "A parser for Lux code analysis nodes.")} (//.Parser (List Analysis))) -(def: #export (run parser input) +(def: .public (run parser input) {#.doc (doc "Executes a parser and makes sure no inputs go unconsumed.")} (All [a] (-> (Parser a) (List Analysis) (Try a))) (case (parser input) @@ -65,7 +65,7 @@ (#try.Success [unconsumed _]) (exception.except ..unconsumed_input unconsumed))) -(def: #export any +(def: .public any {#.doc (doc "Matches any value, without discrimination.")} (Parser Analysis) (function (_ input) @@ -76,7 +76,7 @@ (#.Item [head tail]) (#try.Success [tail head])))) -(def: #export end! +(def: .public end! {#.doc "Ensures there are no more inputs."} (Parser Any) (function (_ tokens) @@ -85,7 +85,7 @@ _ (#try.Failure (format "Expected list of tokens to be empty!" (remaining_inputs tokens)))))) -(def: #export end? +(def: .public end? {#.doc "Checks whether there are no more inputs."} (Parser Bit) (function (_ tokens) @@ -94,7 +94,7 @@ _ false)]))) (template [ ] - [(`` (as_is (def: #export + [(`` (as_is (def: .public {#.doc (doc (~~ (template.text ["Queries for a " " value."])))} (Parser ) (function (_ input) @@ -105,7 +105,7 @@ _ (exception.except ..cannot_parse input)))) - (def: #export ( expected) + (def: .public ( expected) {#.doc (doc (~~ (template.text ["Assert a specific " " value."])))} (-> (Parser Any)) (function (_ input) @@ -129,7 +129,7 @@ [constant constant! /.constant Name name.equivalence] ) -(def: #export (tuple parser) +(def: .public (tuple parser) {#.doc (doc "Parses only within the context of a tuple's contents.")} (All [a] (-> (Parser a) (Parser a))) (function (_ input) diff --git a/stdlib/source/library/lux/control/parser/binary.lux b/stdlib/source/library/lux/control/parser/binary.lux index fd4e1880a..fe10ed1ee 100644 --- a/stdlib/source/library/lux/control/parser/binary.lux +++ b/stdlib/source/library/lux/control/parser/binary.lux @@ -26,20 +26,20 @@ ["." frac]]]]] ["." // ("#\." monad)]) -(type: #export Offset +(type: .public Offset {#.doc (doc "An offset for reading within binary data.")} Nat) -(type: #export Parser +(type: .public Parser {#.doc (doc "A parser for raw binary data.")} (//.Parser [Offset Binary])) -(exception: #export (binary_was_not_fully_read {binary_length Nat} {bytes_read Nat}) +(exception: .public (binary_was_not_fully_read {binary_length Nat} {bytes_read Nat}) (exception.report ["Binary length" (%.nat binary_length)] ["Bytes read" (%.nat bytes_read)])) -(def: #export (run parser input) +(def: .public (run parser input) {#.doc (doc "Runs a parser and checks that all the binary data was read by it.")} (All [a] (-> (Parser a) Binary (Try a))) (case (parser [0 input]) @@ -52,35 +52,35 @@ (#try.Success output) (exception.except ..binary_was_not_fully_read [length end]))))) -(def: #export end? +(def: .public end? {#.doc (doc "Checks whether there is no more data to read.")} (Parser Bit) (function (_ (^@ input [offset data])) (#try.Success [input (n.= offset (/.size data))]))) -(def: #export offset +(def: .public offset {#.doc (doc "The current offset (i.e. how much data has been read).")} (Parser Offset) (function (_ (^@ input [offset data])) (#try.Success [input offset]))) -(def: #export remaining +(def: .public remaining {#.doc (doc "How much of the data remains to be read.")} (Parser Nat) (function (_ (^@ input [offset data])) (#try.Success [input (n.- offset (/.size data))]))) -(type: #export Size +(type: .public Size {#.doc (doc "The size of a chunk of data within a binary array.")} Nat) -(def: #export size/8 Size 1) -(def: #export size/16 Size (n.* 2 size/8)) -(def: #export size/32 Size (n.* 2 size/16)) -(def: #export size/64 Size (n.* 2 size/32)) +(def: .public size/8 Size 1) +(def: .public size/16 Size (n.* 2 size/8)) +(def: .public size/32 Size (n.* 2 size/16)) +(def: .public size/64 Size (n.* 2 size/32)) (template [ ] - [(def: #export + [(def: .public (Parser I64) (function (_ [offset binary]) (case ( offset binary) @@ -97,55 +97,55 @@ ) (template [ ] - [(def: #export (Parser ) ..bits/64)] + [(def: .public (Parser ) ..bits/64)] [nat Nat] [int Int] [rev Rev] ) -(def: #export frac +(def: .public frac (Parser Frac) (//\map frac.of_bits ..bits/64)) -(exception: #export (invalid_tag {range Nat} {byte Nat}) +(exception: .public (invalid_tag {range Nat} {byte Nat}) (exception.report ["Tag range" (%.nat range)] ["Tag value" (%.nat byte)])) (template: (!variant +) - (do {! //.monad} - [flag (: (Parser Nat) - ..bits/8)] - (`` (case flag - (^template [ ] - [ (\ ! map (|>> ) )]) - ((~~ (template.spliced +))) - _ (//.lift (exception.except ..invalid_tag [(~~ (template.amount +)) flag])))))) - -(def: #export (or left right) + [(do {! //.monad} + [flag (: (Parser Nat) + ..bits/8)] + (`` (case flag + (^template [ ] + [ (\ ! map (|>> ) )]) + ((~~ (template.spliced +))) + _ (//.lift (exception.except ..invalid_tag [(~~ (template.amount +)) flag])))))]) + +(def: .public (or left right) (All [l r] (-> (Parser l) (Parser r) (Parser (Or l r)))) (!variant [[0 #.Left left] [1 #.Right right]])) -(def: #export (rec body) +(def: .public (rec body) {#.doc (doc "Tie the knot for a recursive parser.")} (All [a] (-> (-> (Parser a) (Parser a)) (Parser a))) (function (_ input) (let [parser (body (rec body))] (parser input)))) -(def: #export any +(def: .public any {#.doc (doc "Does no parsing, and just returns a dummy value.")} (Parser Any) (//\in [])) -(exception: #export (not_a_bit {value Nat}) +(exception: .public (not_a_bit {value Nat}) (exception.report ["Expected values" "either 0 or 1"] ["Actual value" (%.nat value)])) -(def: #export bit +(def: .public bit (Parser Bit) (do //.monad [value (: (Parser Nat) @@ -155,7 +155,7 @@ 1 (in #1) _ (//.lift (exception.except ..not_a_bit [value]))))) -(def: #export (segment size) +(def: .public (segment size) {#.doc (doc "Parses a chunk of data of a given size.")} (-> Nat (Parser Binary)) (function (_ [offset binary]) @@ -166,7 +166,7 @@ (\ try.monad map (|>> [[(n.+ size offset) binary]])))))) (template [ ] - [(`` (def: #export + [(`` (def: .public {#.doc (doc (~~ (template.text ["Parses a block of data prefixed with a size that is " " bytes long."])))} (Parser Binary) (do //.monad @@ -180,7 +180,7 @@ ) (template [ ] - [(`` (def: #export + [(`` (def: .public {#.doc (doc (~~ (template.text ["Parses a block of (UTF-8 encoded) text prefixed with a size that is " " bytes long."])))} (Parser Text) (do //.monad @@ -193,10 +193,10 @@ [64 utf8/64 ..binary/64] ) -(def: #export text ..utf8/64) +(def: .public text ..utf8/64) (template [ ] - [(def: #export ( valueP) + [(def: .public ( valueP) {#.doc (doc (~~ (template.text ["Parses a row of values prefixed with a size that is " " bytes long."])))} (All [v] (-> (Parser v) (Parser (Row v)))) (do //.monad @@ -222,20 +222,20 @@ [64 row/64 ..bits/64] ) -(def: #export maybe +(def: .public maybe (All [a] (-> (Parser a) (Parser (Maybe a)))) (..or ..any)) -(def: #export (list value) +(def: .public (list value) {#.doc (doc "Parses an arbitrarily long list of values.")} (All [a] (-> (Parser a) (Parser (List a)))) (..rec (|>> (//.and value) (..or ..any)))) -(exception: #export set_elements_are_not_unique) +(exception: .public set_elements_are_not_unique) -(def: #export (set hash value) +(def: .public (set hash value) (All [a] (-> (Hash a) (Parser a) (Parser (Set a)))) (do //.monad [raw (..list value) @@ -245,11 +245,11 @@ (set.size output)))] (in output))) -(def: #export name +(def: .public name (Parser Name) (//.and ..text ..text)) -(def: #export type +(def: .public type (Parser Type) (..rec (function (_ type) @@ -268,11 +268,11 @@ [9 #.Apply pair] [10 #.Named (//.and ..name type)]]))))) -(def: #export location +(def: .public location (Parser Location) ($_ //.and ..text ..nat ..nat)) -(def: #export code +(def: .public code (Parser Code) (..rec (function (_ recur) diff --git a/stdlib/source/library/lux/control/parser/cli.lux b/stdlib/source/library/lux/control/parser/cli.lux index df59dbd44..b4051eb43 100644 --- a/stdlib/source/library/lux/control/parser/cli.lux +++ b/stdlib/source/library/lux/control/parser/cli.lux @@ -10,11 +10,11 @@ ["%" format (#+ format)]]]]] ["." //]) -(type: #export (Parser a) +(type: .public (Parser a) {#.doc "A command-line interface parser."} (//.Parser (List Text) a)) -(def: #export (run parser inputs) +(def: .public (run parser inputs) {#.doc (doc "Executes the parser and verifies that all inputs are processed.")} (All [a] (-> (Parser a) (List Text) (Try a))) (case (//.run parser inputs) @@ -29,7 +29,7 @@ (#try.Failure try) (#try.Failure try))) -(def: #export any +(def: .public any {#.doc "Just returns the next input without applying any logic."} (Parser Text) (function (_ inputs) @@ -40,7 +40,7 @@ _ (#try.Failure "Cannot parse empty arguments.")))) -(def: #export (parse parser) +(def: .public (parse parser) {#.doc "Parses the next input with a parsing function."} (All [a] (-> (-> Text (Try a)) (Parser a))) (function (_ inputs) @@ -49,7 +49,7 @@ output (parser raw)] (in [remaining output])))) -(def: #export (this reference) +(def: .public (this reference) {#.doc "Checks that a token is in the inputs."} (-> Text (Parser Any)) (function (_ inputs) @@ -59,7 +59,7 @@ (in [remaining []]) (#try.Failure (format "Missing token: '" reference "'")))))) -(def: #export (somewhere cli) +(def: .public (somewhere cli) {#.doc "Given a parser, tries to parse it somewhere in the inputs (i.e. not necessarily parsing the immediate inputs)."} (All [a] (-> (Parser a) (Parser a))) (function (_ inputs) @@ -79,7 +79,7 @@ (in [(#.Item to_omit remaining) output]))))))) -(def: #export end +(def: .public end {#.doc "Ensures there are no more inputs."} (Parser Any) (function (_ inputs) @@ -87,14 +87,14 @@ #.End (#try.Success [inputs []]) _ (#try.Failure (format "Unknown parameters: " (text.join_with " " inputs)))))) -(def: #export (named name value) +(def: .public (named name value) {#.doc (doc "Parses a named parameter and yields its value.")} (All [a] (-> Text (Parser a) (Parser a))) (|> value (//.after (..this name)) ..somewhere)) -(def: #export (parameter [short long] value) +(def: .public (parameter [short long] value) {#.doc (doc "Parses a parameter that can have either a short or a long name.")} (All [a] (-> [Text Text] (Parser a) (Parser a))) (|> value diff --git a/stdlib/source/library/lux/control/parser/code.lux b/stdlib/source/library/lux/control/parser/code.lux index 6edbb9ed1..c3ac5dca0 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) + [lux (#- nat int rev local) [abstract ["." monad (#+ do)]] [control @@ -27,7 +27,7 @@ #.End #.End (#.Item [[x y] pairs']) (list& x y (un_paired pairs')))) -(type: #export Parser +(type: .public Parser {#.doc "A Lux code parser."} (//.Parser (List Code))) @@ -36,7 +36,7 @@ ($_ text\compose text.new_line "Remaining input: " (|> codes (list\map code.format) (list.interpose " ") (text.join_with "")))) -(def: #export any +(def: .public any {#.doc "Yields the next input without applying any logic."} (Parser Code) (function (_ tokens) @@ -49,7 +49,7 @@ (template [ ] [(with_expansions [ (as_is (#try.Failure ($_ text\compose "Cannot parse " (remaining_inputs tokens))))] - (def: #export + (def: .public {#.doc (code.text ($_ text\compose "Parses the next " " input."))} (Parser ) (function (_ tokens) @@ -60,7 +60,7 @@ _ ))) - (def: #export ( expected) + (def: .public ( expected) {#.doc (code.text ($_ text\compose "Checks for a specific " " input."))} (-> (Parser Any)) (function (_ tokens) @@ -83,7 +83,7 @@ [tag tag! Name #.Tag name.equivalence "tag"] ) -(def: #export (this! code) +(def: .public (this! code) {#.doc "Ensures the given Code is the next input."} (-> Code (Parser Any)) (function (_ tokens) @@ -99,7 +99,7 @@ (template [ ] [(with_expansions [ (as_is (#try.Failure ($_ text\compose "Cannot parse " (remaining_inputs tokens))))] - (def: #export + (def: .public {#.doc (code.text ($_ text\compose "Parse a local " " (a " " that has no module prefix)."))} (Parser Text) (function (_ tokens) @@ -110,7 +110,7 @@ _ ))) - (def: #export ( expected) + (def: .public ( expected) {#.doc (code.text ($_ text\compose "Checks for a specific local " " (a " " that has no module prefix)."))} (-> Text (Parser Any)) (function (_ tokens) @@ -128,7 +128,7 @@ ) (template [ ] - [(def: #export ( p) + [(def: .public ( p) {#.doc (code.text ($_ text\compose "Parses the contents of a " "."))} (All [a] (-> (Parser a) (Parser a))) @@ -146,7 +146,7 @@ [tuple #.Tuple "tuple"] ) -(def: #export (record p) +(def: .public (record p) {#.doc "Parses the contents of a record."} (All [a] (-> (Parser a) (Parser a))) @@ -160,7 +160,7 @@ _ (#try.Failure ($_ text\compose "Cannot parse record" (remaining_inputs tokens)))))) -(def: #export end! +(def: .public end! {#.doc "Verifies there are no more inputs."} (Parser Any) (function (_ tokens) @@ -168,7 +168,7 @@ #.End (#try.Success [tokens []]) _ (#try.Failure ($_ text\compose "Expected list of tokens to be empty!" (remaining_inputs tokens)))))) -(def: #export end? +(def: .public end? {#.doc "Checks whether there are no more inputs."} (Parser Bit) (function (_ tokens) @@ -176,7 +176,7 @@ #.End true _ false)]))) -(def: #export (run parser inputs) +(def: .public (run parser inputs) {#.doc (doc "Executes a parser against a stream of code, and verifies all the inputs are consumed.")} (All [a] (-> (Parser a) (List Code) (Try a))) (case (parser inputs) @@ -193,7 +193,7 @@ (|> (list\map code.format unconsumed) (text.join_with ", "))))))) -(def: #export (local inputs parser) +(def: .public (local inputs parser) {#.doc "Runs parser against the given list of inputs."} (All [a] (-> (List Code) (Parser a) (Parser a))) (function (_ real) diff --git a/stdlib/source/library/lux/control/parser/environment.lux b/stdlib/source/library/lux/control/parser/environment.lux index b7d2d8ebf..fe7c0ea59 100644 --- a/stdlib/source/library/lux/control/parser/environment.lux +++ b/stdlib/source/library/lux/control/parser/environment.lux @@ -12,28 +12,28 @@ ["." dictionary (#+ Dictionary)]]]]] ["." //]) -(type: #export Property +(type: .public Property {#.doc (doc "A property in the environment.")} Text) -(type: #export Environment +(type: .public Environment {#.doc (doc "An abstraction for environment variables of a program.")} (Dictionary Property Text)) -(exception: #export (unknown_property {property Property}) +(exception: .public (unknown_property {property Property}) (exception.report ["Property" (%.text property)])) -(type: #export (Parser a) +(type: .public (Parser a) {#.doc (doc "A parser of environment variables of a program.")} (//.Parser Environment a)) -(def: #export empty +(def: .public empty {#.doc (doc "An empty environment.")} Environment (dictionary.empty text.hash)) -(def: #export (property name) +(def: .public (property name) (-> Property (Parser Text)) (function (_ environment) (case (dictionary.get name environment) @@ -43,7 +43,7 @@ #.None (exception.except ..unknown_property [name])))) -(def: #export (run parser environment) +(def: .public (run parser environment) {#.doc (doc "Executes a parser against the given environment variables." "Does not check whether all environment variables were parsed, since they're usually an open set.")} (All [a] (-> (Parser a) Environment (Try a))) diff --git a/stdlib/source/library/lux/control/parser/json.lux b/stdlib/source/library/lux/control/parser/json.lux index 74747195d..f1112ffbe 100644 --- a/stdlib/source/library/lux/control/parser/json.lux +++ b/stdlib/source/library/lux/control/parser/json.lux @@ -22,17 +22,17 @@ ["." frac]]]]] ["." // ("#\." functor)]) -(type: #export (Parser a) +(type: .public (Parser a) {#.doc "A JSON parser."} (//.Parser (List JSON) a)) -(exception: #export (unconsumed_input {input (List JSON)}) +(exception: .public (unconsumed_input {input (List JSON)}) (exception.report ["Input" (exception.listing /.format input)])) -(exception: #export empty_input) +(exception: .public empty_input) -(def: #export (run parser json) +(def: .public (run parser json) {#.doc (doc "Executes the parser against a JSON object." "Verifies that all of the JSON was consumed by the parser.")} (All [a] (-> (Parser a) JSON (Try a))) @@ -48,7 +48,7 @@ (#try.Failure error) (#try.Failure error))) -(def: #export any +(def: .public any {#.doc "Just returns the JSON input without applying any logic."} (Parser JSON) (<| (function (_ inputs)) @@ -59,12 +59,12 @@ (#.Item head tail) (#try.Success [tail head])))) -(exception: #export (unexpected_value {value JSON}) +(exception: .public (unexpected_value {value JSON}) (exception.report ["Value" (/.format value)])) (template [ ] - [(def: #export + [(def: .public {#.doc (code.text ($_ text\compose "Reads a JSON value as " "."))} (Parser ) (do //.monad @@ -82,13 +82,13 @@ [string /.String #/.String "string"] ) -(exception: #export [a] (value_mismatch {reference JSON} {sample JSON}) +(exception: .public [a] (value_mismatch {reference JSON} {sample JSON}) (exception.report ["Reference" (/.format reference)] ["Sample" (/.format sample)])) (template [ ] - [(def: #export ( test) + [(def: .public ( test) {#.doc (code.text ($_ text\compose "Asks whether a JSON value is a " "."))} (-> (Parser Bit)) (do //.monad @@ -100,7 +100,7 @@ _ (//.failure (exception.error ..unexpected_value [head]))))) - (def: #export ( test) + (def: .public ( test) {#.doc (code.text ($_ text\compose "Ensures a JSON value is a " "."))} (-> (Parser Any)) (do //.monad @@ -119,13 +119,13 @@ [string? string! /.String text.equivalence #/.String "string"] ) -(def: #export (nullable parser) +(def: .public (nullable parser) {#.doc (doc "Enhances parser by adding NULL-handling.")} (All [a] (-> (Parser a) (Parser (Maybe a)))) (//.or ..null parser)) -(def: #export (array parser) +(def: .public (array parser) {#.doc "Parses the contents of a JSON array."} (All [a] (-> (Parser a) (Parser a))) (do //.monad @@ -147,7 +147,7 @@ _ (//.failure (exception.error ..unexpected_value [head]))))) -(def: #export (object parser) +(def: .public (object parser) {#.doc (doc "Parses the contents of a JSON object." "Use this with the 'field' combinator.")} (All [a] (-> (Parser a) (Parser a))) @@ -175,7 +175,7 @@ _ (//.failure (exception.error ..unexpected_value [head]))))) -(def: #export (field field_name parser) +(def: .public (field field_name parser) {#.doc (doc "Parses a field inside a JSON object." "Use this inside the 'object' combinator.")} (All [a] (-> Text (Parser a) (Parser a))) @@ -203,7 +203,7 @@ _ (exception.except ..unconsumed_input inputs)))) -(def: #export dictionary +(def: .public dictionary {#.doc "Parses a dictionary-like JSON object."} (All [a] (-> (Parser a) (Parser (Dictionary Text a)))) (|>> (//.and ..string) diff --git a/stdlib/source/library/lux/control/parser/synthesis.lux b/stdlib/source/library/lux/control/parser/synthesis.lux index 1ecdaab9e..cde50518e 100644 --- a/stdlib/source/library/lux/control/parser/synthesis.lux +++ b/stdlib/source/library/lux/control/parser/synthesis.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Variant Tuple function loop i64) + [lux (#- Variant Tuple function loop i64 local) [abstract [monad (#+ do)]] [control @@ -29,30 +29,30 @@ ["/" synthesis (#+ Synthesis Abstraction)]]]]]]] ["." //]) -(exception: #export (cannot_parse {input (List Synthesis)}) +(exception: .public (cannot_parse {input (List Synthesis)}) (exception.report ["Input" (exception.listing /.%synthesis input)])) -(exception: #export (unconsumed_input {input (List Synthesis)}) +(exception: .public (unconsumed_input {input (List Synthesis)}) (exception.report ["Input" (exception.listing /.%synthesis input)])) -(exception: #export (expected_empty_input {input (List Synthesis)}) +(exception: .public (expected_empty_input {input (List Synthesis)}) (exception.report ["Input" (exception.listing /.%synthesis input)])) -(exception: #export (wrong_arity {expected Arity} {actual Arity}) +(exception: .public (wrong_arity {expected Arity} {actual Arity}) (exception.report ["Expected" (%.nat expected)] ["Actual" (%.nat actual)])) -(exception: #export empty_input) +(exception: .public empty_input) -(type: #export Parser +(type: .public Parser {#.doc (doc "A parser for the Lux compiler's synthesis nodes using during optimization.")} (//.Parser (List Synthesis))) -(def: #export (run parser input) +(def: .public (run parser input) {#.doc (doc "Executes the parser against the inputs." "Ensures all inputs are consumed by the parser.")} (All [a] (-> (Parser a) (List Synthesis) (Try a))) @@ -66,7 +66,7 @@ (#try.Success [unconsumed _]) (exception.except ..unconsumed_input unconsumed))) -(def: #export any +(def: .public any {#.doc (doc "Yields a synthesis node without subjecting it to any analysis.")} (Parser Synthesis) (.function (_ input) @@ -77,7 +77,7 @@ (#.Item [head tail]) (#try.Success [tail head])))) -(def: #export end! +(def: .public end! {#.doc "Ensures there are no more inputs."} (Parser Any) (.function (_ tokens) @@ -85,7 +85,7 @@ #.End (#try.Success [tokens []]) _ (exception.except ..expected_empty_input [tokens])))) -(def: #export end? +(def: .public end? {#.doc "Checks whether there are no more inputs."} (Parser Bit) (.function (_ tokens) @@ -94,7 +94,7 @@ _ false)]))) (template [ ] - [(`` (def: #export + [(`` (def: .public {#.doc (doc (~~ (template.text ["Queries for a " " synthesis node."])))} (Parser ) (.function (_ input) @@ -105,7 +105,7 @@ _ (exception.except ..cannot_parse input))))) - (`` (def: #export ( expected) + (`` (def: .public ( expected) {#.doc (doc (~~ (template.text ["Checks for a specific " " synthesis node."])))} (-> (Parser Any)) (.function (_ input) @@ -127,7 +127,7 @@ [constant constant! /.constant Name name.equivalence] ) -(def: #export (tuple parser) +(def: .public (tuple parser) {#.doc (doc "Parses the contents of a tuple.")} (All [a] (-> (Parser a) (Parser a))) (.function (_ input) @@ -140,7 +140,7 @@ _ (exception.except ..cannot_parse input)))) -(def: #export (function expected parser) +(def: .public (function expected parser) {#.doc (doc "Parses the body of a function with the 'expected' arity.")} (All [a] (-> Arity (Parser a) (Parser [(Environment Synthesis) a]))) (.function (_ input) @@ -155,7 +155,7 @@ _ (exception.except ..cannot_parse input)))) -(def: #export (loop init_parsers iteration_parser) +(def: .public (loop init_parsers iteration_parser) {#.doc (doc "Parses the initial values and the body of a loop.")} (All [a b] (-> (Parser a) (Parser b) (Parser [Register a b]))) (.function (_ input) diff --git a/stdlib/source/library/lux/control/parser/text.lux b/stdlib/source/library/lux/control/parser/text.lux index fcabe68ab..f593f311f 100644 --- a/stdlib/source/library/lux/control/parser/text.lux +++ b/stdlib/source/library/lux/control/parser/text.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- or and not) + [lux (#- or and not local) [abstract [monad (#+ Monad do)]] [control @@ -20,7 +20,7 @@ ["n" nat ("#\." decimal)]]]]] ["." //]) -(type: #export Offset +(type: .public Offset {#.doc (doc "An offset into a block of text.")} Nat) @@ -28,11 +28,11 @@ Offset 0) -(type: #export Parser +(type: .public Parser {#.doc (doc "A parser for text.")} (//.Parser [Offset Text])) -(type: #export Slice +(type: .public Slice {#.doc (doc "A slice of a block of text.")} {#basis Offset #distance Offset}) @@ -41,21 +41,21 @@ (-> Offset Text Text) (|> tape (/.split offset) maybe.assume product.right)) -(exception: #export (unconsumed_input {offset Offset} {tape Text}) +(exception: .public (unconsumed_input {offset Offset} {tape Text}) (exception.report ["Offset" (n\encode offset)] ["Input size" (n\encode (/.size tape))] ["Remaining input" (remaining' offset tape)])) -(exception: #export (expected_to_fail {offset Offset} {tape Text}) +(exception: .public (expected_to_fail {offset Offset} {tape Text}) (exception.report ["Offset" (n\encode offset)] ["Input" (remaining' offset tape)])) -(exception: #export cannot_parse) -(exception: #export cannot_slice) +(exception: .public cannot_parse) +(exception: .public cannot_slice) -(def: #export (run parser input) +(def: .public (run parser input) {#.doc (doc "Executes a parser against a block of text." "Verifies that the entire input has been processed.")} (All [a] (-> (Parser a) Text (Try a))) @@ -68,7 +68,7 @@ (#try.Success output) (exception.except ..unconsumed_input [end_offset input])))) -(def: #export offset +(def: .public offset {#.doc (doc "Yields the current offset into the input.")} (Parser Offset) (function (_ (^@ input [offset tape])) @@ -86,7 +86,7 @@ #distance 0} slices)))) -(def: #export any +(def: .public any {#.doc "Yields the next character without applying any logic."} (Parser Text) (function (_ [offset tape]) @@ -97,7 +97,7 @@ _ (exception.except ..cannot_parse [])))) -(def: #export any! +(def: .public any! {#.doc "Yields the next character (as a slice) without applying any logic."} (Parser Slice) (function (_ [offset tape]) @@ -111,7 +111,7 @@ (exception.except ..cannot_slice [])))) (template [ ] - [(`` (def: #export ( parser) + [(`` (def: .public ( parser) {#.doc (doc (~~ (template.text ["Produce a character" " if the parser fails."])))} (All [a] (-> (Parser a) (Parser ))) (function (_ input) @@ -126,11 +126,11 @@ [not! Slice ..any! " (as a slice)"] ) -(exception: #export (cannot_match {reference Text}) +(exception: .public (cannot_match {reference Text}) (exception.report ["Reference" (/.format reference)])) -(def: #export (this reference) +(def: .public (this reference) {#.doc (doc "Checks that a specific text shows up in the input.")} (-> Text (Parser Any)) (function (_ [offset tape]) @@ -144,7 +144,7 @@ _ (exception.except ..cannot_match [reference])))) -(def: #export end! +(def: .public end! {#.doc "Ensure the parser's input is empty."} (Parser Any) (function (_ (^@ input [offset tape])) @@ -152,7 +152,7 @@ (#try.Success [input []]) (exception.except ..unconsumed_input input)))) -(def: #export peek +(def: .public peek {#.doc "Yields the next character (without consuming it from the input)."} (Parser Text) (function (_ (^@ input [offset tape])) @@ -163,13 +163,13 @@ _ (exception.except ..cannot_parse [])))) -(def: #export remaining +(def: .public remaining {#.doc "Get all of the remaining input (without consuming it)."} (Parser Text) (function (_ (^@ input [offset tape])) (#try.Success [input (remaining' offset tape)]))) -(def: #export (range bottom top) +(def: .public (range bottom top) {#.doc "Only yields characters within a range."} (-> Nat Nat (Parser Text)) (do //.monad @@ -181,7 +181,7 @@ (in char))) (template [ ] - [(def: #export + [(def: .public {#.doc (code.text ($_ /\compose "Only yields " " characters."))} (Parser Text) (..range (char ) (char )))] @@ -192,17 +192,17 @@ [octal "0" "7" "octal"] ) -(def: #export alpha +(def: .public alpha {#.doc "Yields alphabetic characters."} (Parser Text) (//.either lower upper)) -(def: #export alpha_num +(def: .public alpha_num {#.doc "Yields alphanumeric characters."} (Parser Text) (//.either alpha decimal)) -(def: #export hexadecimal +(def: .public hexadecimal {#.doc "Yields hexadecimal digits."} (Parser Text) ($_ //.either @@ -211,7 +211,7 @@ (range (char "A") (char "F")))) (template [] - [(exception: #export ( {options Text} {character Char}) + [(exception: .public ( {options Text} {character Char}) (exception.report ["Options" (/.format options)] ["Character" (/.format (/.of_char character))]))] @@ -221,7 +221,7 @@ ) (template [ ] - [(def: #export ( options) + [(def: .public ( options) {#.doc (code.text ($_ /\compose "Yields characters that are" " part of a piece of text."))} (-> Text (Parser Text)) (function (_ [offset tape]) @@ -240,7 +240,7 @@ ) (template [ ] - [(def: #export ( options) + [(def: .public ( options) {#.doc (code.text ($_ /\compose "Yields characters (as a slice) that are" " part of a piece of text."))} (-> Text (Parser Slice)) (function (_ [offset tape]) @@ -260,11 +260,11 @@ [none_of! .not ..character_should_not_be " not"] ) -(exception: #export (character_does_not_satisfy_predicate {character Char}) +(exception: .public (character_does_not_satisfy_predicate {character Char}) (exception.report ["Character" (/.format (/.of_char character))])) -(def: #export (satisfies parser) +(def: .public (satisfies parser) {#.doc "Yields characters that satisfy a predicate."} (-> (-> Char Bit) (Parser Text)) (function (_ [offset tape]) @@ -277,12 +277,12 @@ _ (exception.except ..cannot_parse [])))) -(def: #export space +(def: .public space {#.doc "Yields white-space."} (Parser Text) (..satisfies /.space?)) -(def: #export (and left right) +(def: .public (and left right) {#.doc (doc "Yields the outputs of both parsers composed together.")} (-> (Parser Text) (Parser Text) (Parser Text)) (do //.monad @@ -290,7 +290,7 @@ =right right] (in ($_ /\compose =left =right)))) -(def: #export (and! left right) +(def: .public (and! left right) {#.doc (doc "Yields the outputs of both parsers composed together (as a slice).")} (-> (Parser Slice) (Parser Slice) (Parser Slice)) (do //.monad @@ -299,7 +299,7 @@ (in [left::basis ("lux i64 +" left::distance right::distance)]))) (template [ ] - [(def: #export ( parser) + [(def: .public ( parser) {#.doc (code.text ($_ /\compose "Yields " " characters as a single continuous text (as a slice)."))} (-> (Parser Text) (Parser Text)) (|> parser (\ //.monad map /.concat)))] @@ -309,7 +309,7 @@ ) (template [ ] - [(def: #export ( parser) + [(def: .public ( parser) {#.doc (code.text ($_ /\compose "Yields " " characters as a single continuous text (as a slice)."))} (-> (Parser Slice) (Parser Slice)) (with_slices ( parser)))] @@ -319,7 +319,7 @@ ) (template [ ] - [(def: #export ( amount parser) + [(def: .public ( amount parser) {#.doc (code.text ($_ /\compose "Yields " " N characters (as a slice)."))} (-> Nat (Parser Text) (Parser Text)) (|> parser @@ -332,7 +332,7 @@ ) (template [ ] - [(def: #export ( amount parser) + [(def: .public ( amount parser) {#.doc (code.text ($_ /\compose "Yields " " N characters (as a slice)."))} (-> Nat (Parser Slice) (Parser Slice)) (with_slices @@ -343,24 +343,24 @@ [at_least! //.at_least "at least"] ) -(def: #export (between minimum additional parser) +(def: .public (between minimum additional parser) (-> Nat Nat (Parser Text) (Parser Text)) (|> parser (//.between minimum additional) (\ //.monad map /.concat))) -(def: #export (between! minimum additional parser) +(def: .public (between! minimum additional parser) (-> Nat Nat (Parser Slice) (Parser Slice)) (with_slices (//.between minimum additional parser))) -(def: #export (enclosed [start end] parser) +(def: .public (enclosed [start end] parser) (All [a] (-> [Text Text] (Parser a) (Parser a))) (|> parser (//.before (this end)) (//.after (this start)))) -(def: #export (local local_input parser) +(def: .public (local local_input parser) {#.doc "Applies a parser against the given input."} (All [a] (-> Text (Parser a) (Parser a))) (function (_ real_input) @@ -371,7 +371,7 @@ (#try.Success value) (#try.Success [real_input value])))) -(def: #export (slice parser) +(def: .public (slice parser) {#.doc (doc "Converts a slice to a block of text.")} (-> (Parser Slice) (Parser Text)) (do //.monad @@ -384,7 +384,7 @@ #.None (exception.except ..cannot_slice []))))) -(def: #export (then structured text) +(def: .public (then structured text) {#.doc (doc "Embeds a text parser into an arbitrary parser that yields text.")} (All [s a] (-> (Parser a) diff --git a/stdlib/source/library/lux/control/parser/tree.lux b/stdlib/source/library/lux/control/parser/tree.lux index ad2015624..6daf1129e 100644 --- a/stdlib/source/library/lux/control/parser/tree.lux +++ b/stdlib/source/library/lux/control/parser/tree.lux @@ -12,32 +12,32 @@ ["." zipper (#+ Zipper)]]]]]] ["." //]) -(type: #export (Parser t a) +(type: .public (Parser t a) {#.doc (doc "A parser of arbitrary trees.")} (//.Parser (Zipper t) a)) -(def: #export (run' parser zipper) +(def: .public (run' parser zipper) {#.doc (doc "Applies the parser against a tree zipper.")} (All [t a] (-> (Parser t a) (Zipper t) (Try a))) (do try.monad [[zipper output] (//.run parser zipper)] (in output))) -(def: #export (run parser tree) +(def: .public (run parser tree) {#.doc (doc "Applies the parser against a tree.")} (All [t a] (-> (Parser t a) (Tree t) (Try a))) (run' parser (zipper.zipper tree))) -(def: #export value +(def: .public value {#.doc (doc "Yields the value inside the current tree node.")} (All [t] (Parser t t)) (function (_ zipper) (#try.Success [zipper (zipper.value zipper)]))) -(exception: #export cannot_move_further) +(exception: .public cannot_move_further) (template [ ] - [(def: #export + [(def: .public {#.doc (doc )} (All [t] (Parser t [])) (function (_ zipper) diff --git a/stdlib/source/library/lux/control/parser/type.lux b/stdlib/source/library/lux/control/parser/type.lux index 0e07c633c..6e5c0f005 100644 --- a/stdlib/source/library/lux/control/parser/type.lux +++ b/stdlib/source/library/lux/control/parser/type.lux @@ -2,7 +2,7 @@ {#.doc (.doc "Parsing of Lux types." "Used mostly for polytypic programming.")} [library - [lux (#- function) + [lux (#- function local) [abstract ["." monad (#+ do)]] [control @@ -26,7 +26,7 @@ ["." //]) (template [] - [(exception: #export ( {type Type}) + [(exception: .public ( {type Type}) (exception.report ["Type" (%.type type)]))] @@ -43,7 +43,7 @@ ) (template [] - [(exception: #export ( {expected Type} {actual Type}) + [(exception: .public ( {expected Type} {actual Type}) (exception.report ["Expected" (%.type expected)] ["Actual" (%.type actual)]))] @@ -52,23 +52,23 @@ [wrong_parameter] ) -(exception: #export empty_input) +(exception: .public empty_input) -(exception: #export (unconsumed_input {remaining (List Type)}) +(exception: .public (unconsumed_input {remaining (List Type)}) (exception.report ["Types" (|> remaining (list\map (|>> %.type (format text.new_line "* "))) (text.join_with ""))])) -(type: #export Env +(type: .public Env {#.doc (doc "An environment for type parsing.")} (Dictionary Nat [Type Code])) -(type: #export (Parser a) +(type: .public (Parser a) {#.doc (doc "A parser of Lux types.")} (//.Parser [Env (List Type)] a)) -(def: #export fresh +(def: .public fresh {#.doc (doc "An empty parsing environment.")} Env (dictionary.empty n.hash)) @@ -87,13 +87,13 @@ _ (exception.except ..unconsumed_input remaining)))) -(def: #export (run poly type) +(def: .public (run poly type) {#.doc (doc "Applies a parser against a type." "Verifies that the parser fully consumes the type's information.")} (All [a] (-> (Parser a) Type (Try a))) (run' ..fresh poly (list type))) -(def: #export env +(def: .public env {#.doc (doc "Yields the current parsing environment.")} (Parser Env) (.function (_ [env inputs]) @@ -109,7 +109,7 @@ (#try.Success [[_ remaining] output]) (#try.Success [[env remaining] output])))) -(def: #export peek +(def: .public peek {#.doc (doc "Inspect a type in the input stream without consuming it.")} (Parser Type) (.function (_ [env inputs]) @@ -120,7 +120,7 @@ (#.Item headT tail) (#try.Success [[env inputs] headT])))) -(def: #export any +(def: .public any {#.doc (doc "Yields a type, without examination.")} (Parser Type) (.function (_ [env inputs]) @@ -131,7 +131,7 @@ (#.Item headT tail) (#try.Success [[env tail] headT])))) -(def: #export (local types poly) +(def: .public (local types poly) {#.doc (doc "Apply a parser to the given inputs.")} (All [a] (-> (List Type) (Parser a) (Parser a))) (.function (_ [env pass_through]) @@ -146,7 +146,7 @@ (-> Nat Code) (code.local_identifier ($_ text\compose "label" text.tab (n\encode idx)))) -(def: #export (with_extension type poly) +(def: .public (with_extension type poly) (All [a] (-> Type (Parser a) (Parser [Code a]))) (.function (_ [env inputs]) (let [current_id (dictionary.size env) @@ -161,7 +161,7 @@ (#try.Success [[env inputs'] [g!var output]]))))) (template [ ] - [(`` (def: #export ( poly) + [(`` (def: .public ( poly) {#.doc (doc (~~ (template.text ["Parses the contents of a " " type."])))} (All [a] (-> (Parser a) (Parser a))) (do //.monad @@ -184,7 +184,7 @@ (//.failure (exception.error ..not_polymorphic headT)) (in [num_arg bodyT])))) -(def: #export (polymorphic poly) +(def: .public (polymorphic poly) (All [a] (-> (Parser a) (Parser [Code (List Code) a]))) (do {! //.monad} [headT any @@ -221,7 +221,7 @@ [output poly] (in [funcL all_varsL output]))))) -(def: #export (function in_poly out_poly) +(def: .public (function in_poly out_poly) {#.doc (doc "Parses a function's inputs and output.")} (All [i o] (-> (Parser i) (Parser o) (Parser [i o]))) (do //.monad @@ -232,7 +232,7 @@ (local (list outputT) out_poly)) (//.failure (exception.error ..not_function headT))))) -(def: #export (applied poly) +(def: .public (applied poly) {#.doc (doc "Parses a type application.")} (All [a] (-> (Parser a) (Parser a))) (do //.monad @@ -243,7 +243,7 @@ (..local (#.Item funcT paramsT) poly)))) (template [ ] - [(def: #export ( expected) + [(def: .public ( expected) {#.doc (doc )} (-> Type (Parser Any)) (do //.monad @@ -260,14 +260,14 @@ "Parses a super type."] ) -(def: #export (adjusted_idx env idx) +(def: .public (adjusted_idx env idx) (-> Env Nat Nat) (let [env_level (n./ 2 (dictionary.size env)) parameter_level (n./ 2 idx) parameter_idx (n.% 2 idx)] (|> env_level dec (n.- parameter_level) (n.* 2) (n.+ parameter_idx)))) -(def: #export parameter +(def: .public parameter (Parser Code) (do //.monad [env ..env @@ -284,7 +284,7 @@ _ (//.failure (exception.error ..not_parameter headT))))) -(def: #export (parameter! id) +(def: .public (parameter! id) (-> Nat (Parser Any)) (do //.monad [env ..env @@ -298,7 +298,7 @@ _ (//.failure (exception.error ..not_parameter headT))))) -(def: #export existential +(def: .public existential {#.doc (doc "Yields an existential type.")} (Parser Nat) (do //.monad @@ -310,7 +310,7 @@ _ (//.failure (exception.error ..not_existential headT))))) -(def: #export named +(def: .public named {#.doc (doc "Yields a named type.")} (Parser [Name Type]) (do //.monad @@ -323,11 +323,11 @@ (//.failure (exception.error ..not_named inputT))))) (`` (template: (|nothing|) - (#.Named [(~~ (static .prelude_module)) "Nothing"] - (#.UnivQ #.End - (#.Parameter 1))))) + [(#.Named [(~~ (static .prelude_module)) "Nothing"] + (#.UnivQ #.End + (#.Parameter 1)))])) -(def: #export (recursive poly) +(def: .public (recursive poly) (All [a] (-> (Parser a) (Parser [Code a]))) (do {! //.monad} [headT any] @@ -343,7 +343,7 @@ _ (//.failure (exception.error ..not_recursive headT))))) -(def: #export recursive_self +(def: .public recursive_self (Parser Code) (do //.monad [env ..env @@ -357,7 +357,7 @@ _ (//.failure (exception.error ..not_recursive headT))))) -(def: #export recursive_call +(def: .public recursive_call (Parser Code) (do {! //.monad} [env ..env diff --git a/stdlib/source/library/lux/control/parser/xml.lux b/stdlib/source/library/lux/control/parser/xml.lux index 91fd7e67c..14072c73c 100644 --- a/stdlib/source/library/lux/control/parser/xml.lux +++ b/stdlib/source/library/lux/control/parser/xml.lux @@ -17,24 +17,24 @@ ["/" xml (#+ Attribute Attrs Tag XML)]]]]] ["." //]) -(type: #export (Parser a) +(type: .public (Parser a) {#.doc (doc "A parser of XML-encoded data.")} (//.Parser [Attrs (List XML)] a)) -(exception: #export empty_input) -(exception: #export unexpected_input) +(exception: .public empty_input) +(exception: .public unexpected_input) -(exception: #export (wrong_tag {expected Tag} {actual Tag}) +(exception: .public (wrong_tag {expected Tag} {actual Tag}) (exception.report ["Expected" (%.text (/.tag expected))] ["Actual" (%.text (/.tag actual))])) -(exception: #export (unknown_attribute {expected Attribute} {available (List Attribute)}) +(exception: .public (unknown_attribute {expected Attribute} {available (List Attribute)}) (exception.report ["Expected" (%.text (/.attribute expected))] ["Available" (exception.listing (|>> /.attribute %.text) available)])) -(exception: #export (unconsumed_inputs {inputs (List XML)}) +(exception: .public (unconsumed_inputs {inputs (List XML)}) (exception.report ["Inputs" (exception.listing (\ /.codec encode) inputs)])) @@ -49,13 +49,13 @@ (#try.Failure error) (#try.Failure error))) -(def: #export (run parser documents) +(def: .public (run parser documents) {#.doc (doc "Applies a parser against a stream of XML documents." "Verifies that all of the inputs are consumed by the parser.")} (All [a] (-> (Parser a) (List XML) (Try a))) (..run' parser /.attributes documents)) -(def: #export text +(def: .public text {#.doc (doc "Yields text from a text node.")} (Parser Text) (function (_ [attrs documents]) @@ -71,7 +71,7 @@ (#/.Node _) (exception.except ..unexpected_input []))))) -(def: #export tag +(def: .public tag {#.doc (doc "Yields the tag from the next node.")} (Parser Tag) (function (_ [attrs documents]) @@ -87,7 +87,7 @@ (#/.Node tag _ _) (#try.Success [[attrs documents] tag]))))) -(def: #export (attribute name) +(def: .public (attribute name) {#.doc (doc "Yields the value of an attribute in the current node.")} (-> Attribute (Parser Text)) (function (_ [attrs documents]) @@ -98,7 +98,7 @@ (#.Some value) (#try.Success [[attrs documents] value])))) -(def: #export (node expected parser) +(def: .public (node expected parser) {#.doc (doc "Parses the contents of the next node if the tag matches.")} (All [a] (-> Tag (Parser a) (Parser a))) (function (_ [attrs documents]) @@ -118,7 +118,7 @@ (try\map (|>> [[attrs tail]]))) (exception.except ..wrong_tag [expected actual])))))) -(def: #export ignore +(def: .public ignore {#.doc (doc "Skips the next node.")} (Parser Any) (function (_ [attrs documents]) @@ -129,9 +129,9 @@ (#.Item head tail) (#try.Success [[attrs tail] []])))) -(exception: #export nowhere) +(exception: .public nowhere) -(def: #export (somewhere parser) +(def: .public (somewhere parser) {#.doc (doc "Applies the parser somewhere among the remaining inputs; instead of demanding that the parser succeeds against the immediate inputs.")} (All [a] (-> (Parser a) (Parser a))) (function (recur [attrs input]) diff --git a/stdlib/source/library/lux/control/pipe.lux b/stdlib/source/library/lux/control/pipe.lux index 8f36f8a41..7e551f43c 100644 --- a/stdlib/source/library/lux/control/pipe.lux +++ b/stdlib/source/library/lux/control/pipe.lux @@ -24,7 +24,7 @@ (Parser (List Code)) (s.tuple (p.some s.any))) -(syntax: #export (new> start +(syntax: .public (new> start {body body^} prev) {#.doc (doc "Ignores the piped argument, and begins a new pipe." @@ -35,7 +35,7 @@ (new> 0 [inc]))))} (in (list (` (|> (~ start) (~+ body)))))) -(syntax: #export (let> binding body prev) +(syntax: .public (let> binding body prev) {#.doc (doc "Gives a name to the piped-argument, within the given expression." (n.= 10 (|> 5 @@ -48,7 +48,7 @@ (function (_ tokens) (#e.Success [(list.reversed tokens) []]))) -(syntax: #export (cond> {_ _reversed_} +(syntax: .public (cond> {_ _reversed_} prev {else body^} {_ _reversed_} @@ -67,7 +67,7 @@ (` (|> (~ g!temp) (~+ then)))))) (|> (~ g!temp) (~+ else))))))))) -(syntax: #export (if> {test body^} {then body^} {else body^} prev) +(syntax: .public (if> {test body^} {then body^} {else body^} prev) {#.doc (doc "If-branching." (is? (if (n.even? sample) "even" @@ -80,7 +80,7 @@ [(~+ else)] (~ prev)))))) -(syntax: #export (when> {test body^} {then body^} prev) +(syntax: .public (when> {test body^} {then body^} prev) {#.doc (doc "Only execute the body when the test passes." (is? (if (n.even? sample) (n.* 2 sample) @@ -92,7 +92,7 @@ [] (~ prev)))))) -(syntax: #export (loop> {test body^} +(syntax: .public (loop> {test body^} {then body^} prev) {#.doc (doc "Loops for pipes." @@ -106,7 +106,7 @@ ((~' recur) (|> (~ g!temp) (~+ then))) (~ g!temp)))))))) -(syntax: #export (do> monad +(syntax: .public (do> monad {steps (p.some body^)} prev) {#.doc (doc "Monadic pipes." @@ -130,7 +130,7 @@ _ (in (list prev))))) -(syntax: #export (exec> {body body^} +(syntax: .public (exec> {body body^} prev) {#.doc (doc "Non-updating pipes." "Will generate piped computations, but their results will not be used in the larger scope." @@ -142,7 +142,7 @@ (exec (|> (~ g!temp) (~+ body)) (~ g!temp)))))))) -(syntax: #export (tuple> {paths (p.many body^)} +(syntax: .public (tuple> {paths (p.many body^)} prev) {#.doc (doc "Parallel branching for pipes." "Allows to run multiple pipelines for a value and gives you a tuple of the outputs." @@ -156,7 +156,7 @@ [(~+ (list\map (function (_ body) (` (|> (~ g!temp) (~+ body)))) paths))])))))) -(syntax: #export (case> {branches (p.many (p.and s.any s.any))} +(syntax: .public (case> {branches (p.many (p.and s.any s.any))} prev) {#.doc (doc "Pattern-matching for pipes." "The bodies of each branch are NOT pipes; just regular values." diff --git a/stdlib/source/library/lux/control/reader.lux b/stdlib/source/library/lux/control/reader.lux index 8c46ef9a8..947c18b21 100644 --- a/stdlib/source/library/lux/control/reader.lux +++ b/stdlib/source/library/lux/control/reader.lux @@ -1,38 +1,38 @@ (.module: [library - [lux #* + [lux (#- local) [abstract [apply (#+ Apply)] ["." functor (#+ Functor)] ["." monad (#+ Monad do)]]]]) -(type: #export (Reader r a) +(type: .public (Reader r a) {#.doc "Computations that have access to some environmental value."} (-> r a)) -(def: #export ask +(def: .public ask {#.doc "Get the environment."} (All [r] (Reader r r)) (function (_ env) env)) -(def: #export (local change proc) +(def: .public (local change proc) {#.doc "Run computation with a locally-modified environment."} (All [r a] (-> (-> r r) (Reader r a) (Reader r a))) (|>> change proc)) -(def: #export (run env proc) +(def: .public (run env proc) {#.doc (doc "Executes the reader against the given environment.")} (All [r a] (-> r (Reader r a) a)) (proc env)) -(implementation: #export functor +(implementation: .public functor (All [r] (Functor (Reader r))) (def: (map f fa) (function (_ env) (f (fa env))))) -(implementation: #export apply +(implementation: .public apply (All [r] (Apply (Reader r))) (def: &functor ..functor) @@ -41,7 +41,7 @@ (function (_ env) ((ff env) (fa env))))) -(implementation: #export monad +(implementation: .public monad (All [r] (Monad (Reader r))) (def: &functor ..functor) @@ -53,7 +53,7 @@ (function (_ env) (mma env env)))) -(implementation: #export (with monad) +(implementation: .public (with monad) {#.doc "Monad transformer for Reader."} (All [M] (-> (Monad M) (All [e] (Monad (All [a] (Reader e (M a))))))) @@ -67,7 +67,7 @@ [eMa (run env eMeMa)] (run env eMa))))) -(def: #export lift +(def: .public lift {#.doc "Lift monadic values to the Reader wrapper."} (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 6911ef015..daf4b33d3 100644 --- a/stdlib/source/library/lux/control/region.lux +++ b/stdlib/source/library/lux/control/region.lux @@ -18,7 +18,7 @@ (type: (Cleaner r !) (-> r (! (Try Any)))) -(type: #export (Region r ! a) +(type: .public (Region r ! a) {#.doc (doc "A region where resources may be be claimed and where a side-effecting computation may be performed." "Every resource is paired with a function that knows how to clean/reclaim it, to make sure there are no leaks.")} (-> [r (List (Cleaner r !))] @@ -33,7 +33,7 @@ "-----------------------------------------" text.new_line text.new_line)) -(exception: #export [a] (clean_up_error {error Text} +(exception: .public [a] (clean_up_error {error Text} {output (Try a)}) (format error (case output @@ -53,7 +53,7 @@ (#try.Failure error) (exception.except ..clean_up_error [error output]))) -(def: #export (run monad computation) +(def: .public (run monad computation) {#.doc (doc "Executes a region-based computation, with a side-effect determined by the monad.")} (All [! a] (-> (Monad !) (All [r] (Region r ! a)) @@ -64,7 +64,7 @@ (monad.map ! (function (_ cleaner) (cleaner []))) (\ ! map (list\fold clean output))))) -(def: #export (acquire monad cleaner value) +(def: .public (acquire monad cleaner value) {#.doc (doc "Acquire a resource while pairing it a function that knows how to reclaim it.")} (All [! a] (-> (Monad !) (-> a (! (Try Any))) a (All [r] (Region r ! a)))) @@ -73,7 +73,7 @@ cleaners) (#try.Success value)]))) -(implementation: #export (functor super) +(implementation: .public (functor super) (All [!] (-> (Functor !) (All [r] (Functor (Region r !))))) @@ -91,7 +91,7 @@ (#try.Failure error))]) (fa region+cleaners)))))) -(implementation: #export (apply super) +(implementation: .public (apply super) (All [!] (-> (Monad !) (All [r] (Apply (Region r !))))) @@ -116,7 +116,7 @@ (#try.Failure error) (in [cleaners (#try.Failure error)])))))) -(implementation: #export (monad super) +(implementation: .public (monad super) (All [!] (-> (Monad !) (All [r] (Monad (Region r !))))) @@ -139,7 +139,7 @@ (#try.Failure error) (in [cleaners (#try.Failure error)])))))) -(def: #export (failure monad error) +(def: .public (failure monad error) {#.doc (doc "Immediately fail with this 'message'.")} (All [! a] (-> (Monad !) Text @@ -147,14 +147,14 @@ (function (_ [region cleaners]) (\ monad in [cleaners (#try.Failure error)]))) -(def: #export (except monad exception message) +(def: .public (except monad exception message) {#.doc (doc "Fail by throwing/raising an exception.")} (All [! e a] (-> (Monad !) (Exception e) e (All [r] (Region r ! a)))) (failure monad (exception.error exception message))) -(def: #export (lift monad operation) +(def: .public (lift monad operation) {#.doc (doc "Lift an effectful computation into a region-based computation.")} (All [! a] (-> (Monad !) (! a) diff --git a/stdlib/source/library/lux/control/remember.lux b/stdlib/source/library/lux/control/remember.lux index 48a7e8abf..44289b3cb 100644 --- a/stdlib/source/library/lux/control/remember.lux +++ b/stdlib/source/library/lux/control/remember.lux @@ -21,7 +21,7 @@ ["." template] [syntax (#+ syntax:)]]]]) -(exception: #export (must_remember {deadline Date} {today Date} {message Text} {focus (Maybe Code)}) +(exception: .public (must_remember {deadline Date} {today Date} {message Text} {focus (Maybe Code)}) (exception.report ["Deadline" (%.date deadline)] ["Today" (%.date today)] @@ -47,7 +47,7 @@ (#try.Failure message) (<>.failure message))))) -(syntax: #export (remember {deadline ..deadline} {message .text} {focus (<>.maybe .any)}) +(syntax: .public (remember {deadline ..deadline} {message .text} {focus (<>.maybe .any)}) {#.doc (doc "A message with an expiration date." "Can have an optional piece of code to focus on." (remember "2022-04-01" @@ -67,7 +67,7 @@ (meta.failure (exception.error ..must_remember [deadline today message focus]))))) (template [ ] - [(`` (syntax: #export ( {deadline ..deadline} {message .text} {focus (<>.maybe .any)}) + [(`` (syntax: .public ( {deadline ..deadline} {message .text} {focus (<>.maybe .any)}) {#.doc (doc (~~ (template.text ["A " " message with an expiration date."])) "Can have an optional piece of code to focus on." ( "2022-04-01" diff --git a/stdlib/source/library/lux/control/security/capability.lux b/stdlib/source/library/lux/control/security/capability.lux index b58468911..4834e172c 100644 --- a/stdlib/source/library/lux/control/security/capability.lux +++ b/stdlib/source/library/lux/control/security/capability.lux @@ -24,19 +24,19 @@ ["|.|" declaration] ["|.|" annotations]]]]]) -(abstract: #export (Capability brand input output) - (-> input output) - +(abstract: .public (Capability brand input output) {#.doc (doc "Represents the capability to perform an operation." "This operation is assumed to have security implications.")} + (-> input output) + (def: forge (All [brand input output] (-> (-> input output) (Capability brand input output))) (|>> :abstraction)) - (def: #export (use capability input) + (def: .public (use capability input) {#.doc (doc "Applies a capability against its required input.")} (All [brand input output] (-> (Capability brand input output) @@ -44,7 +44,7 @@ output)) ((:representation capability) input)) - (syntax: #export (capability: {export |export|.parser} + (syntax: .public (capability: {export |export|.parser} {declaration |declaration|.parser} {annotations (<>.maybe |annotations|.parser)} {[forge input output] (.form ($_ <>.and .local_identifier .any .any))}) @@ -74,7 +74,7 @@ (~! ..forge))) )))) - (def: #export (async capability) + (def: .public (async capability) {#.doc (doc "Converts a synchronous I/O-based capability into an asynchronous capability.")} (All [brand input output] (-> (Capability brand input (IO output)) diff --git a/stdlib/source/library/lux/control/security/policy.lux b/stdlib/source/library/lux/control/security/policy.lux index dc5a07e0d..32bf06c38 100644 --- a/stdlib/source/library/lux/control/security/policy.lux +++ b/stdlib/source/library/lux/control/security/policy.lux @@ -8,38 +8,38 @@ [type abstract]]]) -(abstract: #export (Policy brand value label) - value - +(abstract: .public (Policy brand value label) {#.doc (doc "A security policy encoded as the means to 'upgrade' or 'downgrade' in a secure context.")} - (type: #export (Can_Upgrade brand label value) + value + + (type: .public (Can_Upgrade brand label value) {#.doc (doc "Represents the capacity to 'upgrade' a value.")} (-> value (Policy brand value label))) - (type: #export (Can_Downgrade brand label value) + (type: .public (Can_Downgrade brand label value) {#.doc (doc "Represents the capacity to 'downgrade' a value.")} (-> (Policy brand value label) value)) - (type: #export (Privilege brand label) + (type: .public (Privilege brand label) {#.doc (doc "Represents the privilege to both 'upgrade' and 'downgrade' a value.")} {#can_upgrade (Can_Upgrade brand label) #can_downgrade (Can_Downgrade brand label)}) - (type: #export (Delegation brand from to) + (type: .public (Delegation brand from to) {#.doc (doc "Represents the act of delegating policy capacities.")} (All [value] (-> (Policy brand value from) (Policy brand value to)))) - (def: #export (delegation downgrade upgrade) + (def: .public (delegation downgrade upgrade) {#.doc (doc "Delegating policy capacities.")} (All [brand from to] (-> (Can_Downgrade brand from) (Can_Upgrade brand to) (Delegation brand from to))) (|>> downgrade upgrade)) - (type: #export (Context brand scope label) + (type: .public (Context brand scope label) {#.doc (doc "A computational context with an associated policy privilege.")} (-> (Privilege brand label) (scope label))) @@ -49,7 +49,7 @@ {#can_upgrade (|>> :abstraction) #can_downgrade (|>> :representation)}) - (def: #export (with_policy context) + (def: .public (with_policy context) {#.doc (doc "Activates a security context with the priviledge to enforce it's policy." (type: Password @@ -82,13 +82,13 @@ (type (All [brand label] (constructor (All [value] (Policy brand value label)))))) - (implementation: #export functor + (implementation: .public functor (:~ (..of_policy Functor)) (def: (map f fa) (|> fa :representation f :abstraction))) - (implementation: #export apply + (implementation: .public apply (:~ (..of_policy Apply)) (def: &functor ..functor) @@ -96,7 +96,7 @@ (def: (apply ff fa) (:abstraction ((:representation ff) (:representation fa))))) - (implementation: #export monad + (implementation: .public monad (:~ (..of_policy Monad)) (def: &functor ..functor) @@ -105,18 +105,18 @@ ) (template [ ] - [(abstract: #export - Any - + [(abstract: .public {#.doc } - (type: #export + Any + + (type: .public (Policy )) - (type: #export + (type: .public (Can_Upgrade )) - (type: #export + (type: .public (Can_Downgrade )) )] diff --git a/stdlib/source/library/lux/control/state.lux b/stdlib/source/library/lux/control/state.lux index ec576f9cd..5021d293d 100644 --- a/stdlib/source/library/lux/control/state.lux +++ b/stdlib/source/library/lux/control/state.lux @@ -1,52 +1,52 @@ (.module: [library - [lux #* + [lux (#- local) [abstract [functor (#+ Functor)] [apply (#+ Apply)] [monad (#+ Monad do)]]]]) -(type: #export (State s a) +(type: .public (State s a) {#.doc "Stateful computations."} (-> s [s a])) -(def: #export get +(def: .public get {#.doc "Read the current state."} (All [s] (State s s)) (function (_ state) [state state])) -(def: #export (put new_state) +(def: .public (put new_state) {#.doc "Set the new state."} (All [s] (-> s (State s Any))) (function (_ state) [new_state []])) -(def: #export (update change) +(def: .public (update change) {#.doc "Compute the new state."} (All [s] (-> (-> s s) (State s Any))) (function (_ state) [(change state) []])) -(def: #export (use user) +(def: .public (use user) {#.doc "Run a function on the current state."} (All [s a] (-> (-> s a) (State s a))) (function (_ state) [state (user state)])) -(def: #export (local change action) +(def: .public (local change action) {#.doc "Run the computation with a locally-modified state."} (All [s a] (-> (-> s s) (State s a) (State s a))) (function (_ state) (let [[state' output] (action (change state))] [state output]))) -(def: #export (run state action) +(def: .public (run state action) {#.doc "Run a stateful computation."} (All [s a] (-> s (State s a) [s a])) (action state)) -(implementation: #export functor +(implementation: .public functor (All [s] (Functor (State s))) (def: (map f ma) @@ -54,7 +54,7 @@ (let [[state' a] (ma state)] [state' (f a)])))) -(implementation: #export apply +(implementation: .public apply (All [s] (Apply (State s))) (def: &functor ..functor) @@ -65,7 +65,7 @@ [state'' a] (fa state')] [state'' (f a)])))) -(implementation: #export monad +(implementation: .public monad (All [s] (Monad (State s))) (def: &functor ..functor) @@ -79,7 +79,7 @@ (let [[state' ma] (mma state)] (ma state'))))) -(def: #export (while condition body) +(def: .public (while condition body) {#.doc (doc "A stateful while loop.")} (All [s] (-> (State s Bit) (State s Any) (State s Any))) (do {! ..monad} @@ -90,7 +90,7 @@ (while condition body)) (in [])))) -(def: #export (do_while condition body) +(def: .public (do_while condition body) {#.doc (doc "A stateful do-while loop.")} (All [s] (-> (State s Bit) (State s Any) (State s Any))) (do ..monad @@ -117,16 +117,16 @@ [state a] (sFa state)] (in [state (f a)]))))) -(type: #export (+State M s a) +(type: .public (+State M s a) {#.doc "Stateful computations decorated by a monad."} (-> s (M [s a]))) -(def: #export (run' state action) +(def: .public (run' state action) {#.doc "Execute a stateful computation decorated by a monad."} (All [M s a] (-> s (+State M s a) (M [s a]))) (action state)) -(implementation: #export (with monad) +(implementation: .public (with monad) {#.doc "A monad transformer to create composite stateful computations."} (All [M s] (-> (Monad M) (Monad (+State M s)))) @@ -142,7 +142,7 @@ [[state' sMa] (sMsMa state)] (sMa state'))))) -(def: #export (lift monad ma) +(def: .public (lift monad ma) {#.doc "Lift monadic values to the +State wrapper."} (All [M s a] (-> (Monad M) (M a) (+State M s a))) (function (_ state) diff --git a/stdlib/source/library/lux/control/thread.lux b/stdlib/source/library/lux/control/thread.lux index b528d22aa..8b6323863 100644 --- a/stdlib/source/library/lux/control/thread.lux +++ b/stdlib/source/library/lux/control/thread.lux @@ -14,16 +14,16 @@ [type abstract]]]) -(type: #export (Thread ! a) +(type: .public (Thread ! a) {#.doc (doc "An imperative process with access to mutable values.")} (-> ! a)) -(abstract: #export (Box t v) - (Array v) - +(abstract: .public (Box t v) {#.doc "A mutable box holding a value."} - (def: #export (box init) + (Array v) + + (def: .public (box init) {#.doc (doc "A brand-new box initialized to the given value.")} (All [a] (-> a (All [!] (Thread ! (Box ! a))))) (function (_ !) @@ -31,7 +31,7 @@ (array.write! 0 init) :abstraction))) - (def: #export (read box) + (def: .public (read box) {#.doc (doc "Reads the current value in the box.")} (All [! a] (-> (Box ! a) (Thread ! a))) (function (_ !) @@ -53,28 +53,28 @@ @.php ("php array read" 0 (:representation box)) @.scheme ("scheme array read" 0 (:representation box))}))) - (def: #export (write value box) + (def: .public (write value box) {#.doc (doc "Mutates the value in the box.")} (All [a] (-> a (All [!] (-> (Box ! a) (Thread ! Any))))) (function (_ !) (|> box :representation (array.write! 0 value) :abstraction))) ) -(def: #export (run thread) +(def: .public (run thread) {#.doc (doc "Executes the imperative thread in a self-contained way.")} (All [a] (-> (All [!] (Thread ! a)) a)) (thread [])) -(def: #export io +(def: .public io {#.doc (doc "Transforms the imperative thread into an I/O computation.")} (All [a] (-> (All [!] (Thread ! a)) (IO a))) (|>> ..run io.io)) -(implementation: #export functor +(implementation: .public functor (All [!] (Functor (Thread !))) (def: (map f) @@ -82,7 +82,7 @@ (function (_ !) (f (fa !)))))) -(implementation: #export apply +(implementation: .public apply (All [!] (Apply (Thread !))) (def: &functor ..functor) @@ -91,7 +91,7 @@ (function (_ !) ((ff !) (fa !))))) -(implementation: #export monad +(implementation: .public monad (All [!] (Monad (Thread !))) (def: &functor ..functor) @@ -104,7 +104,7 @@ (function (_ !) ((ffa !) !)))) -(def: #export (update f box) +(def: .public (update f box) {#.doc (doc "Update a box's value by applying a function to it.")} (All [a !] (-> (-> a a) (Box ! a) (Thread ! a))) (do ..monad diff --git a/stdlib/source/library/lux/control/try.lux b/stdlib/source/library/lux/control/try.lux index 0226bab08..fa02b452a 100644 --- a/stdlib/source/library/lux/control/try.lux +++ b/stdlib/source/library/lux/control/try.lux @@ -9,12 +9,12 @@ [meta ["." location]]]]) -(type: #export (Try a) +(type: .public (Try a) {#.doc (doc "A computation that can fail with an error message.")} (#Failure Text) (#Success a)) -(implementation: #export functor +(implementation: .public functor (Functor Try) (def: (map f ma) @@ -25,7 +25,7 @@ (#Success datum) (#Success (f datum))))) -(implementation: #export apply +(implementation: .public apply (Apply Try) (def: &functor ..functor) @@ -43,7 +43,7 @@ (#Failure msg) (#Failure msg)))) -(implementation: #export monad +(implementation: .public monad (Monad Try) (def: &functor ..functor) @@ -59,7 +59,7 @@ (#Success ma) ma))) -(implementation: #export (with monad) +(implementation: .public (with monad) {#.doc (doc "Enhances a monad with error-handling functionality.")} ## TODO: Replace (All [a] (! (Try a))) with (functor.Then ! Try) (All [!] (-> (Monad !) (Monad (All [a] (! (Try a)))))) @@ -81,12 +81,12 @@ (#Success Mea) Mea)))) -(def: #export (lifted monad) +(def: .public (lifted monad) {#.doc (doc "Wraps a monadic value with error-handling machinery.")} (All [! a] (-> (Monad !) (-> (! a) (! (Try a))))) (\ monad map (\ ..monad in))) -(implementation: #export (equivalence (^open "_\.")) +(implementation: .public (equivalence (^open "_\.")) (All [a] (-> (Equivalence a) (Equivalence (Try a)))) (def: (= reference sample) @@ -101,7 +101,7 @@ false ))) -(def: #export (assumed try) +(def: .public (assumed try) {#.doc (doc "Assumes a Try value succeeded, and yields its value." "If it didn't, raises the error as a runtime error." "WARNING: Use with caution.")} @@ -113,7 +113,7 @@ (#Failure message) (error! message))) -(def: #export (maybe try) +(def: .public (maybe try) (All [a] (-> (Try a) (Maybe a))) (case try (#Success value) @@ -122,7 +122,7 @@ (#Failure message) #.None)) -(def: #export (of_maybe maybe) +(def: .public (of_maybe maybe) (All [a] (-> (Maybe a) (Try a))) (case maybe (#.Some value) @@ -132,7 +132,7 @@ (#Failure (`` (("lux in-module" (~~ (static .prelude_module)) .name\encode) (name_of ..of_maybe)))))) -(macro: #export (else tokens compiler) +(macro: .public (else tokens compiler) {#.doc (doc "Allows you to provide a default value that will be used" "if a (Try x) value turns out to be #Failure." "Note: the expression for the default value will not be computed if the base computation succeeds." diff --git a/stdlib/source/library/lux/control/writer.lux b/stdlib/source/library/lux/control/writer.lux index ee5c15ee8..b4ea701cb 100644 --- a/stdlib/source/library/lux/control/writer.lux +++ b/stdlib/source/library/lux/control/writer.lux @@ -8,17 +8,17 @@ ["." functor (#+ Functor)] ["." monad (#+ Monad do)]]]]) -(type: #export (Writer l a) +(type: .public (Writer l a) {#.doc "Represents a value with an associated 'log' value to record arbitrary information."} {#log l #value a}) -(def: #export (write l) +(def: .public (write l) {#.doc "Set the log to a particular value."} (All [l] (-> l (Writer l Any))) [l []]) -(implementation: #export functor +(implementation: .public functor (All [l] (Functor (Writer l))) @@ -26,7 +26,7 @@ (let [[log datum] fa] [log (f datum)]))) -(implementation: #export (apply monoid) +(implementation: .public (apply monoid) (All [l] (-> (Monoid l) (Apply (Writer l)))) @@ -37,7 +37,7 @@ [log2 a] fa] [(\ monoid compose log1 log2) (f a)]))) -(implementation: #export (monad monoid) +(implementation: .public (monad monoid) (All [l] (-> (Monoid l) (Monad (Writer l)))) @@ -50,7 +50,7 @@ (let [[log1 [log2 a]] mma] [(\ monoid compose log1 log2) a]))) -(implementation: #export (with monoid monad) +(implementation: .public (with monoid monad) {#.doc (doc "Enhances a monad with Writer functionality.")} (All [l M] (-> (Monoid l) (Monad M) (Monad (All [a] (M (Writer l a)))))) @@ -72,7 +72,7 @@ [l2 a] Mla] (in [(\ monoid compose l1 l2) a])))) -(def: #export (lift monoid monad) +(def: .public (lift monoid monad) {#.doc (doc "Wraps a monadic value with Writer machinery.")} (All [l M a] (-> (Monoid l) (Monad M) diff --git a/stdlib/source/library/lux/data/binary.lux b/stdlib/source/library/lux/data/binary.lux index 1b320f241..59c5c026a 100644 --- a/stdlib/source/library/lux/data/binary.lux +++ b/stdlib/source/library/lux/data/binary.lux @@ -22,19 +22,19 @@ ["f" frac] ["." i64]]]]]) -(exception: #export (index_out_of_bounds {size Nat} {index Nat}) +(exception: .public (index_out_of_bounds {size Nat} {index Nat}) (exception.report ["Size" (%.nat size)] ["Index" (%.nat index)])) -(exception: #export (slice_out_of_bounds {size Nat} {offset Nat} {length Nat}) +(exception: .public (slice_out_of_bounds {size Nat} {offset Nat} {length Nat}) (exception.report ["Size" (%.nat size)] ["Offset" (%.nat offset)] ["Length" (%.nat length)])) (with_expansions [ (as_is {#.doc (doc "A binary BLOB of data.")}) - (as_is (type: #export Binary + (as_is (type: .public Binary (ffi.type [byte])) @@ -77,17 +77,17 @@ (new [ArrayBuffer]) (length ffi.Number)]) - (type: #export Binary + (type: .public Binary Uint8Array)) @.python - (type: #export Binary + (type: .public Binary (primitive "bytearray")) @.scheme - (as_is (type: #export Binary + (as_is (type: .public Binary (primitive "bytevector")) @@ -97,80 +97,80 @@ (ffi.import: (bytevector-length [Binary] Nat)))} ## Default - (type: #export Binary + (type: .public Binary (array.Array (I64 Any))))) (template: (!size binary) - (for {@.old (ffi.array_length binary) - @.jvm (ffi.array_length binary) + [(for {@.old (ffi.array_length binary) + @.jvm (ffi.array_length binary) - @.js - (|> binary - Uint8Array::length - f.nat) + @.js + (|> binary + Uint8Array::length + f.nat) - @.python - (|> binary - (:as (array.Array (I64 Any))) - "python array length") + @.python + (|> binary + (:as (array.Array (I64 Any))) + "python array length") - @.scheme - (..bytevector-length [binary])} + @.scheme + (..bytevector-length [binary])} - ## Default - (array.size binary))) + ## Default + (array.size binary))]) (template: (!read index binary) - (for {@.old (..i64 (ffi.array_read index binary)) - @.jvm (..i64 (ffi.array_read index binary)) - - @.js + [(for {@.old (..i64 (ffi.array_read index binary)) + @.jvm (..i64 (ffi.array_read index binary)) + + @.js + (|> binary + (: ..Binary) + (:as (array.Array .Frac)) + ("js array read" index) + f.nat + .i64) + + @.python + (|> binary + (:as (array.Array .I64)) + ("python array read" index)) + + @.scheme + (..bytevector-u8-ref [binary index])} + + ## Default (|> binary - (: ..Binary) - (:as (array.Array .Frac)) - ("js array read" index) - f.nat - .i64) - - @.python - (|> binary - (:as (array.Array .I64)) - ("python array read" index)) - - @.scheme - (..bytevector-u8-ref [binary index])} - - ## Default - (|> binary - (array.read index) - (maybe.else (: (I64 Any) 0)) - (:as I64)))) + (array.read index) + (maybe.else (: (I64 Any) 0)) + (:as I64)))]) (template: (!!write index value binary) - (|> binary - (: ..Binary) - (:as (array.Array )) - ( index (|> value .nat (n.% (hex "100")) )) - (:as ..Binary))) + [(|> binary + (: ..Binary) + (:as (array.Array )) + ( index (|> value .nat (n.% (hex "100")) )) + (:as ..Binary))]) (template: (!write index value binary) - (for {@.old (ffi.array_write index (..byte value) binary) - @.jvm (ffi.array_write index (..byte value) binary) + [(for {@.old (ffi.array_write index (..byte value) binary) + @.jvm (ffi.array_write index (..byte value) binary) - @.js (!!write .Frac n.frac "js array write" index value binary) - @.python (!!write (I64 Any) (:as (I64 Any)) "python array write" index value binary) - @.scheme (exec (..bytevector-u8-set! [binary index value]) - binary)} + @.js (!!write .Frac n.frac "js array write" index value binary) + @.python (!!write (I64 Any) (:as (I64 Any)) "python array write" index value binary) + @.scheme (exec (..bytevector-u8-set! [binary index value]) + binary)} - ## Default - (array.write! index (|> value .nat (n.% (hex "100"))) binary))) + ## Default + (array.write! index (|> value .nat (n.% (hex "100"))) binary))]) -(def: #export size +(def: .public size (-> Binary Nat) (|>> !size)) -(def: #export (create size) +(def: .public (create size) {#.doc (doc "A fresh/empty binary BLOB of the specified size.")} (-> Nat Binary) (for {@.old (ffi.array byte size) @@ -190,7 +190,7 @@ ## Default (array.empty size))) -(def: #export (fold f init binary) +(def: .public (fold f init binary) (All [a] (-> (-> I64 a a) a Binary a)) (let [size (..!size binary)] (loop [index 0 @@ -199,14 +199,14 @@ (recur (inc index) (f (!read index binary) output)) output)))) -(def: #export (read/8 index binary) +(def: .public (read/8 index binary) {#.doc (doc "Read 1 byte (8 bits) at the given index.")} (-> Nat Binary (Try I64)) (if (n.< (..!size binary) index) (#try.Success (!read index binary)) (exception.except ..index_out_of_bounds [(..!size binary) index]))) -(def: #export (read/16 index binary) +(def: .public (read/16 index binary) {#.doc (doc "Read 2 bytes (16 bits) at the given index.")} (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 1 index)) @@ -215,7 +215,7 @@ (!read (n.+ 1 index) binary))) (exception.except ..index_out_of_bounds [(..!size binary) index]))) -(def: #export (read/32 index binary) +(def: .public (read/32 index binary) {#.doc (doc "Read 4 bytes (32 bits) at the given index.")} (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 3 index)) @@ -226,7 +226,7 @@ (!read (n.+ 3 index) binary))) (exception.except ..index_out_of_bounds [(..!size binary) index]))) -(def: #export (read/64 index binary) +(def: .public (read/64 index binary) {#.doc (doc "Read 8 bytes (64 bits) at the given index.")} (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 7 index)) @@ -241,7 +241,7 @@ (!read (n.+ 7 index) binary))) (exception.except ..index_out_of_bounds [(..!size binary) index]))) -(def: #export (write/8 index value binary) +(def: .public (write/8 index value binary) {#.doc (doc "Write 1 byte (8 bits) at the given index.")} (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) index) @@ -249,7 +249,7 @@ (!write index value))) (exception.except ..index_out_of_bounds [(..!size binary) index]))) -(def: #export (write/16 index value binary) +(def: .public (write/16 index value binary) {#.doc (doc "Write 2 bytes (16 bits) at the given index.")} (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) (n.+ 1 index)) @@ -258,7 +258,7 @@ (!write (n.+ 1 index) value))) (exception.except ..index_out_of_bounds [(..!size binary) index]))) -(def: #export (write/32 index value binary) +(def: .public (write/32 index value binary) {#.doc (doc "Write 4 bytes (32 bits) at the given index.")} (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) (n.+ 3 index)) @@ -269,7 +269,7 @@ (!write (n.+ 3 index) value))) (exception.except ..index_out_of_bounds [(..!size binary) index]))) -(def: #export (write/64 index value binary) +(def: .public (write/64 index value binary) {#.doc (doc "Write 8 bytes (64 bits) at the given index.")} (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) (n.+ 7 index)) @@ -293,7 +293,7 @@ (!write (n.+ 7 index) value)))) (exception.except ..index_out_of_bounds [(..!size binary) index]))) -(implementation: #export equivalence +(implementation: .public equivalence (Equivalence Binary) (def: (= reference sample) @@ -314,7 +314,7 @@ @.jvm (as_is)} ## Default - (exception: #export (cannot_copy_bytes {bytes Nat} + (exception: .public (cannot_copy_bytes {bytes Nat} {source_input Nat} {target_output Nat}) (exception.report @@ -322,7 +322,7 @@ ["Source input space" (%.nat source_input)] ["Target output space" (%.nat target_output)]))) -(def: #export (copy bytes source_offset source target_offset target) +(def: .public (copy bytes source_offset source target_offset target) {#.doc (doc "Mutates the target binary BLOB by copying bytes from the source BLOB to it.")} (-> Nat Nat Binary Nat Binary (Try Binary)) (with_expansions [ (as_is (do try.monad @@ -344,7 +344,7 @@ (recur (inc index))) (#try.Success target)))))))) -(def: #export (slice offset length binary) +(def: .public (slice offset length binary) {#.doc (doc "Yields a subset of the binary BLOB, so long as the specified range is valid.")} (-> Nat Nat Binary (Try Binary)) (let [size (..!size binary) @@ -358,7 +358,7 @@ ## Default (..copy length offset binary 0 (..create length))))))) -(def: #export (drop bytes binary) +(def: .public (drop bytes binary) {#.doc (doc "Yields a binary BLOB with at most the specified number of bytes removed.")} (-> Nat Binary Binary) (case bytes @@ -371,7 +371,7 @@ (#try.Failure _) (..create 0))))) -(implementation: #export monoid +(implementation: .public monoid (Monoid Binary) (def: identity diff --git a/stdlib/source/library/lux/data/bit.lux b/stdlib/source/library/lux/data/bit.lux index 5de3cf526..69111ccb4 100644 --- a/stdlib/source/library/lux/data/bit.lux +++ b/stdlib/source/library/lux/data/bit.lux @@ -10,14 +10,14 @@ ["." function]]]]) (template [ ] - [(def: #export Bit #0) - (def: #export Bit #1)] + [(def: .public Bit #0) + (def: .public Bit #1)] [no yes] [off on] ) -(implementation: #export equivalence +(implementation: .public equivalence (Equivalence Bit) (def: (= x y) @@ -25,7 +25,7 @@ y (not y)))) -(implementation: #export hash +(implementation: .public hash (Hash Bit) (def: &equivalence ..equivalence) @@ -36,7 +36,7 @@ #1 3))) (template [ ] - [(implementation: #export + [(implementation: .public (Monoid Bit) (def: identity ) @@ -46,7 +46,7 @@ [conjunction #1 and] ) -(implementation: #export codec +(implementation: .public codec (Codec Text Bit) (def: (encode x) @@ -60,7 +60,7 @@ "#0" (#.Right #0) _ (#.Left "Wrong syntax for Bit.")))) -(def: #export complement +(def: .public complement {#.doc (doc "Generates the complement of a predicate." "That is a predicate that returns the oposite of the original predicate.")} (All [a] (-> (-> a Bit) (-> a Bit))) diff --git a/stdlib/source/library/lux/data/collection/array.lux b/stdlib/source/library/lux/data/collection/array.lux index 6811c2234..8a3d0db92 100644 --- a/stdlib/source/library/lux/data/collection/array.lux +++ b/stdlib/source/library/lux/data/collection/array.lux @@ -17,10 +17,10 @@ [number ["n" nat]]]]]) -(def: #export type_name +(def: .public type_name "#Array") -(type: #export (Array a) +(type: .public (Array a) {#.doc "Mutable arrays."} (#.Primitive ..type_name (#.Item a #.End))) @@ -29,13 +29,13 @@ (type (Array ))] (for {@.jvm (template: (!int value) - (|> value - (:as ) - "jvm object cast" - "jvm conversion long-to-int"))} + [(|> value + (:as ) + "jvm object cast" + "jvm conversion long-to-int")])} (as_is)) - (def: #export (empty size) + (def: .public (empty size) {#.doc (doc "An empty array of the specified size.")} (All [a] (-> Nat (Array a))) (for {@.old @@ -55,7 +55,7 @@ @.php ("php array new" size) @.scheme ("scheme array new" size)})) - (def: #export (size array) + (def: .public (size array) (All [a] (-> (Array a) Nat)) (for {@.old ("jvm arraylength" array) @@ -77,12 +77,12 @@ @.scheme ("scheme array length" array)})) (template: (!read ) - (let [output ( index array)] - (if ( output) - #.None - (#.Some output)))) + [(let [output ( index array)] + (if ( output) + #.None + (#.Some output)))]) - (def: #export (read index array) + (def: .public (read index array) (All [a] (-> Nat (Array a) (Maybe a))) (if (n.< (size array) index) @@ -108,7 +108,7 @@ @.scheme (!read "scheme array read" "scheme object nil?")}) #.None)) - (def: #export (write! index value array) + (def: .public (write! index value array) {#.doc (doc "Mutate the array by writing a value to the specified index.")} (All [a] (-> Nat a (Array a) (Array a))) @@ -128,7 +128,7 @@ @.php ("php array write" index value array) @.scheme ("scheme array write" index value array)})) - (def: #export (delete! index array) + (def: .public (delete! index array) {#.doc (doc "Mutate the array by deleting the value at the specified index.")} (All [a] (-> Nat (Array a) (Array a))) @@ -148,7 +148,7 @@ array)) ) -(def: #export (contains? index array) +(def: .public (contains? index array) (All [a] (-> Nat (Array a) Bit)) (case (..read index array) @@ -158,7 +158,7 @@ _ false)) -(def: #export (update! index transform array) +(def: .public (update! index transform array) {#.doc (doc "Mutate the array by updating the value at the specified index.")} (All [a] (-> Nat (-> a a) (Array a) (Array a))) @@ -169,7 +169,7 @@ (#.Some value) (write! index (transform value) array))) -(def: #export (upsert! index default transform array) +(def: .public (upsert! index default transform array) {#.doc (doc "Mutate the array by updating the value at the specified index." "If there is no value, update and write the default value given.")} (All [a] @@ -178,7 +178,7 @@ (|> array (read index) (maybe.else default) transform) array)) -(def: #export (copy! length src_start src_array dest_start dest_array) +(def: .public (copy! length src_start src_array dest_start dest_array) {#.doc (doc "Writes the contents of one array into the other.")} (All [a] (-> Nat Nat (Array a) Nat (Array a) @@ -195,7 +195,7 @@ dest_array (list.indices length)))) -(def: #export (occupancy array) +(def: .public (occupancy array) {#.doc "Finds out how many cells in an array are occupied."} (All [a] (-> (Array a) Nat)) (list\fold (function (_ idx count) @@ -208,12 +208,12 @@ 0 (list.indices (size array)))) -(def: #export (vacancy array) +(def: .public (vacancy array) {#.doc "Finds out how many cells in an array are vacant."} (All [a] (-> (Array a) Nat)) (n.- (..occupancy array) (..size array))) -(def: #export (filter! p xs) +(def: .public (filter! p xs) {#.doc (doc "Delete every item of the array that fails to satisfy the predicate.")} (All [a] (-> (Predicate a) (Array a) (Array a))) @@ -229,7 +229,7 @@ xs (list.indices (size xs)))) -(def: #export (find p xs) +(def: .public (find p xs) {#.doc (doc "Yields the first item in the array that satisfies the predicate.")} (All [a] (-> (Predicate a) (Array a) (Maybe a))) @@ -246,7 +246,7 @@ (recur (inc idx)))) #.None)))) -(def: #export (find+ p xs) +(def: .public (find+ p xs) {#.doc "Just like 'find', but with access to the index of each value."} (All [a] (-> (-> Nat a Bit) (Array a) (Maybe [Nat a]))) @@ -263,7 +263,7 @@ (recur (inc idx)))) #.None)))) -(def: #export (clone xs) +(def: .public (clone xs) {#.doc (doc "Yields a shallow clone of the array.")} (All [a] (-> (Array a) (Array a))) (let [arr_size (size xs)] @@ -277,7 +277,7 @@ (empty arr_size) (list.indices arr_size)))) -(def: #export (of_list xs) +(def: .public (of_list xs) (All [a] (-> (List a) (Array a))) (product.right (list\fold (function (_ x [idx arr]) [(inc idx) (write! idx x arr)]) @@ -288,7 +288,7 @@ Nat (dec 0)) -(def: #export (list array) +(def: .public (list array) {#.doc (doc "Yields a list with every non-empty item in the array.")} (All [a] (-> (Array a) (List a))) (loop [idx (dec (size array)) @@ -306,7 +306,7 @@ #.None output))))) -(def: #export (list' default array) +(def: .public (list' default array) {#.doc (doc "Like 'list', but uses the 'default' value when encountering an empty cell in the array.")} (All [a] (-> a (Array a) (List a))) (loop [idx (dec (size array)) @@ -320,7 +320,7 @@ (#.Item (maybe.else default (read idx array)) output))))) -(implementation: #export (equivalence (^open ",\.")) +(implementation: .public (equivalence (^open ",\.")) (All [a] (-> (Equivalence a) (Equivalence (Array a)))) (def: (= xs ys) @@ -341,7 +341,7 @@ true (list.indices sxs)))))) -(implementation: #export monoid +(implementation: .public monoid (All [a] (Monoid (Array a))) (def: identity (empty 0)) @@ -353,7 +353,7 @@ (copy! sxs 0 xs 0) (copy! sxy 0 ys sxs))))) -(implementation: #export functor +(implementation: .public functor (Functor Array) (def: (map f ma) @@ -371,7 +371,7 @@ (list.indices arr_size)) )))) -(implementation: #export fold +(implementation: .public fold (Fold Array) (def: (fold f init xs) @@ -388,7 +388,7 @@ so_far))))) (template [ ] - [(def: #export ( predicate) + [(def: .public ( predicate) (All [a] (-> (Predicate a) (Predicate (Array a)))) (function (_ array) diff --git a/stdlib/source/library/lux/data/collection/bits.lux b/stdlib/source/library/lux/data/collection/bits.lux index 7820cfe4c..01296c8a2 100644 --- a/stdlib/source/library/lux/data/collection/bits.lux +++ b/stdlib/source/library/lux/data/collection/bits.lux @@ -14,13 +14,13 @@ ["n" nat] ["." i64]]]]]) -(type: #export Chunk +(type: .public Chunk I64) -(def: #export chunk_size +(def: .public chunk_size i64.width) -(type: #export Bits +(type: .public Bits {#.doc (doc "A bit-map.")} (Array Chunk)) @@ -28,11 +28,11 @@ Chunk (.i64 0)) -(def: #export empty +(def: .public empty Bits (array.empty 0)) -(def: #export (size bits) +(def: .public (size bits) {#.doc (doc "Measures the size of a bit-map by counting all the 1s in the bit-map.")} (-> Bits Nat) (array\fold (function (_ chunk total) @@ -40,15 +40,15 @@ 0 bits)) -(def: #export (capacity bits) +(def: .public (capacity bits) (-> Bits Nat) (|> bits array.size (n.* chunk_size))) -(def: #export empty? +(def: .public empty? (-> Bits Bit) (|>> ..size (n.= 0))) -(def: #export (get index bits) +(def: .public (get index bits) (-> Nat Bits Bit) (let [[chunk_index bit_index] (n./% chunk_size index)] (.and (n.< (array.size bits) chunk_index) @@ -63,7 +63,7 @@ empty_chunk)) (template [ ] - [(def: #export ( index input) + [(def: .public ( index input) (-> Nat Bits Bits) (let [[chunk_index bit_index] (n./% chunk_size index)] (loop [size|output (n.max (inc chunk_index) @@ -96,7 +96,7 @@ [flip i64.flip] ) -(def: #export (intersects? reference sample) +(def: .public (intersects? reference sample) (-> Bits Bits Bit) (let [chunks (n.min (array.size reference) (array.size sample))] @@ -109,7 +109,7 @@ (recur (inc idx))) #0)))) -(def: #export (not input) +(def: .public (not input) (-> Bits Bits) (case (array.size input) 0 @@ -133,7 +133,7 @@ output)))))) (template [ ] - [(def: #export ( param subject) + [(def: .public ( param subject) (-> Bits Bits Bits) (case (n.max (array.size param) (array.size subject)) @@ -164,7 +164,7 @@ [xor i64.xor] ) -(implementation: #export equivalence +(implementation: .public equivalence (Equivalence Bits) (def: (= reference sample) diff --git a/stdlib/source/library/lux/data/collection/dictionary.lux b/stdlib/source/library/lux/data/collection/dictionary.lux index 771bdc551..6ed3c4f4f 100644 --- a/stdlib/source/library/lux/data/collection/dictionary.lux +++ b/stdlib/source/library/lux/data/collection/dictionary.lux @@ -555,52 +555,52 @@ #.End colls))) -(type: #export (Dictionary k v) +(type: .public (Dictionary k v) {#.doc "A dictionary implemented as a Hash-Array Mapped Trie (HAMT)."} {#hash (Hash k) #root (Node k v)}) -(def: #export key_hash +(def: .public key_hash (All [k v] (-> (Dictionary k v) (Hash k))) (get@ #..hash)) -(def: #export (empty key_hash) +(def: .public (empty key_hash) {#.doc (doc "An empty dictionary.")} (All [k v] (-> (Hash k) (Dictionary k v))) {#hash key_hash #root empty_node}) -(def: #export (put key val dict) +(def: .public (put key val dict) (All [k v] (-> k v (Dictionary k v) (Dictionary k v))) (let [[key_hash node] dict] [key_hash (put' root_level (\ key_hash hash key) key val key_hash node)])) -(def: #export (remove key dict) +(def: .public (remove key dict) (All [k v] (-> k (Dictionary k v) (Dictionary k v))) (let [[key_hash node] dict] [key_hash (remove' root_level (\ key_hash hash key) key key_hash node)])) -(def: #export (get key dict) +(def: .public (get key dict) (All [k v] (-> k (Dictionary k v) (Maybe v))) (let [[key_hash node] dict] (get' root_level (\ key_hash hash key) key key_hash node))) -(def: #export (key? dict key) +(def: .public (key? dict key) (All [k v] (-> (Dictionary k v) k Bit)) (case (get key dict) #.None #0 (#.Some _) #1)) -(exception: #export key_already_exists) +(exception: .public key_already_exists) -(def: #export (try_put key val dict) +(def: .public (try_put key val dict) {#.doc "Only puts the KV-pair if the key is not already present."} (All [k v] (-> k v (Dictionary k v) (Try (Dictionary k v)))) (case (get key dict) #.None (#try.Success (put key val dict)) (#.Some _) (exception.except ..key_already_exists []))) -(def: #export (update key f dict) +(def: .public (update key f dict) {#.doc "Transforms the value located at key (if available), using the given function."} (All [k v] (-> k (-> v v) (Dictionary k v) (Dictionary k v))) (case (get key dict) @@ -610,7 +610,7 @@ (#.Some val) (put key (f val) dict))) -(def: #export (upsert key default f dict) +(def: .public (upsert key default f dict) {#.doc (doc "Updates the value at the key; if it exists." "Otherwise, puts a value by applying the function to a default.")} (All [k v] (-> k v (-> v v) (Dictionary k v) (Dictionary k v))) @@ -619,19 +619,19 @@ (..get key dict))) dict)) -(def: #export size +(def: .public size (All [k v] (-> (Dictionary k v) Nat)) (|>> product.right ..size')) -(def: #export empty? +(def: .public empty? (All [k v] (-> (Dictionary k v) Bit)) (|>> size (n.= 0))) -(def: #export entries +(def: .public entries (All [k v] (-> (Dictionary k v) (List [k v]))) (|>> product.right ..entries')) -(def: #export (of_list key_hash kvs) +(def: .public (of_list key_hash kvs) (All [k v] (-> (Hash k) (List [k v]) (Dictionary k v))) (list\fold (function (_ [k v] dict) (..put k v dict)) @@ -639,7 +639,7 @@ kvs)) (template [ ] - [(def: #export + [(def: .public (All [k v] (-> (Dictionary k v) (List ))) (|>> ..entries (list\fold (function (_ [k v] bundle) @@ -650,7 +650,7 @@ [v values] ) -(def: #export (merged dict2 dict1) +(def: .public (merged dict2 dict1) {#.doc (doc "Merges 2 dictionaries." "If any collisions with keys occur, the values of dict2 will overwrite those of dict1.")} (All [k v] (-> (Dictionary k v) (Dictionary k v) (Dictionary k v))) @@ -658,7 +658,7 @@ dict1 (entries dict2))) -(def: #export (merged_with f dict2 dict1) +(def: .public (merged_with f dict2 dict1) {#.doc (doc "Merges 2 dictionaries." "If any collisions with keys occur, a new value will be computed by applying 'f' to the values of dict2 and dict1.")} (All [k v] (-> (-> v v v) (Dictionary k v) (Dictionary k v) (Dictionary k v))) @@ -672,7 +672,7 @@ dict1 (entries dict2))) -(def: #export (re_bind from_key to_key dict) +(def: .public (re_bind from_key to_key dict) {#.doc (doc "If there is a value under 'from_key', remove 'from_key' and store the value under 'to_key'.")} (All [k v] (-> k k (Dictionary k v) (Dictionary k v))) (case (get from_key dict) @@ -684,7 +684,7 @@ (remove from_key) (put to_key val)))) -(def: #export (sub keys dict) +(def: .public (sub keys dict) {#.doc "A sub-dictionary, with only the specified keys."} (All [k v] (-> (List k) (Dictionary k v) (Dictionary k v))) (let [[key_hash _] dict] @@ -695,7 +695,7 @@ (empty key_hash) keys))) -(implementation: #export (equivalence (^open ",\.")) +(implementation: .public (equivalence (^open ",\.")) (All [k v] (-> (Equivalence v) (Equivalence (Dictionary k v)))) (def: (= reference subject) @@ -733,7 +733,7 @@ [k (f v)]) collisions))))) -(implementation: #export functor +(implementation: .public functor (All [k] (Functor (Dictionary k))) (def: (map 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 3b4e7a17c..8d91b5cfb 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux @@ -44,12 +44,12 @@ [black #Black] ) -(type: #export (Dictionary k v) +(type: .public (Dictionary k v) {#.doc (doc "A dictionary data-structure with ordered entries.")} {#&order (Order k) #root (Maybe (Node k v))}) -(def: #export (empty order) +(def: .public (empty order) {#.doc (doc "An empty dictionary, employing the given order.")} (All [k v] (-> (Order k) (Dictionary k v))) {#&order order @@ -57,7 +57,7 @@ ## TODO: Doing inneficient access of Order functions due to compiler bug. ## TODO: Must improve it as soon as bug is fixed. -(def: #export (get key dict) +(def: .public (get key dict) (All [k v] (-> k (Dictionary k v) (Maybe v))) (let [## (^open "_\.") (get@ #&order 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: #export (key? dict key) +(def: .public (key? dict key) (All [k v] (-> (Dictionary k v) k Bit)) (let [## (^open "_\.") (get@ #&order dict) ] @@ -101,7 +101,7 @@ (recur (get@ #right node))))))))) (template [ ] - [(def: #export ( dict) + [(def: .public ( dict) {#.doc (doc (~~ (template.text ["Yields value under the " "imum key."])))} (All [k v] (-> (Dictionary k v) (Maybe v))) (case (get@ #root dict) @@ -121,7 +121,7 @@ [max #right] ) -(def: #export (size dict) +(def: .public (size dict) (All [k v] (-> (Dictionary k v) Nat)) (loop [node (get@ #root dict)] (case node @@ -132,7 +132,7 @@ (inc (n.+ (recur (get@ #left node)) (recur (get@ #right node))))))) -(def: #export empty? +(def: .public empty? (All [k v] (-> (Dictionary k v) Bit)) (|>> ..size (n.= 0))) @@ -249,7 +249,7 @@ #Black )))) -(def: #export (put key value dict) +(def: .public (put key value dict) (All [k v] (-> k v (Dictionary k v) (Dictionary k v))) (let [(^open "_\.") (get@ #&order dict) root' (loop [?root (get@ #root dict)] @@ -472,7 +472,7 @@ _ (undefined))) -(def: #export (remove key dict) +(def: .public (remove key dict) (All [k v] (-> k (Dictionary k v) (Dictionary k v))) (let [(^open "_\.") (get@ #&order dict) [?root found?] (loop [?root (get@ #root dict)] @@ -527,7 +527,7 @@ (set@ #root (#.Some (blackened root)) dict) ))) -(def: #export (update key transform dict) +(def: .public (update key transform dict) (All [k v] (-> k (-> v v) (Dictionary k v) (Dictionary k v))) (case (..get key dict) (#.Some old) @@ -536,7 +536,7 @@ #.None dict)) -(def: #export (of_list order list) +(def: .public (of_list order list) (All [k v] (-> (Order k) (List [k v]) (Dictionary k v))) (list\fold (function (_ [key value] dict) (put key value dict)) @@ -544,7 +544,7 @@ list)) (template [ ] - [(def: #export ( dict) + [(def: .public ( dict) (All [k v] (-> (Dictionary k v) (List ))) (loop [node (get@ #root dict)] (case node @@ -562,7 +562,7 @@ [values v (get@ #value node')] ) -(implementation: #export (equivalence (^open ",\.")) +(implementation: .public (equivalence (^open ",\.")) (All [k v] (-> (Equivalence v) (Equivalence (Dictionary k v)))) (def: (= reference sample) diff --git a/stdlib/source/library/lux/data/collection/dictionary/plist.lux b/stdlib/source/library/lux/data/collection/dictionary/plist.lux index 03025db7e..10c831700 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/plist.lux @@ -13,24 +13,24 @@ ["n" nat]]]]]) ## https://en.wikipedia.org/wiki/Property_list -(type: #export (PList a) +(type: .public (PList a) {#.doc (doc "A property list." "It's a simple dictionary-like structure with Text keys.")} (List [Text a])) -(def: #export empty +(def: .public empty PList #.End) -(def: #export size +(def: .public size (All [a] (-> (PList a) Nat)) list.size) -(def: #export empty? +(def: .public empty? (All [a] (-> (PList a) Bit)) (|>> ..size (n.= 0))) -(def: #export (get key properties) +(def: .public (get key properties) (All [a] (-> Text (PList a) (Maybe a))) (case properties #.End @@ -42,7 +42,7 @@ (get key properties')))) (template [ ] - [(def: #export + [(def: .public (All [a] (-> (PList a) (List ))) (list\map ))] @@ -50,7 +50,7 @@ [values a product.right] ) -(def: #export (contains? key properties) +(def: .public (contains? key properties) (All [a] (-> Text (PList a) Bit)) (case (..get key properties) (#.Some _) @@ -59,7 +59,7 @@ #.None false)) -(def: #export (put key val properties) +(def: .public (put key val properties) (All [a] (-> Text a (PList a) (PList a))) (case properties #.End @@ -72,7 +72,7 @@ (#.Item [k' v'] (put key val properties'))))) -(def: #export (update key f properties) +(def: .public (update key f properties) (All [a] (-> Text (-> a a) (PList a) (PList a))) (case properties #.End @@ -83,7 +83,7 @@ (#.Item [k' (f v')] properties') (#.Item [k' v'] (update key f properties'))))) -(def: #export (remove key properties) +(def: .public (remove key properties) (All [a] (-> Text (PList a) (PList a))) (case properties #.End @@ -95,7 +95,7 @@ (#.Item [k' v'] (remove key properties'))))) -(def: #export equivalence +(def: .public equivalence (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 35aeaafe4..1c8294dc0 100644 --- a/stdlib/source/library/lux/data/collection/list.lux +++ b/stdlib/source/library/lux/data/collection/list.lux @@ -23,7 +23,7 @@ ## #End ## (#Item a (List a))) -(implementation: #export fold +(implementation: .public fold (Fold List) (def: (fold f init xs) @@ -34,7 +34,7 @@ (#.Item x xs') (fold f (f x init) xs')))) -(def: #export (folds f init inputs) +(def: .public (folds f init inputs) (All [a b] (-> (-> a b b) b (List a) (List b))) (case inputs #.End @@ -43,14 +43,14 @@ (#.Item [head tail]) (#.Item [init (folds f (f head init) tail)]))) -(def: #export (reversed xs) +(def: .public (reversed xs) (All [a] (-> (List a) (List a))) (fold (function (_ head tail) (#.Item head tail)) #.End xs)) -(def: #export (only keep? xs) +(def: .public (only keep? xs) {#.doc (doc "A list with only values that satisfy the predicate.")} (All [a] (-> (Predicate a) (List a) (List a))) @@ -63,7 +63,7 @@ (#.Item x (only keep? xs')) (only keep? xs')))) -(def: #export (partition satisfies? list) +(def: .public (partition satisfies? list) {#.doc "Divide the list into all elements that satisfy a predicate, and all elements that do not."} (All [a] (-> (Predicate a) (List a) [(List a) (List a)])) (case list @@ -76,7 +76,7 @@ [(#.Item head in) out] [in (#.Item head out)])))) -(def: #export (pairs xs) +(def: .public (pairs xs) {#.doc (doc "Cut the list into pairs of 2." "Caveat emptor: If the list has an un-even number of elements, the last one will be skipped.")} (All [a] (-> (List a) (List [a a]))) @@ -88,7 +88,7 @@ #.End)) (template [ ] - [(def: #export ( n xs) + [(def: .public ( n xs) (All [a] (-> Nat (List a) (List a))) (if (n.> 0 n) @@ -105,7 +105,7 @@ ) (template [ ] - [(def: #export ( predicate xs) + [(def: .public ( predicate xs) (All [a] (-> (Predicate a) (List a) (List a))) (case xs @@ -121,7 +121,7 @@ [drop_while (drop_while predicate xs') xs] ) -(def: #export (split n xs) +(def: .public (split n xs) (All [a] (-> Nat (List a) [(List a) (List a)])) (if (n.> 0 n) @@ -146,14 +146,14 @@ (split_with' predicate (#.Item x ys) xs') [ys xs]))) -(def: #export (split_with predicate xs) +(def: .public (split_with predicate xs) {#.doc "Segment the list by using a predicate to tell when to cut."} (All [a] (-> (Predicate a) (List a) [(List a) (List a)])) (let [[ys' xs'] (split_with' predicate #.End xs)] [(reversed ys') xs'])) -(def: #export (chunk size list) +(def: .public (chunk size list) {#.doc "Segment the list in chunks of the given size."} (All [a] (-> Nat (List a) (List (List a)))) (case list @@ -164,7 +164,7 @@ (let [[pre post] (split size list)] (#.Item pre (chunk size post))))) -(def: #export (repeat n x) +(def: .public (repeat n x) {#.doc "A list of the value x, repeated n times."} (All [a] (-> Nat a (List a))) @@ -182,7 +182,7 @@ #.None (list))) -(def: #export (iterations f x) +(def: .public (iterations f x) {#.doc "Generates a list element by element until the function returns #.None."} (All [a] (-> (-> a (Maybe a)) a (List a))) @@ -193,7 +193,7 @@ #.None (list x))) -(def: #export (one check xs) +(def: .public (one check xs) (All [a b] (-> (-> a (Maybe b)) (List a) (Maybe b))) (case xs @@ -208,7 +208,7 @@ #.None (one check xs')))) -(def: #export (all check xs) +(def: .public (all check xs) (All [a b] (-> (-> a (Maybe b)) (List a) (List b))) (for {## TODO: Stop relying on this ASAP. @@ -234,7 +234,7 @@ #.None (all check xs'))))) -(def: #export (find predicate xs) +(def: .public (find predicate xs) {#.doc "Yields the first value in the list that satisfies the predicate."} (All [a] (-> (Predicate a) (List a) (Maybe a))) @@ -244,7 +244,7 @@ #.None)) xs)) -(def: #export (interpose sep xs) +(def: .public (interpose sep xs) {#.doc "Puts a value between every two elements in the list."} (All [a] (-> a (List a) (List a))) @@ -258,12 +258,12 @@ (#.Item x xs') (list& x sep (interpose sep xs')))) -(def: #export (size list) +(def: .public (size list) (All [a] (-> (List a) Nat)) (fold (function (_ _ acc) (n.+ 1 acc)) 0 list)) (template [ ] - [(def: #export ( predicate xs) + [(def: .public ( predicate xs) (All [a] (-> (Predicate a) (List a) Bit)) (loop [xs xs] @@ -283,7 +283,7 @@ [any? #0 or] ) -(def: #export (item i xs) +(def: .public (item i xs) {#.doc "Fetches the element at the specified index."} (All [a] (-> Nat (List a) (Maybe a))) @@ -296,7 +296,7 @@ (#.Some x) (item (dec i) xs')))) -(implementation: #export (equivalence Equivalence) +(implementation: .public (equivalence Equivalence) (All [a] (-> (Equivalence a) (Equivalence (List a)))) (def: (= xs ys) @@ -312,7 +312,7 @@ #0 ))) -(implementation: #export (hash super) +(implementation: .public (hash super) (All [a] (-> (Hash a) (Hash (List a)))) (def: &equivalence @@ -324,7 +324,7 @@ (n.+ (\ super hash member) hash)) 0))) -(implementation: #export monoid +(implementation: .public monoid (All [a] (Monoid (List a))) (def: identity #.End) @@ -338,7 +338,7 @@ (open: "." ..monoid) -(implementation: #export functor +(implementation: .public functor (Functor List) (def: (map f ma) @@ -351,7 +351,7 @@ (open: "." ..functor) -(implementation: #export apply +(implementation: .public apply (Apply List) (def: &functor ..functor) @@ -364,7 +364,7 @@ (#.Item f ff') (compose (map f fa) (apply ff' fa))))) -(implementation: #export monad +(implementation: .public monad (Monad List) (def: &functor ..functor) @@ -375,7 +375,7 @@ (def: join (|>> reversed (fold compose identity)))) -(def: #export (sort < xs) +(def: .public (sort < xs) {#.doc (doc "A list ordered by a comparison function.")} (All [a] (-> (-> a a Bit) (List a) (List a))) (case xs @@ -391,7 +391,7 @@ xs')] ($_ compose (sort < pre) (list x) (sort < post))))) -(def: #export (empty? xs) +(def: .public (empty? xs) (All [a] (Predicate (List a))) (case xs #.End @@ -400,7 +400,7 @@ _ false)) -(def: #export (member? eq xs x) +(def: .public (member? eq xs x) (All [a] (-> (Equivalence a) (List a) a Bit)) (case xs #.End @@ -411,7 +411,7 @@ (member? eq xs' x)))) (template [ ] - [(def: #export ( xs) + [(def: .public ( xs) {#.doc } (All [a] (-> (List a) (Maybe ))) (case xs @@ -425,7 +425,7 @@ [tail (List a) xs' "For a list of size N, yields the N-1 elements after the first one."] ) -(def: #export (indices size) +(def: .public (indices size) {#.doc "Produces all the valid indices for a given size."} (All [a] (-> Nat (List Nat))) (if (n.= 0 size) @@ -458,10 +458,10 @@ output' (recur input' output'))))) -(macro: #export (zipped tokens state) +(macro: .public (zipped tokens state) {#.doc (doc "Create list zippers with the specified number of input lists." - (def: #export zipped/2 (zipped 2)) - (def: #export zipped/3 (zipped 3)) + (def: .public zipped/2 (zipped 2)) + (def: .public zipped/3 (zipped 3)) (zipped/3 xs ys zs) ((zipped 3) xs ys zs))} (case tokens @@ -500,13 +500,13 @@ _ (#.Left "Wrong syntax for zipped"))) -(def: #export zipped/2 (zipped 2)) -(def: #export zipped/3 (zipped 3)) +(def: .public zipped/2 (zipped 2)) +(def: .public zipped/3 (zipped 3)) -(macro: #export (zipped_with tokens state) +(macro: .public (zipped_with tokens state) {#.doc (doc "Create list zippers with the specified number of input lists." - (def: #export zipped_with/2 (zipped_with 2)) - (def: #export zipped_with/3 (zipped_with 3)) + (def: .public zipped_with/2 (zipped_with 2)) + (def: .public zipped_with/3 (zipped_with 3)) (zipped_with/2 + xs ys) ((zipped_with 2) + xs ys))} (case tokens @@ -548,10 +548,10 @@ _ (#.Left "Wrong syntax for zipped_with"))) -(def: #export zipped_with/2 (zipped_with 2)) -(def: #export zipped_with/3 (zipped_with 3)) +(def: .public zipped_with/2 (zipped_with 2)) +(def: .public zipped_with/3 (zipped_with 3)) -(def: #export (last xs) +(def: .public (last xs) (All [a] (-> (List a) (Maybe a))) (case xs #.End @@ -563,7 +563,7 @@ (#.Item x xs') (last xs'))) -(def: #export (inits xs) +(def: .public (inits xs) {#.doc (doc "For a list of size N, yields the first N-1 elements." "Will yield a #.None for empty lists.")} (All [a] (-> (List a) (Maybe (List a)))) @@ -583,12 +583,12 @@ (#.Some (#.Item x tail))) )) -(def: #export concat +(def: .public concat {#.doc (doc "The sequential combination of all the lists.")} (All [a] (-> (List (List a)) (List a))) (\ ..monad join)) -(implementation: #export (with monad) +(implementation: .public (with monad) {#.doc (doc "Enhances a monad with List functionality.")} (All [M] (-> (Monad M) (Monad (All [a] (M (List a)))))) @@ -606,12 +606,12 @@ (monad.seq ! lMla))] (in (concat lla))))) -(def: #export (lift monad) +(def: .public (lift monad) {#.doc (doc "Wraps a monadic value with List machinery.")} (All [M a] (-> (Monad M) (-> (M a) (M (List a))))) (\ monad map (\ ..monad in))) -(def: #export (enumeration xs) +(def: .public (enumeration xs) {#.doc "Pairs every element in the list with its index, starting at 0."} (All [a] (-> (List a) (List [Nat a]))) (loop [idx 0 @@ -623,7 +623,7 @@ (#.Item x xs') (#.Item [idx x] (recur (inc idx) xs'))))) -(macro: #export (when tokens state) +(macro: .public (when tokens state) {#.doc (doc "Can be used as a guard in (co)monadic be/do expressions." (do monad [value (do_something 1 2 3) diff --git a/stdlib/source/library/lux/data/collection/queue.lux b/stdlib/source/library/lux/data/collection/queue.lux index 0c6a24f88..31c8222a2 100644 --- a/stdlib/source/library/lux/data/collection/queue.lux +++ b/stdlib/source/library/lux/data/collection/queue.lux @@ -11,48 +11,48 @@ [number ["n" nat]]]]]) -(type: #export (Queue a) +(type: .public (Queue a) {#.doc (doc "A first-in, first-out sequential data-structure.")} {#front (List a) #rear (List a)}) -(def: #export empty +(def: .public empty Queue {#front (.list) #rear (.list)}) -(def: #export (of_list entries) +(def: .public (of_list entries) (All [a] (-> (List a) (Queue a))) {#front entries #rear (.list)}) -(def: #export (list queue) +(def: .public (list queue) (All [a] (-> (Queue a) (List a))) (let [(^slots [#front #rear]) queue] (list\compose front (list.reversed rear)))) -(def: #export peek +(def: .public peek {#.doc (doc "Yields the first value in the queue, if any.")} (All [a] (-> (Queue a) (Maybe a))) (|>> (get@ #front) list.head)) -(def: #export (size queue) +(def: .public (size queue) (All [a] (-> (Queue a) Nat)) (let [(^slots [#front #rear]) queue] (n.+ (list.size front) (list.size rear)))) -(def: #export empty? +(def: .public empty? (All [a] (-> (Queue a) Bit)) (|>> (get@ #front) list.empty?)) -(def: #export (member? equivalence queue member) +(def: .public (member? equivalence queue member) (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: #export (pop queue) +(def: .public (pop queue) (All [a] (-> (Queue a) (Queue a))) (case (get@ #front queue) ## Empty... @@ -70,7 +70,7 @@ (|> queue (set@ #front front')))) -(def: #export (push val queue) +(def: .public (push val queue) (All [a] (-> a (Queue a) (Queue a))) (case (get@ #front queue) #.End @@ -79,7 +79,7 @@ _ (update@ #rear (|>> (#.Item val)) queue))) -(implementation: #export (equivalence super) +(implementation: .public (equivalence super) (All [a] (-> (Equivalence a) (Equivalence (Queue a)))) (def: (= reference subject) @@ -87,7 +87,7 @@ (..list reference) (..list subject)))) -(implementation: #export functor +(implementation: .public functor (Functor Queue) (def: (map f fa) diff --git a/stdlib/source/library/lux/data/collection/queue/priority.lux b/stdlib/source/library/lux/data/collection/queue/priority.lux index 698bb57ac..763f1836d 100644 --- a/stdlib/source/library/lux/data/collection/queue/priority.lux +++ b/stdlib/source/library/lux/data/collection/queue/priority.lux @@ -15,14 +15,14 @@ [type (#+ :by_example) [abstract (#+ abstract: :abstraction :representation)]]]]) -(type: #export Priority +(type: .public Priority Nat) -(def: #export max +(def: .public max Priority n\top) -(def: #export min +(def: .public min Priority n\bottom) @@ -36,21 +36,23 @@ @)) -(abstract: #export (Queue a) +(abstract: .public (Queue a) + {} + (Maybe (Tree :@: Priority a)) - (def: #export empty + (def: .public empty Queue (:abstraction #.None)) - (def: #export (peek queue) + (def: .public (peek queue) (All [a] (-> (Queue a) (Maybe a))) (do maybe.monad [tree (:representation queue)] (tree.one (n.= (tree.tag tree)) tree))) - (def: #export (size queue) + (def: .public (size queue) (All [a] (-> (Queue a) Nat)) (case (:representation queue) #.None @@ -65,7 +67,7 @@ (0 #1 [left right]) (n.+ (recur left) (recur right)))))) - (def: #export (member? equivalence queue member) + (def: .public (member? equivalence queue member) (All [a] (-> (Equivalence a) (Queue a) a Bit)) (case (:representation queue) #.None @@ -81,7 +83,7 @@ (or (recur left) (recur right)))))) - (def: #export (pop queue) + (def: .public (pop queue) (All [a] (-> (Queue a) (Queue a))) (:abstraction (do maybe.monad @@ -109,7 +111,7 @@ (#.Some =right) (#.Some (\ ..builder branch left =right))))))))) - (def: #export (push priority value queue) + (def: .public (push priority value queue) (All [a] (-> Priority a (Queue a) (Queue a))) (let [addition (\ ..builder leaf priority value)] (:abstraction @@ -121,6 +123,6 @@ (#.Some (\ ..builder branch tree addition)))))) ) -(def: #export empty? +(def: .public empty? (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 20c6c2cea..43d41cc2c 100644 --- a/stdlib/source/library/lux/data/collection/row.lux +++ b/stdlib/source/library/lux/data/collection/row.lux @@ -182,25 +182,25 @@ (list\fold (function (_ sub acc) (list\compose (list' sub) acc)) #.End)))) -(type: #export (Row a) +(type: .public (Row a) {#.doc (doc "A sequential data-structure with fast random access.")} {#level Level #size Nat #root (Hierarchy a) #tail (Base a)}) -(def: #export empty +(def: .public empty Row {#level (level_up root_level) #size 0 #root (empty_hierarchy []) #tail (array.empty 0)}) -(def: #export (size row) +(def: .public (size row) (All [a] (-> (Row a) Nat)) (get@ #size row)) -(def: #export (add val row) +(def: .public (add val row) (All [a] (-> a (Row a) (Row a))) ## Check if there is room in the tail. (let [row_size (get@ #size row)] @@ -235,13 +235,13 @@ (exception: incorrect_row_structure) -(exception: #export [a] (index_out_of_bounds {row (Row a)} {index Nat}) +(exception: .public [a] (index_out_of_bounds {row (Row a)} {index Nat}) (exception.report ["Size" (\ n.decimal encode (get@ #size row))] ["Index" (\ n.decimal encode index)])) (exception: base_was_not_found) -(def: #export (within_bounds? row idx) +(def: .public (within_bounds? row idx) {#.doc (doc "Determines whether the index is within the bounds of the row.")} (All [a] (-> (Row a) Nat Bit)) (n.< (get@ #size row) idx)) @@ -268,7 +268,7 @@ (exception.except ..incorrect_row_structure [])))) (exception.except ..index_out_of_bounds [row idx]))) -(def: #export (item idx row) +(def: .public (item idx row) (All [a] (-> Nat (Row a) (Try a))) (do try.monad [base (base_for idx row)] @@ -279,7 +279,7 @@ #.None (exception.except ..incorrect_row_structure [])))) -(def: #export (put idx val row) +(def: .public (put idx val row) (All [a] (-> Nat a (Row a) (Try (Row a)))) (let [row_size (get@ #size row)] (if (within_bounds? row idx) @@ -293,13 +293,13 @@ row))) (exception.except ..index_out_of_bounds [row idx])))) -(def: #export (update idx f row) +(def: .public (update idx f row) (All [a] (-> Nat (-> a a) (Row a) (Try (Row a)))) (do try.monad [val (..item idx row)] (..put idx (f val) row))) -(def: #export (pop row) +(def: .public (pop row) (All [a] (-> (Row a) (Row a))) (case (get@ #size row) 0 @@ -341,24 +341,24 @@ (set@ #tail new_tail)))))) )) -(def: #export (list row) +(def: .public (list row) (All [a] (-> (Row a) (List a))) (list\compose (list' (#Hierarchy (get@ #root row))) (list' (#Base (get@ #tail row))))) -(def: #export of_list +(def: .public of_list (All [a] (-> (List a) (Row a))) (list\fold ..add ..empty)) -(def: #export (member? a/Equivalence row val) +(def: .public (member? a/Equivalence row val) (All [a] (-> (Equivalence a) (Row a) a Bit)) (list.member? a/Equivalence (list row) val)) -(def: #export empty? +(def: .public empty? (All [a] (-> (Row a) Bit)) (|>> (get@ #size) (n.= 0))) -(syntax: #export (row {elems (p.some s.any)}) +(syntax: .public (row {elems (p.some s.any)}) {#.doc (doc "Row literals." (row 12 34 56 78 90))} (in (.list (` (..of_list (.list (~+ elems))))))) @@ -377,7 +377,7 @@ _ #0))) -(implementation: #export (equivalence Equivalence) +(implementation: .public (equivalence Equivalence) (All [a] (-> (Equivalence a) (Equivalence (Row a)))) (def: (= v1 v2) @@ -401,7 +401,7 @@ init hierarchy)))) -(implementation: #export fold +(implementation: .public fold (Fold Row) (def: (fold f init xs) @@ -412,7 +412,7 @@ (#Hierarchy (get@ #root xs))) (#Base (get@ #tail xs)))))) -(implementation: #export monoid +(implementation: .public monoid (All [a] (Monoid (Row a))) (def: identity ..empty) @@ -431,7 +431,7 @@ (#Hierarchy hierarchy) (#Hierarchy (array\map (map f) hierarchy))))) -(implementation: #export functor +(implementation: .public functor (Functor Row) (def: (map f xs) @@ -440,7 +440,7 @@ #root (|> xs (get@ #root) (array\map (\ node_functor map f))) #tail (|> xs (get@ #tail) (array\map f))})) -(implementation: #export apply +(implementation: .public apply (Apply Row) (def: &functor ..functor) @@ -453,7 +453,7 @@ ff)] (fold compose identity results)))) -(implementation: #export monad +(implementation: .public monad (Monad Row) (def: &functor ..functor) @@ -465,14 +465,14 @@ (^open ".") ..monoid] (fold (function (_ post pre) (compose pre post)) identity)))) -(def: #export reversed +(def: .public reversed (All [a] (-> (Row a) (Row a))) (|>> ..list list.reversed (list\fold add ..empty))) (template [ ] - [(def: #export + [(def: .public (All [a] (-> (Predicate a) (Row a) Bit)) (let [help (: (All [a] diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux index 44755f0db..98869531f 100644 --- a/stdlib/source/library/lux/data/collection/sequence.lux +++ b/stdlib/source/library/lux/data/collection/sequence.lux @@ -19,23 +19,23 @@ [number ["n" nat]]]]]) -(type: #export (Sequence a) +(type: .public (Sequence a) {#.doc "An infinite sequence of values."} (Cont [a (Sequence a)])) -(def: #export (iterations f x) +(def: .public (iterations f x) {#.doc "Create a sequence by applying a function to a value, and to its result, on and on..."} (All [a] (-> (-> a a) a (Sequence a))) (//.pending [x (iterations f (f x))])) -(def: #export (repeat x) +(def: .public (repeat x) {#.doc "Repeat a value forever."} (All [a] (-> a (Sequence a))) (//.pending [x (repeat x)])) -(def: #export (cycle [start next]) +(def: .public (cycle [start next]) {#.doc (doc "Go over the elements of a list forever." "The list should not be empty.")} (All [a] @@ -50,7 +50,7 @@ (recur head' tail'))]))) (template [ ] - [(def: #export ( sequence) + [(def: .public ( sequence) (All [a] (-> (Sequence a) )) (let [[head tail] (//.run sequence)] ))] @@ -59,7 +59,7 @@ [tail (Sequence a)] ) -(def: #export (item idx sequence) +(def: .public (item idx sequence) (All [a] (-> Nat (Sequence a) a)) (let [[head tail] (//.run sequence)] (case idx @@ -67,7 +67,7 @@ _ (item (dec idx) tail)))) (template [ ] - [(def: #export ( pred xs) + [(def: .public ( pred xs) (All [a] (-> (Sequence a) (List a))) (let [[x xs'] (//.run xs)] @@ -75,7 +75,7 @@ (list& x ( xs')) (list)))) - (def: #export ( pred xs) + (def: .public ( pred xs) (All [a] (-> (Sequence a) (Sequence a))) (let [[x xs'] (//.run xs)] @@ -83,7 +83,7 @@ ( xs') xs))) - (def: #export ( pred xs) + (def: .public ( pred xs) (All [a] (-> (Sequence a) [(List a) (Sequence a)])) (let [[x xs'] (//.run xs)] @@ -96,14 +96,14 @@ [take drop split Nat (n.> 0 pred) (dec pred)] ) -(def: #export (unfold step init) +(def: .public (unfold step init) {#.doc "A stateful way of infinitely calculating the values of a sequence."} (All [a b] (-> (-> a [a b]) a (Sequence b))) (let [[next x] (step init)] (//.pending [x (unfold step next)]))) -(def: #export (only predicate sequence) +(def: .public (only predicate sequence) {#.doc (doc "A new sequence only with items that satisfy the predicate.")} (All [a] (-> (-> a Bit) (Sequence a) (Sequence a))) (let [[head tail] (//.run sequence)] @@ -111,7 +111,7 @@ (//.pending [head (only predicate tail)]) (only predicate tail)))) -(def: #export (partition left? xs) +(def: .public (partition left? xs) {#.doc (doc "Split a sequence in two based on a predicate." "The left side contains all entries for which the predicate is #1." "The right side contains all entries for which the predicate is #0.")} @@ -119,14 +119,14 @@ [(..only left? xs) (..only (bit.complement left?) xs)]) -(implementation: #export functor +(implementation: .public functor (Functor Sequence) (def: (map f fa) (let [[head tail] (//.run fa)] (//.pending [(f head) (map f tail)])))) -(implementation: #export comonad +(implementation: .public comonad (CoMonad Sequence) (def: &functor ..functor) @@ -137,7 +137,7 @@ (let [[head tail] (//.run wa)] (//.pending [wa (split tail)])))) -(syntax: #export (^sequence& {patterns (.form (<>.many .any))} +(syntax: .public (^sequence& {patterns (.form (<>.many .any))} body {branches (<>.some .any)}) {#.doc (doc "Allows destructuring of sequences in pattern-matching expressions." diff --git a/stdlib/source/library/lux/data/collection/set.lux b/stdlib/source/library/lux/data/collection/set.lux index 64438517f..2269117ca 100644 --- a/stdlib/source/library/lux/data/collection/set.lux +++ b/stdlib/source/library/lux/data/collection/set.lux @@ -15,53 +15,53 @@ ["." // #_ ["#" dictionary (#+ Dictionary)]]) -(type: #export (Set a) +(type: .public (Set a) {#.doc (doc "An un-ordered data-structure with unique items." "This means there is no repetition/duplication among the items.")} (Dictionary a Any)) -(def: #export member_hash +(def: .public member_hash (All [a] (-> (Set a) (Hash a))) //.key_hash) -(def: #export empty +(def: .public empty (All [a] (-> (Hash a) (Set a))) //.empty) -(def: #export size +(def: .public size (All [a] (-> (Set a) Nat)) //.size) -(def: #export (add elem set) +(def: .public (add elem set) (All [a] (-> a (Set a) (Set a))) (|> set (//.put elem []))) -(def: #export remove +(def: .public remove (All [a] (-> a (Set a) (Set a))) //.remove) -(def: #export member? +(def: .public member? (All [a] (-> (Set a) a Bit)) //.key?) -(def: #export list +(def: .public list (All [a] (-> (Set a) (List a))) //.keys) -(def: #export union +(def: .public union (All [a] (-> (Set a) (Set a) (Set a))) //.merged) -(def: #export (difference sub base) +(def: .public (difference sub base) (All [a] (-> (Set a) (Set a) (Set a))) (list\fold ..remove base (..list sub))) -(def: #export (intersection filter base) +(def: .public (intersection filter base) (All [a] (-> (Set a) (Set a) (Set a))) (//.sub (//.keys filter) base)) -(implementation: #export equivalence +(implementation: .public equivalence (All [a] (Equivalence (Set a))) (def: (= (^@ reference [hash _]) sample) @@ -70,7 +70,7 @@ (list.every? (..member? reference) (..list sample))))) -(implementation: #export hash +(implementation: .public hash (All [a] (Hash (Set a))) (def: &equivalence ..equivalence) @@ -80,28 +80,28 @@ ..list (\ (list.hash (..member_hash set)) hash)))) -(implementation: #export (monoid hash) +(implementation: .public (monoid hash) (All [a] (-> (Hash a) (Monoid (Set a)))) (def: identity (..empty hash)) (def: compose ..union)) -(def: #export empty? +(def: .public empty? (All [a] (-> (Set a) Bit)) (|>> ..size (n.= 0))) -(def: #export (of_list hash elements) +(def: .public (of_list hash elements) (All [a] (-> (Hash a) (List a) (Set a))) (list\fold ..add (..empty hash) elements)) -(def: #export (sub? super sub) +(def: .public (sub? super sub) (All [a] (-> (Set a) (Set a) Bit)) (list.every? (..member? super) (..list sub))) -(def: #export (super? sub super) +(def: .public (super? sub super) (All [a] (-> (Set a) (Set a) Bit)) (..sub? super sub)) -(def: #export predicate +(def: .public predicate (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 9d746ae52..05c02d4cf 100644 --- a/stdlib/source/library/lux/data/collection/set/multi.lux +++ b/stdlib/source/library/lux/data/collection/set/multi.lux @@ -19,20 +19,20 @@ [// ["." maybe]]]]) -(abstract: #export (Set a) - (Dictionary a Nat) - +(abstract: .public (Set a) {#.doc (doc "A set that keeps track of repetition in its entries.")} - (def: #export empty + (Dictionary a Nat) + + (def: .public empty (All [a] (-> (Hash a) (Set a))) (|>> dictionary.empty :abstraction)) - (def: #export size + (def: .public size (All [a] (-> (Set a) Nat)) (|>> :representation dictionary.values (list\fold n.+ 0))) - (def: #export (add multiplicity elem set) + (def: .public (add multiplicity elem set) (All [a] (-> Nat a (Set a) (Set a))) (case multiplicity 0 set @@ -41,7 +41,7 @@ (dictionary.upsert elem 0 (n.+ multiplicity)) :abstraction))) - (def: #export (remove multiplicity elem set) + (def: .public (remove multiplicity elem set) (All [a] (-> Nat a (Set a) (Set a))) (case multiplicity 0 set @@ -55,11 +55,11 @@ #.None set))) - (def: #export (multiplicity set elem) + (def: .public (multiplicity set elem) (All [a] (-> (Set a) a Nat)) (|> set :representation (dictionary.get elem) (maybe.else 0))) - (def: #export list + (def: .public list (All [a] (-> (Set a) (List a))) (|>> :representation dictionary.entries @@ -68,7 +68,7 @@ #.End))) (template [ ] - [(def: #export ( parameter subject) + [(def: .public ( parameter subject) (All [a] (-> (Set a) (Set a) (Set a))) (:abstraction (dictionary.merged_with (:representation parameter) (:representation subject))))] @@ -76,7 +76,7 @@ [sum n.+] ) - (def: #export (intersection parameter (^:representation subject)) + (def: .public (intersection parameter (^:representation subject)) (All [a] (-> (Set a) (Set a) (Set a))) (list\fold (function (_ [elem multiplicity] output) (..add (n.min (..multiplicity parameter elem) @@ -86,7 +86,7 @@ (..empty (dictionary.key_hash subject)) (dictionary.entries subject))) - (def: #export (difference parameter subject) + (def: .public (difference parameter subject) (All [a] (-> (Set a) (Set a) (Set a))) (|> parameter :representation @@ -95,7 +95,7 @@ (..remove multiplicity elem output)) subject))) - (def: #export (sub? reference subject) + (def: .public (sub? reference subject) {#.doc (doc "Is 'subject' a sub-set of 'reference'?")} (All [a] (-> (Set a) (Set a) Bit)) (|> subject @@ -106,7 +106,7 @@ (..multiplicity reference) (n.>= multiplicity)))))) - (def: #export (support set) + (def: .public (support set) {#.doc (doc "A set of the unique (non repeated) members.")} (All [a] (-> (Set a) (//.Set a))) (let [(^@ set [hash _]) (:representation set)] @@ -114,7 +114,7 @@ dictionary.keys (//.of_list hash)))) - (implementation: #export equivalence + (implementation: .public equivalence (All [a] (Equivalence (Set a))) (def: (= (^:representation reference) sample) @@ -127,7 +127,7 @@ (..multiplicity sample) (n.= multiplicity)))))))) - (implementation: #export hash + (implementation: .public hash (All [a] (Hash (Set a))) (def: &equivalence ..equivalence) @@ -140,24 +140,24 @@ (dictionary.entries set))))) ) -(def: #export (member? set elem) +(def: .public (member? set elem) (All [a] (-> (Set a) a Bit)) (|> elem (..multiplicity set) (n.> 0))) -(def: #export empty? +(def: .public empty? (All [a] (-> (Set a) Bit)) (|>> ..size (n.= 0))) -(def: #export (of_list hash subject) +(def: .public (of_list hash subject) (All [a] (-> (Hash a) (List a) (Set a))) (list\fold (..add 1) (..empty hash) subject)) -(def: #export (of_set subject) +(def: .public (of_set subject) (All [a] (-> (//.Set a) (Set a))) (..of_list (//.member_hash subject) (//.list subject))) -(def: #export super? +(def: .public super? {#.doc (doc "Is 'subject' a super-set of 'reference'?")} (All [a] (-> (Set a) (Set a) Bit)) (function.flip sub?)) diff --git a/stdlib/source/library/lux/data/collection/set/ordered.lux b/stdlib/source/library/lux/data/collection/set/ordered.lux index 97e32646c..8f2992ebc 100644 --- a/stdlib/source/library/lux/data/collection/set/ordered.lux +++ b/stdlib/source/library/lux/data/collection/set/ordered.lux @@ -12,21 +12,21 @@ [type abstract]]]) -(abstract: #export (Set a) - (/.Dictionary a a) - +(abstract: .public (Set a) {#.doc (doc "A set with ordered entries.")} - (def: #export empty + (/.Dictionary a a) + + (def: .public empty (All [a] (-> (Order a) (Set a))) (|>> /.empty :abstraction)) - (def: #export (member? set elem) + (def: .public (member? set elem) (All [a] (-> (Set a) a Bit)) (/.key? (:representation set) elem)) (template [ ] - [(def: #export + [(def: .public (All [a] (-> (Set a) )) (|>> :representation ))] @@ -36,39 +36,39 @@ [Bit empty? /.empty?] ) - (def: #export (add elem set) + (def: .public (add elem set) (All [a] (-> a (Set a) (Set a))) (|> set :representation (/.put elem elem) :abstraction)) - (def: #export (remove elem set) + (def: .public (remove elem set) (All [a] (-> a (Set a) (Set a))) (|> set :representation (/.remove elem) :abstraction)) - (def: #export list + (def: .public list (All [a] (-> (Set a) (List a))) (|>> :representation /.keys)) - (def: #export (of_list &order list) + (def: .public (of_list &order list) (All [a] (-> (Order a) (List a) (Set a))) (list\fold add (..empty &order) list)) - (def: #export (union left right) + (def: .public (union left right) (All [a] (-> (Set a) (Set a) (Set a))) (list\fold ..add right (..list left))) - (def: #export (intersection left right) + (def: .public (intersection left right) (All [a] (-> (Set a) (Set a) (Set a))) (|> (..list right) (list.only (..member? left)) (..of_list (get@ #/.&order (:representation right))))) - (def: #export (difference param subject) + (def: .public (difference param subject) (All [a] (-> (Set a) (Set a) (Set a))) (|> (..list subject) (list.only (|>> (..member? param) not)) (..of_list (get@ #/.&order (:representation subject))))) - (implementation: #export equivalence + (implementation: .public equivalence (All [a] (Equivalence (Set a))) (def: (= reference sample) @@ -76,14 +76,14 @@ = (..list reference) (..list sample)))) ) -(def: #export (sub? super sub) +(def: .public (sub? super sub) {#.doc (doc "Is 'sub' a sub-set of 'super'?")} (All [a] (-> (Set a) (Set a) Bit)) (|> sub ..list (list.every? (..member? super)))) -(def: #export (super? sub super) +(def: .public (super? sub super) {#.doc (doc "Is 'super' a super-set of 'sub'?")} (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 3f720d9ac..d34fe97ac 100644 --- a/stdlib/source/library/lux/data/collection/stack.lux +++ b/stdlib/source/library/lux/data/collection/stack.lux @@ -10,24 +10,24 @@ [type abstract]]]) -(abstract: #export (Stack a) - (List a) - +(abstract: .public (Stack a) {#.doc (doc "A first-in, last-out sequential data-structure.")} - (def: #export empty + (List a) + + (def: .public empty Stack (:abstraction (list))) - (def: #export size + (def: .public size (All [a] (-> (Stack a) Nat)) (|>> :representation //.size)) - (def: #export empty? + (def: .public empty? (All [a] (-> (Stack a) Bit)) (|>> :representation //.empty?)) - (def: #export (peek stack) + (def: .public (peek stack) {#.doc (doc "Yields the top value in the stack, if any.")} (All [a] (-> (Stack a) (Maybe a))) (case (:representation stack) @@ -37,7 +37,7 @@ (#.Item value _) (#.Some value))) - (def: #export (pop stack) + (def: .public (pop stack) (All [a] (-> (Stack a) (Maybe [a (Stack a)]))) (case (:representation stack) #.End @@ -46,11 +46,11 @@ (#.Item top stack') (#.Some [top (:abstraction stack')]))) - (def: #export (push value stack) + (def: .public (push value stack) (All [a] (-> a (Stack a) (Stack a))) (:abstraction (#.Item value (:representation stack)))) - (implementation: #export (equivalence super) + (implementation: .public (equivalence super) (All [a] (-> (Equivalence a) (Equivalence (Stack a)))) @@ -58,7 +58,7 @@ (def: (= reference subject) (\ (//.equivalence super) = (:representation reference) (:representation subject)))) - (implementation: #export functor + (implementation: .public functor (Functor Stack) (def: (map f value) diff --git a/stdlib/source/library/lux/data/collection/tree.lux b/stdlib/source/library/lux/data/collection/tree.lux index 23a957fb7..7d12bad74 100644 --- a/stdlib/source/library/lux/data/collection/tree.lux +++ b/stdlib/source/library/lux/data/collection/tree.lux @@ -16,12 +16,12 @@ [syntax (#+ syntax:)] ["." code]]]]) -(type: #export (Tree a) +(type: .public (Tree a) {#.doc (doc "A generic tree data-structure.")} {#value a #children (List (Tree a))}) -(def: #export (flat tree) +(def: .public (flat tree) {#.doc (doc "All the leaf values of the tree, in order.")} (All [a] (-> (Tree a) (List a))) (|> tree @@ -30,12 +30,12 @@ list\join (#.Item (get@ #value tree)))) -(def: #export (leaf value) +(def: .public (leaf value) (All [a] (-> a (Tree a))) {#value value #children (list)}) -(def: #export (branch value children) +(def: .public (branch value children) (All [a] (-> a (List (Tree a)) (Tree a))) {#value value #children children}) @@ -54,7 +54,7 @@ (<>.else (list)) (<>.and .any))) -(syntax: #export (tree {root tree^}) +(syntax: .public (tree {root tree^}) {#.doc (doc "Tree literals." (: (Tree Nat) (tree 12 @@ -65,14 +65,14 @@ (` {#value (~ value) #children (list (~+ (list\map recur children)))}))))))) -(implementation: #export (equivalence super) +(implementation: .public (equivalence super) (All [a] (-> (Equivalence a) (Equivalence (Tree a)))) (def: (= tx ty) (and (\ super = (get@ #value tx) (get@ #value ty)) (\ (list.equivalence (equivalence super)) = (get@ #children tx) (get@ #children ty))))) -(implementation: #export functor +(implementation: .public functor (Functor Tree) (def: (map f fa) @@ -80,7 +80,7 @@ #children (list\map (map f) (get@ #children fa))})) -(implementation: #export fold +(implementation: .public fold (Fold Tree) (def: (fold f init tree) diff --git a/stdlib/source/library/lux/data/collection/tree/finger.lux b/stdlib/source/library/lux/data/collection/tree/finger.lux index ae6c21990..157b6657e 100644 --- a/stdlib/source/library/lux/data/collection/tree/finger.lux +++ b/stdlib/source/library/lux/data/collection/tree/finger.lux @@ -11,15 +11,15 @@ [abstract (#+ abstract: :abstraction :representation)]]]]) ## https://en.wikipedia.org/wiki/Finger_tree -(abstract: #export (Tree @ t v) +(abstract: .public (Tree @ t v) + {#.doc (doc "A finger tree.")} + {#monoid (Monoid t) #tag t #root (Or v [(Tree @ t v) (Tree @ t v)])} - {#.doc (doc "A finger tree.")} - - (interface: #export (Builder @ t) + (interface: .public (Builder @ t) {#.doc (doc "A builder for finter tree structures.")} (: (All [v] (-> t v (Tree @ t v))) @@ -31,7 +31,7 @@ branch)) (template [ ] - [(def: #export + [(def: .public (All [@ t v] (-> (Tree @ t v) )) (|>> :representation (get@ )))] @@ -39,7 +39,7 @@ [root #root (Either v [(Tree @ t v) (Tree @ t v)])] ) - (implementation: #export (builder monoid) + (implementation: .public (builder monoid) {#.doc (doc "A new builder using the given monoid.")} (All [t] (Ex [@] (-> (Monoid t) (Builder @ t)))) @@ -55,7 +55,7 @@ #tag (\ monoid compose (..tag left) (..tag right)) #root (0 #1 [left right])}))) - (def: #export (value tree) + (def: .public (value tree) (All [@ t v] (-> (Tree @ t v) v)) (case (get@ #root (:representation tree)) (0 #0 value) @@ -64,7 +64,7 @@ (0 #1 [left right]) (value left))) - (def: #export (tags tree) + (def: .public (tags tree) (All [@ t v] (-> (Tree @ t v) (List t))) (case (get@ #root (:representation tree)) (0 #0 value) @@ -74,7 +74,7 @@ (list\compose (tags left) (tags right)))) - (def: #export (values tree) + (def: .public (values tree) (All [@ t v] (-> (Tree @ t v) (List v))) (case (get@ #root (:representation tree)) (0 #0 value) @@ -84,7 +84,7 @@ (list\compose (values left) (values right)))) - (def: #export (one predicate tree) + (def: .public (one predicate tree) {#.doc (doc "Finds one value that meets the predicate.")} (All [@ t v] (-> (Predicate t) (Tree @ t v) (Maybe v))) (let [[monoid tag root] (:representation tree)] @@ -104,7 +104,7 @@ #.None))) ) -(def: #export (exists? predicate tree) +(def: .public (exists? predicate tree) {#.doc (doc "Verifies that a value exists which meets the predicate.")} (All [@ t v] (-> (Predicate t) (Tree @ t v) Bit)) (case (..one predicate tree) diff --git a/stdlib/source/library/lux/data/collection/tree/zipper.lux b/stdlib/source/library/lux/data/collection/tree/zipper.lux index e47036a56..6d7e0f9e4 100644 --- a/stdlib/source/library/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/library/lux/data/collection/tree/zipper.lux @@ -22,12 +22,12 @@ #rights (List (Tree a))}) ## https://en.wikipedia.org/wiki/Zipper_(data_structure) -(type: #export (Zipper a) +(type: .public (Zipper a) {#.doc "Tree zippers, for easy navigation and editing of trees."} {#family (Maybe (Family Zipper a)) #node (Tree a)}) -(implementation: #export (equivalence super) +(implementation: .public (equivalence super) (All [a] (-> (Equivalence a) (Equivalence (Zipper a)))) @@ -42,24 +42,24 @@ (//.equivalence super))] (== reference sample)))) -(def: #export (zipper tree) +(def: .public (zipper tree) (All [a] (-> (Tree a) (Zipper a))) {#family #.None #node tree}) -(def: #export tree +(def: .public tree (All [a] (-> (Zipper a) (Tree a))) (get@ #node)) -(def: #export value +(def: .public value (All [a] (-> (Zipper a) a)) (get@ [#node #//.value])) -(def: #export (set value zipper) +(def: .public (set value zipper) (All [a] (-> a (Zipper a) (Zipper a))) (set@ [#node #//.value] value zipper)) -(def: #export (update transform zipper) +(def: .public (update transform zipper) (All [a] (-> (-> a a) (Zipper a) (Zipper a))) (update@ [#node #//.value] transform zipper)) @@ -67,15 +67,15 @@ (All [a] (-> (Zipper a) (List (Tree a)))) (get@ [#node #//.children])) -(def: #export leaf? +(def: .public leaf? (All [a] (-> (Zipper a) Bit)) (|>> ..children list.empty?)) -(def: #export branch? +(def: .public branch? (All [a] (-> (Zipper a) Bit)) (|>> ..leaf? not)) -(def: #export (start? zipper) +(def: .public (start? zipper) (All [a] (-> (Zipper a) Bit)) (case (get@ #family zipper) #.None @@ -84,7 +84,7 @@ _ false)) -(def: #export (down zipper) +(def: .public (down zipper) (All [a] (-> (Zipper a) (Maybe (Zipper a)))) (case (..children zipper) #.End @@ -96,7 +96,7 @@ #rights tail}) #node head}))) -(def: #export (up zipper) +(def: .public (up zipper) (All [a] (-> (Zipper a) (Maybe (Zipper a)))) (do maybe.monad [family (get@ #family zipper)] @@ -115,7 +115,7 @@ parent)))))) (template [ ] - [(def: #export ( zipper) + [(def: .public ( zipper) (All [a] (-> (Zipper a) (Maybe (Zipper a)))) (case (get@ #family zipper) (#.Some family) @@ -139,7 +139,7 @@ #.None #.None)) - (def: #export ( zipper) + (def: .public ( zipper) (All [a] (-> (Zipper a) (Maybe (Zipper a)))) (case (get@ #family zipper) #.None @@ -168,7 +168,7 @@ [left leftmost #lefts #rights] ) -(def: #export (next zipper) +(def: .public (next zipper) (All [a] (-> (Zipper a) (Maybe (Zipper a)))) (case (..down zipper) (#.Some forward) @@ -199,7 +199,7 @@ #.None zipper))) -(def: #export (previous zipper) +(def: .public (previous zipper) (All [a] (-> (Zipper a) (Maybe (Zipper a)))) (case (..left zipper) #.None @@ -214,7 +214,7 @@ backward)))) (template [ ] - [(def: #export ( zipper) + [(def: .public ( zipper) (All [a] (-> (Zipper a) (Maybe (Zipper a)))) (case ( zipper) #.None @@ -233,7 +233,7 @@ [start ..previous] ) -(def: #export (end? zipper) +(def: .public (end? zipper) (All [a] (-> (Zipper a) Bit)) (case (..end zipper) #.None @@ -242,19 +242,19 @@ (#.Some _) false)) -(def: #export (interpose value zipper) +(def: .public (interpose value zipper) (All [a] (-> a (Zipper a) (Zipper a))) (update@ [#node #//.children] (|>> (//.branch value) list) zipper)) -(def: #export (adopt value zipper) +(def: .public (adopt value zipper) (All [a] (-> a (Zipper a) (Zipper a))) (update@ [#node #//.children] (|>> (#.Item (//.leaf value))) zipper)) -(def: #export (remove zipper) +(def: .public (remove zipper) (All [a] (-> (Zipper a) (Maybe (Zipper a)))) (do maybe.monad [family (get@ #family zipper)] @@ -272,7 +272,7 @@ (set@ #node next)))))) (template [ ] - [(def: #export ( value zipper) + [(def: .public ( value zipper) (All [a] (-> a (Zipper a) (Maybe (Zipper a)))) (case (get@ #family zipper) #.None @@ -287,7 +287,7 @@ [insert_right #rights] ) -(implementation: #export functor +(implementation: .public functor (Functor Zipper) (def: (map f (^slots [#family #node])) @@ -298,7 +298,7 @@ family) #node (//\map f node)})) -(implementation: #export comonad +(implementation: .public comonad (CoMonad Zipper) (def: &functor ..functor) diff --git a/stdlib/source/library/lux/data/color.lux b/stdlib/source/library/lux/data/color.lux index 433dd9bc3..f99dbfbd9 100644 --- a/stdlib/source/library/lux/data/color.lux +++ b/stdlib/source/library/lux/data/color.lux @@ -41,43 +41,43 @@ (-> Frac Nat) (|>> (f.* rgb_factor) f.int .nat)) -(type: #export RGB +(type: .public RGB {#.doc (doc "Red-Green-Blue color format.")} {#red Nat #green Nat #blue Nat}) -(type: #export HSL +(type: .public HSL {#.doc (doc "Hue-Saturation-Lightness color format.")} [Frac Frac Frac]) -(type: #export CMYK +(type: .public CMYK {#.doc (doc "Cyan-Magenta-Yellow-Key color format.")} {#cyan Frac #magenta Frac #yellow Frac #key Frac}) -(type: #export HSB +(type: .public HSB {#.doc (doc "Hue-Saturation-Brightness color format.")} [Frac Frac Frac]) -(abstract: #export Color - RGB - +(abstract: .public Color {#.doc (doc "A color value, independent of color format.")} - (def: #export (of_rgb [red green blue]) + RGB + + (def: .public (of_rgb [red green blue]) (-> RGB Color) (:abstraction {#red (n.% ..rgb_limit red) #green (n.% ..rgb_limit green) #blue (n.% ..rgb_limit blue)})) - (def: #export rgb + (def: .public rgb (-> Color RGB) (|>> :representation)) - (implementation: #export equivalence + (implementation: .public equivalence (Equivalence Color) (def: (= reference sample) @@ -87,7 +87,7 @@ (n.= gR gS) (n.= bR bS))))) - (implementation: #export hash + (implementation: .public hash (Hash Color) (def: &equivalence ..equivalence) @@ -99,19 +99,19 @@ (i64.left_shifted 8 g) b)))) - (def: #export black + (def: .public black Color (..of_rgb {#red 0 #green 0 #blue 0})) - (def: #export white + (def: .public white Color (..of_rgb {#red ..top #green ..top #blue ..top})) - (implementation: #export addition + (implementation: .public addition (Monoid Color) (def: identity ..black) @@ -127,7 +127,7 @@ (-> Nat Nat) (|> ..top (n.- value))) - (def: #export (complement color) + (def: .public (complement color) {#.doc (doc "The opposite color.")} (-> Color Color) (let [[red green blue] (:representation color)] @@ -135,7 +135,7 @@ #green (complement' green) #blue (complement' blue)}))) - (implementation: #export subtraction + (implementation: .public subtraction (Monoid Color) (def: identity ..white) @@ -148,7 +148,7 @@ #blue (n.min lB rB)})))) ) -(def: #export (hsl color) +(def: .public (hsl color) (-> Color HSL) (let [[red green blue] (rgb color) red (..down red) @@ -202,7 +202,7 @@ ## else p)))) -(def: #export (of_hsl [hue saturation luminance]) +(def: .public (of_hsl [hue saturation luminance]) (-> HSL Color) (if (f.= +0.0 saturation) ## Achromatic @@ -220,7 +220,7 @@ #green (|> hue (hue_rgb p q)) #blue (|> hue (f.- third) (hue_rgb p q))})))) -(def: #export (hsb color) +(def: .public (hsb color) (-> Color HSB) (let [[red green blue] (rgb color) red (..down red) @@ -252,7 +252,7 @@ saturation brightness])))) -(def: #export (of_hsb [hue saturation brightness]) +(def: .public (of_hsb [hue saturation brightness]) (-> HSB Color) (let [hue (|> hue (f.* +6.0)) i (math.floor hue) @@ -269,7 +269,7 @@ #green (..up green) #blue (..up blue)}))) -(def: #export (cmyk color) +(def: .public (cmyk color) (-> Color CMYK) (let [[red green blue] (rgb color) red (..down red) @@ -287,7 +287,7 @@ #yellow yellow #key key})) -(def: #export (of_cmyk [cyan magenta yellow key]) +(def: .public (of_cmyk [cyan magenta yellow key]) (-> CMYK Color) (if (f.= +1.0 key) (of_rgb {#red 0 @@ -314,7 +314,7 @@ ## else ratio)) -(def: #export (interpolated ratio end start) +(def: .public (interpolated ratio end start) (-> Frac Color Color Color) (let [dS (..normal ratio) dE (|> +1.0 (f.- dS)) @@ -331,7 +331,7 @@ #blue (interpolated' blueE blueS)}))) (template [ ] - [(def: #export ( ratio color) + [(def: .public ( ratio color) (-> Frac Color Color) (..interpolated ratio color))] @@ -340,7 +340,7 @@ ) (template [ ] - [(def: #export ( ratio color) + [(def: .public ( ratio color) (-> Frac Color Color) (let [[hue saturation luminance] (hsl color)] (of_hsl [hue @@ -353,7 +353,7 @@ [f.- un_saturated] ) -(def: #export (gray_scale color) +(def: .public (gray_scale color) (-> Color Color) (let [[_ _ luminance] (hsl color)] (of_hsl [+0.0 @@ -366,7 +366,7 @@ (in (list (` {#.doc (.doc (~ g!documentation))}))))) (template [ <1> <2>] - [(`` (def: #export ( color) + [(`` (def: .public ( color) (~~ (..color_scheme_documentation )) (-> Color [Color Color Color]) (let [[hue saturation luminance] (hsl color)] @@ -384,7 +384,7 @@ ) (template [ <1> <2> <3>] - [(`` (def: #export ( color) + [(`` (def: .public ( color) (~~ (..color_scheme_documentation )) (-> Color [Color Color Color Color]) (let [[hue saturation luminance] (hsb color)] @@ -403,10 +403,10 @@ [tetradic (|> +2.0 (f./ +12.0)) (|> +6.0 (f./ +12.0)) (|> +8.0 (f./ +12.0))] ) -(type: #export Spread +(type: .public Spread Frac) -(type: #export Palette +(type: .public Palette (-> Spread Nat Color (List Color))) (syntax: (palette_documentation {name .local_identifier}) @@ -414,7 +414,7 @@ g!documentation (code.text (format "A " name " palette."))] (in (list (` {#.doc (.doc (~ g!documentation))}))))) -(`` (def: #export (analogous spread variations color) +(`` (def: .public (analogous spread variations color) (~~ (..palette_documentation analogous)) Palette (let [[hue saturation brightness] (hsb color) @@ -425,7 +425,7 @@ brightness])) (list.indices variations))))) -(`` (def: #export (monochromatic spread variations color) +(`` (def: .public (monochromatic spread variations color) (~~ (..palette_documentation monochromatic)) Palette (let [[hue saturation brightness] (hsb color) @@ -438,26 +438,26 @@ [hue saturation] of_hsb)))))) -(type: #export Alpha +(type: .public Alpha {#.doc (doc "The degree of transparency of a pigment.")} Rev) -(def: #export transparent +(def: .public transparent {#.doc (doc "The maximum degree of transparency.")} Alpha rev\bottom) -(def: #export translucent +(def: .public translucent {#.doc (doc "The average degree of transparency.")} Alpha .5) -(def: #export opaque +(def: .public opaque {#.doc (doc "The minimum degree of transparency.")} Alpha rev\top) -(type: #export Pigment +(type: .public Pigment {#.doc (doc "A color with some degree of transparency.")} {#color Color #alpha Alpha}) diff --git a/stdlib/source/library/lux/data/color/named.lux b/stdlib/source/library/lux/data/color/named.lux index 459ab6db8..b64c9cbcc 100644 --- a/stdlib/source/library/lux/data/color/named.lux +++ b/stdlib/source/library/lux/data/color/named.lux @@ -26,7 +26,7 @@ in)) (template [ ] - [(`` (def: #export + [(`` (def: .public {#.doc (doc (~~ (..documentation )))} Color (//.of_rgb {#//.red (hex ) diff --git a/stdlib/source/library/lux/data/format/binary.lux b/stdlib/source/library/lux/data/format/binary.lux index 918119cb2..8d8c388c5 100644 --- a/stdlib/source/library/lux/data/format/binary.lux +++ b/stdlib/source/library/lux/data/format/binary.lux @@ -32,25 +32,25 @@ (-> Size (I64 Any)) (|>> (n.* i64.bits_per_byte) i64.mask)) -(type: #export Mutation +(type: .public Mutation {#.doc (doc "A mutation of binary data, tracking where in the data to transform.")} (-> [Offset Binary] [Offset Binary])) -(type: #export Specification +(type: .public Specification {#.doc (doc "A description of how to transform binary data.")} [Size Mutation]) -(def: #export no_op +(def: .public no_op {#.doc (doc "A specification for empty binary data.")} Specification [0 function.identity]) -(def: #export (instance [size mutation]) +(def: .public (instance [size mutation]) {#.doc (doc "Given a specification of how to construct binary data, yields a binary blob that matches it.")} (-> Specification Binary) (|> size binary.create [0] mutation product.right)) -(implementation: #export monoid +(implementation: .public monoid (Monoid Specification) (def: identity @@ -60,17 +60,17 @@ [(n.+ sizeL sizeR) (|>> mutL mutR)])) -(type: #export (Writer a) +(type: .public (Writer a) {#.doc (doc "An operation that knows how to write information into a binary blob.")} (-> a Specification)) -(def: #export (run writer value) +(def: .public (run writer value) {#.doc (doc "Yields a binary blob with all the information written to it.")} (All [a] (-> (Writer a) a Binary)) (..instance (writer value))) (template [ ] - [(def: #export + [(def: .public (Writer (I64 Any)) (function (_ value) [ @@ -86,7 +86,7 @@ [bits/64 /.size/64 binary.write/64] ) -(def: #export (or left right) +(def: .public (or left right) (All [l r] (-> (Writer l) (Writer r) (Writer (Or l r)))) (function (_ altV) (case altV @@ -104,38 +104,38 @@ [1 #.Right right]) ))) -(def: #export (and pre post) +(def: .public (and pre post) (All [a b] (-> (Writer a) (Writer b) (Writer [a b]))) (function (_ [preV postV]) (\ ..monoid compose (pre preV) (post postV)))) -(def: #export (rec body) +(def: .public (rec body) {#.doc (doc "A combinator for recursive writers.")} (All [a] (-> (-> (Writer a) (Writer a)) (Writer a))) (function (recur value) (body recur value))) -(def: #export any +(def: .public any (Writer Any) (function.constant ..no_op)) -(def: #export bit +(def: .public bit (Writer Bit) (|>> (case> #0 0 #1 1) ..bits/8)) (template [ ] - [(def: #export (Writer ) ..bits/64)] + [(def: .public (Writer ) ..bits/64)] [nat Nat] [int Int] [rev Rev] ) -(def: #export frac +(def: .public frac (Writer Frac) (|>> frac.bits ..bits/64)) -(def: #export (segment size) +(def: .public (segment size) {#.doc (doc "Writes at most 'size' bytes of an input binary blob.")} (-> Nat (Writer Binary)) (function (_ value) @@ -150,7 +150,7 @@ binary))])])) (template [ ] - [(def: #export + [(def: .public (Writer Binary) (let [mask (..mask )] (function (_ value) @@ -171,7 +171,7 @@ ) (template [ ] - [(def: #export + [(def: .public (Writer Text) (|>> (\ utf8.codec encode) ))] @@ -181,10 +181,10 @@ [utf8/64 ..binary/64] ) -(def: #export text ..utf8/64) +(def: .public text ..utf8/64) (template [ ] - [(def: #export ( valueW) + [(def: .public ( valueW) (All [v] (-> (Writer v) (Writer (Row v)))) (function (_ value) (let [original_count (row.size value) @@ -213,25 +213,25 @@ [row/64 /.size/64 binary.write/64] ) -(def: #export maybe +(def: .public maybe (All [a] (-> (Writer a) (Writer (Maybe a)))) (..or ..any)) -(def: #export (list value) +(def: .public (list value) (All [a] (-> (Writer a) (Writer (List a)))) (..rec (|>> (..and value) (..or ..any)))) -(def: #export (set value) +(def: .public (set value) (All [a] (-> (Writer a) (Writer (Set a)))) (|>> set.list (..list value))) -(def: #export name +(def: .public name (Writer Name) (..and ..text ..text)) -(def: #export type +(def: .public type (Writer Type) (..rec (function (_ recur) @@ -263,11 +263,11 @@ [10 #.Named (..and ..name recur)]) )))))) -(def: #export location +(def: .public location (Writer Location) ($_ ..and ..text ..nat ..nat)) -(def: #export code +(def: .public code (Writer Code) (..rec (function (_ recur) diff --git a/stdlib/source/library/lux/data/format/css.lux b/stdlib/source/library/lux/data/format/css.lux index a3ff932e7..52a44d226 100644 --- a/stdlib/source/library/lux/data/format/css.lux +++ b/stdlib/source/library/lux/data/format/css.lux @@ -21,32 +21,34 @@ ["#." style (#+ Style)] ["#." query (#+ Query)]]) -(abstract: #export Common Any) -(abstract: #export Special Any) +(abstract: .public Common {} Any) +(abstract: .public Special {} Any) -(abstract: #export (CSS brand) +(abstract: .public (CSS brand) + {} + Text - (def: #export css + (def: .public css (-> (CSS Any) Text) (|>> :representation)) - (def: #export empty + (def: .public empty (CSS Common) (:abstraction "")) - (def: #export (rule selector style) + (def: .public (rule selector style) (-> (Selector Any) Style (CSS Common)) (:abstraction (format (/selector.selector selector) "{" (/style.inline style) "}"))) - (def: #export char_set + (def: .public char_set (-> Encoding (CSS Special)) (|>> encoding.name %.text (text.enclosed ["@charset " ";"]) :abstraction)) - (def: #export (font font) + (def: .public (font font) (-> Font (CSS Special)) (let [with_unicode (case (get@ #/font.unicode_range font) (#.Some unicode_range) @@ -69,7 +71,7 @@ (format "@font-face") :abstraction))) - (def: #export (import url query) + (def: .public (import url query) (-> URL (Maybe Query) (CSS Special)) (:abstraction (format (format "@import url(" (%.text url) ")") (case query @@ -83,11 +85,11 @@ (def: css_separator text.new_line) - (type: #export Frame + (type: .public Frame {#when Percentage #what Style}) - (def: #export (key_frames animation frames) + (def: .public (key_frames animation frames) (-> (Value Animation) (List Frame) (CSS Special)) (:abstraction (format "@keyframes " (/value.value animation) " {" (|> frames @@ -102,11 +104,11 @@ (:abstraction (format (:representation
) ..css_separator
                           (:representation ))))
   
-  (def: #export (and pre post)
+  (def: .public (and pre post)
     (-> (CSS Any) (CSS Any) (CSS Any))
     (!compose pre post))
 
-  (def: #export (alter combinator selector css)
+  (def: .public (alter combinator selector css)
     (-> Combinator (Selector Any) (CSS Common) (CSS Common))
     (|> css
         :representation
@@ -115,13 +117,13 @@
         (text.join_with ..css_separator)
         :abstraction))
 
-  (def: #export (dependent combinator selector style inner)
+  (def: .public (dependent combinator selector style inner)
     (-> Combinator (Selector Any) Style (CSS Common) (CSS Common))
     (!compose (..rule selector style)
               (..alter combinator selector inner)))
 
   (template [ ]
-    [(def: #export 
+    [(def: .public 
        (-> (Selector Any) Style (CSS Common) (CSS Common))
        (..dependent ))]
 
diff --git a/stdlib/source/library/lux/data/format/css/font.lux b/stdlib/source/library/lux/data/format/css/font.lux
index 9856d19e4..9149bf899 100644
--- a/stdlib/source/library/lux/data/format/css/font.lux
+++ b/stdlib/source/library/lux/data/format/css/font.lux
@@ -13,11 +13,11 @@
   ["." // #_
    ["#." value (#+ Value Font_Stretch Font_Style Font_Weight)]])
 
-(type: #export Unicode_Range
+(type: .public Unicode_Range
   {#start Nat
    #end Nat})
 
-(type: #export Font
+(type: .public Font
   {#family Text
    #source URL
    #stretch (Maybe (Value Font_Stretch))
diff --git a/stdlib/source/library/lux/data/format/css/property.lux b/stdlib/source/library/lux/data/format/css/property.lux
index 29f3681f9..de5197de3 100644
--- a/stdlib/source/library/lux/data/format/css/property.lux
+++ b/stdlib/source/library/lux/data/format/css/property.lux
@@ -55,16 +55,18 @@
 (syntax: (text_identifier {identifier s.text})
   (in (list (code.local_identifier (text.replace_all "-" "_" identifier)))))
 
-(abstract: #export (Property brand)
+(abstract: .public (Property brand)
+  {}
+  
   Text
 
-  (def: #export name
+  (def: .public name
     (-> (Property Any) Text)
     (|>> :representation))
 
   (template [ + +]
     [(`` (template [ ]
-           [(def: #export 
+           [(def: .public 
               (Property )
               (:abstraction ))]
 
@@ -72,7 +74,7 @@
 
      (with_expansions [ (template.spliced +)]
        (template []
-         [(`` (def: #export (~~ (text_identifier ))
+         [(`` (def: .public (~~ (text_identifier ))
                 (Property )
                 (:abstraction )))]
          
diff --git a/stdlib/source/library/lux/data/format/css/query.lux b/stdlib/source/library/lux/data/format/css/query.lux
index 115aeaf97..5366e1013 100644
--- a/stdlib/source/library/lux/data/format/css/query.lux
+++ b/stdlib/source/library/lux/data/format/css/query.lux
@@ -24,15 +24,17 @@
 (syntax: (text_identifier {identifier s.text})
   (in (list (code.local_identifier (text.replace_all "-" "_" identifier)))))
 
-(abstract: #export Media
+(abstract: .public Media
+  {}
+  
   Text
 
-  (def: #export media
+  (def: .public media
     (-> Media Text)
     (|>> :representation))
 
   (template []
-    [(`` (def: #export (~~ (text_identifier ))
+    [(`` (def: .public (~~ (text_identifier ))
            Media
            (:abstraction )))]
 
@@ -42,15 +44,17 @@
     ["speech"]
     ))
 
-(abstract: #export Feature
+(abstract: .public Feature
+  {}
+  
   Text
 
-  (def: #export feature
+  (def: .public feature
     (-> Feature Text)
     (|>> :representation))
 
   (template [ ]
-    [(`` (def: #export ((~~ (text_identifier )) input)
+    [(`` (def: .public ((~~ (text_identifier )) input)
            (-> (Value ) Feature)
            (:abstraction (format "("  ": " (//value.value input) ")"))))]
 
@@ -102,15 +106,17 @@
     )
   )
 
-(abstract: #export Query
+(abstract: .public Query
+  {}
+  
   Text
 
-  (def: #export query
+  (def: .public query
     (-> Query Text)
     (|>> :representation))
 
   (template [ ]
-    [(def: #export 
+    [(def: .public 
        (-> Media Query)
        (|>> ..media (format ) :abstraction))]
 
@@ -118,12 +124,12 @@
     [only "only "]
     )
 
-  (def: #export not
+  (def: .public not
     (-> Feature Query)
     (|>> ..feature (format "not ") :abstraction))
 
   (template [ ]
-    [(def: #export ( left right)
+    [(def: .public ( left right)
        (-> Query Query Query)
        (:abstraction (format (:representation left)
                              
diff --git a/stdlib/source/library/lux/data/format/css/selector.lux b/stdlib/source/library/lux/data/format/css/selector.lux
index 08f2165da..50bbb160d 100644
--- a/stdlib/source/library/lux/data/format/css/selector.lux
+++ b/stdlib/source/library/lux/data/format/css/selector.lux
@@ -12,44 +12,46 @@
      ["." template]]
     ["." locale (#+ Locale)]]])
 
-(type: #export Label Text)
+(type: .public Label Text)
 
-(type: #export Tag Label)
-(type: #export ID Label)
-(type: #export Class Label)
-(type: #export Attribute Label)
+(type: .public Tag Label)
+(type: .public ID Label)
+(type: .public Class Label)
+(type: .public Attribute Label)
 
-(abstract: #export (Generic brand) Any)
+(abstract: .public (Generic brand) {} Any)
 
 (template [ ]
-  [(abstract:  Any)
-   (type: #export  (Generic ))]
+  [(abstract:  {} Any)
+   (type: .public  (Generic ))]
 
   [Can_Chain Can_Chain']
   [Cannot_Chain Cannot_Chain']
   )
 
-(abstract: #export Unique Any)
-(abstract: #export Specific Any)
-(abstract: #export Composite Any)
+(abstract: .public Unique {} Any)
+(abstract: .public Specific {} Any)
+(abstract: .public Composite {} Any)
 
-(abstract: #export (Selector kind)
+(abstract: .public (Selector kind)
+  {}
+  
   Text
 
-  (def: #export selector
+  (def: .public selector
     (-> (Selector Any) Text)
     (|>> :representation))
 
-  (def: #export any
+  (def: .public any
     (Selector Cannot_Chain)
     (:abstraction "*"))
 
-  (def: #export tag
+  (def: .public tag
     (-> Tag (Selector Cannot_Chain))
     (|>> :abstraction))
 
   (template [   ]
-    [(def: #export 
+    [(def: .public 
        (->  (Selector ))
        (|>> (format ) :abstraction))]
 
@@ -59,7 +61,7 @@
 
   (template [   +]
     [(`` (template [ ]
-           [(def: #export ( right left)
+           [(def: .public ( right left)
               (-> (Selector ) (Selector ) (Selector ))
               (:abstraction (format (:representation left)
                                     
@@ -81,15 +83,15 @@
       ["~" later]]]
     )
 
-  (type: #export Combinator
+  (type: .public Combinator
     (-> (Selector Any) (Selector Any) (Selector Composite)))
 
-  (def: #export (with? attribute)
+  (def: .public (with? attribute)
     (-> Attribute (Selector Can_Chain))
     (:abstraction (format "[" attribute "]")))
 
   (template [ ]
-    [(def: #export ( attribute value)
+    [(def: .public ( attribute value)
        (-> Attribute Text (Selector Can_Chain))
        (:abstraction (format "[" attribute  value "]")))]
 
@@ -103,7 +105,7 @@
 
   (template [ +]
     [(`` (template [ ]
-           [(def: #export 
+           [(def: .public 
               (Selector Can_Chain)
               (:abstraction ))]
 
@@ -147,7 +149,7 @@
       [selection "::selection"]]]
     )
 
-  (def: #export (language locale)
+  (def: .public (language locale)
     (-> Locale (Selector Can_Chain))
     (|> locale
         locale.code
@@ -155,32 +157,34 @@
         (format ":lang")
         :abstraction))
 
-  (def: #export not
+  (def: .public not
     (-> (Selector Any) (Selector Can_Chain))
     (|>> :representation
          (text.enclosed ["(" ")"])
          (format ":not")
          :abstraction))
 
-  (abstract: #export Index
+  (abstract: .public Index
+    {}
+    
     Text
 
-    (def: #export index
+    (def: .public index
       (-> Nat Index)
       (|>> %.nat :abstraction))
 
     (template [ ]
-      [(def: #export  Index (:abstraction ))]
+      [(def: .public  Index (:abstraction ))]
       
       [odd "odd"]
       [even "even"]
       )
 
-    (type: #export Formula
+    (type: .public Formula
       {#constant Int
        #variable Int})
 
-    (def: #export (formula input)
+    (def: .public (formula input)
       (-> Formula Index)
       (let [(^slots [#constant #variable]) input]
         (:abstraction (format (if (i.< +0 variable)
@@ -189,7 +193,7 @@
                               (%.int constant)))))
     
     (template [ ]
-      [(def: #export ( index)
+      [(def: .public ( index)
          (-> Index (Selector Can_Chain))
          (|> (:representation index)
              (text.enclosed ["(" ")"])
diff --git a/stdlib/source/library/lux/data/format/css/style.lux b/stdlib/source/library/lux/data/format/css/style.lux
index 5f2c68888..a8ad45203 100644
--- a/stdlib/source/library/lux/data/format/css/style.lux
+++ b/stdlib/source/library/lux/data/format/css/style.lux
@@ -10,19 +10,19 @@
    ["#." value (#+ Value)]
    ["#." property (#+ Property)]])
 
-(abstract: #export Style
-  Text
-
+(abstract: .public Style
   {#.doc "The style associated with a CSS selector."}
 
-  (def: #export empty
+  Text
+
+  (def: .public empty
     Style
     (:abstraction ""))
 
-  (def: #export separator
+  (def: .public separator
     " ")
 
-  (def: #export (with [property value])
+  (def: .public (with [property value])
     (All [brand]
       (-> [(Property brand) (Value brand)]
           (-> Style Style)))
@@ -30,7 +30,7 @@
          (format (//property.name property) ": " (//value.value value) ";" ..separator)
          :abstraction))
 
-  (def: #export inline
+  (def: .public inline
     (-> Style Text)
     (|>> :representation))
   )
diff --git a/stdlib/source/library/lux/data/format/css/value.lux b/stdlib/source/library/lux/data/format/css/value.lux
index 6dbf1c3f4..ed2d75319 100644
--- a/stdlib/source/library/lux/data/format/css/value.lux
+++ b/stdlib/source/library/lux/data/format/css/value.lux
@@ -32,15 +32,17 @@
   (in (list (code.local_identifier (text.replace_all "-" "_" identifier)))))
 
 (template: (enumeration:    + +)
-  (abstract: #export 
+  (abstract: .public 
+    {}
+    
     
 
-    (def: #export 
+    (def: .public 
       (->  )
       (|>> :representation))
 
     (`` (template [ ]
-          [(def: #export   (:abstraction ))]
+          [(def: .public   (:abstraction ))]
 
           (~~ (template.spliced +))
           ))
@@ -48,7 +50,7 @@
     (template.spliced +)))
 
 (template: (multi:   )
-  (def: #export ( pre post)
+  (def: .public ( pre post)
     (-> (Value ) (Value ) (Value ))
     (:abstraction (format (:representation pre)
                           
@@ -61,15 +63,17 @@
       raw
       (|> raw (text.split 1) maybe.assume product.right))))
 
-(abstract: #export (Value brand)
+(abstract: .public (Value brand)
+  {}
+  
   Text
 
-  (def: #export value
+  (def: .public value
     (-> (Value Any) Text)
     (|>> :representation))
 
   (template [ ]
-    [(def: #export  Value (:abstraction ))]
+    [(def: .public  Value (:abstraction ))]
 
     [initial "initial"]
     [inherit "inherit"]
@@ -77,10 +81,10 @@
     )
   
   (template [ + +]
-    [(abstract: #export  Any)
+    [(abstract: .public  {} Any)
 
      (`` (template [ ]
-           [(def: #export 
+           [(def: .public 
               (Value )
               (:abstraction ))]
            
@@ -88,7 +92,7 @@
 
      (with_expansions [ (template.spliced +)]
        (template []
-         [(`` (def: #export (~~ (..text_identifier ))
+         [(`` (def: .public (~~ (..text_identifier ))
                 (Value )
                 (:abstraction )))]
          
@@ -793,18 +797,18 @@
      [end "end"]]
     [])
 
-  (def: #export (steps intervals step)
+  (def: .public (steps intervals step)
     (-> Nat Step (Value Timing))
     (..apply "steps" (list (%.nat intervals) (..step step))))
 
-  (def: #export (cubic_bezier p0 p1 p2 p3)
+  (def: .public (cubic_bezier p0 p1 p2 p3)
     (-> Frac Frac Frac Frac (Value Timing))
     (|> (list p0 p1 p2 p3)
         (list\map %number)
         (..apply "cubic-bezier")))
 
   (template [ ]
-    [(def: #export 
+    [(def: .public 
        (-> Nat (Value ))
        (|>> %.nat :abstraction))]
 
@@ -814,18 +818,18 @@
     [span_line Grid_Span]
     )
 
-  (def: #export animation
+  (def: .public animation
     (-> Label (Value Animation))
     (|>> :abstraction))
 
-  (def: #export (rgb color)
+  (def: .public (rgb color)
     (-> color.Color (Value Color))
     (let [[red green blue] (color.rgb color)]
       (..apply "rgb" (list (%.nat red)
                            (%.nat green)
                            (%.nat blue)))))
 
-  (def: #export (rgba pigment)
+  (def: .public (rgba pigment)
     (-> color.Pigment (Value Color))
     (let [(^slots [#color.color #color.alpha]) pigment
           [red green blue] (color.rgb color)]
@@ -837,7 +841,7 @@
                               (format "0" (%.rev alpha)))))))
 
   (template [ ]
-    [(def: #export ( value)
+    [(def: .public ( value)
        (-> Frac (Value Length))
        (:abstraction (format (%number value) )))]
 
@@ -866,7 +870,7 @@
       (%.nat (.nat value))))
 
   (template [ ]
-    [(def: #export ( value)
+    [(def: .public ( value)
        (-> Int (Value Time))
        (:abstraction (format (if (i.< +0 value)
                                (%.int value)
@@ -878,41 +882,45 @@
     [milli_seconds "ms"]
     )
 
-  (def: #export thickness
+  (def: .public thickness
     (-> (Value Length) (Value Thickness))
     (|>> :transmutation))
 
   (def: slice_separator " ")
 
-  (def: #export (slice_number/2 horizontal vertical)
+  (def: .public (slice_number/2 horizontal vertical)
     (-> Nat Nat (Value Slice))
     (:abstraction (format (%.nat horizontal) ..slice_separator
                           (%.nat vertical))))
 
-  (abstract: #export Stop
+  (abstract: .public Stop
+    {}
+    
     Text
 
-    (def: #export stop
+    (def: .public stop
       (-> (Value Color) Stop)
       (|>> (:representation Value) (:abstraction Stop)))
 
     (def: stop_separator " ")
 
-    (def: #export (single_stop length color)
+    (def: .public (single_stop length color)
       (-> (Value Length) (Value Color) Stop)
       (:abstraction (format (:representation Value color) ..stop_separator
                             (:representation Value length))))
 
-    (def: #export (double_stop start end color)
+    (def: .public (double_stop start end color)
       (-> (Value Length) (Value Length) (Value Color) Stop)
       (:abstraction (format (:representation Value color) ..stop_separator
                             (:representation Value start) ..stop_separator
                             (:representation Value end))))
 
-    (abstract: #export Hint
+    (abstract: .public Hint
+      {}
+      
       Text
 
-      (def: #export hint
+      (def: .public hint
         (-> (Value Length) Hint)
         (|>> (:representation Value) (:abstraction Hint)))
 
@@ -925,28 +933,30 @@
           (#.Some hint)
           (format (:representation Hint hint) ..value_separator (:representation Stop stop))))))
 
-  (type: #export (List/1 a)
+  (type: .public (List/1 a)
     [a (List a)])
 
-  (abstract: #export Angle
+  (abstract: .public Angle
+    {}
+    
     Text
 
-    (def: #export angle
+    (def: .public angle
       (-> Angle Text)
       (|>> :representation))
 
-    (def: #export (turn value)
+    (def: .public (turn value)
       (-> Rev Angle)
       (:abstraction (format (%.rev value) "turn")))
 
     (def: degree_limit Nat 360)
     
-    (def: #export (degree value)
+    (def: .public (degree value)
       (-> Nat Angle)
       (:abstraction (format (%.nat (n.% ..degree_limit value)) "deg")))
 
     (template [ ]
-      [(def: #export 
+      [(def: .public 
          Angle
          (..degree ))]
       
@@ -957,7 +967,7 @@
       )
 
     (template [ ]
-      [(def: #export ( angle start next)
+      [(def: .public ( angle start next)
          (-> Angle Stop (List/1 [(Maybe Hint) Stop]) (Value Image))
          (let [[now after] next]
            (..apply  (list& (:representation Angle angle)
@@ -969,31 +979,33 @@
       )
     )
 
-  (abstract: #export Percentage
+  (abstract: .public Percentage
+    {}
+    
     Text
 
-    (def: #export percentage
+    (def: .public percentage
       (-> Percentage Text)
       (|>> :representation))
 
     (def: percentage_limit Nat (.inc 100))
 
-    (def: #export (%% value)
+    (def: .public (%% value)
       (-> Nat Percentage)
       (:abstraction (format (%.nat (n.% percentage_limit value)) "%")))
 
-    (def: #export slice_percent/1
+    (def: .public slice_percent/1
       (-> Percentage (Value Slice))
       (|>> :representation (:abstraction Value)))
 
-    (def: #export (slice_percent/2 horizontal vertical)
+    (def: .public (slice_percent/2 horizontal vertical)
       (-> Percentage Percentage (Value Slice))
       (:abstraction Value (format (:representation horizontal) ..slice_separator
                                   (:representation vertical))))
 
     (template [ 
 +]
       [(`` (template [ ]
-             [(def: #export 
+             [(def: .public 
                 (->  (Value Filter))
                 (|>> 
 (list) (..apply )))]
 
@@ -1014,13 +1026,13 @@
       )
     )
 
-  (def: #export svg_filter
+  (def: .public svg_filter
     (-> URL (Value Filter))
     (|>> (list) (..apply "url")))
 
   (def: default_shadow_length (px +0.0))
 
-  (def: #export (drop_shadow horizontal vertical blur spread color)
+  (def: .public (drop_shadow horizontal vertical blur spread color)
     (-> (Value Length) (Value Length)
         (Maybe (Value Length)) (Maybe (Value Length))
         (Value Color)
@@ -1037,7 +1049,7 @@
   (def: length_separator " ")
 
   (template [ ]
-    [(def: #export ( horizontal vertical)
+    [(def: .public ( horizontal vertical)
        (-> (Value Length) (Value Length) (Value ))
        (:abstraction (format (:representation horizontal)
                              ..length_separator
@@ -1047,11 +1059,11 @@
     [fit Fit]
     )
 
-  (def: #export (fit/1 length)
+  (def: .public (fit/1 length)
     (-> (Value Length) (Value Fit))
     (..fit length length))
 
-  (def: #export image
+  (def: .public image
     (-> URL (Value Image))
     (|>> %.text
          (list)
@@ -1072,7 +1084,7 @@
     [])
 
   (template [ ]
-    [(def: #export ( shape extent location start next)
+    [(def: .public ( shape extent location start next)
        (-> Shape (Maybe Extent) (Value Location)
            Stop (List/1 [(Maybe Hint) Stop])
            (Value Image))
@@ -1093,7 +1105,7 @@
     [repeating_radial_gradient "repeating-radial-gradient"]
     )
 
-  (def: #export (shadow horizontal vertical blur spread color inset?)
+  (def: .public (shadow horizontal vertical blur spread color inset?)
     (-> (Value Length) (Value Length)
         (Maybe (Value Length)) (Maybe (Value Length))
         (Value Color) Bit
@@ -1110,36 +1122,36 @@
           (text.join_with " ")
           :abstraction)))
 
-  (type: #export Rectangle
+  (type: .public Rectangle
     {#top (Value Length)
      #right (Value Length)
      #bottom (Value Length)
      #left (Value Length)})
 
-  (def: #export (clip rectangle)
+  (def: .public (clip rectangle)
     (-> Rectangle (Value Clip))
     (`` (..apply "rect" (list (~~ (template []
                                     [(:representation (get@  rectangle))]
 
                                     [#top] [#right] [#bottom] [#left]))))))
 
-  (def: #export counter
+  (def: .public counter
     (-> Label (Value Counter))
     (|>> :abstraction))
 
-  (def: #export current_count
+  (def: .public current_count
     (-> (Value Counter) (Value Content))
     (|>> :representation (list) (..apply "counter")))
 
-  (def: #export text
+  (def: .public text
     (-> Text (Value Content))
     (|>> %.text :abstraction))
 
-  (def: #export attribute
+  (def: .public attribute
     (-> Label (Value Content))
     (|>> (list) (..apply "attr")))
 
-  (def: #export media
+  (def: .public media
     (-> URL (Value Content))
     (|>> (list) (..apply "url")))
 
@@ -1150,11 +1162,11 @@
      [cursive "cursive"]
      [fantasy "fantasy"]
      [monospace "monospace"]]
-    [(def: #export font
+    [(def: .public font
        (-> Text Font)
        (|>> %.text :abstraction))
 
-     (def: #export (font_family options)
+     (def: .public (font_family options)
        (-> (List Font) (Value Font))
        (case options
          (#.Item _)
@@ -1166,35 +1178,35 @@
          #.End
          ..initial))])
 
-  (def: #export font_size
+  (def: .public font_size
     (-> (Value Length) (Value Font_Size))
     (|>> :transmutation))
 
-  (def: #export number
+  (def: .public number
     (-> Frac (Value Number))
     (|>> %number :abstraction))
 
-  (def: #export grid
+  (def: .public grid
     (-> Label (Value Grid))
     (|>> :abstraction))
 
-  (def: #export fit_content
+  (def: .public fit_content
     (-> (Value Length) (Value Grid_Content))
     (|>> :representation (list) (..apply "fit-content")))
 
-  (def: #export (min_max min max)
+  (def: .public (min_max min max)
     (-> (Value Grid_Content) (Value Grid_Content) (Value Grid_Content))
     (..apply "minmax" (list (:representation min)
                             (:representation max))))
 
-  (def: #export grid_span
+  (def: .public grid_span
     (-> Nat (Value Grid_Span))
     (|>> %.nat (format "span ") :abstraction))
 
   (def: grid_column_separator " ")
   (def: grid_row_separator " ")
 
-  (def: #export grid_template
+  (def: .public grid_template
     (-> (List (List (Maybe (Value Grid)))) (Value Grid_Template))
     (let [empty (: (Value Grid)
                    (:abstraction "."))]
@@ -1205,11 +1217,11 @@
            (text.join_with ..grid_row_separator)
            :abstraction)))
 
-  (def: #export (resolution dpi)
+  (def: .public (resolution dpi)
     (-> Nat (Value Resolution))
     (:abstraction (format (%.nat dpi) "dpi")))
 
-  (def: #export (ratio numerator denominator)
+  (def: .public (ratio numerator denominator)
     (-> Nat Nat (Value Ratio))
     (:abstraction (format (%.nat numerator) "/" (%.nat denominator))))
 
@@ -1226,20 +1238,20 @@
      [double_left_quote "\201C"]
      [double_right_quote "\201D"]
      [low_double_quote "\201E"]]
-    [(def: #export quote
+    [(def: .public quote
        (-> Text Quote)
        (|>> :abstraction))])
 
   (def: quote_separator " ")
 
-  (def: #export (quotes [left0 right0] [left1 right1])
+  (def: .public (quotes [left0 right0] [left1 right1])
     (-> [Quote Quote] [Quote Quote] (Value Quotes))
     (|> (list left0 right0 left1 right1)
         (list\map (|>> ..quote_text %.text))
         (text.join_with ..quote_separator)
         :abstraction))
 
-  (def: #export (matrix_2d [a b] [c d] [tx ty])
+  (def: .public (matrix_2d [a b] [c d] [tx ty])
     (-> [Frac Frac]
         [Frac Frac]
         [Frac Frac]
@@ -1248,7 +1260,7 @@
         (list\map %number)
         (..apply "matrix")))
 
-  (def: #export (matrix_3d [a0 b0 c0 d0] [a1 b1 c1 d1] [a2 b2 c2 d2] [a3 b3 c3 d3])
+  (def: .public (matrix_3d [a0 b0 c0 d0] [a1 b1 c1 d1] [a2 b2 c2 d2] [a3 b3 c3 d3])
     (-> [Frac Frac Frac Frac]
         [Frac Frac Frac Frac]
         [Frac Frac Frac Frac]
@@ -1259,7 +1271,7 @@
         (..apply "matrix3d")))
 
   (template [   ]
-    [(`` (def: #export ( [(~~ (template.spliced ))])
+    [(`` (def: .public ( [(~~ (template.spliced ))])
            (-> [(~~ (template.spliced ))] (Value Transform))
            (|> (list (~~ (template.spliced )))
                (list\map %number)
@@ -1281,7 +1293,7 @@
     )
 
   (template [   ]
-    [(`` (def: #export ( [(~~ (template.spliced ))])
+    [(`` (def: .public ( [(~~ (template.spliced ))])
            (-> [(~~ (template.spliced ))] (Value Transform))
            (|> (list (~~ (template.spliced )))
                (list\map ..angle)
@@ -1297,29 +1309,29 @@
     [skew_y "skewY" [Angle] [angle]]
     )
 
-  (def: #export (rotate_3d [x y z angle])
+  (def: .public (rotate_3d [x y z angle])
     (-> [Frac Frac Frac Angle] (Value Transform))
     (..apply "rotate3d"
              (list (%number x) (%number y) (%number z) (..angle angle))))
 
   (def: origin_separator " ")
 
-  (def: #export (origin_2d x y)
+  (def: .public (origin_2d x y)
     (-> (Value Length) (Value Length) (Value Transform_Origin))
     (:abstraction (format (:representation x) ..origin_separator
                           (:representation y))))
 
-  (def: #export (origin_3d x y z)
+  (def: .public (origin_3d x y z)
     (-> (Value Length) (Value Length) (Value Length) (Value Transform_Origin))
     (:abstraction (format (:representation x) ..origin_separator
                           (:representation y) ..origin_separator
                           (:representation z))))
 
-  (def: #export vertical_align
+  (def: .public vertical_align
     (-> (Value Length) (Value Vertical_Align))
     (|>> :transmutation))
 
-  (def: #export (z_index index)
+  (def: .public (z_index index)
     (-> Int (Value Z_Index))
     (:abstraction (if (i.< +0 index)
                     (%.int index)
diff --git a/stdlib/source/library/lux/data/format/html.lux b/stdlib/source/library/lux/data/format/html.lux
index 6bbef9f5b..33500a7ac 100644
--- a/stdlib/source/library/lux/data/format/html.lux
+++ b/stdlib/source/library/lux/data/format/html.lux
@@ -23,17 +23,17 @@
     ["." style (#+ Style)]]
    ["." xml (#+ XML)]])
 
-(type: #export Tag selector.Tag)
-(type: #export ID selector.ID)
-(type: #export Class selector.Class)
+(type: .public Tag selector.Tag)
+(type: .public ID selector.ID)
+(type: .public Class selector.Class)
 
-(type: #export Attributes
+(type: .public Attributes
   {#.doc "Attributes for an HTML tag."}
   (List [Text Text]))
 
-(type: #export Script js.Statement)
+(type: .public Script js.Statement)
 
-(type: #export Target
+(type: .public Target
   #Blank
   #Parent
   #Self
@@ -76,12 +76,14 @@
   (-> Tag Text)
   (text.enclosed [""]))
 
-(abstract: #export (HTML brand)
+(abstract: .public (HTML brand)
+  {}
+  
   Text
 
   (template [ ]
-    [(abstract: #export  Any)
-     (type: #export  (HTML ))]
+    [(abstract: .public  {} Any)
+     (type: .public  (HTML ))]
 
     [Meta Meta']
     [Head Head']
@@ -98,12 +100,12 @@
     )
 
   (template [  +]
-    [(abstract: #export ( brand) Any)
-     (type: #export  (HTML ( Any)))
+    [(abstract: .public ( brand) {} Any)
+     (type: .public  (HTML ( Any)))
 
      (`` (template [ ]
-           [(abstract: #export  Any)
-            (type: #export  (HTML ( )))]
+           [(abstract: .public  {} Any)
+            (type: .public  (HTML ( )))]
 
            (~~ (template.spliced +))))]
 
@@ -116,15 +118,15 @@
       [Track Track']]]
     )
 
-  (def: #export html
+  (def: .public html
     (-> Document Text)
     (|>> :representation))
 
-  (def: #export (and pre post)
+  (def: .public (and pre post)
     (All [brand] (-> (HTML brand) (HTML brand) (HTML brand)))
     (:abstraction (format (:representation pre) (:representation post))))
 
-  (def: #export (comment content node)
+  (def: .public (comment content node)
     (All [brand] (-> Text (HTML brand) (HTML brand)))
     (:abstraction
      (format (text.enclosed [""] content)
@@ -157,7 +159,7 @@
              (..close tag))))
 
   (template [  ]
-    [(def: #export 
+    [(def: .public 
        (-> Attributes )
        (..simple ))]
 
@@ -169,7 +171,7 @@
     [parameter "param" Parameter]
     )
 
-  (def: #export (base href target)
+  (def: .public (base href target)
     (-> URL (Maybe Target) Meta)
     (let [partial (list ["href" href])
           full (case target
@@ -180,46 +182,46 @@
                  partial)]
       (..simple "base" full)))
 
-  (def: #export style
+  (def: .public style
     (-> Style Meta)
     (|>> style.inline (..raw "style" (list))))
 
-  (def: #export (script attributes inline)
+  (def: .public (script attributes inline)
     (-> Attributes (Maybe Script) Meta)
     (|> inline
         (maybe\map js.code)
         (maybe.else "")
         (..raw "script" attributes)))
 
-  (def: #export text
+  (def: .public text
     (-> Text Content)
     (|>> ..safe
          :abstraction))
 
   (template [  ]
-    [(def: #export 
+    [(def: .public 
        Element
        (..simple  (list)))
 
-     (def: #export  )]
+     (def: .public  )]
     ["br"  br  line_break]
     ["wbr" wbr word_break]
     ["hr"  hr  separator]
     )
 
-  (def: #export (image source attributes)
+  (def: .public (image source attributes)
     (-> URL Attributes Image)
     (|> attributes
         (#.Item ["src" source])
         (..simple "img")))
 
-  (def: #export (svg attributes content)
+  (def: .public (svg attributes content)
     (-> Attributes XML Element)
     (|> content
         (\ xml.codec encode)
         (..raw "svg" attributes)))
 
-  (type: #export Coord
+  (type: .public Coord
     {#horizontal Nat
      #vertical Nat})
 
@@ -230,15 +232,15 @@
     (Format Coord)
     (format (%.nat horizontal) ..metric_separator (%.nat vertical)))
   
-  (type: #export Rectangle
+  (type: .public Rectangle
     {#start Coord
      #end Coord})
 
-  (type: #export Circle
+  (type: .public Circle
     {#center Coord
      #radius Nat})
 
-  (type: #export Polygon
+  (type: .public Polygon
     {#first Coord
      #second Coord
      #third Coord
@@ -258,7 +260,7 @@
         (list\map %coord)
         (text.join_with ..coord_separator)))
   
-  (type: #export Shape
+  (type: .public Shape
     (#Rectangle Rectangle)
     (#Circle Circle)
     (#Polygon Polygon))
@@ -287,7 +289,7 @@
       (#Polygon polygon)
       (..polygon attributes polygon)))
 
-  (def: #export (map attributes areas for)
+  (def: .public (map attributes areas for)
     (-> Attributes (List [Attributes Shape]) Image Image)
     ($_ ..and
         for
@@ -300,7 +302,7 @@
                  (list\fold (function.flip ..and) head tail)))))
 
   (template [  ]
-    [(def: #export 
+    [(def: .public 
        (-> Attributes )
        (..empty ))]
 
@@ -312,7 +314,7 @@
     )
 
   (template [ ]
-    [(def: #export ( attributes media on_unsupported)
+    [(def: .public ( attributes media on_unsupported)
        (-> Attributes Media (Maybe Content) Element)
        (..tag  attributes
               (|> on_unsupported
@@ -323,20 +325,20 @@
     [video "video"]
     )
 
-  (def: #export (picture attributes sources image)
+  (def: .public (picture attributes sources image)
     (-> Attributes Source Image Element)
     (..tag "picture" attributes (..and sources image)))
 
-  (def: #export (anchor href attributes content)
+  (def: .public (anchor href attributes content)
     (-> URL Attributes Element Element)
     (..tag "a" (list& ["href" href] attributes) content))
 
-  (def: #export label
+  (def: .public label
     (-> ID Input)
     (|>> ["for"] list (..empty "label")))
 
   (template [   ]
-    [(def: #export ( description attributes content)
+    [(def: .public ( description attributes content)
        (-> (Maybe Content) Attributes  )
        (..tag  attributes
               (case description
@@ -354,7 +356,7 @@
     )
 
   (template [  ]
-    [(def: #export ( attributes content)
+    [(def: .public ( attributes content)
        (-> Attributes (Maybe Content) )
        (|> content
            (maybe.else (..text ""))
@@ -364,10 +366,10 @@
     [iframe "iframe" Element]
     )
 
-  (type: #export Phrase (-> Attributes Content Element))
+  (type: .public Phrase (-> Attributes Content Element))
 
   (template [ ]
-    [(def: #export 
+    [(def: .public 
        Phrase
        (..tag ))]
 
@@ -403,7 +405,7 @@
     [variable "var"]
     )
 
-  (def: #export incorrect ..struck)
+  (def: .public incorrect ..struck)
 
   (def: (ruby_pronunciation pronunciation)
     (-> Content (HTML Any))
@@ -413,18 +415,18 @@
                pronunciation
                (..tag "rp" (list) (..text ")")))))
 
-  (def: #export (ruby attributes content pronunciation)
+  (def: .public (ruby attributes content pronunciation)
     (-> Attributes Content Content Element)
     (..tag "ruby" attributes
            ($_ ..and
                content
                (ruby_pronunciation pronunciation))))
 
-  (type: #export Composite
+  (type: .public Composite
     (-> Attributes Element Element))
 
   (template [ ]
-    [(def: #export 
+    [(def: .public 
        Composite
        (..tag ))]
 
@@ -450,7 +452,7 @@
     ["dd" description Element]
     )
 
-  (def: #export (description_list attributes descriptions)
+  (def: .public (description_list attributes descriptions)
     (-> Attributes (List [Content Element]) Element)
     (case (list\map (function (_ [term description])
                       ($_ ..and
@@ -464,10 +466,10 @@
       (..tag "dl" attributes
              (list\fold (function.flip ..and) head tail))))
 
-  (def: #export p ..paragraph)
+  (def: .public p ..paragraph)
 
   (template [   ]
-    [(def: #export 
+    [(def: .public 
        (-> Attributes  )
        (..tag ))]
 
@@ -486,7 +488,7 @@
     )
 
   (template [   ]
-    [(def: #export 
+    [(def: .public 
        (->  )
        (..tag  (list)))]
 
@@ -511,7 +513,7 @@
     [columns_group "colgroup" Column HTML]
     )
 
-  (def: #export (table attributes caption columns headers rows footer)
+  (def: .public (table attributes caption columns headers rows footer)
     (-> Attributes (Maybe Content) (Maybe Column) Header (List Cell) (Maybe Cell) Element)
     (let [head (..table_head (..table_row headers))
           content (case (list\map table_row rows)
@@ -547,7 +549,7 @@
              content)))
 
   (template [ ]
-    [(def: #export 
+    [(def: .public 
        (-> Head Body Document)
        (let [doc_type ]
          (function (_ head body)
diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux
index 60bcfd107..3f7789e70 100644
--- a/stdlib/source/library/lux/data/format/json.lux
+++ b/stdlib/source/library/lux/data/format/json.lux
@@ -32,7 +32,7 @@
       ["f" frac ("#\." decimal)]]]]])
 
 (template [ ]
-  [(type: #export 
+  [(type: .public 
      )]
 
   [Null    Any]
@@ -41,7 +41,7 @@
   [String  Text]
   )
 
-(type: #export #rec JSON
+(type: .public #rec JSON
   (#Null    Null)
   (#Boolean Boolean)
   (#Number  Number)
@@ -50,23 +50,23 @@
   (#Object  (Dictionary String JSON)))
 
 (template [ ]
-  [(type: #export 
+  [(type: .public 
      )]
 
   [Array  (Row JSON)]
   [Object (Dictionary String JSON)]
   )
 
-(def: #export null?
+(def: .public null?
   (Predicate JSON)
   (|>> (case> #Null true
               _ false)))
 
-(def: #export object
+(def: .public object
   (-> (List [String JSON]) JSON)
   (|>> (dictionary.of_list text.hash) #..Object))
 
-(syntax: #export (json token)
+(syntax: .public (json token)
   {#.doc (doc "A simple way to produce JSON literals."
               (json #null)
               (json #1)
@@ -109,7 +109,7 @@
       _
       (in (list token)))))
 
-(def: #export (fields json)
+(def: .public (fields json)
   {#.doc "Get all the fields in a JSON object."}
   (-> JSON (Try (List String)))
   (case json
@@ -119,7 +119,7 @@
     _
     (#try.Failure ($_ text\compose "Cannot get the fields of a non-object."))))
 
-(def: #export (get key json)
+(def: .public (get key json)
   {#.doc "A JSON object field getter."}
   (-> String JSON (Try JSON))
   (case json
@@ -134,7 +134,7 @@
     _
     (#try.Failure ($_ text\compose "Cannot get field '" key "' on a non-object."))))
 
-(def: #export (set key value json)
+(def: .public (set key value json)
   {#.doc "A JSON object field setter."}
   (-> String JSON JSON (Try JSON))
   (case json
@@ -145,7 +145,7 @@
     (#try.Failure ($_ text\compose "Cannot set field '" key "' on a non-object."))))
 
 (template [   ]
-  [(def: #export ( key json)
+  [(def: .public ( key json)
      {#.doc (code.text ($_ text\compose "A JSON object field getter for "  "."))}
      (-> Text JSON (Try ))
      (case (get key json)
@@ -165,7 +165,7 @@
   [get_object  #Object  Object  "objects"]
   )
 
-(implementation: #export equivalence
+(implementation: .public equivalence
   (Equivalence JSON)
   
   (def: (= x y)
@@ -273,7 +273,7 @@
        (text.join_with ..value_separator)
        (text.enclosed [..object_start ..object_end])))
 
-(def: #export (format json)
+(def: .public (format json)
   (-> JSON Text)
   (case json
     (^template [ ]
@@ -416,7 +416,7 @@
          (array_parser json_parser)
          (object_parser json_parser)))))
 
-(implementation: #export codec
+(implementation: .public codec
   (Codec Text JSON)
   
   (def: encode ..format)
diff --git a/stdlib/source/library/lux/data/format/markdown.lux b/stdlib/source/library/lux/data/format/markdown.lux
index 2fbef2fa0..5fe9a9a9d 100644
--- a/stdlib/source/library/lux/data/format/markdown.lux
+++ b/stdlib/source/library/lux/data/format/markdown.lux
@@ -31,17 +31,19 @@
        (text.replace_all "." "\.")
        (text.replace_all "!" "\!")))
 
-(abstract: #export Span Any)
-(abstract: #export Block Any)
+(abstract: .public Span {} Any)
+(abstract: .public Block {} Any)
 
-(abstract: #export (Markdown brand)
+(abstract: .public (Markdown brand)
+  {}
+  
   Text
 
-  (def: #export empty
+  (def: .public empty
     Markdown
     (:abstraction ""))
 
-  (def: #export text
+  (def: .public text
     (-> Text (Markdown Span))
     (|>> ..safe :abstraction))
 
@@ -49,7 +51,7 @@
     (format text.new_line text.new_line))
 
   (template [ ]
-    [(def: #export ( content)
+    [(def: .public ( content)
        (-> Text Markdown)
        (:abstraction (format  " " (..safe content) ..blank_line)))]
 
@@ -65,16 +67,16 @@
     (-> Text (Markdown Block))
     (:abstraction (format content ..blank_line)))
 
-  (def: #export paragraph
+  (def: .public paragraph
     (-> (Markdown Span) (Markdown Block))
     (|>> :representation ..block))
 
-  (def: #export break
+  (def: .public break
     (Markdown Span)
     (:abstraction (format "  " text.new_line)))
 
   (template [ ]
-    [(def: #export 
+    [(def: .public 
        (-> (Markdown Span) (Markdown Span))
        (|>> :representation
             (text.enclosed [ ])
@@ -97,13 +99,13 @@
     (-> Text Text)
     (..prefix text.tab))
 
-  (def: #export quote
+  (def: .public quote
     (-> (Markdown Block) (Markdown Block))
     (|>> :representation
          (..prefix "> ")
          :abstraction))
 
-  (def: #export numbered_list
+  (def: .public numbered_list
     (-> (List [(Markdown Span) (Maybe (Markdown Block))])
         (Markdown Block))
     (|>> list.enumeration
@@ -118,7 +120,7 @@
          (text.join_with text.new_line)
          ..block))
 
-  (def: #export bullet_list
+  (def: .public bullet_list
     (-> (List [(Markdown Span) (Maybe (Markdown Block))])
         (Markdown Block))
     (|>> (list\map (function (_ [summary detail])
@@ -132,35 +134,35 @@
          (text.join_with text.new_line)
          ..block))
 
-  (def: #export snippet
+  (def: .public snippet
     {#.doc "A snippet of code."}
     (-> Text (Markdown Span))
     (|>> ..safe (text.enclosed ["`" "`"]) :abstraction))
 
-  (def: #export code
+  (def: .public code
     {#.doc "A block of code."}
     (-> Text (Markdown Block))
     (let [open (format "```" text.new_line)
           close (format text.new_line "```")]
       (|>> (text.enclosed [open close]) ..block)))
 
-  (def: #export (image description url)
+  (def: .public (image description url)
     (-> Text URL (Markdown Span))
     (:abstraction (format "![" (..safe description) "](" url ")")))
 
-  (def: #export horizontal_rule
+  (def: .public horizontal_rule
     (Markdown Block)
     (..block "___"))
 
-  (def: #export (link description url)
+  (def: .public (link description url)
     (-> (Markdown Span) URL (Markdown Span))
     (:abstraction (format "[" (:representation description) "](" url ")")))
 
-  (type: #export Email
+  (type: .public Email
     Text)
 
   (template [ ]
-    [(def: #export 
+    [(def: .public 
        (->  (Markdown Span))
        (|>> (text.enclosed ["<" ">"]) :abstraction))]
 
@@ -169,7 +171,7 @@
     )
 
   (template [  ]
-    [(def: #export ( pre post)
+    [(def: .public ( pre post)
        (-> (Markdown ) (Markdown ) (Markdown ))
        (:abstraction (format (:representation pre)  (:representation post))))]
 
@@ -177,7 +179,7 @@
     [then Block ""]
     )
 
-  (def: #export markdown
+  (def: .public markdown
     (-> (Markdown Any) Text)
     (|>> :representation))
   )
diff --git a/stdlib/source/library/lux/data/format/tar.lux b/stdlib/source/library/lux/data/format/tar.lux
index 1f1451790..e60c13e05 100644
--- a/stdlib/source/library/lux/data/format/tar.lux
+++ b/stdlib/source/library/lux/data/format/tar.lux
@@ -56,28 +56,30 @@
 (template [  
                
            ]
-  [(def: #export 
+  [(def: .public 
      Nat
      (|> ..octal_size
          (list.repeat )
          (list\fold n.* 1)
          inc))
 
-   (exception: #export ( {value Nat})
+   (exception: .public ( {value Nat})
      (exception.report
       ["Value" (%.nat value)]
       ["Maximum" (%.nat (dec ))]))
 
-   (abstract: #export 
+   (abstract: .public 
+     {}
+     
      Nat
 
-     (def: #export ( value)
+     (def: .public ( value)
        (-> Nat (Try ))
        (if (n.<  value)
          (#try.Success (:abstraction value))
          (exception.except  [value])))
 
-     (def: #export 
+     (def: .public 
        (->  Nat)
        (|>> :representation))
 
@@ -108,7 +110,7 @@
    as_big]
   )
 
-(exception: #export (wrong_character {expected Char} {actual Char})
+(exception: .public (wrong_character {expected Char} {actual Char})
   (exception.report
    ["Expected" (%.nat expected)]
    ["Actual" (%.nat actual)]))
@@ -152,6 +154,8 @@
        (..big value)))))
 
 (abstract: Checksum
+  {}
+  
   Text
 
   (def: from_checksum
@@ -217,12 +221,12 @@
                             (n.<= ..last_ascii char)))
                     true)))
 
-(exception: #export (not_ascii {text Text})
+(exception: .public (not_ascii {text Text})
   (exception.report
    ["Text" (%.text text)]))
 
-(def: #export name_size Size 31)
-(def: #export path_size Size 99)
+(def: .public name_size Size 31)
+(def: .public path_size Size 99)
 
 (def: (un_padded string)
   (-> Binary (Try Binary))
@@ -241,16 +245,18 @@
                        (binary.slice 0 (inc end) string))))))))
 
 (template [        ]
-  [(abstract: #export 
+  [(abstract: .public 
+     {}
+     
      
 
-     (exception: #export ( {value Text})
+     (exception: .public ( {value Text})
        (exception.report
         ["Value" (%.text value)]
         ["Size" (%.nat (text.size value))]
         ["Maximum" (%.nat )]))
 
-     (def: #export ( value)
+     (def: .public ( value)
        (->  (Try ))
        (if (..ascii? value)
          (if (|> value (\ utf8.codec encode) binary.size (n.<= ))
@@ -258,7 +264,7 @@
            (exception.except  [value]))
          (exception.except ..not_ascii [value])))
 
-     (def: #export 
+     (def: .public 
        (->  )
        (|>> :representation))
 
@@ -285,7 +291,7 @@
              text (\ utf8.codec decode ascii)]
             ( text)))))
 
-     (def: #export 
+     (def: .public 
        
        (try.assumed ( "")))
      )]
@@ -297,6 +303,8 @@
 (def: magic_size Size 7)
 
 (abstract: Magic
+  {}
+  
   Text
 
   (def: ustar (:abstraction "ustar  "))
@@ -383,6 +391,8 @@
       (..small_number ..device_size)))
 
 (abstract: Link_Flag
+  {}
+  
   Char
 
   (def: link_flag
@@ -411,7 +421,7 @@
       
       )
 
-    (exception: #export (invalid_link_flag {value Nat})
+    (exception: .public (invalid_link_flag {value Nat})
       (exception.report
        ["Value" (%.nat value)]))
 
@@ -430,14 +440,16 @@
            (exception.except ..invalid_link_flag [(.nat linkflag)]))))))
   )
 
-(abstract: #export Mode
+(abstract: .public Mode
+  {}
+  
   Nat
 
-  (def: #export mode
+  (def: .public mode
     (-> Mode Nat)
     (|>> :representation))
 
-  (def: #export (and left right)
+  (def: .public (and left right)
     (-> Mode Mode Mode)
     (:abstraction
      (i64.or (:representation left)
@@ -450,7 +462,7 @@
          try.assumed
          ..small_writer))
 
-  (exception: #export (invalid_mode {value Nat})
+  (exception: .public (invalid_mode {value Nat})
     (exception.report
      ["Value" (%.nat value)]))
 
@@ -472,7 +484,7 @@
                                      ["2000" set_group_id_on_execution]
                                      ["4000" set_user_id_on_execution])]
     (template [ ]
-      [(def: #export 
+      [(def: .public 
          Mode
          (:abstraction (number.oct )))]
 
@@ -518,10 +530,12 @@
       (list.repeat ..content_size)
       (list\fold n.* 1)))
 
-(abstract: #export Content
+(abstract: .public Content
+  {}
+  
   [Big Binary]
 
-  (def: #export (content content)
+  (def: .public (content content)
     (-> Binary (Try Content))
     (do try.monad
       [size (..big (binary.size content))]
@@ -531,35 +545,35 @@
     (-> Content [Big Binary])
     (|>> :representation))
 
-  (def: #export data
+  (def: .public data
     (-> Content Binary)
     (|>> :representation product.right))
   )
 
-(type: #export ID
+(type: .public ID
   Small)
 
-(def: #export no_id
+(def: .public no_id
   ID
   (..as_small 0))
 
-(type: #export Owner
+(type: .public Owner
   {#name Name
    #id ID})
 
-(type: #export Ownership
+(type: .public Ownership
   {#user Owner
    #group Owner})
 
-(type: #export File
+(type: .public File
   [Path Instant Mode Ownership Content])
 
-(type: #export Normal File)
-(type: #export Symbolic_Link Path)
-(type: #export Directory Path)
-(type: #export Contiguous File)
+(type: .public Normal File)
+(type: .public Symbolic_Link Path)
+(type: .public Directory Path)
+(type: .public Contiguous File)
 
-(type: #export Entry
+(type: .public Entry
   (#Normal ..Normal)
   (#Symbolic_Link ..Symbolic_Link)
   (#Directory ..Directory)
@@ -572,7 +586,7 @@
   Device
   (try.assumed (..small 0)))
 
-(type: #export Tar
+(type: .public Tar
   (Row Entry))
 
 (def: (blocks size)
@@ -717,7 +731,7 @@
 
 (def: end_of_archive_size Size (n.* 2 ..block_size))
 
-(def: #export writer
+(def: .public writer
   (Writer Tar)
   (let [end_of_archive (binary.create ..end_of_archive_size)]
     (function (_ tar)
@@ -727,7 +741,7 @@
                                 tar)
                       (format.segment ..end_of_archive_size end_of_archive)))))
 
-(exception: #export (wrong_checksum {expected Nat} {actual Nat})
+(exception: .public (wrong_checksum {expected Nat} {actual Nat})
   (exception.report
    ["Expected" (%.nat expected)]
    ["Actual" (%.nat actual)]))
@@ -789,7 +803,7 @@
          #major_device major_device
          #minor_device minor_device})))
 
-(exception: #export (wrong_link_flag {expected Link_Flag} {actual Link_Flag})
+(exception: .public (wrong_link_flag {expected Link_Flag} {actual Link_Flag})
   (exception.report
    ["Expected" (%.nat (..link_flag expected))]
    ["Actual" (%.nat (..link_flag actual))]))
@@ -854,7 +868,7 @@
        (exception.assertion ..wrong_checksum [0 actual]
                             (n.= 0 actual))))))
 
-(exception: #export invalid_end_of_archive)
+(exception: .public invalid_end_of_archive)
 
 (def: end_of_archive_parser
   (Parser Any)
@@ -865,7 +879,7 @@
      (exception.assertion ..invalid_end_of_archive []
                           done?))))
 
-(def: #export parser
+(def: .public parser
   (Parser Tar)
   (|> (<>.some entry_parser)
       (\ <>.monad map row.of_list)
diff --git a/stdlib/source/library/lux/data/format/xml.lux b/stdlib/source/library/lux/data/format/xml.lux
index 843a35c91..54e544583 100644
--- a/stdlib/source/library/lux/data/format/xml.lux
+++ b/stdlib/source/library/lux/data/format/xml.lux
@@ -21,21 +21,21 @@
       ["n" nat]
       ["." int]]]]])
 
-(type: #export Tag
+(type: .public Tag
   Name)
 
-(type: #export Attribute
+(type: .public Attribute
   Name)
 
-(type: #export Attrs
+(type: .public Attrs
   (Dictionary Attribute Text))
 
-(def: #export attributes
+(def: .public attributes
   {#.doc (doc "An empty set of XML attributes.")}
   Attrs
   (dictionary.empty name.hash))
 
-(type: #export #rec XML
+(type: .public #rec XML
   (#Text Text)
   (#Node Tag Attrs (List XML)))
 
@@ -206,14 +206,14 @@
       (text.replace_all "'" "'")
       (text.replace_all text.double_quote """)))
 
-(def: #export (tag [namespace name])
+(def: .public (tag [namespace name])
   {#.doc (doc "The text format of a XML tag.")}
   (-> Tag Text)
   (case namespace
     "" name
     _ ($_ text\compose namespace ..namespace_separator name)))
 
-(def: #export attribute
+(def: .public attribute
   {#.doc (doc "The text format of a XML attribute.")}
   (-> Attribute Text)
   ..tag)
@@ -229,7 +229,7 @@
         " encoding=" (quote "UTF-8")
         "?>")))
 
-(implementation: #export codec
+(implementation: .public codec
   (Codec Text XML)
   
   (def: encode
@@ -275,7 +275,7 @@
   (def: decode
     (.run ..xml^)))
 
-(implementation: #export equivalence
+(implementation: .public equivalence
   (Equivalence XML)
   
   (def: (= reference sample)
diff --git a/stdlib/source/library/lux/data/identity.lux b/stdlib/source/library/lux/data/identity.lux
index 851504816..be7560d60 100644
--- a/stdlib/source/library/lux/data/identity.lux
+++ b/stdlib/source/library/lux/data/identity.lux
@@ -9,29 +9,29 @@
     [control
      ["." function]]]])
 
-(type: #export (Identity a)
+(type: .public (Identity a)
   {#.doc (doc "A value, as is, without any extra structure super-imposed on it.")}
   a)
 
-(implementation: #export functor
+(implementation: .public functor
   (Functor Identity)
 
   (def: map function.identity))
 
-(implementation: #export apply
+(implementation: .public apply
   (Apply Identity)
 
   (def: &functor ..functor)
   (def: (apply ff fa) (ff fa)))
 
-(implementation: #export monad
+(implementation: .public monad
   (Monad Identity)
   
   (def: &functor ..functor)
   (def: in function.identity)
   (def: join function.identity))
 
-(implementation: #export comonad
+(implementation: .public comonad
   (CoMonad Identity)
   
   (def: &functor ..functor)
diff --git a/stdlib/source/library/lux/data/lazy.lux b/stdlib/source/library/lux/data/lazy.lux
index d4b345f87..1fa45e583 100644
--- a/stdlib/source/library/lux/data/lazy.lux
+++ b/stdlib/source/library/lux/data/lazy.lux
@@ -17,12 +17,12 @@
     [type
      abstract]]])
 
-(abstract: #export (Lazy a)
-  (-> [] a)
-
+(abstract: .public (Lazy a)
   {#.doc (doc "A value specified by an expression that is calculated only at the last moment possible."
               "Afterwards, the value is cached for future reference.")}
 
+  (-> [] a)
+
   (def: (lazy' generator)
     (All [a] (-> (-> [] a) (Lazy a)))
     (let [cache (atom.atom #.None)]
@@ -36,36 +36,36 @@
                           (exec (io.run (atom.compare_and_swap _ (#.Some value) cache))
                             value)))))))
 
-  (def: #export (value lazy)
+  (def: .public (value lazy)
     (All [a] (-> (Lazy a) a))
     ((:representation lazy) [])))
 
-(syntax: #export (lazy expression)
+(syntax: .public (lazy expression)
   {#.doc (doc "Specifies a lazy value by providing the expression that computes it.")}
   (with_gensyms [g!_]
     (in (list (` ((~! lazy') (function ((~ g!_) (~ g!_)) (~ expression))))))))
 
-(implementation: #export (equivalence (^open "\."))
+(implementation: .public (equivalence (^open "\."))
   (All [a] (-> (Equivalence a) (Equivalence (Lazy a))))
   
   (def: (= left right)
     (\= (..value left)
         (..value right))))
 
-(implementation: #export functor
+(implementation: .public functor
   (Functor Lazy)
   
   (def: (map f fa)
     (lazy (f (value fa)))))
 
-(implementation: #export apply
+(implementation: .public apply
   (Apply Lazy)
   
   (def: &functor ..functor)
   (def: (apply ff fa)
     (lazy ((value ff) (value fa)))))
 
-(implementation: #export monad
+(implementation: .public monad
   (Monad Lazy)
   
   (def: &functor ..functor)
diff --git a/stdlib/source/library/lux/data/maybe.lux b/stdlib/source/library/lux/data/maybe.lux
index bab93295d..a34bf2948 100644
--- a/stdlib/source/library/lux/data/maybe.lux
+++ b/stdlib/source/library/lux/data/maybe.lux
@@ -15,7 +15,7 @@
 ##   #.None
 ##   (#.Some a))
 
-(implementation: #export monoid
+(implementation: .public monoid
   (All [a] (Monoid (Maybe a)))
   
   (def: identity #.None)
@@ -28,7 +28,7 @@
       (#.Some x)
       (#.Some x))))
 
-(implementation: #export functor
+(implementation: .public functor
   (Functor Maybe)
   
   (def: (map f ma)
@@ -36,7 +36,7 @@
       #.None     #.None
       (#.Some a) (#.Some (f a)))))
 
-(implementation: #export apply
+(implementation: .public apply
   (Apply Maybe)
   
   (def: &functor ..functor)
@@ -49,7 +49,7 @@
       _
       #.None)))
 
-(implementation: #export monad
+(implementation: .public monad
   (Monad Maybe)
   
   (def: &functor ..functor)
@@ -65,7 +65,7 @@
       (#.Some mx)
       mx)))
 
-(implementation: #export (equivalence super)
+(implementation: .public (equivalence super)
   (All [a] (-> (Equivalence a) (Equivalence (Maybe a))))
   
   (def: (= mx my)
@@ -79,7 +79,7 @@
       _
       #0)))
 
-(implementation: #export (hash super)
+(implementation: .public (hash super)
   (All [a] (-> (Hash a) (Hash (Maybe a))))
 
   (def: &equivalence
@@ -93,7 +93,7 @@
       (#.Some value)
       (\ super hash value))))
 
-(implementation: #export (with monad)
+(implementation: .public (with monad)
   (All [M] (-> (Monad M) (Monad (All [a] (M (Maybe a))))))
 
   (def: &functor (functor.compose (get@ #monad.&functor monad) ..functor))
@@ -110,12 +110,12 @@
         (#.Some Mma)
         Mma))))
 
-(def: #export (lift monad)
+(def: .public (lift monad)
   {#.doc (doc "Wraps a monadic value with Maybe machinery.")}
   (All [M a] (-> (Monad M) (-> (M a) (M (Maybe a)))))
   (\ monad map (\ ..monad in)))
 
-(macro: #export (else tokens state)
+(macro: .public (else tokens state)
   {#.doc (doc "Allows you to provide a default value that will be used"
               "if a (Maybe x) value turns out to be #.None."
               "Note: the expression for the default value will not be computed if the base computation succeeds."
@@ -139,14 +139,14 @@
     _
     (#.Left "Wrong syntax for else")))
 
-(def: #export assume
+(def: .public assume
   {#.doc (doc "Assumes that a Maybe value is a #.Some and yields its value."
               "Raises/throws a runtime error otherwise."
               "WARNING: Use with caution.")}
   (All [a] (-> (Maybe a) a))
   (|>> (..else (undefined))))
 
-(def: #export (list value)
+(def: .public (list value)
   (All [a] (-> (Maybe a) (List a)))
   (case value
     #.None
@@ -155,7 +155,7 @@
     (#.Some value)
     (#.Item value #.End)))
 
-(macro: #export (when tokens state)
+(macro: .public (when tokens state)
   {#.doc (doc "Can be used as a guard in (co)monadic be/do expressions."
               (do monad
                 [value (do_something 1 2 3)
diff --git a/stdlib/source/library/lux/data/name.lux b/stdlib/source/library/lux/data/name.lux
index cd4b3b67d..1cc1d321c 100644
--- a/stdlib/source/library/lux/data/name.lux
+++ b/stdlib/source/library/lux/data/name.lux
@@ -14,7 +14,7 @@
 ##   [Text Text])
 
 (template [ ]
-  [(def: #export ( name)
+  [(def: .public ( name)
      {#.doc (doc )}
      (-> Name Text)
      (let [[module short] name]
@@ -24,15 +24,15 @@
   [short "The short part of a name."]
   )
 
-(def: #export hash
+(def: .public hash
   (Hash Name)
   (product.hash text.hash text.hash))
 
-(def: #export equivalence
+(def: .public equivalence
   (Equivalence Name)
   (\ ..hash &equivalence))
 
-(implementation: #export order
+(implementation: .public order
   (Order Name)
   
   (def: &equivalence ..equivalence)
@@ -44,7 +44,7 @@
 (def: separator
   ".")
 
-(implementation: #export codec
+(implementation: .public codec
   (Codec Text Name)
   
   (def: (encode [module short])
diff --git a/stdlib/source/library/lux/data/product.lux b/stdlib/source/library/lux/data/product.lux
index 25e6b02d0..9a8d5da7d 100644
--- a/stdlib/source/library/lux/data/product.lux
+++ b/stdlib/source/library/lux/data/product.lux
@@ -7,7 +7,7 @@
      [hash (#+ Hash)]]]])
 
 (template [ ]
-  [(def: #export ( pair)
+  [(def: .public ( pair)
      {#.doc (doc )}
      (All [left right]
        (-> [left right] ))
@@ -19,7 +19,7 @@
   )
 
 ## https://en.wikipedia.org/wiki/Currying
-(def: #export (curry f)
+(def: .public (curry f)
   {#.doc (doc "Converts a 2-argument function into nested single-argument functions.")}
   (All [a b c]
     (-> (-> [a b] c)
@@ -27,7 +27,7 @@
   (function (_ x y)
     (f [x y])))
 
-(def: #export (uncurry f)
+(def: .public (uncurry f)
   {#.doc (doc "Converts nested single-argument functions into a 2-argument function.")}
   (All [a b c]
     (-> (-> a b c)
@@ -36,12 +36,12 @@
     (let [[x y] xy]
       (f x y))))
 
-(def: #export (swap xy)
+(def: .public (swap xy)
   (All [a b] (-> [a b] [b a]))
   (let [[x y] xy]
     [y x]))
 
-(def: #export (apply f g)
+(def: .public (apply f g)
   {#.doc (doc "Apply functions to both sides of a pair.")}
   (All [a b c d]
     (-> (-> a c) (-> b d)
@@ -49,7 +49,7 @@
   (function (_ [x y])
     [(f x) (g y)]))
 
-(def: #export (fork f g)
+(def: .public (fork f g)
   {#.doc (doc "Yields a pair by applying both functions to a single value.")}
   (All [a l r]
     (-> (-> a l) (-> a r)
@@ -57,14 +57,14 @@
   (function (_ x)
     [(f x) (g x)]))
 
-(implementation: #export (equivalence left right)
+(implementation: .public (equivalence left right)
   (All [l r] (-> (Equivalence l) (Equivalence r) (Equivalence [l r])))
 
   (def: (= [rl rr] [sl sr])
     (and (\ left = rl sl)
          (\ right = rr sr))))
 
-(def: #export (hash left right)
+(def: .public (hash left right)
   (All [l r] (-> (Hash l) (Hash r) (Hash [l r])))
   (implementation
    (def: &equivalence
diff --git a/stdlib/source/library/lux/data/store.lux b/stdlib/source/library/lux/data/store.lux
index ecc34fde5..ba795f4d1 100644
--- a/stdlib/source/library/lux/data/store.lux
+++ b/stdlib/source/library/lux/data/store.lux
@@ -7,7 +7,7 @@
     [type
      implicit]]])
 
-(type: #export (Store s a)
+(type: .public (Store s a)
   {#cursor s
    #peek (-> s a)})
 
@@ -16,7 +16,7 @@
   {#cursor (get@ #cursor wa)
    #peek (function (_ s) (f (set@ #cursor s wa)))})
 
-(implementation: #export functor
+(implementation: .public functor
   (All [s] (Functor (Store s)))
   
   (def: (map f fa)
@@ -24,7 +24,7 @@
               (f (\ store peek (\ store cursor))))
             fa)))
 
-(implementation: #export comonad
+(implementation: .public comonad
   (All [s] (CoMonad (Store s)))
   
   (def: &functor ..functor)
@@ -33,18 +33,18 @@
 
   (def: split (extend id)))
 
-(def: #export (peeks trans store)
+(def: .public (peeks trans store)
   (All [s a] (-> (-> s s) (Store s a) a))
   (|> (\\ cursor) trans (\\ peek)))
 
-(def: #export (seek cursor store)
+(def: .public (seek cursor store)
   (All [s a] (-> s (Store s a) (Store s a)))
   (\ (\\ split store) peek cursor))
 
-(def: #export (seeks change store)
+(def: .public (seeks change store)
   (All [s a] (-> (-> s s) (Store s a) (Store s a)))
   (|> store (\\ split) (peeks change)))
 
-(def: #export (experiment Functor change store)
+(def: .public (experiment Functor change store)
   (All [f s a] (-> (Functor f) (-> s (f s)) (Store s a) (f a)))
   (\ Functor map (\\ peek) (change (\\ cursor))))
diff --git a/stdlib/source/library/lux/data/sum.lux b/stdlib/source/library/lux/data/sum.lux
index 224ba3878..bde3fc86f 100644
--- a/stdlib/source/library/lux/data/sum.lux
+++ b/stdlib/source/library/lux/data/sum.lux
@@ -7,7 +7,7 @@
      [hash (#+ Hash)]]]])
 
 (template [  ]
-  [(def: #export ( value)
+  [(def: .public ( value)
      {#.doc (doc )}
      (All [left right]
        (->  (Or left right)))
@@ -18,7 +18,7 @@
   [#1 right
    "Lifts value to the right side of a 2-variant."])
 
-(def: #export (either fl fr)
+(def: .public (either fl fr)
   {#.doc (doc "Applies a function to either side of a 2-variant.")}
   (All [a b c]
     (-> (-> a c) (-> b c)
@@ -28,7 +28,7 @@
       (0 #0 l) (fl l)
       (0 #1 r) (fr r))))
 
-(def: #export (apply fl fr)
+(def: .public (apply fl fr)
   {#.doc (doc "Applies functions to both sides of a 2-variant.")}
   (All [l l' r r']
     (-> (-> l l') (-> r r')
@@ -39,7 +39,7 @@
       (0 #1 r) (0 #1 (fr r)))))
 
 (template [  ]
-  [(def: #export ( es)
+  [(def: .public ( es)
      (All [a b] (-> (List (Or a b)) (List )))
      (case es
        #.End
@@ -55,7 +55,7 @@
   [rights b #1]
   )
 
-(def: #export (partition xs)
+(def: .public (partition xs)
   (All [a b] (-> (List (Or a b)) [(List a) (List b)]))
   (case xs
     #.End
@@ -67,7 +67,7 @@
         (0 #0 x')  [(#.Item x' lefts) rights]
         (0 #1 x') [lefts (#.Item x' rights)]))))
 
-(def: #export (equivalence left right)
+(def: .public (equivalence left right)
   (All [l r] (-> (Equivalence l) (Equivalence r) (Equivalence (Or l r))))
   (implementation
    (def: (= reference sample)
@@ -81,7 +81,7 @@
        _
        false))))
 
-(def: #export (hash left right)
+(def: .public (hash left right)
   (All [l r] (-> (Hash l) (Hash r) (Hash (Or l r))))
   (implementation
    (def: &equivalence
diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux
index f4870ecf5..f58365d66 100644
--- a/stdlib/source/library/lux/data/text.lux
+++ b/stdlib/source/library/lux/data/text.lux
@@ -18,19 +18,19 @@
       ["n" nat]
       ["." i64]]]]])
 
-(type: #export Char
+(type: .public Char
   {#.doc (doc "A character code number.")}
   Nat)
 
 ## TODO: Instead of ints, chars should be produced fron nats.
 ## (The JVM specifies chars as 16-bit unsigned integers)
-(def: #export of_char
+(def: .public of_char
   (-> Char Text)
   (|>> .int "lux i64 char"))
 
 (template [  ]
-  [(def: #export  (..of_char ))
-   (def: #export  )]
+  [(def: .public  (..of_char ))
+   (def: .public  )]
 
   [00 \0  null]
   [07 \a  alarm]
@@ -43,26 +43,26 @@
   [34 \'' double_quote]
   )
 
-(def: #export line_feed
+(def: .public line_feed
   {#.doc (doc "Same as 'new_line'.")}
   ..new_line)
 
-(def: #export size
+(def: .public size
   (-> Text Nat)
   (|>> "lux text size"))
 
-(def: #export (char index input)
+(def: .public (char index input)
   {#.doc (doc "Yields the character at the specified index.")}
   (-> Nat Text (Maybe Char))
   (if (n.< ("lux text size" input) index)
     (#.Some ("lux text char" index input))
     #.None))
 
-(def: #export (index_of' from pattern input)
+(def: .public (index_of' from pattern input)
   (-> Nat Text Text (Maybe Nat))
   ("lux text index" from pattern input))
 
-(def: #export (index_of pattern input)
+(def: .public (index_of pattern input)
   (-> Text Text (Maybe Nat))
   (index_of' 0 pattern input))
 
@@ -79,11 +79,11 @@
         (#.Some from')
         (recur (inc from') output')))))
 
-(def: #export (last_index_of part text)
+(def: .public (last_index_of part text)
   (-> Text Text (Maybe Nat))
   (last_index_of' 0 part text))
 
-(def: #export (starts_with? prefix x)
+(def: .public (starts_with? prefix x)
   (-> Text Text Bit)
   (case (index_of prefix x)
     (#.Some 0)
@@ -92,7 +92,7 @@
     _
     false))
 
-(def: #export (ends_with? postfix x)
+(def: .public (ends_with? postfix x)
   (-> Text Text Bit)
   (case (last_index_of postfix x)
     (#.Some n)
@@ -102,12 +102,12 @@
     _
     false))
 
-(def: #export (enclosed_by? boundary value)
+(def: .public (enclosed_by? boundary value)
   (-> Text Text Bit)
   (and (starts_with? boundary value)
        (ends_with? boundary value)))
 
-(def: #export (contains? sub text)
+(def: .public (contains? sub text)
   (-> Text Text Bit)
   (case ("lux text index" 0 sub text)
     (#.Some _)
@@ -116,36 +116,36 @@
     _
     false))
 
-(def: #export (prefix param subject)
+(def: .public (prefix param subject)
   (-> Text Text Text)
   ("lux text concat" param subject))
 
-(def: #export (suffix param subject)
+(def: .public (suffix param subject)
   (-> Text Text Text)
   ("lux text concat" subject param))
 
-(def: #export (enclosed [left right] content)
+(def: .public (enclosed [left right] content)
   {#.doc "Surrounds the given content text with left and right side additions."}
   (-> [Text Text] Text Text)
   ($_ "lux text concat" left content right))
 
-(def: #export (enclosed' boundary content)
+(def: .public (enclosed' boundary content)
   {#.doc "Surrounds the given content text with the same boundary text."}
   (-> Text Text Text)
   (enclosed [boundary boundary] content))
 
-(def: #export format
+(def: .public format
   (-> Text Text)
   (..enclosed' ..double_quote))
 
-(def: #export (clip offset size input)
+(def: .public (clip offset size input)
   {#.doc (doc "Clips a chunk of text from the input at the specified offset and of the specified size.")}
   (-> Nat Nat Text (Maybe Text))
   (if (|> size (n.+ offset) (n.<= ("lux text size" input)))
     (#.Some ("lux text clip" offset size input))
     #.None))
 
-(def: #export (clip' offset input)
+(def: .public (clip' offset input)
   {#.doc (doc "Clips the remaining text from the input at the specified offset.")}
   (-> Nat Text (Maybe Text))
   (let [size ("lux text size" input)]
@@ -153,7 +153,7 @@
       (#.Some ("lux text clip" offset (n.- offset size) input))
       #.None)))
 
-(def: #export (split at x)
+(def: .public (split at x)
   (-> Nat Text (Maybe [Text Text]))
   (case [(..clip 0 at x) (..clip' at x)]
     [(#.Some pre) (#.Some post)]
@@ -162,7 +162,7 @@
     _
     #.None))
 
-(def: #export (split_with token sample)
+(def: .public (split_with token sample)
   (-> Text Text (Maybe [Text Text]))
   (do maybe.monad
     [index (index_of token sample)
@@ -170,7 +170,7 @@
      [_ post] (split (size token) post')]
     (in [pre post])))
 
-(def: #export (split_all_with token sample)
+(def: .public (split_all_with token sample)
   (-> Text Text (List Text))
   (loop [input sample
          output (: (List Text) (list))]
@@ -185,14 +185,14 @@
           (#.Item input)
           list.reversed))))
 
-(def: #export (replace_once pattern replacement template)
+(def: .public (replace_once pattern replacement template)
   (-> Text Text Text Text)
   (<| (maybe.else template)
       (do maybe.monad
         [[pre post] (..split_with pattern template)]
         (in ($_ "lux text concat" pre replacement post)))))
 
-(def: #export (replace_all pattern replacement template)
+(def: .public (replace_all pattern replacement template)
   (-> Text Text Text Text)
   (for {@.old
         (:as Text
@@ -235,13 +235,13 @@
            #.None
            ("lux text concat" left right)))))
 
-(implementation: #export equivalence
+(implementation: .public equivalence
   (Equivalence Text)
   
   (def: (= reference sample)
     ("lux text =" reference sample)))
 
-(implementation: #export order
+(implementation: .public order
   (Order Text)
   
   (def: &equivalence ..equivalence)
@@ -249,7 +249,7 @@
   (def: (< reference sample)
     ("lux text <" reference sample)))
 
-(implementation: #export monoid
+(implementation: .public monoid
   (Monoid Text)
   
   (def: identity "")
@@ -257,7 +257,7 @@
   (def: (compose left right)
     ("lux text concat" left right)))
 
-(implementation: #export hash
+(implementation: .public hash
   (Hash Text)
   
   (def: &equivalence ..equivalence)
@@ -290,27 +290,27 @@
                           (n.+ ("lux text char" index input))))
                hash))))))
 
-(def: #export concat
+(def: .public concat
   (-> (List Text) Text)
   (let [(^open ".") ..monoid]
     (|>> list.reversed
          (list\fold compose identity))))
 
-(def: #export (join_with separator texts)
+(def: .public (join_with separator texts)
   (-> Text (List Text) Text)
   (|> texts (list.interpose separator) concat))
 
-(def: #export (empty? text)
+(def: .public (empty? text)
   (-> Text Bit)
   (case text
     "" true
     _  false))
 
-(def: #export space
+(def: .public space
   Text
   " ")
 
-(def: #export (space? char)
+(def: .public (space? char)
   {#.doc "Checks whether the character is white-space."}
   (-> Char Bit)
   (with_expansions [ (template []
@@ -330,7 +330,7 @@
           _
           false))))
 
-(def: #export (lower_cased value)
+(def: .public (lower_cased value)
   (-> Text Text)
   (for {@.old
         (:as Text
@@ -353,7 +353,7 @@
         (:as Text
              ("ruby object do" "downcase" value))}))
 
-(def: #export (upper_cased value)
+(def: .public (upper_cased value)
   (-> Text Text)
   (for {@.old
         (:as Text
diff --git a/stdlib/source/library/lux/data/text/buffer.lux b/stdlib/source/library/lux/data/text/buffer.lux
index d20dc21b9..332504d08 100644
--- a/stdlib/source/library/lux/data/text/buffer.lux
+++ b/stdlib/source/library/lux/data/text/buffer.lux
@@ -47,7 +47,9 @@
                          )}
            (as_is))))
 
-(`` (abstract: #export Buffer
+(`` (abstract: .public Buffer
+      {#.doc "Immutable text buffer for efficient text concatenation."}
+
       (for {@.old [Nat (-> java/lang/StringBuilder java/lang/StringBuilder)]
             @.jvm [Nat (-> java/lang/StringBuilder java/lang/StringBuilder)]
             @.js [Nat (-> (JS_Array Text) (JS_Array Text))]
@@ -55,9 +57,7 @@
            ## default
            (Row Text))
 
-      {#.doc "Immutable text buffer for efficient text concatenation."}
-
-      (def: #export empty
+      (def: .public empty
         Buffer
         (:abstraction (with_expansions [ [0 function.identity]]
                         (for {@.old 
@@ -67,7 +67,7 @@
                              ## default
                              row.empty))))
 
-      (def: #export (append chunk buffer)
+      (def: .public (append chunk buffer)
         (-> Text Buffer Buffer)
         (with_expansions [ (let [[capacity transform] (:representation buffer)
                                       append! (: (-> Text java/lang/StringBuilder java/lang/StringBuilder)
@@ -99,7 +99,7 @@
                ## default
                (|> buffer :representation (row.add chunk) :abstraction))))
 
-      (def: #export size
+      (def: .public size
         (-> Buffer Nat)
         (with_expansions [ (|>> :representation product.left)]
           (for {@.old 
@@ -112,7 +112,7 @@
                                 (n.+ (//.size chunk) total))
                               0)))))
 
-      (def: #export (text buffer)
+      (def: .public (text buffer)
         (-> Buffer Text)
         (with_expansions [ (let [[capacity transform] (:representation buffer)]
                                   (|> (java/lang/StringBuilder::new (.int capacity))
diff --git a/stdlib/source/library/lux/data/text/encoding.lux b/stdlib/source/library/lux/data/text/encoding.lux
index 8829d7d92..7f94a8c08 100644
--- a/stdlib/source/library/lux/data/text/encoding.lux
+++ b/stdlib/source/library/lux/data/text/encoding.lux
@@ -6,11 +6,13 @@
 
 ## https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html
 
-(abstract: #export Encoding
+(abstract: .public Encoding
+  {}
+  
   Text
 
   (template [ ]
-    [(def: #export 
+    [(def: .public 
        Encoding
        (:abstraction ))]
 
@@ -159,7 +161,7 @@
     [koi8_u "KOI8-U"]
     )
 
-  (def: #export name
+  (def: .public name
     (-> Encoding Text)
     (|>> :representation))
   )
diff --git a/stdlib/source/library/lux/data/text/encoding/utf8.lux b/stdlib/source/library/lux/data/text/encoding/utf8.lux
index 7e5c8a4e2..5892d403d 100644
--- a/stdlib/source/library/lux/data/text/encoding/utf8.lux
+++ b/stdlib/source/library/lux/data/text/encoding/utf8.lux
@@ -157,7 +157,7 @@
               ..utf8->string
               #try.Success)})))
 
-(implementation: #export codec
+(implementation: .public codec
   {#.doc (doc "A codec for binary encoding of text as UTF-8.")}
   (Codec Binary Text)
   
diff --git a/stdlib/source/library/lux/data/text/escape.lux b/stdlib/source/library/lux/data/text/escape.lux
index d34c91d70..7e02459e1 100644
--- a/stdlib/source/library/lux/data/text/escape.lux
+++ b/stdlib/source/library/lux/data/text/escape.lux
@@ -68,7 +68,7 @@
 (def: ascii_bottom (hex "20"))
 (def: ascii_top (hex "7E"))
 
-(def: #export (escapable? char)
+(def: .public (escapable? char)
   (-> Char Bit)
   (case char
     (^template []
@@ -109,7 +109,7 @@
      ("lux text clip" post_offset post_limit current)
      post_limit]))
 
-(def: #export (escape text)
+(def: .public (escape text)
   {#.doc (doc "Yields a escaped version of the text.")}
   (-> Text Text)
   (loop [offset 0
@@ -141,18 +141,18 @@
           (recur (inc offset) previous current limit)))
       (format previous current))))
 
-(exception: #export (dangling_escape {text Text})
+(exception: .public (dangling_escape {text Text})
   (exception.report
    ["In" (%.text text)]
    ["At" (%.nat (dec (//.size text)))]))
 
-(exception: #export (invalid_escape {text Text} {offset Nat} {sigil Char})
+(exception: .public (invalid_escape {text Text} {offset Nat} {sigil Char})
   (exception.report
    ["In" (%.text text)]
    ["At" (%.nat offset)]
    ["Name" (%.text (//.of_char sigil))]))
 
-(exception: #export (invalid_unicode_escape {text Text} {offset Nat})
+(exception: .public (invalid_unicode_escape {text Text} {offset Nat})
   (exception.report
    ["In" (%.text text)]
    ["At" (%.nat offset)]))
@@ -191,7 +191,7 @@
     (#try.Failure error)
     (exception.except ..invalid_unicode_escape [current offset])))
 
-(def: #export (un_escape text)
+(def: .public (un_escape text)
   {#.doc (doc "Yields an un-escaped text."
               "Fails if it was improperly escaped.")}
   (-> Text (Try Text))
@@ -238,7 +238,7 @@
                       "" current
                       _ (format previous current))))))
 
-(syntax: #export (escaped {literal .text})
+(syntax: .public (escaped {literal .text})
   {#.doc (doc "If given a escaped text literal, expands to an un-escaped version.")}
   (case (..un_escape literal)
     (#try.Success un_escaped)
diff --git a/stdlib/source/library/lux/data/text/format.lux b/stdlib/source/library/lux/data/text/format.lux
index cf4b3e2d4..4cfd5cb34 100644
--- a/stdlib/source/library/lux/data/text/format.lux
+++ b/stdlib/source/library/lux/data/text/format.lux
@@ -39,23 +39,23 @@
      ["." location]]
     ["." type]]])
 
-(type: #export (Format a)
+(type: .public (Format a)
   {#.doc "A way to produce readable text from values."}
   (-> a Text))
 
-(implementation: #export functor
+(implementation: .public functor
   (contravariant.Functor Format)
   
   (def: (map f fb)
     (|>> f fb)))
 
-(syntax: #export (format {fragments (<>.many .any)})
+(syntax: .public (format {fragments (<>.many .any)})
   {#.doc (doc "Text interpolation."
               (format "Static part " (text static) " does not match URI: " uri))}
   (in (.list (` ($_ "lux text concat" (~+ fragments))))))
 
 (template [  ]
-  [(def: #export 
+  [(def: .public 
      (Format )
      )]
 
@@ -85,7 +85,7 @@
 
 (template [ ,]
   [(`` (template [ ]
-         [(def: #export 
+         [(def: .public 
             (Format )
             (\  encode))]
 
@@ -113,18 +113,18 @@
     [frac/16 frac.hex]]]
   )
 
-(def: #export (mod modular)
+(def: .public (mod modular)
   (All [m] (Format (modular.Mod m)))
   (let [codec (modular.codec (modular.modulus modular))]
     (\ codec encode modular)))
 
-(def: #export (list formatter)
+(def: .public (list formatter)
   (All [a] (-> (Format a) (Format (List a))))
   (|>> (list\map (|>> formatter (format " ")))
        (text.join_with "")
        (text.enclosed ["(list" ")"])))
 
-(def: #export (maybe format)
+(def: .public (maybe format)
   (All [a] (-> (Format a) (Format (Maybe a))))
   (function (_ value)
     (case value
diff --git a/stdlib/source/library/lux/data/text/regex.lux b/stdlib/source/library/lux/data/text/regex.lux
index 8c353db1c..defbaf3e1 100644
--- a/stdlib/source/library/lux/data/text/regex.lux
+++ b/stdlib/source/library/lux/data/text/regex.lux
@@ -230,7 +230,7 @@
       (in (` ((~! join_text^) ((~! <>.many) (~ base)))))
       )))
 
-(exception: #export (incorrect_quantification {from Nat} {to Nat})
+(exception: .public (incorrect_quantification {from Nat} {to Nat})
   (exception.report
    ["Input" (format (%.nat from) "," (%.nat to))]
    ["Should be" (format (%.nat to) "," (%.nat from))]))
@@ -411,7 +411,7 @@
   (-> Text (Parser Code))
   (\ <>.monad map product.right (re_alternative^ #1 re_scoped^ current_module)))
 
-(syntax: #export (regex {pattern .text})
+(syntax: .public (regex {pattern .text})
   {#.doc (doc "Create lexers using regular-expression syntax."
               "For example:"
               
@@ -482,7 +482,7 @@
       (in (list regex))
       )))
 
-(syntax: #export (^regex {[pattern bindings] (.form (<>.and .text (<>.maybe .any)))}
+(syntax: .public (^regex {[pattern bindings] (.form (<>.and .text (<>.maybe .any)))}
                          body
                          {branches (<>.many .any)})
   {#.doc (doc "Allows you to test text against regular expressions."
diff --git a/stdlib/source/library/lux/data/text/unicode/block.lux b/stdlib/source/library/lux/data/text/unicode/block.lux
index 955b851d2..e1a4a4de6 100644
--- a/stdlib/source/library/lux/data/text/unicode/block.lux
+++ b/stdlib/source/library/lux/data/text/unicode/block.lux
@@ -21,12 +21,12 @@
      abstract]]]
   ["." /// (#+ Char)])
 
-(abstract: #export Block
-  (Interval Char)
-  
+(abstract: .public Block
   {#.doc (doc "A block of valid unicode characters.")}
 
-  (implementation: #export monoid
+  (Interval Char)
+  
+  (implementation: .public monoid
     (Monoid Block)
     
     (def: identity
@@ -41,12 +41,12 @@
                            (n.max (\ left top)
                                   (\ right top)))))))
 
-  (def: #export (block start additional)
+  (def: .public (block start additional)
     (-> Char Nat Block)
     (:abstraction (interval.between n.enum start (n.+ additional start))))
 
   (template [ ]
-    [(def: #export 
+    [(def: .public 
        (-> Block Char)
        (|>> :representation (get@ )))]
 
@@ -54,25 +54,25 @@
     [end   #interval.top]
     )
 
-  (def: #export (size block)
+  (def: .public (size block)
     (-> Block Nat)
     (let [start (get@ #interval.bottom (:representation block))
           end (get@ #interval.top (:representation block))]
       (|> end (n.- start) inc)))
 
-  (def: #export (within? block char)
+  (def: .public (within? block char)
     (All [a] (-> Block Char Bit))
     (interval.within? (:representation block) char))
   )
 
-(implementation: #export equivalence
+(implementation: .public equivalence
   (Equivalence Block)
 
   (def: (= reference subject)
     (and (n.= (..start reference) (..start subject))
          (n.= (..end reference) (..end subject)))))
 
-(implementation: #export hash
+(implementation: .public hash
   (Hash Block)
 
   (def: &equivalence ..equivalence)
@@ -86,7 +86,7 @@
 (template [  ]
   [(with_expansions [ (..block_name )
                       (template.text [ "-"  " | " ])]
-     (def: #export 
+     (def: .public 
        {#.doc (doc )}
        Block
        (let [start (hex )
diff --git a/stdlib/source/library/lux/data/text/unicode/set.lux b/stdlib/source/library/lux/data/text/unicode/set.lux
index 0a5aa6ce8..ab5d978b6 100644
--- a/stdlib/source/library/lux/data/text/unicode/set.lux
+++ b/stdlib/source/library/lux/data/text/unicode/set.lux
@@ -26,10 +26,12 @@
                
                @))
 
-(abstract: #export Set
+(abstract: .public Set
+  {}
+  
   (Tree :@: Block [])
 
-  (def: #export (compose left right)
+  (def: .public (compose left right)
     (-> Set Set Set)
     (:abstraction
      (\ builder branch
@@ -41,7 +43,7 @@
     (:abstraction
      (\ builder leaf block [])))
 
-  (def: #export (set [head tail])
+  (def: .public (set [head tail])
     (-> [Block (List Block)] Set)
     (list\fold (: (-> Block Set Set)
                   (function (_ block set)
@@ -150,7 +152,7 @@
                   //block.hangul_syllables
                   )]))
 
-  (def: #export character
+  (def: .public character
     Set
     ($_ ..compose
         ..character/0
@@ -158,7 +160,7 @@
         ..character/2
         ))
 
-  (def: #export non_character
+  (def: .public non_character
     Set
     (..set [//block.high_surrogates
             (list  //block.high_private_use_surrogates
@@ -193,26 +195,26 @@
                    ## //block.tags
                    )]))
 
-  (def: #export full
+  (def: .public full
     Set
     ($_ ..compose
         ..character
         ..non_character
         ))
 
-  (def: #export start
+  (def: .public start
     (-> Set Char)
     (|>> :representation
          tree.tag
          //block.start))
 
-  (def: #export end
+  (def: .public end
     (-> Set Char)
     (|>> :representation
          tree.tag
          //block.end))
 
-  (def: #export (member? set character)
+  (def: .public (member? set character)
     (-> Set Char Bit)
     (loop [tree (:representation set)]
       (if (//block.within? (tree.tag tree) character)
@@ -225,7 +227,7 @@
               (recur right)))
         false)))
 
-  (implementation: #export equivalence
+  (implementation: .public equivalence
     (Equivalence Set)
 
     (def: (= reference subject)
@@ -234,7 +236,7 @@
   )
 
 (template [ ]
-  [(def: #export 
+  [(def: .public 
      Set
      (..set ))]
 
diff --git a/stdlib/source/library/lux/data/trace.lux b/stdlib/source/library/lux/data/trace.lux
index 9646fa0f3..5767084eb 100644
--- a/stdlib/source/library/lux/data/trace.lux
+++ b/stdlib/source/library/lux/data/trace.lux
@@ -7,15 +7,15 @@
      comonad]
     function]])
 
-(type: #export (Trace t a)
+(type: .public (Trace t a)
   {#monoid (Monoid t)
    #trace (-> t a)})
 
-(implementation: #export functor (All [t] (Functor (Trace t)))
+(implementation: .public functor (All [t] (Functor (Trace t)))
   (def: (map f fa)
     (update@ #trace (compose f) fa)))
 
-(implementation: #export comonad (All [t] (CoMonad (Trace t)))
+(implementation: .public comonad (All [t] (CoMonad (Trace t)))
   (def: &functor ..functor)
 
   (def: (out wa)
@@ -31,6 +31,6 @@
                           ((get@ #trace wa)
                            (\ monoid compose t1 t2)))})})))
 
-(def: #export (run context tracer)
+(def: .public (run context tracer)
   (All [t a] (-> t (Trace t a) a))
   (\ tracer trace context))
diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux
index 0fbd4657a..cc09e996e 100644
--- a/stdlib/source/library/lux/debug.lux
+++ b/stdlib/source/library/lux/debug.lux
@@ -1,6 +1,6 @@
 (.module:
   [library
-   [lux (#- type)
+   [lux (#- type private)
     ["@" target]
     ["." type]
     ["." ffi (#+ import:)]
@@ -140,7 +140,7 @@
              (text.join_with " ")
              (text.enclosed ["[" "]"])))))
 
-(def: #export (inspection value)
+(def: .public (inspection value)
   Inspector
   (with_expansions [ (let [object (:as java/lang/Object value)]
                             (`` (<| (~~ (template [ ]
@@ -378,7 +378,7 @@
                     ))
           })))
 
-(exception: #export (cannot_represent_value {type Type})
+(exception: .public (cannot_represent_value {type Type})
   (exception.report
    ["Type" (%.type type)]))
 
@@ -511,7 +511,7 @@
          (<>.failure "")
          ))))
 
-(def: #export (representation type value)
+(def: .public (representation type value)
   (-> Type Any (Try Text))
   (case (.run ..representation_parser type)
     (#try.Success representation)
@@ -520,23 +520,23 @@
     (#try.Failure _)
     (exception.except ..cannot_represent_value type)))
 
-(syntax: #export (private {definition .identifier})
+(syntax: .public (private {definition .identifier})
   (let [[module _] definition]
     (in (list (` ("lux in-module"
                   (~ (code.text module))
                   (~ (code.identifier definition))))))))
 
-(def: #export (log! message)
+(def: .public (log! message)
   {#.doc "Logs message to standard output."}
   (-> Text Any)
   ("lux io log" message))
 
-(exception: #export (type_hole {location Location} {type Type})
+(exception: .public (type_hole {location Location} {type Type})
   (exception.report
    ["Location" (%.location location)]
    ["Type" (%.type type)]))
 
-(syntax: #export (:hole)
+(syntax: .public (:hole)
   (do meta.monad
     [location meta.location
      expectedT meta.expected_type]
@@ -552,11 +552,11 @@
              (.record (<>.and .local_identifier
                                     (\ <>.monad map (|>> #.Some) .any)))))
 
-(exception: #export (unknown_local_binding {name Text})
+(exception: .public (unknown_local_binding {name Text})
   (exception.report
    ["Name" (%.text name)]))
 
-(syntax: #export (here {targets (: (.Parser (List Target))
+(syntax: .public (here {targets (: (.Parser (List Target))
                                    (|> ..target
                                        <>.some
                                        (<>.else (list))))})
diff --git a/stdlib/source/library/lux/extension.lux b/stdlib/source/library/lux/extension.lux
index 4347cec39..ae9745baa 100644
--- a/stdlib/source/library/lux/extension.lux
+++ b/stdlib/source/library/lux/extension.lux
@@ -57,7 +57,7 @@
                 (<>.some (..input default)))))
 
 (template [     ]
-  [(syntax: #export (
+  [(syntax: .public (
                      {[name extension phase archive inputs] (..declaration (` ))}
                      body)
      (let [g!parser (case (list\map product.right inputs)
diff --git a/stdlib/source/library/lux/ffi.js.lux b/stdlib/source/library/lux/ffi.js.lux
index 0b641a3a6..069e38123 100644
--- a/stdlib/source/library/lux/ffi.js.lux
+++ b/stdlib/source/library/lux/ffi.js.lux
@@ -22,7 +22,7 @@
      ["." code]
      ["." template]]]])
 
-(abstract: #export (Object brand)
+(abstract: .public (Object brand)
   Any)
 
 (template []
@@ -30,7 +30,7 @@
      (abstract: 
        Any
        
-       (type: #export 
+       (type: .public 
          (Object ))))]
 
   [Function]
@@ -40,7 +40,7 @@
   )
 
 (template [ ]
-  [(type: #export 
+  [(type: .public 
      )]
 
   [Boolean Bit]
@@ -149,11 +149,11 @@
          ("js object null")))
     input))
 
-(def: #export (null _)
+(def: .public (null _)
   (-> Any Nothing)
   (:assume ("js object null")))
 
-(def: #export null?
+(def: .public null?
   (-> Any Bit)
   (|>> "js object null?"))
 
@@ -232,7 +232,7 @@
                      ("js constant" (~ (code.text source)))
                      (~+ (list\map (with_null g!temp) g!inputs)))))))))))
 
-(syntax: #export (import: {import ..import})
+(syntax: .public (import: {import ..import})
   (with_gensyms [g!temp]
     (case import
       (#Class [[class_name class_parameters] format members])
@@ -319,10 +319,10 @@
                                  outputT)))
       )))
 
-(template: #export (type_of object)
+(template: .public (type_of object)
   ("js type-of" object))
 
-(syntax: #export (constant type
+(syntax: .public (constant type
                            {[head tail] (.tuple (<>.and .local_identifier (<>.some .local_identifier)))})
   (with_gensyms [g!_]
     (let [constant (` ("js constant" (~ (code.text head))))]
@@ -356,7 +356,7 @@
     .true))
 
 (template [ ]
-  [(def: #export 
+  [(def: .public 
      Bit
      (!defined? ))]
 
@@ -364,7 +364,7 @@
   [on_nashorn? [java lang Object]]
   )
 
-(def: #export on_node_js?
+(def: .public on_node_js?
   Bit
   (case (..constant (Object Any) [process])
     (#.Some process)
@@ -379,7 +379,7 @@
     #.None
     false))
 
-(template: #export (closure  )
+(template: .public (closure  )
   (.:as ..Function
         (`` ("js function"
              (~~ (template.amount ))
diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux
index 536960c9a..bda7e8484 100644
--- a/stdlib/source/library/lux/ffi.jvm.lux
+++ b/stdlib/source/library/lux/ffi.jvm.lux
@@ -55,7 +55,7 @@
   (|>> type.reflection reflection.reflection))
 
 (template [ ]
-  [(def: #export 
+  [(def: .public 
      .Type
      (#.Primitive  #.End))]
 
@@ -70,7 +70,7 @@
   )
 
 (template [ ]
-  [(def: #export 
+  [(def: .public 
      .Type
      (#.Primitive (reflection.reflection ) #.End))]
 
@@ -124,16 +124,16 @@
   )
 
 (template [   ]
-  [(template: #export ( value)
+  [(template: .public ( value)
      {#.doc (doc "Type converter."
                  (: 
                     ( (:  foo))))}
-     (|> value
-         (: )
-         "jvm object cast"
-         
-         "jvm object cast"
-         (: )))]
+     [(|> value
+          (: )
+          "jvm object cast"
+          
+          "jvm object cast"
+          (: ))])]
 
   [byte_to_long    "jvm conversion byte-to-long"    ..Byte      ..Long]
 
@@ -167,11 +167,11 @@
   )
 
 (template [   <0> <1>]
-  [(template: #export ( value)
+  [(template: .public ( value)
      {#.doc (doc "Type converter."
                  (: 
                     ( (:  foo))))}
-     (|> value <0> <1>))]
+     [(|> value <0> <1>)])]
 
   [long_to_char ..Long ..Character ..long_to_int ..int_to_char]
   [byte_to_int ..Byte ..Integer ..byte_to_long ..long_to_int]
@@ -187,18 +187,18 @@
   #ManualPrM
   #AutoPrM)
 
-(type: #export Privacy
+(type: .public Privacy
   #PublicP
   #PrivateP
   #ProtectedP
   #DefaultP)
 
-(type: #export State
+(type: .public State
   #VolatileS
   #FinalS
   #DefaultS)
 
-(type: #export Inheritance
+(type: .public Inheritance
   #FinalI
   #AbstractI
   #DefaultI)
@@ -537,11 +537,11 @@
         (.this! (' #abstract))
         (in []))))
 
-(exception: #export (class_names_cannot_contain_periods {name Text})
+(exception: .public (class_names_cannot_contain_periods {name Text})
   (exception.report
    ["Name" (%.text name)]))
 
-(exception: #export (class_name_cannot_be_a_type_variable {name Text}
+(exception: .public (class_name_cannot_be_a_type_variable {name Text}
                                                           {type_vars (List (Type Var))})
   (exception.report
    ["Name" (%.text name)]
@@ -575,7 +575,7 @@
                               (.form (<>.and class_name^ (<>.some (parameter^ type_vars))))))]
     (in (type.class (name.safe name) parameters))))
 
-(exception: #export (unexpected_type_variable {name Text}
+(exception: .public (unexpected_type_variable {name Text}
                                               {type_vars (List (Type Var))})
   (exception.report
    ["Unexpected Type Variable" (%.text name)]
@@ -1199,7 +1199,7 @@
   (Type Class)
   (type.class "java.lang.Object" (list)))
 
-(syntax: #export (class:
+(syntax: .public (class:
                    {.let [! <>.monad]}
                    {im inheritance_modifier^}
                    {[full_class_name class_vars] (\ ! map parser.declaration ..declaration^)}
@@ -1256,7 +1256,7 @@
                   [(~+ (list\map field_decl$ fields))]
                   [(~+ (list\map (method_def$ fully_qualified_class_name method_parser super fields) methods))]))))))
 
-(syntax: #export (interface:
+(syntax: .public (interface:
                    {.let [! <>.monad]}
                    {[full_class_name class_vars] (\ ! map parser.declaration ..declaration^)}
                    {supers (<>.else (list)
@@ -1272,7 +1272,7 @@
                 [(~+ (list\map annotation$ annotations))]
                 (~+ (list\map method_decl$ members)))))))
 
-(syntax: #export (object
+(syntax: .public (object
                    {class_vars ..vars^}
                    {super (<>.else $Object
                                    (class^ class_vars))}
@@ -1298,12 +1298,12 @@
                 [(~+ (list\map constructor_arg$ constructor_args))]
                 [(~+ (list\map (method_def$ "" (<>.failure "") super (list)) methods))])))))
 
-(syntax: #export (null)
+(syntax: .public (null)
   {#.doc (doc "Null object reference."
               (null))}
   (in (list (` ("jvm object null")))))
 
-(def: #export (null? obj)
+(def: .public (null? obj)
   {#.doc (doc "Test for null object reference."
               (= (null? (null))
                  true)
@@ -1312,7 +1312,7 @@
   (-> (primitive "java.lang.Object") Bit)
   ("jvm object null?" obj))
 
-(syntax: #export (??? expr)
+(syntax: .public (??? expr)
   {#.doc (doc "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it."
               (= (??? (: java/lang/String (null)))
                  #.None)
@@ -1324,7 +1324,7 @@
                      #.None
                      (#.Some (~ g!temp)))))))))
 
-(syntax: #export (!!! expr)
+(syntax: .public (!!! expr)
   {#.doc (doc "Takes a (Maybe ObjectType) and returns a ObjectType."
               "A #.None would get translated into a (null)."
               (= (null)
@@ -1339,7 +1339,7 @@
                    ("jvm object null")}
                   (~ expr)))))))
 
-(syntax: #export (check {class (..type^ (list))}
+(syntax: .public (check {class (..type^ (list))}
                         {unchecked (<>.maybe .any)})
   {#.doc (doc "Checks whether an object is an instance of a particular class."
               "Caveat emptor: Cannot check for polymorphism, so avoid using parameterized classes."
@@ -1366,7 +1366,7 @@
                           (~ check_code))))))
         ))))
 
-(syntax: #export (synchronized lock body)
+(syntax: .public (synchronized lock body)
   {#.doc (doc "Evaluates body, while holding a lock on a given object."
               (synchronized object_to_be_locked
                 (exec (do_something ___)
@@ -1374,7 +1374,7 @@
                   (finish_the_computation ___))))}
   (in (list (` ("jvm object synchronized" (~ lock) (~ body))))))
 
-(syntax: #export (do_to obj {methods (<>.some partial_call^)})
+(syntax: .public (do_to obj {methods (<>.some partial_call^)})
   {#.doc (doc "Call a variety of methods on an object. Then, return the object."
               (do_to object
                 (ClassName::method1 arg0 arg1 arg2)
@@ -1739,7 +1739,7 @@
       (#.Left _)
       (meta.failure (format "Unknown class: " class_name)))))
 
-(syntax: #export (import:
+(syntax: .public (import:
                    {declaration ..declaration^}
                    {.let [[class_name class_type_vars] (parser.declaration declaration)]}
                    {bundles (<>.some (..bundle class_type_vars))})
@@ -1803,7 +1803,7 @@
                   (monad.map ! (member_import$ class_type_vars kind declaration)))]
     (in (list& (class_import$ declaration) (list\join =members)))))
 
-(syntax: #export (array {type (..type^ (list))}
+(syntax: .public (array {type (..type^ (list))}
                         size)
   {#.doc (doc "Create an array of the given type, with the given size."
               (array java/lang/Object 10))}
@@ -1828,7 +1828,7 @@
               (in (list (` (: (~ (value_type #ManualPrM (type.array type)))
                               ("jvm array new object" (~ g!size))))))))))
 
-(exception: #export (cannot_convert_to_jvm_type {type .Type})
+(exception: .public (cannot_convert_to_jvm_type {type .Type})
   (exception.report
    ["Lux Type" (%.type type)]))
 
@@ -1923,7 +1923,7 @@
         _
         ))))
 
-(syntax: #export (array_length array)
+(syntax: .public (array_length array)
   {#.doc (doc "Gives the length of an array."
               (array_length my_array))}
   (case array
@@ -1959,7 +1959,7 @@
       (in (list (` (let [(~ g!array) (~ array)]
                      (..array_length (~ g!array)))))))))
 
-(syntax: #export (array_read idx array)
+(syntax: .public (array_read idx array)
   {#.doc (doc "Loads an element from an array."
               (array_read 10 my_array))}
   (case array
@@ -1997,7 +1997,7 @@
       (in (list (` (let [(~ g!array) (~ array)]
                      (..array_read (~ idx) (~ g!array)))))))))
 
-(syntax: #export (array_write idx value array)
+(syntax: .public (array_write idx value array)
   {#.doc (doc "Stores an element into an array."
               (array_write 10 my_object my_array))}
   (case array
@@ -2036,20 +2036,20 @@
       (in (list (` (let [(~ g!array) (~ array)]
                      (..array_write (~ idx) (~ value) (~ g!array)))))))))
 
-(syntax: #export (class_for {type (..type^ (list))})
+(syntax: .public (class_for {type (..type^ (list))})
   {#.doc (doc "Loads the class as a java.lang.Class object."
               (class_for java/lang/String))}
   (in (list (` ("jvm object class" (~ (code.text (..reflection type))))))))
 
-(syntax: #export (type {type (..type^ (list))})
+(syntax: .public (type {type (..type^ (list))})
   (in (list (..value_type #ManualPrM type))))
 
-(exception: #export (cannot_cast_to_non_object {type (Type Value)})
+(exception: .public (cannot_cast_to_non_object {type (Type Value)})
   (exception.report
    ["Signature" (..signature type)]
    ["Reflection" (..reflection type)]))
 
-(syntax: #export (:cast {type (..type^ (list))}
+(syntax: .public (:cast {type (..type^ (list))}
                         object)
   (case [(parser.array? type)
          (parser.class? type)]
diff --git a/stdlib/source/library/lux/ffi.lua.lux b/stdlib/source/library/lux/ffi.lua.lux
index c004b3145..fc6266d78 100644
--- a/stdlib/source/library/lux/ffi.lua.lux
+++ b/stdlib/source/library/lux/ffi.lua.lux
@@ -23,12 +23,12 @@
      ["." code]
      ["." template]]]])
 
-(abstract: #export (Object brand) Any)
+(abstract: .public (Object brand) Any)
 
 (template []
   [(with_expansions [ (template.identifier [ "'"])]
      (abstract:  Any)
-     (type: #export 
+     (type: .public 
        (..Object )))]
 
   [Nil]
@@ -37,7 +37,7 @@
   )
 
 (template [ ]
-  [(type: #export 
+  [(type: .public 
      )]
 
   [Boolean Bit]
@@ -212,7 +212,7 @@
                      (:as ..Function (~ source))
                      (~+ (list\map (with_nil g!temp) g!inputs)))))))))))
 
-(syntax: #export (import: {import ..import})
+(syntax: .public (import: {import ..import})
   (with_gensyms [g!temp]
     (case import
       (#Class [class format members])
@@ -302,7 +302,7 @@
                                       ("lua constant" (~ (code.text (text.replace_all "/" "." name))))))))))))
       )))
 
-(template: #export (closure  )
+(template: .public (closure  )
   (.:as ..Function
         (`` ("lua function"
              (~~ (template.amount ))
diff --git a/stdlib/source/library/lux/ffi.old.lux b/stdlib/source/library/lux/ffi.old.lux
index 6b8ff867d..d81d48c39 100644
--- a/stdlib/source/library/lux/ffi.old.lux
+++ b/stdlib/source/library/lux/ffi.old.lux
@@ -27,7 +27,7 @@
      ["." annotation]]]])
 
 (template [   ]
-  [(def: #export ( value)
+  [(def: .public ( value)
      {#.doc (doc "Type converter."
                  (: 
                     ( (:  foo))))}
@@ -89,18 +89,18 @@
   #ManualPrM
   #AutoPrM)
 
-(type: #export Privacy
+(type: .public Privacy
   #PublicP
   #PrivateP
   #ProtectedP
   #DefaultP)
 
-(type: #export State
+(type: .public State
   #VolatileS
   #FinalS
   #DefaultS)
 
-(type: #export Inheritance
+(type: .public Inheritance
   #FinalI
   #AbstractI
   #DefaultI)
@@ -1165,7 +1165,7 @@
   {#super_class_name   "java/lang/Object"
    #super_class_params (list)})
 
-(syntax: #export (class:
+(syntax: .public (class:
                    {im inheritance_modifier^}
                    {class_decl ..class_decl^}
                    {.let [full_class_name (product.left class_decl)]}
@@ -1225,7 +1225,7 @@
                                           (with_brackets (spaced (list\map (method_def$ replacer super) methods))))))]]
     (in (list (` ((~ (code.text def_code))))))))
 
-(syntax: #export (interface:
+(syntax: .public (interface:
                    {class_decl ..class_decl^}
                    {.let [class_vars (product.right class_decl)]}
                    {supers (<>.else (list)
@@ -1243,7 +1243,7 @@
     (in (list (` ((~ (code.text def_code))))))
     ))
 
-(syntax: #export (object
+(syntax: .public (object
                    {class_vars (.tuple (<>.some ..type_param^))}
                    {super (<>.else object_super_class
                                    (..super_class_decl^ class_vars))}
@@ -1269,12 +1269,12 @@
                                        (with_brackets (spaced (list\map (method_def$ function.identity super) methods))))))]
     (in (list (` ((~ (code.text def_code))))))))
 
-(syntax: #export (null)
+(syntax: .public (null)
   {#.doc (doc "Null object reference."
               (null))}
   (in (list (` ("jvm object null")))))
 
-(def: #export (null? obj)
+(def: .public (null? obj)
   {#.doc (doc "Test for null object reference."
               (= (null? (null))
                  true)
@@ -1283,7 +1283,7 @@
   (-> (primitive "java.lang.Object") Bit)
   ("jvm object null?" obj))
 
-(syntax: #export (??? expr)
+(syntax: .public (??? expr)
   {#.doc (doc "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it."
               (= (??? (: java/lang/String (null)))
                  #.None)
@@ -1295,7 +1295,7 @@
                      #.None
                      (#.Some (~ g!temp)))))))))
 
-(syntax: #export (!!! expr)
+(syntax: .public (!!! expr)
   {#.doc (doc "Takes a (Maybe ObjectType) and returns a ObjectType."
               "A #.None would get translated into a (null)."
               (= (null)
@@ -1310,7 +1310,7 @@
                    ("jvm object null")}
                   (~ expr)))))))
 
-(syntax: #export (check {class (..generic_type^ (list))}
+(syntax: .public (check {class (..generic_type^ (list))}
                         {unchecked (<>.maybe .any)})
   {#.doc (doc "Checks whether an object is an instance of a particular class."
               "Caveat emptor: Cannot check for polymorphism, so avoid using parameterized classes."
@@ -1337,7 +1337,7 @@
                           (~ check_code))))))
         ))))
 
-(syntax: #export (synchronized lock body)
+(syntax: .public (synchronized lock body)
   {#.doc (doc "Evaluates body, while holding a lock on a given object."
               (synchronized object_to_be_locked
                 (exec (do_something ___)
@@ -1345,7 +1345,7 @@
                   (finish_the_computation ___))))}
   (in (list (` ("jvm object synchronized" (~ lock) (~ body))))))
 
-(syntax: #export (do_to obj {methods (<>.some partial_call^)})
+(syntax: .public (do_to obj {methods (<>.some partial_call^)})
   {#.doc (doc "Call a variety of methods on an object. Then, return the object."
               (do_to object
                 (ClassName::method1 arg0 arg1 arg2)
@@ -1652,7 +1652,7 @@
       (meta.failure (format "Cannot load class: " class_name text.new_line
                             error)))))
 
-(syntax: #export (import:
+(syntax: .public (import:
                    {class_decl ..class_decl^}
                    {bundles (<>.some (..bundle (product.right class_decl)))})
   {#.doc (doc "Allows importing JVM classes, and using them as types."
@@ -1715,7 +1715,7 @@
                   (monad.map ! (member_import$ (product.right class_decl) kind class_decl)))]
     (in (list& (class_import$ class_decl) (list\join =members)))))
 
-(syntax: #export (array {type (..generic_type^ (list))}
+(syntax: .public (array {type (..generic_type^ (list))}
                         size)
   {#.doc (doc "Create an array of the given type, with the given size."
               (array java/lang/Object 10))}
@@ -1735,7 +1735,7 @@
     _
     (in (list (` ("jvm anewarray" (~ (code.text (generic_type$ type))) (~ size)))))))
 
-(syntax: #export (array_length array)
+(syntax: .public (array_length array)
   {#.doc (doc "Gives the length of an array."
               (array_length my_array))}
   (in (list (` ("jvm arraylength" (~ array))))))
@@ -1762,7 +1762,7 @@
       _
       (meta.failure (format "Cannot convert to JvmType: " (type.format type))))))
 
-(syntax: #export (array_read idx array)
+(syntax: .public (array_read idx array)
   {#.doc (doc "Loads an element from an array."
               (array_read 10 my_array))}
   (case array
@@ -1791,7 +1791,7 @@
       (in (list (` (let [(~ g!array) (~ array)]
                      (..array_read (~ idx) (~ g!array)))))))))
 
-(syntax: #export (array_write idx value array)
+(syntax: .public (array_write idx value array)
   {#.doc (doc "Stores an element into an array."
               (array_write 10 my_object my_array))}
   (case array
@@ -1820,10 +1820,10 @@
       (in (list (` (let [(~ g!array) (~ array)]
                      (..array_write (~ idx) (~ value) (~ g!array)))))))))
 
-(syntax: #export (class_for {type (..generic_type^ (list))})
+(syntax: .public (class_for {type (..generic_type^ (list))})
   {#.doc (doc "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: #export (type {type (..generic_type^ (list))})
+(syntax: .public (type {type (..generic_type^ (list))})
   (in (list (..class_type #ManualPrM (list) type))))
diff --git a/stdlib/source/library/lux/ffi.php.lux b/stdlib/source/library/lux/ffi.php.lux
index a8f0a7f06..114dfce7b 100644
--- a/stdlib/source/library/lux/ffi.php.lux
+++ b/stdlib/source/library/lux/ffi.php.lux
@@ -23,12 +23,12 @@
      ["." code]
      ["." template]]]])
 
-(abstract: #export (Object brand) Any)
+(abstract: .public (Object brand) Any)
 
 (template []
   [(with_expansions [ (template.identifier [ "'"])]
-     (abstract: #export  Any)
-     (type: #export 
+     (abstract: .public  Any)
+     (type: .public 
        (..Object )))]
 
   [Null]
@@ -36,7 +36,7 @@
   )
 
 (template [ ]
-  [(type: #export 
+  [(type: .public 
      )]
 
   [Boolean Bit]
@@ -182,7 +182,7 @@
       ..constant
       ))
 
-(syntax: #export (try expression)
+(syntax: .public (try expression)
   {#.doc (doc (case (try (risky_computation input))
                 (#.Right success)
                 (do_something success)
@@ -232,7 +232,7 @@
                      (:as ..Function (~ source))
                      (~+ (list\map (with_null g!temp) g!inputs)))))))))))
 
-(syntax: #export (import: {import ..import})
+(syntax: .public (import: {import ..import})
   (with_gensyms [g!temp]
     (case import
       (#Class [class alias format members])
diff --git a/stdlib/source/library/lux/ffi.py.lux b/stdlib/source/library/lux/ffi.py.lux
index 5c05710a7..d1a81dc6a 100644
--- a/stdlib/source/library/lux/ffi.py.lux
+++ b/stdlib/source/library/lux/ffi.py.lux
@@ -23,12 +23,12 @@
      ["." code]
      ["." template]]]])
 
-(abstract: #export (Object brand) Any)
+(abstract: .public (Object brand) Any)
 
 (template []
   [(with_expansions [ (template.identifier [ "'"])]
      (abstract:  Any)
-     (type: #export 
+     (type: .public 
        (..Object )))]
 
   [None]
@@ -37,7 +37,7 @@
   )
 
 (template [ ]
-  [(type: #export 
+  [(type: .public 
      )]
 
   [Boolean Bit]
@@ -212,7 +212,7 @@
                      (:as ..Function (~ source))
                      (~+ (list\map (with_none g!temp) g!inputs)))))))))))
 
-(syntax: #export (import: {import ..import})
+(syntax: .public (import: {import ..import})
   (with_gensyms [g!temp]
     (case import
       (#Class [class format members])
@@ -307,7 +307,7 @@
                                  outputT)))
       )))
 
-(template: #export (lambda  )
+(template: .public (lambda  )
   (.:as ..Function
         (`` ("python function"
              (~~ (template.amount ))
diff --git a/stdlib/source/library/lux/ffi.rb.lux b/stdlib/source/library/lux/ffi.rb.lux
index 70c2f21be..dfb8aabc4 100644
--- a/stdlib/source/library/lux/ffi.rb.lux
+++ b/stdlib/source/library/lux/ffi.rb.lux
@@ -23,12 +23,12 @@
      ["." code]
      ["." template]]]])
 
-(abstract: #export (Object brand) Any)
+(abstract: .public (Object brand) Any)
 
 (template []
   [(with_expansions [ (template.identifier [ "'"])]
      (abstract:  Any)
-     (type: #export 
+     (type: .public 
        (..Object )))]
 
   [Nil]
@@ -36,7 +36,7 @@
   )
 
 (template [ ]
-  [(type: #export 
+  [(type: .public 
      )]
 
   [Boolean Bit]
@@ -225,7 +225,7 @@
                      (:as ..Function (~ source))
                      (~+ (list\map (with_nil g!temp) g!inputs)))))))))))
 
-(syntax: #export (import: {[?module import] ..import})
+(syntax: .public (import: {[?module import] ..import})
   (with_gensyms [g!temp]
     (case import
       (#Class [class alias format members])
diff --git a/stdlib/source/library/lux/ffi.scm.lux b/stdlib/source/library/lux/ffi.scm.lux
index 886f045d1..85f3f560a 100644
--- a/stdlib/source/library/lux/ffi.scm.lux
+++ b/stdlib/source/library/lux/ffi.scm.lux
@@ -23,12 +23,12 @@
      ["." code]
      ["." template]]]])
 
-(abstract: #export (Object brand) Any)
+(abstract: .public (Object brand) Any)
 
 (template []
   [(with_expansions [ (template.identifier [ "'"])]
-     (abstract: #export  Any)
-     (type: #export 
+     (abstract: .public  Any)
+     (type: .public 
        (..Object )))]
 
   [Nil]
@@ -36,7 +36,7 @@
   )
 
 (template [ ]
-  [(type: #export 
+  [(type: .public 
      )]
 
   [Boolean Bit]
@@ -149,7 +149,7 @@
       ..constant
       ))
 
-(syntax: #export (try expression)
+(syntax: .public (try expression)
   {#.doc (doc (case (try (risky_computation input))
                 (#.Right success)
                 (do_something success)
@@ -199,7 +199,7 @@
                      (:as ..Function (~ source))
                      (~+ (list\map (with_nil g!temp) g!inputs)))))))))))
 
-(syntax: #export (import: {import ..import})
+(syntax: .public (import: {import ..import})
   (with_gensyms [g!temp]
     (case import
       (#Function [name alias inputsT io? try? outputT])
diff --git a/stdlib/source/library/lux/locale.lux b/stdlib/source/library/lux/locale.lux
index e77e88c89..512d214c6 100644
--- a/stdlib/source/library/lux/locale.lux
+++ b/stdlib/source/library/lux/locale.lux
@@ -15,13 +15,15 @@
    ["." language (#+ Language)]
    ["." territory (#+ Territory)]])
 
-(abstract: #export Locale
+(abstract: .public Locale
+  {}
+  
   Text
 
   (def: territory_separator "_")
   (def: encoding_separator ".")
 
-  (def: #export (locale language territory encoding)
+  (def: .public (locale language territory encoding)
     (-> Language (Maybe Territory) (Maybe Encoding) Locale)
     (:abstraction (format (language.code language)
                           (|> territory
@@ -31,15 +33,15 @@
                               (maybe\map (|>> encoding.name (format ..encoding_separator)))
                               (maybe.else "")))))
 
-  (def: #export code
+  (def: .public code
     (-> Locale Text)
     (|>> :representation))
 
-  (def: #export hash
+  (def: .public hash
     (Hash Locale)
     (\ hash.functor map ..code text.hash))
 
-  (def: #export equivalence
+  (def: .public equivalence
     (Equivalence Locale)
     (\ ..hash &equivalence))
   )
diff --git a/stdlib/source/library/lux/locale/language.lux b/stdlib/source/library/lux/locale/language.lux
index 4933a97a6..cf6b38e99 100644
--- a/stdlib/source/library/lux/locale/language.lux
+++ b/stdlib/source/library/lux/locale/language.lux
@@ -12,14 +12,14 @@
      ["." template]]]])
 
 ## https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes
-(abstract: #export Language
+(abstract: .public Language
+  {#.doc (doc "An ISO 639 language.")}
+
   {#name Text
    #code Text}
 
-  {#.doc (doc "An ISO 639 language.")}
-
   (template [ ]
-    [(def: #export 
+    [(def: .public 
        (-> Language Text)
        (|>> :representation (get@ )))]
 
@@ -30,12 +30,12 @@
   (template []
     [(with_expansions [' (template.spliced )]
        (template [   +]
-         [(def: #export 
+         [(def: .public 
             Language
             (:abstraction {#name 
                            #code }))
           (`` (template []
-                [(def: #export 
+                [(def: .public 
                    Language
                    )]
 
@@ -557,13 +557,13 @@
       ["zun" "Zuni" zuni []]
       ["zza" "Zaza; Dimili; Dimli; Kirdki; Kirmanjki; Zazaki" zaza [[dimili] [dimli] [kirdki] [kirmanjki] [zazaki]]]]])
 
-  (implementation: #export equivalence
+  (implementation: .public equivalence
     (Equivalence Language)
     
     (def: (= reference sample)
       (is? reference sample)))
 
-  (implementation: #export hash
+  (implementation: .public hash
     (Hash Language)
     
     (def: &equivalence
diff --git a/stdlib/source/library/lux/locale/territory.lux b/stdlib/source/library/lux/locale/territory.lux
index 15ac79698..862c10bb6 100644
--- a/stdlib/source/library/lux/locale/territory.lux
+++ b/stdlib/source/library/lux/locale/territory.lux
@@ -12,16 +12,16 @@
      ["." template]]]])
 
 ## https://en.wikipedia.org/wiki/ISO_3166-1
-(abstract: #export Territory
+(abstract: .public Territory
+  {#.doc (doc "An ISO 3166 territory.")}
+
   {#name Text
    #short Text
    #long Text
    #code Nat}
 
-  {#.doc (doc "An ISO 3166 territory.")}
-
   (template [  ]
-    [(def: #export 
+    [(def: .public 
        (-> Territory )
        (|>> :representation
             (get@ )))]
@@ -33,7 +33,7 @@
     )
 
   (template [    
+] - [(def: #export
+ [(def: .public
Territory (:abstraction {#name #short @@ -41,7 +41,7 @@ #code })) (`` (template [] - [(def: #export Territory
)] + [(def: .public Territory
)] (~~ (template.spliced +))))] @@ -296,13 +296,13 @@ ["ZW" "ZWE" 716 "Zimbabwe" zimbabwe []] ) - (implementation: #export equivalence + (implementation: .public equivalence (Equivalence Territory) (def: (= reference sample) (is? reference sample))) - (implementation: #export hash + (implementation: .public hash (Hash Territory) (def: &equivalence ..equivalence) diff --git a/stdlib/source/library/lux/macro.lux b/stdlib/source/library/lux/macro.lux index 91025dcaf..193b5a25e 100644 --- a/stdlib/source/library/lux/macro.lux +++ b/stdlib/source/library/lux/macro.lux @@ -18,7 +18,7 @@ ["#" meta ["." location]]]) -(def: #export (single_expansion syntax) +(def: .public (single_expansion syntax) {#.doc (doc "Given code that requires applying a macro, does it once and returns the result." "Otherwise, returns the code as-is.")} (-> Code (Meta (List Code))) @@ -36,7 +36,7 @@ _ (\ //.monad in (list syntax)))) -(def: #export (expansion syntax) +(def: .public (expansion syntax) {#.doc (doc "Given code that requires applying a macro, expands repeatedly until no more direct macro-calls are left." "Otherwise, returns the code as-is.")} (-> Code (Meta (List Code))) @@ -58,7 +58,7 @@ _ (\ //.monad in (list syntax)))) -(def: #export (full_expansion syntax) +(def: .public (full_expansion syntax) {#.doc "Expands all macro-calls everywhere recursively, until only primitive/base code remains."} (-> Code (Meta (List Code))) (case syntax @@ -106,7 +106,7 @@ _ (\ //.monad in (list syntax)))) -(def: #export (gensym prefix) +(def: .public (gensym prefix) {#.doc (doc "Generates a unique name as an Code node (ready to be used in code templates)." "A prefix can be given (or just be empty text) to better identify the code for debugging purposes.")} (-> Text (Meta Code)) @@ -126,14 +126,14 @@ _ (//.failure (text\compose "Code is not a local identifier: " (code.format ast))))) -(def: #export wrong_syntax_error +(def: .public wrong_syntax_error (-> Name Text) (|>> name\encode (text\compose "Wrong syntax for "))) -(macro: #export (with_gensyms tokens) +(macro: .public (with_gensyms tokens) {#.doc (doc "Creates new identifiers and offers them to the body expression." - (syntax: #export (synchronized lock body) + (syntax: .public (synchronized lock body) (with_gensyms [g!lock g!body g!_] (in (list (` (let [(~ g!lock) (~ lock) (~ g!_) ("jvm monitorenter" (~ g!lock)) @@ -155,7 +155,7 @@ _ (//.failure (..wrong_syntax_error (name_of ..with_gensyms))))) -(def: #export (one_expansion token) +(def: .public (one_expansion token) {#.doc "Works just like expand, except that it ensures that the output is a single Code token."} (-> Code (Meta Code)) (do //.monad @@ -168,7 +168,7 @@ (//.failure "Macro expanded to more than 1 element.")))) (template [ ] - [(macro: #export ( tokens) + [(macro: .public ( tokens) {#.doc (doc "Performs a macro-expansion and logs the resulting code." "You can either use the resulting code, or omit them." "By omitting them, this macro produces nothing (just like the lux.comment macro)." diff --git a/stdlib/source/library/lux/macro/code.lux b/stdlib/source/library/lux/macro/code.lux index ec99f68a4..916e82dee 100644 --- a/stdlib/source/library/lux/macro/code.lux +++ b/stdlib/source/library/lux/macro/code.lux @@ -36,7 +36,7 @@ ## (Ann Location (Code' (Ann Location)))) (template [ ] - [(def: #export ( x) + [(def: .public ( x) (-> Code) [location.dummy ( x)])] @@ -54,7 +54,7 @@ ) (template [ ] - [(def: #export ( name) + [(def: .public ( name) {#.doc } (-> Text Code) [location.dummy ( ["" name])])] @@ -62,7 +62,7 @@ [local_identifier #.Identifier "Produces a local identifier (an identifier with no module prefix)."] [local_tag #.Tag "Produces a local tag (a tag with no module prefix)."]) -(implementation: #export equivalence +(implementation: .public equivalence (Equivalence Code) (def: (= x y) @@ -92,7 +92,7 @@ _ false))) -(def: #export (format ast) +(def: .public (format ast) (-> Code Text) (case ast (^template [ ] @@ -139,7 +139,7 @@ "}") )) -(def: #export (replace original substitute ast) +(def: .public (replace original substitute ast) {#.doc "Replaces all code that looks like the 'original' with the 'substitute'."} (-> Code Code Code Code) (if (\ ..equivalence = original ast) diff --git a/stdlib/source/library/lux/macro/local.lux b/stdlib/source/library/lux/macro/local.lux index f6dcb0590..8a4360ac7 100644 --- a/stdlib/source/library/lux/macro/local.lux +++ b/stdlib/source/library/lux/macro/local.lux @@ -17,12 +17,12 @@ ["." // ["#." code]]) -(exception: #export (unknown_module {module Text}) +(exception: .public (unknown_module {module Text}) (exception.report ["Module" (text.format module)])) (template [] - [(exception: #export ( {module Text} {definition Text}) + [(exception: .public ( {module Text} {definition Text}) (exception.report ["Module" (text.format module)] ["Definition" (text.format definition)]))] @@ -95,7 +95,7 @@ #.None (list))))))) -(def: #export (push macros) +(def: .public (push macros) (-> (List [Name Macro]) (Meta Code)) (do meta.monad [_ (monad.map meta.monad ..push_one macros) diff --git a/stdlib/source/library/lux/macro/poly.lux b/stdlib/source/library/lux/macro/poly.lux index f89f7568c..535c8236f 100644 --- a/stdlib/source/library/lux/macro/poly.lux +++ b/stdlib/source/library/lux/macro/poly.lux @@ -6,9 +6,9 @@ [abstract ["." monad (#+ do)]] [control - ["<>" parser + ["<>" parser ("#\." monad) ["<.>" type (#+ Env)] - ["<.>" code]]] + ["<.>" code (#+ Parser)]]] [data ["." product] ["." maybe] @@ -18,18 +18,23 @@ ["." dictionary]]] [macro (#+ with_gensyms) ["." code] - [syntax (#+ syntax:) - ["|.|" export]]] + [syntax (#+ syntax:)]] [math [number ["n" nat]]]]]) -(syntax: #export (poly: {export |export|.parser} - {name .local_identifier} - body) +(def: polyP + (Parser [Code Text Code]) + (let [private ($_ <>.and + .local_identifier + .any)] + (<>.either (<>.and .any private) + (<>.and (<>\in (` .private)) private)))) + +(syntax: .public (poly: {[export_policy name body] ..polyP}) (with_gensyms [g!_ g!type g!output] (let [g!name (code.identifier ["" name])] - (in (.list (` ((~! syntax:) (~+ (|export|.format export)) ((~ g!name) {(~ g!type) (~! .identifier)}) + (in (.list (` ((~! syntax:) (~ export_policy) ((~ g!name) {(~ g!type) (~! .identifier)}) ((~! do) (~! meta.monad) [(~ g!type) ((~! meta.type_definition) (~ g!type))] (case (: (.Either .Text .Code) @@ -43,45 +48,30 @@ (#.Right (~ g!output)) ((~' in) (.list (~ g!output)))))))))))) -(def: (common_poly_name? poly_func) - (-> Text Bit) - (text.contains? "?" poly_func)) - -(def: (derivation_name poly args) - (-> Text (List Text) (Maybe Text)) - (if (common_poly_name? poly) - (#.Some (list\fold (text.replace_once "?") poly args)) - #.None)) +(def: derivedP + (Parser [Code Text [Name (List Name)] (Maybe Code)]) + (let [private ($_ <>.and + .local_identifier + (.form (<>.and .identifier (<>.many .identifier))) + (<>.maybe .any))] + (<>.either (<>.and .any private) + (<>.and (<>\in (` .private)) private)))) -(syntax: #export (derived: {export |export|.parser} - {?name (<>.maybe .local_identifier)} - {[poly_func poly_args] (.form (<>.and .identifier (<>.many .identifier)))} - {?custom_impl (<>.maybe .any)}) +(syntax: .public (derived: {[export_policy name [poly_func poly_args] ?custom_impl] + ..derivedP}) (do {! meta.monad} [poly_args (monad.map ! meta.normal poly_args) - name (case ?name - (#.Some name) - (in name) - - (^multi #.None - {(derivation_name (product.right poly_func) (list\map product.right poly_args)) - (#.Some derived_name)}) - (in derived_name) - - _ - (<>.failure "derived: was given no explicit name, and cannot generate one from given information.")) .let [impl (case ?custom_impl (#.Some custom_impl) custom_impl #.None (` ((~ (code.identifier poly_func)) (~+ (list\map code.identifier poly_args)))))]] - (in (.list (` (def: (~+ (|export|.format export)) - (~ (code.identifier ["" name])) + (in (.list (` (def: (~ export_policy) (~ (code.identifier ["" name])) {#.implementation? #1} (~ impl))))))) -(def: #export (code env type) +(def: .public (code env type) (-> Env Type Code) (`` (case type (#.Primitive name params) diff --git a/stdlib/source/library/lux/macro/syntax.lux b/stdlib/source/library/lux/macro/syntax.lux index 99bb28c0e..2689d68f3 100644 --- a/stdlib/source/library/lux/macro/syntax.lux +++ b/stdlib/source/library/lux/macro/syntax.lux @@ -41,12 +41,12 @@ #.End #.End (#.Item [[x y] pairs']) (list& x y (un_paired pairs')))) -(macro: #export (syntax: tokens) +(macro: .public (syntax: tokens) {#.doc (doc "A more advanced way to define macros than 'macro:'." "The inputs to the macro can be parsed in complex ways through the use of syntax parsers." "The macro body is also (implicitly) run in the Meta monad, to save some typing." "Also, the compiler state can be accessed through the *compiler* binding." - (syntax: #export (object {.let [imports (class_imports *compiler*)]} + (syntax: .public (object {.let [imports (class_imports *compiler*)]} {.let [class_vars (list)]} {super (opt (super_class_decl^ imports class_vars))} {interfaces (tuple (some (super_class_decl^ imports class_vars)))} @@ -58,28 +58,32 @@ (with_brackets (spaced (list\map constructor_arg$ constructor_args))) (with_brackets (spaced (list\map (method_def$ id) methods))))))] (in (list (` ((~ (code.text def_code)))))))))} - (let [[exported? tokens] (: [Bit (List Code)] - (case tokens - (^ (list& [_ (#.Tag ["" "export"])] tokens')) - [#1 tokens'] - - _ - [#0 tokens])) - ?parts (: (Maybe [Text (List Code) Code Code]) + (let [?parts (: (Maybe [Code Text (List Code) Code Code]) (case tokens + (^ (list export_policy + [_ (#.Form (list& [_ (#.Identifier ["" name])] args))] + body)) + (#.Some [export_policy name args (` {}) body]) + + (^ (list export_policy + [_ (#.Form (list& [_ (#.Identifier ["" name])] args))] + meta_data + body)) + (#.Some [export_policy name args meta_data body]) + (^ (list [_ (#.Form (list& [_ (#.Identifier ["" name])] args))] body)) - (#.Some name args (` {}) body) + (#.Some [(` .private) name args (` {}) body]) (^ (list [_ (#.Form (list& [_ (#.Identifier ["" name])] args))] meta_data body)) - (#.Some name args meta_data body) + (#.Some [(` .private) name args meta_data body]) _ #.None))] (case ?parts - (#.Some [name args meta body]) + (#.Some [export_policy name args meta body]) (with_gensyms [g!tokens g!body g!error] (do {! meta.monad} [vars+parsers (monad.map ! @@ -110,12 +114,8 @@ args) this_module meta.current_module_name .let [g!state (code.identifier ["" "*compiler*"]) - error_msg (code.text (macro.wrong_syntax_error [this_module name])) - export_ast (: (List Code) - (if exported? - (list (' #export)) - (list)))]] - (in (list (` (macro: (~+ export_ast) ((~ (code.identifier ["" name])) (~ g!tokens) (~ g!state)) + error_msg (code.text (macro.wrong_syntax_error [this_module name]))]] + (in (list (` (macro: (~ export_policy) ((~ (code.identifier ["" name])) (~ g!tokens) (~ g!state)) (~ meta) ({(#.Right (~ g!body)) ((~ g!body) (~ g!state)) diff --git a/stdlib/source/library/lux/macro/syntax/annotations.lux b/stdlib/source/library/lux/macro/syntax/annotations.lux index 73738ebc5..88d43f03d 100644 --- a/stdlib/source/library/lux/macro/syntax/annotations.lux +++ b/stdlib/source/library/lux/macro/syntax/annotations.lux @@ -15,27 +15,27 @@ [macro ["." code]]]]) -(type: #export Annotations +(type: .public Annotations {#.doc (doc "Definition/module annotations.")} (List [Name Code])) -(def: #export equivalence +(def: .public equivalence (Equivalence Annotations) (list.equivalence (product.equivalence name.equivalence code.equivalence))) -(def: #export empty +(def: .public empty Annotations (list)) -(def: #export format +(def: .public format (-> Annotations Code) (let [entry (product.apply code.tag function.identity)] (|>> (list\map entry) code.record))) -(def: #export parser +(def: .public parser (Parser Annotations) (.record (<>.some diff --git a/stdlib/source/library/lux/macro/syntax/check.lux b/stdlib/source/library/lux/macro/syntax/check.lux index 2e60ed0cc..c55f6f233 100644 --- a/stdlib/source/library/lux/macro/syntax/check.lux +++ b/stdlib/source/library/lux/macro/syntax/check.lux @@ -17,25 +17,25 @@ (def: extension "lux check") -(type: #export Check +(type: .public Check {#.doc (doc "A type annotation for an expression.")} {#type Code #value Code}) -(def: #export equivalence +(def: .public equivalence (Equivalence Check) ($_ product.equivalence code.equivalence code.equivalence )) -(def: #export (format (^slots [#type #value])) +(def: .public (format (^slots [#type #value])) (-> Check Code) (` ((~ (code.text ..extension)) (~ type) (~ value)))) -(def: #export parser +(def: .public parser (Parser Check) (<| .form (<>.after (.text! ..extension)) diff --git a/stdlib/source/library/lux/macro/syntax/declaration.lux b/stdlib/source/library/lux/macro/syntax/declaration.lux index 429368764..158bb618f 100644 --- a/stdlib/source/library/lux/macro/syntax/declaration.lux +++ b/stdlib/source/library/lux/macro/syntax/declaration.lux @@ -14,19 +14,19 @@ [macro ["." code]]]]) -(type: #export Declaration +(type: .public Declaration {#.doc (doc "A declaration for either a constant or a function.")} {#name Text #arguments (List Text)}) -(def: #export equivalence +(def: .public equivalence (Equivalence Declaration) ($_ product.equivalence text.equivalence (list.equivalence text.equivalence) )) -(def: #export parser +(def: .public parser {#.doc (doc "A parser for declaration syntax." "Such as:" quux @@ -37,7 +37,7 @@ (.form (<>.and .local_identifier (<>.some .local_identifier))))) -(def: #export (format value) +(def: .public (format value) (-> Declaration Code) (let [g!name (code.local_identifier (get@ #name value))] (case (get@ #arguments value) diff --git a/stdlib/source/library/lux/macro/syntax/definition.lux b/stdlib/source/library/lux/macro/syntax/definition.lux index 4ad19d041..eeefc3074 100644 --- a/stdlib/source/library/lux/macro/syntax/definition.lux +++ b/stdlib/source/library/lux/macro/syntax/definition.lux @@ -25,7 +25,7 @@ ["#." annotations (#+ Annotations)] ["#." check (#+ Check)]]) -(type: #export Definition +(type: .public Definition {#.doc (doc "Syntax for a constant definition.")} {#name Text #value (Either Check @@ -33,7 +33,7 @@ #anns Annotations #export? Bit}) -(def: #export equivalence +(def: .public equivalence (Equivalence Definition) ($_ product.equivalence text.equivalence @@ -70,7 +70,7 @@ #.line (~ (code.nat (get@ #.line location.dummy))) #.column (~ (code.nat (get@ #.column location.dummy)))})) -(def: #export (format (^slots [#name #value #anns #export?])) +(def: .public (format (^slots [#name #value #anns #export?])) (-> Definition Code) (` ((~ (code.text ..extension)) (~ (code.local_identifier name)) @@ -100,7 +100,7 @@ (in [head tail]))) )))) -(def: #export (parser compiler) +(def: .public (parser compiler) {#.doc "A reader that first macro-expands and then analyses the input Code, to ensure it is a definition."} (-> Lux (Parser Definition)) (do {! <>.monad} @@ -124,11 +124,11 @@ .bit )))) -(exception: #export (lacks_type! {definition Definition}) +(exception: .public (lacks_type! {definition Definition}) (exception.report ["Definition" (%.code (..format definition))])) -(def: #export (typed compiler) +(def: .public (typed compiler) {#.doc "Only works for typed definitions."} (-> Lux (Parser Definition)) (do <>.monad diff --git a/stdlib/source/library/lux/macro/syntax/export.lux b/stdlib/source/library/lux/macro/syntax/export.lux index f1e3c7a0f..03f96a2a0 100644 --- a/stdlib/source/library/lux/macro/syntax/export.lux +++ b/stdlib/source/library/lux/macro/syntax/export.lux @@ -9,13 +9,13 @@ (def: token (' #export)) -(def: #export (format exported?) +(def: .public (format exported?) (-> Bit (List Code)) (if exported? (list ..token) (list))) -(def: #export parser +(def: .public parser (Parser Bit) (<>.either (<>.after (.this! ..token) (<>\in true)) diff --git a/stdlib/source/library/lux/macro/syntax/input.lux b/stdlib/source/library/lux/macro/syntax/input.lux index c8630283e..d577d68e3 100644 --- a/stdlib/source/library/lux/macro/syntax/input.lux +++ b/stdlib/source/library/lux/macro/syntax/input.lux @@ -11,25 +11,25 @@ [macro ["." code]]]]) -(type: #export Input +(type: .public Input {#.doc (doc "The common typed-argument syntax used by many macros.")} {#binding Code #type Code}) -(def: #export equivalence +(def: .public equivalence (Equivalence Input) ($_ product.equivalence code.equivalence code.equivalence )) -(def: #export (format value) +(def: .public (format value) (-> Input Code) (code.record (list [(get@ #binding value) (get@ #type value)]))) -(def: #export parser +(def: .public parser {#.doc "Parser for the common typed-argument syntax used by many macros."} (Parser Input) (.record diff --git a/stdlib/source/library/lux/macro/syntax/type/variable.lux b/stdlib/source/library/lux/macro/syntax/type/variable.lux index a2e710e4d..09dbdcd62 100644 --- a/stdlib/source/library/lux/macro/syntax/type/variable.lux +++ b/stdlib/source/library/lux/macro/syntax/type/variable.lux @@ -11,19 +11,19 @@ [macro ["." code]]]]) -(type: #export Variable +(type: .public Variable {#.doc (doc "A variable'S name.")} Text) -(def: #export equivalence +(def: .public equivalence (Equivalence Variable) text.equivalence) -(def: #export format +(def: .public format (-> Variable Code) code.local_identifier) -(def: #export parser +(def: .public parser {#.doc "Parser for the common type variable/parameter used by many macros."} (Parser Variable) .local_identifier) diff --git a/stdlib/source/library/lux/macro/template.lux b/stdlib/source/library/lux/macro/template.lux index 09204ce76..c8a211113 100644 --- a/stdlib/source/library/lux/macro/template.lux +++ b/stdlib/source/library/lux/macro/template.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- let) + [lux (#- let local) ["." meta] [abstract ["." monad (#+ do)]] @@ -26,13 +26,13 @@ ["." code] ["." local]]) -(syntax: #export (spliced {parts (.tuple (<>.some .any))}) +(syntax: .public (spliced {parts (.tuple (<>.some .any))}) (in parts)) -(syntax: #export (amount {parts (.tuple (<>.some .any))}) +(syntax: .public (amount {parts (.tuple (<>.some .any))}) (in (list (code.nat (list.size parts))))) -(syntax: #export (with_locals {locals (.tuple (<>.some .local_identifier))} +(syntax: .public (with_locals {locals (.tuple (<>.some .local_identifier))} body) (do {! meta.monad} [g!locals (|> locals @@ -79,11 +79,11 @@ (-> Bit (Parser (List Text))) (.tuple (<>.many (..snippet module_side?)))) -(syntax: #export (text {simple (..part false)}) +(syntax: .public (text {simple (..part false)}) (in (list (|> simple (text.join_with "") code.text)))) (template [ ] - [(syntax: #export ( {name (<>.or (<>.and (..part true) (..part false)) + [(syntax: .public ( {name (<>.or (<>.and (..part true) (..part false)) (..part false))}) (case name (#.Left [simple complex]) @@ -132,7 +132,7 @@ #parameters (List Text) #template (List Code)}) -(exception: #export (irregular_arguments {expected Nat} {actual Nat}) +(exception: .public (irregular_arguments {expected Nat} {actual Nat}) (exception.report ["Expected" (\ nat.decimal encode expected)] ["Actual" (\ nat.decimal encode actual)])) @@ -160,7 +160,7 @@ #parameters parameters #template template}))) -(syntax: #export (let {locals (.tuple (<>.some ..local))} +(syntax: .public (let {locals (.tuple (<>.some ..local))} body) (do meta.monad [here_name meta.current_module_name diff --git a/stdlib/source/library/lux/math.lux b/stdlib/source/library/lux/math.lux index 65c3c01d0..8a7c9feff 100644 --- a/stdlib/source/library/lux/math.lux +++ b/stdlib/source/library/lux/math.lux @@ -8,18 +8,20 @@ ["i" int]]]]]) (template [ ] - [(def: #export + [(def: .public {#.doc } )] [e +2.7182818284590452354 "The base of the natural logarithm."] + ## ["Ï€ is wrong!" by Bob Palais](https://www.math.utah.edu/~palais/pi.html) [pi +3.14159265358979323846 "The ratio of a circle's circumference to its diameter."] + ## [The Tau Manifesto](https://tauday.com/tau-manifesto) [tau +6.28318530717958647692 "The ratio of a circle's circumference to its radius."] ) (for {@.old (as_is (template [ ] - [(def: #export ( input) + [(def: .public ( input) (-> Frac Frac) ( input))] @@ -40,24 +42,24 @@ [root/2 "jvm invokestatic:java.lang.Math:sqrt:double"] [root/3 "jvm invokestatic:java.lang.Math:cbrt:double"] ) - (def: #export (pow param subject) + (def: .public (pow param subject) (-> Frac Frac Frac) ("jvm invokestatic:java.lang.Math:pow:double,double" subject param))) @.jvm (as_is (template: (!double value) - (|> value - (:as (primitive "java.lang.Double")) - "jvm object cast")) + [(|> value + (:as (primitive "java.lang.Double")) + "jvm object cast")]) (template: (!frac value) - (|> value - "jvm object cast" - (: (primitive "java.lang.Double")) - (:as Frac))) + [(|> value + "jvm object cast" + (: (primitive "java.lang.Double")) + (:as Frac))]) (template [ ] - [(def: #export + [(def: .public (-> Frac Frac) (|>> !double ["D"] @@ -82,7 +84,7 @@ [root/3 "cbrt"] ) - (def: #export (pow param subject) + (def: .public (pow param subject) (-> Frac Frac Frac) (|> ("jvm member invoke static" [] "java.lang.Math" "pow" [] ["D" (!double subject)] ["D" (!double param)]) @@ -90,7 +92,7 @@ @.js (as_is (template [ ] - [(def: #export + [(def: .public (-> Frac Frac) (|>> ("js apply" ("js constant" )) (:as Frac)))] @@ -113,13 +115,13 @@ [root/3 "Math.cbrt"] ) - (def: #export (pow param subject) + (def: .public (pow param subject) (-> Frac Frac Frac) (:as Frac ("js apply" ("js constant" "Math.pow") subject param)))) @.python (as_is (template [ ] - [(def: #export + [(def: .public (-> Frac Frac) (|>> ("python object do" ("python import" "math")) (:as Frac)))] @@ -141,17 +143,17 @@ [root/2 "sqrt"] ) - (def: #export (pow param subject) + (def: .public (pow param subject) (-> Frac Frac Frac) (:as Frac ("python object do" "pow" ("python import" "math") subject param))) - (def: #export root/3 + (def: .public root/3 (-> Frac Frac) (..pow ("lux f64 /" +3.0 +1.0)))) @.lua (as_is (template [ ] - [(def: #export + [(def: .public (-> Frac Frac) (|>> ("lua apply" ("lua constant" )) (:as Frac)))] @@ -173,17 +175,17 @@ [root/2 "math.sqrt"] ) - (def: #export (pow param subject) + (def: .public (pow param subject) (-> Frac Frac Frac) ("lua power" param subject)) - (def: #export root/3 + (def: .public root/3 (-> Frac Frac) (..pow ("lux f64 /" +3.0 +1.0)))) @.ruby (as_is (template [ ] - [(def: #export + [(def: .public (-> Frac Frac) (|>> ("ruby apply" ("ruby constant" )) (:as Frac)))] @@ -204,7 +206,7 @@ ) (template [ ] - [(def: #export + [(def: .public (-> Frac Frac) (|>> ("ruby object do" ) (:as Int) @@ -214,13 +216,13 @@ [floor "floor"] ) - (def: #export (pow param subject) + (def: .public (pow param subject) (-> Frac Frac Frac) (:as Frac ("ruby object do" "**" subject param)))) @.php (as_is (template [ ] - [(def: #export + [(def: .public (-> Frac Frac) (|>> ("php apply" ("php constant" )) (:as Frac)))] @@ -242,17 +244,17 @@ [root/2 "sqrt"] ) - (def: #export (pow param subject) + (def: .public (pow param subject) (-> Frac Frac Frac) (:as Frac ("php apply" ("php constant" "pow") subject param))) - (def: #export root/3 + (def: .public root/3 (-> Frac Frac) (..pow ("lux f64 /" +3.0 +1.0)))) @.scheme (as_is (template [ ] - [(def: #export + [(def: .public (-> Frac Frac) (|>> ("scheme apply" ("scheme constant" )) (:as Frac)))] @@ -274,16 +276,16 @@ [root/2 "sqrt"] ) - (def: #export (pow param subject) + (def: .public (pow param subject) (-> Frac Frac Frac) (:as Frac ("scheme apply" ("scheme constant" "expt") subject param))) - (def: #export root/3 + (def: .public root/3 (-> Frac Frac) (..pow ("lux f64 /" +3.0 +1.0)))) }) -(def: #export (round input) +(def: .public (round input) (-> Frac Frac) (let [floored (floor input) diff ("lux f64 -" floored input)] @@ -296,7 +298,7 @@ ## else floored))) -(def: #export (atan/2 x y) +(def: .public (atan/2 x y) (-> Frac Frac Frac) (cond ("lux f64 <" x +0.0) (..atan ("lux f64 /" x y)) @@ -317,13 +319,13 @@ ## ("lux f64 =" +0.0 y) ("lux f64 /" +0.0 +0.0)))) -(def: #export (log' base input) +(def: .public (log' base input) (-> Frac Frac Frac) ("lux f64 /" (..log base) (..log input))) -(def: #export (factorial n) +(def: .public (factorial n) (-> Nat Nat) (loop [acc 1 n n] @@ -331,7 +333,7 @@ acc (recur (n.* n acc) (dec n))))) -(def: #export (hypotenuse catA catB) +(def: .public (hypotenuse catA catB) (-> Frac Frac Frac) (..pow +0.5 ("lux f64 +" (..pow +2.0 catA) @@ -340,11 +342,11 @@ ## Hyperbolic functions ## https://en.wikipedia.org/wiki/Hyperbolic_function#Definitions (template [ ] - [(def: #export ( x) + [(def: .public ( x) (-> Frac Frac) (|> (..exp x) ( (..exp ("lux f64 *" -1.0 x))) ("lux f64 /" +2.0))) - (def: #export ( x) + (def: .public ( x) (-> Frac Frac) (|> +2.0 ("lux f64 /" (|> (..exp x) ( (..exp ("lux f64 *" -1.0 x)))))))] @@ -353,7 +355,7 @@ ) (template [ ] - [(def: #export ( x) + [(def: .public ( x) (-> Frac Frac) (let [e+ (exp x) e- (exp ("lux f64 *" -1.0 x)) @@ -367,7 +369,7 @@ ## https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions#Definitions_in_terms_of_logarithms (template [ ] - [(def: #export ( x) + [(def: .public ( x) (-> Frac Frac) (|> x (pow +2.0) ( +1.0) (pow +0.5) ("lux f64 +" x) log))] @@ -376,7 +378,7 @@ ) (template [ ] - [(def: #export ( x) + [(def: .public ( x) (-> Frac Frac) (let [x+ (|> ("lux f64 +" )) x- (|> ("lux f64 -" ))] @@ -387,7 +389,7 @@ ) (template [ ] - [(def: #export ( x) + [(def: .public ( x) (-> Frac Frac) (let [x^2 (|> x (pow +2.0))] (|> +1.0 ( x^2) (pow +0.5) ("lux f64 +" +1.0) ("lux f64 /" x) log)))] diff --git a/stdlib/source/library/lux/math/infix.lux b/stdlib/source/library/lux/math/infix.lux index 4b1a1ef8b..55653989a 100644 --- a/stdlib/source/library/lux/math/infix.lux +++ b/stdlib/source/library/lux/math/infix.lux @@ -80,7 +80,7 @@ (#Binary left op right) (` ((~ op) (~ (prefix right)) (~ (prefix left)))))) -(syntax: #export (infix {expr infix^}) +(syntax: .public (infix {expr infix^}) {#.doc (doc "Infix math syntax." (infix [x i.* +10]) (infix [[x i.+ y] i.* [x i.- y]]) diff --git a/stdlib/source/library/lux/math/logic/continuous.lux b/stdlib/source/library/lux/math/logic/continuous.lux index e68527938..691890917 100644 --- a/stdlib/source/library/lux/math/logic/continuous.lux +++ b/stdlib/source/library/lux/math/logic/continuous.lux @@ -11,15 +11,15 @@ [number ["/" rev ("#\." interval)]]]]]) -(def: #export false Rev /\bottom) -(def: #export true Rev /\top) +(def: .public false Rev /\bottom) +(def: .public true Rev /\top) (template [ ] - [(def: #export + [(def: .public (-> Rev Rev Rev) ) - (implementation: #export + (implementation: .public (Monoid Rev) (def: identity ) @@ -29,16 +29,16 @@ [and /.min conjunction ..true] ) -(def: #export (not input) +(def: .public (not input) (-> Rev Rev) (/.- input ..true)) -(def: #export (implies consequent antecedent) +(def: .public (implies consequent antecedent) (-> Rev Rev Rev) (or (not antecedent) consequent)) -(def: #export (= left right) +(def: .public (= left right) (-> Rev Rev Rev) (and (or (not left) right) (or left (not right)))) diff --git a/stdlib/source/library/lux/math/logic/fuzzy.lux b/stdlib/source/library/lux/math/logic/fuzzy.lux index a449f1ca6..d36b7cfd2 100644 --- a/stdlib/source/library/lux/math/logic/fuzzy.lux +++ b/stdlib/source/library/lux/math/logic/fuzzy.lux @@ -17,18 +17,18 @@ ["." // #_ ["#" continuous]]) -(type: #export (Fuzzy a) +(type: .public (Fuzzy a) {#.doc (doc "A fuzzy set.")} (-> a Rev)) -(implementation: #export functor +(implementation: .public functor (contravariant.Functor Fuzzy) (def: (map f fb) (|>> f fb))) (template [ ] - [(def: #export + [(def: .public Fuzzy (function (_ _) ))] @@ -37,12 +37,12 @@ [full //.true] ) -(def: #export (membership set elem) +(def: .public (membership set elem) (All [a] (-> (Fuzzy a) a Rev)) (set elem)) (template [ ] - [(def: #export ( left right) + [(def: .public ( left right) (All [a] (-> (Fuzzy a) (Fuzzy a) (Fuzzy a))) (function (_ elem) ( (left elem) @@ -52,27 +52,27 @@ [intersection //.and] ) -(def: #export (complement set) +(def: .public (complement set) (All [a] (-> (Fuzzy a) (Fuzzy a))) (|>> set //.not)) -(def: #export (difference sub base) +(def: .public (difference sub base) (All [a] (-> (Fuzzy a) (Fuzzy a) (Fuzzy a))) (..intersection (..complement sub) base)) -(def: #export (of_predicate predicate) +(def: .public (of_predicate predicate) (All [a] (-> (Predicate a) (Fuzzy a))) (function (_ elem) (if (predicate elem) //.true //.false))) -(def: #export (predicate treshold set) +(def: .public (predicate treshold set) (All [a] (-> Rev (Fuzzy a) (Predicate a))) (function (_ elem) (/.> treshold (set elem)))) -(def: #export of_set +(def: .public of_set (All [a] (-> (Set a) (Fuzzy a))) (|>> set.member? ..of_predicate)) @@ -97,18 +97,18 @@ (-> Rev Rev (Fuzzy Rev)) (..complement (..ascending from to))) -(def: #export (gradient from to) +(def: .public (gradient from to) (-> Rev Rev (Fuzzy Rev)) (if (/.< to from) (..ascending from to) (..descending from to))) (template: (!sort_2 ) - (if (/.> ) - [ ] - [ ])) + [(if (/.> ) + [ ] + [ ])]) -(def: #export (triangle bottom middle top) +(def: .public (triangle bottom middle top) (-> Rev Rev Rev (Fuzzy Rev)) (let [[low_0 high_0] (!sort_2 bottom middle) [bottom' high_1] (!sort_2 low_0 top) @@ -116,7 +116,7 @@ (..intersection (..ascending bottom' middle') (..descending middle' top')))) -(def: #export (trapezoid bottom middle_bottom middle_top top) +(def: .public (trapezoid bottom middle_bottom middle_top top) (-> Rev Rev Rev Rev (Fuzzy Rev)) (let [[low_0 high_0] (!sort_2 bottom middle_bottom) [low_1 high_1] (!sort_2 middle_top top) @@ -126,7 +126,7 @@ (..intersection (..ascending bottom' middle_bottom') (..descending middle_top' top')))) -(def: #export (cut treshold set) +(def: .public (cut treshold set) (All [a] (-> Rev (Fuzzy a) (Fuzzy a))) (function (_ elem) (let [membership (set elem)] diff --git a/stdlib/source/library/lux/math/modular.lux b/stdlib/source/library/lux/math/modular.lux index bc92467b1..7bfbf34a0 100644 --- a/stdlib/source/library/lux/math/modular.lux +++ b/stdlib/source/library/lux/math/modular.lux @@ -27,19 +27,19 @@ ["." // #_ ["#" modulus (#+ Modulus)]]) -(abstract: #export (Mod m) +(abstract: .public (Mod m) + {#.doc "A number under a modulus."} + {#modulus (Modulus m) #value Int} - {#.doc "A number under a modulus."} - - (def: #export (modular modulus value) + (def: .public (modular modulus value) (All [%] (-> (Modulus %) Int (Mod %))) (:abstraction {#modulus modulus #value (i.mod (//.divisor modulus) value)})) (template [ ] - [(def: #export + [(def: .public (All [%] (-> (Mod %) )) (|>> :representation ))] @@ -47,7 +47,7 @@ [value Int product.right] ) - (exception: #export [%] (incorrect_modulus {modulus (Modulus %)} + (exception: .public [%] (incorrect_modulus {modulus (Modulus %)} {parsed Int}) (exception.report ["Expected" (i\encode (//.divisor modulus))] @@ -61,7 +61,7 @@ (<>.codec i.decimal (.and (.one_of "-+") (.many .decimal)))) - (implementation: #export (codec expected) + (implementation: .public (codec expected) (All [%] (-> (Modulus %) (Codec Text (Mod %)))) (def: (encode modular) @@ -80,7 +80,7 @@ (in (..modular expected value)))))) (template [ ] - [(def: #export ( reference subject) + [(def: .public ( reference subject) (All [%] (-> (Mod %) (Mod %) Bit)) (let [[_ reference] (:representation reference) [_ subject] (:representation subject)] @@ -93,19 +93,19 @@ [>= i.>=] ) - (implementation: #export equivalence + (implementation: .public equivalence (All [%] (Equivalence (Mod %))) (def: = ..=)) - (implementation: #export order + (implementation: .public order (All [%] (Order (Mod %))) (def: &equivalence ..equivalence) (def: < ..<)) (template [ ] - [(def: #export ( param subject) + [(def: .public ( param subject) (All [%] (-> (Mod %) (Mod %) (Mod %))) (let [[modulus param] (:representation param) [_ subject] (:representation subject)] @@ -120,7 +120,7 @@ ) (template [ ] - [(implementation: #export ( modulus) + [(implementation: .public ( modulus) (All [%] (-> (Modulus %) (Monoid (Mod %)))) (def: identity @@ -132,7 +132,7 @@ [..* +1 multiplication] ) - (def: #export (inverse modular) + (def: .public (inverse modular) (All [%] (-> (Mod %) (Maybe (Mod %)))) (let [[modulus value] (:representation modular) [[vk mk] gcd] (i.extended_gcd value (//.divisor modulus))] @@ -141,13 +141,13 @@ _ #.None))) ) -(exception: #export [r% s%] (moduli_are_not_equal {reference (Modulus r%)} +(exception: .public [r% s%] (moduli_are_not_equal {reference (Modulus r%)} {subject (Modulus s%)}) (exception.report ["Reference" (i\encode (//.divisor reference))] ["Subject" (i\encode (//.divisor subject))])) -(def: #export (adapter reference subject) +(def: .public (adapter reference subject) (All [r% s%] (-> (Modulus r%) (Modulus s%) (Try (-> (Mod s%) (Mod r%))))) diff --git a/stdlib/source/library/lux/math/modulus.lux b/stdlib/source/library/lux/math/modulus.lux index 05a0ef26d..72f5d583e 100644 --- a/stdlib/source/library/lux/math/modulus.lux +++ b/stdlib/source/library/lux/math/modulus.lux @@ -18,30 +18,30 @@ [type abstract]]]) -(exception: #export zero_cannot_be_a_modulus) - -(abstract: #export (Modulus %) - Int +(exception: .public zero_cannot_be_a_modulus) +(abstract: .public (Modulus %) {#.doc (doc "A number used as a modulus in modular arithmetic." "It cannot be 0.")} - (def: #export (modulus value) + Int + + (def: .public (modulus value) (Ex [%] (-> Int (Try (Modulus %)))) (if (i.= +0 value) (exception.except ..zero_cannot_be_a_modulus []) (#try.Success (:abstraction value)))) - (def: #export divisor + (def: .public divisor (All [%] (-> (Modulus %) Int)) (|>> :representation)) - (def: #export (= reference subject) + (def: .public (= reference subject) (All [%r %s] (-> (Modulus %r) (Modulus %s) Bit)) (i.= (:representation reference) (:representation subject))) - (def: #export (congruent? modulus reference subject) + (def: .public (congruent? modulus reference subject) (All [%] (-> (Modulus %) Int Int Bit)) (|> subject (i.- reference) @@ -49,7 +49,7 @@ (i.= +0))) ) -(syntax: #export (literal {divisor .int}) +(syntax: .public (literal {divisor .int}) {#.doc (doc "Success!" (literal 123) diff --git a/stdlib/source/library/lux/math/number.lux b/stdlib/source/library/lux/math/number.lux index 288afd703..d1e8144ab 100644 --- a/stdlib/source/library/lux/math/number.lux +++ b/stdlib/source/library/lux/math/number.lux @@ -46,7 +46,7 @@ (text.replace_all ..separator "")) (template [ ] - [(macro: #export ( tokens state) + [(macro: .public ( tokens state) {#.doc } (case tokens (#.Item [meta (#.Text repr')] #.End) diff --git a/stdlib/source/library/lux/math/number/complex.lux b/stdlib/source/library/lux/math/number/complex.lux index de73592f0..63df9b5ae 100644 --- a/stdlib/source/library/lux/math/number/complex.lux +++ b/stdlib/source/library/lux/math/number/complex.lux @@ -23,12 +23,12 @@ ["f" frac] ["." int]]]]]) -(type: #export Complex +(type: .public Complex {#.doc (doc "A complex number.")} {#real Frac #imaginary Frac}) -(syntax: #export (complex real {?imaginary (<>.maybe .any)}) +(syntax: .public (complex real {?imaginary (<>.maybe .any)}) {#.doc (doc "Complex literals." (complex real imaginary) "The imaginary part can be omitted if it's +0.0." @@ -36,23 +36,23 @@ (in (list (` {#..real (~ real) #..imaginary (~ (maybe.else (' +0.0) ?imaginary))})))) -(def: #export i +(def: .public i (..complex +0.0 +1.0)) -(def: #export +one +(def: .public +one (..complex +1.0 +0.0)) -(def: #export -one +(def: .public -one (..complex -1.0 +0.0)) -(def: #export zero +(def: .public zero (..complex +0.0 +0.0)) -(def: #export (not_a_number? complex) +(def: .public (not_a_number? complex) (or (f.not_a_number? (get@ #real complex)) (f.not_a_number? (get@ #imaginary complex)))) -(def: #export (= param input) +(def: .public (= param input) (-> Complex Complex Bit) (and (f.= (get@ #real param) (get@ #real input)) @@ -60,7 +60,7 @@ (get@ #imaginary input)))) (template [ ] - [(def: #export ( param input) + [(def: .public ( param input) (-> Complex Complex Complex) {#real ( (get@ #real param) (get@ #real input)) @@ -71,13 +71,13 @@ [- f.-] ) -(implementation: #export equivalence +(implementation: .public equivalence (Equivalence Complex) (def: = ..=)) (template [ ] - [(def: #export + [(def: .public (-> Complex Complex) (|>> (update@ #real ) (update@ #imaginary )))] @@ -86,18 +86,18 @@ [signum f.signum] ) -(def: #export conjugate +(def: .public conjugate (-> Complex Complex) (update@ #imaginary f.opposite)) -(def: #export (*' param input) +(def: .public (*' param input) (-> Frac Complex Complex) {#real (f.* param (get@ #real input)) #imaginary (f.* param (get@ #imaginary input))}) -(def: #export (* param input) +(def: .public (* param input) (-> Complex Complex Complex) {#real (f.- (f.* (get@ #imaginary param) (get@ #imaginary input)) @@ -108,7 +108,7 @@ (f.* (get@ #imaginary param) (get@ #real input)))}) -(def: #export (/ param input) +(def: .public (/ param input) (-> Complex Complex Complex) (let [(^slots [#real #imaginary]) param] (if (f.< (f.abs imaginary) @@ -122,13 +122,13 @@ {#real (|> (get@ #imaginary input) (f.* quot) (f.+ (get@ #real input)) (f./ denom)) #imaginary (|> (get@ #imaginary input) (f.- (f.* quot (get@ #real input))) (f./ denom))})))) -(def: #export (/' param subject) +(def: .public (/' param subject) (-> Frac Complex Complex) (let [(^slots [#real #imaginary]) subject] {#real (f./ param real) #imaginary (f./ param imaginary)})) -(def: #export (% param input) +(def: .public (% param input) (-> Complex Complex Complex) (let [scaled (/ param input) quotient (|> scaled @@ -137,7 +137,7 @@ (- (* quotient param) input))) -(def: #export (cos subject) +(def: .public (cos subject) (-> Complex Complex) (let [(^slots [#real #imaginary]) subject] {#real (f.* (math.cosh imaginary) @@ -145,7 +145,7 @@ #imaginary (f.opposite (f.* (math.sinh imaginary) (math.sin real)))})) -(def: #export (cosh subject) +(def: .public (cosh subject) (-> Complex Complex) (let [(^slots [#real #imaginary]) subject] {#real (f.* (math.cos imaginary) @@ -153,7 +153,7 @@ #imaginary (f.* (math.sin imaginary) (math.sinh real))})) -(def: #export (sin subject) +(def: .public (sin subject) (-> Complex Complex) (let [(^slots [#real #imaginary]) subject] {#real (f.* (math.cosh imaginary) @@ -161,7 +161,7 @@ #imaginary (f.* (math.sinh imaginary) (math.cos real))})) -(def: #export (sinh subject) +(def: .public (sinh subject) (-> Complex Complex) (let [(^slots [#real #imaginary]) subject] {#real (f.* (math.cos imaginary) @@ -169,7 +169,7 @@ #imaginary (f.* (math.sin imaginary) (math.cosh real))})) -(def: #export (tan subject) +(def: .public (tan subject) (-> Complex Complex) (let [(^slots [#real #imaginary]) subject r2 (f.* +2.0 real) @@ -178,7 +178,7 @@ {#real (f./ d (math.sin r2)) #imaginary (f./ d (math.sinh i2))})) -(def: #export (tanh subject) +(def: .public (tanh subject) (-> Complex Complex) (let [(^slots [#real #imaginary]) subject r2 (f.* +2.0 real) @@ -187,7 +187,7 @@ {#real (f./ d (math.sinh r2)) #imaginary (f./ d (math.sin i2))})) -(def: #export (abs subject) +(def: .public (abs subject) (-> Complex Frac) (let [(^slots [#real #imaginary]) subject] (if (f.< (f.abs imaginary) @@ -203,21 +203,21 @@ (f.* (math.pow +0.5 (f.+ +1.0 (f.* q q))) (f.abs real))))))) -(def: #export (exp subject) +(def: .public (exp subject) (-> Complex Complex) (let [(^slots [#real #imaginary]) subject r_exp (math.exp real)] {#real (f.* r_exp (math.cos imaginary)) #imaginary (f.* r_exp (math.sin imaginary))})) -(def: #export (log subject) +(def: .public (log subject) (-> Complex Complex) (let [(^slots [#real #imaginary]) subject] {#real (|> subject ..abs math.log) #imaginary (math.atan/2 real imaginary)})) (template [ ] - [(def: #export ( param input) + [(def: .public ( param input) (-> Complex Complex) (|> input log ( param) exp))] @@ -229,7 +229,7 @@ (-> Frac Frac Frac) (f.* (f.signum sign) magnitude)) -(def: #export (root/2 input) +(def: .public (root/2 input) (-> Complex Complex) (let [(^slots [#real #imaginary]) input t (|> input ..abs (f.+ (f.abs real)) (f./ +2.0) (math.pow +0.5))] @@ -245,7 +245,7 @@ (-> Complex Complex) (|> (complex +1.0) (- (* input input)) ..root/2)) -(def: #export (reciprocal (^slots [#real #imaginary])) +(def: .public (reciprocal (^slots [#real #imaginary])) (-> Complex Complex) (if (f.< (f.abs imaginary) (f.abs real)) @@ -260,14 +260,14 @@ {#real scale #imaginary (|> scale f.opposite (f.* q))}))) -(def: #export (acos input) +(def: .public (acos input) (-> Complex Complex) (|> input (..+ (|> input ..root/2-1z (..* ..i))) ..log (..* (..opposite ..i)))) -(def: #export (asin input) +(def: .public (asin input) (-> Complex Complex) (|> input ..root/2-1z @@ -275,7 +275,7 @@ ..log (..* (..opposite ..i)))) -(def: #export (atan input) +(def: .public (atan input) (-> Complex Complex) (|> input (..+ ..i) @@ -283,11 +283,11 @@ ..log (..* (../ (..complex +2.0) ..i)))) -(def: #export (argument (^slots [#real #imaginary])) +(def: .public (argument (^slots [#real #imaginary])) (-> Complex Frac) (math.atan/2 real imaginary)) -(def: #export (roots nth input) +(def: .public (roots nth input) (-> Nat Complex (List Complex)) (if (n.= 0 nth) (list) @@ -307,7 +307,7 @@ {#real real #imaginary imaginary}))))))) -(def: #export (approximately? margin_of_error standard value) +(def: .public (approximately? margin_of_error standard value) (-> Frac Complex Complex Bit) (and (f.approximately? margin_of_error (get@ #..real standard) diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux index c602db1c5..729d9b5b7 100644 --- a/stdlib/source/library/lux/math/number/frac.lux +++ b/stdlib/source/library/lux/math/number/frac.lux @@ -22,35 +22,35 @@ ["#." rev] ["/#" //]]) -(def: #export (= reference sample) +(def: .public (= reference sample) {#.doc "Frac(tion) equivalence."} (-> Frac Frac Bit) ("lux f64 =" reference sample)) -(def: #export (< reference sample) +(def: .public (< reference sample) {#.doc "Frac(tion) less-than."} (-> Frac Frac Bit) ("lux f64 <" reference sample)) -(def: #export (<= reference sample) +(def: .public (<= reference sample) {#.doc "Frac(tion) less-than or equal."} (-> Frac Frac Bit) (or ("lux f64 <" reference sample) ("lux f64 =" reference sample))) -(def: #export (> reference sample) +(def: .public (> reference sample) {#.doc "Frac(tion) greater-than."} (-> Frac Frac Bit) ("lux f64 <" sample reference)) -(def: #export (>= reference sample) +(def: .public (>= reference sample) {#.doc "Frac(tion) greater-than or equal."} (-> Frac Frac Bit) (or ("lux f64 <" sample reference) ("lux f64 =" sample reference))) (template [ ] - [(def: #export + [(def: .public (Predicate Frac) ( +0.0))] @@ -60,7 +60,7 @@ ) (template [ ] - [(def: #export ( param subject) + [(def: .public ( param subject) {#.doc } (-> Frac Frac Frac) ( param subject))] @@ -72,22 +72,22 @@ [% "lux f64 %" "Frac(tion) remainder."] ) -(def: #export (/% param subject) +(def: .public (/% param subject) (-> Frac Frac [Frac Frac]) [(../ param subject) (..% param subject)]) -(def: #export opposite +(def: .public opposite (-> Frac Frac) (..* -1.0)) -(def: #export (abs x) +(def: .public (abs x) (-> Frac Frac) (if (..< +0.0 x) (..* -1.0 x) x)) -(def: #export (signum x) +(def: .public (signum x) (-> Frac Frac) (cond (..= +0.0 x) +0.0 (..< +0.0 x) -1.0 @@ -98,7 +98,7 @@ (def: max_exponent (//int.frac +1023)) (template [ ] - [(def: #export ( left right) + [(def: .public ( left right) {#.doc } (-> Frac Frac Frac) (if ( right left) @@ -109,11 +109,11 @@ [max ..> "Frac(tion) minimum."] ) -(def: #export nat +(def: .public nat (-> Frac Nat) (|>> "lux f64 i64" .nat)) -(def: #export int +(def: .public int (-> Frac Int) (|>> "lux f64 i64")) @@ -125,7 +125,7 @@ ("lux i64 right-shift" ..exponent_size) "lux i64 f64")) -(def: #export rev +(def: .public rev (-> Frac Rev) (|>> ..abs (..% +1.0) @@ -133,23 +133,23 @@ "lux f64 i64" ("lux i64 left-shift" ..exponent_size))) -(implementation: #export equivalence +(implementation: .public equivalence (Equivalence Frac) (def: = ..=)) -(implementation: #export order +(implementation: .public order (Order Frac) (def: &equivalence ..equivalence) (def: < ..<)) -(def: #export smallest +(def: .public smallest Frac (///.pow (//int.frac (//int.- (.int ..mantissa_size) ..min_exponent)) +2.0)) -(def: #export biggest +(def: .public biggest Frac (let [f2^-52 (///.pow (//nat.frac (//nat.- ..mantissa_size 0)) +2.0) f2^+1023 (///.pow ..max_exponent +2.0)] @@ -158,7 +158,7 @@ (..* f2^+1023)))) (template [ ] - [(implementation: #export + [(implementation: .public (Monoid Frac) (def: identity ) @@ -171,7 +171,7 @@ ) (template [ ] - [(def: #export + [(def: .public {#.doc } Frac (../ +0.0 ))] @@ -180,23 +180,23 @@ [positive_infinity +1.0 "Positive infinity."] ) -(def: #export negative_infinity +(def: .public negative_infinity {#.doc "Negative infinity."} Frac (..* -1.0 ..positive_infinity)) -(def: #export (not_a_number? number) +(def: .public (not_a_number? number) {#.doc "Tests whether a frac is actually not-a-number."} (-> Frac Bit) (not (..= number number))) -(def: #export (number? value) +(def: .public (number? value) (-> Frac Bit) (not (or (..not_a_number? value) (..= ..positive_infinity value) (..= ..negative_infinity value)))) -(implementation: #export decimal +(implementation: .public decimal (Codec Text Frac) (def: (encode x) @@ -247,7 +247,7 @@ (def: smallest_exponent (..log/2 ..smallest)) -(def: #export (bits input) +(def: .public (bits input) (-> Frac I64) (.i64 (cond (..not_a_number? input) ..not_a_number_bits @@ -310,7 +310,7 @@ [sign 1 ..sign_offset] ) -(def: #export (of_bits input) +(def: .public (of_bits input) (-> I64 Frac) (case [(: Nat (..exponent input)) (: Nat (..mantissa input)) @@ -374,7 +374,7 @@ (#try.Success [representation +0]))) (template [ ] - [(implementation: #export + [(implementation: .public (Codec Text Frac) (def: (encode value) @@ -427,20 +427,20 @@ [hex //nat.hex //int.hex "Invalid hexadecimal syntax: "] ) -(implementation: #export hash +(implementation: .public hash (Hash Frac) (def: &equivalence ..equivalence) (def: hash ..bits)) -(def: #export (approximately? margin_of_error standard value) +(def: .public (approximately? margin_of_error standard value) (-> Frac Frac Frac Bit) (|> value (..- standard) ..abs (..< margin_of_error))) -(def: #export (mod divisor dividend) +(def: .public (mod divisor dividend) (All [m] (-> Frac Frac Frac)) (let [remainder (..% divisor dividend)] (if (or (and (..< +0.0 divisor) diff --git a/stdlib/source/library/lux/math/number/i16.lux b/stdlib/source/library/lux/math/number/i16.lux index 569e228fd..0f273497c 100644 --- a/stdlib/source/library/lux/math/number/i16.lux +++ b/stdlib/source/library/lux/math/number/i16.lux @@ -12,7 +12,7 @@ (def: sub (maybe.assume (i64.sub 16))) -(def: #export I16 +(def: .public I16 {#.doc (doc "A 16-bit integer.")} (:by_example [size] (Sub size) @@ -20,7 +20,7 @@ (I64 size))) -(def: #export equivalence (Equivalence I16) (\ ..sub &equivalence)) -(def: #export width Nat (\ ..sub width)) -(def: #export i16 (-> I64 I16) (\ ..sub narrow)) -(def: #export i64 (-> I16 I64) (\ ..sub widen)) +(def: .public equivalence (Equivalence I16) (\ ..sub &equivalence)) +(def: .public width Nat (\ ..sub width)) +(def: .public i16 (-> I64 I16) (\ ..sub narrow)) +(def: .public i64 (-> I16 I64) (\ ..sub widen)) diff --git a/stdlib/source/library/lux/math/number/i32.lux b/stdlib/source/library/lux/math/number/i32.lux index 33374d19a..61fe87f40 100644 --- a/stdlib/source/library/lux/math/number/i32.lux +++ b/stdlib/source/library/lux/math/number/i32.lux @@ -12,7 +12,7 @@ (def: sub (maybe.assume (i64.sub 32))) -(def: #export I32 +(def: .public I32 {#.doc (doc "A 32-bit integer.")} (:by_example [size] (Sub size) @@ -20,7 +20,7 @@ (I64 size))) -(def: #export equivalence (Equivalence I32) (\ ..sub &equivalence)) -(def: #export width Nat (\ ..sub width)) -(def: #export i32 (-> I64 I32) (\ ..sub narrow)) -(def: #export i64 (-> I32 I64) (\ ..sub widen)) +(def: .public equivalence (Equivalence I32) (\ ..sub &equivalence)) +(def: .public width Nat (\ ..sub width)) +(def: .public i32 (-> I64 I32) (\ ..sub narrow)) +(def: .public i64 (-> I32 I64) (\ ..sub widen)) diff --git a/stdlib/source/library/lux/math/number/i64.lux b/stdlib/source/library/lux/math/number/i64.lux index 02dc98748..c6b8a69d8 100644 --- a/stdlib/source/library/lux/math/number/i64.lux +++ b/stdlib/source/library/lux/math/number/i64.lux @@ -10,19 +10,19 @@ [// ["n" nat]]) -(def: #export bits_per_byte +(def: .public bits_per_byte 8) -(def: #export bytes_per_i64 +(def: .public bytes_per_i64 8) -(def: #export width +(def: .public width Nat (n.* ..bits_per_byte ..bytes_per_i64)) (template [ ] - [(def: #export ( parameter subject) + [(def: .public ( parameter subject) {#.doc } (All [s] (-> (I64 s) (I64 s))) ( parameter subject))] @@ -36,34 +36,34 @@ ) ## https://en.wikipedia.org/wiki/Mask_(computing) -(type: #export Mask +(type: .public Mask {#.doc (doc "A pattern of bits that can be imposed on I64 values.")} I64) -(def: #export (bit position) +(def: .public (bit position) {#.doc (doc "A mask with only a specific bit set.")} (-> Nat Mask) (|> 1 .i64 (..left_shifted (n.% ..width position)))) -(def: #export sign +(def: .public sign {#.doc (doc "A mask for the sign bit of ints.")} Mask (..bit (dec ..width))) -(def: #export not +(def: .public not {#.doc "Bitwise negation."} (All [s] (-> (I64 s) (I64 s))) (..xor (.i64 (dec 0)))) -(def: #export false +(def: .public false Mask (.i64 0)) -(def: #export true +(def: .public true Mask (..not ..false)) -(def: #export (mask amount_of_bits) +(def: .public (mask amount_of_bits) {#.doc (doc "Mask a block of bits of the specified size.")} (-> Nat Mask) (case amount_of_bits @@ -76,7 +76,7 @@ (-> Nat Nat Nat) (|> value (right_shifted shift) (n.+ value))) -(def: #export (count subject) +(def: .public (count subject) {#.doc "Count the number of 1s in a bit-map."} (-> (I64 Any) Nat) (let [count' (n.- (|> subject (right_shifted 1) (..and 6148914691236517205) i64) @@ -89,13 +89,13 @@ (add_shift 32) (..and 127)))) -(def: #export (clear index input) +(def: .public (clear index input) {#.doc "Clear bit at the given index."} (All [s] (-> Nat (I64 s) (I64 s))) (|> index ..bit ..not (..and input))) (template [ ] - [(def: #export ( index input) + [(def: .public ( index input) {#.doc } (All [s] (-> Nat (I64 s) (I64 s))) (|> index ..bit ( input)))] @@ -104,16 +104,16 @@ [flip ..xor "Flip bit at given index."] ) -(def: #export (set? index input) +(def: .public (set? index input) (-> Nat (I64 Any) Bit) (|> input (:as I64) (..and (..bit index)) (n.= 0) .not)) -(def: #export (clear? index input) +(def: .public (clear? index input) (-> Nat (I64 Any) Bit) (.not (..set? index input))) (template [ ] - [(def: #export ( distance input) + [(def: .public ( distance input) (All [s] (-> Nat (I64 s) (I64 s))) (..or ( distance input) ( (n.- (n.% ..width distance) ..width) input)))] @@ -122,18 +122,18 @@ [right_rotated ..right_shifted ..left_shifted] ) -(def: #export (region offset size) +(def: .public (region offset size) {#.doc (doc "A mask for a block of bits of the given size, starting at the given offset.")} (-> Nat Nat Mask) (..left_rotated offset (..mask size))) -(implementation: #export equivalence +(implementation: .public equivalence (All [a] (Equivalence (I64 a))) (def: (= reference sample) ("lux i64 =" reference sample))) -(implementation: #export hash +(implementation: .public hash (All [a] (Hash (I64 a))) (def: &equivalence ..equivalence) @@ -141,7 +141,7 @@ (def: hash .nat)) (template [ ] - [(implementation: #export + [(implementation: .public (All [a] (Monoid (I64 a))) (def: identity ) @@ -151,7 +151,7 @@ [conjunction ..true ..and] ) -(def: #export reversed +(def: .public reversed (All [a] (-> (I64 a) (I64 a))) (let [swapper (: (-> Nat (All [a] (-> (I64 a) (I64 a)))) (function (_ power) @@ -188,7 +188,7 @@ swap/02 swap/01))) -(interface: #export (Sub size) +(interface: .public (Sub size) {#.doc (doc "A sub-space of I64 with a reduce amount of bits.")} (: (Equivalence (I64 size)) @@ -200,7 +200,7 @@ (: (-> (I64 size) I64) widen)) -(def: #export (sub width) +(def: .public (sub width) {#.doc (doc "Given a width in the interval (0,64), yields an implementation for integers of that width.")} (Ex [size] (-> Nat (Maybe (Sub size)))) (if (.and (n.> 0 width) diff --git a/stdlib/source/library/lux/math/number/i8.lux b/stdlib/source/library/lux/math/number/i8.lux index 1f02b508b..1c3bccea6 100644 --- a/stdlib/source/library/lux/math/number/i8.lux +++ b/stdlib/source/library/lux/math/number/i8.lux @@ -12,7 +12,7 @@ (def: sub (maybe.assume (i64.sub 8))) -(def: #export I8 +(def: .public I8 {#.doc (doc "An 8-bit integer.")} (:by_example [size] (Sub size) @@ -20,7 +20,7 @@ (I64 size))) -(def: #export equivalence (Equivalence I8) (\ ..sub &equivalence)) -(def: #export width Nat (\ ..sub width)) -(def: #export i8 (-> I64 I8) (\ ..sub narrow)) -(def: #export i64 (-> I8 I64) (\ ..sub widen)) +(def: .public equivalence (Equivalence I8) (\ ..sub &equivalence)) +(def: .public width Nat (\ ..sub width)) +(def: .public i8 (-> I64 I8) (\ ..sub narrow)) +(def: .public i64 (-> I8 I64) (\ ..sub widen)) diff --git a/stdlib/source/library/lux/math/number/int.lux b/stdlib/source/library/lux/math/number/int.lux index 610ad296e..dbef9c89c 100644 --- a/stdlib/source/library/lux/math/number/int.lux +++ b/stdlib/source/library/lux/math/number/int.lux @@ -19,29 +19,29 @@ ["#." nat] ["#." i64]]) -(def: #export (= reference sample) +(def: .public (= reference sample) {#.doc "Int(eger) equivalence."} (-> Int Int Bit) ("lux i64 =" reference sample)) -(def: #export (< reference sample) +(def: .public (< reference sample) {#.doc "Int(eger) less-than."} (-> Int Int Bit) ("lux i64 <" reference sample)) -(def: #export (<= reference sample) +(def: .public (<= reference sample) {#.doc "Int(eger) less-than or equal."} (-> Int Int Bit) (if ("lux i64 <" reference sample) #1 ("lux i64 =" reference sample))) -(def: #export (> reference sample) +(def: .public (> reference sample) {#.doc "Int(eger) greater-than."} (-> Int Int Bit) ("lux i64 <" sample reference)) -(def: #export (>= reference sample) +(def: .public (>= reference sample) {#.doc "Int(eger) greater-than or equal."} (-> Int Int Bit) (if ("lux i64 <" sample reference) @@ -49,7 +49,7 @@ ("lux i64 =" reference sample))) (template [ ] - [(def: #export + [(def: .public (Predicate Int) ( +0))] @@ -59,7 +59,7 @@ ) (template [ ] - [(def: #export ( left right) + [(def: .public ( left right) {#.doc } (-> Int Int Int) (if ( right left) @@ -71,7 +71,7 @@ ) (template [ ] - [(def: #export ( param subject) + [(def: .public ( param subject) {#.doc } (-> Int Int Int) ( param subject))] @@ -83,25 +83,25 @@ [% "lux i64 %" "Int(eger) remainder."] ) -(def: #export (/% param subject) +(def: .public (/% param subject) {#.doc "Int(eger) [division remainder]."} (-> Int Int [Int Int]) [(../ param subject) (..% param subject)]) -(def: #export (opposite value) +(def: .public (opposite value) {#.doc (doc "A value of equal magnitude and opposite sign.")} (-> Int Int) (..- value +0)) -(def: #export (abs x) +(def: .public (abs x) {#.doc (doc "A value of equal magnitude and positive sign.")} (-> Int Int) (if (..< +0 x) (..* -1 x) x)) -(def: #export (signum x) +(def: .public (signum x) {#.doc (doc "A value (either -1, 0 or +0) which represents the sign.")} (-> Int Int) (cond (..= +0 x) +0 @@ -110,7 +110,7 @@ +1)) ## https://rob.conery.io/2018/08/21/mod-and-remainder-are-not-the-same/ -(def: #export (mod divisor dividend) +(def: .public (mod divisor dividend) {#.doc (doc "Integer modulo." "Note: The modulo and the remainder are not the same.")} (All [m] (-> Int Int Int)) @@ -122,28 +122,28 @@ (..+ divisor remainder) remainder))) -(def: #export even? +(def: .public even? (-> Int Bit) (|>> (..% +2) ("lux i64 =" +0))) -(def: #export odd? +(def: .public odd? (-> Int Bit) (|>> ..even? not)) ## https://en.wikipedia.org/wiki/Greatest_common_divisor -(def: #export (gcd a b) +(def: .public (gcd a b) {#.doc "Greatest Common Divisor."} (-> Int Int Int) (case b +0 a _ (gcd b (..% b a)))) -(def: #export (co_prime? a b) +(def: .public (co_prime? a b) (-> Int Int Bit) (..= +1 (..gcd a b))) ## https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm -(def: #export (extended_gcd a b) +(def: .public (extended_gcd a b) {#.doc "Extended euclidean algorithm."} (-> Int Int [[Int Int] Int]) (loop [x +1 x1 +0 @@ -157,7 +157,7 @@ b1 (- (* q b1) a1)))))) ## https://en.wikipedia.org/wiki/Least_common_multiple -(def: #export (lcm a b) +(def: .public (lcm a b) {#.doc "Least Common Multiple."} (-> Int Int Int) (case [a b] @@ -167,22 +167,22 @@ _ (|> a (/ (gcd a b)) (* b)))) -(def: #export frac +(def: .public frac (-> Int Frac) (|>> "lux i64 f64")) -(implementation: #export equivalence +(implementation: .public equivalence (Equivalence Int) (def: = ..=)) -(implementation: #export order +(implementation: .public order (Order Int) (def: &equivalence ..equivalence) (def: < ..<)) -(implementation: #export enum +(implementation: .public enum (Enum Int) (def: &order ..order) @@ -190,7 +190,7 @@ (def: pred dec)) ## TODO: Find out why the numeric literals fail during JS compilation. -(implementation: #export interval +(implementation: .public interval (Interval Int) (def: &enum ..enum) @@ -204,7 +204,7 @@ (//i64.left_shifted 63 +1))) (template [ ] - [(implementation: #export + [(implementation: .public (Monoid Int) (def: identity ) @@ -220,7 +220,7 @@ (def: +sign "+") (template [ ] - [(implementation: #export + [(implementation: .public (Codec Text Int) (def: (encode value) @@ -254,13 +254,13 @@ [hex //nat.hex "Invalid hexadecimal syntax for Int: "] ) -(implementation: #export hash +(implementation: .public hash (Hash Int) (def: &equivalence ..equivalence) (def: hash .nat)) -(def: #export (right_shifted parameter subject) +(def: .public (right_shifted parameter subject) {#.doc "Signed/arithmetic bitwise right-shift."} (-> Nat Int Int) (//i64.or (//i64.and //i64.sign subject) diff --git a/stdlib/source/library/lux/math/number/nat.lux b/stdlib/source/library/lux/math/number/nat.lux index 7599e221f..63c2302c4 100644 --- a/stdlib/source/library/lux/math/number/nat.lux +++ b/stdlib/source/library/lux/math/number/nat.lux @@ -16,7 +16,7 @@ ["." maybe]]]]) (template [ ] - [(def: #export ( parameter subject) + [(def: .public ( parameter subject) {#.doc } (-> Nat Nat ) ( parameter subject))] @@ -35,7 +35,7 @@ (let [mask (|> 1 ("lux i64 left-shift" 32) ("lux i64 -" 1))] (|>> ("lux i64 and" mask)))) -(def: #export (< reference sample) +(def: .public (< reference sample) {#.doc "Nat(ural) less-than."} (-> Nat Nat Bit) (let [referenceH (..high reference) @@ -48,19 +48,19 @@ (..low sample)) #0)))) -(def: #export (<= reference sample) +(def: .public (<= reference sample) {#.doc "Nat(ural) less-than or equal."} (-> Nat Nat Bit) (if (..< reference sample) #1 ("lux i64 =" reference sample))) -(def: #export (> reference sample) +(def: .public (> reference sample) {#.doc "Nat(ural) greater-than."} (-> Nat Nat Bit) (..< sample reference)) -(def: #export (>= reference sample) +(def: .public (>= reference sample) {#.doc "Nat(ural) greater-than or equal."} (-> Nat Nat Bit) (if (..< sample reference) @@ -68,7 +68,7 @@ ("lux i64 =" reference sample))) (template [ ] - [(def: #export ( left right) + [(def: .public ( left right) {#.doc } (-> Nat Nat Nat) (if ( right left) @@ -79,7 +79,7 @@ [max ..> "Nat(ural) maximum."] ) -(def: #export (* parameter subject) +(def: .public (* parameter subject) {#.doc "Nat(ural) multiplication."} (-> Nat Nat Nat) (:as Nat @@ -87,7 +87,7 @@ (:as Int parameter) (:as Int subject)))) -(def: #export (/ parameter subject) +(def: .public (/ parameter subject) {#.doc "Nat(ural) division."} (-> Nat Nat Nat) (if ("lux i64 <" +0 (:as Int parameter)) @@ -106,7 +106,7 @@ quotient ("lux i64 +" 1 quotient))))) -(def: #export (/% parameter subject) +(def: .public (/% parameter subject) {#.doc "Nat(ural) [division remainder]."} (-> Nat Nat [Nat Nat]) (let [quotient (../ parameter subject) @@ -115,7 +115,7 @@ (:as Int quotient))] [quotient ("lux i64 -" flat subject)])) -(def: #export (% parameter subject) +(def: .public (% parameter subject) {#.doc "Nat(ural) remainder."} (-> Nat Nat Nat) (let [flat ("lux i64 *" @@ -123,18 +123,18 @@ (:as Int (../ parameter subject)))] ("lux i64 -" flat subject))) -(def: #export (gcd a b) +(def: .public (gcd a b) {#.doc "Greatest Common Divisor."} (-> Nat Nat Nat) (case b 0 a _ (gcd b (..% b a)))) -(def: #export (co_prime? a b) +(def: .public (co_prime? a b) (-> Nat Nat Bit) (..= 1 (..gcd a b))) -(def: #export (lcm a b) +(def: .public (lcm a b) {#.doc "Least Common Multiple."} (-> Nat Nat Nat) (case [a b] @@ -144,37 +144,37 @@ _ (|> a (../ (..gcd a b)) (..* b)))) -(def: #export even? +(def: .public even? (-> Nat Bit) (|>> (..% 2) ("lux i64 =" 0))) -(def: #export odd? +(def: .public odd? (-> Nat Bit) (|>> ..even? not)) -(def: #export frac +(def: .public frac (-> Nat Frac) (|>> .int "lux i64 f64")) -(implementation: #export equivalence +(implementation: .public equivalence (Equivalence Nat) (def: = ..=)) -(implementation: #export order +(implementation: .public order (Order Nat) (def: &equivalence ..equivalence) (def: < ..<)) -(implementation: #export enum +(implementation: .public enum (Enum Nat) (def: &order ..order) (def: succ inc) (def: pred dec)) -(implementation: #export interval +(implementation: .public interval (Interval Nat) (def: &enum ..enum) @@ -182,7 +182,7 @@ (def: bottom 0)) (template [ ] - [(implementation: #export + [(implementation: .public (Monoid Nat) (def: identity ) @@ -300,7 +300,7 @@ _ #.None)) (template [ ] - [(implementation: #export + [(implementation: .public (Codec Text Nat) (def: encode @@ -341,7 +341,7 @@ [4 hex hexadecimal_character hexadecimal_value "Invalid hexadecimal syntax for Nat: "] ) -(implementation: #export decimal +(implementation: .public decimal (Codec Text Nat) (def: (encode value) @@ -373,7 +373,7 @@ (#try.Success output))) ))))) -(implementation: #export hash +(implementation: .public hash (Hash Nat) (def: &equivalence ..equivalence) diff --git a/stdlib/source/library/lux/math/number/ratio.lux b/stdlib/source/library/lux/math/number/ratio.lux index a53f87dd9..a9a494208 100644 --- a/stdlib/source/library/lux/math/number/ratio.lux +++ b/stdlib/source/library/lux/math/number/ratio.lux @@ -23,12 +23,12 @@ [// ["n" nat ("#\." decimal)]]) -(type: #export Ratio +(type: .public Ratio {#.doc (doc "An unsigned ratio of numbers.")} {#numerator Nat #denominator Nat}) -(def: #export (nat value) +(def: .public (nat value) (-> Ratio (Maybe Nat)) (case (get@ #denominator value) 1 (#.Some (get@ #numerator value)) @@ -40,7 +40,7 @@ {#numerator (n./ common numerator) #denominator (n./ common denominator)})) -(syntax: #export (ratio numerator {?denominator (<>.maybe .any)}) +(syntax: .public (ratio numerator {?denominator (<>.maybe .any)}) {#.doc (doc "Rational literals." (ratio numerator denominator) "The denominator can be omitted if it is 1." @@ -48,14 +48,14 @@ (in (list (` ((~! ..normal) {#..numerator (~ numerator) #..denominator (~ (maybe.else (' 1) ?denominator))}))))) -(def: #export (= parameter subject) +(def: .public (= parameter subject) (-> Ratio Ratio Bit) (and (n.= (get@ #numerator parameter) (get@ #numerator subject)) (n.= (get@ #denominator parameter) (get@ #denominator subject)))) -(implementation: #export equivalence +(implementation: .public equivalence (Equivalence Ratio) (def: = ..=)) @@ -67,72 +67,72 @@ (n.* (get@ #denominator parameter) (get@ #numerator subject))]) -(def: #export (< parameter subject) +(def: .public (< parameter subject) (-> Ratio Ratio Bit) (let [[parameter' subject'] (..equalized parameter subject)] (n.< parameter' subject'))) -(def: #export (<= parameter subject) +(def: .public (<= parameter subject) (-> Ratio Ratio Bit) (or (< parameter subject) (= parameter subject))) -(def: #export (> parameter subject) +(def: .public (> parameter subject) (-> Ratio Ratio Bit) (..< subject parameter)) -(def: #export (>= parameter subject) +(def: .public (>= parameter subject) (-> Ratio Ratio Bit) (or (> parameter subject) (= parameter subject))) -(implementation: #export order +(implementation: .public order (Order Ratio) (def: &equivalence ..equivalence) (def: < ..<)) -(def: #export (+ parameter subject) +(def: .public (+ parameter subject) (-> Ratio Ratio Ratio) (let [[parameter' subject'] (..equalized parameter subject)] (normal [(n.+ parameter' subject') (n.* (get@ #denominator parameter) (get@ #denominator subject))]))) -(def: #export (- parameter subject) +(def: .public (- parameter subject) (-> Ratio Ratio Ratio) (let [[parameter' subject'] (..equalized parameter subject)] (normal [(n.- parameter' subject') (n.* (get@ #denominator parameter) (get@ #denominator subject))]))) -(def: #export (* parameter subject) +(def: .public (* parameter subject) (-> Ratio Ratio Ratio) (normal [(n.* (get@ #numerator parameter) (get@ #numerator subject)) (n.* (get@ #denominator parameter) (get@ #denominator subject))])) -(def: #export (/ parameter subject) +(def: .public (/ parameter subject) (-> Ratio Ratio Ratio) (let [[parameter' subject'] (..equalized parameter subject)] (normal [subject' parameter']))) -(def: #export (% parameter subject) +(def: .public (% parameter subject) (-> Ratio Ratio Ratio) (let [[parameter' subject'] (..equalized parameter subject) quot (n./ parameter' subject')] (..- (update@ #numerator (n.* quot) parameter) subject))) -(def: #export (reciprocal (^slots [#numerator #denominator])) +(def: .public (reciprocal (^slots [#numerator #denominator])) (-> Ratio Ratio) {#numerator denominator #denominator numerator}) (def: separator ":") -(implementation: #export codec +(implementation: .public codec (Codec Text Ratio) (def: (encode (^slots [#numerator #denominator])) @@ -151,7 +151,7 @@ (#.Left (text\compose "Invalid syntax for ratio: " input))))) (template [ ] - [(implementation: #export + [(implementation: .public (Monoid Ratio) (def: identity (..ratio )) diff --git a/stdlib/source/library/lux/math/number/rev.lux b/stdlib/source/library/lux/math/number/rev.lux index 66abd7e12..dadb71641 100644 --- a/stdlib/source/library/lux/math/number/rev.lux +++ b/stdlib/source/library/lux/math/number/rev.lux @@ -21,7 +21,7 @@ ["#." int]]) (template [ ] - [(def: #export + [(def: .public Rev (.rev (//i64.left_shifted (//nat.- //i64.width) 1)))] @@ -39,29 +39,29 @@ [12 /4096] ) -(def: #export (= reference sample) +(def: .public (= reference sample) {#.doc "Rev(olution) equivalence."} (-> Rev Rev Bit) ("lux i64 =" reference sample)) -(def: #export (< reference sample) +(def: .public (< reference sample) {#.doc "Rev(olution) less-than."} (-> Rev Rev Bit) (//nat.< (.nat reference) (.nat sample))) -(def: #export (<= reference sample) +(def: .public (<= reference sample) {#.doc "Rev(olution) less-than or equal."} (-> Rev Rev Bit) (if (//nat.< (.nat reference) (.nat sample)) true ("lux i64 =" reference sample))) -(def: #export (> reference sample) +(def: .public (> reference sample) {#.doc "Rev(olution) greater-than."} (-> Rev Rev Bit) (..< sample reference)) -(def: #export (>= reference sample) +(def: .public (>= reference sample) {#.doc "Rev(olution) greater-than or equal."} (-> Rev Rev Bit) (if (..< sample reference) @@ -69,7 +69,7 @@ ("lux i64 =" reference sample))) (template [ ] - [(def: #export ( left right) + [(def: .public ( left right) {#.doc } (-> Rev Rev Rev) (if ( right left) @@ -81,7 +81,7 @@ ) (template [ ] - [(def: #export ( param subject) + [(def: .public ( param subject) {#.doc } (-> Rev Rev Rev) ( param subject))] @@ -99,7 +99,7 @@ (let [mask (|> 1 ("lux i64 left-shift" 32) ("lux i64 -" 1))] (|>> ("lux i64 and" mask)))) -(def: #export (* param subject) +(def: .public (* param subject) {#.doc "Rev(olution) multiplication."} (-> Rev Rev Rev) (let [subjectH (..high subject) @@ -131,14 +131,14 @@ (//nat./ numerator ..odd_one)) (with_expansions [ 1] - (def: #export (reciprocal numerator) + (def: .public (reciprocal numerator) {#.doc "Rev(olution) reciprocal of a Nat(ural)."} (-> Nat Rev) (.rev (case (: Nat ("lux i64 and" numerator)) 0 (..even_reciprocal numerator) _ (..odd_reciprocal numerator)))) - (def: #export (/ param subject) + (def: .public (/ param subject) {#.doc "Rev(olution) division."} (-> Rev Rev Rev) (if ("lux i64 =" +0 param) @@ -149,7 +149,7 @@ (.rev (//nat.* reciprocal (.nat subject))))))) (template [ ] - [(def: #export ( param subject) + [(def: .public ( param subject) {#.doc } (-> Rev Rev ) ( ( (.nat param) (.nat subject))))] @@ -159,7 +159,7 @@ ) (template [ ] - [(def: #export ( scale subject) + [(def: .public ( scale subject) (-> Nat Rev Rev) (.rev ( (.nat scale) (.nat subject))))] @@ -167,7 +167,7 @@ [//nat./ down] ) -(def: #export (/% param subject) +(def: .public (/% param subject) (-> Rev Rev [Rev Rev]) [(../ param subject) (..% param subject)]) @@ -180,35 +180,35 @@ (def: frac_denominator (..mantissa -1)) -(def: #export frac +(def: .public frac (-> Rev Frac) (|>> ..mantissa ("lux f64 /" ..frac_denominator))) -(implementation: #export equivalence +(implementation: .public equivalence (Equivalence Rev) (def: = ..=)) -(implementation: #export hash +(implementation: .public hash (Hash Rev) (def: &equivalence ..equivalence) (def: hash .nat)) -(implementation: #export order +(implementation: .public order (Order Rev) (def: &equivalence ..equivalence) (def: < ..<)) -(implementation: #export enum +(implementation: .public enum (Enum Rev) (def: &order ..order) (def: succ inc) (def: pred dec)) -(implementation: #export interval +(implementation: .public interval (Interval Rev) (def: &enum ..enum) @@ -216,7 +216,7 @@ (def: bottom (.rev 0))) (template [ ] - [(implementation: #export + [(implementation: .public (Monoid Rev) (def: identity (\ interval )) @@ -233,7 +233,7 @@ (template [ ] [(with_expansions [ (as_is (#try.Failure ("lux text concat" repr)))] - (implementation: #export + (implementation: .public (Codec Text Rev) (def: (encode value) @@ -408,7 +408,7 @@ (digits\-!' idx (..digit idx param) output)) output))) -(implementation: #export decimal +(implementation: .public decimal (Codec Text Rev) (def: (encode input) diff --git a/stdlib/source/library/lux/math/random.lux b/stdlib/source/library/lux/math/random.lux index 7d80d6f76..a0f8f66a1 100644 --- a/stdlib/source/library/lux/math/random.lux +++ b/stdlib/source/library/lux/math/random.lux @@ -38,15 +38,15 @@ [type [refinement (#+ Refiner Refined)]]]]) -(type: #export #rec PRNG +(type: .public #rec PRNG {#.doc "An abstract way to represent any PRNG."} (-> Any [PRNG I64])) -(type: #export (Random a) +(type: .public (Random a) {#.doc "A producer of random values based on a PRNG."} (-> PRNG [PRNG a])) -(implementation: #export functor +(implementation: .public functor (Functor Random) (def: (map f fa) @@ -54,7 +54,7 @@ (let [[state' a] (fa state)] [state' (f a)])))) -(implementation: #export apply +(implementation: .public apply (Apply Random) (def: &functor ..functor) @@ -65,7 +65,7 @@ [state'' a] (fa state')] [state'' (f a)])))) -(implementation: #export monad +(implementation: .public monad (Monad Random) (def: &functor ..functor) @@ -79,7 +79,7 @@ (let [[state' fa] (ffa state)] (fa state'))))) -(def: #export (only pred gen) +(def: .public (only pred gen) {#.doc "Retries the generator until the output satisfies a predicate."} (All [a] (-> (-> a Bit) (Random a) (Random a))) (do ..monad @@ -88,7 +88,7 @@ (in sample) (only pred gen)))) -(def: #export (one check random) +(def: .public (one check random) (All [a b] (-> (-> a (Maybe b)) (Random a) (Random b))) (do ..monad @@ -100,7 +100,7 @@ #.None (one check random)))) -(def: #export (refined refiner gen) +(def: .public (refined refiner gen) {#.doc "Retries the generator until the output can be refined."} (All [t r] (-> (Refiner t r) (Random t) (Random (Refined t r)))) (do ..monad @@ -112,13 +112,13 @@ #.None (refined refiner gen)))) -(def: #export bit +(def: .public bit (Random Bit) (function (_ prng) (let [[prng output] (prng [])] [prng (|> output (i64.and 1) (n.= 1))]))) -(def: #export i64 +(def: .public i64 (Random I64) (function (_ prng) (let [[prng left] (prng []) @@ -128,7 +128,7 @@ ("lux i64 +" right))]))) (template [ ] - [(def: #export + [(def: .public (Random ) (\ ..monad map ..i64))] @@ -137,11 +137,11 @@ [rev Rev .rev] ) -(def: #export frac +(def: .public frac (Random Frac) (\ ..monad map (|>> .i64 f.of_bits) ..nat)) -(def: #export safe_frac +(def: .public safe_frac {#.doc (doc "A number in the interval [0.0,1.0].")} (Random Frac) (let [mantissa_range (.int (i64.left_shifted 53 1)) @@ -152,7 +152,7 @@ (f./ mantissa_max)) ..int))) -(def: #export (char set) +(def: .public (char set) (-> unicode.Set (Random Char)) (let [start (unicode.start set) end (unicode.end set) @@ -163,7 +163,7 @@ (\ ..monad map in_range) (..only (unicode.member? set))))) -(def: #export (text char_gen size) +(def: .public (text char_gen size) (-> (Random Char) Nat (Random Text)) (if (n.= 0 size) (\ ..monad in "") @@ -173,7 +173,7 @@ (in (text\compose (text.of_char x) xs))))) (template [ ] - [(def: #export + [(def: .public (-> Nat (Random Text)) (..text (..char )))] @@ -187,7 +187,7 @@ ) (template [ ] - [(def: #export + [(def: .public (Random ) (do ..monad [left @@ -198,7 +198,7 @@ [complex c.Complex c.complex ..safe_frac] ) -(def: #export (and left right) +(def: .public (and left right) {#.doc "Sequencing combinator."} (All [a b] (-> (Random a) (Random b) (Random [a b]))) (do ..monad @@ -206,7 +206,7 @@ =right right] (in [=left =right]))) -(def: #export (or left right) +(def: .public (or left right) {#.doc "Heterogeneous alternative combinator."} (All [a b] (-> (Random a) (Random b) (Random (Or a b)))) (do {! ..monad} @@ -219,7 +219,7 @@ [=right right] (in (0 #1 =right)))))) -(def: #export (either left right) +(def: .public (either left right) {#.doc "Homogeneous alternative combinator."} (All [a] (-> (Random a) (Random a) (Random a))) (do ..monad @@ -228,14 +228,14 @@ left right))) -(def: #export (rec gen) +(def: .public (rec gen) {#.doc "A combinator for producing recursive random generators."} (All [a] (-> (-> (Random a) (Random a)) (Random a))) (function (_ state) (let [gen' (gen (rec gen))] (gen' state)))) -(def: #export (maybe value_gen) +(def: .public (maybe value_gen) (All [a] (-> (Random a) (Random (Maybe a)))) (do {! ..monad} [some? bit] @@ -246,7 +246,7 @@ (in #.None)))) (template [ ] - [(def: #export ( size value_gen) + [(def: .public ( size value_gen) (All [a] (-> Nat (Random a) (Random ( a)))) (if (n.> 0 size) (do ..monad @@ -260,7 +260,7 @@ ) (template [ ] - [(def: #export ( size value_gen) + [(def: .public ( size value_gen) (All [a] (-> Nat (Random a) (Random ( a)))) (do ..monad [values (list size value_gen)] @@ -271,7 +271,7 @@ [stack Stack (list\fold stack.push stack.empty)] ) -(def: #export (set hash size value_gen) +(def: .public (set hash size value_gen) (All [a] (-> (Hash a) Nat (Random a) (Random (Set a)))) (if (n.> 0 size) (do {! ..monad} @@ -285,7 +285,7 @@ (recur []))))) (\ ..monad in (set.empty hash)))) -(def: #export (dictionary hash size key_gen value_gen) +(def: .public (dictionary hash size key_gen value_gen) (All [k v] (-> (Hash k) Nat (Random k) (Random v) (Random (Dictionary k v)))) (if (n.> 0 size) (do {! ..monad} @@ -300,23 +300,23 @@ (recur []))))) (\ ..monad in (dictionary.empty hash)))) -(def: #export instant +(def: .public instant (Random Instant) (\ ..monad map instant.of_millis ..int)) -(def: #export date +(def: .public date (Random Date) (\ ..monad map instant.date ..instant)) -(def: #export time +(def: .public time (Random Time) (\ ..monad map instant.time ..instant)) -(def: #export duration +(def: .public duration (Random Duration) (\ ..monad map duration.of_millis ..int)) -(def: #export month +(def: .public month (Random Month) (let [(^open "\.") ..monad] (..either (..either (..either (\in #month.January) @@ -332,7 +332,7 @@ (..either (\in #month.November) (\in #month.December))))))) -(def: #export day +(def: .public day (Random Day) (let [(^open "\.") ..monad] (..either (..either (\in #day.Sunday) @@ -343,18 +343,18 @@ (..either (\in #day.Friday) (\in #day.Saturday)))))) -(def: #export (run prng calc) +(def: .public (run prng calc) (All [a] (-> PRNG (Random a) [PRNG a])) (calc prng)) -(def: #export (prng update return) +(def: .public (prng update return) (All [a] (-> (-> a a) (-> a I64) (-> a PRNG))) (function (recur state) (function (_ _) [(recur (update state)) (return state)]))) -(def: #export (pcg_32 [increase seed]) +(def: .public (pcg_32 [increase seed]) {#.doc (doc "An implementation of the PCG32 algorithm." "For more information, please see: http://www.pcg-random.org/")} (-> [(I64 Any) (I64 Any)] PRNG) @@ -369,7 +369,7 @@ (i64.right_rotated rot) .i64))]))) -(def: #export (xoroshiro_128+ [s0 s1]) +(def: .public (xoroshiro_128+ [s0 s1]) {#.doc (doc "An implementation of the Xoroshiro128+ algorithm." "For more information, please see: http://xoroshiro.di.unimi.it/")} (-> [(I64 Any) (I64 Any)] PRNG) @@ -384,7 +384,7 @@ ## https://en.wikipedia.org/wiki/Xorshift#Initialization ## http://xorshift.di.unimi.it/splitmix64.c -(def: #export split_mix_64 +(def: .public split_mix_64 {#.doc (doc "An implementation of the SplitMix64 algorithm.")} (-> Nat PRNG) (let [twist (: (-> Nat Nat Nat) diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux index a3ae310b0..c3b66e3fc 100644 --- a/stdlib/source/library/lux/meta.lux +++ b/stdlib/source/library/lux/meta.lux @@ -29,7 +29,7 @@ ## (type: (Meta a) ## (-> Lux (Try [Lux a]))) -(implementation: #export functor +(implementation: .public functor (Functor Meta) (def: (map f fa) @@ -41,7 +41,7 @@ (#try.Success [compiler' a]) (#try.Success [compiler' (f a)]))))) -(implementation: #export apply +(implementation: .public apply (Apply Meta) (def: &functor ..functor) @@ -60,7 +60,7 @@ (#try.Failure msg) (#try.Failure msg))))) -(implementation: #export monad +(implementation: .public monad (Monad Meta) (def: &functor ..functor) @@ -78,11 +78,11 @@ (#try.Success [compiler' ma]) (ma compiler'))))) -(def: #export (run' compiler action) +(def: .public (run' compiler action) (All [a] (-> Lux (Meta a) (Try [Lux a]))) (action compiler)) -(def: #export (run compiler action) +(def: .public (run compiler action) (All [a] (-> Lux (Meta a) (Try a))) (case (action compiler) (#try.Failure error) @@ -91,7 +91,7 @@ (#try.Success [_ output]) (#try.Success output))) -(def: #export (either left right) +(def: .public (either left right) {#.doc "Pick whichever computation succeeds."} (All [a] (-> (Meta a) (Meta a) (Meta a))) (function (_ compiler) @@ -102,7 +102,7 @@ (#try.Success [compiler' output]) (#try.Success [compiler' output])))) -(def: #export (assertion message test) +(def: .public (assertion message test) {#.doc "Fails with the given message if the test is #0."} (-> Text Bit (Meta Any)) (function (_ compiler) @@ -110,14 +110,14 @@ (#try.Success [compiler []]) (#try.Failure message)))) -(def: #export (failure error) +(def: .public (failure error) {#.doc "Fails with the given error message."} (All [a] (-> Text (Meta a))) (function (_ state) (#try.Failure (location.with (get@ #.location state) error)))) -(def: #export (module name) +(def: .public (module name) (-> Text (Meta Module)) (function (_ compiler) (case (plist.get name (get@ #.modules compiler)) @@ -127,7 +127,7 @@ _ (#try.Failure ($_ text\compose "Unknown module: " name))))) -(def: #export current_module_name +(def: .public current_module_name (Meta Text) (function (_ compiler) (case (get@ #.current_module compiler) @@ -137,7 +137,7 @@ _ (#try.Failure "No current module.")))) -(def: #export current_module +(def: .public current_module (Meta Module) (let [(^open "\.") ..monad] (|> ..current_module_name @@ -153,7 +153,7 @@ _ false))) -(def: #export (normal name) +(def: .public (normal name) {#.doc (doc "If given a name without a module prefix, gives it the current module's name as prefix." "Otherwise, returns the name as-is.")} (-> Name (Meta Name)) @@ -184,7 +184,7 @@ (#.Some (:as Macro def_value)) #.None)))) -(def: #export (macro full_name) +(def: .public (macro full_name) (-> Name (Meta (Maybe Macro))) (do ..monad [[module name] (..normal full_name)] @@ -198,13 +198,13 @@ (macro' (get@ #.modules compiler) this_module module name))] (#try.Success [compiler macro])))))) -(def: #export seed +(def: .public seed (Meta Nat) (function (_ compiler) (#try.Success [(update@ #.seed inc compiler) (get@ #.seed compiler)]))) -(def: #export (module_exists? module) +(def: .public (module_exists? module) (-> Text (Meta Bit)) (function (_ compiler) (#try.Success [compiler (case (plist.get module (get@ #.modules compiler)) @@ -249,7 +249,7 @@ _ (\ ..monad in type))) -(def: #export (var_type name) +(def: .public (var_type name) {#.doc "Looks-up the type of a local variable somewhere in the environment."} (-> Text (Meta Type)) (function (_ compiler) @@ -274,7 +274,7 @@ #.None (#try.Failure ($_ text\compose "Unknown variable: " name)))))) -(def: #export (definition name) +(def: .public (definition name) {#.doc "Looks-up a definition's whole data in the available modules (including the current one)."} (-> Name (Meta Global)) (do ..monad @@ -331,7 +331,7 @@ "") " All known modules: " (|> compiler (get@ #.modules) (list\map product.left) (text.join_with separator)) text.new_line))))))) -(def: #export (export name) +(def: .public (export name) {#.doc "Looks-up a definition's type in the available modules (including the current one)."} (-> Name (Meta Definition)) (do ..monad @@ -348,7 +348,7 @@ (in definition) (failure ($_ text\compose "Definition is not an export: " (name\encode name)))))))) -(def: #export (definition_type name) +(def: .public (definition_type name) {#.doc "Looks-up a definition's type in the available modules (including the current one)."} (-> Name (Meta Type)) (do ..monad @@ -360,7 +360,7 @@ (#.Right [exported? def_type def_data def_value]) (clean_type def_type)))) -(def: #export (type name) +(def: .public (type name) {#.doc "Looks-up the type of either a local variable or a definition."} (-> Name (Meta Type)) (do ..monad @@ -373,7 +373,7 @@ _ (definition_type name)))) -(def: #export (type_definition name) +(def: .public (type_definition name) {#.doc "Finds the value of a type definition (such as Int, Any or Lux)."} (-> Name (Meta Type)) (do ..monad @@ -391,7 +391,7 @@ (in (:as Type def_value)) (..failure ($_ text\compose "Definition is not a type: " (name\encode name)))))))) -(def: #export (globals module) +(def: .public (globals module) {#.doc "The entire list of globals in a module (including the non-exported/private ones)."} (-> Text (Meta (List [Text Global]))) (function (_ compiler) @@ -402,7 +402,7 @@ (#.Some module) (#try.Success [compiler (get@ #.definitions module)])))) -(def: #export (definitions module) +(def: .public (definitions module) {#.doc "The entire list of definitions in a module (including the non-exported/private ones)."} (-> Text (Meta (List [Text Definition]))) (\ ..monad map @@ -415,7 +415,7 @@ (#.Some [name definition])))) (..globals module))) -(def: #export (exports module_name) +(def: .public (exports module_name) {#.doc "All the exported definitions in a module."} (-> Text (Meta (List [Text Definition]))) (do ..monad @@ -426,7 +426,7 @@ (in [name [exported? def_type def_data def_value]]) (list)))))) -(def: #export modules +(def: .public modules {#.doc "All the available modules (including the current one)."} (Meta (List [Text Module])) (function (_ compiler) @@ -435,7 +435,7 @@ [compiler] #try.Success))) -(def: #export (tags_of type_name) +(def: .public (tags_of type_name) {#.doc "All the tags associated with a type definition."} (-> Name (Meta (Maybe (List Name)))) (do ..monad @@ -448,13 +448,13 @@ _ (in #.None)))) -(def: #export location +(def: .public location {#.doc "The location of the current expression being analyzed."} (Meta Location) (function (_ compiler) (#try.Success [compiler (get@ #.location compiler)]))) -(def: #export expected_type +(def: .public expected_type {#.doc "The expected type of the current expression being analyzed."} (Meta Type) (function (_ compiler) @@ -465,26 +465,26 @@ #.None (#try.Failure "Not expecting any type.")))) -(def: #export (imported_modules module_name) +(def: .public (imported_modules module_name) {#.doc "All the modules imported by a specified module."} (-> Text (Meta (List Text))) (do ..monad [(^slots [#.imports]) (..module module_name)] (in imports))) -(def: #export (imported_by? import module) +(def: .public (imported_by? import module) (-> Text Text (Meta Bit)) (do ..monad [(^slots [#.imports]) (..module module)] (in (list.any? (text\= import) imports)))) -(def: #export (imported? import) +(def: .public (imported? import) (-> Text (Meta Bit)) (\ ..functor map (|>> (get@ #.imports) (list.any? (text\= import))) ..current_module)) -(def: #export (tag tag_name) +(def: .public (tag tag_name) {#.doc "Given a tag, finds out what is its index, its related tag-list and its associated type."} (-> Name (Meta [Nat (List Name) Type])) (do ..monad @@ -508,7 +508,7 @@ (text.join_with "")) ))))) -(def: #export (tag_lists module) +(def: .public (tag_lists module) {#.doc "All the tag-lists defined in a module, with their associated types."} (-> Text (Meta (List [(List Name) Type]))) (do ..monad @@ -521,7 +521,7 @@ (list\map (function (_ [type_name [tag_list exported? type]]) [tag_list type])))))) -(def: #export locals +(def: .public locals {#.doc "All the local variables currently in scope, separated in different scopes."} (Meta (List (List [Text Type]))) (function (_ compiler) @@ -536,7 +536,7 @@ [name type]))) scopes)])))) -(def: #export (de_aliased def_name) +(def: .public (de_aliased def_name) {#.doc "Given an aliased definition's name, returns the original definition being referenced."} (-> Name (Meta Name)) (do ..monad @@ -548,18 +548,18 @@ (#.Right _) def_name)))) -(def: #export get_compiler +(def: .public get_compiler {#.doc "Obtains the current state of the compiler."} (Meta Lux) (function (_ compiler) (#try.Success [compiler compiler]))) -(def: #export type_context +(def: .public type_context (Meta Type_Context) (function (_ compiler) (#try.Success [compiler (get@ #.type_context compiler)]))) -(def: #export (lift result) +(def: .public (lift result) (All [a] (-> (Try a) (Meta a))) (case result (#try.Success output) diff --git a/stdlib/source/library/lux/meta/annotation.lux b/stdlib/source/library/lux/meta/annotation.lux index b49dd5d8e..5180187e6 100644 --- a/stdlib/source/library/lux/meta/annotation.lux +++ b/stdlib/source/library/lux/meta/annotation.lux @@ -8,10 +8,10 @@ ["." maybe] ["." name ("#\." equivalence)]]]]) -(type: #export Annotation +(type: .public Annotation Code) -(def: #export (value tag ann) +(def: .public (value tag ann) (-> Name Annotation (Maybe Code)) (case ann [_ (#.Record ann)] @@ -34,7 +34,7 @@ #.None)) (template [ ] - [(def: #export ( tag ann) + [(def: .public ( tag ann) (-> Name Annotation (Maybe )) (case (..value tag ann) (#.Some [_ ( value)]) @@ -56,16 +56,16 @@ [record #.Record (List [Code Code])] ) -(def: #export documentation +(def: .public documentation (-> Annotation (Maybe Text)) (..text (name_of #.doc))) -(def: #export (flagged? flag) +(def: .public (flagged? flag) (-> Name Annotation Bit) (|>> (..bit flag) (maybe.else false))) (template [ ] - [(def: #export + [(def: .public (-> Annotation Bit) (..flagged? (name_of )))] @@ -84,7 +84,7 @@ #.None)) (template [ ] - [(def: #export ( ann) + [(def: .public ( ann) (-> Annotation (List Text)) (<| (maybe.else (list)) (do {! maybe.monad} diff --git a/stdlib/source/library/lux/meta/location.lux b/stdlib/source/library/lux/meta/location.lux index 9216889f0..7e21951ce 100644 --- a/stdlib/source/library/lux/meta/location.lux +++ b/stdlib/source/library/lux/meta/location.lux @@ -4,7 +4,7 @@ [abstract [equivalence (#+ Equivalence)]]]]) -(implementation: #export equivalence +(implementation: .public equivalence (Equivalence Location) (def: (= reference subject) @@ -12,13 +12,13 @@ ("lux i64 =" (get@ #.line reference) (get@ #.line subject)) ("lux i64 =" (get@ #.column reference) (get@ #.column subject))))) -(def: #export dummy +(def: .public dummy Location {#.module "" #.line 0 #.column 0}) -(macro: #export (here tokens compiler) +(macro: .public (here tokens compiler) {#.doc (doc "The Location of the current form." (here))} (case tokens @@ -33,7 +33,7 @@ _ (#.Left (`` (("lux in-module" (~~ (static .prelude_module)) wrong_syntax_error) (name_of ..here)))))) -(def: #export (format value) +(def: .public (format value) (-> Location Text) (let [separator "," [file line column] value] @@ -46,7 +46,7 @@ (def: \n ("lux i64 char" +10)) -(def: #export (with location error) +(def: .public (with location error) (-> Location Text Text) ($_ "lux text concat" (..format location) \n error)) diff --git a/stdlib/source/library/lux/program.lux b/stdlib/source/library/lux/program.lux index f17d42ec1..d2caa1a85 100644 --- a/stdlib/source/library/lux/program.lux +++ b/stdlib/source/library/lux/program.lux @@ -31,7 +31,7 @@ (in [(code.identifier ["" name]) (` (~! .any))])) (.record (<>.and .any .any))))))) -(syntax: #export (program: +(syntax: .public (program: {args ..arguments^} body) {#.doc (doc "Defines the entry-point to a program (similar to the 'main' function/method in other programming languages)." diff --git a/stdlib/source/library/lux/target.lux b/stdlib/source/library/lux/target.lux index 323cf812b..c2da2412f 100644 --- a/stdlib/source/library/lux/target.lux +++ b/stdlib/source/library/lux/target.lux @@ -2,11 +2,11 @@ [library lux]) -(type: #export Target +(type: .public Target Text) (template [ ] - [(def: #export + [(def: .public Target )] diff --git a/stdlib/source/library/lux/target/common_lisp.lux b/stdlib/source/library/lux/target/common_lisp.lux index ed040a6b4..3bd089fa6 100644 --- a/stdlib/source/library/lux/target/common_lisp.lux +++ b/stdlib/source/library/lux/target/common_lisp.lux @@ -20,21 +20,23 @@ (-> Text Text) (text.enclosed ["(" ")"])) -(abstract: #export (Code brand) +(abstract: .public (Code brand) + {} + Text - (def: #export manual + (def: .public manual (-> Text Code) (|>> :abstraction)) - (def: #export code + (def: .public code (-> (Code Any) Text) (|>> :representation)) (template [ ] [(with_expansions [ (template.identifier [ "'"])] - (`` (abstract: #export ( brand) Any)) - (`` (type: #export ( brand) + (`` (abstract: .public ( brand) {} Any)) + (`` (type: .public ( brand) ( ( brand)))))] [Expression Code] @@ -47,8 +49,8 @@ (template [ ] [(with_expansions [ (template.identifier [ "'"])] - (`` (abstract: #export Any)) - (`` (type: #export ( ))))] + (`` (abstract: .public {} Any)) + (`` (type: .public ( ))))] [Label Code] [Tag Expression] @@ -57,32 +59,32 @@ [Var/* Input] ) - (type: #export Lambda + (type: .public Lambda {#input Var/* #output (Expression Any)}) - (def: #export nil + (def: .public nil Literal (:abstraction "()")) (template [ ] - [(def: #export + [(def: .public (-> Text Literal) (|>> (format ) :abstraction))] ["'" symbol] [":" keyword]) - (def: #export bool + (def: .public bool (-> Bit Literal) (|>> (case> #0 ..nil #1 (..symbol "t")))) - (def: #export int + (def: .public int (-> Int Literal) (|>> %.int :abstraction)) - (def: #export float + (def: .public float (-> Frac Literal) (|>> (cond> [(f.= f.positive_infinity)] [(new> "(/ 1.0 0.0)" [])] @@ -97,7 +99,7 @@ [%.frac]) :abstraction)) - (def: #export (double value) + (def: .public (double value) (-> Frac Literal) (:abstraction (.cond (f.= f.positive_infinity value) @@ -132,24 +134,24 @@ )) ))) - (def: #export string + (def: .public string (-> Text Literal) (|>> ..safe (text.enclosed' text.double_quote) :abstraction)) - (def: #export var + (def: .public var (-> Text Var/1) (|>> :abstraction)) - (def: #export args + (def: .public args (-> (List Var/1) Var/*) (|>> (list\map ..code) (text.join_with " ") ..as_form :abstraction)) - (def: #export (args& singles rest) + (def: .public (args& singles rest) (-> (List Var/1) Var/1 Var/*) (|> (case singles #.End @@ -171,12 +173,12 @@ ..as_form :abstraction)) - (def: #export (call/* func) + (def: .public (call/* func) (-> (Expression Any) (-> (List (Expression Any)) (Computation Any))) (|>> (#.Item func) ..form)) (template [ ] - [(def: #export + [(def: .public (-> (List (Expression Any)) (Computation Any)) (..call/* (..var )))] @@ -184,7 +186,7 @@ [list/* "list"] ) - (def: #export (labels definitions body) + (def: .public (labels definitions body) (-> (List [Var/1 Lambda]) (Expression Any) (Computation Any)) (..form (list (..var "labels") (..form (list\map (function (_ [def_name [def_args def_body]]) @@ -192,19 +194,19 @@ definitions)) body))) - (def: #export (destructuring_bind [bindings expression] body) + (def: .public (destructuring_bind [bindings expression] body) (-> [Var/* (Expression Any)] (List (Expression Any)) (Computation Any)) (..form (list& (..var "destructuring-bind") (:transmutation bindings) expression body))) (template [ + + +] - [(`` (def: #export ( [(~~ (template.spliced +))] function) + [(`` (def: .public ( [(~~ (template.spliced +))] function) (-> [(~~ (template.spliced +))] (Expression Any) (Computation Any)) (..call/* function (list (~~ (template.spliced +)))))) (`` (template [ ] - [(def: #export ( args) + [(def: .public ( args) (-> [(~~ (template.spliced +))] (Computation Any)) ( args (..var )))] @@ -262,7 +264,7 @@ (template [ + +] [(`` (template [ ] - [(def: #export ( args) + [(def: .public ( args) (-> [(~~ (template.spliced +))] (Access Any)) (:transmutation ( args (..var ))))] @@ -279,29 +281,29 @@ [gethash/2 "gethash"]]] ) - (def: #export (make_hash_table/with_size size) + (def: .public (make_hash_table/with_size size) (-> (Expression Any) (Computation Any)) (..call/* (..var "make-hash-table") (list (..keyword "size") size))) - (def: #export (funcall/+ [func args]) + (def: .public (funcall/+ [func args]) (-> [(Expression Any) (List (Expression Any))] (Computation Any)) (..call/* (..var "funcall") (list& func args))) - (def: #export (search/3 [reference space start]) + (def: .public (search/3 [reference space start]) (-> [(Expression Any) (Expression Any) (Expression Any)] (Computation Any)) (..call/* (..var "search") (list reference space (..keyword "start2") start))) - (def: #export (concatenate/2|string [left right]) + (def: .public (concatenate/2|string [left right]) (-> [(Expression Any) (Expression Any)] (Computation Any)) (concatenate/3 [(..symbol "string") left right])) (template [ ] - [(def: #export ( left right) + [(def: .public ( left right) (-> (Expression Any) (Expression Any) (Computation Any)) (..form (list (..var ) left right)))] @@ -310,7 +312,7 @@ ) (template [ ] - [(def: #export ( [param subject]) + [(def: .public ( [param subject]) (-> [(Expression Any) (Expression Any)] (Computation Any)) (..form (list (..var ) subject param)))] @@ -330,20 +332,20 @@ [logxor/2 "logxor"] ) - (def: #export (if test then else) + (def: .public (if test then else) (-> (Expression Any) (Expression Any) (Expression Any) (Computation Any)) (..form (list (..var "if") test then else))) - (def: #export (when test then) + (def: .public (when test then) (-> (Expression Any) (Expression Any) (Computation Any)) (..form (list (..var "when") test then))) - (def: #export (lambda input body) + (def: .public (lambda input body) (-> Var/* (Expression Any) Literal) (..form (list (..var "lambda") (:transmutation input) body))) (template [ ] - [(def: #export ( bindings body) + [(def: .public ( bindings body) (-> (List [Var/1 (Expression Any)]) (List (Expression Any)) (Computation Any)) (..form (list& (..var ) (|> bindings @@ -356,16 +358,16 @@ [let* "let*"] ) - (def: #export (defparameter name body) + (def: .public (defparameter name body) (-> Var/1 (Expression Any) (Expression Any)) (..form (list (..var "defparameter") name body))) - (def: #export (defun name inputs body) + (def: .public (defun name inputs body) (-> Var/1 Var/* (Expression Any) (Expression Any)) (..form (list (..var "defun") name (:transmutation inputs) body))) (template [ ] - [(def: #export + [(def: .public (-> (List (Expression Any)) (Computation Any)) (|>> (list& (..var )) ..form))] @@ -374,20 +376,20 @@ [values/* "values"] ) - (def: #export (setq name value) + (def: .public (setq name value) (-> Var/1 (Expression Any) (Expression Any)) (..form (list (..var "setq") name value))) - (def: #export (setf access value) + (def: .public (setf access value) (-> (Access Any) (Expression Any) (Expression Any)) (..form (list (..var "setf") access value))) - (type: #export Handler + (type: .public Handler {#condition_type (Expression Any) #condition Var/1 #body (Expression Any)}) - (def: #export (handler_case handlers body) + (def: .public (handler_case handlers body) (-> (List Handler) (Expression Any) (Computation Any)) (..form (list& (..var "handler-case") body @@ -398,7 +400,7 @@ handlers)))) (template [ ] - [(def: #export ( conditions expression) + [(def: .public ( conditions expression) (-> (List Text) (Expression Any) (Expression Any)) (case conditions #.End @@ -418,23 +420,23 @@ [conditional+ "#+"] [conditional- "#-"]) - (def: #export label + (def: .public label (-> Text Label) (|>> :abstraction)) - (def: #export (block name body) + (def: .public (block name body) (-> Label (List (Expression Any)) (Computation Any)) (..form (list& (..var "block") (:transmutation name) body))) - (def: #export (return_from target value) + (def: .public (return_from target value) (-> Label (Expression Any) (Computation Any)) (..form (list (..var "return-from") (:transmutation target) value))) - (def: #export (return value) + (def: .public (return value) (-> (Expression Any) (Computation Any)) (..form (list (..var "return") value))) - (def: #export (cond clauses else) + (def: .public (cond clauses else) (-> (List [(Expression Any) (Expression Any)]) (Expression Any) (Computation Any)) (..form (list& (..var "cond") (list\compose (list\map (function (_ [test then]) @@ -442,28 +444,28 @@ clauses) (list (..form (list (..bool true) else))))))) - (def: #export tag + (def: .public tag (-> Text Tag) (|>> :abstraction)) - (def: #export go + (def: .public go (-> Tag (Expression Any)) (|>> (list (..var "go")) ..form)) - (def: #export values_list/1 + (def: .public values_list/1 (-> (Expression Any) (Expression Any)) (|>> (list (..var "values-list")) ..form)) - (def: #export (multiple_value_setq bindings values) + (def: .public (multiple_value_setq bindings values) (-> Var/* (Expression Any) (Expression Any)) (..form (list (..var "multiple-value-setq") (:transmutation bindings) values))) ) -(def: #export (while condition body) +(def: .public (while condition body) (-> (Expression Any) (Expression Any) (Computation Any)) (..form (list (..var "loop") (..var "while") condition (..var "do") body))) diff --git a/stdlib/source/library/lux/target/js.lux b/stdlib/source/library/lux/target/js.lux index 1ef296cdf..27e77e1fd 100644 --- a/stdlib/source/library/lux/target/js.lux +++ b/stdlib/source/library/lux/target/js.lux @@ -28,17 +28,19 @@ (|>> (format text.new_line) (text.replace_all text.new_line (format text.new_line text.tab)))) -(abstract: #export (Code brand) +(abstract: .public (Code brand) + {} + Text - (def: #export code + (def: .public code (-> (Code Any) Text) (|>> :representation)) (template [ +] [(with_expansions [ (template.identifier [ "'"])] - (abstract: ( brand) Any) - (`` (type: #export (|> Any (~~ (template.spliced +))))))] + (abstract: ( brand) {} Any) + (`` (type: .public (|> Any (~~ (template.spliced +))))))] [Expression [Code]] [Computation [Expression' Code]] @@ -48,8 +50,8 @@ (template [ +] [(with_expansions [ (template.identifier [ "'"])] - (abstract: #export Any) - (`` (type: #export (|> (~~ (template.spliced +))))))] + (abstract: .public {} Any) + (`` (type: .public (|> (~~ (template.spliced +))))))] [Var [Location' Computation' Expression' Code]] [Access [Location' Computation' Expression' Code]] @@ -59,20 +61,20 @@ ) (template [ ] - [(def: #export Literal (:abstraction ))] + [(def: .public Literal (:abstraction ))] [null "null"] [undefined "undefined"] ) - (def: #export boolean + (def: .public boolean (-> Bit Literal) (|>> (case> #0 "false" #1 "true") :abstraction)) - (def: #export (number value) + (def: .public (number value) (-> Frac Literal) (:abstraction (.cond (f.not_a_number? value) @@ -105,7 +107,7 @@ )) ))) - (def: #export string + (def: .public string (-> Text Literal) (|>> ..safe (text.enclosed [text.double_quote text.double_quote]) @@ -115,26 +117,26 @@ (def: field_separator ": ") (def: statement_suffix ";") - (def: #export array + (def: .public array (-> (List Expression) Computation) (|>> (list\map ..code) (text.join_with ..argument_separator) ..element :abstraction)) - (def: #export var + (def: .public var (-> Text Var) (|>> :abstraction)) - (def: #export (at index array_or_object) + (def: .public (at index array_or_object) (-> Expression Expression Access) (:abstraction (format (:representation array_or_object) (..element (:representation index))))) - (def: #export (the field object) + (def: .public (the field object) (-> Text Expression Access) (:abstraction (format (:representation object) "." field))) - (def: #export (apply/* function inputs) + (def: .public (apply/* function inputs) (-> Expression (List Expression) Computation) (|> inputs (list\map ..code) @@ -143,11 +145,11 @@ (format (:representation function)) :abstraction)) - (def: #export (do method inputs object) + (def: .public (do method inputs object) (-> Text (List Expression) Expression Computation) (apply/* (..the method object) inputs)) - (def: #export object + (def: .public object (-> (List [Text Expression]) Computation) (|>> (list\map (.function (_ [key val]) (format (:representation (..string key)) ..field_separator (:representation val)))) @@ -156,13 +158,13 @@ ..expression :abstraction)) - (def: #export (, pre post) + (def: .public (, pre post) (-> Expression Expression Computation) (|> (format (:representation pre) ..argument_separator (:representation post)) ..expression :abstraction)) - (def: #export (then pre post) + (def: .public (then pre post) (-> Statement Statement Statement) (:abstraction (format (:representation pre) text.new_line @@ -176,7 +178,7 @@ (text.enclosed ["{" close])))) - (def: #export (function! name inputs body) + (def: .public (function! name inputs body) (-> Var (List Var) Statement Statement) (|> body ..block @@ -188,14 +190,14 @@ " ") :abstraction)) - (def: #export (function name inputs body) + (def: .public (function name inputs body) (-> Var (List Var) Statement Computation) (|> (..function! name inputs body) :representation ..expression :abstraction)) - (def: #export (closure inputs body) + (def: .public (closure inputs body) (-> (List Var) Statement Computation) (|> body ..block @@ -209,7 +211,7 @@ :abstraction)) (template [ ] - [(def: #export ( param subject) + [(def: .public ( param subject) (-> Expression Expression Computation) (|> (format (:representation subject) " " " " (:representation param)) ..expression @@ -239,7 +241,7 @@ ) (template [ ] - [(def: #export + [(def: .public (-> Expression Computation) (|>> :representation (text.prefix ) ..expression :abstraction))] @@ -249,7 +251,7 @@ ) (template [ ] - [(def: #export ( value) + [(def: .public ( value) {#.doc "A 32-bit integer expression."} (-> Computation) (:abstraction (..expression (format ( value) "|0"))))] @@ -258,13 +260,13 @@ [i32 Int %.int] ) - (def: #export (int value) + (def: .public (int value) (-> Int Literal) (:abstraction (.if (i.< +0 value) (%.int value) (%.nat (.nat value))))) - (def: #export (? test then else) + (def: .public (? test then else) (-> Expression Expression Expression Computation) (|> (format (:representation test) " ? " (:representation then) @@ -272,14 +274,14 @@ ..expression :abstraction)) - (def: #export type_of + (def: .public type_of (-> Expression Computation) (|>> :representation (format "typeof ") ..expression :abstraction)) - (def: #export (new constructor inputs) + (def: .public (new constructor inputs) (-> Expression (List Expression) Computation) (|> (format "new " (:representation constructor) (|> inputs @@ -289,76 +291,76 @@ ..expression :abstraction)) - (def: #export statement + (def: .public statement (-> Expression Statement) (|>> :representation (text.suffix ..statement_suffix) :abstraction)) - (def: #export use_strict + (def: .public use_strict Statement (:abstraction (format text.double_quote "use strict" text.double_quote ..statement_suffix))) - (def: #export (declare name) + (def: .public (declare name) (-> Var Statement) (:abstraction (format "var " (:representation name) ..statement_suffix))) - (def: #export (define name value) + (def: .public (define name value) (-> Var Expression Statement) (:abstraction (format "var " (:representation name) " = " (:representation value) ..statement_suffix))) - (def: #export (set' name value) + (def: .public (set' name value) (-> Location Expression Expression) (:abstraction (..expression (format (:representation name) " = " (:representation value))))) - (def: #export (set name value) + (def: .public (set name value) (-> Location Expression Statement) (:abstraction (format (:representation name) " = " (:representation value) ..statement_suffix))) - (def: #export (throw message) + (def: .public (throw message) (-> Expression Statement) (:abstraction (format "throw " (:representation message) ..statement_suffix))) - (def: #export (return value) + (def: .public (return value) (-> Expression Statement) (:abstraction (format "return " (:representation value) ..statement_suffix))) - (def: #export (delete' value) + (def: .public (delete' value) (-> Location Expression) (:abstraction (format "delete " (:representation value)))) - (def: #export (delete value) + (def: .public (delete value) (-> Location Statement) (:abstraction (format (:representation (delete' value)) ..statement_suffix))) - (def: #export (if test then! else!) + (def: .public (if test then! else!) (-> Expression Statement Statement Statement) (:abstraction (format "if(" (:representation test) ") " (..block then!) " else " (..block else!)))) - (def: #export (when test then!) + (def: .public (when test then!) (-> Expression Statement Statement) (:abstraction (format "if(" (:representation test) ") " (..block then!)))) - (def: #export (while test body) + (def: .public (while test body) (-> Expression Statement Loop) (:abstraction (format "while(" (:representation test) ") " (..block body)))) - (def: #export (do_while test body) + (def: .public (do_while test body) (-> Expression Statement Loop) (:abstraction (format "do " (..block body) " while(" (:representation test) ")" ..statement_suffix))) - (def: #export (try body [exception catch]) + (def: .public (try body [exception catch]) (-> Statement [Var Statement] Statement) (:abstraction (format "try " (..block body) " catch(" (:representation exception) ") " (..block catch)))) - (def: #export (for var init condition update iteration) + (def: .public (for var init condition update iteration) (-> Var Expression Expression Expression Statement Loop) (:abstraction (format "for(" (:representation (..define var init)) " " (:representation condition) @@ -366,20 +368,20 @@ ")" (..block iteration)))) - (def: #export label + (def: .public label (-> Text Label) (|>> :abstraction)) - (def: #export (with_label label loop) + (def: .public (with_label label loop) (-> Label Loop Statement) (:abstraction (format (:representation label) ": " (:representation loop)))) (template [ <0> <1>] - [(def: #export <0> + [(def: .public <0> Statement (:abstraction (format ..statement_suffix))) - (def: #export (<1> label) + (def: .public (<1> label) (-> Label Statement) (:abstraction (format " " (:representation label) ..statement_suffix)))] @@ -388,7 +390,7 @@ ) (template [ ] - [(def: #export + [(def: .public (-> Location Expression) (|>> :representation (text.suffix ) @@ -398,11 +400,11 @@ [-- "--"] ) - (def: #export (comment commentary on) + (def: .public (comment commentary on) (All [kind] (-> Text (Code kind) (Code kind))) (:abstraction (format "/* " commentary " */" " " (:representation on)))) - (def: #export (switch input cases default) + (def: .public (switch input cases default) (-> Expression (List [(List Literal) Statement]) (Maybe Statement) Statement) (:abstraction (format "switch (" (:representation input) ") " (|> (format (|> cases @@ -423,7 +425,7 @@ ..block)))) ) -(def: #export (cond clauses else!) +(def: .public (cond clauses else!) (-> (List [Expression Statement]) Statement Statement) (list\fold (.function (_ [test then!] next!) (..if test then! next!)) @@ -431,13 +433,13 @@ (list.reversed clauses))) (template [ + + +] - [(`` (def: #export ( function) + [(`` (def: .public ( function) (-> Expression (~~ (template.spliced +)) Computation) (.function (_ (~~ (template.spliced +))) (..apply/* function (list (~~ (template.spliced +))))))) (`` (template [ ] - [(def: #export ( (..var )))] + [(def: .public ( (..var )))] (~~ (template.spliced +))))] diff --git a/stdlib/source/library/lux/target/jvm.lux b/stdlib/source/library/lux/target/jvm.lux index b470abea9..1ada0da04 100644 --- a/stdlib/source/library/lux/target/jvm.lux +++ b/stdlib/source/library/lux/target/jvm.lux @@ -9,7 +9,7 @@ [type (#+ Type) ["." category (#+ Primitive Class Value Method)]]]]]]) -(type: #export Literal +(type: .public Literal (#Boolean Bit) (#Int Int) (#Long Int) @@ -17,7 +17,7 @@ (#Char Nat) (#String Text)) -(type: #export Constant +(type: .public Constant (#BIPUSH Int) (#SIPUSH Int) @@ -44,7 +44,7 @@ (#LDC Literal)) -(type: #export Int_Arithmetic +(type: .public Int_Arithmetic #IADD #ISUB #IMUL @@ -52,7 +52,7 @@ #IREM #INEG) -(type: #export Long_Arithmetic +(type: .public Long_Arithmetic #LADD #LSUB #LMUL @@ -60,7 +60,7 @@ #LREM #LNEG) -(type: #export Float_Arithmetic +(type: .public Float_Arithmetic #FADD #FSUB #FMUL @@ -68,7 +68,7 @@ #FREM #FNEG) -(type: #export Double_Arithmetic +(type: .public Double_Arithmetic #DADD #DSUB #DMUL @@ -76,13 +76,13 @@ #DREM #DNEG) -(type: #export Arithmetic +(type: .public Arithmetic (#Int_Arithmetic Int_Arithmetic) (#Long_Arithmetic Long_Arithmetic) (#Float_Arithmetic Float_Arithmetic) (#Double_Arithmetic Double_Arithmetic)) -(type: #export Int_Bitwise +(type: .public Int_Bitwise #IOR #IXOR #IAND @@ -90,7 +90,7 @@ #ISHR #IUSHR) -(type: #export Long_Bitwise +(type: .public Long_Bitwise #LOR #LXOR #LAND @@ -98,11 +98,11 @@ #LSHR #LUSHR) -(type: #export Bitwise +(type: .public Bitwise (#Int_Bitwise Int_Bitwise) (#Long_Bitwise Long_Bitwise)) -(type: #export Conversion +(type: .public Conversion #I2B #I2S #I2L @@ -122,7 +122,7 @@ #D2L #D2F) -(type: #export Array +(type: .public Array #ARRAYLENGTH (#NEWARRAY (Type Primitive)) @@ -152,7 +152,7 @@ #AALOAD #AASTORE) -(type: #export Object +(type: .public Object (#GETSTATIC (Type Class) Text (Type Value)) (#PUTSTATIC (Type Class) Text (Type Value)) @@ -169,29 +169,29 @@ (#INVOKESTATIC (Type Class) Text (Type Method)) (#INVOKEVIRTUAL (Type Class) Text (Type Method))) -(type: #export Register Nat) +(type: .public Register Nat) -(type: #export Local_Int +(type: .public Local_Int (#ILOAD Register) (#ISTORE Register)) -(type: #export Local_Long +(type: .public Local_Long (#LLOAD Register) (#LSTORE Register)) -(type: #export Local_Float +(type: .public Local_Float (#FLOAD Register) (#FSTORE Register)) -(type: #export Local_Double +(type: .public Local_Double (#DLOAD Register) (#DSTORE Register)) -(type: #export Local_Object +(type: .public Local_Object (#ALOAD Register) (#ASTORE Register)) -(type: #export Local +(type: .public Local (#Local_Int Local_Int) (#IINC Register) (#Local_Long Local_Long) @@ -199,7 +199,7 @@ (#Local_Double Local_Double) (#Local_Object Local_Object)) -(type: #export Stack +(type: .public Stack #DUP #DUP_X1 #DUP_X2 @@ -210,7 +210,7 @@ #POP #POP2) -(type: #export Comparison +(type: .public Comparison #LCMP #FCMPG @@ -219,9 +219,9 @@ #DCMPG #DCMPL) -(type: #export Label Nat) +(type: .public Label Nat) -(type: #export (Branching label) +(type: .public (Branching label) (#IF_ICMPEQ label) (#IF_ICMPGE label) (#IF_ICMPGT label) @@ -243,15 +243,15 @@ (#IFNONNULL label) (#IFNULL label)) -(type: #export (Exception label) +(type: .public (Exception label) (#Try label label label (Type Class)) #ATHROW) -(type: #export Concurrency +(type: .public Concurrency #MONITORENTER #MONITOREXIT) -(type: #export Return +(type: .public Return #RETURN #IRETURN #LRETURN @@ -259,14 +259,14 @@ #DRETURN #ARETURN) -(type: #export (Control label) +(type: .public (Control label) (#GOTO label) (#Branching (Branching label)) (#Exception (Exception label)) (#Concurrency Concurrency) (#Return Return)) -(type: #export (Instruction embedded label) +(type: .public (Instruction embedded label) #NOP (#Constant Constant) (#Arithmetic Arithmetic) @@ -280,5 +280,5 @@ (#Control (Control label)) (#Embedded embedded)) -(type: #export (Bytecode embedded label) +(type: .public (Bytecode embedded label) (Row (Instruction embedded label))) diff --git a/stdlib/source/library/lux/target/jvm/attribute.lux b/stdlib/source/library/lux/target/jvm/attribute.lux index 6d94c1b5b..0aa919723 100644 --- a/stdlib/source/library/lux/target/jvm/attribute.lux +++ b/stdlib/source/library/lux/target/jvm/attribute.lux @@ -25,12 +25,12 @@ ["#." constant (#+ Constant)] ["#." code]]) -(type: #export (Info about) +(type: .public (Info about) {#name (Index UTF8) #length U4 #info about}) -(def: #export (info_equivalence Equivalence) +(def: .public (info_equivalence Equivalence) (All [about] (-> (Equivalence about) (Equivalence (Info about)))) @@ -51,15 +51,15 @@ (|>> nameT lengthT infoT)]))) (with_expansions [ (as_is (/code.Code Attribute))] - (type: #export #rec Attribute + (type: .public #rec Attribute (#Constant (Info (Constant Any))) (#Code (Info ))) - (type: #export Code + (type: .public Code ) ) -(def: #export equivalence +(def: .public equivalence (Equivalence Attribute) (equivalence.rec (function (_ equivalence) @@ -90,7 +90,7 @@ #length (|> /constant.length //unsigned.u4 try.assumed) #info index})) -(def: #export (constant index) +(def: .public (constant index) (-> (Constant Any) (Resource Attribute)) (do //constant/pool.monad [@name (//constant/pool.utf8 "ConstantValue")] @@ -107,13 +107,13 @@ try.assumed) #info specification})) -(def: #export (code specification) +(def: .public (code specification) (-> Code (Resource Attribute)) (do //constant/pool.monad [@name (//constant/pool.utf8 "Code")] (in (code' @name specification)))) -(def: #export (writer value) +(def: .public (writer value) (Writer Attribute) (case value (#Constant attribute) diff --git a/stdlib/source/library/lux/target/jvm/attribute/code.lux b/stdlib/source/library/lux/target/jvm/attribute/code.lux index 2f80d96d2..733fd4d7c 100644 --- a/stdlib/source/library/lux/target/jvm/attribute/code.lux +++ b/stdlib/source/library/lux/target/jvm/attribute/code.lux @@ -22,13 +22,13 @@ ["." / #_ ["#." exception (#+ Exception)]]) -(type: #export (Code Attribute) +(type: .public (Code Attribute) {#limit Limit #code Binary #exception_table (Row Exception) #attributes (Row Attribute)}) -(def: #export (length length code) +(def: .public (length length code) (All [Attribute] (-> (-> Attribute Nat) (Code Attribute) Nat)) ($_ n.+ ## u2 max_stack; @@ -53,7 +53,7 @@ (row\map length) (row\fold n.+ 0)))) -(def: #export (equivalence attribute_equivalence) +(def: .public (equivalence attribute_equivalence) (All [attribute] (-> (Equivalence attribute) (Equivalence (Code attribute)))) ($_ product.equivalence @@ -64,7 +64,7 @@ )) ## https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3 -(def: #export (writer writer code) +(def: .public (writer writer code) (All [Attribute] (-> (Writer Attribute) (Writer (Code Attribute)))) ($_ binaryF\compose ## u2 max_stack; diff --git a/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux b/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux index e2aa089b0..42bb8ebb9 100644 --- a/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux +++ b/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux @@ -19,13 +19,13 @@ [encoding ["#." unsigned (#+ U2)]]]]) -(type: #export Exception +(type: .public Exception {#start Address #end Address #handler Address #catch (Index Class)}) -(def: #export equivalence +(def: .public equivalence (Equivalence Exception) ($_ product.equivalence ////address.equivalence @@ -35,7 +35,7 @@ )) ## https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3 -(def: #export length +(def: .public length Nat ($_ n.+ ## u2 start_pc; @@ -48,7 +48,7 @@ ////unsigned.bytes/2 )) -(def: #export writer +(def: .public writer (Writer Exception) ($_ format.and ////address.writer diff --git a/stdlib/source/library/lux/target/jvm/attribute/constant.lux b/stdlib/source/library/lux/target/jvm/attribute/constant.lux index d9f26d418..8d7a0a26a 100644 --- a/stdlib/source/library/lux/target/jvm/attribute/constant.lux +++ b/stdlib/source/library/lux/target/jvm/attribute/constant.lux @@ -12,16 +12,16 @@ [encoding ["#." unsigned (#+ U2 U4)]]]) -(type: #export (Constant a) +(type: .public (Constant a) (Index (Value a))) -(def: #export equivalence +(def: .public equivalence (All [a] (Equivalence (Constant a))) ///index.equivalence) -(def: #export length +(def: .public length ///index.length) -(def: #export writer +(def: .public writer (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 a22ff102b..fa48223ae 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode.lux @@ -51,11 +51,11 @@ ["." reflection] ["." parser]]]]) -(type: #export Label Nat) +(type: .public Label Nat) -(type: #export Resolver (Dictionary Label [Stack (Maybe Address)])) +(type: .public Resolver (Dictionary Label [Stack (Maybe Address)])) -(type: #export Tracker +(type: .public Tracker {#program_counter Address #next Label #known Resolver}) @@ -66,7 +66,7 @@ #next 0 #known (dictionary.empty n.hash)}) -(type: #export Relative +(type: .public Relative (-> Resolver (Try [(Row Exception) Instruction]))) (def: no_exceptions @@ -97,10 +97,10 @@ (in [(\ row.monoid compose left_exceptions right_exceptions) (_\compose left_instruction right_instruction)])))))) -(type: #export (Bytecode a) +(type: .public (Bytecode a) (+State Try [Pool Environment Tracker] (Writer Relative a))) -(def: #export new_label +(def: .public new_label (Bytecode Label) (function (_ [pool environment tracker]) (#try.Success [[pool @@ -109,11 +109,11 @@ [..relative_identity (get@ #next tracker)]]))) -(exception: #export (label_has_already_been_set {label Label}) +(exception: .public (label_has_already_been_set {label Label}) (exception.report ["Label" (%.nat label)])) -(exception: #export (mismatched_environments {instruction Name} +(exception: .public (mismatched_environments {instruction Name} {label Label} {address Address} {expected Stack} @@ -132,7 +132,7 @@ tracker)] [..relative_identity []]]))] - (def: #export (set_label label) + (def: .public (set_label label) (-> Label (Bytecode Any)) (function (_ [pool environment tracker]) (let [@here (get@ #program_counter tracker)] @@ -153,7 +153,7 @@ environment)] )))))) -(def: #export monad +(def: .public monad (Monad Bytecode) (<| (:as (Monad Bytecode)) (writer.with ..relative_monoid) @@ -162,15 +162,15 @@ (: (Monad Try)) try.monad)) -(def: #export failure +(def: .public failure (-> Text Bytecode) (|>> #try.Failure function.constant)) -(def: #export (except exception value) +(def: .public (except exception value) (All [e] (-> (exception.Exception e) e Bytecode)) (..failure (exception.error exception value))) -(def: #export (resolve environment bytecode) +(def: .public (resolve environment bytecode) (All [a] (-> Environment (Bytecode a) (Resource [Environment (Row Exception) Instruction a]))) (function (_ pool) (do try.monad @@ -221,7 +221,7 @@ ) (template [ ] - [(def: #export + [(def: .public (Bytecode Any) (..bytecode @@ -416,7 +416,7 @@ []]])))) (template [ ] - [(def: #export + [(def: .public (Bytecode Any) (do ..monad [_ (..bytecode $0 @_ [])] @@ -432,7 +432,7 @@ [athrow $1 _.athrow] ) -(def: #export (bipush byte) +(def: .public (bipush byte) (-> S1 (Bytecode Any)) (..bytecode $0 $1 @_ _.bipush [byte])) @@ -447,7 +447,7 @@ [..relative_identity output]])))) -(def: #export (string value) +(def: .public (string value) (-> //constant.UTF8 (Bytecode Any)) (do ..monad [index (..lift (//constant/pool.string value))] @@ -467,7 +467,7 @@ (#static doubleToRawLongBits #manual [double] long)]) (template [ ] - [(def: #export ( value) + [(def: .public ( value) (-> (Bytecode Any)) (case (|> value ) (^template [ ] @@ -514,7 +514,7 @@ (def: negative_zero_float_bits (|> -0.0 (:as java/lang/Double) ffi.double_to_float ..float_bits)) -(def: #export (float value) +(def: .public (float value) (-> java/lang/Float (Bytecode Any)) (if (i.= ..negative_zero_float_bits (..float_bits value)) @@ -529,7 +529,7 @@ _ (..arbitrary_float value)))) (template [ ] - [(def: #export ( value) + [(def: .public ( value) (-> (Bytecode Any)) (case (|> value ) (^template [ ] @@ -560,7 +560,7 @@ (def: negative_zero_double_bits (..double_bits (:as java/lang/Double -0.0))) -(def: #export (double value) +(def: .public (double value) (-> java/lang/Double (Bytecode Any)) (if (i.= ..negative_zero_double_bits (..double_bits value)) @@ -573,7 +573,7 @@ _ (..arbitrary_double value)))) -(exception: #export (invalid_register {id Nat}) +(exception: .public (invalid_register {id Nat}) (exception.report ["ID" (%.nat id)])) @@ -587,7 +587,7 @@ (..except ..invalid_register [id]))) (template [ ] - [(def: #export ( local) + [(def: .public ( local) (-> Nat (Bytecode Any)) (with_expansions [' (template.spliced )] (`` (case local @@ -627,7 +627,7 @@ ) (template [ ] - [(def: #export ( local) + [(def: .public ( local) (-> Nat (Bytecode Any)) (with_expansions [' (template.spliced )] (`` (case local @@ -667,7 +667,7 @@ ) (template [ ] - [(def: #export + [(def: .public (-> (Bytecode Any)) (..bytecode @_ ))] @@ -675,11 +675,11 @@ [$0 $1 sipush _.sipush S2] ) -(exception: #export (unknown_label {label Label}) +(exception: .public (unknown_label {label Label}) (exception.report ["Label" (%.nat label)])) -(exception: #export (cannot_do_a_big_jump {label Label} +(exception: .public (cannot_do_a_big_jump {label Label} {@from Address} {jump Big_Jump}) (exception.report @@ -703,7 +703,7 @@ (\ ! map (|>> #.Left) (//signed.s4 jump)) (\ ! map (|>> #.Right) (//signed.s2 jump)))))) -(exception: #export (unset_label {label Label}) +(exception: .public (unset_label {label Label}) (exception.report ["Label" (%.nat label)])) @@ -729,7 +729,7 @@ (update@ #known (dictionary.put label [stack #.None]) tracker))) (template [ ] - [(def: #export ( label) + [(def: .public ( label) (-> Label (Bytecode Any)) (let [[estimator bytecode] ] (function (_ [pool environment tracker]) @@ -781,7 +781,7 @@ ) (template [ ] - [(def: #export ( label) + [(def: .public ( label) (-> Label (Bytecode Any)) (let [[estimator bytecode] ] (function (_ [pool environment tracker]) @@ -833,9 +833,9 @@ (#.Right small) (/jump.lift small))) -(exception: #export invalid_tableswitch) +(exception: .public invalid_tableswitch) -(def: #export (tableswitch minimum default [at_minimum afterwards]) +(def: .public (tableswitch minimum default [at_minimum afterwards]) (-> S4 Label [Label (List Label)] (Bytecode Any)) (let [[estimator bytecode] _.tableswitch] (function (_ [pool environment tracker]) @@ -872,9 +872,9 @@ (exception.except ..invalid_tableswitch [])))) []]])))))) -(exception: #export invalid_lookupswitch) +(exception: .public invalid_lookupswitch) -(def: #export (lookupswitch default cases) +(def: .public (lookupswitch default cases) (-> Label (List [S4 Label]) (Bytecode Any)) (let [cases (list.sort (function (_ [left _] [right _]) (i.< (//signed.value left) @@ -920,7 +920,7 @@ (|>> type.reflection reflection.reflection)) (template [ ] - [(def: #export ( class) + [(def: .public ( class) (-> (Type ) (Bytecode Any)) (do ..monad [## TODO: Make sure it's impossible to have indexes greater than U2. @@ -933,16 +933,16 @@ [$1 $1 instanceof Object _.instanceof] ) -(def: #export (iinc register increase) +(def: .public (iinc register increase) (-> Nat U1 (Bytecode Any)) (do ..monad [register (..register register)] (..bytecode $0 $0 (/registry.for register) _.iinc [register increase]))) -(exception: #export (multiarray_cannot_be_zero_dimensional {class (Type Object)}) +(exception: .public (multiarray_cannot_be_zero_dimensional {class (Type Object)}) (exception.report ["Class" (..reflection class)])) -(def: #export (multianewarray class dimensions) +(def: .public (multianewarray class dimensions) (-> (Type Object) U1 (Bytecode Any)) (do ..monad [_ (: (Bytecode Any) @@ -965,7 +965,7 @@ 1)) (template [ ] - [(def: #export ( class method type) + [(def: .public ( class method type) (-> (Type Class) Text (Type Method) (Bytecode Any)) (let [[type_variables inputs output exceptions] (parser.method type)] (do ..monad @@ -991,7 +991,7 @@ ) (template [ <1> <2>] - [(def: #export ( class field type) + [(def: .public ( class field type) (-> (Type Class) Text (Type Value) (Bytecode Any)) (do ..monad [index (<| ..lift @@ -1009,12 +1009,12 @@ [$2 putfield _.putfield/1 _.putfield/2] ) -(exception: #export (invalid_range_for_try {start Address} {end Address}) +(exception: .public (invalid_range_for_try {start Address} {end Address}) (exception.report ["Start" (|> start /address.value //unsigned.value %.nat)] ["End" (|> end /address.value //unsigned.value %.nat)])) -(def: #export (try @start @end @handler catch) +(def: .public (try @start @end @handler catch) (-> Label Label Label (Type Class) (Bytecode Any)) (do ..monad [@catch (..lift (//constant/pool.class (//name.internal (..reflection catch))))] @@ -1038,7 +1038,7 @@ _.empty]))) []]])))) -(def: #export (compose pre post) +(def: .public (compose pre post) (All [pre post] (-> (Bytecode pre) (Bytecode post) (Bytecode post))) (do ..monad diff --git a/stdlib/source/library/lux/target/jvm/bytecode/address.lux b/stdlib/source/library/lux/target/jvm/bytecode/address.lux index 8a42afb41..d7f2f612f 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/address.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/address.lux @@ -23,18 +23,20 @@ ["#." unsigned (#+ U2)] ["#." signed (#+ S4)]]]]) -(abstract: #export Address +(abstract: .public Address + {} + U2 - (def: #export value + (def: .public value (-> Address U2) (|>> :representation)) - (def: #export start + (def: .public start Address (|> 0 ///unsigned.u2 try.assumed :abstraction)) - (def: #export (move distance) + (def: .public (move distance) (-> U2 (-> Address (Try Address))) (|>> :representation (///unsigned.+/2 distance) @@ -44,19 +46,19 @@ (-> Address (Try S4)) (|>> :representation ///unsigned.value .int ///signed.s4)) - (def: #export (jump from to) + (def: .public (jump from to) (-> Address Address (Try Big_Jump)) (do try.monad [from (with_sign from) to (with_sign to)] (///signed.-/4 from to))) - (def: #export (after? reference subject) + (def: .public (after? reference subject) (-> Address Address Bit) (n.> (|> reference :representation ///unsigned.value) (|> subject :representation ///unsigned.value))) - (implementation: #export equivalence + (implementation: .public equivalence (Equivalence Address) (def: (= reference subject) @@ -64,11 +66,11 @@ (:representation reference) (:representation subject)))) - (def: #export writer + (def: .public writer (Writer Address) (|>> :representation ///unsigned.writer/2)) - (def: #export format + (def: .public format (Format Address) (|>> :representation ///unsigned.value %.nat)) ) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux index 6fbdadfa3..d426726e3 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux @@ -17,12 +17,12 @@ [type (#+ Type) [category (#+ Method)]]]]) -(type: #export Environment +(type: .public Environment {#limit Limit #stack (Maybe Stack)}) (template [ ] - [(def: #export ( type) + [(def: .public ( type) (-> (Type Method) (Try Environment)) (do try.monad [limit ( type)] @@ -33,10 +33,10 @@ [virtual /limit.virtual] ) -(type: #export Condition +(type: .public Condition (-> Environment (Try Environment))) -(implementation: #export monoid +(implementation: .public monoid (Monoid Condition) (def: identity (|>> #try.Success)) @@ -47,9 +47,9 @@ [environment (left environment)] (right environment))))) -(exception: #export discontinuity) +(exception: .public discontinuity) -(def: #export (stack environment) +(def: .public (stack environment) (-> Environment (Try Stack)) (case (get@ #..stack environment) (#.Some stack) @@ -58,17 +58,17 @@ #.None (exception.except ..discontinuity []))) -(def: #export discontinue +(def: .public discontinue (-> Environment Environment) (set@ #..stack #.None)) -(exception: #export (mismatched_stacks {expected Stack} +(exception: .public (mismatched_stacks {expected Stack} {actual Stack}) (exception.report ["Expected" (/stack.format expected)] ["Actual" (/stack.format actual)])) -(def: #export (continue expected environment) +(def: .public (continue expected environment) (-> Stack Environment (Try [Stack Environment])) (case (get@ #..stack environment) (#.Some actual) @@ -79,7 +79,7 @@ #.None (#try.Success [expected (set@ #..stack (#.Some expected) environment)]))) -(def: #export (consumes amount) +(def: .public (consumes amount) (-> U2 Condition) ## TODO: Revisit this definition once lenses/optics have been implemented, ## since it can probably be simplified with them. @@ -89,7 +89,7 @@ current (/stack.pop amount previous)] (in (set@ #..stack (#.Some current) environment))))) -(def: #export (produces amount) +(def: .public (produces amount) (-> U2 Condition) (function (_ environment) (do try.monad @@ -102,7 +102,7 @@ (set@ #..stack (#.Some current)) (set@ [#..limit #/limit.stack] limit)))))) -(def: #export (has registry) +(def: .public (has registry) (-> Registry Condition) (|>> (update@ [#..limit #/limit.registry] (/registry.has registry)) #try.Success)) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux index fad7c9dae..d8117947e 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux @@ -20,12 +20,12 @@ [type (#+ Type) [category (#+ Method)]]]]) -(type: #export Limit +(type: .public Limit {#stack Stack #registry Registry}) (template [ ] - [(def: #export ( type) + [(def: .public ( type) (-> (Type Method) (Try Limit)) (do try.monad [registry ( type)] @@ -36,21 +36,21 @@ [virtual /registry.virtual] ) -(def: #export length +(def: .public length ($_ n.+ ## u2 max_stack; /stack.length ## u2 max_locals; /registry.length)) -(def: #export equivalence +(def: .public equivalence (Equivalence Limit) ($_ product.equivalence /stack.equivalence /registry.equivalence )) -(def: #export (writer limit) +(def: .public (writer limit) (Writer Limit) ($_ format\compose (/stack.writer (get@ #stack limit)) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux index 3773b4333..7db606a0b 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux @@ -22,15 +22,17 @@ [category (#+ Method)] ["#/." parser]]]) -(type: #export Register U1) +(type: .public Register U1) (def: normal 1) (def: wide 2) -(abstract: #export Registry +(abstract: .public Registry + {} + U2 - (def: #export registry + (def: .public registry (-> U2 Registry) (|>> :abstraction)) @@ -46,7 +48,7 @@ (list\fold n.+ 0)))) (template [ ] - [(def: #export + [(def: .public (-> (Type Method) (Try Registry)) (|>> ..minimal (n.+ ) @@ -57,24 +59,24 @@ [1 virtual] ) - (def: #export equivalence + (def: .public equivalence (Equivalence Registry) (\ equivalence.functor map (|>> :representation) /////unsigned.equivalence)) - (def: #export writer + (def: .public writer (Writer Registry) (|>> :representation /////unsigned.writer/2)) - (def: #export (has needed) + (def: .public (has needed) (-> Registry Registry Registry) (|>> :representation (/////unsigned.max/2 (:representation needed)) :abstraction)) (template [ ] - [(def: #export + [(def: .public (-> Register Registry) (let [extra (|> /////unsigned.u2 try.assumed)] (|>> /////unsigned.lift/2 @@ -87,5 +89,5 @@ ) ) -(def: #export length +(def: .public length /////unsigned.bytes/2) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux index 99a560347..a825e6699 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux @@ -17,11 +17,13 @@ [encoding ["#." unsigned (#+ U2)]]]) -(abstract: #export Stack +(abstract: .public Stack + {} + U2 (template [ ] - [(def: #export + [(def: .public Stack (|> /////unsigned.u2 maybe.assume :abstraction))] @@ -29,13 +31,13 @@ [1 catch] ) - (def: #export equivalence + (def: .public equivalence (Equivalence Stack) (\ equivalence.functor map (|>> :representation) /////unsigned.equivalence)) - (def: #export writer + (def: .public writer (Writer Stack) (|>> :representation /////unsigned.writer/2)) @@ -44,7 +46,7 @@ (|>> :abstraction)) (template [ ] - [(def: #export ( amount) + [(def: .public ( amount) (-> U2 (-> Stack (Try Stack))) (|>> :representation ( amount) @@ -54,16 +56,16 @@ [/////unsigned.-/2 pop] ) - (def: #export (max left right) + (def: .public (max left right) (-> Stack Stack Stack) (:abstraction (/////unsigned.max/2 (:representation left) (:representation right)))) - (def: #export format + (def: .public format (Format Stack) (|>> :representation /////unsigned.value %.nat)) ) -(def: #export length +(def: .public length /////unsigned.bytes/2) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux index 3302b60dc..5aee5816a 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux @@ -36,23 +36,23 @@ [type [category (#+ Value Method)]]]]) -(type: #export Size U2) +(type: .public Size U2) -(type: #export Estimator +(type: .public Estimator (-> Address Size)) (def: fixed (-> Size Estimator) function.constant) -(type: #export Instruction +(type: .public Instruction (-> Specification Specification)) -(def: #export empty +(def: .public empty Instruction function.identity) -(def: #export run +(def: .public run (-> Instruction Specification) (function.apply format.no_op)) @@ -232,7 +232,9 @@ [(n.+ (///unsigned.value ..size/211) size) (|>> mutation ((trinary/211' opcode input0 input1 input2)))])]) -(abstract: #export Primitive_Array_Type +(abstract: .public Primitive_Array_Type + {} + U1 (def: code @@ -240,7 +242,7 @@ (|>> :representation)) (template [ ] - [(def: #export (|> ///unsigned.u1 try.assumed :abstraction))] + [(def: .public (|> ///unsigned.u1 try.assumed :abstraction))] [04 t_boolean] [05 t_char] @@ -491,7 +493,7 @@ [] ')] - (def: #export + (def: .public [Estimator (-> [] Instruction)] (let [[estimator '] ] [estimator @@ -582,7 +584,7 @@ (n.- (n.% 4 parameter_start) 4)))) -(def: #export tableswitch +(def: .public tableswitch [(-> Nat Estimator) (-> S4 Big_Jump [Big_Jump (List Big_Jump)] Instruction)] (let [estimator (: (-> Nat Estimator) @@ -646,7 +648,7 @@ size) (|>> mutation tableswitch_mutation)]))))])) -(def: #export lookupswitch +(def: .public lookupswitch [(-> Nat Estimator) (-> Big_Jump (List [S4 Big_Jump]) Instruction)] (let [case_size (n.+ (///unsigned.value ..integer_size) @@ -706,7 +708,7 @@ size) (|>> mutation lookupswitch_mutation)]))))])) -(implementation: #export monoid +(implementation: .public monoid (Monoid Instruction) (def: identity ..empty) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/jump.lux b/stdlib/source/library/lux/target/jvm/bytecode/jump.lux index 2873ef781..53fdd6081 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/jump.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/jump.lux @@ -10,18 +10,18 @@ [encoding ["#." signed (#+ S2 S4)]]]) -(type: #export Jump S2) +(type: .public Jump S2) -(def: #export equivalence +(def: .public equivalence (Equivalence Jump) ///signed.equivalence) -(def: #export writer +(def: .public writer (Writer Jump) ///signed.writer/2) -(type: #export Big_Jump S4) +(type: .public Big_Jump S4) -(def: #export lift +(def: .public lift (-> Jump Big_Jump) ///signed.lift/4) diff --git a/stdlib/source/library/lux/target/jvm/class.lux b/stdlib/source/library/lux/target/jvm/class.lux index 2e4b8eb15..17561fa0d 100644 --- a/stdlib/source/library/lux/target/jvm/class.lux +++ b/stdlib/source/library/lux/target/jvm/class.lux @@ -1,6 +1,6 @@ (.module: [library - [lux #* + [lux (#- public private) [abstract [equivalence (#+ Equivalence)] ["." monad (#+ do)]] @@ -27,7 +27,7 @@ ["#." constant (#+ Constant) ["#/." pool (#+ Pool Resource)]]]) -(type: #export #rec Class +(type: .public #rec Class {#magic Magic #minor_version Minor #major_version Major @@ -51,7 +51,7 @@ ["4000" enum] ) -(def: #export equivalence +(def: .public equivalence (Equivalence Class) ($_ product.equivalence //unsigned.equivalence @@ -81,7 +81,7 @@ interfaces))] (in [@this @super @interfaces]))) -(def: #export (class version modifier +(def: .public (class version modifier this super interfaces fields methods attributes) (-> Major (Modifier Class) @@ -110,7 +110,7 @@ #methods (row.of_list =methods) #attributes attributes}))) -(def: #export (writer class) +(def: .public (writer class) (Writer Class) (`` ($_ binaryF\compose (~~ (template [ ] diff --git a/stdlib/source/library/lux/target/jvm/constant.lux b/stdlib/source/library/lux/target/jvm/constant.lux index 7f2a7aa26..229dd247f 100644 --- a/stdlib/source/library/lux/target/jvm/constant.lux +++ b/stdlib/source/library/lux/target/jvm/constant.lux @@ -34,24 +34,26 @@ [encoding ["#." unsigned]]]]) -(type: #export UTF8 Text) +(type: .public UTF8 Text) (def: utf8_writer (Writer UTF8) binaryF.utf8/16) -(abstract: #export Class +(abstract: .public Class + {} + (Index UTF8) - (def: #export index + (def: .public index (-> Class (Index UTF8)) (|>> :representation)) - (def: #export class + (def: .public class (-> (Index UTF8) Class) (|>> :abstraction)) - (def: #export class_equivalence + (def: .public class_equivalence (Equivalence Class) (\ equivalence.functor map ..index @@ -66,7 +68,7 @@ ["#::." (#static floatToRawIntBits #manual [float] int)]) -(implementation: #export float_equivalence +(implementation: .public float_equivalence (Equivalence java/lang/Float) (def: (= parameter subject) @@ -82,14 +84,16 @@ ["#::." (#static doubleToRawLongBits [double] long)]) -(abstract: #export (Value kind) +(abstract: .public (Value kind) + {} + kind - (def: #export value + (def: .public value (All [kind] (-> (Value kind) kind)) (|>> :representation)) - (def: #export (value_equivalence Equivalence) + (def: .public (value_equivalence Equivalence) (All [kind] (-> (Equivalence kind) (Equivalence (Value kind)))) @@ -98,9 +102,9 @@ Equivalence)) (template [ ] - [(type: #export (Value )) + [(type: .public (Value )) - (def: #export + (def: .public (-> ) (|>> :abstraction))] @@ -126,16 +130,16 @@ ) ) -(type: #export (Name_And_Type of) +(type: .public (Name_And_Type of) {#name (Index UTF8) #descriptor (Index (Descriptor of))}) -(type: #export (Reference of) +(type: .public (Reference of) {#class (Index Class) #name_and_type (Index (Name_And_Type of))}) (template [ ] - [(def: #export + [(def: .public (Equivalence ( Any)) ($_ product.equivalence //index.equivalence @@ -151,7 +155,7 @@ [Reference reference_equivalence reference_writer] ) -(type: #export Constant +(type: .public Constant (#UTF8 UTF8) (#Integer Integer) (#Float Float) @@ -164,7 +168,7 @@ (#Interface_Method (Reference //category.Method)) (#Name_And_Type (Name_And_Type Any))) -(def: #export (size constant) +(def: .public (size constant) (-> Constant Nat) (case constant (^or (#Long _) (#Double _)) @@ -173,7 +177,7 @@ _ 1)) -(def: #export equivalence +(def: .public equivalence (Equivalence Constant) ## TODO: Delete the explicit "implementation" and use the combinator ## version below as soon as the new format for variants is implemented. @@ -219,7 +223,7 @@ ## ) ) -(def: #export writer +(def: .public writer (Writer Constant) (with_expansions [ (as_is [#UTF8 /tag.utf8 ..utf8_writer] [#Integer /tag.integer ..integer_writer] diff --git a/stdlib/source/library/lux/target/jvm/constant/pool.lux b/stdlib/source/library/lux/target/jvm/constant/pool.lux index d050b1e34..a82683e1b 100644 --- a/stdlib/source/library/lux/target/jvm/constant/pool.lux +++ b/stdlib/source/library/lux/target/jvm/constant/pool.lux @@ -35,59 +35,59 @@ [category (#+ Value Method)] ["#." descriptor (#+ Descriptor)]]]]) -(type: #export Pool [Index (Row [Index Constant])]) +(type: .public Pool [Index (Row [Index Constant])]) -(def: #export equivalence +(def: .public equivalence (Equivalence Pool) (product.equivalence //index.equivalence (row.equivalence (product.equivalence //index.equivalence //.equivalence)))) -(type: #export (Resource a) +(type: .public (Resource a) (+State Try Pool a)) -(def: #export monad +(def: .public monad (Monad Resource) (state.with try.monad)) (template: (!add ) - (function (_ [current pool]) - (let [' ] - (with_expansions [ (as_is (recur (.inc idx)))] - (loop [idx 0] - (case (row.item idx pool) - (#try.Success entry) - (case entry - [index ( reference)] - (if (\ = reference ') - (#try.Success [[current pool] - index]) - ) - - _ - ) - - (#try.Failure _) - (let [new ( ')] - (do {! try.monad} - [@new (//unsigned.u2 (//.size new)) - next (: (Try Index) - (|> current - //index.value - (//unsigned.+/2 @new) - (\ ! map //index.index)))] - (in [[next - (row.add [current new] pool)] - current]))))))))) + [(function (_ [current pool]) + (let [' ] + (with_expansions [ (as_is (recur (.inc idx)))] + (loop [idx 0] + (case (row.item idx pool) + (#try.Success entry) + (case entry + [index ( reference)] + (if (\ = reference ') + (#try.Success [[current pool] + index]) + ) + + _ + ) + + (#try.Failure _) + (let [new ( ')] + (do {! try.monad} + [@new (//unsigned.u2 (//.size new)) + next (: (Try Index) + (|> current + //index.value + (//unsigned.+/2 @new) + (\ ! map //index.index)))] + (in [[next + (row.add [current new] pool)] + current]))))))))]) (template: (!index ) - (|> //index.value //unsigned.value)) + [(|> //index.value //unsigned.value)]) (type: (Adder of) (-> of (Resource (Index of)))) (template [ ] - [(def: #export ( value) + [(def: .public ( value) (Adder ) (!add value))] @@ -98,32 +98,32 @@ [utf8 UTF8 #//.UTF8 text.equivalence] ) -(def: #export (string value) +(def: .public (string value) (-> Text (Resource (Index String))) (do ..monad [@value (utf8 value) .let [value (//.string @value)]] (!add #//.String (//.value_equivalence //index.equivalence) value))) -(def: #export (class name) +(def: .public (class name) (-> Internal (Resource (Index Class))) (do ..monad [@name (utf8 (//name.read name)) .let [value (//.class @name)]] (!add #//.Class //.class_equivalence value))) -(def: #export (descriptor value) +(def: .public (descriptor value) (All [kind] (-> (Descriptor kind) (Resource (Index (Descriptor kind))))) (let [value (//descriptor.descriptor value)] (!add #//.UTF8 text.equivalence value))) -(type: #export (Member of) +(type: .public (Member of) {#name UTF8 #descriptor (Descriptor of)}) -(def: #export (name_and_type [name descriptor]) +(def: .public (name_and_type [name descriptor]) (All [of] (-> (Member of) (Resource (Index (Name_And_Type of))))) (do ..monad @@ -132,7 +132,7 @@ (!add #//.Name_And_Type //.name_and_type_equivalence {#//.name @name #//.descriptor @descriptor}))) (template [ ] - [(def: #export ( class member) + [(def: .public ( class member) (-> External (Member ) (Resource (Index (Reference )))) (do ..monad [@class (..class (//name.internal class)) @@ -144,7 +144,7 @@ [interface_method #//.Interface_Method Method] ) -(def: #export writer +(def: .public writer (Writer Pool) (function (_ [next pool]) (row\fold (function (_ [_index post] pre) @@ -152,7 +152,7 @@ (format.bits/16 (!index next)) pool))) -(def: #export empty +(def: .public empty Pool [(|> 1 //unsigned.u2 try.assumed //index.index) row.empty]) diff --git a/stdlib/source/library/lux/target/jvm/constant/tag.lux b/stdlib/source/library/lux/target/jvm/constant/tag.lux index 0eba9788e..7d53837f0 100644 --- a/stdlib/source/library/lux/target/jvm/constant/tag.lux +++ b/stdlib/source/library/lux/target/jvm/constant/tag.lux @@ -14,17 +14,19 @@ [encoding ["#." unsigned (#+ U1) ("u1//." equivalence)]]]) -(abstract: #export Tag +(abstract: .public Tag + {} + U1 - (implementation: #export equivalence + (implementation: .public equivalence (Equivalence Tag) (def: (= reference sample) (u1//= (:representation reference) (:representation sample)))) (template [ ] - [(def: #export + [(def: .public Tag (|> ///unsigned.u1 try.assumed :abstraction))] @@ -44,7 +46,7 @@ [18 invoke_dynamic] ) - (def: #export writer + (def: .public writer (Writer Tag) (|>> :representation ///unsigned.writer/1)) ) diff --git a/stdlib/source/library/lux/target/jvm/encoding/name.lux b/stdlib/source/library/lux/target/jvm/encoding/name.lux index 02507ceb6..a0761950e 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/name.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/name.lux @@ -7,34 +7,36 @@ [type abstract]]]) -(def: #export internal_separator "/") -(def: #export external_separator ".") +(def: .public internal_separator "/") +(def: .public external_separator ".") -(type: #export External Text) +(type: .public External Text) -(abstract: #export Internal +(abstract: .public Internal + {} + Text - (def: #export internal + (def: .public internal (-> External Internal) (|>> (text.replace_all ..external_separator ..internal_separator) :abstraction)) - (def: #export read + (def: .public read (-> Internal Text) (|>> :representation)) - (def: #export external + (def: .public external (-> Internal External) (|>> :representation (text.replace_all ..internal_separator ..external_separator)))) -(def: #export safe +(def: .public safe (-> Text External) (|>> ..internal ..external)) -(def: #export (qualify package class) +(def: .public (qualify package class) (-> Text External External) (format (..safe package) ..external_separator class)) diff --git a/stdlib/source/library/lux/target/jvm/encoding/signed.lux b/stdlib/source/library/lux/target/jvm/encoding/signed.lux index dfdcedbb6..196f60380 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/signed.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/signed.lux @@ -22,26 +22,28 @@ [type abstract]]]) -(abstract: #export (Signed brand) +(abstract: .public (Signed brand) + {} + Int - (def: #export value + (def: .public value (-> (Signed Any) Int) (|>> :representation)) - (implementation: #export equivalence + (implementation: .public equivalence (All [brand] (Equivalence (Signed brand))) (def: (= reference sample) (i.= (:representation reference) (:representation sample)))) - (implementation: #export order + (implementation: .public order (All [brand] (Order (Signed brand))) (def: &equivalence ..equivalence) (def: (< reference sample) (i.< (:representation reference) (:representation sample)))) - (exception: #export (value_exceeds_the_scope {value Int} + (exception: .public (value_exceeds_the_scope {value Int} {scope Nat}) (exception.report ["Value" (%.int value)] @@ -49,16 +51,16 @@ (template [ <+> <->] [(with_expansions [ (template.identifier [ "'"])] - (abstract: #export Any) - (type: #export (Signed ))) + (abstract: .public {} Any) + (type: .public (Signed ))) - (def: #export ) + (def: .public ) - (def: #export + (def: .public (|> (n.* i64.bits_per_byte) dec i64.mask :abstraction)) - (def: #export + (def: .public (-> Int (Try )) (let [positive (|> (n.* i64.bits_per_byte) i64.mask) negative (|> positive .int (i.right_shifted 1) i64.not)] @@ -71,7 +73,7 @@ (exception.except ..value_exceeds_the_scope [value ]))))) (template [ ] - [(def: #export ( parameter subject) + [(def: .public ( parameter subject) (-> (Try )) ( ( (:representation parameter) @@ -87,7 +89,7 @@ ) (template [ ] - [(def: #export + [(def: .public (-> ) (|>> :transmutation))] @@ -96,7 +98,7 @@ ) (template [ ] - [(def: #export + [(def: .public (Writer ) (|>> :representation ))] diff --git a/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux b/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux index 546d4f516..e9084bb9d 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux @@ -21,20 +21,22 @@ [type abstract]]]) -(abstract: #export (Unsigned brand) +(abstract: .public (Unsigned brand) + {} + Nat - (def: #export value + (def: .public value (-> (Unsigned Any) Nat) (|>> :representation)) - (implementation: #export equivalence + (implementation: .public equivalence (All [brand] (Equivalence (Unsigned brand))) (def: (= reference sample) (n.= (:representation reference) (:representation sample)))) - (implementation: #export order + (implementation: .public order (All [brand] (Order (Unsigned brand))) (def: &equivalence ..equivalence) @@ -42,7 +44,7 @@ (n.< (:representation reference) (:representation sample)))) - (exception: #export (value_exceeds_the_maximum {type Name} + (exception: .public (value_exceeds_the_maximum {type Name} {value Nat} {maximum (Unsigned Any)}) (exception.report @@ -50,7 +52,7 @@ ["Value" (%.nat value)] ["Maximum" (%.nat (:representation maximum))])) - (exception: #export [brand] (subtraction_cannot_yield_negative_value + (exception: .public [brand] (subtraction_cannot_yield_negative_value {type Name} {parameter (Unsigned brand)} {subject (Unsigned brand)}) @@ -61,28 +63,28 @@ (template [ <+> <-> ] [(with_expansions [ (template.identifier [ "'"])] - (abstract: #export Any) - (type: #export (Unsigned ))) + (abstract: .public {} Any) + (type: .public (Unsigned ))) - (def: #export ) + (def: .public ) - (def: #export + (def: .public (|> (n.* i64.bits_per_byte) i64.mask :abstraction)) - (def: #export ( value) + (def: .public ( value) (-> Nat (Try )) (if (n.<= (:representation ) value) (#try.Success (:abstraction value)) (exception.except ..value_exceeds_the_maximum [(name_of ) value ]))) - (def: #export (<+> parameter subject) + (def: .public (<+> parameter subject) (-> (Try )) ( (n.+ (:representation parameter) (:representation subject)))) - (def: #export (<-> parameter subject) + (def: .public (<-> parameter subject) (-> (Try )) (let [parameter' (:representation parameter) subject' (:representation subject)] @@ -90,7 +92,7 @@ (#try.Success (:abstraction (n.- parameter' subject'))) (exception.except ..subtraction_cannot_yield_negative_value [(name_of ) parameter subject])))) - (def: #export ( left right) + (def: .public ( left right) (-> ) (:abstraction (n.max (:representation left) (:representation right))))] @@ -101,7 +103,7 @@ ) (template [ ] - [(def: #export + [(def: .public (-> ) (|>> :transmutation))] @@ -110,7 +112,7 @@ ) (template [ ] - [(def: #export + [(def: .public (Writer ) (|>> :representation ))] diff --git a/stdlib/source/library/lux/target/jvm/field.lux b/stdlib/source/library/lux/target/jvm/field.lux index 93cda4c5e..a9d783621 100644 --- a/stdlib/source/library/lux/target/jvm/field.lux +++ b/stdlib/source/library/lux/target/jvm/field.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Type static) + [lux (#- Type static public private) [abstract [equivalence (#+ Equivalence)] ["." monad (#+ do)]] @@ -20,7 +20,7 @@ [category (#+ Value)] [descriptor (#+ Descriptor)]]]) -(type: #export #rec Field +(type: .public #rec Field {#modifier (Modifier Field) #name (Index UTF8) #descriptor (Index (Descriptor Value)) @@ -38,7 +38,7 @@ ["4000" enum] ) -(def: #export equivalence +(def: .public equivalence (Equivalence Field) ($_ product.equivalence modifier.equivalence @@ -46,7 +46,7 @@ //index.equivalence (row.equivalence //attribute.equivalence))) -(def: #export (writer field) +(def: .public (writer field) (Writer Field) (`` ($_ binaryF\compose (~~ (template [ ] @@ -58,7 +58,7 @@ [(binaryF.row/16 //attribute.writer) #attributes])) ))) -(def: #export (field modifier name type attributes) +(def: .public (field modifier name type attributes) (-> (Modifier Field) UTF8 (Type Value) (Row Attribute) (Resource Field)) (do //constant/pool.monad diff --git a/stdlib/source/library/lux/target/jvm/index.lux b/stdlib/source/library/lux/target/jvm/index.lux index 851d6903f..66df65314 100644 --- a/stdlib/source/library/lux/target/jvm/index.lux +++ b/stdlib/source/library/lux/target/jvm/index.lux @@ -12,27 +12,29 @@ [encoding ["#." unsigned (#+ U2)]]]) -(def: #export length +(def: .public length //unsigned.bytes/2) -(abstract: #export (Index kind) +(abstract: .public (Index kind) + {} + U2 - (def: #export index + (def: .public index (All [kind] (-> U2 (Index kind))) (|>> :abstraction)) - (def: #export value + (def: .public value (-> (Index Any) U2) (|>> :representation)) - (def: #export equivalence + (def: .public equivalence (All [kind] (Equivalence (Index kind))) (\ equivalence.functor map ..value //unsigned.equivalence)) - (def: #export writer + (def: .public writer (All [kind] (Writer (Index kind))) (|>> :representation //unsigned.writer/2)) ) diff --git a/stdlib/source/library/lux/target/jvm/loader.lux b/stdlib/source/library/lux/target/jvm/loader.lux index ec7931743..3a38d9bb8 100644 --- a/stdlib/source/library/lux/target/jvm/loader.lux +++ b/stdlib/source/library/lux/target/jvm/loader.lux @@ -19,18 +19,18 @@ ["." array] ["." dictionary (#+ Dictionary)]]]]]) -(type: #export Library +(type: .public Library (Atom (Dictionary Text Binary))) -(exception: #export (already_stored {class Text}) +(exception: .public (already_stored {class Text}) (exception.report ["Class" class])) -(exception: #export (unknown {class Text}) +(exception: .public (unknown {class Text}) (exception.report ["Class" class])) -(exception: #export (cannot_define {class Text} {error Text}) +(exception: .public (cannot_define {class Text} {error Text}) (exception.report ["Class" class] ["Error" error])) @@ -78,7 +78,7 @@ (ffi.class_for java/lang/ClassLoader)) (java/lang/reflect/AccessibleObject::setAccessible true))))) -(def: #export (define class_name bytecode loader) +(def: .public (define class_name bytecode loader) (-> Text Binary java/lang/ClassLoader (Try java/lang/Object)) (let [signature (array.of_list (list (:as java/lang/Object class_name) @@ -95,11 +95,11 @@ ffi.long_to_int))))] (java/lang/reflect/Method::invoke loader signature java/lang/ClassLoader::defineClass))) -(def: #export (new_library _) +(def: .public (new_library _) (-> Any Library) (atom.atom (dictionary.empty text.hash))) -(def: #export (memory library) +(def: .public (memory library) (-> Library java/lang/ClassLoader) (with_expansions [ (for {@.old (<|) @@ -126,7 +126,7 @@ #.None (error! (exception.error ..unknown [class_name]))))))))) -(def: #export (store name bytecode library) +(def: .public (store name bytecode library) (-> Text Binary Library (IO (Try Any))) (do {! io.monad} [library' (atom.read library)] @@ -136,7 +136,7 @@ [_ (atom.update (dictionary.put name bytecode) library)] (in (#try.Success [])))))) -(def: #export (load name loader) +(def: .public (load name loader) (-> Text java/lang/ClassLoader (IO (Try (java/lang/Class java/lang/Object)))) (java/lang/ClassLoader::loadClass name loader)) diff --git a/stdlib/source/library/lux/target/jvm/magic.lux b/stdlib/source/library/lux/target/jvm/magic.lux index fee2c425a..c08360f9e 100644 --- a/stdlib/source/library/lux/target/jvm/magic.lux +++ b/stdlib/source/library/lux/target/jvm/magic.lux @@ -9,12 +9,12 @@ [encoding ["#." unsigned (#+ U4)]]]) -(type: #export Magic +(type: .public Magic U4) -(def: #export code +(def: .public code Magic (|> (hex "CAFEBABE") //unsigned.u4 try.assumed)) -(def: #export writer +(def: .public writer //unsigned.writer/4) diff --git a/stdlib/source/library/lux/target/jvm/method.lux b/stdlib/source/library/lux/target/jvm/method.lux index a2868b2ac..54aee2e60 100644 --- a/stdlib/source/library/lux/target/jvm/method.lux +++ b/stdlib/source/library/lux/target/jvm/method.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Type static) + [lux (#- Type static public private) [abstract [equivalence (#+ Equivalence)] ["." monad (#+ do)]] @@ -26,7 +26,7 @@ ["#/." category] ["#." descriptor (#+ Descriptor)]]]) -(type: #export #rec Method +(type: .public #rec Method {#modifier (Modifier Method) #name (Index UTF8) #descriptor (Index (Descriptor //type/category.Method)) @@ -47,7 +47,7 @@ ["1000" synthetic] ) -(def: #export (method modifier name type attributes code) +(def: .public (method modifier name type attributes code) (-> (Modifier Method) UTF8 (Type //type/category.Method) (List (Resource Attribute)) (Maybe (Bytecode Any)) (Resource Method)) (do {! //constant/pool.monad} @@ -82,7 +82,7 @@ #descriptor @descriptor #attributes attributes}))) -(def: #export equivalence +(def: .public equivalence (Equivalence Method) ($_ product.equivalence //modifier.equivalence @@ -91,7 +91,7 @@ (row.equivalence //attribute.equivalence) )) -(def: #export (writer field) +(def: .public (writer field) (Writer Method) (`` ($_ format\compose (~~ (template [ ] diff --git a/stdlib/source/library/lux/target/jvm/modifier.lux b/stdlib/source/library/lux/target/jvm/modifier.lux index d6fae89ed..92aeafec2 100644 --- a/stdlib/source/library/lux/target/jvm/modifier.lux +++ b/stdlib/source/library/lux/target/jvm/modifier.lux @@ -23,14 +23,16 @@ [encoding ["#." unsigned]]]) -(abstract: #export (Modifier of) +(abstract: .public (Modifier of) + {} + //unsigned.U2 - (def: #export code + (def: .public code (-> (Modifier Any) //unsigned.U2) (|>> :representation)) - (implementation: #export equivalence + (implementation: .public equivalence (All [of] (Equivalence (Modifier of))) (def: (= reference sample) @@ -39,24 +41,24 @@ (:representation sample)))) (template: (!wrap value) - (|> value - //unsigned.u2 - try.assumed - :abstraction)) + [(|> value + //unsigned.u2 + try.assumed + :abstraction)]) (template: (!unwrap value) - (|> value - :representation - //unsigned.value)) + [(|> value + :representation + //unsigned.value)]) - (def: #export (has? sub super) + (def: .public (has? sub super) (All [of] (-> (Modifier of) (Modifier of) Bit)) (let [sub (!unwrap sub)] (|> (!unwrap super) (i64.and sub) (\ i64.equivalence = sub)))) - (implementation: #export monoid + (implementation: .public monoid (All [of] (Monoid (Modifier of))) (def: identity @@ -65,11 +67,11 @@ (def: (compose left right) (!wrap (i64.or (!unwrap left) (!unwrap right))))) - (def: #export empty + (def: .public empty Modifier (\ ..monoid identity)) - (def: #export writer + (def: .public writer (All [of] (Writer (Modifier of))) (|>> :representation //unsigned.writer/2)) @@ -78,10 +80,10 @@ (|>> !wrap)) ) -(syntax: #export (modifiers: ofT {options (<>.many .any)}) +(syntax: .public (modifiers: ofT {options (<>.many .any)}) (with_gensyms [g!modifier g!code] (in (list (` (template [(~ g!code) (~ g!modifier)] - [(def: (~' #export) (~ g!modifier) + [(def: (~' .public) (~ g!modifier) (..Modifier (~ ofT)) ((~! ..modifier) ((~! number.hex) (~ g!code))))] diff --git a/stdlib/source/library/lux/target/jvm/modifier/inner.lux b/stdlib/source/library/lux/target/jvm/modifier/inner.lux index fc9bc982c..6a7e9ae7c 100644 --- a/stdlib/source/library/lux/target/jvm/modifier/inner.lux +++ b/stdlib/source/library/lux/target/jvm/modifier/inner.lux @@ -5,7 +5,7 @@ abstract]]] [// (#+ modifiers:)]) -(abstract: #export Inner Any) +(abstract: .public Inner {} Any) (modifiers: Inner ["0001" public] diff --git a/stdlib/source/library/lux/target/jvm/reflection.lux b/stdlib/source/library/lux/target/jvm/reflection.lux index 6827f2be9..bdb8249f2 100644 --- a/stdlib/source/library/lux/target/jvm/reflection.lux +++ b/stdlib/source/library/lux/target/jvm/reflection.lux @@ -111,12 +111,12 @@ (getConstructors [] [(java/lang/reflect/Constructor java/lang/Object)]) (getDeclaredMethods [] [java/lang/reflect/Method])]) -(exception: #export (unknown_class {class External}) +(exception: .public (unknown_class {class External}) (exception.report ["Class" (%.text class)])) (template [] - [(exception: #export ( {jvm_type java/lang/reflect/Type}) + [(exception: .public ( {jvm_type java/lang/reflect/Type}) (exception.report ["Type" (java/lang/reflect/Type::getTypeName jvm_type)] ["Class" (|> jvm_type java/lang/Object::getClass java/lang/Object::toString)]))] @@ -125,7 +125,7 @@ [cannot_convert_to_a_lux_type] ) -(def: #export (load class_loader name) +(def: .public (load class_loader name) (-> java/lang/ClassLoader External (Try (java/lang/Class java/lang/Object))) (case (java/lang/Class::forName name false class_loader) (#try.Success class) @@ -134,7 +134,7 @@ (#try.Failure _) (exception.except ..unknown_class name))) -(def: #export (sub? class_loader super sub) +(def: .public (sub? class_loader super sub) (-> java/lang/ClassLoader External External (Try Bit)) (do try.monad [super (..load class_loader super) @@ -187,7 +187,7 @@ ## else (exception.except ..cannot_convert_to_a_lux_type reflection))) -(def: #export (parameter reflection) +(def: .public (parameter reflection) (-> java/lang/reflect/Type (Try (/.Type Parameter))) (<| (case (ffi.check java/lang/reflect/TypeVariable reflection) (#.Some reflection) @@ -217,12 +217,12 @@ _) (..class' parameter reflection))) -(def: #export class +(def: .public class (-> java/lang/reflect/Type (Try (/.Type Class))) (..class' ..parameter)) -(def: #export (type reflection) +(def: .public (type reflection) (-> java/lang/reflect/Type (Try (/.Type Value))) (<| (case (ffi.check java/lang/Class reflection) (#.Some reflection) @@ -256,7 +256,7 @@ ## else (..parameter reflection))) -(def: #export (return reflection) +(def: .public (return reflection) (-> java/lang/reflect/Type (Try (/.Type Return))) (with_expansions [ (as_is (..type reflection))] (case (ffi.check java/lang/Class reflection) @@ -272,13 +272,13 @@ #.None ))) -(exception: #export (cannot_correspond {class (java/lang/Class java/lang/Object)} +(exception: .public (cannot_correspond {class (java/lang/Class java/lang/Object)} {type Type}) (exception.report ["Class" (java/lang/Object::toString class)] ["Type" (%.type type)])) -(exception: #export (type_parameter_mismatch {expected Nat} +(exception: .public (type_parameter_mismatch {expected Nat} {actual Nat} {class (java/lang/Class java/lang/Object)} {type Type}) @@ -288,11 +288,11 @@ ["Class" (java/lang/Object::toString class)] ["Type" (%.type type)])) -(exception: #export (non_jvm_type {type Type}) +(exception: .public (non_jvm_type {type Type}) (exception.report ["Type" (%.type type)])) -(def: #export (correspond class type) +(def: .public (correspond class type) (-> (java/lang/Class java/lang/Object) Type (Try Mapping)) (case type (#.Primitive name params) @@ -326,7 +326,7 @@ _ (exception.except ..non_jvm_type [type]))) -(exception: #export (mistaken_field_owner {field java/lang/reflect/Field} +(exception: .public (mistaken_field_owner {field java/lang/reflect/Field} {owner (java/lang/Class java/lang/Object)} {target (java/lang/Class java/lang/Object)}) (exception.report @@ -335,7 +335,7 @@ ["Target" (java/lang/Object::toString target)])) (template [] - [(exception: #export ( {field Text} + [(exception: .public ( {field Text} {class (java/lang/Class java/lang/Object)}) (exception.report ["Field" (%.text field)] @@ -346,7 +346,7 @@ [not_a_virtual_field] ) -(def: #export (field field target) +(def: .public (field field target) (-> Text (java/lang/Class java/lang/Object) (Try java/lang/reflect/Field)) (case (java/lang/Class::getDeclaredField field target) (#try.Success field) @@ -358,7 +358,7 @@ (#try.Failure _) (exception.except ..unknown_field [field target]))) -(def: #export deprecated? +(def: .public deprecated? (-> (array.Array java/lang/annotation/Annotation) Bit) (|>> array.list (list.all (|>> (ffi.check java/lang/Deprecated))) @@ -366,7 +366,7 @@ not)) (template [ ] - [(def: #export ( field class) + [(def: .public ( field class) (-> Text (java/lang/Class java/lang/Object) (Try [Bit Bit (/.Type Value)])) (do {! try.monad} [fieldJ (..field field class) diff --git a/stdlib/source/library/lux/target/jvm/type.lux b/stdlib/source/library/lux/target/jvm/type.lux index 9b29382c7..c4a5abd0b 100644 --- a/stdlib/source/library/lux/target/jvm/type.lux +++ b/stdlib/source/library/lux/target/jvm/type.lux @@ -24,22 +24,24 @@ ["#." descriptor (#+ Descriptor)] ["#." reflection (#+ Reflection)]]) -(abstract: #export (Type category) +(abstract: .public (Type category) + {} + [(Signature category) (Descriptor category) (Reflection category)] - (type: #export Argument + (type: .public Argument [Text (Type Value)]) - (type: #export (Typed a) + (type: .public (Typed a) [(Type Value) a]) - (type: #export Constraint + (type: .public Constraint {#name Text #super_class (Type Class) #super_interfaces (List (Type Class))}) (template [