From da27db478b368724ee4659eb674dcdbeb2cd8747 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 24 May 2021 19:29:13 -0400 Subject: Re-named lux/host to lux/ffi. --- stdlib/source/lux/control/concurrency/atom.lux | 4 +- stdlib/source/lux/control/concurrency/thread.lux | 30 +- stdlib/source/lux/data/binary.lux | 72 +- stdlib/source/lux/data/text/buffer.lux | 2 +- stdlib/source/lux/data/text/encoding.lux | 48 +- stdlib/source/lux/debug.lux | 26 +- stdlib/source/lux/ffi.js.lux | 368 ++++ stdlib/source/lux/ffi.jvm.lux | 2023 ++++++++++++++++++++ stdlib/source/lux/ffi.lua.lux | 313 +++ stdlib/source/lux/ffi.old.lux | 1835 ++++++++++++++++++ stdlib/source/lux/ffi.php.lux | 307 +++ stdlib/source/lux/ffi.py.lux | 319 +++ stdlib/source/lux/ffi.rb.lux | 334 ++++ stdlib/source/lux/ffi.scm.lux | 219 +++ stdlib/source/lux/host.js.lux | 368 ---- stdlib/source/lux/host.jvm.lux | 2023 -------------------- stdlib/source/lux/host.lua.lux | 313 --- stdlib/source/lux/host.old.lux | 1835 ------------------ stdlib/source/lux/host.php.lux | 307 --- stdlib/source/lux/host.py.lux | 319 --- stdlib/source/lux/host.rb.lux | 334 ---- stdlib/source/lux/host.scm.lux | 219 --- stdlib/source/lux/target/jvm/bytecode.lux | 8 +- stdlib/source/lux/target/jvm/constant.lux | 4 +- stdlib/source/lux/target/jvm/constant/pool.lux | 2 +- stdlib/source/lux/target/jvm/loader.lux | 24 +- stdlib/source/lux/target/jvm/reflection.lux | 22 +- stdlib/source/lux/target/lua.lux | 15 +- stdlib/source/lux/target/php.lux | 15 +- stdlib/source/lux/target/python.lux | 6 +- stdlib/source/lux/target/ruby.lux | 15 +- stdlib/source/lux/target/scheme.lux | 12 +- .../language/lux/phase/extension/analysis/jvm.lux | 6 +- .../language/lux/phase/generation/jvm/host.lux | 2 +- .../lux/phase/generation/jvm/primitive.lux | 2 +- .../source/lux/tool/compiler/meta/packager/jvm.lux | 18 +- stdlib/source/lux/world/console.lux | 2 +- stdlib/source/lux/world/db/jdbc/input.lux | 4 +- stdlib/source/lux/world/db/jdbc/output.lux | 4 +- stdlib/source/lux/world/file.lux | 200 +- stdlib/source/lux/world/file/watch.lux | 2 +- stdlib/source/lux/world/program.lux | 80 +- stdlib/source/lux/world/shell.lux | 2 +- .../program/aedifex/dependency/resolution.lux | 2 +- stdlib/source/program/aedifex/hash.lux | 2 +- .../source/program/aedifex/repository/identity.lux | 2 +- stdlib/source/program/aedifex/repository/local.lux | 2 +- .../source/program/aedifex/repository/remote.lux | 2 +- .../spec/compositor/generation/structure.lux | 4 +- stdlib/source/test/lux.lux | 4 +- .../source/test/lux/control/function/contract.lux | 10 +- stdlib/source/test/lux/ffi.js.lux | 88 + stdlib/source/test/lux/ffi.jvm.lux | 151 ++ stdlib/source/test/lux/ffi.lua.lux | 24 + stdlib/source/test/lux/ffi.old.lux | 145 ++ stdlib/source/test/lux/ffi.php.lux | 24 + stdlib/source/test/lux/ffi.py.lux | 24 + stdlib/source/test/lux/ffi.rb.lux | 24 + stdlib/source/test/lux/ffi.scm.lux | 24 + stdlib/source/test/lux/host.js.lux | 88 - stdlib/source/test/lux/host.jvm.lux | 151 -- stdlib/source/test/lux/host.lua.lux | 24 - stdlib/source/test/lux/host.old.lux | 145 -- stdlib/source/test/lux/host.php.lux | 24 - stdlib/source/test/lux/host.py.lux | 24 - stdlib/source/test/lux/host.rb.lux | 24 - stdlib/source/test/lux/host.scm.lux | 24 - stdlib/source/test/lux/math/number/frac.lux | 4 +- stdlib/source/test/lux/target/jvm.lux | 142 +- stdlib/source/test/lux/time/instant.lux | 4 +- 70 files changed, 6603 insertions(+), 6646 deletions(-) create mode 100644 stdlib/source/lux/ffi.js.lux create mode 100644 stdlib/source/lux/ffi.jvm.lux create mode 100644 stdlib/source/lux/ffi.lua.lux create mode 100644 stdlib/source/lux/ffi.old.lux create mode 100644 stdlib/source/lux/ffi.php.lux create mode 100644 stdlib/source/lux/ffi.py.lux create mode 100644 stdlib/source/lux/ffi.rb.lux create mode 100644 stdlib/source/lux/ffi.scm.lux delete mode 100644 stdlib/source/lux/host.js.lux delete mode 100644 stdlib/source/lux/host.jvm.lux delete mode 100644 stdlib/source/lux/host.lua.lux delete mode 100644 stdlib/source/lux/host.old.lux delete mode 100644 stdlib/source/lux/host.php.lux delete mode 100644 stdlib/source/lux/host.py.lux delete mode 100644 stdlib/source/lux/host.rb.lux delete mode 100644 stdlib/source/lux/host.scm.lux create mode 100644 stdlib/source/test/lux/ffi.js.lux create mode 100644 stdlib/source/test/lux/ffi.jvm.lux create mode 100644 stdlib/source/test/lux/ffi.lua.lux create mode 100644 stdlib/source/test/lux/ffi.old.lux create mode 100644 stdlib/source/test/lux/ffi.php.lux create mode 100644 stdlib/source/test/lux/ffi.py.lux create mode 100644 stdlib/source/test/lux/ffi.rb.lux create mode 100644 stdlib/source/test/lux/ffi.scm.lux delete mode 100644 stdlib/source/test/lux/host.js.lux delete mode 100644 stdlib/source/test/lux/host.jvm.lux delete mode 100644 stdlib/source/test/lux/host.lua.lux delete mode 100644 stdlib/source/test/lux/host.old.lux delete mode 100644 stdlib/source/test/lux/host.php.lux delete mode 100644 stdlib/source/test/lux/host.py.lux delete mode 100644 stdlib/source/test/lux/host.rb.lux delete mode 100644 stdlib/source/test/lux/host.scm.lux diff --git a/stdlib/source/lux/control/concurrency/atom.lux b/stdlib/source/lux/control/concurrency/atom.lux index f8a95a41a..e3b711785 100644 --- a/stdlib/source/lux/control/concurrency/atom.lux +++ b/stdlib/source/lux/control/concurrency/atom.lux @@ -1,6 +1,6 @@ (.module: [lux #* - ["." host] + ["." ffi] ["@" target] [abstract [monad (#+ do)]] @@ -14,7 +14,7 @@ [type abstract]]) -(with_expansions [ (as_is (host.import: (java/util/concurrent/atomic/AtomicReference a) +(with_expansions [ (as_is (ffi.import: (java/util/concurrent/atomic/AtomicReference a) ["#::." (new [a]) (get [] a) diff --git a/stdlib/source/lux/control/concurrency/thread.lux b/stdlib/source/lux/control/concurrency/thread.lux index d07edd0d8..4afa4dde3 100644 --- a/stdlib/source/lux/control/concurrency/thread.lux +++ b/stdlib/source/lux/control/concurrency/thread.lux @@ -1,7 +1,7 @@ (.module: [lux #* ["@" target] - ["." host] + ["." ffi] [abstract ["." monad (#+ do)]] [control @@ -17,26 +17,26 @@ [// ["." atom (#+ Atom)]]) -(with_expansions [ (as_is (host.import: java/lang/Object) +(with_expansions [ (as_is (ffi.import: java/lang/Object) - (host.import: java/lang/Runtime + (ffi.import: java/lang/Runtime ["#::." (#static getRuntime [] java/lang/Runtime) (availableProcessors [] int)]) - (host.import: java/lang/Runnable) + (ffi.import: java/lang/Runnable) - (host.import: java/util/concurrent/TimeUnit + (ffi.import: java/util/concurrent/TimeUnit ["#::." (#enum MILLISECONDS)]) - (host.import: java/util/concurrent/Executor + (ffi.import: java/util/concurrent/Executor ["#::." (execute [java/lang/Runnable] #io void)]) - (host.import: (java/util/concurrent/ScheduledFuture a)) + (ffi.import: (java/util/concurrent/ScheduledFuture a)) - (host.import: java/util/concurrent/ScheduledThreadPoolExecutor + (ffi.import: java/util/concurrent/ScheduledThreadPoolExecutor ["#::." (new [int]) (schedule [java/lang/Runnable long java/util/concurrent/TimeUnit] #io (java/util/concurrent/ScheduledFuture java/lang/Object))]))] @@ -44,11 +44,11 @@ @.jvm (as_is ) @.js - (as_is (host.import: (setTimeout [host.Function host.Number] #io Any))) + (as_is (ffi.import: (setTimeout [ffi.Function ffi.Number] #io Any))) @.python - (host.import: threading/Timer - (new [host.Float host.Function]) + (ffi.import: threading/Timer + (new [ffi.Float ffi.Function]) (start [] #io #? Any))} ## Default @@ -84,7 +84,7 @@ (def: #export (schedule milli_seconds action) (-> Nat (IO Any) (IO Any)) (for {@.old - (let [runnable (host.object [] [java/lang/Runnable] + (let [runnable (ffi.object [] [java/lang/Runnable] [] (java/lang/Runnable [] (run self) void (io.run action)))] @@ -94,7 +94,7 @@ runner))) @.jvm - (let [runnable (host.object [] [java/lang/Runnable] + (let [runnable (ffi.object [] [java/lang/Runnable] [] (java/lang/Runnable [] (run self) void (io.run action)))] @@ -104,12 +104,12 @@ runner))) @.js - (..setTimeout [(host.closure [] (io.run action)) + (..setTimeout [(ffi.closure [] (io.run action)) (n.frac milli_seconds)]) @.python (do io.monad - [_ (|> (host.lambda [] (io.run action)) + [_ (|> (ffi.lambda [] (io.run action)) [(|> milli_seconds n.frac (f./ +1,000.0))] threading/Timer::new (threading/Timer::start []))] diff --git a/stdlib/source/lux/data/binary.lux b/stdlib/source/lux/data/binary.lux index 40a7b3fc7..ce8deb1d2 100644 --- a/stdlib/source/lux/data/binary.lux +++ b/stdlib/source/lux/data/binary.lux @@ -1,7 +1,7 @@ (.module: [lux (#- i64) ["@" target] - ["." host] + ["." ffi] [abstract [monad (#+ do)] [equivalence (#+ Equivalence)] @@ -37,15 +37,15 @@ [inverted_slice] ) -(with_expansions [ (as_is (type: #export Binary (host.type [byte])) +(with_expansions [ (as_is (type: #export Binary (ffi.type [byte])) - (host.import: java/lang/Object) + (ffi.import: java/lang/Object) - (host.import: java/lang/System + (ffi.import: java/lang/System ["#::." (#static arraycopy [java/lang/Object int java/lang/Object int int] #try void)]) - (host.import: java/util/Arrays + (ffi.import: java/util/Arrays ["#::." (#static copyOfRange [[byte] int int] [byte]) (#static equals [[byte] [byte]] boolean)]) @@ -56,25 +56,25 @@ (def: i64 (-> (primitive "java.lang.Byte") I64) - (|>> host.byte_to_long (:coerce I64) (i64.and ..byte_mask))) + (|>> ffi.byte_to_long (:coerce I64) (i64.and ..byte_mask))) (def: byte (-> (I64 Any) (primitive "java.lang.Byte")) (for {@.old - (|>> .int host.long_to_byte) + (|>> .int ffi.long_to_byte) @.jvm - (|>> .int (:coerce (primitive "java.lang.Long")) host.long_to_byte)})))] + (|>> .int (:coerce (primitive "java.lang.Long")) ffi.long_to_byte)})))] (for {@.old (as_is ) @.jvm (as_is ) @.js - (as_is (host.import: ArrayBuffer - (new [host.Number])) + (as_is (ffi.import: ArrayBuffer + (new [ffi.Number])) - (host.import: Uint8Array + (ffi.import: Uint8Array (new [ArrayBuffer]) - (length host.Number)) + (length ffi.Number)) (type: #export Binary Uint8Array)) @@ -87,18 +87,18 @@ (as_is (type: #export Binary (primitive "bytevector")) - (host.import: (make-bytevector [Nat] Binary)) - (host.import: (bytevector-u8-ref [Binary Nat] I64)) - (host.import: (bytevector-u8-set! [Binary Nat (I64 Any)] Any)) - (host.import: (bytevector-length [Binary] Nat)))} + (ffi.import: (make-bytevector [Nat] Binary)) + (ffi.import: (bytevector-u8-ref [Binary Nat] I64)) + (ffi.import: (bytevector-u8-set! [Binary Nat (I64 Any)] Any)) + (ffi.import: (bytevector-length [Binary] Nat)))} ## Default (type: #export Binary (array.Array (I64 Any))))) (template: (!size binary) - (for {@.old (host.array_length binary) - @.jvm (host.array_length binary) + (for {@.old (ffi.array_length binary) + @.jvm (ffi.array_length binary) @.js (|> binary @@ -117,8 +117,8 @@ (array.size binary))) (template: (!read idx binary) - (for {@.old (..i64 (host.array_read idx binary)) - @.jvm (..i64 (host.array_read idx binary)) + (for {@.old (..i64 (ffi.array_read idx binary)) + @.jvm (..i64 (ffi.array_read idx binary)) @.js (|> binary @@ -150,8 +150,8 @@ (:coerce ..Binary))) (template: (!write idx value binary) - (for {@.old (host.array_write idx (..byte value) binary) - @.jvm (host.array_write idx (..byte value) binary) + (for {@.old (ffi.array_write idx (..byte value) binary) + @.jvm (ffi.array_write idx (..byte value) binary) @.js (!!write .Frac n.frac "js array write" idx value binary) @.python (!!write (I64 Any) (:coerce (I64 Any)) "python array write" idx value binary) @@ -167,14 +167,14 @@ (def: #export create (-> Nat Binary) - (for {@.old (|>> (host.array byte)) - @.jvm (|>> (host.array byte)) + (for {@.old (|>> (ffi.array byte)) + @.jvm (|>> (ffi.array byte)) @.js (|>> n.frac ArrayBuffer::new Uint8Array::new) @.python - (|>> ("python apply" (:coerce host.Function ("python constant" "bytearray"))) + (|>> ("python apply" (:coerce ffi.Function ("python constant" "bytearray"))) (:coerce Binary)) @.scheme @@ -283,17 +283,17 @@ (def: (= reference sample) (with_expansions [ (java/util/Arrays::equals reference sample)] - (for {@.old - @.jvm } - (let [limit (!size reference)] - (and (n.= limit - (!size sample)) - (loop [idx 0] - (if (n.< limit idx) - (and (n.= (!read idx reference) - (!read idx sample)) - (recur (inc idx))) - true)))))))) + (for {@.old + @.jvm } + (let [limit (!size reference)] + (and (n.= limit + (!size sample)) + (loop [idx 0] + (if (n.< limit idx) + (and (n.= (!read idx reference) + (!read idx sample)) + (recur (inc idx))) + true)))))))) (for {@.old (as_is) @.jvm (as_is)} diff --git a/stdlib/source/lux/data/text/buffer.lux b/stdlib/source/lux/data/text/buffer.lux index fe648023d..fb90ab15e 100644 --- a/stdlib/source/lux/data/text/buffer.lux +++ b/stdlib/source/lux/data/text/buffer.lux @@ -1,6 +1,6 @@ (.module: [lux #* - [host (#+ import:)] + [ffi (#+ import:)] ["@" target] [control ["." function]] diff --git a/stdlib/source/lux/data/text/encoding.lux b/stdlib/source/lux/data/text/encoding.lux index a081233c9..7445d5ebc 100644 --- a/stdlib/source/lux/data/text/encoding.lux +++ b/stdlib/source/lux/data/text/encoding.lux @@ -1,7 +1,7 @@ (.module: [lux #* ["@" target] - ["." host] + ["." ffi] [abstract [codec (#+ Codec)]] [control @@ -169,7 +169,7 @@ (|>> :representation)) ) -(with_expansions [ (as_is (host.import: java/lang/String +(with_expansions [ (as_is (ffi.import: java/lang/String ["#::." (new [[byte] java/lang/String]) (getBytes [java/lang/String] [byte])]))] @@ -177,42 +177,42 @@ @.jvm (as_is ) @.js - (as_is (host.import: Uint8Array) + (as_is (ffi.import: Uint8Array) ## On Node - (host.import: Buffer - (#static from #as from|encode [host.String host.String] Buffer) + (ffi.import: Buffer + (#static from #as from|encode [ffi.String ffi.String] Buffer) (#static from #as from|decode [Uint8Array] Buffer) - (toString [host.String] host.String)) + (toString [ffi.String] ffi.String)) ## On the browser - (host.import: TextEncoder - (new [host.String]) - (encode [host.String] Uint8Array)) + (ffi.import: TextEncoder + (new [ffi.String]) + (encode [ffi.String] Uint8Array)) - (host.import: TextDecoder - (new [host.String]) - (decode [Uint8Array] host.String))) + (ffi.import: TextDecoder + (new [ffi.String]) + (decode [Uint8Array] ffi.String))) @.ruby - (as_is (host.import: String #as RubyString + (as_is (ffi.import: String #as RubyString (encode [Text] RubyString) (force_encoding [Text] Text) (bytes [] Binary)) - (host.import: Array #as RubyArray + (ffi.import: Array #as RubyArray (pack [Text] RubyString))) @.php - (as_is (host.import: Almost_Binary) - (host.import: (unpack [host.String host.String] Almost_Binary)) - (host.import: (array_values [Almost_Binary] Binary)) + (as_is (ffi.import: Almost_Binary) + (ffi.import: (unpack [ffi.String ffi.String] Almost_Binary)) + (ffi.import: (array_values [Almost_Binary] Binary)) (def: php_byte_array_format "C*")) @.scheme ## https://srfi.schemers.org/srfi-140/srfi-140.html - (as_is (host.import: (string->utf8 [Text] Binary)) - (host.import: (utf8->string [Binary] Text)))} + (as_is (ffi.import: (string->utf8 [Text] Binary)) + (ffi.import: (utf8->string [Binary] Text)))} (as_is))) (def: (utf8\encode value) @@ -229,10 +229,10 @@ (java/lang/String::getBytes (..name ..utf_8) value) @.js - (cond host.on_nashorn? + (cond ffi.on_nashorn? (:coerce Binary ("js object do" "getBytes" value ["utf8"])) - host.on_node_js? + ffi.on_node_js? (|> (Buffer::from|encode [value "utf8"]) ## This coercion is valid as per NodeJS's documentation: ## https://nodejs.org/api/buffer.html#buffer_buffers_and_typedarrays @@ -271,12 +271,12 @@ @.jvm @.js - (cond host.on_nashorn? + (cond ffi.on_nashorn? (|> ("js object new" ("js constant" "java.lang.String") [value "utf8"]) (:coerce Text) #try.Success) - host.on_node_js? + ffi.on_node_js? (|> (Buffer::from|decode [value]) (Buffer::toString ["utf8"]) #try.Success) @@ -287,7 +287,7 @@ #try.Success)) @.python - (host.try (:coerce Text ("python object do" "decode" (:assume value) "utf-8"))) + (ffi.try (:coerce Text ("python object do" "decode" (:assume value) "utf-8"))) @.lua (#try.Success ("lua utf8 decode" value)) diff --git a/stdlib/source/lux/debug.lux b/stdlib/source/lux/debug.lux index d5bbd3be2..a076942bc 100644 --- a/stdlib/source/lux/debug.lux +++ b/stdlib/source/lux/debug.lux @@ -2,7 +2,7 @@ [lux (#- type) ["@" target] ["." type] - ["." host (#+ import:)] + ["." ffi (#+ import:)] [abstract [monad (#+ do)]] [control @@ -66,23 +66,23 @@ @.js (as_is (import: JSON - (#static stringify [.Any] host.String)) + (#static stringify [.Any] ffi.String)) (import: Array - (#static isArray [.Any] host.Boolean))) + (#static isArray [.Any] ffi.Boolean))) @.python (as_is (type: PyType (primitive "python_type")) (import: (type [.Any] PyType)) - (import: (str [.Any] host.String))) + (import: (str [.Any] ffi.String))) @.lua - (as_is (import: (type [.Any] host.String)) - (import: (tostring [.Any] host.String)) + (as_is (import: (type [.Any] ffi.String)) + (import: (tostring [.Any] ffi.String)) (import: math - (#static type [.Any] #? host.String))) + (#static type [.Any] #? ffi.String))) @.ruby (as_is (import: Class) @@ -91,8 +91,8 @@ (type [] Class))) @.php - (as_is (import: (gettype [.Any] host.String)) - (import: (strval [.Any] host.String))) + (as_is (import: (gettype [.Any] ffi.String)) + (import: (strval [.Any] ffi.String))) @.scheme (as_is (import: (boolean? [.Any] Bit)) @@ -120,7 +120,7 @@ Inspector (with_expansions [ (let [object (:coerce java/lang/Object value)] (`` (<| (~~ (template [ ] - [(case (host.check object) + [(case (ffi.check object) (#.Some value) (`` (|> value (~~ (template.splice )))) #.None)] @@ -130,12 +130,12 @@ [java/lang/Long [(:coerce .Int) %.int]] [java/lang/Number [java/lang/Number::doubleValue %.frac]] )) - (case (host.check [java/lang/Object] object) + (case (ffi.check [java/lang/Object] object) (#.Some value) (let [value (:coerce (array.Array java/lang/Object) value)] (case (array.read 0 value) (^multi (#.Some tag) - [(host.check java/lang/Integer tag) + [(ffi.check java/lang/Integer tag) (#.Some tag)] [[(array.read 1 value) (array.read 2 value)] @@ -157,7 +157,7 @@ @.jvm @.js - (case (host.type_of value) + (case (ffi.type_of value) (^template [ ] [ (`` (|> value (~~ (template.splice ))))]) diff --git a/stdlib/source/lux/ffi.js.lux b/stdlib/source/lux/ffi.js.lux new file mode 100644 index 000000000..8bfe8cc94 --- /dev/null +++ b/stdlib/source/lux/ffi.js.lux @@ -0,0 +1,368 @@ +(.module: + [lux #* + ["." meta] + [abstract + [monad (#+ do)]] + [control + ["." io] + ["<>" parser + ["" code (#+ Parser)]]] + [data + ["." product] + ["." maybe] + ["." text + ["%" format (#+ format)]] + [collection + ["." list ("#\." functor fold)]]] + [type + abstract] + [macro (#+ with_gensyms) + [syntax (#+ syntax:)] + ["." code] + ["." template]]]) + +(abstract: #export (Object brand) + Any) + +(template [] + [(with_expansions [ (template.identifier [ "'"])] + (abstract: + Any + + (type: #export + (Object ))))] + + [Function] + [Symbol] + [Null] + [Undefined] + ) + +(template [ ] + [(type: #export + )] + + [Boolean Bit] + [Number Frac] + [String Text] + ) + +(type: Nullable + [Bit Code]) + +(def: nullable + (Parser Nullable) + (let [token (' #?)] + (<| (<>.and (<>.parses? (.this! token))) + (<>.after (<>.not (.this! token))) + .any))) + +(type: Constructor + (List Nullable)) + +(def: constructor + (Parser Constructor) + (.form (<>.after (.this! (' new)) + (.tuple (<>.some ..nullable))))) + +(type: Field + [Bit Text Nullable]) + +(def: static! + (Parser Any) + (.this! (' #static))) + +(def: field + (Parser Field) + (.form ($_ <>.and + (<>.parses? ..static!) + .local_identifier + ..nullable))) + +(type: Common_Method + {#name Text + #alias (Maybe Text) + #inputs (List Nullable) + #io? Bit + #try? Bit + #output Nullable}) + +(type: Static_Method Common_Method) +(type: Virtual_Method Common_Method) + +(type: Method + (#Static Static_Method) + (#Virtual Virtual_Method)) + +(def: common_method + (Parser Common_Method) + ($_ <>.and + .local_identifier + (<>.maybe (<>.after (.this! (' #as)) .local_identifier)) + (.tuple (<>.some ..nullable)) + (<>.parses? (.this! (' #io))) + (<>.parses? (.this! (' #try))) + ..nullable)) + +(def: static_method + (<>.after ..static! ..common_method)) + +(def: method + (Parser Method) + (.form (<>.or ..static_method + ..common_method))) + +(type: Member + (#Constructor Constructor) + (#Field Field) + (#Method Method)) + +(def: member + (Parser Member) + ($_ <>.or + ..constructor + ..field + ..method + )) + +(def: input_variables + (-> (List Nullable) (List [Bit Code])) + (|>> list.enumeration + (list\map (function (_ [idx [nullable? type]]) + [nullable? (|> idx %.nat code.local_identifier)])))) + +(def: (nullable_type [nullable? type]) + (-> Nullable Code) + (if nullable? + (` (.Maybe (~ type))) + type)) + +(def: (with_null g!temp [nullable? input]) + (-> Code [Bit Code] Code) + (if nullable? + (` (case (~ input) + (#.Some (~ g!temp)) + (~ g!temp) + + #.None + ("js object null"))) + input)) + +(def: (without_null g!temp [nullable? outputT] output) + (-> Code Nullable Code Code) + (if nullable? + (` (let [(~ g!temp) (~ output)] + (if ("js object null?" (~ g!temp)) + #.None + (#.Some (~ g!temp))))) + (` (let [(~ g!temp) (~ output)] + (if (not ("js object null?" (~ g!temp))) + (~ g!temp) + (.error! "Null is an invalid value.")))))) + +(type: Import + (#Class [Text (List Member)]) + (#Function Static_Method)) + +(def: import + ($_ <>.or + ($_ <>.and + .local_identifier + (<>.some member)) + (.form ..common_method) + )) + +(syntax: #export (try expression) + {#.doc (doc (case (try (risky_computation input)) + (#.Right success) + (do_something success) + + (#.Left error) + (recover_from_failure error)))} + (wrap (list (` ("lux try" ((~! io.io) (~ expression))))))) + +(def: (with_io with? without) + (-> Bit Code Code) + (if with? + (` (io.io (~ without))) + without)) + +(def: (io_type io? rawT) + (-> Bit Code Code) + (if io? + (` (io.IO (~ rawT))) + rawT)) + +(def: (with_try with? without_try) + (-> Bit Code Code) + (if with? + (` (..try (~ without_try))) + without_try)) + +(def: (try_type try? rawT) + (-> Bit Code Code) + (if try? + (` (.Either .Text (~ rawT))) + rawT)) + +(def: (make_function g!method g!temp source inputsT io? try? outputT) + (-> Code Code Text (List Nullable) Bit Bit Nullable Code) + (let [g!inputs (input_variables inputsT)] + (` (def: ((~ g!method) + [(~+ (list\map product.right g!inputs))]) + (-> [(~+ (list\map nullable_type inputsT))] + (~ (|> (nullable_type outputT) + (try_type try?) + (io_type io?)))) + (:assume + (~ (<| (with_io io?) + (with_try try?) + (without_null g!temp outputT) + (` ("js apply" + ("js constant" (~ (code.text source))) + (~+ (list\map (with_null g!temp) g!inputs))))))))))) + +(syntax: #export (import: {import ..import}) + (with_gensyms [g!temp] + (case import + (#Class [class members]) + (with_gensyms [g!object] + (let [qualify (: (-> Text Code) + (|>> (format class "::") code.local_identifier)) + g!type (code.local_identifier class) + real_class (text.replace_all "/" "." class)] + (wrap (list& (` (type: (~ g!type) + (..Object (primitive (~ (code.text real_class)))))) + (list\map (function (_ member) + (case member + (#Constructor inputsT) + (let [g!inputs (input_variables inputsT)] + (` (def: ((~ (qualify "new")) + [(~+ (list\map product.right g!inputs))]) + (-> [(~+ (list\map nullable_type inputsT))] + (~ g!type)) + (:assume + ("js object new" + ("js constant" (~ (code.text real_class))) + [(~+ (list\map (with_null g!temp) g!inputs))]))))) + + (#Field [static? field fieldT]) + (if static? + (` ((~! syntax:) ((~ (qualify field))) + (\ (~! meta.monad) (~' wrap) + (list (` (.:coerce (~ (nullable_type fieldT)) + ("js constant" (~ (code.text (format real_class "." field)))))))))) + (` (def: ((~ (qualify field)) + (~ g!object)) + (-> (~ g!type) + (~ (nullable_type fieldT))) + (:assume + (~ (without_null g!temp fieldT (` ("js object get" (~ (code.text field)) (~ g!object))))))))) + + (#Method method) + (case method + (#Static [method alias inputsT io? try? outputT]) + (..make_function (qualify (maybe.default method alias)) + g!temp + (format real_class "." method) + inputsT + io? + try? + outputT) + + (#Virtual [method alias inputsT io? try? outputT]) + (let [g!inputs (input_variables inputsT)] + (` (def: ((~ (qualify (maybe.default method alias))) + [(~+ (list\map product.right g!inputs))] + (~ g!object)) + (-> [(~+ (list\map nullable_type inputsT))] + (~ g!type) + (~ (|> (nullable_type outputT) + (try_type try?) + (io_type io?)))) + (:assume + (~ (<| (with_io io?) + (with_try try?) + (without_null g!temp outputT) + (` ("js object do" + (~ (code.text method)) + (~ g!object) + [(~+ (list\map (with_null g!temp) g!inputs))]))))))))))) + members))))) + + (#Function [name alias inputsT io? try? outputT]) + (wrap (list (..make_function (code.local_identifier (maybe.default name alias)) + g!temp + name + inputsT + io? + try? + outputT))) + ))) + +(template: #export (type_of object) + ("js type-of" object)) + +(syntax: #export (constant type + {[head tail] (.tuple (<>.and .local_identifier (<>.some .local_identifier)))}) + (with_gensyms [g!_] + (let [constant (` ("js constant" (~ (code.text head))))] + (case tail + #.Nil + (wrap (list (` (: (.Maybe (~ type)) + (case (..type_of (~ constant)) + "undefined" + #.None + + (~ g!_) + (#.Some (:coerce (~ type) (~ constant)))))))) + + (#.Cons [next tail]) + (let [separator "."] + (wrap (list (` (: (.Maybe (~ type)) + (case (..type_of (~ constant)) + "undefined" + #.None + + (~ g!_) + (..constant (~ type) [(~ (code.local_identifier (format head "." next))) + (~+ (list\map code.local_identifier tail))]))))))))))) + +(template: (!defined? ) + (.case (..constant Any ) + #.None + .false + + (#.Some _) + .true)) + +(template [ ] + [(def: #export + Bit + (!defined? ))] + + [on_browser? [window]] + [on_nashorn? [java lang Object]] + ) + +(def: #export on_node_js? + Bit + (case (..constant (Object Any) [process]) + (#.Some process) + (case (:coerce Text + ("js apply" ("js constant" "Object.prototype.toString.call") process)) + "[object process]" + true + + _ + false) + + #.None + false)) + +(template: #export (closure ) + (.:coerce ..Function + (`` ("js function" + (~~ (template.count )) + (.function (_ []) + ))))) diff --git a/stdlib/source/lux/ffi.jvm.lux b/stdlib/source/lux/ffi.jvm.lux new file mode 100644 index 000000000..ad087f95b --- /dev/null +++ b/stdlib/source/lux/ffi.jvm.lux @@ -0,0 +1,2023 @@ +(.module: + ["." lux (#- Type type int char) + ["#_." type ("#\." equivalence)] + [abstract + ["." monad (#+ Monad do)] + ["." enum]] + [control + ["." function] + ["." io] + ["." try (#+ Try)] + ["." exception (#+ Exception exception:)] + ["<>" parser ("#\." monad) + ["<.>" code (#+ Parser)]]] + [data + ["." maybe] + ["." product] + ["." text ("#\." equivalence) + ["%" format (#+ format)]] + [collection + ["." array] + ["." list ("#\." monad fold monoid)] + ["." dictionary (#+ Dictionary)]]] + [macro (#+ with_gensyms) + [syntax (#+ syntax:)] + ["." code] + ["." template]] + ["." meta + ["." annotation]] + [target + [jvm + [encoding + ["." name (#+ External)]] + ["." type (#+ Type Argument Typed) + ["." category (#+ Void Value' Value Return' Return Method Primitive Object Class Array Var Parameter Declaration)] + ["." box] + ["." descriptor] + ["." signature] + ["." reflection] + ["." parser]]]]]) + +(def: internal + (-> External Text) + (|>> name.internal + name.read)) + +(def: signature + (All [category] + (-> (Type category) Text)) + (|>> type.signature signature.signature)) + +(def: reflection + (All [category] + (-> (Type (<| Return' Value' category)) Text)) + (|>> type.reflection reflection.reflection)) + +(template [ ] + [(def: #export .Type (#.Primitive #.Nil))] + + [Boolean box.boolean] + [Byte box.byte] + [Short box.short] + [Integer box.int] + [Long box.long] + [Float box.float] + [Double box.double] + [Character box.char] + ) + +(template [ ] + [(def: #export .Type (#.Primitive (reflection.reflection ) #.Nil))] + + ## Primitives + [boolean reflection.boolean] + [byte reflection.byte] + [short reflection.short] + [int reflection.int] + [long reflection.long] + [float reflection.float] + [double reflection.double] + [char reflection.char] + ) + +(def: (get_static_field class field) + (-> Text Text Code) + (` ("jvm member get static" + (~ (code.text class)) + (~ (code.text field))))) + +(def: (get_virtual_field class field object) + (-> Text Text Code Code) + (` ("jvm member get virtual" + (~ (code.text class)) + (~ (code.text field)) + (~ object)))) + +(def: boxes + (Dictionary (Type Value) Text) + (|> (list [type.boolean box.boolean] + [type.byte box.byte] + [type.short box.short] + [type.int box.int] + [type.long box.long] + [type.float box.float] + [type.double box.double] + [type.char box.char]) + (dictionary.from_list type.hash))) + +(template [
 ]
+  [(def: ( unboxed boxed raw)
+     (-> (Type Value) Text Code Code)
+     (let [unboxed (..reflection unboxed)]
+       (` (|> (~ raw)
+              (: (primitive (~ (code.text 
))))
+              "jvm object cast"
+              (: (primitive (~ (code.text ))))))))]
+
+  [unbox boxed unboxed]
+  [box unboxed boxed]
+  )
+
+(template [   ]
+  [(template: #export ( value)
+     {#.doc (doc "Type converter."
+                 (: 
+                    ( (:  foo))))}
+     (|> value
+         (: )
+         "jvm object cast"
+         
+         "jvm object cast"
+         (: )))]
+
+  [byte_to_long    "jvm conversion byte-to-long"    ..Byte      ..Long]
+
+  [short_to_long   "jvm conversion short-to-long"   ..Short     ..Long]
+  
+  [double_to_int   "jvm conversion double-to-int"   ..Double    ..Integer]
+  [double_to_long  "jvm conversion double-to-long"  ..Double    ..Long]
+  [double_to_float "jvm conversion double-to-float" ..Double    ..Float]
+
+  [float_to_int    "jvm conversion float-to-int"    ..Float     ..Integer]
+  [float_to_long   "jvm conversion float-to-long"   ..Float     ..Long]
+  [float_to_double "jvm conversion float-to-double" ..Float     ..Double]
+  
+  [int_to_byte     "jvm conversion int-to-byte"     ..Integer   ..Byte]
+  [int_to_short    "jvm conversion int-to-short"    ..Integer   ..Short]
+  [int_to_long     "jvm conversion int-to-long"     ..Integer   ..Long]
+  [int_to_float    "jvm conversion int-to-float"    ..Integer   ..Float]
+  [int_to_double   "jvm conversion int-to-double"   ..Integer   ..Double]
+  [int_to_char     "jvm conversion int-to-char"     ..Integer   ..Character]
+
+  [long_to_byte    "jvm conversion long-to-byte"    ..Long      ..Byte]
+  [long_to_short   "jvm conversion long-to-short"   ..Long      ..Short]
+  [long_to_int     "jvm conversion long-to-int"     ..Long      ..Integer]
+  [long_to_float   "jvm conversion long-to-float"   ..Long      ..Float]
+  [long_to_double  "jvm conversion long-to-double"  ..Long      ..Double]
+
+  [char_to_byte    "jvm conversion char-to-byte"    ..Character ..Byte]
+  [char_to_short   "jvm conversion char-to-short"   ..Character ..Short]
+  [char_to_int     "jvm conversion char-to-int"     ..Character ..Integer]
+  [char_to_long    "jvm conversion char-to-long"    ..Character ..Long]
+  )
+
+(def: constructor_method_name "")
+
+(type: Primitive_Mode
+  #ManualPrM
+  #AutoPrM)
+
+(type: Privacy
+  #PublicP
+  #PrivateP
+  #ProtectedP
+  #DefaultP)
+
+(type: StateModifier
+  #VolatileSM
+  #FinalSM
+  #DefaultSM)
+
+(type: InheritanceModifier
+  #FinalIM
+  #AbstractIM
+  #DefaultIM)
+
+(type: Class_Kind
+  #Class
+  #Interface)
+
+(type: StackFrame (primitive "java/lang/StackTraceElement"))
+(type: StackTrace (array.Array StackFrame))
+
+(type: Annotation_Parameter
+  [Text Code])
+
+(type: Annotation
+  {#ann_name   Text
+   #ann_params (List Annotation_Parameter)})
+
+(type: Member_Declaration
+  {#member_name Text
+   #member_privacy Privacy
+   #member_anns (List Annotation)})
+
+(type: FieldDecl
+  (#ConstantField (Type Value) Code)
+  (#VariableField StateModifier (Type Value)))
+
+(type: MethodDecl
+  {#method_tvars  (List (Type Var))
+   #method_inputs (List (Type Value))
+   #method_output (Type Return)
+   #method_exs    (List (Type Class))})
+
+(type: Method_Definition
+  (#ConstructorMethod [Bit
+                       (List (Type Var))
+                       Text
+                       (List Argument)
+                       (List (Typed Code))
+                       Code
+                       (List (Type Class))])
+  (#VirtualMethod [Bit
+                   Bit
+                   (List (Type Var))
+                   Text
+                   (List Argument)
+                   (Type Return)
+                   Code
+                   (List (Type Class))])
+  (#OverridenMethod [Bit
+                     (Type Declaration)
+                     (List (Type Var))
+                     Text
+                     (List Argument)
+                     (Type Return)
+                     Code
+                     (List (Type Class))])
+  (#StaticMethod [Bit
+                  (List (Type Var))
+                  (List Argument)
+                  (Type Return)
+                  Code
+                  (List (Type Class))])
+  (#AbstractMethod [(List (Type Var))
+                    (List Argument)
+                    (Type Return)
+                    (List (Type Class))])
+  (#NativeMethod [(List (Type Var))
+                  (List Argument)
+                  (Type Return)
+                  (List (Type Class))]))
+
+(type: Partial_Call
+  {#pc_method Name
+   #pc_args   (List Code)})
+
+(type: ImportMethodKind
+  #StaticIMK
+  #VirtualIMK)
+
+(type: ImportMethodCommons
+  {#import_member_mode   Primitive_Mode
+   #import_member_alias  Text
+   #import_member_kind   ImportMethodKind
+   #import_member_tvars  (List (Type Var))
+   #import_member_args   (List [Bit (Type Value)])
+   #import_member_maybe? Bit
+   #import_member_try?   Bit
+   #import_member_io?    Bit})
+
+(type: ImportConstructorDecl
+  {})
+
+(type: ImportMethodDecl
+  {#import_method_name    Text
+   #import_method_return  (Type Return)})
+
+(type: ImportFieldDecl
+  {#import_field_mode    Primitive_Mode
+   #import_field_name    Text
+   #import_field_static? Bit
+   #import_field_maybe?  Bit
+   #import_field_setter? Bit
+   #import_field_type    (Type Value)})
+
+(type: Import_Member_Declaration
+  (#EnumDecl        (List Text))
+  (#ConstructorDecl [ImportMethodCommons ImportConstructorDecl])
+  (#MethodDecl      [ImportMethodCommons ImportMethodDecl])
+  (#FieldAccessDecl ImportFieldDecl))
+
+(def: (primitive_type mode type)
+  (-> Primitive_Mode (Type Primitive) Code)
+  (case mode
+    #ManualPrM
+    (cond (\ type.equivalence = type.boolean type) (` ..Boolean)
+          (\ type.equivalence = type.byte type) (` ..Byte)
+          (\ type.equivalence = type.short type) (` ..Short)
+          (\ type.equivalence = type.int type) (` ..Integer)
+          (\ type.equivalence = type.long type) (` ..Long)
+          (\ type.equivalence = type.float type) (` ..Float)
+          (\ type.equivalence = type.double type) (` ..Double)
+          (\ type.equivalence = type.char type) (` ..Character)
+          ## else
+          (undefined))
+    
+    #AutoPrM
+    (cond (\ type.equivalence = type.boolean type)
+          (` .Bit)
+          
+          (or (\ type.equivalence = type.short type)
+              (\ type.equivalence = type.byte type)
+              (\ type.equivalence = type.int type)
+              (\ type.equivalence = type.long type))
+          (` .Int)
+          
+          (or (\ type.equivalence = type.float type)
+              (\ type.equivalence = type.double type))
+          (` .Frac)
+
+          (\ type.equivalence = type.char type)
+          (` .Nat)
+
+          ## else
+          (undefined))))
+
+(def: (parameter_type type)
+  (-> (Type Parameter) Code)
+  (`` (<| (~~ (template [  ]
+                [(case ( type)
+                   (#.Some )
+                   
+
+                   #.None)]
+
+                [parser.var? name (code.identifier ["" name])]
+                [parser.wildcard? _ (` .Any)]
+                [parser.lower? _ (` .Any)]
+                [parser.upper? limit (parameter_type limit)]
+                [parser.class? [name parameters]
+                 (` (.primitive (~ (code.text name))
+                                [(~+ (list\map parameter_type parameters))]))]))
+          ## else
+          (undefined)
+          )))
+
+(def: (value_type mode type)
+  (-> Primitive_Mode (Type Value) Code)
+  (`` (<| (~~ (template [  ]
+                [(case ( type)
+                   (#.Some )
+                   
+
+                   #.None)]
+
+                [parser.parameter? type (parameter_type type)]
+                [parser.primitive? type (primitive_type mode type)]
+                [parser.array? elementT (case (parser.primitive? elementT)
+                                          (#.Some elementT)
+                                          (` (#.Primitive (~ (code.text (..reflection (type.array elementT)))) #.Nil))
+                                          
+                                          #.None
+                                          (` (#.Primitive (~ (code.text array.type_name))
+                                                          (#.Cons (~ (value_type mode elementT)) #.Nil))))]))
+          (undefined)
+          )))
+
+(def: declaration_type$
+  (-> (Type Declaration) Code)
+  (|>> ..signature code.text))
+
+(def: (make_get_const_parser class_name field_name)
+  (-> Text Text (Parser Code))
+  (do <>.monad
+    [#let [dotted_name (format "::" field_name)]
+     _ (.this! (code.identifier ["" dotted_name]))]
+    (wrap (get_static_field class_name field_name))))
+
+(def: (make_get_var_parser class_name field_name)
+  (-> Text Text (Parser Code))
+  (do <>.monad
+    [#let [dotted_name (format "::" field_name)]
+     _ (.this! (code.identifier ["" dotted_name]))]
+    (wrap (get_virtual_field class_name field_name (' _jvm_this)))))
+
+(def: (make_put_var_parser class_name field_name)
+  (-> Text Text (Parser Code))
+  (do <>.monad
+    [#let [dotted_name (format "::" field_name)]
+     [_ _ value] (: (Parser [Any Any Code])
+                    (.form ($_ <>.and (.this! (' :=)) (.this! (code.identifier ["" dotted_name])) .any)))]
+    (wrap (`' ((~ (code.text (format "jvm putfield" ":" class_name ":" field_name))) _jvm_this (~ value))))))
+
+(def: (pre_walk_replace f input)
+  (-> (-> Code Code) Code Code)
+  (case (f input)
+    (^template []
+      [[meta ( parts)]
+       [meta ( (list\map (pre_walk_replace f) parts))]])
+    ([#.Form]
+     [#.Tuple])
+    
+    [meta (#.Record pairs)]
+    [meta (#.Record (list\map (: (-> [Code Code] [Code Code])
+                                 (function (_ [key val])
+                                   [(pre_walk_replace f key) (pre_walk_replace f val)]))
+                              pairs))]
+    
+    ast'
+    ast'))
+
+(def: (parser->replacer p ast)
+  (-> (Parser Code) (-> Code Code))
+  (case (<>.run p (list ast))
+    (#.Right [#.Nil ast'])
+    ast'
+
+    _
+    ast
+    ))
+
+(def: (field->parser class_name [[field_name _ _] field])
+  (-> Text [Member_Declaration FieldDecl] (Parser Code))
+  (case field
+    (#ConstantField _)
+    (make_get_const_parser class_name field_name)
+    
+    (#VariableField _)
+    (<>.either (make_get_var_parser class_name field_name)
+               (make_put_var_parser class_name field_name))))
+
+(def: (decorate_input [class value])
+  (-> [(Type Value) Code] Code)
+  (` [(~ (code.text (..signature class))) (~ value)]))
+
+(def: (make_constructor_parser class_name arguments)
+  (-> Text (List Argument) (Parser Code))
+  (do <>.monad
+    [args (: (Parser (List Code))
+             (.form (<>.after (.this! (' ::new!))
+                                    (.tuple (<>.exactly (list.size arguments) .any)))))]
+    (wrap (` ("jvm member invoke constructor" (~ (code.text class_name))
+              (~+ (|> args
+                      (list.zip/2 (list\map product.right arguments))
+                      (list\map ..decorate_input))))))))
+
+(def: (make_static_method_parser class_name method_name arguments)
+  (-> Text Text (List Argument) (Parser Code))
+  (do <>.monad
+    [#let [dotted_name (format "::" method_name "!")]
+     args (: (Parser (List Code))
+             (.form (<>.after (.this! (code.identifier ["" dotted_name]))
+                                    (.tuple (<>.exactly (list.size arguments) .any)))))]
+    (wrap (` ("jvm member invoke static" (~ (code.text class_name)) (~ (code.text method_name))
+              (~+ (|> args
+                      (list.zip/2 (list\map product.right arguments))
+                      (list\map ..decorate_input))))))))
+
+(template [ ]
+  [(def: ( class_name method_name arguments)
+     (-> Text Text (List Argument) (Parser Code))
+     (do <>.monad
+       [#let [dotted_name (format "::" method_name "!")]
+        args (: (Parser (List Code))
+                (.form (<>.after (.this! (code.identifier ["" dotted_name]))
+                                       (.tuple (<>.exactly (list.size arguments) .any)))))]
+       (wrap (` ( (~ (code.text class_name)) (~ (code.text method_name))
+                          (~' _jvm_this)
+                          (~+ (|> args
+                                  (list.zip/2 (list\map product.right arguments))
+                                  (list\map ..decorate_input))))))))]
+
+  [make_special_method_parser "jvm member invoke special"]
+  [make_virtual_method_parser "jvm member invoke virtual"]
+  )
+
+(def: (method->parser class_name [[method_name _ _] meth_def])
+  (-> Text [Member_Declaration Method_Definition] (Parser Code))
+  (case meth_def
+    (#ConstructorMethod strict? type_vars self_name args constructor_args return_expr exs)
+    (make_constructor_parser class_name args)
+    
+    (#StaticMethod strict? type_vars args return_type return_expr exs)
+    (make_static_method_parser class_name method_name args)
+    
+    (^or (#VirtualMethod final? strict? type_vars self_name args return_type return_expr exs)
+         (#OverridenMethod strict? owner_class type_vars self_name args return_type return_expr exs))
+    (make_special_method_parser class_name method_name args)
+
+    (#AbstractMethod type_vars args return_type exs)
+    (make_virtual_method_parser class_name method_name args)
+
+    (#NativeMethod type_vars args return_type exs)
+    (make_virtual_method_parser class_name method_name args)))
+
+(def: privacy_modifier^
+  (Parser Privacy)
+  (let [(^open ".") <>.monad]
+    ($_ <>.or
+        (.this! (' #public))
+        (.this! (' #private))
+        (.this! (' #protected))
+        (wrap []))))
+
+(def: inheritance_modifier^
+  (Parser InheritanceModifier)
+  (let [(^open ".") <>.monad]
+    ($_ <>.or
+        (.this! (' #final))
+        (.this! (' #abstract))
+        (wrap []))))
+
+(exception: #export (class_names_cannot_contain_periods {name Text})
+  (exception.report
+   ["Name" (%.text name)]))
+
+(exception: #export (class_name_cannot_be_a_type_variable {name Text}
+                                                          {type_vars (List (Type Var))})
+  (exception.report
+   ["Name" (%.text name)]
+   ["Type Variables" (exception.enumerate parser.name type_vars)]))
+
+(def: (assert exception payload test)
+  (All [e] (-> (Exception e) e Bit (Parser Any)))
+  (<>.assert (exception.construct exception payload)
+             test))
+
+(def: (assert_valid_class_name type_vars name)
+  (-> (List (Type Var)) External (Parser Any))
+  (do <>.monad
+    [_ (..assert ..class_names_cannot_contain_periods [name]
+                 (not (text.contains? name.external_separator name)))]
+    (..assert ..class_name_cannot_be_a_type_variable [name type_vars]
+              (not (list.member? text.equivalence
+                                 (list\map parser.name type_vars)
+                                 name)))))
+
+(def: (valid_class_name type_vars)
+  (-> (List (Type Var)) (Parser External))
+  (do <>.monad
+    [name .local_identifier
+     _ (assert_valid_class_name type_vars name)]
+    (wrap name)))
+
+(def: (class^' parameter^ type_vars)
+  (-> (-> (List (Type Var)) (Parser (Type Parameter)))
+      (-> (List (Type Var)) (Parser (Type Class))))
+  (do <>.monad
+    [[name parameters] (: (Parser [External (List (Type Parameter))])
+                          ($_ <>.either
+                              (<>.and (valid_class_name type_vars)
+                                      (<>\wrap (list)))
+                              (.form (<>.and .local_identifier
+                                                   (<>.some (parameter^ type_vars))))))]
+    (wrap (type.class (name.sanitize name) parameters))))
+
+(exception: #export (unexpected_type_variable {name Text}
+                                              {type_vars (List (Type Var))})
+  (exception.report
+   ["Unexpected Type Variable" (%.text name)]
+   ["Expected Type Variables" (exception.enumerate parser.name type_vars)]))
+
+(def: (variable^ type_vars)
+  (-> (List (Type Var)) (Parser (Type Parameter)))
+  (do <>.monad
+    [name .local_identifier
+     _ (..assert ..unexpected_type_variable [name type_vars]
+                 (list.member? text.equivalence (list\map parser.name type_vars) name))]
+    (wrap (type.var name))))
+
+(def: wildcard^
+  (Parser (Type Parameter))
+  (do <>.monad
+    [_ (.this! (' ?))]
+    (wrap type.wildcard)))
+
+(template [  ]
+  [(def: 
+     (-> (Parser (Type Class)) (Parser (Type Parameter)))
+     (|>> (<>.after (.this! (' )))
+          (<>.after ..wildcard^)
+          .tuple
+          (\ <>.monad map )))]
+
+  [upper^ < type.upper]
+  [lower^ > type.lower]
+  )
+
+(def: (parameter^ type_vars)
+  (-> (List (Type Var)) (Parser (Type Parameter)))
+  (<>.rec
+   (function (_ recur^)
+     (let [class^ (..class^' parameter^ type_vars)]
+       ($_ <>.either
+           (..variable^ type_vars)
+           ..wildcard^
+           (upper^ class^)
+           (lower^ class^)
+           class^
+           )))))
+
+(def: (itself^ type)
+  (All [category]
+    (-> (Type (<| Return' Value' category))
+        (Parser (Type (<| Return' Value' category)))))
+  (do <>.monad
+    [_ (.identifier! ["" (..reflection type)])]
+    (wrap type)))
+
+(def: primitive^
+  (Parser (Type Primitive))
+  ($_ <>.either
+      (itself^ type.boolean)
+      (itself^ type.byte)
+      (itself^ type.short)
+      (itself^ type.int)
+      (itself^ type.long)
+      (itself^ type.float)
+      (itself^ type.double)
+      (itself^ type.char)
+      ))
+
+(def: array^
+  (-> (Parser (Type Value)) (Parser (Type Array)))
+  (|>> .tuple
+       (\ <>.monad map type.array)))
+
+(def: (type^ type_vars)
+  (-> (List (Type Var)) (Parser (Type Value)))
+  (<>.rec
+   (function (_ type^)
+     ($_ <>.either
+         ..primitive^
+         (..parameter^ type_vars)
+         (..array^ type^)
+         ))))
+
+(def: void^
+  (Parser (Type Void))
+  (do <>.monad
+    [_ (.identifier! ["" (reflection.reflection reflection.void)])]
+    (wrap type.void)))
+
+(def: (return^ type_vars)
+  (-> (List (Type Var)) (Parser (Type Return)))
+  (<>.either ..void^
+             (..type^ type_vars)))
+
+(def: var^
+  (Parser (Type Var))
+  (\ <>.monad map type.var .local_identifier))
+
+(def: vars^
+  (Parser (List (Type Var)))
+  (.tuple (<>.some var^)))
+
+(def: declaration^
+  (Parser (Type Declaration))
+  (do <>.monad
+    [[name variables] (: (Parser [External (List (Type Var))])
+                         (<>.either (<>.and (valid_class_name (list))
+                                            (<>\wrap (list)))
+                                    (.form (<>.and (valid_class_name (list))
+                                                         (<>.some var^)))
+                                    ))]
+    (wrap (type.declaration name variables))))
+
+(def: (class^ type_vars)
+  (-> (List (Type Var)) (Parser (Type Class)))
+  (class^' parameter^ type_vars))
+
+(def: annotation_parameters^
+  (Parser (List Annotation_Parameter))
+  (.record (<>.some (<>.and .local_tag .any))))
+
+(def: annotation^
+  (Parser Annotation)
+  (<>.either (do <>.monad
+               [ann_name .local_identifier]
+               (wrap [ann_name (list)]))
+             (.form (<>.and .local_identifier
+                                  annotation_parameters^))))
+
+(def: annotations^'
+  (Parser (List Annotation))
+  (do <>.monad
+    [_ (.this! (' #ann))]
+    (.tuple (<>.some ..annotation^))))
+
+(def: annotations^
+  (Parser (List Annotation))
+  (do <>.monad
+    [anns?? (<>.maybe ..annotations^')]
+    (wrap (maybe.default (list) anns??))))
+
+(def: (throws_decl^ type_vars)
+  (-> (List (Type Var)) (Parser (List (Type Class))))
+  (<| (<>.default (list))
+      (do <>.monad
+        [_ (.this! (' #throws))]
+        (.tuple (<>.some (..class^ type_vars))))))
+
+(def: (method_decl^ type_vars)
+  (-> (List (Type Var)) (Parser [Member_Declaration MethodDecl]))
+  (.form (do <>.monad
+                 [tvars (<>.default (list) ..vars^)
+                  name .local_identifier
+                  anns ..annotations^
+                  inputs (.tuple (<>.some (..type^ type_vars)))
+                  output (..return^ type_vars)
+                  exs (throws_decl^ type_vars)]
+                 (wrap [[name #PublicP anns] {#method_tvars tvars
+                                              #method_inputs inputs
+                                              #method_output output
+                                              #method_exs    exs}]))))
+
+(def: state_modifier^
+  (Parser StateModifier)
+  ($_ <>.or
+      (.this! (' #volatile))
+      (.this! (' #final))
+      (\ <>.monad wrap [])))
+
+(def: (field_decl^ type_vars)
+  (-> (List (Type Var)) (Parser [Member_Declaration FieldDecl]))
+  (<>.either (.form (do <>.monad
+                            [_ (.this! (' #const))
+                             name .local_identifier
+                             anns ..annotations^
+                             type (..type^ type_vars)
+                             body .any]
+                            (wrap [[name #PublicP anns] (#ConstantField [type body])])))
+             (.form (do <>.monad
+                            [pm privacy_modifier^
+                             sm state_modifier^
+                             name .local_identifier
+                             anns ..annotations^
+                             type (..type^ type_vars)]
+                            (wrap [[name pm anns] (#VariableField [sm type])])))))
+
+(def: (argument^ type_vars)
+  (-> (List (Type Var)) (Parser Argument))
+  (.record (<>.and .local_identifier
+                         (..type^ type_vars))))
+
+(def: (arguments^ type_vars)
+  (-> (List (Type Var)) (Parser (List Argument)))
+  (<>.some (..argument^ type_vars)))
+
+(def: (constructor_arg^ type_vars)
+  (-> (List (Type Var)) (Parser (Typed Code)))
+  (.record (<>.and (..type^ type_vars) .any)))
+
+(def: (constructor_args^ type_vars)
+  (-> (List (Type Var)) (Parser (List (Typed Code))))
+  (.tuple (<>.some (..constructor_arg^ type_vars))))
+
+(def: (constructor_method^ class_vars)
+  (-> (List (Type Var)) (Parser [Member_Declaration Method_Definition]))
+  (.form (do <>.monad
+                 [pm privacy_modifier^
+                  strict_fp? (<>.parses? (.this! (' #strict)))
+                  method_vars (<>.default (list) ..vars^)
+                  #let [total_vars (list\compose class_vars method_vars)]
+                  [_ self_name arguments] (.form ($_ <>.and
+                                                           (.this! (' new))
+                                                           .local_identifier
+                                                           (..arguments^ total_vars)))
+                  constructor_args (..constructor_args^ total_vars)
+                  exs (throws_decl^ total_vars)
+                  annotations ..annotations^
+                  body .any]
+                 (wrap [{#member_name constructor_method_name
+                         #member_privacy pm
+                         #member_anns annotations}
+                        (#ConstructorMethod strict_fp? method_vars self_name arguments constructor_args body exs)]))))
+
+(def: (virtual_method_def^ class_vars)
+  (-> (List (Type Var)) (Parser [Member_Declaration Method_Definition]))
+  (.form (do <>.monad
+                 [pm privacy_modifier^
+                  strict_fp? (<>.parses? (.this! (' #strict)))
+                  final? (<>.parses? (.this! (' #final)))
+                  method_vars (<>.default (list) ..vars^)
+                  #let [total_vars (list\compose class_vars method_vars)]
+                  [name self_name arguments] (.form ($_ <>.and
+                                                              .local_identifier
+                                                              .local_identifier
+                                                              (..arguments^ total_vars)))
+                  return_type (..return^ total_vars)
+                  exs (throws_decl^ total_vars)
+                  annotations ..annotations^
+                  body .any]
+                 (wrap [{#member_name name
+                         #member_privacy pm
+                         #member_anns annotations}
+                        (#VirtualMethod final? strict_fp? method_vars self_name arguments return_type body exs)]))))
+
+(def: overriden_method_def^
+  (Parser [Member_Declaration Method_Definition])
+  (.form (do <>.monad
+                 [strict_fp? (<>.parses? (.this! (' #strict)))
+                  owner_class ..declaration^
+                  method_vars (<>.default (list) ..vars^)
+                  #let [total_vars (list\compose (product.right (parser.declaration owner_class))
+                                                 method_vars)]
+                  [name self_name arguments] (.form ($_ <>.and
+                                                              .local_identifier
+                                                              .local_identifier
+                                                              (..arguments^ total_vars)))
+                  return_type (..return^ total_vars)
+                  exs (throws_decl^ total_vars)
+                  annotations ..annotations^
+                  body .any]
+                 (wrap [{#member_name name
+                         #member_privacy #PublicP
+                         #member_anns annotations}
+                        (#OverridenMethod strict_fp? owner_class method_vars self_name arguments return_type body exs)]))))
+
+(def: static_method_def^
+  (Parser [Member_Declaration Method_Definition])
+  (.form (do <>.monad
+                 [pm privacy_modifier^
+                  strict_fp? (<>.parses? (.this! (' #strict)))
+                  _ (.this! (' #static))
+                  method_vars (<>.default (list) ..vars^)
+                  #let [total_vars method_vars]
+                  [name arguments] (.form (<>.and .local_identifier
+                                                        (..arguments^ total_vars)))
+                  return_type (..return^ total_vars)
+                  exs (throws_decl^ total_vars)
+                  annotations ..annotations^
+                  body .any]
+                 (wrap [{#member_name name
+                         #member_privacy pm
+                         #member_anns annotations}
+                        (#StaticMethod strict_fp? method_vars arguments return_type body exs)]))))
+
+(def: abstract_method_def^
+  (Parser [Member_Declaration Method_Definition])
+  (.form (do <>.monad
+                 [pm privacy_modifier^
+                  _ (.this! (' #abstract))
+                  method_vars (<>.default (list) ..vars^)
+                  #let [total_vars method_vars]
+                  [name arguments] (.form (<>.and .local_identifier
+                                                        (..arguments^ total_vars)))
+                  return_type (..return^ total_vars)
+                  exs (throws_decl^ total_vars)
+                  annotations ..annotations^]
+                 (wrap [{#member_name name
+                         #member_privacy pm
+                         #member_anns annotations}
+                        (#AbstractMethod method_vars arguments return_type exs)]))))
+
+(def: native_method_def^
+  (Parser [Member_Declaration Method_Definition])
+  (.form (do <>.monad
+                 [pm privacy_modifier^
+                  _ (.this! (' #native))
+                  method_vars (<>.default (list) ..vars^)
+                  #let [total_vars method_vars]
+                  [name arguments] (.form (<>.and .local_identifier
+                                                        (..arguments^ total_vars)))
+                  return_type (..return^ total_vars)
+                  exs (throws_decl^ total_vars)
+                  annotations ..annotations^]
+                 (wrap [{#member_name name
+                         #member_privacy pm
+                         #member_anns annotations}
+                        (#NativeMethod method_vars arguments return_type exs)]))))
+
+(def: (method_def^ class_vars)
+  (-> (List (Type Var)) (Parser [Member_Declaration Method_Definition]))
+  ($_ <>.either
+      (..constructor_method^ class_vars)
+      (..virtual_method_def^ class_vars)
+      ..overriden_method_def^
+      ..static_method_def^
+      ..abstract_method_def^
+      ..native_method_def^))
+
+(def: partial_call^
+  (Parser Partial_Call)
+  (.form (<>.and .identifier (<>.some .any))))
+
+(def: class_kind^
+  (Parser Class_Kind)
+  (<>.either (do <>.monad
+               [_ (.this! (' #class))]
+               (wrap #Class))
+             (do <>.monad
+               [_ (.this! (' #interface))]
+               (wrap #Interface))
+             ))
+
+(def: import_member_alias^
+  (Parser (Maybe Text))
+  (<>.maybe (do <>.monad
+              [_ (.this! (' #as))]
+              .local_identifier)))
+
+(def: (import_member_args^ type_vars)
+  (-> (List (Type Var)) (Parser (List [Bit (Type Value)])))
+  (.tuple (<>.some (<>.and (<>.parses? (.tag! ["" "?"]))
+                                 (..type^ type_vars)))))
+
+(def: import_member_return_flags^
+  (Parser [Bit Bit Bit])
+  ($_ <>.and
+      (<>.parses? (.this! (' #io)))
+      (<>.parses? (.this! (' #try)))
+      (<>.parses? (.this! (' #?)))))
+
+(def: primitive_mode^
+  (Parser Primitive_Mode)
+  (<>.or (.tag! ["" "manual"])
+         (.tag! ["" "auto"])))
+
+(def: (import_member_decl^ owner_vars)
+  (-> (List (Type Var)) (Parser Import_Member_Declaration))
+  ($_ <>.either
+      (.form (do <>.monad
+                     [_ (.this! (' #enum))
+                      enum_members (<>.some .local_identifier)]
+                     (wrap (#EnumDecl enum_members))))
+      (.form (do <>.monad
+                     [tvars (<>.default (list) ..vars^)
+                      _ (.identifier! ["" "new"])
+                      ?alias import_member_alias^
+                      #let [total_vars (list\compose owner_vars tvars)]
+                      ?prim_mode (<>.maybe primitive_mode^)
+                      args (..import_member_args^ total_vars)
+                      [io? try? maybe?] import_member_return_flags^]
+                     (wrap (#ConstructorDecl [{#import_member_mode    (maybe.default #AutoPrM ?prim_mode)
+                                               #import_member_alias   (maybe.default "new" ?alias)
+                                               #import_member_kind    #VirtualIMK
+                                               #import_member_tvars   tvars
+                                               #import_member_args    args
+                                               #import_member_maybe?  maybe?
+                                               #import_member_try?    try?
+                                               #import_member_io?     io?}
+                                              {}]))
+                     ))
+      (.form (do <>.monad
+                     [kind (: (Parser ImportMethodKind)
+                              (<>.or (.tag! ["" "static"])
+                                     (wrap [])))
+                      tvars (<>.default (list) ..vars^)
+                      name .local_identifier
+                      ?alias import_member_alias^
+                      #let [total_vars (list\compose owner_vars tvars)]
+                      ?prim_mode (<>.maybe primitive_mode^)
+                      args (..import_member_args^ total_vars)
+                      [io? try? maybe?] import_member_return_flags^
+                      return (..return^ total_vars)]
+                     (wrap (#MethodDecl [{#import_member_mode    (maybe.default #AutoPrM ?prim_mode)
+                                          #import_member_alias   (maybe.default name ?alias)
+                                          #import_member_kind    kind
+                                          #import_member_tvars   tvars
+                                          #import_member_args    args
+                                          #import_member_maybe?  maybe?
+                                          #import_member_try?    try?
+                                          #import_member_io?     io?}
+                                         {#import_method_name    name
+                                          #import_method_return  return}]))))
+      (.form (do <>.monad
+                     [static? (<>.parses? (.this! (' #static)))
+                      name .local_identifier
+                      ?prim_mode (<>.maybe primitive_mode^)
+                      gtype (..type^ owner_vars)
+                      maybe? (<>.parses? (.this! (' #?)))
+                      setter? (<>.parses? (.this! (' #!)))]
+                     (wrap (#FieldAccessDecl {#import_field_mode    (maybe.default #AutoPrM ?prim_mode)
+                                              #import_field_name    name
+                                              #import_field_static? static?
+                                              #import_field_maybe?  maybe?
+                                              #import_field_setter? setter?
+                                              #import_field_type    gtype}))))
+      ))
+
+(def: bundle
+  (-> (List (Type Var)) (Parser [Text (List Import_Member_Declaration)]))
+  (|>> ..import_member_decl^
+       <>.some
+       (<>.and .text)
+       .tuple))
+
+(def: (privacy_modifier$ pm)
+  (-> Privacy Code)
+  (case pm
+    #PublicP    (code.text "public")
+    #PrivateP   (code.text "private")
+    #ProtectedP (code.text "protected")
+    #DefaultP   (code.text "default")))
+
+(def: (inheritance_modifier$ im)
+  (-> InheritanceModifier Code)
+  (case im
+    #FinalIM    (code.text "final")
+    #AbstractIM (code.text "abstract")
+    #DefaultIM  (code.text "default")))
+
+(def: (annotation_parameter$ [name value])
+  (-> Annotation_Parameter Code)
+  (` [(~ (code.text name)) (~ value)]))
+
+(def: (annotation$ [name params])
+  (-> Annotation Code)
+  (` ((~ (code.text name)) (~+ (list\map annotation_parameter$ params)))))
+
+(template [ ]
+  [(def: 
+     (-> (Type ) Code)
+     (|>> ..signature code.text))]
+
+  [var$ Var]
+  [parameter$ Parameter]
+  [value$ Value]
+  [return$ Return]
+  [declaration$ Declaration]
+  [class$ Class]
+  )
+
+(def: var$'
+  (-> (Type Var) Code)
+  (|>> ..signature code.local_identifier))
+
+(def: (method_decl$ [[name pm anns] method_decl])
+  (-> [Member_Declaration MethodDecl] Code)
+  (let [(^slots [#method_tvars #method_inputs #method_output #method_exs]) method_decl]
+    (` ((~ (code.text name))
+        [(~+ (list\map annotation$ anns))]
+        [(~+ (list\map var$ method_tvars))]
+        [(~+ (list\map class$ method_exs))]
+        [(~+ (list\map value$ method_inputs))]
+        (~ (return$ method_output))))))
+
+(def: (state_modifier$ sm)
+  (-> StateModifier Code)
+  (case sm
+    #VolatileSM (' "volatile")
+    #FinalSM    (' "final")
+    #DefaultSM  (' "default")))
+
+(def: (field_decl$ [[name pm anns] field])
+  (-> [Member_Declaration FieldDecl] Code)
+  (case field
+    (#ConstantField class value)
+    (` ("constant" (~ (code.text name))
+        [(~+ (list\map annotation$ anns))]
+        (~ (value$ class))
+        (~ value)
+        ))
+
+    (#VariableField sm class)
+    (` ("variable" (~ (code.text name))
+        (~ (privacy_modifier$ pm))
+        (~ (state_modifier$ sm))
+        [(~+ (list\map annotation$ anns))]
+        (~ (value$ class))
+        ))
+    ))
+
+(def: (argument$ [name type])
+  (-> Argument Code)
+  (` [(~ (code.text name)) (~ (value$ type))]))
+
+(def: (constructor_arg$ [class term])
+  (-> (Typed Code) Code)
+  (` [(~ (value$ class)) (~ term)]))
+
+(def: (method_def$ replacer super_class [[name pm anns] method_def])
+  (-> (-> Code Code) (Type Class) [Member_Declaration Method_Definition] Code)
+  (case method_def
+    (#ConstructorMethod strict_fp? type_vars self_name arguments constructor_args body exs)
+    (` ("init"
+        (~ (privacy_modifier$ pm))
+        (~ (code.bit strict_fp?))
+        [(~+ (list\map annotation$ anns))]
+        [(~+ (list\map var$ type_vars))]
+        [(~+ (list\map class$ exs))]
+        (~ (code.text self_name))
+        [(~+ (list\map argument$ arguments))]
+        [(~+ (list\map constructor_arg$ constructor_args))]
+        (~ (pre_walk_replace replacer body))
+        ))
+    
+    (#VirtualMethod final? strict_fp? type_vars self_name arguments return_type body exs)
+    (` ("virtual"
+        (~ (code.text name))
+        (~ (privacy_modifier$ pm))
+        (~ (code.bit final?))
+        (~ (code.bit strict_fp?))
+        [(~+ (list\map annotation$ anns))]
+        [(~+ (list\map var$ type_vars))]
+        (~ (code.text self_name))
+        [(~+ (list\map argument$ arguments))]
+        (~ (return$ return_type))
+        [(~+ (list\map class$ exs))]
+        (~ (pre_walk_replace replacer body))))
+    
+    (#OverridenMethod strict_fp? declaration type_vars self_name arguments return_type body exs)
+    (let [super_replacer (parser->replacer (.form (do <>.monad
+                                                          [_ (.this! (' ::super!))
+                                                           args (.tuple (<>.exactly (list.size arguments) .any))]
+                                                          (wrap (` ("jvm member invoke special"
+                                                                    (~ (code.text (product.left (parser.read_class super_class))))
+                                                                    (~ (code.text name))
+                                                                    (~' _jvm_this)
+                                                                    (~+ (|> args
+                                                                            (list.zip/2 (list\map product.right arguments))
+                                                                            (list\map ..decorate_input)))))))))]
+      (` ("override"
+          (~ (declaration$ declaration))
+          (~ (code.text name))
+          (~ (code.bit strict_fp?))
+          [(~+ (list\map annotation$ anns))]
+          [(~+ (list\map var$ type_vars))]
+          (~ (code.text self_name))
+          [(~+ (list\map argument$ arguments))]
+          (~ (return$ return_type))
+          [(~+ (list\map class$ exs))]
+          (~ (|> body
+                 (pre_walk_replace replacer)
+                 (pre_walk_replace super_replacer)))
+          )))
+
+    (#StaticMethod strict_fp? type_vars arguments return_type body exs)
+    (` ("static"
+        (~ (code.text name))
+        (~ (privacy_modifier$ pm))
+        (~ (code.bit strict_fp?))
+        [(~+ (list\map annotation$ anns))]
+        [(~+ (list\map var$ type_vars))]
+        [(~+ (list\map class$ exs))]
+        [(~+ (list\map argument$ arguments))]
+        (~ (return$ return_type))
+        (~ (pre_walk_replace replacer body))))
+
+    (#AbstractMethod type_vars arguments return_type exs)
+    (` ("abstract"
+        (~ (code.text name))
+        (~ (privacy_modifier$ pm))
+        [(~+ (list\map annotation$ anns))]
+        [(~+ (list\map var$ type_vars))]
+        [(~+ (list\map class$ exs))]
+        [(~+ (list\map argument$ arguments))]
+        (~ (return$ return_type))))
+
+    (#NativeMethod type_vars arguments return_type exs)
+    (` ("native"
+        (~ (code.text name))
+        (~ (privacy_modifier$ pm))
+        [(~+ (list\map annotation$ anns))]
+        [(~+ (list\map var$ type_vars))]
+        [(~+ (list\map class$ exs))]
+        [(~+ (list\map argument$ arguments))]
+        (~ (return$ return_type))))
+    ))
+
+(def: (complete_call$ g!obj [method args])
+  (-> Code Partial_Call Code)
+  (` ((~ (code.identifier method)) (~+ args) (~ g!obj))))
+
+(def: $Object
+  (Type Class)
+  (type.class "java.lang.Object" (list)))
+
+(syntax: #export (class:
+                   {#let [! <>.monad]}
+                   {im inheritance_modifier^}
+                   {[full_class_name class_vars] (\ ! map parser.declaration ..declaration^)}
+                   {super (<>.default $Object
+                                      (class^ class_vars))}
+                   {interfaces (<>.default (list)
+                                           (.tuple (<>.some (class^ class_vars))))}
+                   {annotations ..annotations^}
+                   {fields (<>.some (..field_decl^ class_vars))}
+                   {methods (<>.some (..method_def^ class_vars))})
+  {#.doc (doc "Allows defining JVM classes in Lux code."
+              "For example:"
+              (class: #final (TestClass A) [Runnable]
+                ## Fields
+                (#private foo boolean)
+                (#private bar A)
+                (#private baz java/lang/Object)
+                ## Methods
+                (#public [] (new [value A]) []
+                         (exec (:= ::foo #1)
+                           (:= ::bar value)
+                           (:= ::baz "")
+                           []))
+                (#public (virtual) java/lang/Object
+                         "")
+                (#public #static (static) java/lang/Object
+                         "")
+                (Runnable [] (run) void
+                          [])
+                )
+
+              "The tuple corresponds to parent interfaces."
+              "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed."
+              "Fields and methods defined in the class can be used with special syntax."
+              "For example:"
+              "::resolved, for accessing the 'resolved' field."
+              "(:= ::resolved #1) for modifying it."
+              "(::new! []) for calling the class's constructor."
+              "(::resolve! container [value]) for calling the 'resolve' method."
+              )}
+  (do meta.monad
+    [current_module meta.current_module_name
+     #let [fully_qualified_class_name (name.qualify current_module full_class_name)
+           field_parsers (list\map (field->parser fully_qualified_class_name) fields)
+           method_parsers (list\map (method->parser fully_qualified_class_name) methods)
+           replacer (parser->replacer (list\fold <>.either
+                                                 (<>.fail "")
+                                                 (list\compose field_parsers method_parsers)))]]
+    (wrap (list (` ("jvm class"
+                    (~ (declaration$ (type.declaration (name.qualify current_module full_class_name) class_vars)))
+                    (~ (class$ super))
+                    [(~+ (list\map class$ interfaces))]
+                    (~ (inheritance_modifier$ im))
+                    [(~+ (list\map annotation$ annotations))]
+                    [(~+ (list\map field_decl$ fields))]
+                    [(~+ (list\map (method_def$ replacer super) methods))]))))))
+
+(syntax: #export (interface:
+                   {#let [! <>.monad]}
+                   {[full_class_name class_vars] (\ ! map parser.declaration ..declaration^)}
+                   {supers (<>.default (list)
+                                       (.tuple (<>.some (class^ class_vars))))}
+                   {annotations ..annotations^}
+                   {members (<>.some (..method_decl^ class_vars))})
+  {#.doc (doc "Allows defining JVM interfaces."
+              (interface: TestInterface
+                ([] foo [boolean String] void #throws [Exception])))}
+  (do meta.monad
+    [current_module meta.current_module_name]
+    (wrap (list (` ("jvm class interface"
+                    (~ (declaration$ (type.declaration (name.qualify current_module full_class_name) class_vars)))
+                    [(~+ (list\map class$ supers))]
+                    [(~+ (list\map annotation$ annotations))]
+                    (~+ (list\map method_decl$ members))))))))
+
+(syntax: #export (object
+                   {class_vars ..vars^}
+                   {super (<>.default $Object
+                                      (class^ class_vars))}
+                   {interfaces (<>.default (list)
+                                           (.tuple (<>.some (class^ class_vars))))}
+                   {constructor_args (..constructor_args^ class_vars)}
+                   {methods (<>.some ..overriden_method_def^)})
+  {#.doc (doc "Allows defining anonymous classes."
+              "The 1st tuple corresponds to class-level type-variables."
+              "The 2nd tuple corresponds to parent interfaces."
+              "The 3rd tuple corresponds to arguments to the super class constructor."
+              "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed."
+              (object [] [Runnable]
+                []
+                (Runnable [] (run self) void
+                          (exec (do_something some_value)
+                            [])))
+              )}
+  (wrap (list (` ("jvm class anonymous"
+                  [(~+ (list\map var$ class_vars))]
+                  (~ (class$ super))
+                  [(~+ (list\map class$ interfaces))]
+                  [(~+ (list\map constructor_arg$ constructor_args))]
+                  [(~+ (list\map (method_def$ function.identity super) methods))])))))
+
+(syntax: #export (null)
+  {#.doc (doc "Null object reference."
+              (null))}
+  (wrap (list (` ("jvm object null")))))
+
+(def: #export (null? obj)
+  {#.doc (doc "Test for null object reference."
+              (= (null? (null))
+                 true)
+              (= (null? "YOLO")
+                 false))}
+  (-> (primitive "java.lang.Object") Bit)
+  ("jvm object null?" obj))
+
+(syntax: #export (??? expr)
+  {#.doc (doc "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it."
+              (= (??? (: java/lang/String (null)))
+                 #.None)
+              (= (??? "YOLO")
+                 (#.Some "YOLO")))}
+  (with_gensyms [g!temp]
+    (wrap (list (` (let [(~ g!temp) (~ expr)]
+                     (if ("jvm object null?" (~ g!temp))
+                       #.None
+                       (#.Some (~ g!temp)))))))))
+
+(syntax: #export (!!! expr)
+  {#.doc (doc "Takes a (Maybe ObjectType) and returns a ObjectType."
+              "A #.None would get translated into a (null)."
+              (= (null)
+                 (!!! (??? (: java/lang/Thread (null)))))
+              (= "foo"
+                 (!!! (??? "foo"))))}
+  (with_gensyms [g!value]
+    (wrap (list (` ({(#.Some (~ g!value))
+                     (~ g!value)
+
+                     #.None
+                     ("jvm object null")}
+                    (~ expr)))))))
+
+(syntax: #export (try expression)
+  {#.doc (doc (case (try (risky_computation input))
+                (#.Right success)
+                (do_something success)
+
+                (#.Left error)
+                (recover_from_failure error)))}
+  (wrap (list (` ("lux try" ((~! io.io) (~ expression)))))))
+
+(syntax: #export (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."
+              (case (check String "YOLO")
+                (#.Some value_as_string)
+                #.None))}
+  (with_gensyms [g!_ g!unchecked]
+    (let [class_name (..reflection class)
+          class_type (` (.primitive (~ (code.text class_name))))
+          check_type (` (.Maybe (~ class_type)))
+          check_code (` (if ("jvm object instance?" (~ (code.text class_name)) (~ g!unchecked))
+                          (#.Some (.:coerce (~ class_type)
+                                            (~ g!unchecked)))
+                          #.None))]
+      (case unchecked
+        (#.Some unchecked)
+        (wrap (list (` (: (~ check_type)
+                          (let [(~ g!unchecked) (~ unchecked)]
+                            (~ check_code))))))
+
+        #.None
+        (wrap (list (` (: (-> (primitive "java.lang.Object") (~ check_type))
+                          (function ((~ g!_) (~ g!unchecked))
+                            (~ check_code))))))
+        ))))
+
+(syntax: #export (synchronized lock body)
+  {#.doc (doc "Evaluates body, while holding a lock on a given object."
+              (synchronized object_to_be_locked
+                (exec (do_something ___)
+                  (do_something_else ___)
+                  (finish_the_computation ___))))}
+  (wrap (list (` ("jvm object synchronized" (~ lock) (~ body))))))
+
+(syntax: #export (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)
+                     (ClassName::method2 arg3 arg4 arg5)))}
+  (with_gensyms [g!obj]
+    (wrap (list (` (let [(~ g!obj) (~ obj)]
+                     (exec (~+ (list\map (complete_call$ g!obj) methods))
+                       (~ g!obj))))))))
+
+(def: (class_import$ declaration)
+  (-> (Type Declaration) Code)
+  (let [[full_name params] (parser.declaration declaration)
+        def_name (..internal full_name)
+        params' (list\map ..var$' params)]
+    (` (def: (~ (code.identifier ["" def_name]))
+         {#..jvm_class (~ (code.text (..internal full_name)))}
+         .Type
+         (All [(~+ params')]
+           (primitive (~ (code.text full_name))
+                      [(~+ params')]))))))
+
+(def: (member_type_vars class_tvars member)
+  (-> (List (Type Var)) Import_Member_Declaration (List (Type Var)))
+  (case member
+    (#ConstructorDecl [commons _])
+    (list\compose class_tvars (get@ #import_member_tvars commons))
+
+    (#MethodDecl [commons _])
+    (case (get@ #import_member_kind commons)
+      #StaticIMK
+      (get@ #import_member_tvars commons)
+
+      _
+      (list\compose class_tvars (get@ #import_member_tvars commons)))
+
+    _
+    class_tvars))
+
+(def: (member_def_arg_bindings vars member)
+  (-> (List (Type Var)) Import_Member_Declaration (Meta [(List [Bit Code]) (List (Type Value)) (List Code)]))
+  (case member
+    (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _]))
+    (let [(^slots [#import_member_tvars #import_member_args]) commons]
+      (do {! meta.monad}
+        [arg_inputs (monad.map !
+                               (: (-> [Bit (Type Value)] (Meta [Bit Code]))
+                                  (function (_ [maybe? _])
+                                    (with_gensyms [arg_name]
+                                      (wrap [maybe? arg_name]))))
+                               import_member_args)
+         #let [input_jvm_types (list\map product.right import_member_args)
+               arg_types (list\map (: (-> [Bit (Type Value)] Code)
+                                      (function (_ [maybe? arg])
+                                        (let [arg_type (value_type (get@ #import_member_mode commons) arg)]
+                                          (if maybe?
+                                            (` (Maybe (~ arg_type)))
+                                            arg_type))))
+                                   import_member_args)]]
+        (wrap [arg_inputs input_jvm_types arg_types])))
+
+    _
+    (\ meta.monad wrap [(list) (list) (list)])))
+
+(def: (decorate_return_maybe member never_null? unboxed return_term)
+  (-> Import_Member_Declaration Bit (Type Value) Code Code)
+  (case member
+    (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _]))
+    (cond (or never_null?
+              (dictionary.key? ..boxes unboxed))
+          return_term
+
+          (get@ #import_member_maybe? commons)
+          (` (??? (~ return_term)))
+
+          ## else
+          (let [g!temp (` ((~' ~') (~ (code.identifier ["" " Ω "]))))]
+            (` (let [(~ g!temp) (~ return_term)]
+                 (if (not (..null? (:coerce (primitive "java.lang.Object")
+                                            (~ g!temp))))
+                   (~ g!temp)
+                   (error! "Cannot produce null references from method calls."))))))
+
+    _
+    return_term))
+
+(template [  ]
+  [(def: ( member return_term)
+     (-> Import_Member_Declaration Code Code)
+     (case member
+       (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _]))
+       (if (get@  commons)
+         
+         return_term)
+
+       _
+       return_term))]
+
+  [decorate_return_try #import_member_try? (` (..try (~ return_term)))]
+  [decorate_return_io  #import_member_io?  (` ((~! io.io) (~ return_term)))]
+  )
+
+(def: $String (type.class "java.lang.String" (list)))
+
+(template [   ]
+  [(def: ( mode [unboxed raw])
+     (-> Primitive_Mode [(Type Value) Code] Code)
+     (let [[unboxed refined post] (: [(Type Value) Code (List Code)]
+                                     (case mode
+                                       #ManualPrM
+                                       [unboxed raw (list)]
+                                       
+                                       #AutoPrM
+                                       (with_expansions [' (template.splice )
+                                                          (template [  
 ]
+                                                                        [(\ type.equivalence =  unboxed)
+                                                                         (with_expansions [' (template.splice )]
+                                                                           [
+                                                                            (` (.|> (~ raw) (~+ 
)))
+                                                                            (list ')])]
+
+                                                                        ')]
+                                         (cond 
+                                               ## else
+                                               [unboxed
+                                                (if 
+                                                  (` ("jvm object cast" (~ raw)))
+                                                  raw)
+                                                (list)]))))
+           unboxed/boxed (case (dictionary.get unboxed ..boxes)
+                           (#.Some boxed)
+                           ( unboxed boxed refined)
+                           
+                           #.None
+                           refined)]
+       (case post
+         #.Nil
+         unboxed/boxed
+
+         _
+         (` (.|> (~ unboxed/boxed) (~+ post))))))]
+
+  [#1 auto_convert_input ..unbox
+   [[type.boolean type.boolean (list (` (.: .Bit)) (` (.:coerce (.primitive (~ (code.text box.boolean)))))) []]
+    [type.byte type.byte (list (` (.: .Int)) (` (.:coerce (.primitive (~ (code.text box.long))))) (` ..long_to_byte)) []]
+    [type.short type.short (list (` (.: .Int)) (` (.:coerce (.primitive (~ (code.text box.long))))) (` ..long_to_short)) []]
+    [type.int type.int (list (` (.: .Int)) (` (.:coerce (.primitive (~ (code.text box.long))))) (` ..long_to_int)) []]
+    [type.long type.long (list (` (.: .Int)) (` (.:coerce (.primitive (~ (code.text box.long)))))) []]
+    [type.float type.float (list (` (.: .Frac)) (` (.:coerce (.primitive (~ (code.text box.double))))) (` ..double_to_float)) []]
+    [type.double type.double (list (` (.: .Frac)) (` (.:coerce (.primitive (~ (code.text box.double)))))) []]
+    [..$String ..$String (list (` (.: .Text)) (` (.:coerce (.primitive (~ (code.text (..reflection ..$String))))))) []]
+    [(type.class box.boolean (list)) (type.class box.boolean (list)) (list (` (.: .Bit)) (` (.:coerce (.primitive (~ (code.text box.boolean)))))) []]
+    [(type.class box.long (list)) (type.class box.long (list)) (list (` (.: .Int)) (` (.:coerce (.primitive (~ (code.text box.long)))))) []]
+    [(type.class box.double (list)) (type.class box.double (list)) (list (` (.: .Frac)) (` (.:coerce (.primitive (~ (code.text box.double)))))) []]]]
+  [#0 auto_convert_output ..box
+   [[type.boolean type.boolean (list) [(` (.: (.primitive (~ (code.text box.boolean))))) (` (.:coerce .Bit))]]
+    [type.byte type.long (list (` "jvm conversion byte-to-long")) [(` (.: (.primitive (~ (code.text box.long))))) (` (.:coerce .Int))]]
+    [type.short type.long (list (` "jvm conversion short-to-long")) [(` (.: (.primitive (~ (code.text box.long))))) (` (.:coerce .Int))]]
+    [type.int type.long (list (` "jvm conversion int-to-long")) [(` (.: (.primitive (~ (code.text box.long))))) (` (.:coerce .Int))]]
+    [type.long type.long (list) [(` (.: (.primitive (~ (code.text box.long))))) (` (.:coerce .Int))]]
+    [type.float type.double (list (` "jvm conversion float-to-double")) [(` (.: (.primitive (~ (code.text box.double))))) (` (.:coerce .Frac))]]
+    [type.double type.double (list) [(` (.: (.primitive (~ (code.text box.double))))) (` (.:coerce .Frac))]]
+    [..$String ..$String (list) [(` (.: (.primitive (~ (code.text (..reflection ..$String)))))) (` (.:coerce .Text))]]
+    [(type.class box.boolean (list)) (type.class box.boolean (list)) (list) [(` (.: (.primitive (~ (code.text box.boolean))))) (` (.:coerce .Bit))]]
+    [(type.class box.long (list)) (type.class box.long (list)) (list) [(` (.: (.primitive (~ (code.text box.long))))) (` (.:coerce .Int))]]
+    [(type.class box.double (list)) (type.class box.double (list)) (list) [(` (.: (.primitive (~ (code.text box.double))))) (` (.:coerce .Frac))]]]]
+  )
+
+(def: (un_quote quoted)
+  (-> Code Code)
+  (` ((~' ~) (~ quoted))))
+
+(def: (jvm_invoke_inputs mode classes inputs)
+  (-> Primitive_Mode (List (Type Value)) (List [Bit Code]) (List Code))
+  (|> inputs
+      (list\map (function (_ [maybe? input])
+                  (if maybe?
+                    (` ((~! !!!) (~ (un_quote input))))
+                    (un_quote input))))
+      (list.zip/2 classes)
+      (list\map (auto_convert_input mode))))
+
+(def: (import_name format class member)
+  (-> Text Text Text Text)
+  (|> format
+      (text.replace_all "#" class)
+      (text.replace_all "." member)))
+
+(def: (member_def_interop vars kind class [arg_function_inputs input_jvm_types arg_types] member method_prefix import_format)
+  (-> (List (Type Var)) Class_Kind (Type Declaration) [(List [Bit Code]) (List (Type Value)) (List Code)] Import_Member_Declaration Text Text (Meta (List Code)))
+  (let [[full_name class_tvars] (parser.declaration class)]
+    (case member
+      (#EnumDecl enum_members)
+      (do meta.monad
+        [#let [enum_type (: Code
+                            (case class_tvars
+                              #.Nil
+                              (` (primitive (~ (code.text full_name))))
+
+                              _
+                              (let [=class_tvars (list\map ..var$' class_tvars)]
+                                (` (All [(~+ =class_tvars)] (primitive (~ (code.text full_name)) [(~+ =class_tvars)]))))))
+               getter_interop (: (-> Text Code)
+                                 (function (_ name)
+                                   (let [getter_name (code.identifier ["" (..import_name import_format method_prefix name)])]
+                                     (` (def: (~ getter_name)
+                                          (~ enum_type)
+                                          (~ (get_static_field full_name name)))))))]]
+        (wrap (list\map getter_interop enum_members)))
+      
+      (#ConstructorDecl [commons _])
+      (do meta.monad
+        [#let [classT (type.class full_name (list))
+               def_name (code.identifier ["" (..import_name import_format method_prefix (get@ #import_member_alias commons))])
+               jvm_interop (|> [classT
+                                (` ("jvm member invoke constructor"
+                                    [(~+ (list\map ..var$ class_tvars))]
+                                    (~ (code.text full_name))
+                                    [(~+ (list\map ..var$ (get@ #import_member_tvars commons)))]
+                                    (~+ (|> (jvm_invoke_inputs (get@ #import_member_mode commons) input_jvm_types arg_function_inputs)
+                                            (list.zip/2 input_jvm_types)
+                                            (list\map ..decorate_input)))))]
+                               (auto_convert_output (get@ #import_member_mode commons))
+                               (decorate_return_maybe member true classT)
+                               (decorate_return_try member)
+                               (decorate_return_io member))]]
+        (wrap (list (` ((~! syntax:) ((~ def_name) (~+ (list\map product.right arg_function_inputs)))
+                        ((~' wrap) (.list (.` (~ jvm_interop)))))))))
+
+      (#MethodDecl [commons method])
+      (with_gensyms [g!obj]
+        (do meta.monad
+          [#let [def_name (code.identifier ["" (..import_name import_format method_prefix (get@ #import_member_alias commons))])
+                 (^slots [#import_member_kind]) commons
+                 (^slots [#import_method_name]) method
+                 [jvm_op object_ast] (: [Text (List Code)]
+                                        (case import_member_kind
+                                          #StaticIMK
+                                          ["jvm member invoke static"
+                                           (list)]
+
+                                          #VirtualIMK
+                                          (case kind
+                                            #Class
+                                            ["jvm member invoke virtual"
+                                             (list g!obj)]
+                                            
+                                            #Interface
+                                            ["jvm member invoke interface"
+                                             (list g!obj)]
+                                            )))
+                 method_return (get@ #import_method_return method)
+                 callC (: Code
+                          (` ((~ (code.text jvm_op))
+                              [(~+ (list\map ..var$ class_tvars))]
+                              (~ (code.text full_name))
+                              (~ (code.text import_method_name))
+                              [(~+ (list\map ..var$ (get@ #import_member_tvars commons)))]
+                              (~+ (|> object_ast
+                                      (list\map ..un_quote)
+                                      (list.zip/2 (list (type.class full_name (list))))
+                                      (list\map (auto_convert_input (get@ #import_member_mode commons)))))
+                              (~+ (|> (jvm_invoke_inputs (get@ #import_member_mode commons) input_jvm_types arg_function_inputs)
+                                      (list.zip/2 input_jvm_types)
+                                      (list\map ..decorate_input))))))
+                 jvm_interop (: Code
+                                (case (type.void? method_return)
+                                  (#.Left method_return)
+                                  (|> [method_return
+                                       callC]
+                                      (auto_convert_output (get@ #import_member_mode commons))
+                                      (decorate_return_maybe member false method_return)
+                                      (decorate_return_try member)
+                                      (decorate_return_io member))
+                                  
+                                  
+                                  (#.Right method_return)
+                                  (|> callC
+                                      (decorate_return_try member)
+                                      (decorate_return_io member))))]]
+          (wrap (list (` ((~! syntax:) ((~ def_name) (~+ (list\map product.right arg_function_inputs)) (~+ object_ast))
+                          ((~' wrap) (.list (.` (~ jvm_interop))))))))))
+
+      (#FieldAccessDecl fad)
+      (do meta.monad
+        [#let [(^open ".") fad
+               getter_name (code.identifier ["" (..import_name import_format method_prefix import_field_name)])
+               setter_name (code.identifier ["" (..import_name import_format method_prefix (format import_field_name "!"))])]
+         getter_interop (with_gensyms [g!obj]
+                          (let [getter_call (if import_field_static?
+                                              (` ((~ getter_name)))
+                                              (` ((~ getter_name) (~ g!obj))))
+                                getter_body (<| (auto_convert_output import_field_mode)
+                                                [import_field_type
+                                                 (if import_field_static?
+                                                   (get_static_field full_name import_field_name)
+                                                   (get_virtual_field full_name import_field_name (un_quote g!obj)))])
+                                getter_body (if import_field_maybe?
+                                              (` ((~! ???) (~ getter_body)))
+                                              getter_body)
+                                getter_body (if import_field_setter?
+                                              (` ((~! io.io) (~ getter_body)))
+                                              getter_body)]
+                            (wrap (` ((~! syntax:) (~ getter_call)
+                                      ((~' wrap) (.list (.` (~ getter_body)))))))))
+         setter_interop (: (Meta (List Code))
+                           (if import_field_setter?
+                             (with_gensyms [g!obj g!value]
+                               (let [setter_call (if import_field_static?
+                                                   (` ((~ setter_name) (~ g!value)))
+                                                   (` ((~ setter_name) (~ g!value) (~ g!obj))))
+                                     setter_value (|> [import_field_type (un_quote g!value)]
+                                                      (auto_convert_input import_field_mode))
+                                     setter_value (if import_field_maybe?
+                                                    (` ((~! !!!) (~ setter_value)))
+                                                    setter_value)
+                                     setter_command (format (if import_field_static? "jvm putstatic" "jvm putfield")
+                                                            ":" full_name ":" import_field_name)
+                                     g!obj+ (: (List Code)
+                                               (if import_field_static?
+                                                 (list)
+                                                 (list (un_quote g!obj))))]
+                                 (wrap (list (` ((~! syntax:) (~ setter_call)
+                                                 ((~' wrap) (.list (.` ((~! io.io) ((~ (code.text setter_command)) (~+ g!obj+) (~ setter_value))))))))))))
+                             (wrap (list))))]
+        (wrap (list& getter_interop setter_interop)))
+      )))
+
+(def: (member_import$ vars kind class [import_format member])
+  (-> (List (Type Var)) Class_Kind (Type Declaration) [Text Import_Member_Declaration] (Meta (List Code)))
+  (let [[full_name _] (parser.declaration class)
+        method_prefix (..internal full_name)]
+    (do meta.monad
+      [=args (member_def_arg_bindings vars member)]
+      (member_def_interop vars kind class =args member method_prefix import_format))))
+
+(def: interface?
+  (All [a] (-> (primitive "java.lang.Class" [a]) Bit))
+  (|>> ("jvm member invoke virtual" [] "java.lang.Class" "isInterface" [])
+       "jvm object cast"
+       (: ..Boolean)
+       (:coerce Bit)))
+
+(def: load_class
+  (-> External (Try (primitive "java.lang.Class" [Any])))
+  (|>> (:coerce (primitive "java.lang.String"))
+       ["Ljava/lang/String;"]
+       ("jvm member invoke static" [] "java.lang.Class" "forName" [])
+       ..try))
+
+(def: (class_kind declaration)
+  (-> (Type Declaration) (Meta Class_Kind))
+  (let [[class_name _] (parser.declaration declaration)]
+    (case (load_class class_name)
+      (#.Right class)
+      (\ meta.monad wrap (if (interface? class)
+                           #Interface
+                           #Class))
+
+      (#.Left _)
+      (meta.fail (format "Unknown class: " class_name)))))
+
+(syntax: #export (import:
+                   {declaration ..declaration^}
+                   {#let [[class_name class_type_vars] (parser.declaration declaration)]}
+                   {bundles (<>.some (..bundle class_type_vars))})
+  {#.doc (doc "Allows importing JVM classes, and using them as types."
+              "Their methods, fields and enum options can also be imported."
+              (import: java/lang/Object
+                ["#::."
+                 (new [])
+                 (equals [java/lang/Object] boolean)
+                 (wait [int] #io #try void)])
+              
+              "Special options can also be given for the return values."
+              "#? means that the values will be returned inside a Maybe type. That way, null becomes #.None."
+              "#try means that the computation might throw an exception, and the return value will be wrapped by the Try type."
+              "#io means the computation has side effects, and will be wrapped by the IO type."
+              "These options must show up in the following order [#io #try #?] (although, each option can be used independently)."
+              (import: java/lang/String
+                ["#::."
+                 (new [[byte]])
+                 (#static valueOf [char] java/lang/String)
+                 (#static valueOf #as int_valueOf [int] java/lang/String)])
+
+              (import: (java/util/List e)
+                ["#::."
+                 (size [] int)
+                 (get [int] e)])
+
+              (import: (java/util/ArrayList a)
+                ["#::."
+                 ([T] toArray [[T]] [T])])
+              
+              "The class-type that is generated is of the fully-qualified name."
+              "This avoids a clash between the java.util.List type, and Lux's own List type."
+              "All enum options to be imported must be specified."
+              (import: java/lang/Character$UnicodeScript
+                ["#::."
+                 (#enum ARABIC CYRILLIC LATIN)])
+
+              "It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-vars."
+              "Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes)."
+              (import: (lux/concurrency/promise/JvmPromise A)
+                ["#::."
+                 (resolve [A] boolean)
+                 (poll [] A)
+                 (wasResolved [] boolean)
+                 (waitOn [lux/Function] void)
+                 (#static [A] make [A] (lux/concurrency/promise/JvmPromise A))])
+              
+              "Also, the names of the imported members will look like Class::member"
+              (java/lang/Object::new [])
+              (java/lang/Object::equals [other_object] my_object)
+              (java/util/List::size [] my_list)
+              java/lang/Character$UnicodeScript::LATIN
+              )}
+  (do {! meta.monad}
+    [kind (class_kind declaration)
+     =members (|> bundles
+                  (list\map (function (_ [import_format members])
+                              (list\map (|>> [import_format]) members)))
+                  list.concat
+                  (monad.map ! (member_import$ class_type_vars kind declaration)))]
+    (wrap (list& (class_import$ declaration) (list\join =members)))))
+
+(syntax: #export (array {type (..type^ (list))}
+                        size)
+  {#.doc (doc "Create an array of the given type, with the given size."
+              (array java/lang/Object 10))}
+  (let [g!size (` (|>  (~ size)
+                       (.: .Nat)
+                       (.:coerce (.primitive (~ (code.text box.long))))
+                       "jvm object cast"
+                       "jvm conversion long-to-int"))]
+    (`` (cond (~~ (template [ ]
+                    [(\ type.equivalence =  type)
+                     (wrap (list (` ( (~ g!size)))))]
+
+                    [type.boolean "jvm array new boolean"]
+                    [type.byte    "jvm array new byte"]
+                    [type.short   "jvm array new short"]
+                    [type.int     "jvm array new int"]
+                    [type.long    "jvm array new long"]
+                    [type.float   "jvm array new float"]
+                    [type.double  "jvm array new double"]
+                    [type.char    "jvm array new char"]))
+              ## else
+              (wrap (list (` (: (~ (value_type #ManualPrM (type.array type)))
+                                ("jvm array new object" (~ g!size))))))))))
+
+(exception: #export (cannot_convert_to_jvm_type {type .Type})
+  (exception.report
+   ["Lux Type" (%.type type)]))
+
+(with_expansions [ (as_is (meta.fail (exception.construct ..cannot_convert_to_jvm_type [type])))]
+  (def: (lux_type->jvm_type type)
+    (-> .Type (Meta (Type Value)))
+    (if (lux_type\= Any type)
+      (\ meta.monad wrap $Object)
+      (case type
+        (#.Primitive name params)
+        (`` (cond (~~ (template []
+                        [(text\= (..reflection ) name)
+                         (case params
+                           #.Nil
+                           (\ meta.monad wrap )
+
+                           _
+                           )]
+                        
+                        [type.boolean]
+                        [type.byte]
+                        [type.short]
+                        [type.int]
+                        [type.long]
+                        [type.float]
+                        [type.double]
+                        [type.char]))
+
+                  (~~ (template []
+                        [(text\= (..reflection (type.array )) name)
+                         (case params
+                           #.Nil
+                           (\ meta.monad wrap (type.array ))
+
+                           _
+                           )]
+                        
+                        [type.boolean]
+                        [type.byte]
+                        [type.short]
+                        [type.int]
+                        [type.long]
+                        [type.float]
+                        [type.double]
+                        [type.char]))
+
+                  (text\= array.type_name name)
+                  (case params
+                    (#.Cons elementLT #.Nil)
+                    (\ meta.monad map type.array
+                       (lux_type->jvm_type elementLT))
+
+                    _
+                    )
+
+                  (text.starts_with? descriptor.array_prefix name)
+                  (case params
+                    #.Nil
+                    (let [[_ unprefixed] (maybe.assume (text.split_with descriptor.array_prefix name))]
+                      (\ meta.monad map type.array
+                         (lux_type->jvm_type (#.Primitive unprefixed (list)))))
+
+                    _
+                    )
+
+                  ## else
+                  (\ meta.monad map (type.class name)
+                     (: (Meta (List (Type Parameter)))
+                        (monad.map meta.monad
+                                   (function (_ paramLT)
+                                     (do meta.monad
+                                       [paramJT (lux_type->jvm_type paramLT)]
+                                       (case (parser.parameter? paramJT)
+                                         (#.Some paramJT)
+                                         (wrap paramJT)
+
+                                         #.None
+                                         )))
+                                   params)))))
+
+        (#.Apply A F)
+        (case (lux_type.apply (list A) F)
+          #.None
+          
+
+          (#.Some type')
+          (lux_type->jvm_type type'))
+        
+        (#.Named _ type')
+        (lux_type->jvm_type type')
+
+        _
+        ))))
+
+(syntax: #export (array_length array)
+  {#.doc (doc "Gives the length of an array."
+              (array_length my_array))}
+  (case array
+    [_ (#.Identifier array_name)]
+    (do meta.monad
+      [array_type (meta.find_type array_name)
+       array_jvm_type (lux_type->jvm_type array_type)
+       #let [g!extension (code.text (`` (cond (~~ (template [ ]
+                                                    [(\ type.equivalence =
+                                                        (type.array )
+                                                        array_jvm_type)
+                                                     ]
+
+                                                    [type.boolean "jvm array length boolean"]
+                                                    [type.byte "jvm array length byte"]
+                                                    [type.short "jvm array length short"]
+                                                    [type.int "jvm array length int"]
+                                                    [type.long "jvm array length long"]
+                                                    [type.float "jvm array length float"]
+                                                    [type.double "jvm array length double"]
+                                                    [type.char "jvm array length char"]))
+                                              
+                                              ## else
+                                              "jvm array length object")))]]
+      (wrap (list (` (.|> ((~ g!extension) (~ array))
+                          "jvm conversion int-to-long"
+                          "jvm object cast"
+                          (.: (.primitive (~ (code.text box.long))))
+                          (.:coerce .Nat))))))
+
+    _
+    (with_gensyms [g!array]
+      (wrap (list (` (let [(~ g!array) (~ array)]
+                       (..array_length (~ g!array)))))))))
+
+(syntax: #export (array_read idx array)
+  {#.doc (doc "Loads an element from an array."
+              (array_read 10 my_array))}
+  (case array
+    [_ (#.Identifier array_name)]
+    (do meta.monad
+      [array_type (meta.find_type array_name)
+       array_jvm_type (lux_type->jvm_type array_type)
+       #let [g!idx (` (.|> (~ idx)
+                           (.: .Nat)
+                           (.:coerce (.primitive (~ (code.text box.long))))
+                           "jvm object cast"
+                           "jvm conversion long-to-int"))]]
+      (`` (cond (~~ (template [  ]
+                      [(\ type.equivalence =
+                          (type.array )
+                          array_jvm_type)
+                       (wrap (list (` (.|> ( (~ g!idx) (~ array))
+                                           "jvm object cast"
+                                           (.: (.primitive (~ (code.text ))))))))]
+
+                      [type.boolean "jvm array read boolean" box.boolean]
+                      [type.byte "jvm array read byte" box.byte]
+                      [type.short "jvm array read short" box.short]
+                      [type.int "jvm array read int" box.int]
+                      [type.long "jvm array read long" box.long]
+                      [type.float "jvm array read float" box.float]
+                      [type.double "jvm array read double" box.double]
+                      [type.char "jvm array read char" box.char]))
+                
+                ## else
+                (wrap (list (` ("jvm array read object" (~ g!idx) (~ array))))))))
+
+    _
+    (with_gensyms [g!array]
+      (wrap (list (` (let [(~ g!array) (~ array)]
+                       (..array_read (~ idx) (~ g!array)))))))))
+
+(syntax: #export (array_write idx value array)
+  {#.doc (doc "Stores an element into an array."
+              (array_write 10 my_object my_array))}
+  (case array
+    [_ (#.Identifier array_name)]
+    (do meta.monad
+      [array_type (meta.find_type array_name)
+       array_jvm_type (lux_type->jvm_type array_type)
+       #let [g!idx (` (.|> (~ idx)
+                           (.: .Nat)
+                           (.:coerce (.primitive (~ (code.text box.long))))
+                           "jvm object cast"
+                           "jvm conversion long-to-int"))]]
+      (`` (cond (~~ (template [  ]
+                      [(\ type.equivalence =
+                          (type.array )
+                          array_jvm_type)
+                       (let [g!value (` (.|> (~ value)
+                                             (.:coerce (.primitive (~ (code.text ))))
+                                             "jvm object cast"))]
+                         (wrap (list (` ( (~ g!idx) (~ g!value) (~ array))))))]
+
+                      [type.boolean "jvm array write boolean" box.boolean]
+                      [type.byte "jvm array write byte" box.byte]
+                      [type.short "jvm array write short" box.short]
+                      [type.int "jvm array write int" box.int]
+                      [type.long "jvm array write long" box.long]
+                      [type.float "jvm array write float" box.float]
+                      [type.double "jvm array write double" box.double]
+                      [type.char "jvm array write char" box.char]))
+                
+                ## else
+                (wrap (list (` ("jvm array write object" (~ g!idx) (~ value) (~ array))))))))
+
+    _
+    (with_gensyms [g!array]
+      (wrap (list (` (let [(~ g!array) (~ array)]
+                       (..array_write (~ idx) (~ value) (~ g!array)))))))))
+
+(syntax: #export (class_for {type (..type^ (list))})
+  {#.doc (doc "Loads the class as a java.lang.Class object."
+              (class_for java/lang/String))}
+  (wrap (list (` ("jvm object class" (~ (code.text (..reflection type))))))))
+
+(syntax: #export (type {type (..type^ (list))})
+  (wrap (list (value_type #ManualPrM type))))
diff --git a/stdlib/source/lux/ffi.lua.lux b/stdlib/source/lux/ffi.lua.lux
new file mode 100644
index 000000000..785ca82d6
--- /dev/null
+++ b/stdlib/source/lux/ffi.lua.lux
@@ -0,0 +1,313 @@
+(.module:
+  [lux #*
+   ["." meta]
+   ["@" target]
+   [abstract
+    [monad (#+ do)]]
+   [control
+    ["." io]
+    ["<>" parser ("#\." monad)
+     ["" code (#+ Parser)]]]
+   [data
+    ["." product]
+    ["." maybe]
+    ["." text
+     ["%" format (#+ format)]]
+    [collection
+     ["." list ("#\." functor fold)]]]
+   [type
+    abstract]
+   [macro (#+ with_gensyms)
+    [syntax (#+ syntax:)]
+    ["." code]
+    ["." template]]])
+
+(abstract: #export (Object brand) Any)
+
+(template []
+  [(with_expansions [ (template.identifier [ "'"])]
+     (abstract: #export  Any)
+     (type: #export 
+       (..Object )))]
+
+  [Nil]
+  [Function]
+  [Table]
+  )
+
+(template [ ]
+  [(type: #export 
+     )]
+
+  [Boolean Bit]
+  [Integer Int]
+  [Float   Frac]
+  [String  Text]
+  )
+
+(type: Nilable
+  [Bit Code])
+
+(def: nilable
+  (Parser Nilable)
+  (let [token (' #?)]
+    (<| (<>.and (<>.parses? (.this! token)))
+        (<>.after (<>.not (.this! token)))
+        .any)))
+
+(type: Field
+  [Bit Text Nilable])
+
+(def: static!
+  (Parser Any)
+  (.this! (' #static)))
+
+(def: field
+  (Parser Field)
+  (.form ($_ <>.and
+                (<>.parses? ..static!)
+                .local_identifier
+                ..nilable)))
+
+(def: constant
+  (Parser Field)
+  (.form ($_ <>.and
+                (<>\wrap true)
+                .local_identifier
+                ..nilable)))
+
+(type: Common_Method
+  {#name Text
+   #alias (Maybe Text)
+   #inputs (List Nilable)
+   #io? Bit
+   #try? Bit
+   #output Nilable})
+
+(type: Static_Method Common_Method)
+(type: Virtual_Method Common_Method)
+
+(type: Method
+  (#Static Static_Method)
+  (#Virtual Virtual_Method))
+
+(def: common_method
+  (Parser Common_Method)
+  ($_ <>.and
+      .local_identifier
+      (<>.maybe (<>.after (.this! (' #as)) .local_identifier))
+      (.tuple (<>.some ..nilable))
+      (<>.parses? (.this! (' #io)))
+      (<>.parses? (.this! (' #try)))
+      ..nilable))
+
+(def: static_method
+  (<>.after ..static! ..common_method))
+
+(def: method
+  (Parser Method)
+  (.form (<>.or ..static_method
+                   ..common_method)))
+
+(type: Member
+  (#Field Field)
+  (#Method Method))
+
+(def: member
+  (Parser Member)
+  ($_ <>.or
+      ..field
+      ..method
+      ))
+
+(def: input_variables
+  (-> (List Nilable) (List [Bit Code]))
+  (|>> list.enumeration
+       (list\map (function (_ [idx [nilable? type]])
+                   [nilable? (|> idx %.nat code.local_identifier)]))))
+
+(def: (nilable_type [nilable? type])
+  (-> Nilable Code)
+  (if nilable?
+    (` (.Maybe (~ type)))
+    type))
+
+(def: (with_nil g!temp [nilable? input])
+  (-> Code [Bit Code] Code)
+  (if nilable?
+    (` (case (~ input)
+         (#.Some (~ g!temp))
+         (~ g!temp)
+
+         #.Nil
+         ("lua object nil")))
+    input))
+
+(def: (without_nil g!temp [nilable? outputT] output)
+  (-> Code Nilable Code Code)
+  (if nilable?
+    (` (let [(~ g!temp) (~ output)]
+         (if ("lua object nil?" (~ g!temp))
+           #.None
+           (#.Some (~ g!temp)))))
+    (` (let [(~ g!temp) (~ output)]
+         (if (not ("lua object nil?" (~ g!temp)))
+           (~ g!temp)
+           (.error! "Nil is an invalid value!"))))))
+
+(type: Import
+  (#Class [Text (List Member)])
+  (#Function Static_Method)
+  (#Constant Field))
+
+(def: import
+  ($_ <>.or
+      ($_ <>.and
+          .local_identifier
+          (<>.some member))
+      (.form ..common_method)
+      ..constant
+      ))
+
+(syntax: #export (try expression)
+  {#.doc (doc (case (try (risky_computation input))
+                (#.Right success)
+                (do_something success)
+
+                (#.Left error)
+                (recover_from_failure error)))}
+  (wrap (list (` ("lux try" ((~! io.io) (~ expression)))))))
+
+(def: (with_io with? without)
+  (-> Bit Code Code)
+  (if with?
+    (` (io.io (~ without)))
+    without))
+
+(def: (io_type io? rawT)
+  (-> Bit Code Code)
+  (if io?
+    (` (io.IO (~ rawT)))
+    rawT))
+
+(def: (with_try with? without_try)
+  (-> Bit Code Code)
+  (if with?
+    (` (..try (~ without_try)))
+    without_try))
+
+(def: (try_type try? rawT)
+  (-> Bit Code Code)
+  (if try?
+    (` (.Either .Text (~ rawT)))
+    rawT))
+
+(def: (make_function g!method g!temp source inputsT io? try? outputT)
+  (-> Code Code Code (List Nilable) Bit Bit Nilable Code)
+  (let [g!inputs (input_variables inputsT)]
+    (` (def: ((~ g!method)
+              [(~+ (list\map product.right g!inputs))])
+         (-> [(~+ (list\map nilable_type inputsT))]
+             (~ (|> (nilable_type outputT)
+                    (try_type try?)
+                    (io_type io?))))
+         (:assume
+          (~ (<| (with_io io?)
+                 (with_try try?)
+                 (without_nil g!temp outputT)
+                 (` ("lua apply"
+                     (:coerce ..Function (~ source))
+                     (~+ (list\map (with_nil g!temp) g!inputs)))))))))))
+
+(syntax: #export (import: {import ..import})
+  (with_gensyms [g!temp]
+    (case import
+      (#Class [class members])
+      (with_gensyms [g!object]
+        (let [qualify (: (-> Text Code)
+                         (|>> (format class "::") code.local_identifier))
+              g!type (code.local_identifier class)
+              real_class (text.replace_all "/" "." class)
+              imported (case (text.split_all_with "/" class)
+                         (#.Cons head tail)
+                         (list\fold (function (_ sub super)
+                                      (` ("lua object get" (~ (code.text sub))
+                                          (:coerce (..Object .Any) (~ super)))))
+                                    (` ("lua import" (~ (code.text head))))
+                                    tail)
+                         
+                         #.Nil
+                         (` ("lua import" (~ (code.text class)))))]
+          (wrap (list& (` (type: (~ g!type)
+                            (..Object (primitive (~ (code.text real_class))))))
+                       (list\map (function (_ member)
+                                   (case member
+                                     (#Field [static? field fieldT])
+                                     (if static?
+                                       (` ((~! syntax:) ((~ (qualify field)))
+                                           (\ (~! meta.monad) (~' wrap)
+                                              (list (` (.:coerce (~ (nilable_type fieldT))
+                                                                 ("lua object get" (~ (code.text field))
+                                                                  (:coerce (..Object .Any) (~ imported)))))))))
+                                       (` (def: ((~ (qualify field))
+                                                 (~ g!object))
+                                            (-> (~ g!type)
+                                                (~ (nilable_type fieldT)))
+                                            (:assume
+                                             (~ (without_nil g!temp fieldT (` ("lua object get" (~ (code.text field))
+                                                                               (:coerce (..Object .Any) (~ g!object))))))))))
+                                     
+                                     (#Method method)
+                                     (case method
+                                       (#Static [method alias inputsT io? try? outputT])
+                                       (..make_function (qualify (maybe.default method alias))
+                                                        g!temp
+                                                        (` ("lua object get" (~ (code.text method))
+                                                            (:coerce (..Object .Any) (~ imported))))
+                                                        inputsT
+                                                        io?
+                                                        try?
+                                                        outputT)
+                                       
+                                       (#Virtual [method alias inputsT io? try? outputT])
+                                       (let [g!inputs (input_variables inputsT)]
+                                         (` (def: ((~ (qualify (maybe.default method alias)))
+                                                   [(~+ (list\map product.right g!inputs))]
+                                                   (~ g!object))
+                                              (-> [(~+ (list\map nilable_type inputsT))]
+                                                  (~ g!type)
+                                                  (~ (|> (nilable_type outputT)
+                                                         (try_type try?)
+                                                         (io_type io?))))
+                                              (:assume
+                                               (~ (<| (with_io io?)
+                                                      (with_try try?)
+                                                      (without_nil g!temp outputT)
+                                                      (` ("lua object do"
+                                                          (~ (code.text method))
+                                                          (~ g!object)
+                                                          (~+ (list\map (with_nil g!temp) g!inputs)))))))))))))
+                                 members)))))
+      
+      (#Function [name alias inputsT io? try? outputT])
+      (wrap (list (..make_function (code.local_identifier (maybe.default name alias))
+                                   g!temp
+                                   (` ("lua constant" (~ (code.text (text.replace_all "/" "." name)))))
+                                   inputsT
+                                   io?
+                                   try?
+                                   outputT)))
+
+      (#Constant [_ name fieldT])
+      (wrap (list (` ((~! syntax:) ((~ (code.local_identifier name)))
+                      (\ (~! meta.monad) (~' wrap)
+                         (list (` (.:coerce (~ (nilable_type fieldT))
+                                            ("lua constant" (~ (code.text (text.replace_all "/" "." name))))))))))))
+      )))
+
+(template: #export (closure  )
+  (.:coerce ..Function
+            (`` ("lua function"
+                 (~~ (template.count ))
+                 (.function (_ [])
+                   )))))
diff --git a/stdlib/source/lux/ffi.old.lux b/stdlib/source/lux/ffi.old.lux
new file mode 100644
index 000000000..3a69f2464
--- /dev/null
+++ b/stdlib/source/lux/ffi.old.lux
@@ -0,0 +1,1835 @@
+(.module:
+  [lux (#- type)
+   ["." type ("#\." equivalence)]
+   [abstract
+    ["." monad (#+ Monad do)]
+    ["." enum]]
+   [control
+    ["." function]
+    ["." io]
+    ["." try (#+ Try)]
+    ["p" parser
+     ["s" code (#+ Parser)]]]
+   [data
+    ["." maybe]
+    ["." product]
+    ["." bit ("#\." codec)]
+    ["." text ("#\." equivalence monoid)
+     ["%" format (#+ format)]]
+    [collection
+     ["." array (#+ Array)]
+     ["." list ("#\." monad fold monoid)]]]
+   [macro (#+ with_gensyms)
+    [syntax (#+ syntax:)]
+    ["." code]]
+   ["." meta
+    ["." annotation]]])
+
+(template [   ]
+  [(def: #export ( value)
+     {#.doc (doc "Type converter."
+                 (: 
+                    ( (:  foo))))}
+     (-> (primitive ) (primitive ))
+     ( value))]
+
+  [byte_to_long "jvm convert byte-to-long" "java.lang.Byte"      "java.lang.Long"]
+
+  [short_to_long "jvm convert short-to-long" "java.lang.Short"     "java.lang.Long"]
+  
+  [double_to_int "jvm convert double-to-int" "java.lang.Double"    "java.lang.Integer"]
+  [double_to_long "jvm convert double-to-long" "java.lang.Double"    "java.lang.Long"]
+  [double_to_float "jvm convert double-to-float" "java.lang.Double"    "java.lang.Float"]
+
+  [float_to_int "jvm convert float-to-int" "java.lang.Float"     "java.lang.Integer"]
+  [float_to_long "jvm convert float-to-long" "java.lang.Float"     "java.lang.Long"]
+  [float_to_double "jvm convert float-to-double" "java.lang.Float"     "java.lang.Double"]
+  
+  [int_to_byte "jvm convert int-to-byte" "java.lang.Integer"   "java.lang.Byte"]
+  [int_to_short "jvm convert int-to-short" "java.lang.Integer"   "java.lang.Short"]
+  [int_to_long "jvm convert int-to-long" "java.lang.Integer"   "java.lang.Long"]
+  [int_to_float "jvm convert int-to-float" "java.lang.Integer"   "java.lang.Float"]
+  [int_to_double "jvm convert int-to-double" "java.lang.Integer"   "java.lang.Double"]
+  [int_to_char "jvm convert int-to-char" "java.lang.Integer"   "java.lang.Character"]
+
+  [long_to_byte "jvm convert long-to-byte" "java.lang.Long"      "java.lang.Byte"]
+  [long_to_short "jvm convert long-to-short" "java.lang.Long"      "java.lang.Short"]
+  [long_to_int "jvm convert long-to-int" "java.lang.Long"      "java.lang.Integer"]
+  [long_to_float "jvm convert long-to-float" "java.lang.Long"      "java.lang.Float"]
+  [long_to_double "jvm convert long-to-double" "java.lang.Long"      "java.lang.Double"]
+
+  [char_to_byte "jvm convert char-to-byte" "java.lang.Character" "java.lang.Byte"]
+  [char_to_short "jvm convert char-to-short" "java.lang.Character" "java.lang.Short"]
+  [char_to_int "jvm convert char-to-int" "java.lang.Character" "java.lang.Integer"]
+  [char_to_long "jvm convert char-to-long" "java.lang.Character" "java.lang.Long"]
+  )
+
+## [Utils]
+(def: constructor_method_name "")
+(def: member_separator "::")
+
+## Types
+(type: JVM_Code Text)
+
+(type: BoundKind
+  #UpperBound
+  #LowerBound)
+
+(type: #rec GenericType
+  (#GenericTypeVar Text)
+  (#GenericClass [Text (List GenericType)])
+  (#GenericArray GenericType)
+  (#GenericWildcard (Maybe [BoundKind GenericType])))
+
+(type: Type_Parameter
+  [Text (List GenericType)])
+
+(type: Primitive_Mode
+  #ManualPrM
+  #AutoPrM)
+
+(type: PrivacyModifier
+  #PublicPM
+  #PrivatePM
+  #ProtectedPM
+  #DefaultPM)
+
+(type: StateModifier
+  #VolatileSM
+  #FinalSM
+  #DefaultSM)
+
+(type: InheritanceModifier
+  #FinalIM
+  #AbstractIM
+  #DefaultIM)
+
+(type: Class_Kind
+  #Class
+  #Interface)
+
+(type: Class_Declaration
+  {#class_name   Text
+   #class_params (List Type_Parameter)})
+
+(type: StackFrame (primitive "java/lang/StackTraceElement"))
+(type: StackTrace (Array StackFrame))
+
+(type: Super_Class_Decl
+  {#super_class_name   Text
+   #super_class_params (List GenericType)})
+
+(type: AnnotationParam
+  [Text Code])
+
+(type: Annotation
+  {#ann_name   Text
+   #ann_params (List AnnotationParam)})
+
+(type: Member_Declaration
+  {#member_name Text
+   #member_privacy PrivacyModifier
+   #member_anns (List Annotation)})
+
+(type: FieldDecl
+  (#ConstantField GenericType Code)
+  (#VariableField StateModifier GenericType))
+
+(type: MethodDecl
+  {#method_tvars  (List Type_Parameter)
+   #method_inputs (List GenericType)
+   #method_output GenericType
+   #method_exs    (List GenericType)})
+
+(type: ArgDecl
+  {#arg_name Text
+   #arg_type GenericType})
+
+(type: ConstructorArg
+  [GenericType Code])
+
+(type: Method_Definition
+  (#ConstructorMethod [Bit
+                       (List Type_Parameter)
+                       (List ArgDecl)
+                       (List ConstructorArg)
+                       Code
+                       (List GenericType)])
+  (#VirtualMethod [Bit
+                   Bit
+                   (List Type_Parameter)
+                   Text
+                   (List ArgDecl)
+                   GenericType
+                   Code
+                   (List GenericType)])
+  (#OverridenMethod [Bit
+                     Class_Declaration
+                     (List Type_Parameter)
+                     Text
+                     (List ArgDecl)
+                     GenericType
+                     Code
+                     (List GenericType)])
+  (#StaticMethod [Bit
+                  (List Type_Parameter)
+                  (List ArgDecl)
+                  GenericType
+                  Code
+                  (List GenericType)])
+  (#AbstractMethod [(List Type_Parameter)
+                    (List ArgDecl)
+                    GenericType
+                    (List GenericType)])
+  (#NativeMethod [(List Type_Parameter)
+                  (List ArgDecl)
+                  GenericType
+                  (List GenericType)]))
+
+(type: Partial_Call
+  {#pc_method Name
+   #pc_args   (List Code)})
+
+(type: ImportMethodKind
+  #StaticIMK
+  #VirtualIMK)
+
+(type: ImportMethodCommons
+  {#import_member_mode   Primitive_Mode
+   #import_member_alias  Text
+   #import_member_kind   ImportMethodKind
+   #import_member_tvars  (List Type_Parameter)
+   #import_member_args   (List [Bit GenericType])
+   #import_member_maybe? Bit
+   #import_member_try?   Bit
+   #import_member_io?    Bit})
+
+(type: ImportConstructorDecl
+  {})
+
+(type: ImportMethodDecl
+  {#import_method_name    Text
+   #import_method_return  GenericType})
+
+(type: ImportFieldDecl
+  {#import_field_mode    Primitive_Mode
+   #import_field_name    Text
+   #import_field_static? Bit
+   #import_field_maybe?  Bit
+   #import_field_setter? Bit
+   #import_field_type    GenericType})
+
+(type: Import_Member_Declaration
+  (#EnumDecl        (List Text))
+  (#ConstructorDecl [ImportMethodCommons ImportConstructorDecl])
+  (#MethodDecl      [ImportMethodCommons ImportMethodDecl])
+  (#FieldAccessDecl ImportFieldDecl))
+
+## Utils
+(def: (manual_primitive_to_type class)
+  (-> Text (Maybe Code))
+  (case class
+    (^template [ ]
+      [
+       (#.Some (' ))])
+    (["boolean" (primitive "java.lang.Boolean")]
+     ["byte"    (primitive "java.lang.Byte")]
+     ["short"   (primitive "java.lang.Short")]
+     ["int"     (primitive "java.lang.Integer")]
+     ["long"    (primitive "java.lang.Long")]
+     ["float"   (primitive "java.lang.Float")]
+     ["double"  (primitive "java.lang.Double")]
+     ["char"    (primitive "java.lang.Character")]
+     ["void"    .Any])
+
+    _
+    #.None))
+
+(def: (auto_primitive_to_type class)
+  (-> Text (Maybe Code))
+  (case class
+    (^template [ ]
+      [
+       (#.Some (' ))])
+    (["boolean" .Bit]
+     ["byte"    .Int]
+     ["short"   .Int]
+     ["int"     .Int]
+     ["long"    .Int]
+     ["float"   .Frac]
+     ["double"  .Frac]
+     ["void"    .Any])
+
+    _
+    #.None))
+
+(def: sanitize
+  (-> Text Text)
+  (text.replace_all "/" "."))
+
+(def: (generic_class->type' mode type_params in_array? name+params
+                            class->type')
+  (-> Primitive_Mode (List Type_Parameter) Bit [Text (List GenericType)]
+      (-> Primitive_Mode (List Type_Parameter) Bit GenericType Code)
+      Code)
+  (case [name+params mode in_array?]
+    (^multi [[prim #.Nil] #ManualPrM #0]
+            [(manual_primitive_to_type prim) (#.Some output)])
+    output
+
+    (^multi [[prim #.Nil] #AutoPrM #0]
+            [(auto_primitive_to_type prim) (#.Some output)])
+    output
+    
+    [[name params] _ _]
+    (let [name (sanitize name)
+          =params (list\map (class->type' mode type_params in_array?) params)]
+      (` (primitive (~ (code.text name)) [(~+ =params)])))))
+
+(def: (class->type' mode type_params in_array? class)
+  (-> Primitive_Mode (List Type_Parameter) Bit GenericType Code)
+  (case class
+    (#GenericTypeVar name)
+    (case (list.find (function (_ [pname pbounds])
+                       (and (text\= name pname)
+                            (not (list.empty? pbounds))))
+                     type_params)
+      #.None
+      (code.identifier ["" name])
+
+      (#.Some [pname pbounds])
+      (class->type' mode type_params in_array? (maybe.assume (list.head pbounds))))
+    
+    (#GenericClass name+params)
+    (generic_class->type' mode type_params in_array? name+params
+                          class->type')
+
+    (#GenericArray param)
+    (let [=param (class->type' mode type_params #1 param)]
+      (` ((~! array.Array) (~ =param))))
+
+    (^or (#GenericWildcard #.None) (#GenericWildcard (#.Some [#LowerBound _])))
+    (` .Any)
+
+    (#GenericWildcard (#.Some [#UpperBound upper_bound]))
+    (class->type' mode type_params in_array? upper_bound)
+    ))
+
+(def: (class->type mode type_params class)
+  (-> Primitive_Mode (List Type_Parameter) GenericType Code)
+  (class->type' mode type_params #0 class))
+
+(def: (type_param_type$ [name bounds])
+  (-> Type_Parameter Code)
+  (code.identifier ["" name]))
+
+(def: (class_decl_type$ (^slots [#class_name #class_params]))
+  (-> Class_Declaration Code)
+  (let [=params (list\map (: (-> Type_Parameter Code)
+                             (function (_ [pname pbounds])
+                               (case pbounds
+                                 #.Nil
+                                 (code.identifier ["" pname])
+
+                                 (#.Cons bound1 _)
+                                 (class->type #ManualPrM class_params bound1))))
+                          class_params)]
+    (` (primitive (~ (code.text (sanitize class_name)))
+                  [(~+ =params)]))))
+
+(def: type_var_class Text "java.lang.Object")
+
+(def: (simple_class$ env class)
+  (-> (List Type_Parameter) GenericType Text)
+  (case class
+    (#GenericTypeVar name)
+    (case (list.find (function (_ [pname pbounds])
+                       (and (text\= name pname)
+                            (not (list.empty? pbounds))))
+                     env)
+      #.None
+      type_var_class
+
+      (#.Some [pname pbounds])
+      (simple_class$ env (maybe.assume (list.head pbounds))))
+
+    (^or (#GenericWildcard #.None) (#GenericWildcard (#.Some [#LowerBound _])))
+    type_var_class
+    
+    (#GenericWildcard (#.Some [#UpperBound upper_bound]))
+    (simple_class$ env upper_bound)
+    
+    (#GenericClass name env)
+    (sanitize name)
+
+    (#GenericArray param')
+    (case param'
+      (#GenericArray param)
+      (format "[" (simple_class$ env param))
+      
+      (^template [ ]
+        [(#GenericClass  #.Nil)
+         ])
+      (["boolean" "[Z"]
+       ["byte"    "[B"]
+       ["short"   "[S"]
+       ["int"     "[I"]
+       ["long"    "[J"]
+       ["float"   "[F"]
+       ["double"  "[D"]
+       ["char"    "[C"])
+      
+      param
+      (format "[L" (simple_class$ env param) ";"))
+    ))
+
+(def: (make_get_const_parser class_name field_name)
+  (-> Text Text (Parser Code))
+  (do p.monad
+    [#let [dotted_name (format "::" field_name)]
+     _ (s.this! (code.identifier ["" dotted_name]))]
+    (wrap (`' ((~ (code.text (format "jvm getstatic" ":" class_name ":" field_name))))))))
+
+(def: (make_get_var_parser class_name field_name)
+  (-> Text Text (Parser Code))
+  (do p.monad
+    [#let [dotted_name (format "::" field_name)]
+     _ (s.this! (code.identifier ["" dotted_name]))]
+    (wrap (`' ((~ (code.text (format "jvm getfield" ":" class_name ":" field_name))) _jvm_this)))))
+
+(def: (make_put_var_parser class_name field_name)
+  (-> Text Text (Parser Code))
+  (do p.monad
+    [#let [dotted_name (format "::" field_name)]
+     [_ _ value] (: (Parser [Any Any Code])
+                    (s.form ($_ p.and (s.this! (' :=)) (s.this! (code.identifier ["" dotted_name])) s.any)))]
+    (wrap (`' ((~ (code.text (format "jvm putfield" ":" class_name ":" field_name))) _jvm_this (~ value))))))
+
+(def: (pre_walk_replace f input)
+  (-> (-> Code Code) Code Code)
+  (case (f input)
+    (^template []
+      [[meta ( parts)]
+       [meta ( (list\map (pre_walk_replace f) parts))]])
+    ([#.Form]
+     [#.Tuple])
+    
+    [meta (#.Record pairs)]
+    [meta (#.Record (list\map (: (-> [Code Code] [Code Code])
+                                 (function (_ [key val])
+                                   [(pre_walk_replace f key) (pre_walk_replace f val)]))
+                              pairs))]
+    
+    ast'
+    ast'))
+
+(def: (parser->replacer p ast)
+  (-> (Parser Code) (-> Code Code))
+  (case (p.run p (list ast))
+    (#.Right [#.Nil ast'])
+    ast'
+
+    _
+    ast
+    ))
+
+(def: (field->parser class_name [[field_name _ _] field])
+  (-> Text [Member_Declaration FieldDecl] (Parser Code))
+  (case field
+    (#ConstantField _)
+    (make_get_const_parser class_name field_name)
+    
+    (#VariableField _)
+    (p.either (make_get_var_parser class_name field_name)
+              (make_put_var_parser class_name field_name))))
+
+(def: (make_constructor_parser params class_name arg_decls)
+  (-> (List Type_Parameter) Text (List ArgDecl) (Parser Code))
+  (do p.monad
+    [args (: (Parser (List Code))
+             (s.form (p.after (s.this! (' ::new!))
+                              (s.tuple (p.exactly (list.size arg_decls) s.any)))))
+     #let [arg_decls' (: (List Text) (list\map (|>> product.right (simple_class$ params)) arg_decls))]]
+    (wrap (` ((~ (code.text (format "jvm new" ":" class_name ":" (text.join_with "," arg_decls'))))
+              (~+ args))))))
+
+(def: (make_static_method_parser params class_name method_name arg_decls)
+  (-> (List Type_Parameter) Text Text (List ArgDecl) (Parser Code))
+  (do p.monad
+    [#let [dotted_name (format "::" method_name "!")]
+     args (: (Parser (List Code))
+             (s.form (p.after (s.this! (code.identifier ["" dotted_name]))
+                              (s.tuple (p.exactly (list.size arg_decls) s.any)))))
+     #let [arg_decls' (: (List Text) (list\map (|>> product.right (simple_class$ params)) arg_decls))]]
+    (wrap (`' ((~ (code.text (format "jvm invokestatic" ":" class_name ":" method_name ":" (text.join_with "," arg_decls'))))
+               (~+ args))))))
+
+(template [ ]
+  [(def: ( params class_name method_name arg_decls)
+     (-> (List Type_Parameter) Text Text (List ArgDecl) (Parser Code))
+     (do p.monad
+       [#let [dotted_name (format "::" method_name "!")]
+        args (: (Parser (List Code))
+                (s.form (p.after (s.this! (code.identifier ["" dotted_name]))
+                                 (s.tuple (p.exactly (list.size arg_decls) s.any)))))
+        #let [arg_decls' (: (List Text) (list\map (|>> product.right (simple_class$ params)) arg_decls))]]
+       (wrap (`' ((~ (code.text (format  ":" class_name ":" method_name ":" (text.join_with "," arg_decls'))))
+                  (~' _jvm_this) (~+ args))))))]
+
+  [make_special_method_parser "jvm invokespecial"]
+  [make_virtual_method_parser "jvm invokevirtual"]
+  )
+
+(def: (method->parser params class_name [[method_name _ _] meth_def])
+  (-> (List Type_Parameter) Text [Member_Declaration Method_Definition] (Parser Code))
+  (case meth_def
+    (#ConstructorMethod strict? type_vars args constructor_args return_expr exs)
+    (make_constructor_parser params class_name args)
+    
+    (#StaticMethod strict? type_vars args return_type return_expr exs)
+    (make_static_method_parser params class_name method_name args)
+    
+    (^or (#VirtualMethod final? strict? type_vars self_name args return_type return_expr exs)
+         (#OverridenMethod strict? owner_class type_vars self_name args return_type return_expr exs))
+    (make_special_method_parser params class_name method_name args)
+
+    (#AbstractMethod type_vars args return_type exs)
+    (make_virtual_method_parser params class_name method_name args)
+
+    (#NativeMethod type_vars args return_type exs)
+    (make_virtual_method_parser params class_name method_name args)))
+
+## Parsers
+(def: privacy_modifier^
+  (Parser PrivacyModifier)
+  (let [(^open ".") p.monad]
+    ($_ p.or
+        (s.this! (' #public))
+        (s.this! (' #private))
+        (s.this! (' #protected))
+        (wrap []))))
+
+(def: inheritance_modifier^
+  (Parser InheritanceModifier)
+  (let [(^open ".") p.monad]
+    ($_ p.or
+        (s.this! (' #final))
+        (s.this! (' #abstract))
+        (wrap []))))
+
+(def: bound_kind^
+  (Parser BoundKind)
+  (p.or (s.this! (' <))
+        (s.this! (' >))))
+
+(def: (assert_no_periods name)
+  (-> Text (Parser Any))
+  (p.assert "Names in class declarations cannot contain periods."
+            (not (text.contains? "." name))))
+
+(def: (generic_type^ type_vars)
+  (-> (List Type_Parameter) (Parser GenericType))
+  (p.rec
+   (function (_ recur^)
+     ($_ p.either
+         (do p.monad
+           [_ (s.this! (' ?))]
+           (wrap (#GenericWildcard #.None)))
+         (s.tuple (do p.monad
+                    [_ (s.this! (' ?))
+                     bound_kind bound_kind^
+                     bound recur^]
+                    (wrap (#GenericWildcard (#.Some [bound_kind bound])))))
+         (do p.monad
+           [name s.local_identifier
+            _ (assert_no_periods name)]
+           (if (list.member? text.equivalence (list\map product.left type_vars) name)
+             (wrap (#GenericTypeVar name))
+             (wrap (#GenericClass name (list)))))
+         (s.tuple (do p.monad
+                    [component recur^]
+                    (case component
+                      (^template [ ]
+                        [(#GenericClass  #.Nil)
+                         (wrap (#GenericClass  (list)))])
+                      (["[Z" "boolean"]
+                       ["[B" "byte"]
+                       ["[S" "short"]
+                       ["[I" "int"]
+                       ["[J" "long"]
+                       ["[F" "float"]
+                       ["[D" "double"]
+                       ["[C" "char"])
+
+                      _
+                      (wrap (#GenericArray component)))))
+         (s.form (do p.monad
+                   [name s.local_identifier
+                    _ (assert_no_periods name)
+                    params (p.some recur^)
+                    _ (p.assert (format name " cannot be a type-parameter!")
+                                (not (list.member? text.equivalence (list\map product.left type_vars) name)))]
+                   (wrap (#GenericClass name params))))
+         ))))
+
+(def: type_param^
+  (Parser Type_Parameter)
+  (p.either (do p.monad
+              [param_name s.local_identifier]
+              (wrap [param_name (list)]))
+            (s.tuple (do p.monad
+                       [param_name s.local_identifier
+                        _ (s.this! (' <))
+                        bounds (p.many (..generic_type^ (list)))]
+                       (wrap [param_name bounds])))))
+
+(def: type_params^
+  (Parser (List Type_Parameter))
+  (|> ..type_param^
+      p.some
+      s.tuple
+      (p.default (list))))
+
+(def: class_decl^
+  (Parser Class_Declaration)
+  (p.either (do p.monad
+              [name s.local_identifier
+               _ (assert_no_periods name)]
+              (wrap [name (list)]))
+            (s.form (do p.monad
+                      [name s.local_identifier
+                       _ (assert_no_periods name)
+                       params (p.some ..type_param^)]
+                      (wrap [name params])))
+            ))
+
+(def: (super_class_decl^ type_vars)
+  (-> (List Type_Parameter) (Parser Super_Class_Decl))
+  (p.either (do p.monad
+              [name s.local_identifier
+               _ (assert_no_periods name)]
+              (wrap [name (list)]))
+            (s.form (do p.monad
+                      [name s.local_identifier
+                       _ (assert_no_periods name)
+                       params (p.some (..generic_type^ type_vars))]
+                      (wrap [name params])))))
+
+(def: annotation_params^
+  (Parser (List AnnotationParam))
+  (s.record (p.some (p.and s.local_tag s.any))))
+
+(def: annotation^
+  (Parser Annotation)
+  (p.either (do p.monad
+              [ann_name s.local_identifier]
+              (wrap [ann_name (list)]))
+            (s.form (p.and s.local_identifier
+                           annotation_params^))))
+
+(def: annotations^'
+  (Parser (List Annotation))
+  (do p.monad
+    [_ (s.this! (' #ann))]
+    (s.tuple (p.some ..annotation^))))
+
+(def: annotations^
+  (Parser (List Annotation))
+  (do p.monad
+    [anns?? (p.maybe ..annotations^')]
+    (wrap (maybe.default (list) anns??))))
+
+(def: (throws_decl'^ type_vars)
+  (-> (List Type_Parameter) (Parser (List GenericType)))
+  (do p.monad
+    [_ (s.this! (' #throws))]
+    (s.tuple (p.some (..generic_type^ type_vars)))))
+
+(def: (throws_decl^ type_vars)
+  (-> (List Type_Parameter) (Parser (List GenericType)))
+  (do p.monad
+    [exs? (p.maybe (throws_decl'^ type_vars))]
+    (wrap (maybe.default (list) exs?))))
+
+(def: (method_decl^ type_vars)
+  (-> (List Type_Parameter) (Parser [Member_Declaration MethodDecl]))
+  (s.form (do p.monad
+            [tvars ..type_params^
+             name s.local_identifier
+             anns ..annotations^
+             inputs (s.tuple (p.some (..generic_type^ type_vars)))
+             output (..generic_type^ type_vars)
+             exs (..throws_decl^ type_vars)]
+            (wrap [[name #PublicPM anns] {#method_tvars tvars
+                                          #method_inputs inputs
+                                          #method_output output
+                                          #method_exs    exs}]))))
+
+(def: state_modifier^
+  (Parser StateModifier)
+  ($_ p.or
+      (s.this! (' #volatile))
+      (s.this! (' #final))
+      (\ p.monad wrap [])))
+
+(def: (field_decl^ type_vars)
+  (-> (List Type_Parameter) (Parser [Member_Declaration FieldDecl]))
+  (p.either (s.form (do p.monad
+                      [_ (s.this! (' #const))
+                       name s.local_identifier
+                       anns ..annotations^
+                       type (..generic_type^ type_vars)
+                       body s.any]
+                      (wrap [[name #PublicPM anns] (#ConstantField [type body])])))
+            (s.form (do p.monad
+                      [pm privacy_modifier^
+                       sm state_modifier^
+                       name s.local_identifier
+                       anns ..annotations^
+                       type (..generic_type^ type_vars)]
+                      (wrap [[name pm anns] (#VariableField [sm type])])))))
+
+(def: (arg_decl^ type_vars)
+  (-> (List Type_Parameter) (Parser ArgDecl))
+  (s.record (p.and s.local_identifier
+                   (..generic_type^ type_vars))))
+
+(def: (arg_decls^ type_vars)
+  (-> (List Type_Parameter) (Parser (List ArgDecl)))
+  (p.some (arg_decl^ type_vars)))
+
+(def: (constructor_arg^ type_vars)
+  (-> (List Type_Parameter) (Parser ConstructorArg))
+  (s.record (p.and (..generic_type^ type_vars) s.any)))
+
+(def: (constructor_args^ type_vars)
+  (-> (List Type_Parameter) (Parser (List ConstructorArg)))
+  (s.tuple (p.some (constructor_arg^ type_vars))))
+
+(def: (constructor_method^ class_vars)
+  (-> (List Type_Parameter) (Parser [Member_Declaration Method_Definition]))
+  (s.form (do p.monad
+            [pm privacy_modifier^
+             strict_fp? (p.parses? (s.this! (' #strict)))
+             method_vars ..type_params^
+             #let [total_vars (list\compose class_vars method_vars)]
+             [_ arg_decls] (s.form (p.and (s.this! (' new))
+                                          (..arg_decls^ total_vars)))
+             constructor_args (..constructor_args^ total_vars)
+             exs (..throws_decl^ total_vars)
+             annotations ..annotations^
+             body s.any]
+            (wrap [{#member_name constructor_method_name
+                    #member_privacy pm
+                    #member_anns annotations}
+                   (#ConstructorMethod strict_fp? method_vars arg_decls constructor_args body exs)]))))
+
+(def: (virtual_method_def^ class_vars)
+  (-> (List Type_Parameter) (Parser [Member_Declaration Method_Definition]))
+  (s.form (do p.monad
+            [pm privacy_modifier^
+             strict_fp? (p.parses? (s.this! (' #strict)))
+             final? (p.parses? (s.this! (' #final)))
+             method_vars ..type_params^
+             #let [total_vars (list\compose class_vars method_vars)]
+             [name this_name arg_decls] (s.form ($_ p.and
+                                                    s.local_identifier
+                                                    s.local_identifier
+                                                    (..arg_decls^ total_vars)))
+             return_type (..generic_type^ total_vars)
+             exs (..throws_decl^ total_vars)
+             annotations ..annotations^
+             body s.any]
+            (wrap [{#member_name name
+                    #member_privacy pm
+                    #member_anns annotations}
+                   (#VirtualMethod final? strict_fp?
+                                   method_vars
+                                   this_name arg_decls return_type
+                                   body exs)]))))
+
+(def: overriden_method_def^
+  (Parser [Member_Declaration Method_Definition])
+  (s.form (do p.monad
+            [strict_fp? (p.parses? (s.this! (' #strict)))
+             owner_class ..class_decl^
+             method_vars ..type_params^
+             #let [total_vars (list\compose (product.right owner_class) method_vars)]
+             [name this_name arg_decls] (s.form ($_ p.and
+                                                    s.local_identifier
+                                                    s.local_identifier
+                                                    (..arg_decls^ total_vars)))
+             return_type (..generic_type^ total_vars)
+             exs (..throws_decl^ total_vars)
+             annotations ..annotations^
+             body s.any]
+            (wrap [{#member_name name
+                    #member_privacy #PublicPM
+                    #member_anns annotations}
+                   (#OverridenMethod strict_fp?
+                                     owner_class method_vars
+                                     this_name arg_decls return_type
+                                     body exs)]))))
+
+(def: static_method_def^
+  (Parser [Member_Declaration Method_Definition])
+  (s.form (do p.monad
+            [pm privacy_modifier^
+             strict_fp? (p.parses? (s.this! (' #strict)))
+             _ (s.this! (' #static))
+             method_vars ..type_params^
+             #let [total_vars method_vars]
+             [name arg_decls] (s.form (p.and s.local_identifier
+                                             (..arg_decls^ total_vars)))
+             return_type (..generic_type^ total_vars)
+             exs (..throws_decl^ total_vars)
+             annotations ..annotations^
+             body s.any]
+            (wrap [{#member_name name
+                    #member_privacy pm
+                    #member_anns annotations}
+                   (#StaticMethod strict_fp? method_vars arg_decls return_type body exs)]))))
+
+(def: abstract_method_def^
+  (Parser [Member_Declaration Method_Definition])
+  (s.form (do p.monad
+            [pm privacy_modifier^
+             _ (s.this! (' #abstract))
+             method_vars ..type_params^
+             #let [total_vars method_vars]
+             [name arg_decls] (s.form (p.and s.local_identifier
+                                             (..arg_decls^ total_vars)))
+             return_type (..generic_type^ total_vars)
+             exs (..throws_decl^ total_vars)
+             annotations ..annotations^]
+            (wrap [{#member_name name
+                    #member_privacy pm
+                    #member_anns annotations}
+                   (#AbstractMethod method_vars arg_decls return_type exs)]))))
+
+(def: native_method_def^
+  (Parser [Member_Declaration Method_Definition])
+  (s.form (do p.monad
+            [pm privacy_modifier^
+             _ (s.this! (' #native))
+             method_vars ..type_params^
+             #let [total_vars method_vars]
+             [name arg_decls] (s.form (p.and s.local_identifier
+                                             (..arg_decls^ total_vars)))
+             return_type (..generic_type^ total_vars)
+             exs (..throws_decl^ total_vars)
+             annotations ..annotations^]
+            (wrap [{#member_name name
+                    #member_privacy pm
+                    #member_anns annotations}
+                   (#NativeMethod method_vars arg_decls return_type exs)]))))
+
+(def: (method_def^ class_vars)
+  (-> (List Type_Parameter) (Parser [Member_Declaration Method_Definition]))
+  ($_ p.either
+      (..constructor_method^ class_vars)
+      (..virtual_method_def^ class_vars)
+      ..overriden_method_def^
+      ..static_method_def^
+      ..abstract_method_def^
+      ..native_method_def^))
+
+(def: partial_call^
+  (Parser Partial_Call)
+  (s.form (p.and s.identifier (p.some s.any))))
+
+(def: class_kind^
+  (Parser Class_Kind)
+  (p.either (do p.monad
+              [_ (s.this! (' #class))]
+              (wrap #Class))
+            (do p.monad
+              [_ (s.this! (' #interface))]
+              (wrap #Interface))
+            ))
+
+(def: import_member_alias^
+  (Parser (Maybe Text))
+  (p.maybe (do p.monad
+             [_ (s.this! (' #as))]
+             s.local_identifier)))
+
+(def: (import_member_args^ type_vars)
+  (-> (List Type_Parameter) (Parser (List [Bit GenericType])))
+  (s.tuple (p.some (p.and (p.parses? (s.this! (' #?))) (..generic_type^ type_vars)))))
+
+(def: import_member_return_flags^
+  (Parser [Bit Bit Bit])
+  ($_ p.and (p.parses? (s.this! (' #io))) (p.parses? (s.this! (' #try))) (p.parses? (s.this! (' #?)))))
+
+(def: primitive_mode^
+  (Parser Primitive_Mode)
+  (p.or (s.this! (' #manual))
+        (s.this! (' #auto))))
+
+(def: (import_member_decl^ owner_vars)
+  (-> (List Type_Parameter) (Parser Import_Member_Declaration))
+  ($_ p.either
+      (s.form (do p.monad
+                [_ (s.this! (' #enum))
+                 enum_members (p.some s.local_identifier)]
+                (wrap (#EnumDecl enum_members))))
+      (s.form (do p.monad
+                [tvars ..type_params^
+                 _ (s.this! (' new))
+                 ?alias import_member_alias^
+                 #let [total_vars (list\compose owner_vars tvars)]
+                 ?prim_mode (p.maybe primitive_mode^)
+                 args (..import_member_args^ total_vars)
+                 [io? try? maybe?] import_member_return_flags^]
+                (wrap (#ConstructorDecl [{#import_member_mode    (maybe.default #AutoPrM ?prim_mode)
+                                          #import_member_alias   (maybe.default "new" ?alias)
+                                          #import_member_kind    #VirtualIMK
+                                          #import_member_tvars   tvars
+                                          #import_member_args    args
+                                          #import_member_maybe?  maybe?
+                                          #import_member_try?    try?
+                                          #import_member_io?     io?}
+                                         {}]))
+                ))
+      (s.form (do p.monad
+                [kind (: (Parser ImportMethodKind)
+                         (p.or (s.this! (' #static))
+                               (wrap [])))
+                 tvars ..type_params^
+                 name s.local_identifier
+                 ?alias import_member_alias^
+                 #let [total_vars (list\compose owner_vars tvars)]
+                 ?prim_mode (p.maybe primitive_mode^)
+                 args (..import_member_args^ total_vars)
+                 [io? try? maybe?] import_member_return_flags^
+                 return (..generic_type^ total_vars)]
+                (wrap (#MethodDecl [{#import_member_mode    (maybe.default #AutoPrM ?prim_mode)
+                                     #import_member_alias   (maybe.default name ?alias)
+                                     #import_member_kind    kind
+                                     #import_member_tvars   tvars
+                                     #import_member_args    args
+                                     #import_member_maybe?  maybe?
+                                     #import_member_try?    try?
+                                     #import_member_io?     io?}
+                                    {#import_method_name    name
+                                     #import_method_return  return
+                                     }]))))
+      (s.form (do p.monad
+                [static? (p.parses? (s.this! (' #static)))
+                 name s.local_identifier
+                 ?prim_mode (p.maybe primitive_mode^)
+                 gtype (..generic_type^ owner_vars)
+                 maybe? (p.parses? (s.this! (' #?)))
+                 setter? (p.parses? (s.this! (' #!)))]
+                (wrap (#FieldAccessDecl {#import_field_mode    (maybe.default #AutoPrM ?prim_mode)
+                                         #import_field_name    name
+                                         #import_field_static? static?
+                                         #import_field_maybe?  maybe?
+                                         #import_field_setter? setter?
+                                         #import_field_type    gtype}))))
+      ))
+
+(def: bundle
+  (-> (List Type_Parameter) (Parser [Text (List Import_Member_Declaration)]))
+  (|>> ..import_member_decl^
+       p.some
+       (p.and s.text)
+       s.tuple))
+
+## Generators
+(def: with_parens
+  (-> JVM_Code JVM_Code)
+  (text.enclose ["(" ")"]))
+
+(def: with_brackets
+  (-> JVM_Code JVM_Code)
+  (text.enclose ["[" "]"]))
+
+(def: spaced
+  (-> (List JVM_Code) JVM_Code)
+  (text.join_with " "))
+
+(def: (privacy_modifier$ pm)
+  (-> PrivacyModifier JVM_Code)
+  (case pm
+    #PublicPM    "public"
+    #PrivatePM   "private"
+    #ProtectedPM "protected"
+    #DefaultPM   "default"))
+
+(def: (inheritance_modifier$ im)
+  (-> InheritanceModifier JVM_Code)
+  (case im
+    #FinalIM    "final"
+    #AbstractIM "abstract"
+    #DefaultIM  "default"))
+
+(def: (annotation_param$ [name value])
+  (-> AnnotationParam JVM_Code)
+  (format name "=" (code.format value)))
+
+(def: (annotation$ [name params])
+  (-> Annotation JVM_Code)
+  (format "(" name " " "{" (text.join_with text.tab (list\map annotation_param$ params)) "}" ")"))
+
+(def: (bound_kind$ kind)
+  (-> BoundKind JVM_Code)
+  (case kind
+    #UpperBound "<"
+    #LowerBound ">"))
+
+(def: (generic_type$ gtype)
+  (-> GenericType JVM_Code)
+  (case gtype
+    (#GenericTypeVar name)
+    name
+
+    (#GenericClass name params)
+    (format "(" (sanitize name) " " (spaced (list\map generic_type$ params)) ")")
+    
+    (#GenericArray param)
+    (format "(" array.type_name " " (generic_type$ param) ")")
+    
+    (#GenericWildcard #.None)
+    "?"
+
+    (#GenericWildcard (#.Some [bound_kind bound]))
+    (format (bound_kind$ bound_kind) (generic_type$ bound))))
+
+(def: (type_param$ [name bounds])
+  (-> Type_Parameter JVM_Code)
+  (format "(" name " " (spaced (list\map generic_type$ bounds)) ")"))
+
+(def: (class_decl$ (^open "."))
+  (-> Class_Declaration JVM_Code)
+  (format "(" (sanitize class_name) " " (spaced (list\map type_param$ class_params)) ")"))
+
+(def: (super_class_decl$ (^slots [#super_class_name #super_class_params]))
+  (-> Super_Class_Decl JVM_Code)
+  (format "(" (sanitize super_class_name) " " (spaced (list\map generic_type$ super_class_params)) ")"))
+
+(def: (method_decl$ [[name pm anns] method_decl])
+  (-> [Member_Declaration MethodDecl] JVM_Code)
+  (let [(^slots [#method_tvars #method_inputs #method_output #method_exs]) method_decl]
+    (with_parens
+      (spaced (list name
+                    (with_brackets (spaced (list\map annotation$ anns)))
+                    (with_brackets (spaced (list\map type_param$ method_tvars)))
+                    (with_brackets (spaced (list\map generic_type$ method_exs)))
+                    (with_brackets (spaced (list\map generic_type$ method_inputs)))
+                    (generic_type$ method_output))
+              ))))
+
+(def: (state_modifier$ sm)
+  (-> StateModifier JVM_Code)
+  (case sm
+    #VolatileSM "volatile"
+    #FinalSM    "final"
+    #DefaultSM  "default"))
+
+(def: (field_decl$ [[name pm anns] field])
+  (-> [Member_Declaration FieldDecl] JVM_Code)
+  (case field
+    (#ConstantField class value)
+    (with_parens
+      (spaced (list "constant" name
+                    (with_brackets (spaced (list\map annotation$ anns)))
+                    (generic_type$ class)
+                    (code.format value))
+              ))
+
+    (#VariableField sm class)
+    (with_parens
+      (spaced (list "variable" name
+                    (privacy_modifier$ pm)
+                    (state_modifier$ sm)
+                    (with_brackets (spaced (list\map annotation$ anns)))
+                    (generic_type$ class))
+              ))
+    ))
+
+(def: (arg_decl$ [name type])
+  (-> ArgDecl JVM_Code)
+  (with_parens
+    (spaced (list name (generic_type$ type)))))
+
+(def: (constructor_arg$ [class term])
+  (-> ConstructorArg JVM_Code)
+  (with_brackets
+    (spaced (list (generic_type$ class) (code.format term)))))
+
+(def: (method_def$ replacer super_class [[name pm anns] method_def])
+  (-> (-> Code Code) Super_Class_Decl [Member_Declaration Method_Definition] JVM_Code)
+  (case method_def
+    (#ConstructorMethod strict_fp? type_vars arg_decls constructor_args body exs)
+    (with_parens
+      (spaced (list "init"
+                    (privacy_modifier$ pm)
+                    (bit\encode strict_fp?)
+                    (with_brackets (spaced (list\map annotation$ anns)))
+                    (with_brackets (spaced (list\map type_param$ type_vars)))
+                    (with_brackets (spaced (list\map generic_type$ exs)))
+                    (with_brackets (spaced (list\map arg_decl$ arg_decls)))
+                    (with_brackets (spaced (list\map constructor_arg$ constructor_args)))
+                    (code.format (pre_walk_replace replacer body))
+                    )))
+    
+    (#VirtualMethod final? strict_fp? type_vars this_name arg_decls return_type body exs)
+    (with_parens
+      (spaced (list "virtual"
+                    name
+                    (privacy_modifier$ pm)
+                    (bit\encode final?)
+                    (bit\encode strict_fp?)
+                    (with_brackets (spaced (list\map annotation$ anns)))
+                    (with_brackets (spaced (list\map type_param$ type_vars)))
+                    (with_brackets (spaced (list\map generic_type$ exs)))
+                    (with_brackets (spaced (list\map arg_decl$ arg_decls)))
+                    (generic_type$ return_type)
+                    (code.format (pre_walk_replace replacer (` (let [(~ (code.local_identifier this_name)) (~' _jvm_this)]
+                                                                 (~ body))))))))
+    
+    (#OverridenMethod strict_fp? class_decl type_vars this_name arg_decls return_type body exs)
+    (let [super_replacer (parser->replacer (s.form (do p.monad
+                                                     [_ (s.this! (' ::super!))
+                                                      args (s.tuple (p.exactly (list.size arg_decls) s.any))
+                                                      #let [arg_decls' (: (List Text) (list\map (|>> product.right (simple_class$ (list)))
+                                                                                                arg_decls))]]
+                                                     (wrap (`' ((~ (code.text (format "jvm invokespecial"
+                                                                                      ":" (get@ #super_class_name super_class)
+                                                                                      ":" name
+                                                                                      ":" (text.join_with "," arg_decls'))))
+                                                                (~' _jvm_this) (~+ args)))))))]
+      (with_parens
+        (spaced (list "override"
+                      (class_decl$ class_decl)
+                      name
+                      (bit\encode strict_fp?)
+                      (with_brackets (spaced (list\map annotation$ anns)))
+                      (with_brackets (spaced (list\map type_param$ type_vars)))
+                      (with_brackets (spaced (list\map generic_type$ exs)))
+                      (with_brackets (spaced (list\map arg_decl$ arg_decls)))
+                      (generic_type$ return_type)
+                      (|> (` (let [(~ (code.local_identifier this_name)) (~' _jvm_this)]
+                               (~ body)))
+                          (pre_walk_replace replacer)
+                          (pre_walk_replace super_replacer)
+                          (code.format))
+                      ))))
+
+    (#StaticMethod strict_fp? type_vars arg_decls return_type body exs)
+    (with_parens
+      (spaced (list "static"
+                    name
+                    (privacy_modifier$ pm)
+                    (bit\encode strict_fp?)
+                    (with_brackets (spaced (list\map annotation$ anns)))
+                    (with_brackets (spaced (list\map type_param$ type_vars)))
+                    (with_brackets (spaced (list\map generic_type$ exs)))
+                    (with_brackets (spaced (list\map arg_decl$ arg_decls)))
+                    (generic_type$ return_type)
+                    (code.format (pre_walk_replace replacer body)))))
+
+    (#AbstractMethod type_vars arg_decls return_type exs)
+    (with_parens
+      (spaced (list "abstract"
+                    name
+                    (privacy_modifier$ pm)
+                    (with_brackets (spaced (list\map annotation$ anns)))
+                    (with_brackets (spaced (list\map type_param$ type_vars)))
+                    (with_brackets (spaced (list\map generic_type$ exs)))
+                    (with_brackets (spaced (list\map arg_decl$ arg_decls)))
+                    (generic_type$ return_type))))
+
+    (#NativeMethod type_vars arg_decls return_type exs)
+    (with_parens
+      (spaced (list "native"
+                    name
+                    (privacy_modifier$ pm)
+                    (with_brackets (spaced (list\map annotation$ anns)))
+                    (with_brackets (spaced (list\map type_param$ type_vars)))
+                    (with_brackets (spaced (list\map generic_type$ exs)))
+                    (with_brackets (spaced (list\map arg_decl$ arg_decls)))
+                    (generic_type$ return_type))))
+    ))
+
+(def: (complete_call$ g!obj [method args])
+  (-> Code Partial_Call Code)
+  (` ((~ (code.identifier method)) (~+ args) (~ g!obj))))
+
+## [Syntax]
+(def: object_super_class
+  Super_Class_Decl
+  {#super_class_name   "java/lang/Object"
+   #super_class_params (list)})
+
+(syntax: #export (class:
+                   {im inheritance_modifier^}
+                   {class_decl ..class_decl^}
+                   {#let [full_class_name (product.left class_decl)]}
+                   {#let [class_vars (product.right class_decl)]}
+                   {super (p.default object_super_class
+                                     (..super_class_decl^ class_vars))}
+                   {interfaces (p.default (list)
+                                          (s.tuple (p.some (..super_class_decl^ class_vars))))}
+                   {annotations ..annotations^}
+                   {fields (p.some (..field_decl^ class_vars))}
+                   {methods (p.some (..method_def^ class_vars))})
+  {#.doc (doc "Allows defining JVM classes in Lux code."
+              "For example:"
+              (class: #final (TestClass A) [Runnable]
+                ## Fields
+                (#private foo boolean)
+                (#private bar A)
+                (#private baz java/lang/Object)
+                ## Methods
+                (#public [] (new [value A]) []
+                         (exec (:= ::foo #1)
+                           (:= ::bar value)
+                           (:= ::baz "")
+                           []))
+                (#public (virtual) java/lang/Object
+                         "")
+                (#public #static (static) java/lang/Object
+                         "")
+                (Runnable [] (run) void
+                          [])
+                )
+
+              "The tuple corresponds to parent interfaces."
+              "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed."
+              "Fields and methods defined in the class can be used with special syntax."
+              "For example:"
+              "::resolved, for accessing the 'resolved' field."
+              "(:= ::resolved #1) for modifying it."
+              "(::new! []) for calling the class's constructor."
+              "(::resolve! container [value]) for calling the 'resolve' method."
+              )}
+  (do meta.monad
+    [current_module meta.current_module_name
+     #let [fully_qualified_class_name (format (sanitize current_module) "." full_class_name)
+           field_parsers (list\map (field->parser fully_qualified_class_name) fields)
+           method_parsers (list\map (method->parser (product.right class_decl) fully_qualified_class_name) methods)
+           replacer (parser->replacer (list\fold p.either
+                                                 (p.fail "")
+                                                 (list\compose field_parsers method_parsers)))
+           def_code (format "jvm class:"
+                            (spaced (list (class_decl$ class_decl)
+                                          (super_class_decl$ super)
+                                          (with_brackets (spaced (list\map super_class_decl$ interfaces)))
+                                          (inheritance_modifier$ im)
+                                          (with_brackets (spaced (list\map annotation$ annotations)))
+                                          (with_brackets (spaced (list\map field_decl$ fields)))
+                                          (with_brackets (spaced (list\map (method_def$ replacer super) methods))))))]]
+    (wrap (list (` ((~ (code.text def_code))))))))
+
+(syntax: #export (interface:
+                   {class_decl ..class_decl^}
+                   {#let [class_vars (product.right class_decl)]}
+                   {supers (p.default (list)
+                                      (s.tuple (p.some (..super_class_decl^ class_vars))))}
+                   {annotations ..annotations^}
+                   {members (p.some (..method_decl^ class_vars))})
+  {#.doc (doc "Allows defining JVM interfaces."
+              (interface: TestInterface
+                ([] foo [boolean String] void #throws [Exception])))}
+  (let [def_code (format "jvm interface:"
+                         (spaced (list (class_decl$ class_decl)
+                                       (with_brackets (spaced (list\map super_class_decl$ supers)))
+                                       (with_brackets (spaced (list\map annotation$ annotations)))
+                                       (spaced (list\map method_decl$ members)))))]
+    (wrap (list (` ((~ (code.text def_code))))))
+    ))
+
+(syntax: #export (object
+                   {class_vars (s.tuple (p.some ..type_param^))}
+                   {super (p.default object_super_class
+                                     (..super_class_decl^ class_vars))}
+                   {interfaces (p.default (list)
+                                          (s.tuple (p.some (..super_class_decl^ class_vars))))}
+                   {constructor_args (..constructor_args^ class_vars)}
+                   {methods (p.some ..overriden_method_def^)})
+  {#.doc (doc "Allows defining anonymous classes."
+              "The 1st tuple corresponds to class-level type-variables."
+              "The 2nd tuple corresponds to parent interfaces."
+              "The 3rd tuple corresponds to arguments to the super class constructor."
+              "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed."
+              (object [] [Runnable]
+                []
+                (Runnable [] (run self) void
+                          (exec (do_something some_value)
+                            [])))
+              )}
+  (let [def_code (format "jvm anon-class:"
+                         (spaced (list (super_class_decl$ super)
+                                       (with_brackets (spaced (list\map super_class_decl$ interfaces)))
+                                       (with_brackets (spaced (list\map constructor_arg$ constructor_args)))
+                                       (with_brackets (spaced (list\map (method_def$ function.identity super) methods))))))]
+    (wrap (list (` ((~ (code.text def_code))))))))
+
+(syntax: #export (null)
+  {#.doc (doc "Null object reference."
+              (null))}
+  (wrap (list (` ("jvm object null")))))
+
+(def: #export (null? obj)
+  {#.doc (doc "Test for null object reference."
+              (= (null? (null))
+                 true)
+              (= (null? "YOLO")
+                 false))}
+  (-> (primitive "java.lang.Object") Bit)
+  ("jvm object null?" obj))
+
+(syntax: #export (??? expr)
+  {#.doc (doc "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it."
+              (= (??? (: java/lang/String (null)))
+                 #.None)
+              (= (??? "YOLO")
+                 (#.Some "YOLO")))}
+  (with_gensyms [g!temp]
+    (wrap (list (` (let [(~ g!temp) (~ expr)]
+                     (if ("jvm object null?" (~ g!temp))
+                       #.None
+                       (#.Some (~ g!temp)))))))))
+
+(syntax: #export (!!! expr)
+  {#.doc (doc "Takes a (Maybe ObjectType) and returns a ObjectType."
+              "A #.None would get translated into a (null)."
+              (= (null)
+                 (!!! (??? (: java/lang/Thread (null)))))
+              (= "foo"
+                 (!!! (??? "foo"))))}
+  (with_gensyms [g!value]
+    (wrap (list (` ({(#.Some (~ g!value))
+                     (~ g!value)
+
+                     #.None
+                     ("jvm object null")}
+                    (~ expr)))))))
+
+(syntax: #export (try expression)
+  {#.doc (doc (case (try (risky_computation input))
+                (#.Right success)
+                (do_something success)
+
+                (#.Left error)
+                (recover_from_failure error)))}
+  (wrap (list (` ("lux try" ((~! io.io) (~ expression)))))))
+
+(syntax: #export (check {class (..generic_type^ (list))}
+                        {unchecked (p.maybe s.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."
+              (case (check java/lang/String "YOLO")
+                (#.Some value_as_string)
+                #.None))}
+  (with_gensyms [g!_ g!unchecked]
+    (let [class_name (simple_class$ (list) class)
+          class_type (` (.primitive (~ (code.text class_name))))
+          check_type (` (.Maybe (~ class_type)))
+          check_code (` (if ((~ (code.text (format "jvm instanceof" ":" class_name))) (~ g!unchecked))
+                          (#.Some (.:coerce (~ class_type)
+                                            (~ g!unchecked)))
+                          #.None))]
+      (case unchecked
+        (#.Some unchecked)
+        (wrap (list (` (: (~ check_type)
+                          (let [(~ g!unchecked) (~ unchecked)]
+                            (~ check_code))))))
+
+        #.None
+        (wrap (list (` (: (-> (primitive "java.lang.Object") (~ check_type))
+                          (function ((~ g!_) (~ g!unchecked))
+                            (~ check_code))))))
+        ))))
+
+(syntax: #export (synchronized lock body)
+  {#.doc (doc "Evaluates body, while holding a lock on a given object."
+              (synchronized object_to_be_locked
+                (exec (do_something ___)
+                  (do_something_else ___)
+                  (finish_the_computation ___))))}
+  (wrap (list (` ("jvm object synchronized" (~ lock) (~ body))))))
+
+(syntax: #export (do_to obj {methods (p.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)
+                     (ClassName::method2 arg3 arg4 arg5)))}
+  (with_gensyms [g!obj]
+    (wrap (list (` (let [(~ g!obj) (~ obj)]
+                     (exec (~+ (list\map (complete_call$ g!obj) methods))
+                       (~ g!obj))))))))
+
+(def: (class_import$ [full_name params])
+  (-> Class_Declaration Code)
+  (let [params' (list\map (|>> product.left code.local_identifier) params)]
+    (` (def: (~ (code.identifier ["" full_name]))
+         {#..jvm_class (~ (code.text full_name))}
+         Type
+         (All [(~+ params')]
+           (primitive (~ (code.text (sanitize full_name)))
+                      [(~+ params')]))))))
+
+(def: (member_type_vars class_tvars member)
+  (-> (List Type_Parameter) Import_Member_Declaration (List Type_Parameter))
+  (case member
+    (#ConstructorDecl [commons _])
+    (list\compose class_tvars (get@ #import_member_tvars commons))
+
+    (#MethodDecl [commons _])
+    (case (get@ #import_member_kind commons)
+      #StaticIMK
+      (get@ #import_member_tvars commons)
+
+      _
+      (list\compose class_tvars (get@ #import_member_tvars commons)))
+
+    _
+    class_tvars))
+
+(def: (member_def_arg_bindings type_params class member)
+  (-> (List Type_Parameter) Class_Declaration Import_Member_Declaration (Meta [(List [Bit Code]) (List Text) (List Code)]))
+  (case member
+    (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _]))
+    (let [(^slots [#import_member_tvars #import_member_args]) commons]
+      (do {! meta.monad}
+        [arg_inputs (monad.map !
+                               (: (-> [Bit GenericType] (Meta [Bit Code]))
+                                  (function (_ [maybe? _])
+                                    (with_gensyms [arg_name]
+                                      (wrap [maybe? arg_name]))))
+                               import_member_args)
+         #let [arg_classes (: (List Text)
+                              (list\map (|>> product.right (simple_class$ (list\compose type_params import_member_tvars)))
+                                        import_member_args))
+               arg_types (list\map (: (-> [Bit GenericType] Code)
+                                      (function (_ [maybe? arg])
+                                        (let [arg_type (class->type (get@ #import_member_mode commons) type_params arg)]
+                                          (if maybe?
+                                            (` (Maybe (~ arg_type)))
+                                            arg_type))))
+                                   import_member_args)]]
+        (wrap [arg_inputs arg_classes arg_types])))
+
+    _
+    (\ meta.monad wrap [(list) (list) (list)])))
+
+(def: (decorate_return_maybe member return_term)
+  (-> Import_Member_Declaration Code Code)
+  (case member
+    (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _]))
+    (if (get@ #import_member_maybe? commons)
+      (` (??? (~ return_term)))
+      (let [g!temp (` ((~' ~') (~ (code.identifier ["" " Ω "]))))]
+        (` (let [(~ g!temp) (~ return_term)]
+             (if (not (..null? (:coerce (primitive "java.lang.Object")
+                                        (~ g!temp))))
+               (~ g!temp)
+               (error! "Cannot produce null references from method calls."))))))
+
+    _
+    return_term))
+
+(template [  ]
+  [(def: ( member return_term)
+     (-> Import_Member_Declaration Code Code)
+     (case member
+       (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _]))
+       (if (get@  commons)
+         
+         return_term)
+
+       _
+       return_term))]
+
+  [decorate_return_try #import_member_try? (` (..try (~ return_term)))]
+  [decorate_return_io  #import_member_io?  (` ((~! io.io) (~ return_term)))]
+  )
+
+(def: (free_type_param? [name bounds])
+  (-> Type_Parameter Bit)
+  (case bounds
+    #.Nil #1
+    _     #0))
+
+(def: (type_param->type_arg [name _])
+  (-> Type_Parameter Code)
+  (code.identifier ["" name]))
+
+(template [    ]
+  [(def: ( mode [class expression])
+     (-> Primitive_Mode [Text Code] Code)
+     (case mode
+       #ManualPrM
+       expression
+       
+       #AutoPrM
+       (case class
+         "byte"  (` ( (~ expression)))
+         "short" (` ( (~ expression)))
+         "int"   (` ( (~ expression)))
+         "float" (` ( (~ expression)))
+         _       expression)))]
+
+  [auto_convert_input  long_to_byte long_to_short long_to_int double_to_float]
+  [auto_convert_output byte_to_long short_to_long int_to_long float_to_double]
+  )
+
+(def: (un_quote quoted)
+  (-> Code Code)
+  (` ((~' ~) (~ quoted))))
+
+(def: (jvm_extension_inputs mode classes inputs)
+  (-> Primitive_Mode (List Text) (List [Bit Code]) (List Code))
+  (|> inputs
+      (list\map (function (_ [maybe? input])
+                  (if maybe?
+                    (` ((~! !!!) (~ (un_quote input))))
+                    (un_quote input))))
+      (list.zip/2 classes)
+      (list\map (auto_convert_input mode))))
+
+(def: (import_name format class member)
+  (-> Text Text Text Text)
+  (|> format
+      (text.replace_all "#" class)
+      (text.replace_all "." member)))
+
+(def: (member_def_interop type_params kind class [arg_function_inputs arg_classes arg_types] member method_prefix import_format)
+  (-> (List Type_Parameter) Class_Kind Class_Declaration [(List [Bit Code]) (List Text) (List Code)] Import_Member_Declaration Text Text (Meta (List Code)))
+  (let [[full_name class_tvars] class
+        full_name (sanitize full_name)
+        all_params (|> (member_type_vars class_tvars member)
+                       (list.filter free_type_param?)
+                       (list\map type_param->type_arg))]
+    (case member
+      (#EnumDecl enum_members)
+      (do {! meta.monad}
+        [#let [enum_type (: Code
+                            (case class_tvars
+                              #.Nil
+                              (` (primitive (~ (code.text full_name))))
+
+                              _
+                              (let [=class_tvars (|> class_tvars
+                                                     (list.filter free_type_param?)
+                                                     (list\map type_param->type_arg))]
+                                (` (All [(~+ =class_tvars)] (primitive (~ (code.text full_name)) [(~+ =class_tvars)]))))))
+               getter_interop (: (-> Text Code)
+                                 (function (_ name)
+                                   (let [getter_name (code.identifier ["" (..import_name import_format method_prefix name)])]
+                                     (` (def: (~ getter_name)
+                                          (~ enum_type)
+                                          ((~ (code.text (format "jvm getstatic" ":" full_name ":" name)))))))))]]
+        (wrap (list\map getter_interop enum_members)))
+      
+      (#ConstructorDecl [commons _])
+      (do meta.monad
+        [#let [def_name (code.identifier ["" (..import_name import_format method_prefix (get@ #import_member_alias commons))])
+               jvm_extension (code.text (format "jvm new" ":" full_name ":" (text.join_with "," arg_classes)))
+               jvm_interop (|> (` ((~ jvm_extension)
+                                   (~+ (jvm_extension_inputs (get@ #import_member_mode commons) arg_classes arg_function_inputs))))
+                               (decorate_return_maybe member)
+                               (decorate_return_try member)
+                               (decorate_return_io member))]]
+        (wrap (list (` ((~! syntax:) ((~ def_name) (~+ (list\map product.right arg_function_inputs)))
+                        ((~' wrap) (.list (.` (~ jvm_interop)))))))))
+
+      (#MethodDecl [commons method])
+      (with_gensyms [g!obj]
+        (do meta.monad
+          [#let [def_name (code.identifier ["" (..import_name import_format method_prefix (get@ #import_member_alias commons))])
+                 (^slots [#import_member_kind]) commons
+                 (^slots [#import_method_name]) method
+                 [jvm_op object_ast] (: [Text (List Code)]
+                                        (case import_member_kind
+                                          #StaticIMK
+                                          ["invokestatic"
+                                           (list)]
+
+                                          #VirtualIMK
+                                          (case kind
+                                            #Class
+                                            ["invokevirtual"
+                                             (list g!obj)]
+                                            
+                                            #Interface
+                                            ["invokeinterface"
+                                             (list g!obj)]
+                                            )))
+                 jvm_extension (code.text (format "jvm " jvm_op ":" full_name ":" import_method_name ":" (text.join_with "," arg_classes)))
+                 jvm_interop (|> [(simple_class$ (list) (get@ #import_method_return method))
+                                  (` ((~ jvm_extension) (~+ (list\map un_quote object_ast))
+                                      (~+ (jvm_extension_inputs (get@ #import_member_mode commons) arg_classes arg_function_inputs))))]
+                                 (auto_convert_output (get@ #import_member_mode commons))
+                                 (decorate_return_maybe member)
+                                 (decorate_return_try member)
+                                 (decorate_return_io member))]]
+          (wrap (list (` ((~! syntax:) ((~ def_name) (~+ (list\map product.right arg_function_inputs)) (~+ object_ast))
+                          ((~' wrap) (.list (.` (~ jvm_interop))))))))))
+
+      (#FieldAccessDecl fad)
+      (do meta.monad
+        [#let [(^open ".") fad
+               base_gtype (class->type import_field_mode type_params import_field_type)
+               classC (class_decl_type$ class)
+               typeC (if import_field_maybe?
+                       (` (Maybe (~ base_gtype)))
+                       base_gtype)
+               tvar_asts (: (List Code)
+                            (|> class_tvars
+                                (list.filter free_type_param?)
+                                (list\map type_param->type_arg)))
+               getter_name (code.identifier ["" (..import_name import_format method_prefix import_field_name)])
+               setter_name (code.identifier ["" (..import_name import_format method_prefix (format import_field_name "!"))])]
+         getter_interop (with_gensyms [g!obj]
+                          (let [getter_call (if import_field_static?
+                                              (` ((~ getter_name)))
+                                              (` ((~ getter_name) (~ g!obj))))
+                                getter_body (<| (auto_convert_output import_field_mode)
+                                                [(simple_class$ (list) import_field_type)
+                                                 (if import_field_static?
+                                                   (let [jvm_extension (code.text (format "jvm getstatic" ":" full_name ":" import_field_name))]
+                                                     (` ((~ jvm_extension))))
+                                                   (let [jvm_extension (code.text (format "jvm getfield" ":" full_name ":" import_field_name))]
+                                                     (` ((~ jvm_extension) (~ (un_quote g!obj))))))])
+                                getter_body (if import_field_maybe?
+                                              (` ((~! ???) (~ getter_body)))
+                                              getter_body)
+                                getter_body (if import_field_setter?
+                                              (` ((~! io.io) (~ getter_body)))
+                                              getter_body)]
+                            (wrap (` ((~! syntax:) (~ getter_call)
+                                      ((~' wrap) (.list (.` (~ getter_body)))))))))
+         setter_interop (: (Meta (List Code))
+                           (if import_field_setter?
+                             (with_gensyms [g!obj g!value]
+                               (let [setter_call (if import_field_static?
+                                                   (` ((~ setter_name) (~ g!value)))
+                                                   (` ((~ setter_name) (~ g!value) (~ g!obj))))
+                                     setter_value (auto_convert_input import_field_mode
+                                                                      [(simple_class$ (list) import_field_type) (un_quote g!value)])
+                                     setter_value (if import_field_maybe?
+                                                    (` ((~! !!!) (~ setter_value)))
+                                                    setter_value)
+                                     setter_command (format (if import_field_static? "jvm putstatic" "jvm putfield")
+                                                            ":" full_name ":" import_field_name)
+                                     g!obj+ (: (List Code)
+                                               (if import_field_static?
+                                                 (list)
+                                                 (list (un_quote g!obj))))]
+                                 (wrap (list (` ((~! syntax:) (~ setter_call)
+                                                 ((~' wrap) (.list (.` ((~! io.io) ((~ (code.text setter_command)) (~+ g!obj+) (~ setter_value))))))))))))
+                             (wrap (list))))]
+        (wrap (list& getter_interop setter_interop)))
+      )))
+
+(def: (member_import$ type_params kind class [import_format member])
+  (-> (List Type_Parameter) Class_Kind Class_Declaration [Text Import_Member_Declaration] (Meta (List Code)))
+  (let [[method_prefix _] class]
+    (do meta.monad
+      [=args (member_def_arg_bindings type_params class member)]
+      (member_def_interop type_params kind class =args member method_prefix import_format))))
+
+(type: (java/lang/Class a)
+  (primitive "java.lang.Class" [a]))
+
+(def: interface?
+  (All [a] (-> (java/lang/Class a) Bit))
+  (|>> "jvm invokevirtual:java.lang.Class:isInterface:"))
+
+(def: (load_class class_name)
+  (-> Text (Try (java/lang/Class Any)))
+  (..try ("jvm invokestatic:java.lang.Class:forName:java.lang.String" class_name)))
+
+(def: (class_kind [class_name _])
+  (-> Class_Declaration (Meta Class_Kind))
+  (let [class_name (..sanitize class_name)]
+    (case (..load_class class_name)
+      (#try.Success class)
+      (\ meta.monad wrap (if (interface? class)
+                           #Interface
+                           #Class))
+
+      (#try.Failure error)
+      (meta.fail (format "Cannot load class: " class_name text.new_line
+                         error)))))
+
+(syntax: #export (import:
+                   {class_decl ..class_decl^}
+                   {bundles (p.some (..bundle (product.right class_decl)))})
+  {#.doc (doc "Allows importing JVM classes, and using them as types."
+              "Their methods, fields and enum options can also be imported."
+              (import: java/lang/Object
+                ["#::."
+                 (new [])
+                 (equals [java/lang/Object] boolean)
+                 (wait [int] #io #try void)])
+              
+              "Special options can also be given for the return values."
+              "#? means that the values will be returned inside a Maybe type. That way, null becomes #.None."
+              "#try means that the computation might throw an exception, and the return value will be wrapped by the Try type."
+              "#io means the computation has side effects, and will be wrapped by the IO type."
+              "These options must show up in the following order [#io #try #?] (although, each option can be used independently)."
+              (import: java/lang/String
+                ["#::."
+                 (new [[byte]])
+                 (#static valueOf [char] java/lang/String)
+                 (#static valueOf #as int_valueOf [int] java/lang/String)])
+
+              (import: (java/util/List e)
+                ["#::."
+                 (size [] int)
+                 (get [int] e)])
+
+              (import: (java/util/ArrayList a)
+                ["#::."
+                 ([T] toArray [[T]] [T])])
+              
+              "The class-type that is generated is of the fully-qualified name."
+              "This avoids a clash between the java.util.List type, and Lux's own List type."
+              "All enum options to be imported must be specified."
+              (import: java/lang/Character$UnicodeScript
+                ["#::."
+                 (#enum ARABIC CYRILLIC LATIN)])
+
+              "It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-parameters."
+              "Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes)."
+              (import: (lux/concurrency/promise/JvmPromise A)
+                ["#::."
+                 (resolve [A] boolean)
+                 (poll [] A)
+                 (wasResolved [] boolean)
+                 (waitOn [lux/Function] void)
+                 (#static [A] make [A] (lux/concurrency/promise/JvmPromise A))])
+              
+              "Also, the names of the imported members will look like Class::member"
+              (java/lang/Object::new [])
+              (java/lang/Object::equals [other_object] my_object)
+              (java/util/List::size [] my_list)
+              java/lang/Character$UnicodeScript::LATIN
+              )}
+  (do {! meta.monad}
+    [kind (class_kind class_decl)
+     =members (|> bundles
+                  (list\map (function (_ [import_format members])
+                              (list\map (|>> [import_format]) members)))
+                  list.concat
+                  (monad.map ! (member_import$ (product.right class_decl) kind class_decl)))]
+    (wrap (list& (class_import$ class_decl) (list\join =members)))))
+
+(syntax: #export (array {type (..generic_type^ (list))}
+                        size)
+  {#.doc (doc "Create an array of the given type, with the given size."
+              (array java/lang/Object 10))}
+  (case type
+    (^template [ ]
+      [(^ (#GenericClass  (list)))
+       (wrap (list (` ( (~ size)))))])
+    (["boolean" "jvm znewarray"]
+     ["byte"    "jvm bnewarray"]
+     ["short"   "jvm snewarray"]
+     ["int"     "jvm inewarray"]
+     ["long"    "jvm lnewarray"]
+     ["float"   "jvm fnewarray"]
+     ["double"  "jvm dnewarray"]
+     ["char"    "jvm cnewarray"])
+
+    _
+    (wrap (list (` ("jvm anewarray" (~ (code.text (generic_type$ type))) (~ size)))))))
+
+(syntax: #export (array_length array)
+  {#.doc (doc "Gives the length of an array."
+              (array_length my_array))}
+  (wrap (list (` ("jvm arraylength" (~ array))))))
+
+(def: (type->class_name type)
+  (-> Type (Meta Text))
+  (if (type\= Any type)
+    (\ meta.monad wrap "java.lang.Object")
+    (case type
+      (#.Primitive name params)
+      (\ meta.monad wrap name)
+
+      (#.Apply A F)
+      (case (type.apply (list A) F)
+        #.None
+        (meta.fail (format "Cannot apply type: " (type.format F) " to " (type.format A)))
+
+        (#.Some type')
+        (type->class_name type'))
+      
+      (#.Named _ type')
+      (type->class_name type')
+
+      _
+      (meta.fail (format "Cannot convert to JvmType: " (type.format type))))))
+
+(syntax: #export (array_read idx array)
+  {#.doc (doc "Loads an element from an array."
+              (array_read 10 my_array))}
+  (case array
+    [_ (#.Identifier array_name)]
+    (do meta.monad
+      [array_type (meta.find_type array_name)
+       array_jvm_type (type->class_name array_type)]
+      (case array_jvm_type
+        (^template [ ]
+          [
+           (wrap (list (` ( (~ array) (~ idx)))))])
+        (["[Z" "jvm zaload"]
+         ["[B" "jvm baload"]
+         ["[S" "jvm saload"]
+         ["[I" "jvm iaload"]
+         ["[J" "jvm jaload"]
+         ["[F" "jvm faload"]
+         ["[D" "jvm daload"]
+         ["[C" "jvm caload"])
+
+        _
+        (wrap (list (` ("jvm aaload" (~ array) (~ idx)))))))
+
+    _
+    (with_gensyms [g!array]
+      (wrap (list (` (let [(~ g!array) (~ array)]
+                       (..array_read (~ idx) (~ g!array)))))))))
+
+(syntax: #export (array_write idx value array)
+  {#.doc (doc "Stores an element into an array."
+              (array_write 10 my_object my_array))}
+  (case array
+    [_ (#.Identifier array_name)]
+    (do meta.monad
+      [array_type (meta.find_type array_name)
+       array_jvm_type (type->class_name array_type)]
+      (case array_jvm_type
+        (^template [ ]
+          [
+           (wrap (list (` ( (~ array) (~ idx) (~ value)))))])
+        (["[Z" "jvm zastore"]
+         ["[B" "jvm bastore"]
+         ["[S" "jvm sastore"]
+         ["[I" "jvm iastore"]
+         ["[J" "jvm jastore"]
+         ["[F" "jvm fastore"]
+         ["[D" "jvm dastore"]
+         ["[C" "jvm castore"])
+
+        _
+        (wrap (list (` ("jvm aastore" (~ array) (~ idx) (~ value)))))))
+
+    _
+    (with_gensyms [g!array]
+      (wrap (list (` (let [(~ g!array) (~ array)]
+                       (..array_write (~ idx) (~ value) (~ g!array)))))))))
+
+(syntax: #export (class_for {type (..generic_type^ (list))})
+  {#.doc (doc "Loads the class as a java.lang.Class object."
+              (class_for java/lang/String))}
+  (wrap (list (` ("jvm object class" (~ (code.text (simple_class$ (list) type))))))))
+
+(syntax: #export (type {type (..generic_type^ (list))})
+  (wrap (list (class->type #ManualPrM (list) type))))
diff --git a/stdlib/source/lux/ffi.php.lux b/stdlib/source/lux/ffi.php.lux
new file mode 100644
index 000000000..ac0daf9c5
--- /dev/null
+++ b/stdlib/source/lux/ffi.php.lux
@@ -0,0 +1,307 @@
+(.module:
+  [lux (#- Alias)
+   ["." meta]
+   ["@" target]
+   [abstract
+    [monad (#+ do)]]
+   [control
+    ["." io]
+    ["<>" parser ("#\." monad)
+     ["<.>" code (#+ Parser)]]]
+   [data
+    ["." product]
+    ["." maybe]
+    ["." text
+     ["%" format (#+ format)]]
+    [collection
+     ["." list ("#\." functor fold)]]]
+   [type
+    abstract]
+   [macro (#+ with_gensyms)
+    [syntax (#+ syntax:)]
+    ["." code]
+    ["." template]]])
+
+(abstract: #export (Object brand) Any)
+
+(template []
+  [(with_expansions [ (template.identifier [ "'"])]
+     (abstract: #export  Any)
+     (type: #export 
+       (..Object )))]
+
+  [Null]
+  [Function]
+  )
+
+(template [ ]
+  [(type: #export 
+     )]
+
+  [Boolean Bit]
+  [Integer Int]
+  [Float   Frac]
+  [String  Text]
+  )
+
+(type: Nullable
+  [Bit Code])
+
+(def: nullable
+  (Parser Nullable)
+  (let [token (' #?)]
+    (<| (<>.and (<>.parses? (.this! token)))
+        (<>.after (<>.not (.this! token)))
+        .any)))
+
+(type: Alias
+  Text)
+
+(def: alias
+  (Parser Alias)
+  (<>.after (.this! (' #as)) .local_identifier))
+
+(type: Field
+  [Bit Text (Maybe Alias) Nullable])
+
+(def: static!
+  (Parser Any)
+  (.this! (' #static)))
+
+(def: field
+  (Parser Field)
+  (.form ($_ <>.and
+                   (<>.parses? ..static!)
+                   .local_identifier
+                   (<>.maybe ..alias)
+                   ..nullable)))
+
+(def: constant
+  (Parser Field)
+  (.form ($_ <>.and
+                   (<>\wrap true)
+                   .local_identifier
+                   (<>.maybe ..alias)
+                   ..nullable)))
+
+(type: Common_Method
+  {#name Text
+   #alias (Maybe Alias)
+   #inputs (List Nullable)
+   #io? Bit
+   #try? Bit
+   #output Nullable})
+
+(type: Static_Method Common_Method)
+(type: Virtual_Method Common_Method)
+
+(type: Method
+  (#Static Static_Method)
+  (#Virtual Virtual_Method))
+
+(def: common_method
+  (Parser Common_Method)
+  ($_ <>.and
+      .local_identifier
+      (<>.maybe ..alias)
+      (.tuple (<>.some ..nullable))
+      (<>.parses? (.this! (' #io)))
+      (<>.parses? (.this! (' #try)))
+      ..nullable))
+
+(def: static_method
+  (<>.after ..static! ..common_method))
+
+(def: method
+  (Parser Method)
+  (.form (<>.or ..static_method
+                      ..common_method)))
+
+(type: Member
+  (#Field Field)
+  (#Method Method))
+
+(def: member
+  (Parser Member)
+  ($_ <>.or
+      ..field
+      ..method
+      ))
+
+(def: input_variables
+  (-> (List Nullable) (List [Bit Code]))
+  (|>> list.enumeration
+       (list\map (function (_ [idx [nullable? type]])
+                   [nullable? (|> idx %.nat code.local_identifier)]))))
+
+(def: (nullable_type [nullable? type])
+  (-> Nullable Code)
+  (if nullable?
+    (` (.Maybe (~ type)))
+    type))
+
+(def: (with_null g!temp [nullable? input])
+  (-> Code [Bit Code] Code)
+  (if nullable?
+    (` (case (~ input)
+         (#.Some (~ g!temp))
+         (~ g!temp)
+
+         #.Null
+         ("php object null")))
+    input))
+
+(def: (without_null g!temp [nullable? outputT] output)
+  (-> Code Nullable Code Code)
+  (if nullable?
+    (` (let [(~ g!temp) (~ output)]
+         (if ("php object null?" (~ g!temp))
+           #.None
+           (#.Some (~ g!temp)))))
+    (` (let [(~ g!temp) (~ output)]
+         (if (not ("php object null?" (~ g!temp)))
+           (~ g!temp)
+           (.error! "Null is an invalid value!"))))))
+
+(type: Import
+  (#Class Text (Maybe Alias) (List Member))
+  (#Function Static_Method)
+  (#Constant Field))
+
+(def: import
+  (Parser Import)
+  ($_ <>.or
+      ($_ <>.and
+          .local_identifier
+          (<>.maybe ..alias)
+          (<>.some member))
+      (.form ..common_method)
+      ..constant
+      ))
+
+(syntax: #export (try expression)
+  {#.doc (doc (case (try (risky_computation input))
+                (#.Right success)
+                (do_something success)
+
+                (#.Left error)
+                (recover_from_failure error)))}
+  (wrap (list (` ("lux try" ((~! io.io) (~ expression)))))))
+
+(def: (with_io with? without)
+  (-> Bit Code Code)
+  (if with?
+    (` (io.io (~ without)))
+    without))
+
+(def: (io_type io? rawT)
+  (-> Bit Code Code)
+  (if io?
+    (` (io.IO (~ rawT)))
+    rawT))
+
+(def: (with_try with? without_try)
+  (-> Bit Code Code)
+  (if with?
+    (` (..try (~ without_try)))
+    without_try))
+
+(def: (try_type try? rawT)
+  (-> Bit Code Code)
+  (if try?
+    (` (.Either .Text (~ rawT)))
+    rawT))
+
+(def: (make_function g!method g!temp source inputsT io? try? outputT)
+  (-> Code Code Code (List Nullable) Bit Bit Nullable Code)
+  (let [g!inputs (input_variables inputsT)]
+    (` (def: ((~ g!method)
+              [(~+ (list\map product.right g!inputs))])
+         (-> [(~+ (list\map nullable_type inputsT))]
+             (~ (|> (nullable_type outputT)
+                    (try_type try?)
+                    (io_type io?))))
+         (:assume
+          (~ (<| (with_io io?)
+                 (with_try try?)
+                 (without_null g!temp outputT)
+                 (` ("php apply"
+                     (:coerce ..Function (~ source))
+                     (~+ (list\map (with_null g!temp) g!inputs)))))))))))
+
+(syntax: #export (import: {import ..import})
+  (with_gensyms [g!temp]
+    (case import
+      (#Class [class alias members])
+      (with_gensyms [g!object]
+        (let [qualify (: (-> Text Code)
+                         (|>> (format (maybe.default class alias) "::") code.local_identifier))
+              g!type (code.local_identifier (maybe.default class alias))
+              class_import (` ("php constant" (~ (code.text class))))]
+          (wrap (list& (` (type: (~ g!type)
+                            (..Object (primitive (~ (code.text class))))))
+                       (list\map (function (_ member)
+                                   (case member
+                                     (#Field [static? field alias fieldT])
+                                     (if static?
+                                       (` ((~! syntax:) ((~ (qualify (maybe.default field alias))))
+                                           (\ (~! meta.monad) (~' wrap)
+                                              (list (` (.:coerce (~ (nullable_type fieldT))
+                                                                 ("php constant" (~ (code.text (format class "::" field))))))))))
+                                       (` (def: ((~ (qualify field))
+                                                 (~ g!object))
+                                            (-> (~ g!type)
+                                                (~ (nullable_type fieldT)))
+                                            (:assume
+                                             (~ (without_null g!temp fieldT (` ("php object get" (~ (code.text field))
+                                                                                (:coerce (..Object .Any) (~ g!object))))))))))
+                                     
+                                     (#Method method)
+                                     (case method
+                                       (#Static [method alias inputsT io? try? outputT])
+                                       (..make_function (qualify (maybe.default method alias))
+                                                        g!temp
+                                                        (` ("php object get" (~ (code.text method))
+                                                            (:coerce (..Object .Any)
+                                                                     ("php constant" (~ (code.text (format class "::" method)))))))
+                                                        inputsT
+                                                        io?
+                                                        try?
+                                                        outputT)
+                                       
+                                       (#Virtual [method alias inputsT io? try? outputT])
+                                       (let [g!inputs (input_variables inputsT)]
+                                         (` (def: ((~ (qualify (maybe.default method alias)))
+                                                   [(~+ (list\map product.right g!inputs))]
+                                                   (~ g!object))
+                                              (-> [(~+ (list\map nullable_type inputsT))]
+                                                  (~ g!type)
+                                                  (~ (|> (nullable_type outputT)
+                                                         (try_type try?)
+                                                         (io_type io?))))
+                                              (:assume
+                                               (~ (<| (with_io io?)
+                                                      (with_try try?)
+                                                      (without_null g!temp outputT)
+                                                      (` ("php object do"
+                                                          (~ (code.text method))
+                                                          (~ g!object)
+                                                          (~+ (list\map (with_null g!temp) g!inputs)))))))))))))
+                                 members)))))
+      
+      (#Function [name alias inputsT io? try? outputT])
+      (let [imported (` ("php constant" (~ (code.text name))))]
+        (wrap (list (..make_function (code.local_identifier (maybe.default name alias))
+                                     g!temp
+                                     imported
+                                     inputsT
+                                     io?
+                                     try?
+                                     outputT))))
+
+      (#Constant [_ name alias fieldT])
+      (let [imported (` ("php constant" (~ (code.text name))))]
+        (wrap (list (` ((~! syntax:) ((~ (code.local_identifier (maybe.default name alias))))
+                        (\ (~! meta.monad) (~' wrap)
+                           (list (` (.:coerce (~ (nullable_type fieldT)) (~ imported))))))))))
+      )))
diff --git a/stdlib/source/lux/ffi.py.lux b/stdlib/source/lux/ffi.py.lux
new file mode 100644
index 000000000..ed67b3705
--- /dev/null
+++ b/stdlib/source/lux/ffi.py.lux
@@ -0,0 +1,319 @@
+(.module:
+  [lux #*
+   ["." meta]
+   ["@" target]
+   [abstract
+    [monad (#+ do)]]
+   [control
+    ["." io]
+    ["<>" parser
+     ["" code (#+ Parser)]]]
+   [data
+    ["." product]
+    ["." maybe]
+    ["." text
+     ["%" format (#+ format)]]
+    [collection
+     ["." list ("#\." functor fold)]]]
+   [type
+    abstract]
+   [macro (#+ with_gensyms)
+    [syntax (#+ syntax:)]
+    ["." code]
+    ["." template]]])
+
+(abstract: #export (Object brand) Any)
+
+(template []
+  [(with_expansions [ (template.identifier [ "'"])]
+     (abstract: #export  Any)
+     (type: #export 
+       (..Object )))]
+
+  [None]
+  [Function]
+  [Dict]
+  )
+
+(template [ ]
+  [(type: #export 
+     )]
+
+  [Boolean Bit]
+  [Integer Int]
+  [Float   Frac]
+  [String  Text]
+  )
+
+(type: Noneable
+  [Bit Code])
+
+(def: noneable
+  (Parser Noneable)
+  (let [token (' #?)]
+    (<| (<>.and (<>.parses? (.this! token)))
+        (<>.after (<>.not (.this! token)))
+        .any)))
+
+(type: Constructor
+  (List Noneable))
+
+(def: constructor
+  (Parser Constructor)
+  (.form (<>.after (.this! (' new))
+                      (.tuple (<>.some ..noneable)))))
+
+(type: Field
+  [Bit Text Noneable])
+
+(def: static!
+  (Parser Any)
+  (.this! (' #static)))
+
+(def: field
+  (Parser Field)
+  (.form ($_ <>.and
+                (<>.parses? ..static!)
+                .local_identifier
+                ..noneable)))
+
+(type: Common_Method
+  {#name Text
+   #alias (Maybe Text)
+   #inputs (List Noneable)
+   #io? Bit
+   #try? Bit
+   #output Noneable})
+
+(type: Static_Method Common_Method)
+(type: Virtual_Method Common_Method)
+
+(type: Method
+  (#Static Static_Method)
+  (#Virtual Virtual_Method))
+
+(def: common_method
+  (Parser Common_Method)
+  ($_ <>.and
+      .local_identifier
+      (<>.maybe (<>.after (.this! (' #as)) .local_identifier))
+      (.tuple (<>.some ..noneable))
+      (<>.parses? (.this! (' #io)))
+      (<>.parses? (.this! (' #try)))
+      ..noneable))
+
+(def: static_method
+  (<>.after ..static! ..common_method))
+
+(def: method
+  (Parser Method)
+  (.form (<>.or ..static_method
+                   ..common_method)))
+
+(type: Member
+  (#Constructor Constructor)
+  (#Field Field)
+  (#Method Method))
+
+(def: member
+  (Parser Member)
+  ($_ <>.or
+      ..constructor
+      ..field
+      ..method
+      ))
+
+(def: input_variables
+  (-> (List Noneable) (List [Bit Code]))
+  (|>> list.enumeration
+       (list\map (function (_ [idx [noneable? type]])
+                   [noneable? (|> idx %.nat code.local_identifier)]))))
+
+(def: (noneable_type [noneable? type])
+  (-> Noneable Code)
+  (if noneable?
+    (` (.Maybe (~ type)))
+    type))
+
+(def: (with_none g!temp [noneable? input])
+  (-> Code [Bit Code] Code)
+  (if noneable?
+    (` (case (~ input)
+         (#.Some (~ g!temp))
+         (~ g!temp)
+
+         #.None
+         ("python object none")))
+    input))
+
+(def: (without_none g!temp [noneable? outputT] output)
+  (-> Code Noneable Code Code)
+  (if noneable?
+    (` (let [(~ g!temp) (~ output)]
+         (if ("python object none?" (~ g!temp))
+           #.None
+           (#.Some (~ g!temp)))))
+    (` (let [(~ g!temp) (~ output)]
+         (if (not ("python object none?" (~ g!temp)))
+           (~ g!temp)
+           (.error! "None is an invalid value!"))))))
+
+(type: Import
+  (#Class [Text (List Member)])
+  (#Function Static_Method))
+
+(def: import
+  ($_ <>.or
+      ($_ <>.and
+          .local_identifier
+          (<>.some member))
+      (.form ..common_method)
+      ))
+
+(syntax: #export (try expression)
+  {#.doc (doc (case (try (risky_computation input))
+                (#.Right success)
+                (do_something success)
+
+                (#.Left error)
+                (recover_from_failure error)))}
+  (wrap (list (` ("lux try" ((~! io.io) (~ expression)))))))
+
+(def: (with_io with? without)
+  (-> Bit Code Code)
+  (if with?
+    (` (io.io (~ without)))
+    without))
+
+(def: (io_type io? rawT)
+  (-> Bit Code Code)
+  (if io?
+    (` (io.IO (~ rawT)))
+    rawT))
+
+(def: (with_try with? without_try)
+  (-> Bit Code Code)
+  (if with?
+    (` (..try (~ without_try)))
+    without_try))
+
+(def: (try_type try? rawT)
+  (-> Bit Code Code)
+  (if try?
+    (` (.Either .Text (~ rawT)))
+    rawT))
+
+(def: (make_function g!method g!temp source inputsT io? try? outputT)
+  (-> Code Code Code (List Noneable) Bit Bit Noneable Code)
+  (let [g!inputs (input_variables inputsT)]
+    (` (def: ((~ g!method)
+              [(~+ (list\map product.right g!inputs))])
+         (-> [(~+ (list\map noneable_type inputsT))]
+             (~ (|> (noneable_type outputT)
+                    (try_type try?)
+                    (io_type io?))))
+         (:assume
+          (~ (<| (with_io io?)
+                 (with_try try?)
+                 (without_none g!temp outputT)
+                 (` ("python apply"
+                     (:coerce ..Function (~ source))
+                     (~+ (list\map (with_none g!temp) g!inputs)))))))))))
+
+(syntax: #export (import: {import ..import})
+  (with_gensyms [g!temp]
+    (case import
+      (#Class [class members])
+      (with_gensyms [g!object]
+        (let [qualify (: (-> Text Code)
+                         (|>> (format class "::") code.local_identifier))
+              g!type (code.local_identifier class)
+              real_class (text.replace_all "/" "." class)
+              imported (case (text.split_all_with "/" class)
+                         (#.Cons head tail)
+                         (list\fold (function (_ sub super)
+                                      (` ("python object get" (~ (code.text sub))
+                                          (:coerce (..Object .Any) (~ super)))))
+                                    (` ("python import" (~ (code.text head))))
+                                    tail)
+                         
+                         #.Nil
+                         (` ("python import" (~ (code.text class)))))]
+          (wrap (list& (` (type: (~ g!type)
+                            (..Object (primitive (~ (code.text real_class))))))
+                       (list\map (function (_ member)
+                                   (case member
+                                     (#Constructor inputsT)
+                                     (let [g!inputs (input_variables inputsT)]
+                                       (` (def: ((~ (qualify "new"))
+                                                 [(~+ (list\map product.right g!inputs))])
+                                            (-> [(~+ (list\map noneable_type inputsT))]
+                                                (~ g!type))
+                                            (:assume
+                                             ("python apply"
+                                              (:coerce ..Function (~ imported))
+                                              (~+ (list\map (with_none g!temp) g!inputs)))))))
+                                     
+                                     (#Field [static? field fieldT])
+                                     (if static?
+                                       (` ((~! syntax:) ((~ (qualify field)))
+                                           (\ (~! meta.monad) (~' wrap)
+                                              (list (` (.:coerce (~ (noneable_type fieldT))
+                                                                 ("python object get" (~ (code.text field))
+                                                                  (:coerce (..Object .Any) (~ imported)))))))))
+                                       (` (def: ((~ (qualify field))
+                                                 (~ g!object))
+                                            (-> (~ g!type)
+                                                (~ (noneable_type fieldT)))
+                                            (:assume
+                                             (~ (without_none g!temp fieldT (` ("python object get" (~ (code.text field))
+                                                                                (:coerce (..Object .Any) (~ g!object))))))))))
+                                     
+                                     (#Method method)
+                                     (case method
+                                       (#Static [method alias inputsT io? try? outputT])
+                                       (..make_function (qualify (maybe.default method alias))
+                                                        g!temp
+                                                        (` ("python object get" (~ (code.text method))
+                                                            (:coerce (..Object .Any) (~ imported))))
+                                                        inputsT
+                                                        io?
+                                                        try?
+                                                        outputT)
+                                       
+                                       (#Virtual [method alias inputsT io? try? outputT])
+                                       (let [g!inputs (input_variables inputsT)]
+                                         (` (def: ((~ (qualify (maybe.default method alias)))
+                                                   [(~+ (list\map product.right g!inputs))]
+                                                   (~ g!object))
+                                              (-> [(~+ (list\map noneable_type inputsT))]
+                                                  (~ g!type)
+                                                  (~ (|> (noneable_type outputT)
+                                                         (try_type try?)
+                                                         (io_type io?))))
+                                              (:assume
+                                               (~ (<| (with_io io?)
+                                                      (with_try try?)
+                                                      (without_none g!temp outputT)
+                                                      (` ("python object do"
+                                                          (~ (code.text method))
+                                                          (~ g!object)
+                                                          (~+ (list\map (with_none g!temp) g!inputs)))))))))))))
+                                 members)))))
+      
+      (#Function [name alias inputsT io? try? outputT])
+      (wrap (list (..make_function (code.local_identifier (maybe.default name alias))
+                                   g!temp
+                                   (` ("python constant" (~ (code.text name))))
+                                   inputsT
+                                   io?
+                                   try?
+                                   outputT)))
+      )))
+
+(template: #export (lambda  )
+  (.:coerce ..Function
+            (`` ("python function"
+                 (~~ (template.count ))
+                 (.function (_ [])
+                   )))))
diff --git a/stdlib/source/lux/ffi.rb.lux b/stdlib/source/lux/ffi.rb.lux
new file mode 100644
index 000000000..63f14e8a3
--- /dev/null
+++ b/stdlib/source/lux/ffi.rb.lux
@@ -0,0 +1,334 @@
+(.module:
+  [lux (#- Alias)
+   ["." meta]
+   ["@" target]
+   [abstract
+    [monad (#+ do)]]
+   [control
+    ["." io]
+    ["<>" parser ("#\." monad)
+     ["<.>" code (#+ Parser)]]]
+   [data
+    ["." product]
+    ["." maybe]
+    ["." text
+     ["%" format (#+ format)]]
+    [collection
+     ["." list ("#\." functor fold)]]]
+   [type
+    abstract]
+   [macro (#+ with_gensyms)
+    [syntax (#+ syntax:)]
+    ["." code]
+    ["." template]]])
+
+(abstract: #export (Object brand) Any)
+
+(template []
+  [(with_expansions [ (template.identifier [ "'"])]
+     (abstract: #export  Any)
+     (type: #export 
+       (..Object )))]
+
+  [Nil]
+  [Function]
+  )
+
+(template [ ]
+  [(type: #export 
+     )]
+
+  [Boolean Bit]
+  [Integer Int]
+  [Float   Frac]
+  [String  Text]
+  )
+
+(type: Nilable
+  [Bit Code])
+
+(def: nilable
+  (Parser Nilable)
+  (let [token (' #?)]
+    (<| (<>.and (<>.parses? (.this! token)))
+        (<>.after (<>.not (.this! token)))
+        .any)))
+
+(type: Alias
+  Text)
+
+(def: alias
+  (Parser Alias)
+  (<>.after (.this! (' #as)) .local_identifier))
+
+(type: Field
+  [Bit Text (Maybe Alias) Nilable])
+
+(def: static!
+  (Parser Any)
+  (.this! (' #static)))
+
+(def: field
+  (Parser Field)
+  (.form ($_ <>.and
+                   (<>.parses? ..static!)
+                   .local_identifier
+                   (<>.maybe ..alias)
+                   ..nilable)))
+
+(def: constant
+  (Parser Field)
+  (.form ($_ <>.and
+                   (<>\wrap true)
+                   .local_identifier
+                   (<>.maybe ..alias)
+                   ..nilable)))
+
+(type: Common_Method
+  {#name Text
+   #alias (Maybe Alias)
+   #inputs (List Nilable)
+   #io? Bit
+   #try? Bit
+   #output Nilable})
+
+(type: Static_Method Common_Method)
+(type: Virtual_Method Common_Method)
+
+(type: Method
+  (#Static Static_Method)
+  (#Virtual Virtual_Method))
+
+(def: common_method
+  (Parser Common_Method)
+  ($_ <>.and
+      .local_identifier
+      (<>.maybe ..alias)
+      (.tuple (<>.some ..nilable))
+      (<>.parses? (.this! (' #io)))
+      (<>.parses? (.this! (' #try)))
+      ..nilable))
+
+(def: static_method
+  (<>.after ..static! ..common_method))
+
+(def: method
+  (Parser Method)
+  (.form (<>.or ..static_method
+                      ..common_method)))
+
+(type: Member
+  (#Field Field)
+  (#Method Method))
+
+(def: member
+  (Parser Member)
+  ($_ <>.or
+      ..field
+      ..method
+      ))
+
+(def: input_variables
+  (-> (List Nilable) (List [Bit Code]))
+  (|>> list.enumeration
+       (list\map (function (_ [idx [nilable? type]])
+                   [nilable? (|> idx %.nat code.local_identifier)]))))
+
+(def: (nilable_type [nilable? type])
+  (-> Nilable Code)
+  (if nilable?
+    (` (.Maybe (~ type)))
+    type))
+
+(def: (with_nil g!temp [nilable? input])
+  (-> Code [Bit Code] Code)
+  (if nilable?
+    (` (case (~ input)
+         (#.Some (~ g!temp))
+         (~ g!temp)
+
+         #.Nil
+         ("ruby object nil")))
+    input))
+
+(def: (without_nil g!temp [nilable? outputT] output)
+  (-> Code Nilable Code Code)
+  (if nilable?
+    (` (let [(~ g!temp) (~ output)]
+         (if ("ruby object nil?" (~ g!temp))
+           #.None
+           (#.Some (~ g!temp)))))
+    (` (let [(~ g!temp) (~ output)]
+         (if (not ("ruby object nil?" (~ g!temp)))
+           (~ g!temp)
+           (.error! "Nil is an invalid value!"))))))
+
+(type: Import
+  (#Class Text (Maybe Alias) (List Member))
+  (#Function Static_Method)
+  (#Constant Field))
+
+(def: import
+  (Parser [(Maybe Text) Import])
+  ($_ <>.and
+      (<>.maybe .text)
+      ($_ <>.or
+          ($_ <>.and
+              .local_identifier
+              (<>.maybe ..alias)
+              (<>.some member))
+          (.form ..common_method)
+          ..constant
+          )))
+
+(syntax: #export (try expression)
+  {#.doc (doc (case (try (risky_computation input))
+                (#.Right success)
+                (do_something success)
+
+                (#.Left error)
+                (recover_from_failure error)))}
+  (wrap (list (` ("lux try" ((~! io.io) (~ expression)))))))
+
+(def: (with_io with? without)
+  (-> Bit Code Code)
+  (if with?
+    (` (io.io (~ without)))
+    without))
+
+(def: (io_type io? rawT)
+  (-> Bit Code Code)
+  (if io?
+    (` (io.IO (~ rawT)))
+    rawT))
+
+(def: (with_try with? without_try)
+  (-> Bit Code Code)
+  (if with?
+    (` (..try (~ without_try)))
+    without_try))
+
+(def: (try_type try? rawT)
+  (-> Bit Code Code)
+  (if try?
+    (` (.Either .Text (~ rawT)))
+    rawT))
+
+(def: (make_function g!method g!temp source inputsT io? try? outputT)
+  (-> Code Code Code (List Nilable) Bit Bit Nilable Code)
+  (let [g!inputs (input_variables inputsT)]
+    (` (def: ((~ g!method)
+              [(~+ (list\map product.right g!inputs))])
+         (-> [(~+ (list\map nilable_type inputsT))]
+             (~ (|> (nilable_type outputT)
+                    (try_type try?)
+                    (io_type io?))))
+         (:assume
+          (~ (<| (with_io io?)
+                 (with_try try?)
+                 (without_nil g!temp outputT)
+                 (` ("ruby apply"
+                     (:coerce ..Function (~ source))
+                     (~+ (list\map (with_nil g!temp) g!inputs)))))))))))
+
+(syntax: #export (import: {[?module import] ..import})
+  (with_gensyms [g!temp]
+    (case import
+      (#Class [class alias members])
+      (with_gensyms [g!object]
+        (let [qualify (: (-> Text Code)
+                         (|>> (format (maybe.default class alias) "::") code.local_identifier))
+              g!type (code.local_identifier (maybe.default class alias))
+              module_import (: (List Code)
+                               (case ?module
+                                 (#.Some module)
+                                 (list (` ("ruby import" (~ (code.text module)))))
+
+                                 #.None
+                                 (list)))
+              class_import (` ("ruby constant" (~ (code.text class))))]
+          (wrap (list& (` (type: (~ g!type)
+                            (..Object (primitive (~ (code.text class))))))
+                       (list\map (function (_ member)
+                                   (case member
+                                     (#Field [static? field alias fieldT])
+                                     (if static?
+                                       (` ((~! syntax:) ((~ (qualify (maybe.default field alias))))
+                                           (\ (~! meta.monad) (~' wrap)
+                                              (list (` (.:coerce (~ (nilable_type fieldT))
+                                                                 (.exec
+                                                                   (~+ module_import)
+                                                                   ("ruby constant" (~ (code.text (format class "::" field)))))))))))
+                                       (` (def: ((~ (qualify field))
+                                                 (~ g!object))
+                                            (-> (~ g!type)
+                                                (~ (nilable_type fieldT)))
+                                            (:assume
+                                             (~ (without_nil g!temp fieldT (` ("ruby object get" (~ (code.text field))
+                                                                               (:coerce (..Object .Any) (~ g!object))))))))))
+                                     
+                                     (#Method method)
+                                     (case method
+                                       (#Static [method alias inputsT io? try? outputT])
+                                       (..make_function (qualify (maybe.default method alias))
+                                                        g!temp
+                                                        (` ("ruby object get" (~ (code.text method))
+                                                            (:coerce (..Object .Any)
+                                                                     (.exec
+                                                                       (~+ module_import)
+                                                                       ("ruby constant" (~ (code.text (format class "::" method))))))))
+                                                        inputsT
+                                                        io?
+                                                        try?
+                                                        outputT)
+                                       
+                                       (#Virtual [method alias inputsT io? try? outputT])
+                                       (let [g!inputs (input_variables inputsT)]
+                                         (` (def: ((~ (qualify (maybe.default method alias)))
+                                                   [(~+ (list\map product.right g!inputs))]
+                                                   (~ g!object))
+                                              (-> [(~+ (list\map nilable_type inputsT))]
+                                                  (~ g!type)
+                                                  (~ (|> (nilable_type outputT)
+                                                         (try_type try?)
+                                                         (io_type io?))))
+                                              (:assume
+                                               (~ (<| (with_io io?)
+                                                      (with_try try?)
+                                                      (without_nil g!temp outputT)
+                                                      (` ("ruby object do"
+                                                          (~ (code.text method))
+                                                          (~ g!object)
+                                                          (~+ (list\map (with_nil g!temp) g!inputs)))))))))))))
+                                 members)))))
+      
+      (#Function [name alias inputsT io? try? outputT])
+      (let [imported (` (.exec
+                          (~+ (case ?module
+                                (#.Some module)
+                                (list (` ("ruby import" (~ (code.text module)))))
+
+                                #.None
+                                (list)))
+                          ("ruby constant" (~ (code.text name)))))]
+        (wrap (list (..make_function (code.local_identifier (maybe.default name alias))
+                                     g!temp
+                                     imported
+                                     inputsT
+                                     io?
+                                     try?
+                                     outputT))))
+
+      (#Constant [_ name alias fieldT])
+      (let [imported (` (.exec
+                          (~+ (case ?module
+                                (#.Some module)
+                                (list (` ("ruby import" (~ (code.text module)))))
+
+                                #.None
+                                (list)))
+                          ("ruby constant" (~ (code.text name)))))]
+        (wrap (list (` ((~! syntax:) ((~ (code.local_identifier (maybe.default name alias))))
+                        (\ (~! meta.monad) (~' wrap)
+                           (list (` (.:coerce (~ (nilable_type fieldT)) (~ imported))))))))))
+      )))
diff --git a/stdlib/source/lux/ffi.scm.lux b/stdlib/source/lux/ffi.scm.lux
new file mode 100644
index 000000000..1dde8ab69
--- /dev/null
+++ b/stdlib/source/lux/ffi.scm.lux
@@ -0,0 +1,219 @@
+(.module:
+  [lux (#- Alias)
+   ["." meta]
+   ["@" target]
+   [abstract
+    [monad (#+ do)]]
+   [control
+    ["." io]
+    ["<>" parser ("#\." monad)
+     ["<.>" code (#+ Parser)]]]
+   [data
+    ["." product]
+    ["." maybe]
+    ["." text
+     ["%" format (#+ format)]]
+    [collection
+     ["." list ("#\." functor fold)]]]
+   [type
+    abstract]
+   [macro (#+ with_gensyms)
+    [syntax (#+ syntax:)]
+    ["." code]
+    ["." template]]])
+
+(abstract: #export (Object brand) Any)
+
+(template []
+  [(with_expansions [ (template.identifier [ "'"])]
+     (abstract: #export  Any)
+     (type: #export 
+       (..Object )))]
+
+  [Nil]
+  [Function]
+  )
+
+(template [ ]
+  [(type: #export 
+     )]
+
+  [Boolean Bit]
+  [Integer Int]
+  [Float   Frac]
+  [String  Text]
+  )
+
+(type: Nilable
+  [Bit Code])
+
+(def: nilable
+  (Parser Nilable)
+  (let [token (' #?)]
+    (<| (<>.and (<>.parses? (.this! token)))
+        (<>.after (<>.not (.this! token)))
+        .any)))
+
+(type: Alias
+  Text)
+
+(def: alias
+  (Parser Alias)
+  (<>.after (.this! (' #as)) .local_identifier))
+
+(type: Field
+  [Bit Text (Maybe Alias) Nilable])
+
+(def: static!
+  (Parser Any)
+  (.this! (' #static)))
+
+(def: field
+  (Parser Field)
+  (.form ($_ <>.and
+                   (<>.parses? ..static!)
+                   .local_identifier
+                   (<>.maybe ..alias)
+                   ..nilable)))
+
+(def: constant
+  (Parser Field)
+  (.form ($_ <>.and
+                   (<>\wrap true)
+                   .local_identifier
+                   (<>.maybe ..alias)
+                   ..nilable)))
+
+(type: Common_Method
+  {#name Text
+   #alias (Maybe Alias)
+   #inputs (List Nilable)
+   #io? Bit
+   #try? Bit
+   #output Nilable})
+
+(def: common_method
+  (Parser Common_Method)
+  ($_ <>.and
+      .local_identifier
+      (<>.maybe ..alias)
+      (.tuple (<>.some ..nilable))
+      (<>.parses? (.this! (' #io)))
+      (<>.parses? (.this! (' #try)))
+      ..nilable))
+
+(def: input_variables
+  (-> (List Nilable) (List [Bit Code]))
+  (|>> list.enumeration
+       (list\map (function (_ [idx [nilable? type]])
+                   [nilable? (|> idx %.nat code.local_identifier)]))))
+
+(def: (nilable_type [nilable? type])
+  (-> Nilable Code)
+  (if nilable?
+    (` (.Maybe (~ type)))
+    type))
+
+(def: (with_nil g!temp [nilable? input])
+  (-> Code [Bit Code] Code)
+  (if nilable?
+    (` (case (~ input)
+         (#.Some (~ g!temp))
+         (~ g!temp)
+
+         #.Nil
+         ("scheme object nil")))
+    input))
+
+(def: (without_nil g!temp [nilable? outputT] output)
+  (-> Code Nilable Code Code)
+  (if nilable?
+    (` (let [(~ g!temp) (~ output)]
+         (if ("scheme object nil?" (~ g!temp))
+           #.None
+           (#.Some (~ g!temp)))))
+    (` (let [(~ g!temp) (~ output)]
+         (if (not ("scheme object nil?" (~ g!temp)))
+           (~ g!temp)
+           (.error! "Nil is an invalid value!"))))))
+
+(type: Import
+  (#Function Common_Method)
+  (#Constant Field))
+
+(def: import
+  (Parser Import)
+  ($_ <>.or
+      (.form ..common_method)
+      ..constant
+      ))
+
+(syntax: #export (try expression)
+  {#.doc (doc (case (try (risky_computation input))
+                (#.Right success)
+                (do_something success)
+
+                (#.Left error)
+                (recover_from_failure error)))}
+  (wrap (list (` ("lux try" ((~! io.io) (~ expression)))))))
+
+(def: (with_io with? without)
+  (-> Bit Code Code)
+  (if with?
+    (` (io.io (~ without)))
+    without))
+
+(def: (io_type io? rawT)
+  (-> Bit Code Code)
+  (if io?
+    (` (io.IO (~ rawT)))
+    rawT))
+
+(def: (with_try with? without_try)
+  (-> Bit Code Code)
+  (if with?
+    (` (..try (~ without_try)))
+    without_try))
+
+(def: (try_type try? rawT)
+  (-> Bit Code Code)
+  (if try?
+    (` (.Either .Text (~ rawT)))
+    rawT))
+
+(def: (make_function g!method g!temp source inputsT io? try? outputT)
+  (-> Code Code Code (List Nilable) Bit Bit Nilable Code)
+  (let [g!inputs (input_variables inputsT)]
+    (` (def: ((~ g!method)
+              [(~+ (list\map product.right g!inputs))])
+         (-> [(~+ (list\map nilable_type inputsT))]
+             (~ (|> (nilable_type outputT)
+                    (try_type try?)
+                    (io_type io?))))
+         (:assume
+          (~ (<| (with_io io?)
+                 (with_try try?)
+                 (without_nil g!temp outputT)
+                 (` ("scheme apply"
+                     (:coerce ..Function (~ source))
+                     (~+ (list\map (with_nil g!temp) g!inputs)))))))))))
+
+(syntax: #export (import: {import ..import})
+  (with_gensyms [g!temp]
+    (case import
+      (#Function [name alias inputsT io? try? outputT])
+      (let [imported (` ("scheme constant" (~ (code.text name))))]
+        (wrap (list (..make_function (code.local_identifier (maybe.default name alias))
+                                     g!temp
+                                     imported
+                                     inputsT
+                                     io?
+                                     try?
+                                     outputT))))
+
+      (#Constant [_ name alias fieldT])
+      (let [imported (` ("scheme constant" (~ (code.text name))))]
+        (wrap (list (` ((~! syntax:) ((~ (code.local_identifier (maybe.default name alias))))
+                        (\ (~! meta.monad) (~' wrap)
+                           (list (` (.:coerce (~ (nilable_type fieldT)) (~ imported))))))))))
+      )))
diff --git a/stdlib/source/lux/host.js.lux b/stdlib/source/lux/host.js.lux
deleted file mode 100644
index 8bfe8cc94..000000000
--- a/stdlib/source/lux/host.js.lux
+++ /dev/null
@@ -1,368 +0,0 @@
-(.module:
-  [lux #*
-   ["." meta]
-   [abstract
-    [monad (#+ do)]]
-   [control
-    ["." io]
-    ["<>" parser
-     ["" code (#+ Parser)]]]
-   [data
-    ["." product]
-    ["." maybe]
-    ["." text
-     ["%" format (#+ format)]]
-    [collection
-     ["." list ("#\." functor fold)]]]
-   [type
-    abstract]
-   [macro (#+ with_gensyms)
-    [syntax (#+ syntax:)]
-    ["." code]
-    ["." template]]])
-
-(abstract: #export (Object brand)
-  Any)
-
-(template []
-  [(with_expansions [ (template.identifier [ "'"])]
-     (abstract: 
-       Any
-       
-       (type: #export 
-         (Object ))))]
-
-  [Function]
-  [Symbol]
-  [Null]
-  [Undefined]
-  )
-
-(template [ ]
-  [(type: #export 
-     )]
-
-  [Boolean Bit]
-  [Number  Frac]
-  [String  Text]
-  )
-
-(type: Nullable
-  [Bit Code])
-
-(def: nullable
-  (Parser Nullable)
-  (let [token (' #?)]
-    (<| (<>.and (<>.parses? (.this! token)))
-        (<>.after (<>.not (.this! token)))
-        .any)))
-
-(type: Constructor
-  (List Nullable))
-
-(def: constructor
-  (Parser Constructor)
-  (.form (<>.after (.this! (' new))
-                      (.tuple (<>.some ..nullable)))))
-
-(type: Field
-  [Bit Text Nullable])
-
-(def: static!
-  (Parser Any)
-  (.this! (' #static)))
-
-(def: field
-  (Parser Field)
-  (.form ($_ <>.and
-                (<>.parses? ..static!)
-                .local_identifier
-                ..nullable)))
-
-(type: Common_Method
-  {#name Text
-   #alias (Maybe Text)
-   #inputs (List Nullable)
-   #io? Bit
-   #try? Bit
-   #output Nullable})
-
-(type: Static_Method Common_Method)
-(type: Virtual_Method Common_Method)
-
-(type: Method
-  (#Static Static_Method)
-  (#Virtual Virtual_Method))
-
-(def: common_method
-  (Parser Common_Method)
-  ($_ <>.and
-      .local_identifier
-      (<>.maybe (<>.after (.this! (' #as)) .local_identifier))
-      (.tuple (<>.some ..nullable))
-      (<>.parses? (.this! (' #io)))
-      (<>.parses? (.this! (' #try)))
-      ..nullable))
-
-(def: static_method
-  (<>.after ..static! ..common_method))
-
-(def: method
-  (Parser Method)
-  (.form (<>.or ..static_method
-                   ..common_method)))
-
-(type: Member
-  (#Constructor Constructor)
-  (#Field Field)
-  (#Method Method))
-
-(def: member
-  (Parser Member)
-  ($_ <>.or
-      ..constructor
-      ..field
-      ..method
-      ))
-
-(def: input_variables
-  (-> (List Nullable) (List [Bit Code]))
-  (|>> list.enumeration
-       (list\map (function (_ [idx [nullable? type]])
-                   [nullable? (|> idx %.nat code.local_identifier)]))))
-
-(def: (nullable_type [nullable? type])
-  (-> Nullable Code)
-  (if nullable?
-    (` (.Maybe (~ type)))
-    type))
-
-(def: (with_null g!temp [nullable? input])
-  (-> Code [Bit Code] Code)
-  (if nullable?
-    (` (case (~ input)
-         (#.Some (~ g!temp))
-         (~ g!temp)
-
-         #.None
-         ("js object null")))
-    input))
-
-(def: (without_null g!temp [nullable? outputT] output)
-  (-> Code Nullable Code Code)
-  (if nullable?
-    (` (let [(~ g!temp) (~ output)]
-         (if ("js object null?" (~ g!temp))
-           #.None
-           (#.Some (~ g!temp)))))
-    (` (let [(~ g!temp) (~ output)]
-         (if (not ("js object null?" (~ g!temp)))
-           (~ g!temp)
-           (.error! "Null is an invalid value."))))))
-
-(type: Import
-  (#Class [Text (List Member)])
-  (#Function Static_Method))
-
-(def: import
-  ($_ <>.or
-      ($_ <>.and
-          .local_identifier
-          (<>.some member))
-      (.form ..common_method)
-      ))
-
-(syntax: #export (try expression)
-  {#.doc (doc (case (try (risky_computation input))
-                (#.Right success)
-                (do_something success)
-
-                (#.Left error)
-                (recover_from_failure error)))}
-  (wrap (list (` ("lux try" ((~! io.io) (~ expression)))))))
-
-(def: (with_io with? without)
-  (-> Bit Code Code)
-  (if with?
-    (` (io.io (~ without)))
-    without))
-
-(def: (io_type io? rawT)
-  (-> Bit Code Code)
-  (if io?
-    (` (io.IO (~ rawT)))
-    rawT))
-
-(def: (with_try with? without_try)
-  (-> Bit Code Code)
-  (if with?
-    (` (..try (~ without_try)))
-    without_try))
-
-(def: (try_type try? rawT)
-  (-> Bit Code Code)
-  (if try?
-    (` (.Either .Text (~ rawT)))
-    rawT))
-
-(def: (make_function g!method g!temp source inputsT io? try? outputT)
-  (-> Code Code Text (List Nullable) Bit Bit Nullable Code)
-  (let [g!inputs (input_variables inputsT)]
-    (` (def: ((~ g!method)
-              [(~+ (list\map product.right g!inputs))])
-         (-> [(~+ (list\map nullable_type inputsT))]
-             (~ (|> (nullable_type outputT)
-                    (try_type try?)
-                    (io_type io?))))
-         (:assume
-          (~ (<| (with_io io?)
-                 (with_try try?)
-                 (without_null g!temp outputT)
-                 (` ("js apply"
-                     ("js constant" (~ (code.text source)))
-                     (~+ (list\map (with_null g!temp) g!inputs)))))))))))
-
-(syntax: #export (import: {import ..import})
-  (with_gensyms [g!temp]
-    (case import
-      (#Class [class members])
-      (with_gensyms [g!object]
-        (let [qualify (: (-> Text Code)
-                         (|>> (format class "::") code.local_identifier))
-              g!type (code.local_identifier class)
-              real_class (text.replace_all "/" "." class)]
-          (wrap (list& (` (type: (~ g!type)
-                            (..Object (primitive (~ (code.text real_class))))))
-                       (list\map (function (_ member)
-                                   (case member
-                                     (#Constructor inputsT)
-                                     (let [g!inputs (input_variables inputsT)]
-                                       (` (def: ((~ (qualify "new"))
-                                                 [(~+ (list\map product.right g!inputs))])
-                                            (-> [(~+ (list\map nullable_type inputsT))]
-                                                (~ g!type))
-                                            (:assume
-                                             ("js object new"
-                                              ("js constant" (~ (code.text real_class)))
-                                              [(~+ (list\map (with_null g!temp) g!inputs))])))))
-                                     
-                                     (#Field [static? field fieldT])
-                                     (if static?
-                                       (` ((~! syntax:) ((~ (qualify field)))
-                                           (\ (~! meta.monad) (~' wrap)
-                                              (list (` (.:coerce (~ (nullable_type fieldT))
-                                                                 ("js constant" (~ (code.text (format real_class "." field))))))))))
-                                       (` (def: ((~ (qualify field))
-                                                 (~ g!object))
-                                            (-> (~ g!type)
-                                                (~ (nullable_type fieldT)))
-                                            (:assume
-                                             (~ (without_null g!temp fieldT (` ("js object get" (~ (code.text field)) (~ g!object)))))))))
-                                     
-                                     (#Method method)
-                                     (case method
-                                       (#Static [method alias inputsT io? try? outputT])
-                                       (..make_function (qualify (maybe.default method alias))
-                                                        g!temp
-                                                        (format real_class "." method)
-                                                        inputsT
-                                                        io?
-                                                        try?
-                                                        outputT)
-                                       
-                                       (#Virtual [method alias inputsT io? try? outputT])
-                                       (let [g!inputs (input_variables inputsT)]
-                                         (` (def: ((~ (qualify (maybe.default method alias)))
-                                                   [(~+ (list\map product.right g!inputs))]
-                                                   (~ g!object))
-                                              (-> [(~+ (list\map nullable_type inputsT))]
-                                                  (~ g!type)
-                                                  (~ (|> (nullable_type outputT)
-                                                         (try_type try?)
-                                                         (io_type io?))))
-                                              (:assume
-                                               (~ (<| (with_io io?)
-                                                      (with_try try?)
-                                                      (without_null g!temp outputT)
-                                                      (` ("js object do"
-                                                          (~ (code.text method))
-                                                          (~ g!object)
-                                                          [(~+ (list\map (with_null g!temp) g!inputs))])))))))))))
-                                 members)))))
-      
-      (#Function [name alias inputsT io? try? outputT])
-      (wrap (list (..make_function (code.local_identifier (maybe.default name alias))
-                                   g!temp
-                                   name
-                                   inputsT
-                                   io?
-                                   try?
-                                   outputT)))
-      )))
-
-(template: #export (type_of object)
-  ("js type-of" object))
-
-(syntax: #export (constant type
-                           {[head tail] (.tuple (<>.and .local_identifier (<>.some .local_identifier)))})
-  (with_gensyms [g!_]
-    (let [constant (` ("js constant" (~ (code.text head))))]
-      (case tail
-        #.Nil
-        (wrap (list (` (: (.Maybe (~ type))
-                          (case (..type_of (~ constant))
-                            "undefined"
-                            #.None
-
-                            (~ g!_)
-                            (#.Some (:coerce (~ type) (~ constant))))))))
-        
-        (#.Cons [next tail])
-        (let [separator "."]
-          (wrap (list (` (: (.Maybe (~ type))
-                            (case (..type_of (~ constant))
-                              "undefined"
-                              #.None
-
-                              (~ g!_)
-                              (..constant (~ type) [(~ (code.local_identifier (format head "." next)))
-                                                    (~+ (list\map code.local_identifier tail))])))))))))))
-
-(template: (!defined? )
-  (.case (..constant Any )
-    #.None
-    .false
-
-    (#.Some _)
-    .true))
-
-(template [ ]
-  [(def: #export 
-     Bit
-     (!defined? ))]
-
-  [on_browser? [window]]
-  [on_nashorn? [java lang Object]]
-  )
-
-(def: #export on_node_js?
-  Bit
-  (case (..constant (Object Any) [process])
-    (#.Some process)
-    (case (:coerce Text
-                   ("js apply" ("js constant" "Object.prototype.toString.call") process))
-      "[object process]"
-      true
-
-      _
-      false)
-
-    #.None
-    false))
-
-(template: #export (closure  )
-  (.:coerce ..Function
-            (`` ("js function"
-                 (~~ (template.count ))
-                 (.function (_ [])
-                   )))))
diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/host.jvm.lux
deleted file mode 100644
index ad087f95b..000000000
--- a/stdlib/source/lux/host.jvm.lux
+++ /dev/null
@@ -1,2023 +0,0 @@
-(.module:
-  ["." lux (#- Type type int char)
-   ["#_." type ("#\." equivalence)]
-   [abstract
-    ["." monad (#+ Monad do)]
-    ["." enum]]
-   [control
-    ["." function]
-    ["." io]
-    ["." try (#+ Try)]
-    ["." exception (#+ Exception exception:)]
-    ["<>" parser ("#\." monad)
-     ["<.>" code (#+ Parser)]]]
-   [data
-    ["." maybe]
-    ["." product]
-    ["." text ("#\." equivalence)
-     ["%" format (#+ format)]]
-    [collection
-     ["." array]
-     ["." list ("#\." monad fold monoid)]
-     ["." dictionary (#+ Dictionary)]]]
-   [macro (#+ with_gensyms)
-    [syntax (#+ syntax:)]
-    ["." code]
-    ["." template]]
-   ["." meta
-    ["." annotation]]
-   [target
-    [jvm
-     [encoding
-      ["." name (#+ External)]]
-     ["." type (#+ Type Argument Typed)
-      ["." category (#+ Void Value' Value Return' Return Method Primitive Object Class Array Var Parameter Declaration)]
-      ["." box]
-      ["." descriptor]
-      ["." signature]
-      ["." reflection]
-      ["." parser]]]]])
-
-(def: internal
-  (-> External Text)
-  (|>> name.internal
-       name.read))
-
-(def: signature
-  (All [category]
-    (-> (Type category) Text))
-  (|>> type.signature signature.signature))
-
-(def: reflection
-  (All [category]
-    (-> (Type (<| Return' Value' category)) Text))
-  (|>> type.reflection reflection.reflection))
-
-(template [ ]
-  [(def: #export  .Type (#.Primitive  #.Nil))]
-
-  [Boolean   box.boolean]
-  [Byte      box.byte]
-  [Short     box.short]
-  [Integer   box.int]
-  [Long      box.long]
-  [Float     box.float]
-  [Double    box.double]
-  [Character box.char]
-  )
-
-(template [ ]
-  [(def: #export  .Type (#.Primitive (reflection.reflection ) #.Nil))]
-
-  ## Primitives
-  [boolean   reflection.boolean]
-  [byte      reflection.byte]
-  [short     reflection.short]
-  [int       reflection.int]
-  [long      reflection.long]
-  [float     reflection.float]
-  [double    reflection.double]
-  [char      reflection.char]
-  )
-
-(def: (get_static_field class field)
-  (-> Text Text Code)
-  (` ("jvm member get static"
-      (~ (code.text class))
-      (~ (code.text field)))))
-
-(def: (get_virtual_field class field object)
-  (-> Text Text Code Code)
-  (` ("jvm member get virtual"
-      (~ (code.text class))
-      (~ (code.text field))
-      (~ object))))
-
-(def: boxes
-  (Dictionary (Type Value) Text)
-  (|> (list [type.boolean box.boolean]
-            [type.byte    box.byte]
-            [type.short   box.short]
-            [type.int     box.int]
-            [type.long    box.long]
-            [type.float   box.float]
-            [type.double  box.double]
-            [type.char    box.char])
-      (dictionary.from_list type.hash)))
-
-(template [ 
 ]
-  [(def: ( unboxed boxed raw)
-     (-> (Type Value) Text Code Code)
-     (let [unboxed (..reflection unboxed)]
-       (` (|> (~ raw)
-              (: (primitive (~ (code.text 
))))
-              "jvm object cast"
-              (: (primitive (~ (code.text ))))))))]
-
-  [unbox boxed unboxed]
-  [box unboxed boxed]
-  )
-
-(template [   ]
-  [(template: #export ( value)
-     {#.doc (doc "Type converter."
-                 (: 
-                    ( (:  foo))))}
-     (|> value
-         (: )
-         "jvm object cast"
-         
-         "jvm object cast"
-         (: )))]
-
-  [byte_to_long    "jvm conversion byte-to-long"    ..Byte      ..Long]
-
-  [short_to_long   "jvm conversion short-to-long"   ..Short     ..Long]
-  
-  [double_to_int   "jvm conversion double-to-int"   ..Double    ..Integer]
-  [double_to_long  "jvm conversion double-to-long"  ..Double    ..Long]
-  [double_to_float "jvm conversion double-to-float" ..Double    ..Float]
-
-  [float_to_int    "jvm conversion float-to-int"    ..Float     ..Integer]
-  [float_to_long   "jvm conversion float-to-long"   ..Float     ..Long]
-  [float_to_double "jvm conversion float-to-double" ..Float     ..Double]
-  
-  [int_to_byte     "jvm conversion int-to-byte"     ..Integer   ..Byte]
-  [int_to_short    "jvm conversion int-to-short"    ..Integer   ..Short]
-  [int_to_long     "jvm conversion int-to-long"     ..Integer   ..Long]
-  [int_to_float    "jvm conversion int-to-float"    ..Integer   ..Float]
-  [int_to_double   "jvm conversion int-to-double"   ..Integer   ..Double]
-  [int_to_char     "jvm conversion int-to-char"     ..Integer   ..Character]
-
-  [long_to_byte    "jvm conversion long-to-byte"    ..Long      ..Byte]
-  [long_to_short   "jvm conversion long-to-short"   ..Long      ..Short]
-  [long_to_int     "jvm conversion long-to-int"     ..Long      ..Integer]
-  [long_to_float   "jvm conversion long-to-float"   ..Long      ..Float]
-  [long_to_double  "jvm conversion long-to-double"  ..Long      ..Double]
-
-  [char_to_byte    "jvm conversion char-to-byte"    ..Character ..Byte]
-  [char_to_short   "jvm conversion char-to-short"   ..Character ..Short]
-  [char_to_int     "jvm conversion char-to-int"     ..Character ..Integer]
-  [char_to_long    "jvm conversion char-to-long"    ..Character ..Long]
-  )
-
-(def: constructor_method_name "")
-
-(type: Primitive_Mode
-  #ManualPrM
-  #AutoPrM)
-
-(type: Privacy
-  #PublicP
-  #PrivateP
-  #ProtectedP
-  #DefaultP)
-
-(type: StateModifier
-  #VolatileSM
-  #FinalSM
-  #DefaultSM)
-
-(type: InheritanceModifier
-  #FinalIM
-  #AbstractIM
-  #DefaultIM)
-
-(type: Class_Kind
-  #Class
-  #Interface)
-
-(type: StackFrame (primitive "java/lang/StackTraceElement"))
-(type: StackTrace (array.Array StackFrame))
-
-(type: Annotation_Parameter
-  [Text Code])
-
-(type: Annotation
-  {#ann_name   Text
-   #ann_params (List Annotation_Parameter)})
-
-(type: Member_Declaration
-  {#member_name Text
-   #member_privacy Privacy
-   #member_anns (List Annotation)})
-
-(type: FieldDecl
-  (#ConstantField (Type Value) Code)
-  (#VariableField StateModifier (Type Value)))
-
-(type: MethodDecl
-  {#method_tvars  (List (Type Var))
-   #method_inputs (List (Type Value))
-   #method_output (Type Return)
-   #method_exs    (List (Type Class))})
-
-(type: Method_Definition
-  (#ConstructorMethod [Bit
-                       (List (Type Var))
-                       Text
-                       (List Argument)
-                       (List (Typed Code))
-                       Code
-                       (List (Type Class))])
-  (#VirtualMethod [Bit
-                   Bit
-                   (List (Type Var))
-                   Text
-                   (List Argument)
-                   (Type Return)
-                   Code
-                   (List (Type Class))])
-  (#OverridenMethod [Bit
-                     (Type Declaration)
-                     (List (Type Var))
-                     Text
-                     (List Argument)
-                     (Type Return)
-                     Code
-                     (List (Type Class))])
-  (#StaticMethod [Bit
-                  (List (Type Var))
-                  (List Argument)
-                  (Type Return)
-                  Code
-                  (List (Type Class))])
-  (#AbstractMethod [(List (Type Var))
-                    (List Argument)
-                    (Type Return)
-                    (List (Type Class))])
-  (#NativeMethod [(List (Type Var))
-                  (List Argument)
-                  (Type Return)
-                  (List (Type Class))]))
-
-(type: Partial_Call
-  {#pc_method Name
-   #pc_args   (List Code)})
-
-(type: ImportMethodKind
-  #StaticIMK
-  #VirtualIMK)
-
-(type: ImportMethodCommons
-  {#import_member_mode   Primitive_Mode
-   #import_member_alias  Text
-   #import_member_kind   ImportMethodKind
-   #import_member_tvars  (List (Type Var))
-   #import_member_args   (List [Bit (Type Value)])
-   #import_member_maybe? Bit
-   #import_member_try?   Bit
-   #import_member_io?    Bit})
-
-(type: ImportConstructorDecl
-  {})
-
-(type: ImportMethodDecl
-  {#import_method_name    Text
-   #import_method_return  (Type Return)})
-
-(type: ImportFieldDecl
-  {#import_field_mode    Primitive_Mode
-   #import_field_name    Text
-   #import_field_static? Bit
-   #import_field_maybe?  Bit
-   #import_field_setter? Bit
-   #import_field_type    (Type Value)})
-
-(type: Import_Member_Declaration
-  (#EnumDecl        (List Text))
-  (#ConstructorDecl [ImportMethodCommons ImportConstructorDecl])
-  (#MethodDecl      [ImportMethodCommons ImportMethodDecl])
-  (#FieldAccessDecl ImportFieldDecl))
-
-(def: (primitive_type mode type)
-  (-> Primitive_Mode (Type Primitive) Code)
-  (case mode
-    #ManualPrM
-    (cond (\ type.equivalence = type.boolean type) (` ..Boolean)
-          (\ type.equivalence = type.byte type) (` ..Byte)
-          (\ type.equivalence = type.short type) (` ..Short)
-          (\ type.equivalence = type.int type) (` ..Integer)
-          (\ type.equivalence = type.long type) (` ..Long)
-          (\ type.equivalence = type.float type) (` ..Float)
-          (\ type.equivalence = type.double type) (` ..Double)
-          (\ type.equivalence = type.char type) (` ..Character)
-          ## else
-          (undefined))
-    
-    #AutoPrM
-    (cond (\ type.equivalence = type.boolean type)
-          (` .Bit)
-          
-          (or (\ type.equivalence = type.short type)
-              (\ type.equivalence = type.byte type)
-              (\ type.equivalence = type.int type)
-              (\ type.equivalence = type.long type))
-          (` .Int)
-          
-          (or (\ type.equivalence = type.float type)
-              (\ type.equivalence = type.double type))
-          (` .Frac)
-
-          (\ type.equivalence = type.char type)
-          (` .Nat)
-
-          ## else
-          (undefined))))
-
-(def: (parameter_type type)
-  (-> (Type Parameter) Code)
-  (`` (<| (~~ (template [  ]
-                [(case ( type)
-                   (#.Some )
-                   
-
-                   #.None)]
-
-                [parser.var? name (code.identifier ["" name])]
-                [parser.wildcard? _ (` .Any)]
-                [parser.lower? _ (` .Any)]
-                [parser.upper? limit (parameter_type limit)]
-                [parser.class? [name parameters]
-                 (` (.primitive (~ (code.text name))
-                                [(~+ (list\map parameter_type parameters))]))]))
-          ## else
-          (undefined)
-          )))
-
-(def: (value_type mode type)
-  (-> Primitive_Mode (Type Value) Code)
-  (`` (<| (~~ (template [  ]
-                [(case ( type)
-                   (#.Some )
-                   
-
-                   #.None)]
-
-                [parser.parameter? type (parameter_type type)]
-                [parser.primitive? type (primitive_type mode type)]
-                [parser.array? elementT (case (parser.primitive? elementT)
-                                          (#.Some elementT)
-                                          (` (#.Primitive (~ (code.text (..reflection (type.array elementT)))) #.Nil))
-                                          
-                                          #.None
-                                          (` (#.Primitive (~ (code.text array.type_name))
-                                                          (#.Cons (~ (value_type mode elementT)) #.Nil))))]))
-          (undefined)
-          )))
-
-(def: declaration_type$
-  (-> (Type Declaration) Code)
-  (|>> ..signature code.text))
-
-(def: (make_get_const_parser class_name field_name)
-  (-> Text Text (Parser Code))
-  (do <>.monad
-    [#let [dotted_name (format "::" field_name)]
-     _ (.this! (code.identifier ["" dotted_name]))]
-    (wrap (get_static_field class_name field_name))))
-
-(def: (make_get_var_parser class_name field_name)
-  (-> Text Text (Parser Code))
-  (do <>.monad
-    [#let [dotted_name (format "::" field_name)]
-     _ (.this! (code.identifier ["" dotted_name]))]
-    (wrap (get_virtual_field class_name field_name (' _jvm_this)))))
-
-(def: (make_put_var_parser class_name field_name)
-  (-> Text Text (Parser Code))
-  (do <>.monad
-    [#let [dotted_name (format "::" field_name)]
-     [_ _ value] (: (Parser [Any Any Code])
-                    (.form ($_ <>.and (.this! (' :=)) (.this! (code.identifier ["" dotted_name])) .any)))]
-    (wrap (`' ((~ (code.text (format "jvm putfield" ":" class_name ":" field_name))) _jvm_this (~ value))))))
-
-(def: (pre_walk_replace f input)
-  (-> (-> Code Code) Code Code)
-  (case (f input)
-    (^template []
-      [[meta ( parts)]
-       [meta ( (list\map (pre_walk_replace f) parts))]])
-    ([#.Form]
-     [#.Tuple])
-    
-    [meta (#.Record pairs)]
-    [meta (#.Record (list\map (: (-> [Code Code] [Code Code])
-                                 (function (_ [key val])
-                                   [(pre_walk_replace f key) (pre_walk_replace f val)]))
-                              pairs))]
-    
-    ast'
-    ast'))
-
-(def: (parser->replacer p ast)
-  (-> (Parser Code) (-> Code Code))
-  (case (<>.run p (list ast))
-    (#.Right [#.Nil ast'])
-    ast'
-
-    _
-    ast
-    ))
-
-(def: (field->parser class_name [[field_name _ _] field])
-  (-> Text [Member_Declaration FieldDecl] (Parser Code))
-  (case field
-    (#ConstantField _)
-    (make_get_const_parser class_name field_name)
-    
-    (#VariableField _)
-    (<>.either (make_get_var_parser class_name field_name)
-               (make_put_var_parser class_name field_name))))
-
-(def: (decorate_input [class value])
-  (-> [(Type Value) Code] Code)
-  (` [(~ (code.text (..signature class))) (~ value)]))
-
-(def: (make_constructor_parser class_name arguments)
-  (-> Text (List Argument) (Parser Code))
-  (do <>.monad
-    [args (: (Parser (List Code))
-             (.form (<>.after (.this! (' ::new!))
-                                    (.tuple (<>.exactly (list.size arguments) .any)))))]
-    (wrap (` ("jvm member invoke constructor" (~ (code.text class_name))
-              (~+ (|> args
-                      (list.zip/2 (list\map product.right arguments))
-                      (list\map ..decorate_input))))))))
-
-(def: (make_static_method_parser class_name method_name arguments)
-  (-> Text Text (List Argument) (Parser Code))
-  (do <>.monad
-    [#let [dotted_name (format "::" method_name "!")]
-     args (: (Parser (List Code))
-             (.form (<>.after (.this! (code.identifier ["" dotted_name]))
-                                    (.tuple (<>.exactly (list.size arguments) .any)))))]
-    (wrap (` ("jvm member invoke static" (~ (code.text class_name)) (~ (code.text method_name))
-              (~+ (|> args
-                      (list.zip/2 (list\map product.right arguments))
-                      (list\map ..decorate_input))))))))
-
-(template [ ]
-  [(def: ( class_name method_name arguments)
-     (-> Text Text (List Argument) (Parser Code))
-     (do <>.monad
-       [#let [dotted_name (format "::" method_name "!")]
-        args (: (Parser (List Code))
-                (.form (<>.after (.this! (code.identifier ["" dotted_name]))
-                                       (.tuple (<>.exactly (list.size arguments) .any)))))]
-       (wrap (` ( (~ (code.text class_name)) (~ (code.text method_name))
-                          (~' _jvm_this)
-                          (~+ (|> args
-                                  (list.zip/2 (list\map product.right arguments))
-                                  (list\map ..decorate_input))))))))]
-
-  [make_special_method_parser "jvm member invoke special"]
-  [make_virtual_method_parser "jvm member invoke virtual"]
-  )
-
-(def: (method->parser class_name [[method_name _ _] meth_def])
-  (-> Text [Member_Declaration Method_Definition] (Parser Code))
-  (case meth_def
-    (#ConstructorMethod strict? type_vars self_name args constructor_args return_expr exs)
-    (make_constructor_parser class_name args)
-    
-    (#StaticMethod strict? type_vars args return_type return_expr exs)
-    (make_static_method_parser class_name method_name args)
-    
-    (^or (#VirtualMethod final? strict? type_vars self_name args return_type return_expr exs)
-         (#OverridenMethod strict? owner_class type_vars self_name args return_type return_expr exs))
-    (make_special_method_parser class_name method_name args)
-
-    (#AbstractMethod type_vars args return_type exs)
-    (make_virtual_method_parser class_name method_name args)
-
-    (#NativeMethod type_vars args return_type exs)
-    (make_virtual_method_parser class_name method_name args)))
-
-(def: privacy_modifier^
-  (Parser Privacy)
-  (let [(^open ".") <>.monad]
-    ($_ <>.or
-        (.this! (' #public))
-        (.this! (' #private))
-        (.this! (' #protected))
-        (wrap []))))
-
-(def: inheritance_modifier^
-  (Parser InheritanceModifier)
-  (let [(^open ".") <>.monad]
-    ($_ <>.or
-        (.this! (' #final))
-        (.this! (' #abstract))
-        (wrap []))))
-
-(exception: #export (class_names_cannot_contain_periods {name Text})
-  (exception.report
-   ["Name" (%.text name)]))
-
-(exception: #export (class_name_cannot_be_a_type_variable {name Text}
-                                                          {type_vars (List (Type Var))})
-  (exception.report
-   ["Name" (%.text name)]
-   ["Type Variables" (exception.enumerate parser.name type_vars)]))
-
-(def: (assert exception payload test)
-  (All [e] (-> (Exception e) e Bit (Parser Any)))
-  (<>.assert (exception.construct exception payload)
-             test))
-
-(def: (assert_valid_class_name type_vars name)
-  (-> (List (Type Var)) External (Parser Any))
-  (do <>.monad
-    [_ (..assert ..class_names_cannot_contain_periods [name]
-                 (not (text.contains? name.external_separator name)))]
-    (..assert ..class_name_cannot_be_a_type_variable [name type_vars]
-              (not (list.member? text.equivalence
-                                 (list\map parser.name type_vars)
-                                 name)))))
-
-(def: (valid_class_name type_vars)
-  (-> (List (Type Var)) (Parser External))
-  (do <>.monad
-    [name .local_identifier
-     _ (assert_valid_class_name type_vars name)]
-    (wrap name)))
-
-(def: (class^' parameter^ type_vars)
-  (-> (-> (List (Type Var)) (Parser (Type Parameter)))
-      (-> (List (Type Var)) (Parser (Type Class))))
-  (do <>.monad
-    [[name parameters] (: (Parser [External (List (Type Parameter))])
-                          ($_ <>.either
-                              (<>.and (valid_class_name type_vars)
-                                      (<>\wrap (list)))
-                              (.form (<>.and .local_identifier
-                                                   (<>.some (parameter^ type_vars))))))]
-    (wrap (type.class (name.sanitize name) parameters))))
-
-(exception: #export (unexpected_type_variable {name Text}
-                                              {type_vars (List (Type Var))})
-  (exception.report
-   ["Unexpected Type Variable" (%.text name)]
-   ["Expected Type Variables" (exception.enumerate parser.name type_vars)]))
-
-(def: (variable^ type_vars)
-  (-> (List (Type Var)) (Parser (Type Parameter)))
-  (do <>.monad
-    [name .local_identifier
-     _ (..assert ..unexpected_type_variable [name type_vars]
-                 (list.member? text.equivalence (list\map parser.name type_vars) name))]
-    (wrap (type.var name))))
-
-(def: wildcard^
-  (Parser (Type Parameter))
-  (do <>.monad
-    [_ (.this! (' ?))]
-    (wrap type.wildcard)))
-
-(template [  ]
-  [(def: 
-     (-> (Parser (Type Class)) (Parser (Type Parameter)))
-     (|>> (<>.after (.this! (' )))
-          (<>.after ..wildcard^)
-          .tuple
-          (\ <>.monad map )))]
-
-  [upper^ < type.upper]
-  [lower^ > type.lower]
-  )
-
-(def: (parameter^ type_vars)
-  (-> (List (Type Var)) (Parser (Type Parameter)))
-  (<>.rec
-   (function (_ recur^)
-     (let [class^ (..class^' parameter^ type_vars)]
-       ($_ <>.either
-           (..variable^ type_vars)
-           ..wildcard^
-           (upper^ class^)
-           (lower^ class^)
-           class^
-           )))))
-
-(def: (itself^ type)
-  (All [category]
-    (-> (Type (<| Return' Value' category))
-        (Parser (Type (<| Return' Value' category)))))
-  (do <>.monad
-    [_ (.identifier! ["" (..reflection type)])]
-    (wrap type)))
-
-(def: primitive^
-  (Parser (Type Primitive))
-  ($_ <>.either
-      (itself^ type.boolean)
-      (itself^ type.byte)
-      (itself^ type.short)
-      (itself^ type.int)
-      (itself^ type.long)
-      (itself^ type.float)
-      (itself^ type.double)
-      (itself^ type.char)
-      ))
-
-(def: array^
-  (-> (Parser (Type Value)) (Parser (Type Array)))
-  (|>> .tuple
-       (\ <>.monad map type.array)))
-
-(def: (type^ type_vars)
-  (-> (List (Type Var)) (Parser (Type Value)))
-  (<>.rec
-   (function (_ type^)
-     ($_ <>.either
-         ..primitive^
-         (..parameter^ type_vars)
-         (..array^ type^)
-         ))))
-
-(def: void^
-  (Parser (Type Void))
-  (do <>.monad
-    [_ (.identifier! ["" (reflection.reflection reflection.void)])]
-    (wrap type.void)))
-
-(def: (return^ type_vars)
-  (-> (List (Type Var)) (Parser (Type Return)))
-  (<>.either ..void^
-             (..type^ type_vars)))
-
-(def: var^
-  (Parser (Type Var))
-  (\ <>.monad map type.var .local_identifier))
-
-(def: vars^
-  (Parser (List (Type Var)))
-  (.tuple (<>.some var^)))
-
-(def: declaration^
-  (Parser (Type Declaration))
-  (do <>.monad
-    [[name variables] (: (Parser [External (List (Type Var))])
-                         (<>.either (<>.and (valid_class_name (list))
-                                            (<>\wrap (list)))
-                                    (.form (<>.and (valid_class_name (list))
-                                                         (<>.some var^)))
-                                    ))]
-    (wrap (type.declaration name variables))))
-
-(def: (class^ type_vars)
-  (-> (List (Type Var)) (Parser (Type Class)))
-  (class^' parameter^ type_vars))
-
-(def: annotation_parameters^
-  (Parser (List Annotation_Parameter))
-  (.record (<>.some (<>.and .local_tag .any))))
-
-(def: annotation^
-  (Parser Annotation)
-  (<>.either (do <>.monad
-               [ann_name .local_identifier]
-               (wrap [ann_name (list)]))
-             (.form (<>.and .local_identifier
-                                  annotation_parameters^))))
-
-(def: annotations^'
-  (Parser (List Annotation))
-  (do <>.monad
-    [_ (.this! (' #ann))]
-    (.tuple (<>.some ..annotation^))))
-
-(def: annotations^
-  (Parser (List Annotation))
-  (do <>.monad
-    [anns?? (<>.maybe ..annotations^')]
-    (wrap (maybe.default (list) anns??))))
-
-(def: (throws_decl^ type_vars)
-  (-> (List (Type Var)) (Parser (List (Type Class))))
-  (<| (<>.default (list))
-      (do <>.monad
-        [_ (.this! (' #throws))]
-        (.tuple (<>.some (..class^ type_vars))))))
-
-(def: (method_decl^ type_vars)
-  (-> (List (Type Var)) (Parser [Member_Declaration MethodDecl]))
-  (.form (do <>.monad
-                 [tvars (<>.default (list) ..vars^)
-                  name .local_identifier
-                  anns ..annotations^
-                  inputs (.tuple (<>.some (..type^ type_vars)))
-                  output (..return^ type_vars)
-                  exs (throws_decl^ type_vars)]
-                 (wrap [[name #PublicP anns] {#method_tvars tvars
-                                              #method_inputs inputs
-                                              #method_output output
-                                              #method_exs    exs}]))))
-
-(def: state_modifier^
-  (Parser StateModifier)
-  ($_ <>.or
-      (.this! (' #volatile))
-      (.this! (' #final))
-      (\ <>.monad wrap [])))
-
-(def: (field_decl^ type_vars)
-  (-> (List (Type Var)) (Parser [Member_Declaration FieldDecl]))
-  (<>.either (.form (do <>.monad
-                            [_ (.this! (' #const))
-                             name .local_identifier
-                             anns ..annotations^
-                             type (..type^ type_vars)
-                             body .any]
-                            (wrap [[name #PublicP anns] (#ConstantField [type body])])))
-             (.form (do <>.monad
-                            [pm privacy_modifier^
-                             sm state_modifier^
-                             name .local_identifier
-                             anns ..annotations^
-                             type (..type^ type_vars)]
-                            (wrap [[name pm anns] (#VariableField [sm type])])))))
-
-(def: (argument^ type_vars)
-  (-> (List (Type Var)) (Parser Argument))
-  (.record (<>.and .local_identifier
-                         (..type^ type_vars))))
-
-(def: (arguments^ type_vars)
-  (-> (List (Type Var)) (Parser (List Argument)))
-  (<>.some (..argument^ type_vars)))
-
-(def: (constructor_arg^ type_vars)
-  (-> (List (Type Var)) (Parser (Typed Code)))
-  (.record (<>.and (..type^ type_vars) .any)))
-
-(def: (constructor_args^ type_vars)
-  (-> (List (Type Var)) (Parser (List (Typed Code))))
-  (.tuple (<>.some (..constructor_arg^ type_vars))))
-
-(def: (constructor_method^ class_vars)
-  (-> (List (Type Var)) (Parser [Member_Declaration Method_Definition]))
-  (.form (do <>.monad
-                 [pm privacy_modifier^
-                  strict_fp? (<>.parses? (.this! (' #strict)))
-                  method_vars (<>.default (list) ..vars^)
-                  #let [total_vars (list\compose class_vars method_vars)]
-                  [_ self_name arguments] (.form ($_ <>.and
-                                                           (.this! (' new))
-                                                           .local_identifier
-                                                           (..arguments^ total_vars)))
-                  constructor_args (..constructor_args^ total_vars)
-                  exs (throws_decl^ total_vars)
-                  annotations ..annotations^
-                  body .any]
-                 (wrap [{#member_name constructor_method_name
-                         #member_privacy pm
-                         #member_anns annotations}
-                        (#ConstructorMethod strict_fp? method_vars self_name arguments constructor_args body exs)]))))
-
-(def: (virtual_method_def^ class_vars)
-  (-> (List (Type Var)) (Parser [Member_Declaration Method_Definition]))
-  (.form (do <>.monad
-                 [pm privacy_modifier^
-                  strict_fp? (<>.parses? (.this! (' #strict)))
-                  final? (<>.parses? (.this! (' #final)))
-                  method_vars (<>.default (list) ..vars^)
-                  #let [total_vars (list\compose class_vars method_vars)]
-                  [name self_name arguments] (.form ($_ <>.and
-                                                              .local_identifier
-                                                              .local_identifier
-                                                              (..arguments^ total_vars)))
-                  return_type (..return^ total_vars)
-                  exs (throws_decl^ total_vars)
-                  annotations ..annotations^
-                  body .any]
-                 (wrap [{#member_name name
-                         #member_privacy pm
-                         #member_anns annotations}
-                        (#VirtualMethod final? strict_fp? method_vars self_name arguments return_type body exs)]))))
-
-(def: overriden_method_def^
-  (Parser [Member_Declaration Method_Definition])
-  (.form (do <>.monad
-                 [strict_fp? (<>.parses? (.this! (' #strict)))
-                  owner_class ..declaration^
-                  method_vars (<>.default (list) ..vars^)
-                  #let [total_vars (list\compose (product.right (parser.declaration owner_class))
-                                                 method_vars)]
-                  [name self_name arguments] (.form ($_ <>.and
-                                                              .local_identifier
-                                                              .local_identifier
-                                                              (..arguments^ total_vars)))
-                  return_type (..return^ total_vars)
-                  exs (throws_decl^ total_vars)
-                  annotations ..annotations^
-                  body .any]
-                 (wrap [{#member_name name
-                         #member_privacy #PublicP
-                         #member_anns annotations}
-                        (#OverridenMethod strict_fp? owner_class method_vars self_name arguments return_type body exs)]))))
-
-(def: static_method_def^
-  (Parser [Member_Declaration Method_Definition])
-  (.form (do <>.monad
-                 [pm privacy_modifier^
-                  strict_fp? (<>.parses? (.this! (' #strict)))
-                  _ (.this! (' #static))
-                  method_vars (<>.default (list) ..vars^)
-                  #let [total_vars method_vars]
-                  [name arguments] (.form (<>.and .local_identifier
-                                                        (..arguments^ total_vars)))
-                  return_type (..return^ total_vars)
-                  exs (throws_decl^ total_vars)
-                  annotations ..annotations^
-                  body .any]
-                 (wrap [{#member_name name
-                         #member_privacy pm
-                         #member_anns annotations}
-                        (#StaticMethod strict_fp? method_vars arguments return_type body exs)]))))
-
-(def: abstract_method_def^
-  (Parser [Member_Declaration Method_Definition])
-  (.form (do <>.monad
-                 [pm privacy_modifier^
-                  _ (.this! (' #abstract))
-                  method_vars (<>.default (list) ..vars^)
-                  #let [total_vars method_vars]
-                  [name arguments] (.form (<>.and .local_identifier
-                                                        (..arguments^ total_vars)))
-                  return_type (..return^ total_vars)
-                  exs (throws_decl^ total_vars)
-                  annotations ..annotations^]
-                 (wrap [{#member_name name
-                         #member_privacy pm
-                         #member_anns annotations}
-                        (#AbstractMethod method_vars arguments return_type exs)]))))
-
-(def: native_method_def^
-  (Parser [Member_Declaration Method_Definition])
-  (.form (do <>.monad
-                 [pm privacy_modifier^
-                  _ (.this! (' #native))
-                  method_vars (<>.default (list) ..vars^)
-                  #let [total_vars method_vars]
-                  [name arguments] (.form (<>.and .local_identifier
-                                                        (..arguments^ total_vars)))
-                  return_type (..return^ total_vars)
-                  exs (throws_decl^ total_vars)
-                  annotations ..annotations^]
-                 (wrap [{#member_name name
-                         #member_privacy pm
-                         #member_anns annotations}
-                        (#NativeMethod method_vars arguments return_type exs)]))))
-
-(def: (method_def^ class_vars)
-  (-> (List (Type Var)) (Parser [Member_Declaration Method_Definition]))
-  ($_ <>.either
-      (..constructor_method^ class_vars)
-      (..virtual_method_def^ class_vars)
-      ..overriden_method_def^
-      ..static_method_def^
-      ..abstract_method_def^
-      ..native_method_def^))
-
-(def: partial_call^
-  (Parser Partial_Call)
-  (.form (<>.and .identifier (<>.some .any))))
-
-(def: class_kind^
-  (Parser Class_Kind)
-  (<>.either (do <>.monad
-               [_ (.this! (' #class))]
-               (wrap #Class))
-             (do <>.monad
-               [_ (.this! (' #interface))]
-               (wrap #Interface))
-             ))
-
-(def: import_member_alias^
-  (Parser (Maybe Text))
-  (<>.maybe (do <>.monad
-              [_ (.this! (' #as))]
-              .local_identifier)))
-
-(def: (import_member_args^ type_vars)
-  (-> (List (Type Var)) (Parser (List [Bit (Type Value)])))
-  (.tuple (<>.some (<>.and (<>.parses? (.tag! ["" "?"]))
-                                 (..type^ type_vars)))))
-
-(def: import_member_return_flags^
-  (Parser [Bit Bit Bit])
-  ($_ <>.and
-      (<>.parses? (.this! (' #io)))
-      (<>.parses? (.this! (' #try)))
-      (<>.parses? (.this! (' #?)))))
-
-(def: primitive_mode^
-  (Parser Primitive_Mode)
-  (<>.or (.tag! ["" "manual"])
-         (.tag! ["" "auto"])))
-
-(def: (import_member_decl^ owner_vars)
-  (-> (List (Type Var)) (Parser Import_Member_Declaration))
-  ($_ <>.either
-      (.form (do <>.monad
-                     [_ (.this! (' #enum))
-                      enum_members (<>.some .local_identifier)]
-                     (wrap (#EnumDecl enum_members))))
-      (.form (do <>.monad
-                     [tvars (<>.default (list) ..vars^)
-                      _ (.identifier! ["" "new"])
-                      ?alias import_member_alias^
-                      #let [total_vars (list\compose owner_vars tvars)]
-                      ?prim_mode (<>.maybe primitive_mode^)
-                      args (..import_member_args^ total_vars)
-                      [io? try? maybe?] import_member_return_flags^]
-                     (wrap (#ConstructorDecl [{#import_member_mode    (maybe.default #AutoPrM ?prim_mode)
-                                               #import_member_alias   (maybe.default "new" ?alias)
-                                               #import_member_kind    #VirtualIMK
-                                               #import_member_tvars   tvars
-                                               #import_member_args    args
-                                               #import_member_maybe?  maybe?
-                                               #import_member_try?    try?
-                                               #import_member_io?     io?}
-                                              {}]))
-                     ))
-      (.form (do <>.monad
-                     [kind (: (Parser ImportMethodKind)
-                              (<>.or (.tag! ["" "static"])
-                                     (wrap [])))
-                      tvars (<>.default (list) ..vars^)
-                      name .local_identifier
-                      ?alias import_member_alias^
-                      #let [total_vars (list\compose owner_vars tvars)]
-                      ?prim_mode (<>.maybe primitive_mode^)
-                      args (..import_member_args^ total_vars)
-                      [io? try? maybe?] import_member_return_flags^
-                      return (..return^ total_vars)]
-                     (wrap (#MethodDecl [{#import_member_mode    (maybe.default #AutoPrM ?prim_mode)
-                                          #import_member_alias   (maybe.default name ?alias)
-                                          #import_member_kind    kind
-                                          #import_member_tvars   tvars
-                                          #import_member_args    args
-                                          #import_member_maybe?  maybe?
-                                          #import_member_try?    try?
-                                          #import_member_io?     io?}
-                                         {#import_method_name    name
-                                          #import_method_return  return}]))))
-      (.form (do <>.monad
-                     [static? (<>.parses? (.this! (' #static)))
-                      name .local_identifier
-                      ?prim_mode (<>.maybe primitive_mode^)
-                      gtype (..type^ owner_vars)
-                      maybe? (<>.parses? (.this! (' #?)))
-                      setter? (<>.parses? (.this! (' #!)))]
-                     (wrap (#FieldAccessDecl {#import_field_mode    (maybe.default #AutoPrM ?prim_mode)
-                                              #import_field_name    name
-                                              #import_field_static? static?
-                                              #import_field_maybe?  maybe?
-                                              #import_field_setter? setter?
-                                              #import_field_type    gtype}))))
-      ))
-
-(def: bundle
-  (-> (List (Type Var)) (Parser [Text (List Import_Member_Declaration)]))
-  (|>> ..import_member_decl^
-       <>.some
-       (<>.and .text)
-       .tuple))
-
-(def: (privacy_modifier$ pm)
-  (-> Privacy Code)
-  (case pm
-    #PublicP    (code.text "public")
-    #PrivateP   (code.text "private")
-    #ProtectedP (code.text "protected")
-    #DefaultP   (code.text "default")))
-
-(def: (inheritance_modifier$ im)
-  (-> InheritanceModifier Code)
-  (case im
-    #FinalIM    (code.text "final")
-    #AbstractIM (code.text "abstract")
-    #DefaultIM  (code.text "default")))
-
-(def: (annotation_parameter$ [name value])
-  (-> Annotation_Parameter Code)
-  (` [(~ (code.text name)) (~ value)]))
-
-(def: (annotation$ [name params])
-  (-> Annotation Code)
-  (` ((~ (code.text name)) (~+ (list\map annotation_parameter$ params)))))
-
-(template [ ]
-  [(def: 
-     (-> (Type ) Code)
-     (|>> ..signature code.text))]
-
-  [var$ Var]
-  [parameter$ Parameter]
-  [value$ Value]
-  [return$ Return]
-  [declaration$ Declaration]
-  [class$ Class]
-  )
-
-(def: var$'
-  (-> (Type Var) Code)
-  (|>> ..signature code.local_identifier))
-
-(def: (method_decl$ [[name pm anns] method_decl])
-  (-> [Member_Declaration MethodDecl] Code)
-  (let [(^slots [#method_tvars #method_inputs #method_output #method_exs]) method_decl]
-    (` ((~ (code.text name))
-        [(~+ (list\map annotation$ anns))]
-        [(~+ (list\map var$ method_tvars))]
-        [(~+ (list\map class$ method_exs))]
-        [(~+ (list\map value$ method_inputs))]
-        (~ (return$ method_output))))))
-
-(def: (state_modifier$ sm)
-  (-> StateModifier Code)
-  (case sm
-    #VolatileSM (' "volatile")
-    #FinalSM    (' "final")
-    #DefaultSM  (' "default")))
-
-(def: (field_decl$ [[name pm anns] field])
-  (-> [Member_Declaration FieldDecl] Code)
-  (case field
-    (#ConstantField class value)
-    (` ("constant" (~ (code.text name))
-        [(~+ (list\map annotation$ anns))]
-        (~ (value$ class))
-        (~ value)
-        ))
-
-    (#VariableField sm class)
-    (` ("variable" (~ (code.text name))
-        (~ (privacy_modifier$ pm))
-        (~ (state_modifier$ sm))
-        [(~+ (list\map annotation$ anns))]
-        (~ (value$ class))
-        ))
-    ))
-
-(def: (argument$ [name type])
-  (-> Argument Code)
-  (` [(~ (code.text name)) (~ (value$ type))]))
-
-(def: (constructor_arg$ [class term])
-  (-> (Typed Code) Code)
-  (` [(~ (value$ class)) (~ term)]))
-
-(def: (method_def$ replacer super_class [[name pm anns] method_def])
-  (-> (-> Code Code) (Type Class) [Member_Declaration Method_Definition] Code)
-  (case method_def
-    (#ConstructorMethod strict_fp? type_vars self_name arguments constructor_args body exs)
-    (` ("init"
-        (~ (privacy_modifier$ pm))
-        (~ (code.bit strict_fp?))
-        [(~+ (list\map annotation$ anns))]
-        [(~+ (list\map var$ type_vars))]
-        [(~+ (list\map class$ exs))]
-        (~ (code.text self_name))
-        [(~+ (list\map argument$ arguments))]
-        [(~+ (list\map constructor_arg$ constructor_args))]
-        (~ (pre_walk_replace replacer body))
-        ))
-    
-    (#VirtualMethod final? strict_fp? type_vars self_name arguments return_type body exs)
-    (` ("virtual"
-        (~ (code.text name))
-        (~ (privacy_modifier$ pm))
-        (~ (code.bit final?))
-        (~ (code.bit strict_fp?))
-        [(~+ (list\map annotation$ anns))]
-        [(~+ (list\map var$ type_vars))]
-        (~ (code.text self_name))
-        [(~+ (list\map argument$ arguments))]
-        (~ (return$ return_type))
-        [(~+ (list\map class$ exs))]
-        (~ (pre_walk_replace replacer body))))
-    
-    (#OverridenMethod strict_fp? declaration type_vars self_name arguments return_type body exs)
-    (let [super_replacer (parser->replacer (.form (do <>.monad
-                                                          [_ (.this! (' ::super!))
-                                                           args (.tuple (<>.exactly (list.size arguments) .any))]
-                                                          (wrap (` ("jvm member invoke special"
-                                                                    (~ (code.text (product.left (parser.read_class super_class))))
-                                                                    (~ (code.text name))
-                                                                    (~' _jvm_this)
-                                                                    (~+ (|> args
-                                                                            (list.zip/2 (list\map product.right arguments))
-                                                                            (list\map ..decorate_input)))))))))]
-      (` ("override"
-          (~ (declaration$ declaration))
-          (~ (code.text name))
-          (~ (code.bit strict_fp?))
-          [(~+ (list\map annotation$ anns))]
-          [(~+ (list\map var$ type_vars))]
-          (~ (code.text self_name))
-          [(~+ (list\map argument$ arguments))]
-          (~ (return$ return_type))
-          [(~+ (list\map class$ exs))]
-          (~ (|> body
-                 (pre_walk_replace replacer)
-                 (pre_walk_replace super_replacer)))
-          )))
-
-    (#StaticMethod strict_fp? type_vars arguments return_type body exs)
-    (` ("static"
-        (~ (code.text name))
-        (~ (privacy_modifier$ pm))
-        (~ (code.bit strict_fp?))
-        [(~+ (list\map annotation$ anns))]
-        [(~+ (list\map var$ type_vars))]
-        [(~+ (list\map class$ exs))]
-        [(~+ (list\map argument$ arguments))]
-        (~ (return$ return_type))
-        (~ (pre_walk_replace replacer body))))
-
-    (#AbstractMethod type_vars arguments return_type exs)
-    (` ("abstract"
-        (~ (code.text name))
-        (~ (privacy_modifier$ pm))
-        [(~+ (list\map annotation$ anns))]
-        [(~+ (list\map var$ type_vars))]
-        [(~+ (list\map class$ exs))]
-        [(~+ (list\map argument$ arguments))]
-        (~ (return$ return_type))))
-
-    (#NativeMethod type_vars arguments return_type exs)
-    (` ("native"
-        (~ (code.text name))
-        (~ (privacy_modifier$ pm))
-        [(~+ (list\map annotation$ anns))]
-        [(~+ (list\map var$ type_vars))]
-        [(~+ (list\map class$ exs))]
-        [(~+ (list\map argument$ arguments))]
-        (~ (return$ return_type))))
-    ))
-
-(def: (complete_call$ g!obj [method args])
-  (-> Code Partial_Call Code)
-  (` ((~ (code.identifier method)) (~+ args) (~ g!obj))))
-
-(def: $Object
-  (Type Class)
-  (type.class "java.lang.Object" (list)))
-
-(syntax: #export (class:
-                   {#let [! <>.monad]}
-                   {im inheritance_modifier^}
-                   {[full_class_name class_vars] (\ ! map parser.declaration ..declaration^)}
-                   {super (<>.default $Object
-                                      (class^ class_vars))}
-                   {interfaces (<>.default (list)
-                                           (.tuple (<>.some (class^ class_vars))))}
-                   {annotations ..annotations^}
-                   {fields (<>.some (..field_decl^ class_vars))}
-                   {methods (<>.some (..method_def^ class_vars))})
-  {#.doc (doc "Allows defining JVM classes in Lux code."
-              "For example:"
-              (class: #final (TestClass A) [Runnable]
-                ## Fields
-                (#private foo boolean)
-                (#private bar A)
-                (#private baz java/lang/Object)
-                ## Methods
-                (#public [] (new [value A]) []
-                         (exec (:= ::foo #1)
-                           (:= ::bar value)
-                           (:= ::baz "")
-                           []))
-                (#public (virtual) java/lang/Object
-                         "")
-                (#public #static (static) java/lang/Object
-                         "")
-                (Runnable [] (run) void
-                          [])
-                )
-
-              "The tuple corresponds to parent interfaces."
-              "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed."
-              "Fields and methods defined in the class can be used with special syntax."
-              "For example:"
-              "::resolved, for accessing the 'resolved' field."
-              "(:= ::resolved #1) for modifying it."
-              "(::new! []) for calling the class's constructor."
-              "(::resolve! container [value]) for calling the 'resolve' method."
-              )}
-  (do meta.monad
-    [current_module meta.current_module_name
-     #let [fully_qualified_class_name (name.qualify current_module full_class_name)
-           field_parsers (list\map (field->parser fully_qualified_class_name) fields)
-           method_parsers (list\map (method->parser fully_qualified_class_name) methods)
-           replacer (parser->replacer (list\fold <>.either
-                                                 (<>.fail "")
-                                                 (list\compose field_parsers method_parsers)))]]
-    (wrap (list (` ("jvm class"
-                    (~ (declaration$ (type.declaration (name.qualify current_module full_class_name) class_vars)))
-                    (~ (class$ super))
-                    [(~+ (list\map class$ interfaces))]
-                    (~ (inheritance_modifier$ im))
-                    [(~+ (list\map annotation$ annotations))]
-                    [(~+ (list\map field_decl$ fields))]
-                    [(~+ (list\map (method_def$ replacer super) methods))]))))))
-
-(syntax: #export (interface:
-                   {#let [! <>.monad]}
-                   {[full_class_name class_vars] (\ ! map parser.declaration ..declaration^)}
-                   {supers (<>.default (list)
-                                       (.tuple (<>.some (class^ class_vars))))}
-                   {annotations ..annotations^}
-                   {members (<>.some (..method_decl^ class_vars))})
-  {#.doc (doc "Allows defining JVM interfaces."
-              (interface: TestInterface
-                ([] foo [boolean String] void #throws [Exception])))}
-  (do meta.monad
-    [current_module meta.current_module_name]
-    (wrap (list (` ("jvm class interface"
-                    (~ (declaration$ (type.declaration (name.qualify current_module full_class_name) class_vars)))
-                    [(~+ (list\map class$ supers))]
-                    [(~+ (list\map annotation$ annotations))]
-                    (~+ (list\map method_decl$ members))))))))
-
-(syntax: #export (object
-                   {class_vars ..vars^}
-                   {super (<>.default $Object
-                                      (class^ class_vars))}
-                   {interfaces (<>.default (list)
-                                           (.tuple (<>.some (class^ class_vars))))}
-                   {constructor_args (..constructor_args^ class_vars)}
-                   {methods (<>.some ..overriden_method_def^)})
-  {#.doc (doc "Allows defining anonymous classes."
-              "The 1st tuple corresponds to class-level type-variables."
-              "The 2nd tuple corresponds to parent interfaces."
-              "The 3rd tuple corresponds to arguments to the super class constructor."
-              "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed."
-              (object [] [Runnable]
-                []
-                (Runnable [] (run self) void
-                          (exec (do_something some_value)
-                            [])))
-              )}
-  (wrap (list (` ("jvm class anonymous"
-                  [(~+ (list\map var$ class_vars))]
-                  (~ (class$ super))
-                  [(~+ (list\map class$ interfaces))]
-                  [(~+ (list\map constructor_arg$ constructor_args))]
-                  [(~+ (list\map (method_def$ function.identity super) methods))])))))
-
-(syntax: #export (null)
-  {#.doc (doc "Null object reference."
-              (null))}
-  (wrap (list (` ("jvm object null")))))
-
-(def: #export (null? obj)
-  {#.doc (doc "Test for null object reference."
-              (= (null? (null))
-                 true)
-              (= (null? "YOLO")
-                 false))}
-  (-> (primitive "java.lang.Object") Bit)
-  ("jvm object null?" obj))
-
-(syntax: #export (??? expr)
-  {#.doc (doc "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it."
-              (= (??? (: java/lang/String (null)))
-                 #.None)
-              (= (??? "YOLO")
-                 (#.Some "YOLO")))}
-  (with_gensyms [g!temp]
-    (wrap (list (` (let [(~ g!temp) (~ expr)]
-                     (if ("jvm object null?" (~ g!temp))
-                       #.None
-                       (#.Some (~ g!temp)))))))))
-
-(syntax: #export (!!! expr)
-  {#.doc (doc "Takes a (Maybe ObjectType) and returns a ObjectType."
-              "A #.None would get translated into a (null)."
-              (= (null)
-                 (!!! (??? (: java/lang/Thread (null)))))
-              (= "foo"
-                 (!!! (??? "foo"))))}
-  (with_gensyms [g!value]
-    (wrap (list (` ({(#.Some (~ g!value))
-                     (~ g!value)
-
-                     #.None
-                     ("jvm object null")}
-                    (~ expr)))))))
-
-(syntax: #export (try expression)
-  {#.doc (doc (case (try (risky_computation input))
-                (#.Right success)
-                (do_something success)
-
-                (#.Left error)
-                (recover_from_failure error)))}
-  (wrap (list (` ("lux try" ((~! io.io) (~ expression)))))))
-
-(syntax: #export (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."
-              (case (check String "YOLO")
-                (#.Some value_as_string)
-                #.None))}
-  (with_gensyms [g!_ g!unchecked]
-    (let [class_name (..reflection class)
-          class_type (` (.primitive (~ (code.text class_name))))
-          check_type (` (.Maybe (~ class_type)))
-          check_code (` (if ("jvm object instance?" (~ (code.text class_name)) (~ g!unchecked))
-                          (#.Some (.:coerce (~ class_type)
-                                            (~ g!unchecked)))
-                          #.None))]
-      (case unchecked
-        (#.Some unchecked)
-        (wrap (list (` (: (~ check_type)
-                          (let [(~ g!unchecked) (~ unchecked)]
-                            (~ check_code))))))
-
-        #.None
-        (wrap (list (` (: (-> (primitive "java.lang.Object") (~ check_type))
-                          (function ((~ g!_) (~ g!unchecked))
-                            (~ check_code))))))
-        ))))
-
-(syntax: #export (synchronized lock body)
-  {#.doc (doc "Evaluates body, while holding a lock on a given object."
-              (synchronized object_to_be_locked
-                (exec (do_something ___)
-                  (do_something_else ___)
-                  (finish_the_computation ___))))}
-  (wrap (list (` ("jvm object synchronized" (~ lock) (~ body))))))
-
-(syntax: #export (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)
-                     (ClassName::method2 arg3 arg4 arg5)))}
-  (with_gensyms [g!obj]
-    (wrap (list (` (let [(~ g!obj) (~ obj)]
-                     (exec (~+ (list\map (complete_call$ g!obj) methods))
-                       (~ g!obj))))))))
-
-(def: (class_import$ declaration)
-  (-> (Type Declaration) Code)
-  (let [[full_name params] (parser.declaration declaration)
-        def_name (..internal full_name)
-        params' (list\map ..var$' params)]
-    (` (def: (~ (code.identifier ["" def_name]))
-         {#..jvm_class (~ (code.text (..internal full_name)))}
-         .Type
-         (All [(~+ params')]
-           (primitive (~ (code.text full_name))
-                      [(~+ params')]))))))
-
-(def: (member_type_vars class_tvars member)
-  (-> (List (Type Var)) Import_Member_Declaration (List (Type Var)))
-  (case member
-    (#ConstructorDecl [commons _])
-    (list\compose class_tvars (get@ #import_member_tvars commons))
-
-    (#MethodDecl [commons _])
-    (case (get@ #import_member_kind commons)
-      #StaticIMK
-      (get@ #import_member_tvars commons)
-
-      _
-      (list\compose class_tvars (get@ #import_member_tvars commons)))
-
-    _
-    class_tvars))
-
-(def: (member_def_arg_bindings vars member)
-  (-> (List (Type Var)) Import_Member_Declaration (Meta [(List [Bit Code]) (List (Type Value)) (List Code)]))
-  (case member
-    (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _]))
-    (let [(^slots [#import_member_tvars #import_member_args]) commons]
-      (do {! meta.monad}
-        [arg_inputs (monad.map !
-                               (: (-> [Bit (Type Value)] (Meta [Bit Code]))
-                                  (function (_ [maybe? _])
-                                    (with_gensyms [arg_name]
-                                      (wrap [maybe? arg_name]))))
-                               import_member_args)
-         #let [input_jvm_types (list\map product.right import_member_args)
-               arg_types (list\map (: (-> [Bit (Type Value)] Code)
-                                      (function (_ [maybe? arg])
-                                        (let [arg_type (value_type (get@ #import_member_mode commons) arg)]
-                                          (if maybe?
-                                            (` (Maybe (~ arg_type)))
-                                            arg_type))))
-                                   import_member_args)]]
-        (wrap [arg_inputs input_jvm_types arg_types])))
-
-    _
-    (\ meta.monad wrap [(list) (list) (list)])))
-
-(def: (decorate_return_maybe member never_null? unboxed return_term)
-  (-> Import_Member_Declaration Bit (Type Value) Code Code)
-  (case member
-    (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _]))
-    (cond (or never_null?
-              (dictionary.key? ..boxes unboxed))
-          return_term
-
-          (get@ #import_member_maybe? commons)
-          (` (??? (~ return_term)))
-
-          ## else
-          (let [g!temp (` ((~' ~') (~ (code.identifier ["" " Ω "]))))]
-            (` (let [(~ g!temp) (~ return_term)]
-                 (if (not (..null? (:coerce (primitive "java.lang.Object")
-                                            (~ g!temp))))
-                   (~ g!temp)
-                   (error! "Cannot produce null references from method calls."))))))
-
-    _
-    return_term))
-
-(template [  ]
-  [(def: ( member return_term)
-     (-> Import_Member_Declaration Code Code)
-     (case member
-       (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _]))
-       (if (get@  commons)
-         
-         return_term)
-
-       _
-       return_term))]
-
-  [decorate_return_try #import_member_try? (` (..try (~ return_term)))]
-  [decorate_return_io  #import_member_io?  (` ((~! io.io) (~ return_term)))]
-  )
-
-(def: $String (type.class "java.lang.String" (list)))
-
-(template [   ]
-  [(def: ( mode [unboxed raw])
-     (-> Primitive_Mode [(Type Value) Code] Code)
-     (let [[unboxed refined post] (: [(Type Value) Code (List Code)]
-                                     (case mode
-                                       #ManualPrM
-                                       [unboxed raw (list)]
-                                       
-                                       #AutoPrM
-                                       (with_expansions [' (template.splice )
-                                                          (template [  
 ]
-                                                                        [(\ type.equivalence =  unboxed)
-                                                                         (with_expansions [' (template.splice )]
-                                                                           [
-                                                                            (` (.|> (~ raw) (~+ 
)))
-                                                                            (list ')])]
-
-                                                                        ')]
-                                         (cond 
-                                               ## else
-                                               [unboxed
-                                                (if 
-                                                  (` ("jvm object cast" (~ raw)))
-                                                  raw)
-                                                (list)]))))
-           unboxed/boxed (case (dictionary.get unboxed ..boxes)
-                           (#.Some boxed)
-                           ( unboxed boxed refined)
-                           
-                           #.None
-                           refined)]
-       (case post
-         #.Nil
-         unboxed/boxed
-
-         _
-         (` (.|> (~ unboxed/boxed) (~+ post))))))]
-
-  [#1 auto_convert_input ..unbox
-   [[type.boolean type.boolean (list (` (.: .Bit)) (` (.:coerce (.primitive (~ (code.text box.boolean)))))) []]
-    [type.byte type.byte (list (` (.: .Int)) (` (.:coerce (.primitive (~ (code.text box.long))))) (` ..long_to_byte)) []]
-    [type.short type.short (list (` (.: .Int)) (` (.:coerce (.primitive (~ (code.text box.long))))) (` ..long_to_short)) []]
-    [type.int type.int (list (` (.: .Int)) (` (.:coerce (.primitive (~ (code.text box.long))))) (` ..long_to_int)) []]
-    [type.long type.long (list (` (.: .Int)) (` (.:coerce (.primitive (~ (code.text box.long)))))) []]
-    [type.float type.float (list (` (.: .Frac)) (` (.:coerce (.primitive (~ (code.text box.double))))) (` ..double_to_float)) []]
-    [type.double type.double (list (` (.: .Frac)) (` (.:coerce (.primitive (~ (code.text box.double)))))) []]
-    [..$String ..$String (list (` (.: .Text)) (` (.:coerce (.primitive (~ (code.text (..reflection ..$String))))))) []]
-    [(type.class box.boolean (list)) (type.class box.boolean (list)) (list (` (.: .Bit)) (` (.:coerce (.primitive (~ (code.text box.boolean)))))) []]
-    [(type.class box.long (list)) (type.class box.long (list)) (list (` (.: .Int)) (` (.:coerce (.primitive (~ (code.text box.long)))))) []]
-    [(type.class box.double (list)) (type.class box.double (list)) (list (` (.: .Frac)) (` (.:coerce (.primitive (~ (code.text box.double)))))) []]]]
-  [#0 auto_convert_output ..box
-   [[type.boolean type.boolean (list) [(` (.: (.primitive (~ (code.text box.boolean))))) (` (.:coerce .Bit))]]
-    [type.byte type.long (list (` "jvm conversion byte-to-long")) [(` (.: (.primitive (~ (code.text box.long))))) (` (.:coerce .Int))]]
-    [type.short type.long (list (` "jvm conversion short-to-long")) [(` (.: (.primitive (~ (code.text box.long))))) (` (.:coerce .Int))]]
-    [type.int type.long (list (` "jvm conversion int-to-long")) [(` (.: (.primitive (~ (code.text box.long))))) (` (.:coerce .Int))]]
-    [type.long type.long (list) [(` (.: (.primitive (~ (code.text box.long))))) (` (.:coerce .Int))]]
-    [type.float type.double (list (` "jvm conversion float-to-double")) [(` (.: (.primitive (~ (code.text box.double))))) (` (.:coerce .Frac))]]
-    [type.double type.double (list) [(` (.: (.primitive (~ (code.text box.double))))) (` (.:coerce .Frac))]]
-    [..$String ..$String (list) [(` (.: (.primitive (~ (code.text (..reflection ..$String)))))) (` (.:coerce .Text))]]
-    [(type.class box.boolean (list)) (type.class box.boolean (list)) (list) [(` (.: (.primitive (~ (code.text box.boolean))))) (` (.:coerce .Bit))]]
-    [(type.class box.long (list)) (type.class box.long (list)) (list) [(` (.: (.primitive (~ (code.text box.long))))) (` (.:coerce .Int))]]
-    [(type.class box.double (list)) (type.class box.double (list)) (list) [(` (.: (.primitive (~ (code.text box.double))))) (` (.:coerce .Frac))]]]]
-  )
-
-(def: (un_quote quoted)
-  (-> Code Code)
-  (` ((~' ~) (~ quoted))))
-
-(def: (jvm_invoke_inputs mode classes inputs)
-  (-> Primitive_Mode (List (Type Value)) (List [Bit Code]) (List Code))
-  (|> inputs
-      (list\map (function (_ [maybe? input])
-                  (if maybe?
-                    (` ((~! !!!) (~ (un_quote input))))
-                    (un_quote input))))
-      (list.zip/2 classes)
-      (list\map (auto_convert_input mode))))
-
-(def: (import_name format class member)
-  (-> Text Text Text Text)
-  (|> format
-      (text.replace_all "#" class)
-      (text.replace_all "." member)))
-
-(def: (member_def_interop vars kind class [arg_function_inputs input_jvm_types arg_types] member method_prefix import_format)
-  (-> (List (Type Var)) Class_Kind (Type Declaration) [(List [Bit Code]) (List (Type Value)) (List Code)] Import_Member_Declaration Text Text (Meta (List Code)))
-  (let [[full_name class_tvars] (parser.declaration class)]
-    (case member
-      (#EnumDecl enum_members)
-      (do meta.monad
-        [#let [enum_type (: Code
-                            (case class_tvars
-                              #.Nil
-                              (` (primitive (~ (code.text full_name))))
-
-                              _
-                              (let [=class_tvars (list\map ..var$' class_tvars)]
-                                (` (All [(~+ =class_tvars)] (primitive (~ (code.text full_name)) [(~+ =class_tvars)]))))))
-               getter_interop (: (-> Text Code)
-                                 (function (_ name)
-                                   (let [getter_name (code.identifier ["" (..import_name import_format method_prefix name)])]
-                                     (` (def: (~ getter_name)
-                                          (~ enum_type)
-                                          (~ (get_static_field full_name name)))))))]]
-        (wrap (list\map getter_interop enum_members)))
-      
-      (#ConstructorDecl [commons _])
-      (do meta.monad
-        [#let [classT (type.class full_name (list))
-               def_name (code.identifier ["" (..import_name import_format method_prefix (get@ #import_member_alias commons))])
-               jvm_interop (|> [classT
-                                (` ("jvm member invoke constructor"
-                                    [(~+ (list\map ..var$ class_tvars))]
-                                    (~ (code.text full_name))
-                                    [(~+ (list\map ..var$ (get@ #import_member_tvars commons)))]
-                                    (~+ (|> (jvm_invoke_inputs (get@ #import_member_mode commons) input_jvm_types arg_function_inputs)
-                                            (list.zip/2 input_jvm_types)
-                                            (list\map ..decorate_input)))))]
-                               (auto_convert_output (get@ #import_member_mode commons))
-                               (decorate_return_maybe member true classT)
-                               (decorate_return_try member)
-                               (decorate_return_io member))]]
-        (wrap (list (` ((~! syntax:) ((~ def_name) (~+ (list\map product.right arg_function_inputs)))
-                        ((~' wrap) (.list (.` (~ jvm_interop)))))))))
-
-      (#MethodDecl [commons method])
-      (with_gensyms [g!obj]
-        (do meta.monad
-          [#let [def_name (code.identifier ["" (..import_name import_format method_prefix (get@ #import_member_alias commons))])
-                 (^slots [#import_member_kind]) commons
-                 (^slots [#import_method_name]) method
-                 [jvm_op object_ast] (: [Text (List Code)]
-                                        (case import_member_kind
-                                          #StaticIMK
-                                          ["jvm member invoke static"
-                                           (list)]
-
-                                          #VirtualIMK
-                                          (case kind
-                                            #Class
-                                            ["jvm member invoke virtual"
-                                             (list g!obj)]
-                                            
-                                            #Interface
-                                            ["jvm member invoke interface"
-                                             (list g!obj)]
-                                            )))
-                 method_return (get@ #import_method_return method)
-                 callC (: Code
-                          (` ((~ (code.text jvm_op))
-                              [(~+ (list\map ..var$ class_tvars))]
-                              (~ (code.text full_name))
-                              (~ (code.text import_method_name))
-                              [(~+ (list\map ..var$ (get@ #import_member_tvars commons)))]
-                              (~+ (|> object_ast
-                                      (list\map ..un_quote)
-                                      (list.zip/2 (list (type.class full_name (list))))
-                                      (list\map (auto_convert_input (get@ #import_member_mode commons)))))
-                              (~+ (|> (jvm_invoke_inputs (get@ #import_member_mode commons) input_jvm_types arg_function_inputs)
-                                      (list.zip/2 input_jvm_types)
-                                      (list\map ..decorate_input))))))
-                 jvm_interop (: Code
-                                (case (type.void? method_return)
-                                  (#.Left method_return)
-                                  (|> [method_return
-                                       callC]
-                                      (auto_convert_output (get@ #import_member_mode commons))
-                                      (decorate_return_maybe member false method_return)
-                                      (decorate_return_try member)
-                                      (decorate_return_io member))
-                                  
-                                  
-                                  (#.Right method_return)
-                                  (|> callC
-                                      (decorate_return_try member)
-                                      (decorate_return_io member))))]]
-          (wrap (list (` ((~! syntax:) ((~ def_name) (~+ (list\map product.right arg_function_inputs)) (~+ object_ast))
-                          ((~' wrap) (.list (.` (~ jvm_interop))))))))))
-
-      (#FieldAccessDecl fad)
-      (do meta.monad
-        [#let [(^open ".") fad
-               getter_name (code.identifier ["" (..import_name import_format method_prefix import_field_name)])
-               setter_name (code.identifier ["" (..import_name import_format method_prefix (format import_field_name "!"))])]
-         getter_interop (with_gensyms [g!obj]
-                          (let [getter_call (if import_field_static?
-                                              (` ((~ getter_name)))
-                                              (` ((~ getter_name) (~ g!obj))))
-                                getter_body (<| (auto_convert_output import_field_mode)
-                                                [import_field_type
-                                                 (if import_field_static?
-                                                   (get_static_field full_name import_field_name)
-                                                   (get_virtual_field full_name import_field_name (un_quote g!obj)))])
-                                getter_body (if import_field_maybe?
-                                              (` ((~! ???) (~ getter_body)))
-                                              getter_body)
-                                getter_body (if import_field_setter?
-                                              (` ((~! io.io) (~ getter_body)))
-                                              getter_body)]
-                            (wrap (` ((~! syntax:) (~ getter_call)
-                                      ((~' wrap) (.list (.` (~ getter_body)))))))))
-         setter_interop (: (Meta (List Code))
-                           (if import_field_setter?
-                             (with_gensyms [g!obj g!value]
-                               (let [setter_call (if import_field_static?
-                                                   (` ((~ setter_name) (~ g!value)))
-                                                   (` ((~ setter_name) (~ g!value) (~ g!obj))))
-                                     setter_value (|> [import_field_type (un_quote g!value)]
-                                                      (auto_convert_input import_field_mode))
-                                     setter_value (if import_field_maybe?
-                                                    (` ((~! !!!) (~ setter_value)))
-                                                    setter_value)
-                                     setter_command (format (if import_field_static? "jvm putstatic" "jvm putfield")
-                                                            ":" full_name ":" import_field_name)
-                                     g!obj+ (: (List Code)
-                                               (if import_field_static?
-                                                 (list)
-                                                 (list (un_quote g!obj))))]
-                                 (wrap (list (` ((~! syntax:) (~ setter_call)
-                                                 ((~' wrap) (.list (.` ((~! io.io) ((~ (code.text setter_command)) (~+ g!obj+) (~ setter_value))))))))))))
-                             (wrap (list))))]
-        (wrap (list& getter_interop setter_interop)))
-      )))
-
-(def: (member_import$ vars kind class [import_format member])
-  (-> (List (Type Var)) Class_Kind (Type Declaration) [Text Import_Member_Declaration] (Meta (List Code)))
-  (let [[full_name _] (parser.declaration class)
-        method_prefix (..internal full_name)]
-    (do meta.monad
-      [=args (member_def_arg_bindings vars member)]
-      (member_def_interop vars kind class =args member method_prefix import_format))))
-
-(def: interface?
-  (All [a] (-> (primitive "java.lang.Class" [a]) Bit))
-  (|>> ("jvm member invoke virtual" [] "java.lang.Class" "isInterface" [])
-       "jvm object cast"
-       (: ..Boolean)
-       (:coerce Bit)))
-
-(def: load_class
-  (-> External (Try (primitive "java.lang.Class" [Any])))
-  (|>> (:coerce (primitive "java.lang.String"))
-       ["Ljava/lang/String;"]
-       ("jvm member invoke static" [] "java.lang.Class" "forName" [])
-       ..try))
-
-(def: (class_kind declaration)
-  (-> (Type Declaration) (Meta Class_Kind))
-  (let [[class_name _] (parser.declaration declaration)]
-    (case (load_class class_name)
-      (#.Right class)
-      (\ meta.monad wrap (if (interface? class)
-                           #Interface
-                           #Class))
-
-      (#.Left _)
-      (meta.fail (format "Unknown class: " class_name)))))
-
-(syntax: #export (import:
-                   {declaration ..declaration^}
-                   {#let [[class_name class_type_vars] (parser.declaration declaration)]}
-                   {bundles (<>.some (..bundle class_type_vars))})
-  {#.doc (doc "Allows importing JVM classes, and using them as types."
-              "Their methods, fields and enum options can also be imported."
-              (import: java/lang/Object
-                ["#::."
-                 (new [])
-                 (equals [java/lang/Object] boolean)
-                 (wait [int] #io #try void)])
-              
-              "Special options can also be given for the return values."
-              "#? means that the values will be returned inside a Maybe type. That way, null becomes #.None."
-              "#try means that the computation might throw an exception, and the return value will be wrapped by the Try type."
-              "#io means the computation has side effects, and will be wrapped by the IO type."
-              "These options must show up in the following order [#io #try #?] (although, each option can be used independently)."
-              (import: java/lang/String
-                ["#::."
-                 (new [[byte]])
-                 (#static valueOf [char] java/lang/String)
-                 (#static valueOf #as int_valueOf [int] java/lang/String)])
-
-              (import: (java/util/List e)
-                ["#::."
-                 (size [] int)
-                 (get [int] e)])
-
-              (import: (java/util/ArrayList a)
-                ["#::."
-                 ([T] toArray [[T]] [T])])
-              
-              "The class-type that is generated is of the fully-qualified name."
-              "This avoids a clash between the java.util.List type, and Lux's own List type."
-              "All enum options to be imported must be specified."
-              (import: java/lang/Character$UnicodeScript
-                ["#::."
-                 (#enum ARABIC CYRILLIC LATIN)])
-
-              "It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-vars."
-              "Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes)."
-              (import: (lux/concurrency/promise/JvmPromise A)
-                ["#::."
-                 (resolve [A] boolean)
-                 (poll [] A)
-                 (wasResolved [] boolean)
-                 (waitOn [lux/Function] void)
-                 (#static [A] make [A] (lux/concurrency/promise/JvmPromise A))])
-              
-              "Also, the names of the imported members will look like Class::member"
-              (java/lang/Object::new [])
-              (java/lang/Object::equals [other_object] my_object)
-              (java/util/List::size [] my_list)
-              java/lang/Character$UnicodeScript::LATIN
-              )}
-  (do {! meta.monad}
-    [kind (class_kind declaration)
-     =members (|> bundles
-                  (list\map (function (_ [import_format members])
-                              (list\map (|>> [import_format]) members)))
-                  list.concat
-                  (monad.map ! (member_import$ class_type_vars kind declaration)))]
-    (wrap (list& (class_import$ declaration) (list\join =members)))))
-
-(syntax: #export (array {type (..type^ (list))}
-                        size)
-  {#.doc (doc "Create an array of the given type, with the given size."
-              (array java/lang/Object 10))}
-  (let [g!size (` (|>  (~ size)
-                       (.: .Nat)
-                       (.:coerce (.primitive (~ (code.text box.long))))
-                       "jvm object cast"
-                       "jvm conversion long-to-int"))]
-    (`` (cond (~~ (template [ ]
-                    [(\ type.equivalence =  type)
-                     (wrap (list (` ( (~ g!size)))))]
-
-                    [type.boolean "jvm array new boolean"]
-                    [type.byte    "jvm array new byte"]
-                    [type.short   "jvm array new short"]
-                    [type.int     "jvm array new int"]
-                    [type.long    "jvm array new long"]
-                    [type.float   "jvm array new float"]
-                    [type.double  "jvm array new double"]
-                    [type.char    "jvm array new char"]))
-              ## else
-              (wrap (list (` (: (~ (value_type #ManualPrM (type.array type)))
-                                ("jvm array new object" (~ g!size))))))))))
-
-(exception: #export (cannot_convert_to_jvm_type {type .Type})
-  (exception.report
-   ["Lux Type" (%.type type)]))
-
-(with_expansions [ (as_is (meta.fail (exception.construct ..cannot_convert_to_jvm_type [type])))]
-  (def: (lux_type->jvm_type type)
-    (-> .Type (Meta (Type Value)))
-    (if (lux_type\= Any type)
-      (\ meta.monad wrap $Object)
-      (case type
-        (#.Primitive name params)
-        (`` (cond (~~ (template []
-                        [(text\= (..reflection ) name)
-                         (case params
-                           #.Nil
-                           (\ meta.monad wrap )
-
-                           _
-                           )]
-                        
-                        [type.boolean]
-                        [type.byte]
-                        [type.short]
-                        [type.int]
-                        [type.long]
-                        [type.float]
-                        [type.double]
-                        [type.char]))
-
-                  (~~ (template []
-                        [(text\= (..reflection (type.array )) name)
-                         (case params
-                           #.Nil
-                           (\ meta.monad wrap (type.array ))
-
-                           _
-                           )]
-                        
-                        [type.boolean]
-                        [type.byte]
-                        [type.short]
-                        [type.int]
-                        [type.long]
-                        [type.float]
-                        [type.double]
-                        [type.char]))
-
-                  (text\= array.type_name name)
-                  (case params
-                    (#.Cons elementLT #.Nil)
-                    (\ meta.monad map type.array
-                       (lux_type->jvm_type elementLT))
-
-                    _
-                    )
-
-                  (text.starts_with? descriptor.array_prefix name)
-                  (case params
-                    #.Nil
-                    (let [[_ unprefixed] (maybe.assume (text.split_with descriptor.array_prefix name))]
-                      (\ meta.monad map type.array
-                         (lux_type->jvm_type (#.Primitive unprefixed (list)))))
-
-                    _
-                    )
-
-                  ## else
-                  (\ meta.monad map (type.class name)
-                     (: (Meta (List (Type Parameter)))
-                        (monad.map meta.monad
-                                   (function (_ paramLT)
-                                     (do meta.monad
-                                       [paramJT (lux_type->jvm_type paramLT)]
-                                       (case (parser.parameter? paramJT)
-                                         (#.Some paramJT)
-                                         (wrap paramJT)
-
-                                         #.None
-                                         )))
-                                   params)))))
-
-        (#.Apply A F)
-        (case (lux_type.apply (list A) F)
-          #.None
-          
-
-          (#.Some type')
-          (lux_type->jvm_type type'))
-        
-        (#.Named _ type')
-        (lux_type->jvm_type type')
-
-        _
-        ))))
-
-(syntax: #export (array_length array)
-  {#.doc (doc "Gives the length of an array."
-              (array_length my_array))}
-  (case array
-    [_ (#.Identifier array_name)]
-    (do meta.monad
-      [array_type (meta.find_type array_name)
-       array_jvm_type (lux_type->jvm_type array_type)
-       #let [g!extension (code.text (`` (cond (~~ (template [ ]
-                                                    [(\ type.equivalence =
-                                                        (type.array )
-                                                        array_jvm_type)
-                                                     ]
-
-                                                    [type.boolean "jvm array length boolean"]
-                                                    [type.byte "jvm array length byte"]
-                                                    [type.short "jvm array length short"]
-                                                    [type.int "jvm array length int"]
-                                                    [type.long "jvm array length long"]
-                                                    [type.float "jvm array length float"]
-                                                    [type.double "jvm array length double"]
-                                                    [type.char "jvm array length char"]))
-                                              
-                                              ## else
-                                              "jvm array length object")))]]
-      (wrap (list (` (.|> ((~ g!extension) (~ array))
-                          "jvm conversion int-to-long"
-                          "jvm object cast"
-                          (.: (.primitive (~ (code.text box.long))))
-                          (.:coerce .Nat))))))
-
-    _
-    (with_gensyms [g!array]
-      (wrap (list (` (let [(~ g!array) (~ array)]
-                       (..array_length (~ g!array)))))))))
-
-(syntax: #export (array_read idx array)
-  {#.doc (doc "Loads an element from an array."
-              (array_read 10 my_array))}
-  (case array
-    [_ (#.Identifier array_name)]
-    (do meta.monad
-      [array_type (meta.find_type array_name)
-       array_jvm_type (lux_type->jvm_type array_type)
-       #let [g!idx (` (.|> (~ idx)
-                           (.: .Nat)
-                           (.:coerce (.primitive (~ (code.text box.long))))
-                           "jvm object cast"
-                           "jvm conversion long-to-int"))]]
-      (`` (cond (~~ (template [  ]
-                      [(\ type.equivalence =
-                          (type.array )
-                          array_jvm_type)
-                       (wrap (list (` (.|> ( (~ g!idx) (~ array))
-                                           "jvm object cast"
-                                           (.: (.primitive (~ (code.text ))))))))]
-
-                      [type.boolean "jvm array read boolean" box.boolean]
-                      [type.byte "jvm array read byte" box.byte]
-                      [type.short "jvm array read short" box.short]
-                      [type.int "jvm array read int" box.int]
-                      [type.long "jvm array read long" box.long]
-                      [type.float "jvm array read float" box.float]
-                      [type.double "jvm array read double" box.double]
-                      [type.char "jvm array read char" box.char]))
-                
-                ## else
-                (wrap (list (` ("jvm array read object" (~ g!idx) (~ array))))))))
-
-    _
-    (with_gensyms [g!array]
-      (wrap (list (` (let [(~ g!array) (~ array)]
-                       (..array_read (~ idx) (~ g!array)))))))))
-
-(syntax: #export (array_write idx value array)
-  {#.doc (doc "Stores an element into an array."
-              (array_write 10 my_object my_array))}
-  (case array
-    [_ (#.Identifier array_name)]
-    (do meta.monad
-      [array_type (meta.find_type array_name)
-       array_jvm_type (lux_type->jvm_type array_type)
-       #let [g!idx (` (.|> (~ idx)
-                           (.: .Nat)
-                           (.:coerce (.primitive (~ (code.text box.long))))
-                           "jvm object cast"
-                           "jvm conversion long-to-int"))]]
-      (`` (cond (~~ (template [  ]
-                      [(\ type.equivalence =
-                          (type.array )
-                          array_jvm_type)
-                       (let [g!value (` (.|> (~ value)
-                                             (.:coerce (.primitive (~ (code.text ))))
-                                             "jvm object cast"))]
-                         (wrap (list (` ( (~ g!idx) (~ g!value) (~ array))))))]
-
-                      [type.boolean "jvm array write boolean" box.boolean]
-                      [type.byte "jvm array write byte" box.byte]
-                      [type.short "jvm array write short" box.short]
-                      [type.int "jvm array write int" box.int]
-                      [type.long "jvm array write long" box.long]
-                      [type.float "jvm array write float" box.float]
-                      [type.double "jvm array write double" box.double]
-                      [type.char "jvm array write char" box.char]))
-                
-                ## else
-                (wrap (list (` ("jvm array write object" (~ g!idx) (~ value) (~ array))))))))
-
-    _
-    (with_gensyms [g!array]
-      (wrap (list (` (let [(~ g!array) (~ array)]
-                       (..array_write (~ idx) (~ value) (~ g!array)))))))))
-
-(syntax: #export (class_for {type (..type^ (list))})
-  {#.doc (doc "Loads the class as a java.lang.Class object."
-              (class_for java/lang/String))}
-  (wrap (list (` ("jvm object class" (~ (code.text (..reflection type))))))))
-
-(syntax: #export (type {type (..type^ (list))})
-  (wrap (list (value_type #ManualPrM type))))
diff --git a/stdlib/source/lux/host.lua.lux b/stdlib/source/lux/host.lua.lux
deleted file mode 100644
index 785ca82d6..000000000
--- a/stdlib/source/lux/host.lua.lux
+++ /dev/null
@@ -1,313 +0,0 @@
-(.module:
-  [lux #*
-   ["." meta]
-   ["@" target]
-   [abstract
-    [monad (#+ do)]]
-   [control
-    ["." io]
-    ["<>" parser ("#\." monad)
-     ["" code (#+ Parser)]]]
-   [data
-    ["." product]
-    ["." maybe]
-    ["." text
-     ["%" format (#+ format)]]
-    [collection
-     ["." list ("#\." functor fold)]]]
-   [type
-    abstract]
-   [macro (#+ with_gensyms)
-    [syntax (#+ syntax:)]
-    ["." code]
-    ["." template]]])
-
-(abstract: #export (Object brand) Any)
-
-(template []
-  [(with_expansions [ (template.identifier [ "'"])]
-     (abstract: #export  Any)
-     (type: #export 
-       (..Object )))]
-
-  [Nil]
-  [Function]
-  [Table]
-  )
-
-(template [ ]
-  [(type: #export 
-     )]
-
-  [Boolean Bit]
-  [Integer Int]
-  [Float   Frac]
-  [String  Text]
-  )
-
-(type: Nilable
-  [Bit Code])
-
-(def: nilable
-  (Parser Nilable)
-  (let [token (' #?)]
-    (<| (<>.and (<>.parses? (.this! token)))
-        (<>.after (<>.not (.this! token)))
-        .any)))
-
-(type: Field
-  [Bit Text Nilable])
-
-(def: static!
-  (Parser Any)
-  (.this! (' #static)))
-
-(def: field
-  (Parser Field)
-  (.form ($_ <>.and
-                (<>.parses? ..static!)
-                .local_identifier
-                ..nilable)))
-
-(def: constant
-  (Parser Field)
-  (.form ($_ <>.and
-                (<>\wrap true)
-                .local_identifier
-                ..nilable)))
-
-(type: Common_Method
-  {#name Text
-   #alias (Maybe Text)
-   #inputs (List Nilable)
-   #io? Bit
-   #try? Bit
-   #output Nilable})
-
-(type: Static_Method Common_Method)
-(type: Virtual_Method Common_Method)
-
-(type: Method
-  (#Static Static_Method)
-  (#Virtual Virtual_Method))
-
-(def: common_method
-  (Parser Common_Method)
-  ($_ <>.and
-      .local_identifier
-      (<>.maybe (<>.after (.this! (' #as)) .local_identifier))
-      (.tuple (<>.some ..nilable))
-      (<>.parses? (.this! (' #io)))
-      (<>.parses? (.this! (' #try)))
-      ..nilable))
-
-(def: static_method
-  (<>.after ..static! ..common_method))
-
-(def: method
-  (Parser Method)
-  (.form (<>.or ..static_method
-                   ..common_method)))
-
-(type: Member
-  (#Field Field)
-  (#Method Method))
-
-(def: member
-  (Parser Member)
-  ($_ <>.or
-      ..field
-      ..method
-      ))
-
-(def: input_variables
-  (-> (List Nilable) (List [Bit Code]))
-  (|>> list.enumeration
-       (list\map (function (_ [idx [nilable? type]])
-                   [nilable? (|> idx %.nat code.local_identifier)]))))
-
-(def: (nilable_type [nilable? type])
-  (-> Nilable Code)
-  (if nilable?
-    (` (.Maybe (~ type)))
-    type))
-
-(def: (with_nil g!temp [nilable? input])
-  (-> Code [Bit Code] Code)
-  (if nilable?
-    (` (case (~ input)
-         (#.Some (~ g!temp))
-         (~ g!temp)
-
-         #.Nil
-         ("lua object nil")))
-    input))
-
-(def: (without_nil g!temp [nilable? outputT] output)
-  (-> Code Nilable Code Code)
-  (if nilable?
-    (` (let [(~ g!temp) (~ output)]
-         (if ("lua object nil?" (~ g!temp))
-           #.None
-           (#.Some (~ g!temp)))))
-    (` (let [(~ g!temp) (~ output)]
-         (if (not ("lua object nil?" (~ g!temp)))
-           (~ g!temp)
-           (.error! "Nil is an invalid value!"))))))
-
-(type: Import
-  (#Class [Text (List Member)])
-  (#Function Static_Method)
-  (#Constant Field))
-
-(def: import
-  ($_ <>.or
-      ($_ <>.and
-          .local_identifier
-          (<>.some member))
-      (.form ..common_method)
-      ..constant
-      ))
-
-(syntax: #export (try expression)
-  {#.doc (doc (case (try (risky_computation input))
-                (#.Right success)
-                (do_something success)
-
-                (#.Left error)
-                (recover_from_failure error)))}
-  (wrap (list (` ("lux try" ((~! io.io) (~ expression)))))))
-
-(def: (with_io with? without)
-  (-> Bit Code Code)
-  (if with?
-    (` (io.io (~ without)))
-    without))
-
-(def: (io_type io? rawT)
-  (-> Bit Code Code)
-  (if io?
-    (` (io.IO (~ rawT)))
-    rawT))
-
-(def: (with_try with? without_try)
-  (-> Bit Code Code)
-  (if with?
-    (` (..try (~ without_try)))
-    without_try))
-
-(def: (try_type try? rawT)
-  (-> Bit Code Code)
-  (if try?
-    (` (.Either .Text (~ rawT)))
-    rawT))
-
-(def: (make_function g!method g!temp source inputsT io? try? outputT)
-  (-> Code Code Code (List Nilable) Bit Bit Nilable Code)
-  (let [g!inputs (input_variables inputsT)]
-    (` (def: ((~ g!method)
-              [(~+ (list\map product.right g!inputs))])
-         (-> [(~+ (list\map nilable_type inputsT))]
-             (~ (|> (nilable_type outputT)
-                    (try_type try?)
-                    (io_type io?))))
-         (:assume
-          (~ (<| (with_io io?)
-                 (with_try try?)
-                 (without_nil g!temp outputT)
-                 (` ("lua apply"
-                     (:coerce ..Function (~ source))
-                     (~+ (list\map (with_nil g!temp) g!inputs)))))))))))
-
-(syntax: #export (import: {import ..import})
-  (with_gensyms [g!temp]
-    (case import
-      (#Class [class members])
-      (with_gensyms [g!object]
-        (let [qualify (: (-> Text Code)
-                         (|>> (format class "::") code.local_identifier))
-              g!type (code.local_identifier class)
-              real_class (text.replace_all "/" "." class)
-              imported (case (text.split_all_with "/" class)
-                         (#.Cons head tail)
-                         (list\fold (function (_ sub super)
-                                      (` ("lua object get" (~ (code.text sub))
-                                          (:coerce (..Object .Any) (~ super)))))
-                                    (` ("lua import" (~ (code.text head))))
-                                    tail)
-                         
-                         #.Nil
-                         (` ("lua import" (~ (code.text class)))))]
-          (wrap (list& (` (type: (~ g!type)
-                            (..Object (primitive (~ (code.text real_class))))))
-                       (list\map (function (_ member)
-                                   (case member
-                                     (#Field [static? field fieldT])
-                                     (if static?
-                                       (` ((~! syntax:) ((~ (qualify field)))
-                                           (\ (~! meta.monad) (~' wrap)
-                                              (list (` (.:coerce (~ (nilable_type fieldT))
-                                                                 ("lua object get" (~ (code.text field))
-                                                                  (:coerce (..Object .Any) (~ imported)))))))))
-                                       (` (def: ((~ (qualify field))
-                                                 (~ g!object))
-                                            (-> (~ g!type)
-                                                (~ (nilable_type fieldT)))
-                                            (:assume
-                                             (~ (without_nil g!temp fieldT (` ("lua object get" (~ (code.text field))
-                                                                               (:coerce (..Object .Any) (~ g!object))))))))))
-                                     
-                                     (#Method method)
-                                     (case method
-                                       (#Static [method alias inputsT io? try? outputT])
-                                       (..make_function (qualify (maybe.default method alias))
-                                                        g!temp
-                                                        (` ("lua object get" (~ (code.text method))
-                                                            (:coerce (..Object .Any) (~ imported))))
-                                                        inputsT
-                                                        io?
-                                                        try?
-                                                        outputT)
-                                       
-                                       (#Virtual [method alias inputsT io? try? outputT])
-                                       (let [g!inputs (input_variables inputsT)]
-                                         (` (def: ((~ (qualify (maybe.default method alias)))
-                                                   [(~+ (list\map product.right g!inputs))]
-                                                   (~ g!object))
-                                              (-> [(~+ (list\map nilable_type inputsT))]
-                                                  (~ g!type)
-                                                  (~ (|> (nilable_type outputT)
-                                                         (try_type try?)
-                                                         (io_type io?))))
-                                              (:assume
-                                               (~ (<| (with_io io?)
-                                                      (with_try try?)
-                                                      (without_nil g!temp outputT)
-                                                      (` ("lua object do"
-                                                          (~ (code.text method))
-                                                          (~ g!object)
-                                                          (~+ (list\map (with_nil g!temp) g!inputs)))))))))))))
-                                 members)))))
-      
-      (#Function [name alias inputsT io? try? outputT])
-      (wrap (list (..make_function (code.local_identifier (maybe.default name alias))
-                                   g!temp
-                                   (` ("lua constant" (~ (code.text (text.replace_all "/" "." name)))))
-                                   inputsT
-                                   io?
-                                   try?
-                                   outputT)))
-
-      (#Constant [_ name fieldT])
-      (wrap (list (` ((~! syntax:) ((~ (code.local_identifier name)))
-                      (\ (~! meta.monad) (~' wrap)
-                         (list (` (.:coerce (~ (nilable_type fieldT))
-                                            ("lua constant" (~ (code.text (text.replace_all "/" "." name))))))))))))
-      )))
-
-(template: #export (closure  )
-  (.:coerce ..Function
-            (`` ("lua function"
-                 (~~ (template.count ))
-                 (.function (_ [])
-                   )))))
diff --git a/stdlib/source/lux/host.old.lux b/stdlib/source/lux/host.old.lux
deleted file mode 100644
index 3a69f2464..000000000
--- a/stdlib/source/lux/host.old.lux
+++ /dev/null
@@ -1,1835 +0,0 @@
-(.module:
-  [lux (#- type)
-   ["." type ("#\." equivalence)]
-   [abstract
-    ["." monad (#+ Monad do)]
-    ["." enum]]
-   [control
-    ["." function]
-    ["." io]
-    ["." try (#+ Try)]
-    ["p" parser
-     ["s" code (#+ Parser)]]]
-   [data
-    ["." maybe]
-    ["." product]
-    ["." bit ("#\." codec)]
-    ["." text ("#\." equivalence monoid)
-     ["%" format (#+ format)]]
-    [collection
-     ["." array (#+ Array)]
-     ["." list ("#\." monad fold monoid)]]]
-   [macro (#+ with_gensyms)
-    [syntax (#+ syntax:)]
-    ["." code]]
-   ["." meta
-    ["." annotation]]])
-
-(template [   ]
-  [(def: #export ( value)
-     {#.doc (doc "Type converter."
-                 (: 
-                    ( (:  foo))))}
-     (-> (primitive ) (primitive ))
-     ( value))]
-
-  [byte_to_long "jvm convert byte-to-long" "java.lang.Byte"      "java.lang.Long"]
-
-  [short_to_long "jvm convert short-to-long" "java.lang.Short"     "java.lang.Long"]
-  
-  [double_to_int "jvm convert double-to-int" "java.lang.Double"    "java.lang.Integer"]
-  [double_to_long "jvm convert double-to-long" "java.lang.Double"    "java.lang.Long"]
-  [double_to_float "jvm convert double-to-float" "java.lang.Double"    "java.lang.Float"]
-
-  [float_to_int "jvm convert float-to-int" "java.lang.Float"     "java.lang.Integer"]
-  [float_to_long "jvm convert float-to-long" "java.lang.Float"     "java.lang.Long"]
-  [float_to_double "jvm convert float-to-double" "java.lang.Float"     "java.lang.Double"]
-  
-  [int_to_byte "jvm convert int-to-byte" "java.lang.Integer"   "java.lang.Byte"]
-  [int_to_short "jvm convert int-to-short" "java.lang.Integer"   "java.lang.Short"]
-  [int_to_long "jvm convert int-to-long" "java.lang.Integer"   "java.lang.Long"]
-  [int_to_float "jvm convert int-to-float" "java.lang.Integer"   "java.lang.Float"]
-  [int_to_double "jvm convert int-to-double" "java.lang.Integer"   "java.lang.Double"]
-  [int_to_char "jvm convert int-to-char" "java.lang.Integer"   "java.lang.Character"]
-
-  [long_to_byte "jvm convert long-to-byte" "java.lang.Long"      "java.lang.Byte"]
-  [long_to_short "jvm convert long-to-short" "java.lang.Long"      "java.lang.Short"]
-  [long_to_int "jvm convert long-to-int" "java.lang.Long"      "java.lang.Integer"]
-  [long_to_float "jvm convert long-to-float" "java.lang.Long"      "java.lang.Float"]
-  [long_to_double "jvm convert long-to-double" "java.lang.Long"      "java.lang.Double"]
-
-  [char_to_byte "jvm convert char-to-byte" "java.lang.Character" "java.lang.Byte"]
-  [char_to_short "jvm convert char-to-short" "java.lang.Character" "java.lang.Short"]
-  [char_to_int "jvm convert char-to-int" "java.lang.Character" "java.lang.Integer"]
-  [char_to_long "jvm convert char-to-long" "java.lang.Character" "java.lang.Long"]
-  )
-
-## [Utils]
-(def: constructor_method_name "")
-(def: member_separator "::")
-
-## Types
-(type: JVM_Code Text)
-
-(type: BoundKind
-  #UpperBound
-  #LowerBound)
-
-(type: #rec GenericType
-  (#GenericTypeVar Text)
-  (#GenericClass [Text (List GenericType)])
-  (#GenericArray GenericType)
-  (#GenericWildcard (Maybe [BoundKind GenericType])))
-
-(type: Type_Parameter
-  [Text (List GenericType)])
-
-(type: Primitive_Mode
-  #ManualPrM
-  #AutoPrM)
-
-(type: PrivacyModifier
-  #PublicPM
-  #PrivatePM
-  #ProtectedPM
-  #DefaultPM)
-
-(type: StateModifier
-  #VolatileSM
-  #FinalSM
-  #DefaultSM)
-
-(type: InheritanceModifier
-  #FinalIM
-  #AbstractIM
-  #DefaultIM)
-
-(type: Class_Kind
-  #Class
-  #Interface)
-
-(type: Class_Declaration
-  {#class_name   Text
-   #class_params (List Type_Parameter)})
-
-(type: StackFrame (primitive "java/lang/StackTraceElement"))
-(type: StackTrace (Array StackFrame))
-
-(type: Super_Class_Decl
-  {#super_class_name   Text
-   #super_class_params (List GenericType)})
-
-(type: AnnotationParam
-  [Text Code])
-
-(type: Annotation
-  {#ann_name   Text
-   #ann_params (List AnnotationParam)})
-
-(type: Member_Declaration
-  {#member_name Text
-   #member_privacy PrivacyModifier
-   #member_anns (List Annotation)})
-
-(type: FieldDecl
-  (#ConstantField GenericType Code)
-  (#VariableField StateModifier GenericType))
-
-(type: MethodDecl
-  {#method_tvars  (List Type_Parameter)
-   #method_inputs (List GenericType)
-   #method_output GenericType
-   #method_exs    (List GenericType)})
-
-(type: ArgDecl
-  {#arg_name Text
-   #arg_type GenericType})
-
-(type: ConstructorArg
-  [GenericType Code])
-
-(type: Method_Definition
-  (#ConstructorMethod [Bit
-                       (List Type_Parameter)
-                       (List ArgDecl)
-                       (List ConstructorArg)
-                       Code
-                       (List GenericType)])
-  (#VirtualMethod [Bit
-                   Bit
-                   (List Type_Parameter)
-                   Text
-                   (List ArgDecl)
-                   GenericType
-                   Code
-                   (List GenericType)])
-  (#OverridenMethod [Bit
-                     Class_Declaration
-                     (List Type_Parameter)
-                     Text
-                     (List ArgDecl)
-                     GenericType
-                     Code
-                     (List GenericType)])
-  (#StaticMethod [Bit
-                  (List Type_Parameter)
-                  (List ArgDecl)
-                  GenericType
-                  Code
-                  (List GenericType)])
-  (#AbstractMethod [(List Type_Parameter)
-                    (List ArgDecl)
-                    GenericType
-                    (List GenericType)])
-  (#NativeMethod [(List Type_Parameter)
-                  (List ArgDecl)
-                  GenericType
-                  (List GenericType)]))
-
-(type: Partial_Call
-  {#pc_method Name
-   #pc_args   (List Code)})
-
-(type: ImportMethodKind
-  #StaticIMK
-  #VirtualIMK)
-
-(type: ImportMethodCommons
-  {#import_member_mode   Primitive_Mode
-   #import_member_alias  Text
-   #import_member_kind   ImportMethodKind
-   #import_member_tvars  (List Type_Parameter)
-   #import_member_args   (List [Bit GenericType])
-   #import_member_maybe? Bit
-   #import_member_try?   Bit
-   #import_member_io?    Bit})
-
-(type: ImportConstructorDecl
-  {})
-
-(type: ImportMethodDecl
-  {#import_method_name    Text
-   #import_method_return  GenericType})
-
-(type: ImportFieldDecl
-  {#import_field_mode    Primitive_Mode
-   #import_field_name    Text
-   #import_field_static? Bit
-   #import_field_maybe?  Bit
-   #import_field_setter? Bit
-   #import_field_type    GenericType})
-
-(type: Import_Member_Declaration
-  (#EnumDecl        (List Text))
-  (#ConstructorDecl [ImportMethodCommons ImportConstructorDecl])
-  (#MethodDecl      [ImportMethodCommons ImportMethodDecl])
-  (#FieldAccessDecl ImportFieldDecl))
-
-## Utils
-(def: (manual_primitive_to_type class)
-  (-> Text (Maybe Code))
-  (case class
-    (^template [ ]
-      [
-       (#.Some (' ))])
-    (["boolean" (primitive "java.lang.Boolean")]
-     ["byte"    (primitive "java.lang.Byte")]
-     ["short"   (primitive "java.lang.Short")]
-     ["int"     (primitive "java.lang.Integer")]
-     ["long"    (primitive "java.lang.Long")]
-     ["float"   (primitive "java.lang.Float")]
-     ["double"  (primitive "java.lang.Double")]
-     ["char"    (primitive "java.lang.Character")]
-     ["void"    .Any])
-
-    _
-    #.None))
-
-(def: (auto_primitive_to_type class)
-  (-> Text (Maybe Code))
-  (case class
-    (^template [ ]
-      [
-       (#.Some (' ))])
-    (["boolean" .Bit]
-     ["byte"    .Int]
-     ["short"   .Int]
-     ["int"     .Int]
-     ["long"    .Int]
-     ["float"   .Frac]
-     ["double"  .Frac]
-     ["void"    .Any])
-
-    _
-    #.None))
-
-(def: sanitize
-  (-> Text Text)
-  (text.replace_all "/" "."))
-
-(def: (generic_class->type' mode type_params in_array? name+params
-                            class->type')
-  (-> Primitive_Mode (List Type_Parameter) Bit [Text (List GenericType)]
-      (-> Primitive_Mode (List Type_Parameter) Bit GenericType Code)
-      Code)
-  (case [name+params mode in_array?]
-    (^multi [[prim #.Nil] #ManualPrM #0]
-            [(manual_primitive_to_type prim) (#.Some output)])
-    output
-
-    (^multi [[prim #.Nil] #AutoPrM #0]
-            [(auto_primitive_to_type prim) (#.Some output)])
-    output
-    
-    [[name params] _ _]
-    (let [name (sanitize name)
-          =params (list\map (class->type' mode type_params in_array?) params)]
-      (` (primitive (~ (code.text name)) [(~+ =params)])))))
-
-(def: (class->type' mode type_params in_array? class)
-  (-> Primitive_Mode (List Type_Parameter) Bit GenericType Code)
-  (case class
-    (#GenericTypeVar name)
-    (case (list.find (function (_ [pname pbounds])
-                       (and (text\= name pname)
-                            (not (list.empty? pbounds))))
-                     type_params)
-      #.None
-      (code.identifier ["" name])
-
-      (#.Some [pname pbounds])
-      (class->type' mode type_params in_array? (maybe.assume (list.head pbounds))))
-    
-    (#GenericClass name+params)
-    (generic_class->type' mode type_params in_array? name+params
-                          class->type')
-
-    (#GenericArray param)
-    (let [=param (class->type' mode type_params #1 param)]
-      (` ((~! array.Array) (~ =param))))
-
-    (^or (#GenericWildcard #.None) (#GenericWildcard (#.Some [#LowerBound _])))
-    (` .Any)
-
-    (#GenericWildcard (#.Some [#UpperBound upper_bound]))
-    (class->type' mode type_params in_array? upper_bound)
-    ))
-
-(def: (class->type mode type_params class)
-  (-> Primitive_Mode (List Type_Parameter) GenericType Code)
-  (class->type' mode type_params #0 class))
-
-(def: (type_param_type$ [name bounds])
-  (-> Type_Parameter Code)
-  (code.identifier ["" name]))
-
-(def: (class_decl_type$ (^slots [#class_name #class_params]))
-  (-> Class_Declaration Code)
-  (let [=params (list\map (: (-> Type_Parameter Code)
-                             (function (_ [pname pbounds])
-                               (case pbounds
-                                 #.Nil
-                                 (code.identifier ["" pname])
-
-                                 (#.Cons bound1 _)
-                                 (class->type #ManualPrM class_params bound1))))
-                          class_params)]
-    (` (primitive (~ (code.text (sanitize class_name)))
-                  [(~+ =params)]))))
-
-(def: type_var_class Text "java.lang.Object")
-
-(def: (simple_class$ env class)
-  (-> (List Type_Parameter) GenericType Text)
-  (case class
-    (#GenericTypeVar name)
-    (case (list.find (function (_ [pname pbounds])
-                       (and (text\= name pname)
-                            (not (list.empty? pbounds))))
-                     env)
-      #.None
-      type_var_class
-
-      (#.Some [pname pbounds])
-      (simple_class$ env (maybe.assume (list.head pbounds))))
-
-    (^or (#GenericWildcard #.None) (#GenericWildcard (#.Some [#LowerBound _])))
-    type_var_class
-    
-    (#GenericWildcard (#.Some [#UpperBound upper_bound]))
-    (simple_class$ env upper_bound)
-    
-    (#GenericClass name env)
-    (sanitize name)
-
-    (#GenericArray param')
-    (case param'
-      (#GenericArray param)
-      (format "[" (simple_class$ env param))
-      
-      (^template [ ]
-        [(#GenericClass  #.Nil)
-         ])
-      (["boolean" "[Z"]
-       ["byte"    "[B"]
-       ["short"   "[S"]
-       ["int"     "[I"]
-       ["long"    "[J"]
-       ["float"   "[F"]
-       ["double"  "[D"]
-       ["char"    "[C"])
-      
-      param
-      (format "[L" (simple_class$ env param) ";"))
-    ))
-
-(def: (make_get_const_parser class_name field_name)
-  (-> Text Text (Parser Code))
-  (do p.monad
-    [#let [dotted_name (format "::" field_name)]
-     _ (s.this! (code.identifier ["" dotted_name]))]
-    (wrap (`' ((~ (code.text (format "jvm getstatic" ":" class_name ":" field_name))))))))
-
-(def: (make_get_var_parser class_name field_name)
-  (-> Text Text (Parser Code))
-  (do p.monad
-    [#let [dotted_name (format "::" field_name)]
-     _ (s.this! (code.identifier ["" dotted_name]))]
-    (wrap (`' ((~ (code.text (format "jvm getfield" ":" class_name ":" field_name))) _jvm_this)))))
-
-(def: (make_put_var_parser class_name field_name)
-  (-> Text Text (Parser Code))
-  (do p.monad
-    [#let [dotted_name (format "::" field_name)]
-     [_ _ value] (: (Parser [Any Any Code])
-                    (s.form ($_ p.and (s.this! (' :=)) (s.this! (code.identifier ["" dotted_name])) s.any)))]
-    (wrap (`' ((~ (code.text (format "jvm putfield" ":" class_name ":" field_name))) _jvm_this (~ value))))))
-
-(def: (pre_walk_replace f input)
-  (-> (-> Code Code) Code Code)
-  (case (f input)
-    (^template []
-      [[meta ( parts)]
-       [meta ( (list\map (pre_walk_replace f) parts))]])
-    ([#.Form]
-     [#.Tuple])
-    
-    [meta (#.Record pairs)]
-    [meta (#.Record (list\map (: (-> [Code Code] [Code Code])
-                                 (function (_ [key val])
-                                   [(pre_walk_replace f key) (pre_walk_replace f val)]))
-                              pairs))]
-    
-    ast'
-    ast'))
-
-(def: (parser->replacer p ast)
-  (-> (Parser Code) (-> Code Code))
-  (case (p.run p (list ast))
-    (#.Right [#.Nil ast'])
-    ast'
-
-    _
-    ast
-    ))
-
-(def: (field->parser class_name [[field_name _ _] field])
-  (-> Text [Member_Declaration FieldDecl] (Parser Code))
-  (case field
-    (#ConstantField _)
-    (make_get_const_parser class_name field_name)
-    
-    (#VariableField _)
-    (p.either (make_get_var_parser class_name field_name)
-              (make_put_var_parser class_name field_name))))
-
-(def: (make_constructor_parser params class_name arg_decls)
-  (-> (List Type_Parameter) Text (List ArgDecl) (Parser Code))
-  (do p.monad
-    [args (: (Parser (List Code))
-             (s.form (p.after (s.this! (' ::new!))
-                              (s.tuple (p.exactly (list.size arg_decls) s.any)))))
-     #let [arg_decls' (: (List Text) (list\map (|>> product.right (simple_class$ params)) arg_decls))]]
-    (wrap (` ((~ (code.text (format "jvm new" ":" class_name ":" (text.join_with "," arg_decls'))))
-              (~+ args))))))
-
-(def: (make_static_method_parser params class_name method_name arg_decls)
-  (-> (List Type_Parameter) Text Text (List ArgDecl) (Parser Code))
-  (do p.monad
-    [#let [dotted_name (format "::" method_name "!")]
-     args (: (Parser (List Code))
-             (s.form (p.after (s.this! (code.identifier ["" dotted_name]))
-                              (s.tuple (p.exactly (list.size arg_decls) s.any)))))
-     #let [arg_decls' (: (List Text) (list\map (|>> product.right (simple_class$ params)) arg_decls))]]
-    (wrap (`' ((~ (code.text (format "jvm invokestatic" ":" class_name ":" method_name ":" (text.join_with "," arg_decls'))))
-               (~+ args))))))
-
-(template [ ]
-  [(def: ( params class_name method_name arg_decls)
-     (-> (List Type_Parameter) Text Text (List ArgDecl) (Parser Code))
-     (do p.monad
-       [#let [dotted_name (format "::" method_name "!")]
-        args (: (Parser (List Code))
-                (s.form (p.after (s.this! (code.identifier ["" dotted_name]))
-                                 (s.tuple (p.exactly (list.size arg_decls) s.any)))))
-        #let [arg_decls' (: (List Text) (list\map (|>> product.right (simple_class$ params)) arg_decls))]]
-       (wrap (`' ((~ (code.text (format  ":" class_name ":" method_name ":" (text.join_with "," arg_decls'))))
-                  (~' _jvm_this) (~+ args))))))]
-
-  [make_special_method_parser "jvm invokespecial"]
-  [make_virtual_method_parser "jvm invokevirtual"]
-  )
-
-(def: (method->parser params class_name [[method_name _ _] meth_def])
-  (-> (List Type_Parameter) Text [Member_Declaration Method_Definition] (Parser Code))
-  (case meth_def
-    (#ConstructorMethod strict? type_vars args constructor_args return_expr exs)
-    (make_constructor_parser params class_name args)
-    
-    (#StaticMethod strict? type_vars args return_type return_expr exs)
-    (make_static_method_parser params class_name method_name args)
-    
-    (^or (#VirtualMethod final? strict? type_vars self_name args return_type return_expr exs)
-         (#OverridenMethod strict? owner_class type_vars self_name args return_type return_expr exs))
-    (make_special_method_parser params class_name method_name args)
-
-    (#AbstractMethod type_vars args return_type exs)
-    (make_virtual_method_parser params class_name method_name args)
-
-    (#NativeMethod type_vars args return_type exs)
-    (make_virtual_method_parser params class_name method_name args)))
-
-## Parsers
-(def: privacy_modifier^
-  (Parser PrivacyModifier)
-  (let [(^open ".") p.monad]
-    ($_ p.or
-        (s.this! (' #public))
-        (s.this! (' #private))
-        (s.this! (' #protected))
-        (wrap []))))
-
-(def: inheritance_modifier^
-  (Parser InheritanceModifier)
-  (let [(^open ".") p.monad]
-    ($_ p.or
-        (s.this! (' #final))
-        (s.this! (' #abstract))
-        (wrap []))))
-
-(def: bound_kind^
-  (Parser BoundKind)
-  (p.or (s.this! (' <))
-        (s.this! (' >))))
-
-(def: (assert_no_periods name)
-  (-> Text (Parser Any))
-  (p.assert "Names in class declarations cannot contain periods."
-            (not (text.contains? "." name))))
-
-(def: (generic_type^ type_vars)
-  (-> (List Type_Parameter) (Parser GenericType))
-  (p.rec
-   (function (_ recur^)
-     ($_ p.either
-         (do p.monad
-           [_ (s.this! (' ?))]
-           (wrap (#GenericWildcard #.None)))
-         (s.tuple (do p.monad
-                    [_ (s.this! (' ?))
-                     bound_kind bound_kind^
-                     bound recur^]
-                    (wrap (#GenericWildcard (#.Some [bound_kind bound])))))
-         (do p.monad
-           [name s.local_identifier
-            _ (assert_no_periods name)]
-           (if (list.member? text.equivalence (list\map product.left type_vars) name)
-             (wrap (#GenericTypeVar name))
-             (wrap (#GenericClass name (list)))))
-         (s.tuple (do p.monad
-                    [component recur^]
-                    (case component
-                      (^template [ ]
-                        [(#GenericClass  #.Nil)
-                         (wrap (#GenericClass  (list)))])
-                      (["[Z" "boolean"]
-                       ["[B" "byte"]
-                       ["[S" "short"]
-                       ["[I" "int"]
-                       ["[J" "long"]
-                       ["[F" "float"]
-                       ["[D" "double"]
-                       ["[C" "char"])
-
-                      _
-                      (wrap (#GenericArray component)))))
-         (s.form (do p.monad
-                   [name s.local_identifier
-                    _ (assert_no_periods name)
-                    params (p.some recur^)
-                    _ (p.assert (format name " cannot be a type-parameter!")
-                                (not (list.member? text.equivalence (list\map product.left type_vars) name)))]
-                   (wrap (#GenericClass name params))))
-         ))))
-
-(def: type_param^
-  (Parser Type_Parameter)
-  (p.either (do p.monad
-              [param_name s.local_identifier]
-              (wrap [param_name (list)]))
-            (s.tuple (do p.monad
-                       [param_name s.local_identifier
-                        _ (s.this! (' <))
-                        bounds (p.many (..generic_type^ (list)))]
-                       (wrap [param_name bounds])))))
-
-(def: type_params^
-  (Parser (List Type_Parameter))
-  (|> ..type_param^
-      p.some
-      s.tuple
-      (p.default (list))))
-
-(def: class_decl^
-  (Parser Class_Declaration)
-  (p.either (do p.monad
-              [name s.local_identifier
-               _ (assert_no_periods name)]
-              (wrap [name (list)]))
-            (s.form (do p.monad
-                      [name s.local_identifier
-                       _ (assert_no_periods name)
-                       params (p.some ..type_param^)]
-                      (wrap [name params])))
-            ))
-
-(def: (super_class_decl^ type_vars)
-  (-> (List Type_Parameter) (Parser Super_Class_Decl))
-  (p.either (do p.monad
-              [name s.local_identifier
-               _ (assert_no_periods name)]
-              (wrap [name (list)]))
-            (s.form (do p.monad
-                      [name s.local_identifier
-                       _ (assert_no_periods name)
-                       params (p.some (..generic_type^ type_vars))]
-                      (wrap [name params])))))
-
-(def: annotation_params^
-  (Parser (List AnnotationParam))
-  (s.record (p.some (p.and s.local_tag s.any))))
-
-(def: annotation^
-  (Parser Annotation)
-  (p.either (do p.monad
-              [ann_name s.local_identifier]
-              (wrap [ann_name (list)]))
-            (s.form (p.and s.local_identifier
-                           annotation_params^))))
-
-(def: annotations^'
-  (Parser (List Annotation))
-  (do p.monad
-    [_ (s.this! (' #ann))]
-    (s.tuple (p.some ..annotation^))))
-
-(def: annotations^
-  (Parser (List Annotation))
-  (do p.monad
-    [anns?? (p.maybe ..annotations^')]
-    (wrap (maybe.default (list) anns??))))
-
-(def: (throws_decl'^ type_vars)
-  (-> (List Type_Parameter) (Parser (List GenericType)))
-  (do p.monad
-    [_ (s.this! (' #throws))]
-    (s.tuple (p.some (..generic_type^ type_vars)))))
-
-(def: (throws_decl^ type_vars)
-  (-> (List Type_Parameter) (Parser (List GenericType)))
-  (do p.monad
-    [exs? (p.maybe (throws_decl'^ type_vars))]
-    (wrap (maybe.default (list) exs?))))
-
-(def: (method_decl^ type_vars)
-  (-> (List Type_Parameter) (Parser [Member_Declaration MethodDecl]))
-  (s.form (do p.monad
-            [tvars ..type_params^
-             name s.local_identifier
-             anns ..annotations^
-             inputs (s.tuple (p.some (..generic_type^ type_vars)))
-             output (..generic_type^ type_vars)
-             exs (..throws_decl^ type_vars)]
-            (wrap [[name #PublicPM anns] {#method_tvars tvars
-                                          #method_inputs inputs
-                                          #method_output output
-                                          #method_exs    exs}]))))
-
-(def: state_modifier^
-  (Parser StateModifier)
-  ($_ p.or
-      (s.this! (' #volatile))
-      (s.this! (' #final))
-      (\ p.monad wrap [])))
-
-(def: (field_decl^ type_vars)
-  (-> (List Type_Parameter) (Parser [Member_Declaration FieldDecl]))
-  (p.either (s.form (do p.monad
-                      [_ (s.this! (' #const))
-                       name s.local_identifier
-                       anns ..annotations^
-                       type (..generic_type^ type_vars)
-                       body s.any]
-                      (wrap [[name #PublicPM anns] (#ConstantField [type body])])))
-            (s.form (do p.monad
-                      [pm privacy_modifier^
-                       sm state_modifier^
-                       name s.local_identifier
-                       anns ..annotations^
-                       type (..generic_type^ type_vars)]
-                      (wrap [[name pm anns] (#VariableField [sm type])])))))
-
-(def: (arg_decl^ type_vars)
-  (-> (List Type_Parameter) (Parser ArgDecl))
-  (s.record (p.and s.local_identifier
-                   (..generic_type^ type_vars))))
-
-(def: (arg_decls^ type_vars)
-  (-> (List Type_Parameter) (Parser (List ArgDecl)))
-  (p.some (arg_decl^ type_vars)))
-
-(def: (constructor_arg^ type_vars)
-  (-> (List Type_Parameter) (Parser ConstructorArg))
-  (s.record (p.and (..generic_type^ type_vars) s.any)))
-
-(def: (constructor_args^ type_vars)
-  (-> (List Type_Parameter) (Parser (List ConstructorArg)))
-  (s.tuple (p.some (constructor_arg^ type_vars))))
-
-(def: (constructor_method^ class_vars)
-  (-> (List Type_Parameter) (Parser [Member_Declaration Method_Definition]))
-  (s.form (do p.monad
-            [pm privacy_modifier^
-             strict_fp? (p.parses? (s.this! (' #strict)))
-             method_vars ..type_params^
-             #let [total_vars (list\compose class_vars method_vars)]
-             [_ arg_decls] (s.form (p.and (s.this! (' new))
-                                          (..arg_decls^ total_vars)))
-             constructor_args (..constructor_args^ total_vars)
-             exs (..throws_decl^ total_vars)
-             annotations ..annotations^
-             body s.any]
-            (wrap [{#member_name constructor_method_name
-                    #member_privacy pm
-                    #member_anns annotations}
-                   (#ConstructorMethod strict_fp? method_vars arg_decls constructor_args body exs)]))))
-
-(def: (virtual_method_def^ class_vars)
-  (-> (List Type_Parameter) (Parser [Member_Declaration Method_Definition]))
-  (s.form (do p.monad
-            [pm privacy_modifier^
-             strict_fp? (p.parses? (s.this! (' #strict)))
-             final? (p.parses? (s.this! (' #final)))
-             method_vars ..type_params^
-             #let [total_vars (list\compose class_vars method_vars)]
-             [name this_name arg_decls] (s.form ($_ p.and
-                                                    s.local_identifier
-                                                    s.local_identifier
-                                                    (..arg_decls^ total_vars)))
-             return_type (..generic_type^ total_vars)
-             exs (..throws_decl^ total_vars)
-             annotations ..annotations^
-             body s.any]
-            (wrap [{#member_name name
-                    #member_privacy pm
-                    #member_anns annotations}
-                   (#VirtualMethod final? strict_fp?
-                                   method_vars
-                                   this_name arg_decls return_type
-                                   body exs)]))))
-
-(def: overriden_method_def^
-  (Parser [Member_Declaration Method_Definition])
-  (s.form (do p.monad
-            [strict_fp? (p.parses? (s.this! (' #strict)))
-             owner_class ..class_decl^
-             method_vars ..type_params^
-             #let [total_vars (list\compose (product.right owner_class) method_vars)]
-             [name this_name arg_decls] (s.form ($_ p.and
-                                                    s.local_identifier
-                                                    s.local_identifier
-                                                    (..arg_decls^ total_vars)))
-             return_type (..generic_type^ total_vars)
-             exs (..throws_decl^ total_vars)
-             annotations ..annotations^
-             body s.any]
-            (wrap [{#member_name name
-                    #member_privacy #PublicPM
-                    #member_anns annotations}
-                   (#OverridenMethod strict_fp?
-                                     owner_class method_vars
-                                     this_name arg_decls return_type
-                                     body exs)]))))
-
-(def: static_method_def^
-  (Parser [Member_Declaration Method_Definition])
-  (s.form (do p.monad
-            [pm privacy_modifier^
-             strict_fp? (p.parses? (s.this! (' #strict)))
-             _ (s.this! (' #static))
-             method_vars ..type_params^
-             #let [total_vars method_vars]
-             [name arg_decls] (s.form (p.and s.local_identifier
-                                             (..arg_decls^ total_vars)))
-             return_type (..generic_type^ total_vars)
-             exs (..throws_decl^ total_vars)
-             annotations ..annotations^
-             body s.any]
-            (wrap [{#member_name name
-                    #member_privacy pm
-                    #member_anns annotations}
-                   (#StaticMethod strict_fp? method_vars arg_decls return_type body exs)]))))
-
-(def: abstract_method_def^
-  (Parser [Member_Declaration Method_Definition])
-  (s.form (do p.monad
-            [pm privacy_modifier^
-             _ (s.this! (' #abstract))
-             method_vars ..type_params^
-             #let [total_vars method_vars]
-             [name arg_decls] (s.form (p.and s.local_identifier
-                                             (..arg_decls^ total_vars)))
-             return_type (..generic_type^ total_vars)
-             exs (..throws_decl^ total_vars)
-             annotations ..annotations^]
-            (wrap [{#member_name name
-                    #member_privacy pm
-                    #member_anns annotations}
-                   (#AbstractMethod method_vars arg_decls return_type exs)]))))
-
-(def: native_method_def^
-  (Parser [Member_Declaration Method_Definition])
-  (s.form (do p.monad
-            [pm privacy_modifier^
-             _ (s.this! (' #native))
-             method_vars ..type_params^
-             #let [total_vars method_vars]
-             [name arg_decls] (s.form (p.and s.local_identifier
-                                             (..arg_decls^ total_vars)))
-             return_type (..generic_type^ total_vars)
-             exs (..throws_decl^ total_vars)
-             annotations ..annotations^]
-            (wrap [{#member_name name
-                    #member_privacy pm
-                    #member_anns annotations}
-                   (#NativeMethod method_vars arg_decls return_type exs)]))))
-
-(def: (method_def^ class_vars)
-  (-> (List Type_Parameter) (Parser [Member_Declaration Method_Definition]))
-  ($_ p.either
-      (..constructor_method^ class_vars)
-      (..virtual_method_def^ class_vars)
-      ..overriden_method_def^
-      ..static_method_def^
-      ..abstract_method_def^
-      ..native_method_def^))
-
-(def: partial_call^
-  (Parser Partial_Call)
-  (s.form (p.and s.identifier (p.some s.any))))
-
-(def: class_kind^
-  (Parser Class_Kind)
-  (p.either (do p.monad
-              [_ (s.this! (' #class))]
-              (wrap #Class))
-            (do p.monad
-              [_ (s.this! (' #interface))]
-              (wrap #Interface))
-            ))
-
-(def: import_member_alias^
-  (Parser (Maybe Text))
-  (p.maybe (do p.monad
-             [_ (s.this! (' #as))]
-             s.local_identifier)))
-
-(def: (import_member_args^ type_vars)
-  (-> (List Type_Parameter) (Parser (List [Bit GenericType])))
-  (s.tuple (p.some (p.and (p.parses? (s.this! (' #?))) (..generic_type^ type_vars)))))
-
-(def: import_member_return_flags^
-  (Parser [Bit Bit Bit])
-  ($_ p.and (p.parses? (s.this! (' #io))) (p.parses? (s.this! (' #try))) (p.parses? (s.this! (' #?)))))
-
-(def: primitive_mode^
-  (Parser Primitive_Mode)
-  (p.or (s.this! (' #manual))
-        (s.this! (' #auto))))
-
-(def: (import_member_decl^ owner_vars)
-  (-> (List Type_Parameter) (Parser Import_Member_Declaration))
-  ($_ p.either
-      (s.form (do p.monad
-                [_ (s.this! (' #enum))
-                 enum_members (p.some s.local_identifier)]
-                (wrap (#EnumDecl enum_members))))
-      (s.form (do p.monad
-                [tvars ..type_params^
-                 _ (s.this! (' new))
-                 ?alias import_member_alias^
-                 #let [total_vars (list\compose owner_vars tvars)]
-                 ?prim_mode (p.maybe primitive_mode^)
-                 args (..import_member_args^ total_vars)
-                 [io? try? maybe?] import_member_return_flags^]
-                (wrap (#ConstructorDecl [{#import_member_mode    (maybe.default #AutoPrM ?prim_mode)
-                                          #import_member_alias   (maybe.default "new" ?alias)
-                                          #import_member_kind    #VirtualIMK
-                                          #import_member_tvars   tvars
-                                          #import_member_args    args
-                                          #import_member_maybe?  maybe?
-                                          #import_member_try?    try?
-                                          #import_member_io?     io?}
-                                         {}]))
-                ))
-      (s.form (do p.monad
-                [kind (: (Parser ImportMethodKind)
-                         (p.or (s.this! (' #static))
-                               (wrap [])))
-                 tvars ..type_params^
-                 name s.local_identifier
-                 ?alias import_member_alias^
-                 #let [total_vars (list\compose owner_vars tvars)]
-                 ?prim_mode (p.maybe primitive_mode^)
-                 args (..import_member_args^ total_vars)
-                 [io? try? maybe?] import_member_return_flags^
-                 return (..generic_type^ total_vars)]
-                (wrap (#MethodDecl [{#import_member_mode    (maybe.default #AutoPrM ?prim_mode)
-                                     #import_member_alias   (maybe.default name ?alias)
-                                     #import_member_kind    kind
-                                     #import_member_tvars   tvars
-                                     #import_member_args    args
-                                     #import_member_maybe?  maybe?
-                                     #import_member_try?    try?
-                                     #import_member_io?     io?}
-                                    {#import_method_name    name
-                                     #import_method_return  return
-                                     }]))))
-      (s.form (do p.monad
-                [static? (p.parses? (s.this! (' #static)))
-                 name s.local_identifier
-                 ?prim_mode (p.maybe primitive_mode^)
-                 gtype (..generic_type^ owner_vars)
-                 maybe? (p.parses? (s.this! (' #?)))
-                 setter? (p.parses? (s.this! (' #!)))]
-                (wrap (#FieldAccessDecl {#import_field_mode    (maybe.default #AutoPrM ?prim_mode)
-                                         #import_field_name    name
-                                         #import_field_static? static?
-                                         #import_field_maybe?  maybe?
-                                         #import_field_setter? setter?
-                                         #import_field_type    gtype}))))
-      ))
-
-(def: bundle
-  (-> (List Type_Parameter) (Parser [Text (List Import_Member_Declaration)]))
-  (|>> ..import_member_decl^
-       p.some
-       (p.and s.text)
-       s.tuple))
-
-## Generators
-(def: with_parens
-  (-> JVM_Code JVM_Code)
-  (text.enclose ["(" ")"]))
-
-(def: with_brackets
-  (-> JVM_Code JVM_Code)
-  (text.enclose ["[" "]"]))
-
-(def: spaced
-  (-> (List JVM_Code) JVM_Code)
-  (text.join_with " "))
-
-(def: (privacy_modifier$ pm)
-  (-> PrivacyModifier JVM_Code)
-  (case pm
-    #PublicPM    "public"
-    #PrivatePM   "private"
-    #ProtectedPM "protected"
-    #DefaultPM   "default"))
-
-(def: (inheritance_modifier$ im)
-  (-> InheritanceModifier JVM_Code)
-  (case im
-    #FinalIM    "final"
-    #AbstractIM "abstract"
-    #DefaultIM  "default"))
-
-(def: (annotation_param$ [name value])
-  (-> AnnotationParam JVM_Code)
-  (format name "=" (code.format value)))
-
-(def: (annotation$ [name params])
-  (-> Annotation JVM_Code)
-  (format "(" name " " "{" (text.join_with text.tab (list\map annotation_param$ params)) "}" ")"))
-
-(def: (bound_kind$ kind)
-  (-> BoundKind JVM_Code)
-  (case kind
-    #UpperBound "<"
-    #LowerBound ">"))
-
-(def: (generic_type$ gtype)
-  (-> GenericType JVM_Code)
-  (case gtype
-    (#GenericTypeVar name)
-    name
-
-    (#GenericClass name params)
-    (format "(" (sanitize name) " " (spaced (list\map generic_type$ params)) ")")
-    
-    (#GenericArray param)
-    (format "(" array.type_name " " (generic_type$ param) ")")
-    
-    (#GenericWildcard #.None)
-    "?"
-
-    (#GenericWildcard (#.Some [bound_kind bound]))
-    (format (bound_kind$ bound_kind) (generic_type$ bound))))
-
-(def: (type_param$ [name bounds])
-  (-> Type_Parameter JVM_Code)
-  (format "(" name " " (spaced (list\map generic_type$ bounds)) ")"))
-
-(def: (class_decl$ (^open "."))
-  (-> Class_Declaration JVM_Code)
-  (format "(" (sanitize class_name) " " (spaced (list\map type_param$ class_params)) ")"))
-
-(def: (super_class_decl$ (^slots [#super_class_name #super_class_params]))
-  (-> Super_Class_Decl JVM_Code)
-  (format "(" (sanitize super_class_name) " " (spaced (list\map generic_type$ super_class_params)) ")"))
-
-(def: (method_decl$ [[name pm anns] method_decl])
-  (-> [Member_Declaration MethodDecl] JVM_Code)
-  (let [(^slots [#method_tvars #method_inputs #method_output #method_exs]) method_decl]
-    (with_parens
-      (spaced (list name
-                    (with_brackets (spaced (list\map annotation$ anns)))
-                    (with_brackets (spaced (list\map type_param$ method_tvars)))
-                    (with_brackets (spaced (list\map generic_type$ method_exs)))
-                    (with_brackets (spaced (list\map generic_type$ method_inputs)))
-                    (generic_type$ method_output))
-              ))))
-
-(def: (state_modifier$ sm)
-  (-> StateModifier JVM_Code)
-  (case sm
-    #VolatileSM "volatile"
-    #FinalSM    "final"
-    #DefaultSM  "default"))
-
-(def: (field_decl$ [[name pm anns] field])
-  (-> [Member_Declaration FieldDecl] JVM_Code)
-  (case field
-    (#ConstantField class value)
-    (with_parens
-      (spaced (list "constant" name
-                    (with_brackets (spaced (list\map annotation$ anns)))
-                    (generic_type$ class)
-                    (code.format value))
-              ))
-
-    (#VariableField sm class)
-    (with_parens
-      (spaced (list "variable" name
-                    (privacy_modifier$ pm)
-                    (state_modifier$ sm)
-                    (with_brackets (spaced (list\map annotation$ anns)))
-                    (generic_type$ class))
-              ))
-    ))
-
-(def: (arg_decl$ [name type])
-  (-> ArgDecl JVM_Code)
-  (with_parens
-    (spaced (list name (generic_type$ type)))))
-
-(def: (constructor_arg$ [class term])
-  (-> ConstructorArg JVM_Code)
-  (with_brackets
-    (spaced (list (generic_type$ class) (code.format term)))))
-
-(def: (method_def$ replacer super_class [[name pm anns] method_def])
-  (-> (-> Code Code) Super_Class_Decl [Member_Declaration Method_Definition] JVM_Code)
-  (case method_def
-    (#ConstructorMethod strict_fp? type_vars arg_decls constructor_args body exs)
-    (with_parens
-      (spaced (list "init"
-                    (privacy_modifier$ pm)
-                    (bit\encode strict_fp?)
-                    (with_brackets (spaced (list\map annotation$ anns)))
-                    (with_brackets (spaced (list\map type_param$ type_vars)))
-                    (with_brackets (spaced (list\map generic_type$ exs)))
-                    (with_brackets (spaced (list\map arg_decl$ arg_decls)))
-                    (with_brackets (spaced (list\map constructor_arg$ constructor_args)))
-                    (code.format (pre_walk_replace replacer body))
-                    )))
-    
-    (#VirtualMethod final? strict_fp? type_vars this_name arg_decls return_type body exs)
-    (with_parens
-      (spaced (list "virtual"
-                    name
-                    (privacy_modifier$ pm)
-                    (bit\encode final?)
-                    (bit\encode strict_fp?)
-                    (with_brackets (spaced (list\map annotation$ anns)))
-                    (with_brackets (spaced (list\map type_param$ type_vars)))
-                    (with_brackets (spaced (list\map generic_type$ exs)))
-                    (with_brackets (spaced (list\map arg_decl$ arg_decls)))
-                    (generic_type$ return_type)
-                    (code.format (pre_walk_replace replacer (` (let [(~ (code.local_identifier this_name)) (~' _jvm_this)]
-                                                                 (~ body))))))))
-    
-    (#OverridenMethod strict_fp? class_decl type_vars this_name arg_decls return_type body exs)
-    (let [super_replacer (parser->replacer (s.form (do p.monad
-                                                     [_ (s.this! (' ::super!))
-                                                      args (s.tuple (p.exactly (list.size arg_decls) s.any))
-                                                      #let [arg_decls' (: (List Text) (list\map (|>> product.right (simple_class$ (list)))
-                                                                                                arg_decls))]]
-                                                     (wrap (`' ((~ (code.text (format "jvm invokespecial"
-                                                                                      ":" (get@ #super_class_name super_class)
-                                                                                      ":" name
-                                                                                      ":" (text.join_with "," arg_decls'))))
-                                                                (~' _jvm_this) (~+ args)))))))]
-      (with_parens
-        (spaced (list "override"
-                      (class_decl$ class_decl)
-                      name
-                      (bit\encode strict_fp?)
-                      (with_brackets (spaced (list\map annotation$ anns)))
-                      (with_brackets (spaced (list\map type_param$ type_vars)))
-                      (with_brackets (spaced (list\map generic_type$ exs)))
-                      (with_brackets (spaced (list\map arg_decl$ arg_decls)))
-                      (generic_type$ return_type)
-                      (|> (` (let [(~ (code.local_identifier this_name)) (~' _jvm_this)]
-                               (~ body)))
-                          (pre_walk_replace replacer)
-                          (pre_walk_replace super_replacer)
-                          (code.format))
-                      ))))
-
-    (#StaticMethod strict_fp? type_vars arg_decls return_type body exs)
-    (with_parens
-      (spaced (list "static"
-                    name
-                    (privacy_modifier$ pm)
-                    (bit\encode strict_fp?)
-                    (with_brackets (spaced (list\map annotation$ anns)))
-                    (with_brackets (spaced (list\map type_param$ type_vars)))
-                    (with_brackets (spaced (list\map generic_type$ exs)))
-                    (with_brackets (spaced (list\map arg_decl$ arg_decls)))
-                    (generic_type$ return_type)
-                    (code.format (pre_walk_replace replacer body)))))
-
-    (#AbstractMethod type_vars arg_decls return_type exs)
-    (with_parens
-      (spaced (list "abstract"
-                    name
-                    (privacy_modifier$ pm)
-                    (with_brackets (spaced (list\map annotation$ anns)))
-                    (with_brackets (spaced (list\map type_param$ type_vars)))
-                    (with_brackets (spaced (list\map generic_type$ exs)))
-                    (with_brackets (spaced (list\map arg_decl$ arg_decls)))
-                    (generic_type$ return_type))))
-
-    (#NativeMethod type_vars arg_decls return_type exs)
-    (with_parens
-      (spaced (list "native"
-                    name
-                    (privacy_modifier$ pm)
-                    (with_brackets (spaced (list\map annotation$ anns)))
-                    (with_brackets (spaced (list\map type_param$ type_vars)))
-                    (with_brackets (spaced (list\map generic_type$ exs)))
-                    (with_brackets (spaced (list\map arg_decl$ arg_decls)))
-                    (generic_type$ return_type))))
-    ))
-
-(def: (complete_call$ g!obj [method args])
-  (-> Code Partial_Call Code)
-  (` ((~ (code.identifier method)) (~+ args) (~ g!obj))))
-
-## [Syntax]
-(def: object_super_class
-  Super_Class_Decl
-  {#super_class_name   "java/lang/Object"
-   #super_class_params (list)})
-
-(syntax: #export (class:
-                   {im inheritance_modifier^}
-                   {class_decl ..class_decl^}
-                   {#let [full_class_name (product.left class_decl)]}
-                   {#let [class_vars (product.right class_decl)]}
-                   {super (p.default object_super_class
-                                     (..super_class_decl^ class_vars))}
-                   {interfaces (p.default (list)
-                                          (s.tuple (p.some (..super_class_decl^ class_vars))))}
-                   {annotations ..annotations^}
-                   {fields (p.some (..field_decl^ class_vars))}
-                   {methods (p.some (..method_def^ class_vars))})
-  {#.doc (doc "Allows defining JVM classes in Lux code."
-              "For example:"
-              (class: #final (TestClass A) [Runnable]
-                ## Fields
-                (#private foo boolean)
-                (#private bar A)
-                (#private baz java/lang/Object)
-                ## Methods
-                (#public [] (new [value A]) []
-                         (exec (:= ::foo #1)
-                           (:= ::bar value)
-                           (:= ::baz "")
-                           []))
-                (#public (virtual) java/lang/Object
-                         "")
-                (#public #static (static) java/lang/Object
-                         "")
-                (Runnable [] (run) void
-                          [])
-                )
-
-              "The tuple corresponds to parent interfaces."
-              "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed."
-              "Fields and methods defined in the class can be used with special syntax."
-              "For example:"
-              "::resolved, for accessing the 'resolved' field."
-              "(:= ::resolved #1) for modifying it."
-              "(::new! []) for calling the class's constructor."
-              "(::resolve! container [value]) for calling the 'resolve' method."
-              )}
-  (do meta.monad
-    [current_module meta.current_module_name
-     #let [fully_qualified_class_name (format (sanitize current_module) "." full_class_name)
-           field_parsers (list\map (field->parser fully_qualified_class_name) fields)
-           method_parsers (list\map (method->parser (product.right class_decl) fully_qualified_class_name) methods)
-           replacer (parser->replacer (list\fold p.either
-                                                 (p.fail "")
-                                                 (list\compose field_parsers method_parsers)))
-           def_code (format "jvm class:"
-                            (spaced (list (class_decl$ class_decl)
-                                          (super_class_decl$ super)
-                                          (with_brackets (spaced (list\map super_class_decl$ interfaces)))
-                                          (inheritance_modifier$ im)
-                                          (with_brackets (spaced (list\map annotation$ annotations)))
-                                          (with_brackets (spaced (list\map field_decl$ fields)))
-                                          (with_brackets (spaced (list\map (method_def$ replacer super) methods))))))]]
-    (wrap (list (` ((~ (code.text def_code))))))))
-
-(syntax: #export (interface:
-                   {class_decl ..class_decl^}
-                   {#let [class_vars (product.right class_decl)]}
-                   {supers (p.default (list)
-                                      (s.tuple (p.some (..super_class_decl^ class_vars))))}
-                   {annotations ..annotations^}
-                   {members (p.some (..method_decl^ class_vars))})
-  {#.doc (doc "Allows defining JVM interfaces."
-              (interface: TestInterface
-                ([] foo [boolean String] void #throws [Exception])))}
-  (let [def_code (format "jvm interface:"
-                         (spaced (list (class_decl$ class_decl)
-                                       (with_brackets (spaced (list\map super_class_decl$ supers)))
-                                       (with_brackets (spaced (list\map annotation$ annotations)))
-                                       (spaced (list\map method_decl$ members)))))]
-    (wrap (list (` ((~ (code.text def_code))))))
-    ))
-
-(syntax: #export (object
-                   {class_vars (s.tuple (p.some ..type_param^))}
-                   {super (p.default object_super_class
-                                     (..super_class_decl^ class_vars))}
-                   {interfaces (p.default (list)
-                                          (s.tuple (p.some (..super_class_decl^ class_vars))))}
-                   {constructor_args (..constructor_args^ class_vars)}
-                   {methods (p.some ..overriden_method_def^)})
-  {#.doc (doc "Allows defining anonymous classes."
-              "The 1st tuple corresponds to class-level type-variables."
-              "The 2nd tuple corresponds to parent interfaces."
-              "The 3rd tuple corresponds to arguments to the super class constructor."
-              "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed."
-              (object [] [Runnable]
-                []
-                (Runnable [] (run self) void
-                          (exec (do_something some_value)
-                            [])))
-              )}
-  (let [def_code (format "jvm anon-class:"
-                         (spaced (list (super_class_decl$ super)
-                                       (with_brackets (spaced (list\map super_class_decl$ interfaces)))
-                                       (with_brackets (spaced (list\map constructor_arg$ constructor_args)))
-                                       (with_brackets (spaced (list\map (method_def$ function.identity super) methods))))))]
-    (wrap (list (` ((~ (code.text def_code))))))))
-
-(syntax: #export (null)
-  {#.doc (doc "Null object reference."
-              (null))}
-  (wrap (list (` ("jvm object null")))))
-
-(def: #export (null? obj)
-  {#.doc (doc "Test for null object reference."
-              (= (null? (null))
-                 true)
-              (= (null? "YOLO")
-                 false))}
-  (-> (primitive "java.lang.Object") Bit)
-  ("jvm object null?" obj))
-
-(syntax: #export (??? expr)
-  {#.doc (doc "Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it."
-              (= (??? (: java/lang/String (null)))
-                 #.None)
-              (= (??? "YOLO")
-                 (#.Some "YOLO")))}
-  (with_gensyms [g!temp]
-    (wrap (list (` (let [(~ g!temp) (~ expr)]
-                     (if ("jvm object null?" (~ g!temp))
-                       #.None
-                       (#.Some (~ g!temp)))))))))
-
-(syntax: #export (!!! expr)
-  {#.doc (doc "Takes a (Maybe ObjectType) and returns a ObjectType."
-              "A #.None would get translated into a (null)."
-              (= (null)
-                 (!!! (??? (: java/lang/Thread (null)))))
-              (= "foo"
-                 (!!! (??? "foo"))))}
-  (with_gensyms [g!value]
-    (wrap (list (` ({(#.Some (~ g!value))
-                     (~ g!value)
-
-                     #.None
-                     ("jvm object null")}
-                    (~ expr)))))))
-
-(syntax: #export (try expression)
-  {#.doc (doc (case (try (risky_computation input))
-                (#.Right success)
-                (do_something success)
-
-                (#.Left error)
-                (recover_from_failure error)))}
-  (wrap (list (` ("lux try" ((~! io.io) (~ expression)))))))
-
-(syntax: #export (check {class (..generic_type^ (list))}
-                        {unchecked (p.maybe s.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."
-              (case (check java/lang/String "YOLO")
-                (#.Some value_as_string)
-                #.None))}
-  (with_gensyms [g!_ g!unchecked]
-    (let [class_name (simple_class$ (list) class)
-          class_type (` (.primitive (~ (code.text class_name))))
-          check_type (` (.Maybe (~ class_type)))
-          check_code (` (if ((~ (code.text (format "jvm instanceof" ":" class_name))) (~ g!unchecked))
-                          (#.Some (.:coerce (~ class_type)
-                                            (~ g!unchecked)))
-                          #.None))]
-      (case unchecked
-        (#.Some unchecked)
-        (wrap (list (` (: (~ check_type)
-                          (let [(~ g!unchecked) (~ unchecked)]
-                            (~ check_code))))))
-
-        #.None
-        (wrap (list (` (: (-> (primitive "java.lang.Object") (~ check_type))
-                          (function ((~ g!_) (~ g!unchecked))
-                            (~ check_code))))))
-        ))))
-
-(syntax: #export (synchronized lock body)
-  {#.doc (doc "Evaluates body, while holding a lock on a given object."
-              (synchronized object_to_be_locked
-                (exec (do_something ___)
-                  (do_something_else ___)
-                  (finish_the_computation ___))))}
-  (wrap (list (` ("jvm object synchronized" (~ lock) (~ body))))))
-
-(syntax: #export (do_to obj {methods (p.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)
-                     (ClassName::method2 arg3 arg4 arg5)))}
-  (with_gensyms [g!obj]
-    (wrap (list (` (let [(~ g!obj) (~ obj)]
-                     (exec (~+ (list\map (complete_call$ g!obj) methods))
-                       (~ g!obj))))))))
-
-(def: (class_import$ [full_name params])
-  (-> Class_Declaration Code)
-  (let [params' (list\map (|>> product.left code.local_identifier) params)]
-    (` (def: (~ (code.identifier ["" full_name]))
-         {#..jvm_class (~ (code.text full_name))}
-         Type
-         (All [(~+ params')]
-           (primitive (~ (code.text (sanitize full_name)))
-                      [(~+ params')]))))))
-
-(def: (member_type_vars class_tvars member)
-  (-> (List Type_Parameter) Import_Member_Declaration (List Type_Parameter))
-  (case member
-    (#ConstructorDecl [commons _])
-    (list\compose class_tvars (get@ #import_member_tvars commons))
-
-    (#MethodDecl [commons _])
-    (case (get@ #import_member_kind commons)
-      #StaticIMK
-      (get@ #import_member_tvars commons)
-
-      _
-      (list\compose class_tvars (get@ #import_member_tvars commons)))
-
-    _
-    class_tvars))
-
-(def: (member_def_arg_bindings type_params class member)
-  (-> (List Type_Parameter) Class_Declaration Import_Member_Declaration (Meta [(List [Bit Code]) (List Text) (List Code)]))
-  (case member
-    (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _]))
-    (let [(^slots [#import_member_tvars #import_member_args]) commons]
-      (do {! meta.monad}
-        [arg_inputs (monad.map !
-                               (: (-> [Bit GenericType] (Meta [Bit Code]))
-                                  (function (_ [maybe? _])
-                                    (with_gensyms [arg_name]
-                                      (wrap [maybe? arg_name]))))
-                               import_member_args)
-         #let [arg_classes (: (List Text)
-                              (list\map (|>> product.right (simple_class$ (list\compose type_params import_member_tvars)))
-                                        import_member_args))
-               arg_types (list\map (: (-> [Bit GenericType] Code)
-                                      (function (_ [maybe? arg])
-                                        (let [arg_type (class->type (get@ #import_member_mode commons) type_params arg)]
-                                          (if maybe?
-                                            (` (Maybe (~ arg_type)))
-                                            arg_type))))
-                                   import_member_args)]]
-        (wrap [arg_inputs arg_classes arg_types])))
-
-    _
-    (\ meta.monad wrap [(list) (list) (list)])))
-
-(def: (decorate_return_maybe member return_term)
-  (-> Import_Member_Declaration Code Code)
-  (case member
-    (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _]))
-    (if (get@ #import_member_maybe? commons)
-      (` (??? (~ return_term)))
-      (let [g!temp (` ((~' ~') (~ (code.identifier ["" " Ω "]))))]
-        (` (let [(~ g!temp) (~ return_term)]
-             (if (not (..null? (:coerce (primitive "java.lang.Object")
-                                        (~ g!temp))))
-               (~ g!temp)
-               (error! "Cannot produce null references from method calls."))))))
-
-    _
-    return_term))
-
-(template [  ]
-  [(def: ( member return_term)
-     (-> Import_Member_Declaration Code Code)
-     (case member
-       (^or (#ConstructorDecl [commons _]) (#MethodDecl [commons _]))
-       (if (get@  commons)
-         
-         return_term)
-
-       _
-       return_term))]
-
-  [decorate_return_try #import_member_try? (` (..try (~ return_term)))]
-  [decorate_return_io  #import_member_io?  (` ((~! io.io) (~ return_term)))]
-  )
-
-(def: (free_type_param? [name bounds])
-  (-> Type_Parameter Bit)
-  (case bounds
-    #.Nil #1
-    _     #0))
-
-(def: (type_param->type_arg [name _])
-  (-> Type_Parameter Code)
-  (code.identifier ["" name]))
-
-(template [    ]
-  [(def: ( mode [class expression])
-     (-> Primitive_Mode [Text Code] Code)
-     (case mode
-       #ManualPrM
-       expression
-       
-       #AutoPrM
-       (case class
-         "byte"  (` ( (~ expression)))
-         "short" (` ( (~ expression)))
-         "int"   (` ( (~ expression)))
-         "float" (` ( (~ expression)))
-         _       expression)))]
-
-  [auto_convert_input  long_to_byte long_to_short long_to_int double_to_float]
-  [auto_convert_output byte_to_long short_to_long int_to_long float_to_double]
-  )
-
-(def: (un_quote quoted)
-  (-> Code Code)
-  (` ((~' ~) (~ quoted))))
-
-(def: (jvm_extension_inputs mode classes inputs)
-  (-> Primitive_Mode (List Text) (List [Bit Code]) (List Code))
-  (|> inputs
-      (list\map (function (_ [maybe? input])
-                  (if maybe?
-                    (` ((~! !!!) (~ (un_quote input))))
-                    (un_quote input))))
-      (list.zip/2 classes)
-      (list\map (auto_convert_input mode))))
-
-(def: (import_name format class member)
-  (-> Text Text Text Text)
-  (|> format
-      (text.replace_all "#" class)
-      (text.replace_all "." member)))
-
-(def: (member_def_interop type_params kind class [arg_function_inputs arg_classes arg_types] member method_prefix import_format)
-  (-> (List Type_Parameter) Class_Kind Class_Declaration [(List [Bit Code]) (List Text) (List Code)] Import_Member_Declaration Text Text (Meta (List Code)))
-  (let [[full_name class_tvars] class
-        full_name (sanitize full_name)
-        all_params (|> (member_type_vars class_tvars member)
-                       (list.filter free_type_param?)
-                       (list\map type_param->type_arg))]
-    (case member
-      (#EnumDecl enum_members)
-      (do {! meta.monad}
-        [#let [enum_type (: Code
-                            (case class_tvars
-                              #.Nil
-                              (` (primitive (~ (code.text full_name))))
-
-                              _
-                              (let [=class_tvars (|> class_tvars
-                                                     (list.filter free_type_param?)
-                                                     (list\map type_param->type_arg))]
-                                (` (All [(~+ =class_tvars)] (primitive (~ (code.text full_name)) [(~+ =class_tvars)]))))))
-               getter_interop (: (-> Text Code)
-                                 (function (_ name)
-                                   (let [getter_name (code.identifier ["" (..import_name import_format method_prefix name)])]
-                                     (` (def: (~ getter_name)
-                                          (~ enum_type)
-                                          ((~ (code.text (format "jvm getstatic" ":" full_name ":" name)))))))))]]
-        (wrap (list\map getter_interop enum_members)))
-      
-      (#ConstructorDecl [commons _])
-      (do meta.monad
-        [#let [def_name (code.identifier ["" (..import_name import_format method_prefix (get@ #import_member_alias commons))])
-               jvm_extension (code.text (format "jvm new" ":" full_name ":" (text.join_with "," arg_classes)))
-               jvm_interop (|> (` ((~ jvm_extension)
-                                   (~+ (jvm_extension_inputs (get@ #import_member_mode commons) arg_classes arg_function_inputs))))
-                               (decorate_return_maybe member)
-                               (decorate_return_try member)
-                               (decorate_return_io member))]]
-        (wrap (list (` ((~! syntax:) ((~ def_name) (~+ (list\map product.right arg_function_inputs)))
-                        ((~' wrap) (.list (.` (~ jvm_interop)))))))))
-
-      (#MethodDecl [commons method])
-      (with_gensyms [g!obj]
-        (do meta.monad
-          [#let [def_name (code.identifier ["" (..import_name import_format method_prefix (get@ #import_member_alias commons))])
-                 (^slots [#import_member_kind]) commons
-                 (^slots [#import_method_name]) method
-                 [jvm_op object_ast] (: [Text (List Code)]
-                                        (case import_member_kind
-                                          #StaticIMK
-                                          ["invokestatic"
-                                           (list)]
-
-                                          #VirtualIMK
-                                          (case kind
-                                            #Class
-                                            ["invokevirtual"
-                                             (list g!obj)]
-                                            
-                                            #Interface
-                                            ["invokeinterface"
-                                             (list g!obj)]
-                                            )))
-                 jvm_extension (code.text (format "jvm " jvm_op ":" full_name ":" import_method_name ":" (text.join_with "," arg_classes)))
-                 jvm_interop (|> [(simple_class$ (list) (get@ #import_method_return method))
-                                  (` ((~ jvm_extension) (~+ (list\map un_quote object_ast))
-                                      (~+ (jvm_extension_inputs (get@ #import_member_mode commons) arg_classes arg_function_inputs))))]
-                                 (auto_convert_output (get@ #import_member_mode commons))
-                                 (decorate_return_maybe member)
-                                 (decorate_return_try member)
-                                 (decorate_return_io member))]]
-          (wrap (list (` ((~! syntax:) ((~ def_name) (~+ (list\map product.right arg_function_inputs)) (~+ object_ast))
-                          ((~' wrap) (.list (.` (~ jvm_interop))))))))))
-
-      (#FieldAccessDecl fad)
-      (do meta.monad
-        [#let [(^open ".") fad
-               base_gtype (class->type import_field_mode type_params import_field_type)
-               classC (class_decl_type$ class)
-               typeC (if import_field_maybe?
-                       (` (Maybe (~ base_gtype)))
-                       base_gtype)
-               tvar_asts (: (List Code)
-                            (|> class_tvars
-                                (list.filter free_type_param?)
-                                (list\map type_param->type_arg)))
-               getter_name (code.identifier ["" (..import_name import_format method_prefix import_field_name)])
-               setter_name (code.identifier ["" (..import_name import_format method_prefix (format import_field_name "!"))])]
-         getter_interop (with_gensyms [g!obj]
-                          (let [getter_call (if import_field_static?
-                                              (` ((~ getter_name)))
-                                              (` ((~ getter_name) (~ g!obj))))
-                                getter_body (<| (auto_convert_output import_field_mode)
-                                                [(simple_class$ (list) import_field_type)
-                                                 (if import_field_static?
-                                                   (let [jvm_extension (code.text (format "jvm getstatic" ":" full_name ":" import_field_name))]
-                                                     (` ((~ jvm_extension))))
-                                                   (let [jvm_extension (code.text (format "jvm getfield" ":" full_name ":" import_field_name))]
-                                                     (` ((~ jvm_extension) (~ (un_quote g!obj))))))])
-                                getter_body (if import_field_maybe?
-                                              (` ((~! ???) (~ getter_body)))
-                                              getter_body)
-                                getter_body (if import_field_setter?
-                                              (` ((~! io.io) (~ getter_body)))
-                                              getter_body)]
-                            (wrap (` ((~! syntax:) (~ getter_call)
-                                      ((~' wrap) (.list (.` (~ getter_body)))))))))
-         setter_interop (: (Meta (List Code))
-                           (if import_field_setter?
-                             (with_gensyms [g!obj g!value]
-                               (let [setter_call (if import_field_static?
-                                                   (` ((~ setter_name) (~ g!value)))
-                                                   (` ((~ setter_name) (~ g!value) (~ g!obj))))
-                                     setter_value (auto_convert_input import_field_mode
-                                                                      [(simple_class$ (list) import_field_type) (un_quote g!value)])
-                                     setter_value (if import_field_maybe?
-                                                    (` ((~! !!!) (~ setter_value)))
-                                                    setter_value)
-                                     setter_command (format (if import_field_static? "jvm putstatic" "jvm putfield")
-                                                            ":" full_name ":" import_field_name)
-                                     g!obj+ (: (List Code)
-                                               (if import_field_static?
-                                                 (list)
-                                                 (list (un_quote g!obj))))]
-                                 (wrap (list (` ((~! syntax:) (~ setter_call)
-                                                 ((~' wrap) (.list (.` ((~! io.io) ((~ (code.text setter_command)) (~+ g!obj+) (~ setter_value))))))))))))
-                             (wrap (list))))]
-        (wrap (list& getter_interop setter_interop)))
-      )))
-
-(def: (member_import$ type_params kind class [import_format member])
-  (-> (List Type_Parameter) Class_Kind Class_Declaration [Text Import_Member_Declaration] (Meta (List Code)))
-  (let [[method_prefix _] class]
-    (do meta.monad
-      [=args (member_def_arg_bindings type_params class member)]
-      (member_def_interop type_params kind class =args member method_prefix import_format))))
-
-(type: (java/lang/Class a)
-  (primitive "java.lang.Class" [a]))
-
-(def: interface?
-  (All [a] (-> (java/lang/Class a) Bit))
-  (|>> "jvm invokevirtual:java.lang.Class:isInterface:"))
-
-(def: (load_class class_name)
-  (-> Text (Try (java/lang/Class Any)))
-  (..try ("jvm invokestatic:java.lang.Class:forName:java.lang.String" class_name)))
-
-(def: (class_kind [class_name _])
-  (-> Class_Declaration (Meta Class_Kind))
-  (let [class_name (..sanitize class_name)]
-    (case (..load_class class_name)
-      (#try.Success class)
-      (\ meta.monad wrap (if (interface? class)
-                           #Interface
-                           #Class))
-
-      (#try.Failure error)
-      (meta.fail (format "Cannot load class: " class_name text.new_line
-                         error)))))
-
-(syntax: #export (import:
-                   {class_decl ..class_decl^}
-                   {bundles (p.some (..bundle (product.right class_decl)))})
-  {#.doc (doc "Allows importing JVM classes, and using them as types."
-              "Their methods, fields and enum options can also be imported."
-              (import: java/lang/Object
-                ["#::."
-                 (new [])
-                 (equals [java/lang/Object] boolean)
-                 (wait [int] #io #try void)])
-              
-              "Special options can also be given for the return values."
-              "#? means that the values will be returned inside a Maybe type. That way, null becomes #.None."
-              "#try means that the computation might throw an exception, and the return value will be wrapped by the Try type."
-              "#io means the computation has side effects, and will be wrapped by the IO type."
-              "These options must show up in the following order [#io #try #?] (although, each option can be used independently)."
-              (import: java/lang/String
-                ["#::."
-                 (new [[byte]])
-                 (#static valueOf [char] java/lang/String)
-                 (#static valueOf #as int_valueOf [int] java/lang/String)])
-
-              (import: (java/util/List e)
-                ["#::."
-                 (size [] int)
-                 (get [int] e)])
-
-              (import: (java/util/ArrayList a)
-                ["#::."
-                 ([T] toArray [[T]] [T])])
-              
-              "The class-type that is generated is of the fully-qualified name."
-              "This avoids a clash between the java.util.List type, and Lux's own List type."
-              "All enum options to be imported must be specified."
-              (import: java/lang/Character$UnicodeScript
-                ["#::."
-                 (#enum ARABIC CYRILLIC LATIN)])
-
-              "It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-parameters."
-              "Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes)."
-              (import: (lux/concurrency/promise/JvmPromise A)
-                ["#::."
-                 (resolve [A] boolean)
-                 (poll [] A)
-                 (wasResolved [] boolean)
-                 (waitOn [lux/Function] void)
-                 (#static [A] make [A] (lux/concurrency/promise/JvmPromise A))])
-              
-              "Also, the names of the imported members will look like Class::member"
-              (java/lang/Object::new [])
-              (java/lang/Object::equals [other_object] my_object)
-              (java/util/List::size [] my_list)
-              java/lang/Character$UnicodeScript::LATIN
-              )}
-  (do {! meta.monad}
-    [kind (class_kind class_decl)
-     =members (|> bundles
-                  (list\map (function (_ [import_format members])
-                              (list\map (|>> [import_format]) members)))
-                  list.concat
-                  (monad.map ! (member_import$ (product.right class_decl) kind class_decl)))]
-    (wrap (list& (class_import$ class_decl) (list\join =members)))))
-
-(syntax: #export (array {type (..generic_type^ (list))}
-                        size)
-  {#.doc (doc "Create an array of the given type, with the given size."
-              (array java/lang/Object 10))}
-  (case type
-    (^template [ ]
-      [(^ (#GenericClass  (list)))
-       (wrap (list (` ( (~ size)))))])
-    (["boolean" "jvm znewarray"]
-     ["byte"    "jvm bnewarray"]
-     ["short"   "jvm snewarray"]
-     ["int"     "jvm inewarray"]
-     ["long"    "jvm lnewarray"]
-     ["float"   "jvm fnewarray"]
-     ["double"  "jvm dnewarray"]
-     ["char"    "jvm cnewarray"])
-
-    _
-    (wrap (list (` ("jvm anewarray" (~ (code.text (generic_type$ type))) (~ size)))))))
-
-(syntax: #export (array_length array)
-  {#.doc (doc "Gives the length of an array."
-              (array_length my_array))}
-  (wrap (list (` ("jvm arraylength" (~ array))))))
-
-(def: (type->class_name type)
-  (-> Type (Meta Text))
-  (if (type\= Any type)
-    (\ meta.monad wrap "java.lang.Object")
-    (case type
-      (#.Primitive name params)
-      (\ meta.monad wrap name)
-
-      (#.Apply A F)
-      (case (type.apply (list A) F)
-        #.None
-        (meta.fail (format "Cannot apply type: " (type.format F) " to " (type.format A)))
-
-        (#.Some type')
-        (type->class_name type'))
-      
-      (#.Named _ type')
-      (type->class_name type')
-
-      _
-      (meta.fail (format "Cannot convert to JvmType: " (type.format type))))))
-
-(syntax: #export (array_read idx array)
-  {#.doc (doc "Loads an element from an array."
-              (array_read 10 my_array))}
-  (case array
-    [_ (#.Identifier array_name)]
-    (do meta.monad
-      [array_type (meta.find_type array_name)
-       array_jvm_type (type->class_name array_type)]
-      (case array_jvm_type
-        (^template [ ]
-          [
-           (wrap (list (` ( (~ array) (~ idx)))))])
-        (["[Z" "jvm zaload"]
-         ["[B" "jvm baload"]
-         ["[S" "jvm saload"]
-         ["[I" "jvm iaload"]
-         ["[J" "jvm jaload"]
-         ["[F" "jvm faload"]
-         ["[D" "jvm daload"]
-         ["[C" "jvm caload"])
-
-        _
-        (wrap (list (` ("jvm aaload" (~ array) (~ idx)))))))
-
-    _
-    (with_gensyms [g!array]
-      (wrap (list (` (let [(~ g!array) (~ array)]
-                       (..array_read (~ idx) (~ g!array)))))))))
-
-(syntax: #export (array_write idx value array)
-  {#.doc (doc "Stores an element into an array."
-              (array_write 10 my_object my_array))}
-  (case array
-    [_ (#.Identifier array_name)]
-    (do meta.monad
-      [array_type (meta.find_type array_name)
-       array_jvm_type (type->class_name array_type)]
-      (case array_jvm_type
-        (^template [ ]
-          [
-           (wrap (list (` ( (~ array) (~ idx) (~ value)))))])
-        (["[Z" "jvm zastore"]
-         ["[B" "jvm bastore"]
-         ["[S" "jvm sastore"]
-         ["[I" "jvm iastore"]
-         ["[J" "jvm jastore"]
-         ["[F" "jvm fastore"]
-         ["[D" "jvm dastore"]
-         ["[C" "jvm castore"])
-
-        _
-        (wrap (list (` ("jvm aastore" (~ array) (~ idx) (~ value)))))))
-
-    _
-    (with_gensyms [g!array]
-      (wrap (list (` (let [(~ g!array) (~ array)]
-                       (..array_write (~ idx) (~ value) (~ g!array)))))))))
-
-(syntax: #export (class_for {type (..generic_type^ (list))})
-  {#.doc (doc "Loads the class as a java.lang.Class object."
-              (class_for java/lang/String))}
-  (wrap (list (` ("jvm object class" (~ (code.text (simple_class$ (list) type))))))))
-
-(syntax: #export (type {type (..generic_type^ (list))})
-  (wrap (list (class->type #ManualPrM (list) type))))
diff --git a/stdlib/source/lux/host.php.lux b/stdlib/source/lux/host.php.lux
deleted file mode 100644
index ac0daf9c5..000000000
--- a/stdlib/source/lux/host.php.lux
+++ /dev/null
@@ -1,307 +0,0 @@
-(.module:
-  [lux (#- Alias)
-   ["." meta]
-   ["@" target]
-   [abstract
-    [monad (#+ do)]]
-   [control
-    ["." io]
-    ["<>" parser ("#\." monad)
-     ["<.>" code (#+ Parser)]]]
-   [data
-    ["." product]
-    ["." maybe]
-    ["." text
-     ["%" format (#+ format)]]
-    [collection
-     ["." list ("#\." functor fold)]]]
-   [type
-    abstract]
-   [macro (#+ with_gensyms)
-    [syntax (#+ syntax:)]
-    ["." code]
-    ["." template]]])
-
-(abstract: #export (Object brand) Any)
-
-(template []
-  [(with_expansions [ (template.identifier [ "'"])]
-     (abstract: #export  Any)
-     (type: #export 
-       (..Object )))]
-
-  [Null]
-  [Function]
-  )
-
-(template [ ]
-  [(type: #export 
-     )]
-
-  [Boolean Bit]
-  [Integer Int]
-  [Float   Frac]
-  [String  Text]
-  )
-
-(type: Nullable
-  [Bit Code])
-
-(def: nullable
-  (Parser Nullable)
-  (let [token (' #?)]
-    (<| (<>.and (<>.parses? (.this! token)))
-        (<>.after (<>.not (.this! token)))
-        .any)))
-
-(type: Alias
-  Text)
-
-(def: alias
-  (Parser Alias)
-  (<>.after (.this! (' #as)) .local_identifier))
-
-(type: Field
-  [Bit Text (Maybe Alias) Nullable])
-
-(def: static!
-  (Parser Any)
-  (.this! (' #static)))
-
-(def: field
-  (Parser Field)
-  (.form ($_ <>.and
-                   (<>.parses? ..static!)
-                   .local_identifier
-                   (<>.maybe ..alias)
-                   ..nullable)))
-
-(def: constant
-  (Parser Field)
-  (.form ($_ <>.and
-                   (<>\wrap true)
-                   .local_identifier
-                   (<>.maybe ..alias)
-                   ..nullable)))
-
-(type: Common_Method
-  {#name Text
-   #alias (Maybe Alias)
-   #inputs (List Nullable)
-   #io? Bit
-   #try? Bit
-   #output Nullable})
-
-(type: Static_Method Common_Method)
-(type: Virtual_Method Common_Method)
-
-(type: Method
-  (#Static Static_Method)
-  (#Virtual Virtual_Method))
-
-(def: common_method
-  (Parser Common_Method)
-  ($_ <>.and
-      .local_identifier
-      (<>.maybe ..alias)
-      (.tuple (<>.some ..nullable))
-      (<>.parses? (.this! (' #io)))
-      (<>.parses? (.this! (' #try)))
-      ..nullable))
-
-(def: static_method
-  (<>.after ..static! ..common_method))
-
-(def: method
-  (Parser Method)
-  (.form (<>.or ..static_method
-                      ..common_method)))
-
-(type: Member
-  (#Field Field)
-  (#Method Method))
-
-(def: member
-  (Parser Member)
-  ($_ <>.or
-      ..field
-      ..method
-      ))
-
-(def: input_variables
-  (-> (List Nullable) (List [Bit Code]))
-  (|>> list.enumeration
-       (list\map (function (_ [idx [nullable? type]])
-                   [nullable? (|> idx %.nat code.local_identifier)]))))
-
-(def: (nullable_type [nullable? type])
-  (-> Nullable Code)
-  (if nullable?
-    (` (.Maybe (~ type)))
-    type))
-
-(def: (with_null g!temp [nullable? input])
-  (-> Code [Bit Code] Code)
-  (if nullable?
-    (` (case (~ input)
-         (#.Some (~ g!temp))
-         (~ g!temp)
-
-         #.Null
-         ("php object null")))
-    input))
-
-(def: (without_null g!temp [nullable? outputT] output)
-  (-> Code Nullable Code Code)
-  (if nullable?
-    (` (let [(~ g!temp) (~ output)]
-         (if ("php object null?" (~ g!temp))
-           #.None
-           (#.Some (~ g!temp)))))
-    (` (let [(~ g!temp) (~ output)]
-         (if (not ("php object null?" (~ g!temp)))
-           (~ g!temp)
-           (.error! "Null is an invalid value!"))))))
-
-(type: Import
-  (#Class Text (Maybe Alias) (List Member))
-  (#Function Static_Method)
-  (#Constant Field))
-
-(def: import
-  (Parser Import)
-  ($_ <>.or
-      ($_ <>.and
-          .local_identifier
-          (<>.maybe ..alias)
-          (<>.some member))
-      (.form ..common_method)
-      ..constant
-      ))
-
-(syntax: #export (try expression)
-  {#.doc (doc (case (try (risky_computation input))
-                (#.Right success)
-                (do_something success)
-
-                (#.Left error)
-                (recover_from_failure error)))}
-  (wrap (list (` ("lux try" ((~! io.io) (~ expression)))))))
-
-(def: (with_io with? without)
-  (-> Bit Code Code)
-  (if with?
-    (` (io.io (~ without)))
-    without))
-
-(def: (io_type io? rawT)
-  (-> Bit Code Code)
-  (if io?
-    (` (io.IO (~ rawT)))
-    rawT))
-
-(def: (with_try with? without_try)
-  (-> Bit Code Code)
-  (if with?
-    (` (..try (~ without_try)))
-    without_try))
-
-(def: (try_type try? rawT)
-  (-> Bit Code Code)
-  (if try?
-    (` (.Either .Text (~ rawT)))
-    rawT))
-
-(def: (make_function g!method g!temp source inputsT io? try? outputT)
-  (-> Code Code Code (List Nullable) Bit Bit Nullable Code)
-  (let [g!inputs (input_variables inputsT)]
-    (` (def: ((~ g!method)
-              [(~+ (list\map product.right g!inputs))])
-         (-> [(~+ (list\map nullable_type inputsT))]
-             (~ (|> (nullable_type outputT)
-                    (try_type try?)
-                    (io_type io?))))
-         (:assume
-          (~ (<| (with_io io?)
-                 (with_try try?)
-                 (without_null g!temp outputT)
-                 (` ("php apply"
-                     (:coerce ..Function (~ source))
-                     (~+ (list\map (with_null g!temp) g!inputs)))))))))))
-
-(syntax: #export (import: {import ..import})
-  (with_gensyms [g!temp]
-    (case import
-      (#Class [class alias members])
-      (with_gensyms [g!object]
-        (let [qualify (: (-> Text Code)
-                         (|>> (format (maybe.default class alias) "::") code.local_identifier))
-              g!type (code.local_identifier (maybe.default class alias))
-              class_import (` ("php constant" (~ (code.text class))))]
-          (wrap (list& (` (type: (~ g!type)
-                            (..Object (primitive (~ (code.text class))))))
-                       (list\map (function (_ member)
-                                   (case member
-                                     (#Field [static? field alias fieldT])
-                                     (if static?
-                                       (` ((~! syntax:) ((~ (qualify (maybe.default field alias))))
-                                           (\ (~! meta.monad) (~' wrap)
-                                              (list (` (.:coerce (~ (nullable_type fieldT))
-                                                                 ("php constant" (~ (code.text (format class "::" field))))))))))
-                                       (` (def: ((~ (qualify field))
-                                                 (~ g!object))
-                                            (-> (~ g!type)
-                                                (~ (nullable_type fieldT)))
-                                            (:assume
-                                             (~ (without_null g!temp fieldT (` ("php object get" (~ (code.text field))
-                                                                                (:coerce (..Object .Any) (~ g!object))))))))))
-                                     
-                                     (#Method method)
-                                     (case method
-                                       (#Static [method alias inputsT io? try? outputT])
-                                       (..make_function (qualify (maybe.default method alias))
-                                                        g!temp
-                                                        (` ("php object get" (~ (code.text method))
-                                                            (:coerce (..Object .Any)
-                                                                     ("php constant" (~ (code.text (format class "::" method)))))))
-                                                        inputsT
-                                                        io?
-                                                        try?
-                                                        outputT)
-                                       
-                                       (#Virtual [method alias inputsT io? try? outputT])
-                                       (let [g!inputs (input_variables inputsT)]
-                                         (` (def: ((~ (qualify (maybe.default method alias)))
-                                                   [(~+ (list\map product.right g!inputs))]
-                                                   (~ g!object))
-                                              (-> [(~+ (list\map nullable_type inputsT))]
-                                                  (~ g!type)
-                                                  (~ (|> (nullable_type outputT)
-                                                         (try_type try?)
-                                                         (io_type io?))))
-                                              (:assume
-                                               (~ (<| (with_io io?)
-                                                      (with_try try?)
-                                                      (without_null g!temp outputT)
-                                                      (` ("php object do"
-                                                          (~ (code.text method))
-                                                          (~ g!object)
-                                                          (~+ (list\map (with_null g!temp) g!inputs)))))))))))))
-                                 members)))))
-      
-      (#Function [name alias inputsT io? try? outputT])
-      (let [imported (` ("php constant" (~ (code.text name))))]
-        (wrap (list (..make_function (code.local_identifier (maybe.default name alias))
-                                     g!temp
-                                     imported
-                                     inputsT
-                                     io?
-                                     try?
-                                     outputT))))
-
-      (#Constant [_ name alias fieldT])
-      (let [imported (` ("php constant" (~ (code.text name))))]
-        (wrap (list (` ((~! syntax:) ((~ (code.local_identifier (maybe.default name alias))))
-                        (\ (~! meta.monad) (~' wrap)
-                           (list (` (.:coerce (~ (nullable_type fieldT)) (~ imported))))))))))
-      )))
diff --git a/stdlib/source/lux/host.py.lux b/stdlib/source/lux/host.py.lux
deleted file mode 100644
index ed67b3705..000000000
--- a/stdlib/source/lux/host.py.lux
+++ /dev/null
@@ -1,319 +0,0 @@
-(.module:
-  [lux #*
-   ["." meta]
-   ["@" target]
-   [abstract
-    [monad (#+ do)]]
-   [control
-    ["." io]
-    ["<>" parser
-     ["" code (#+ Parser)]]]
-   [data
-    ["." product]
-    ["." maybe]
-    ["." text
-     ["%" format (#+ format)]]
-    [collection
-     ["." list ("#\." functor fold)]]]
-   [type
-    abstract]
-   [macro (#+ with_gensyms)
-    [syntax (#+ syntax:)]
-    ["." code]
-    ["." template]]])
-
-(abstract: #export (Object brand) Any)
-
-(template []
-  [(with_expansions [ (template.identifier [ "'"])]
-     (abstract: #export  Any)
-     (type: #export 
-       (..Object )))]
-
-  [None]
-  [Function]
-  [Dict]
-  )
-
-(template [ ]
-  [(type: #export 
-     )]
-
-  [Boolean Bit]
-  [Integer Int]
-  [Float   Frac]
-  [String  Text]
-  )
-
-(type: Noneable
-  [Bit Code])
-
-(def: noneable
-  (Parser Noneable)
-  (let [token (' #?)]
-    (<| (<>.and (<>.parses? (.this! token)))
-        (<>.after (<>.not (.this! token)))
-        .any)))
-
-(type: Constructor
-  (List Noneable))
-
-(def: constructor
-  (Parser Constructor)
-  (.form (<>.after (.this! (' new))
-                      (.tuple (<>.some ..noneable)))))
-
-(type: Field
-  [Bit Text Noneable])
-
-(def: static!
-  (Parser Any)
-  (.this! (' #static)))
-
-(def: field
-  (Parser Field)
-  (.form ($_ <>.and
-                (<>.parses? ..static!)
-                .local_identifier
-                ..noneable)))
-
-(type: Common_Method
-  {#name Text
-   #alias (Maybe Text)
-   #inputs (List Noneable)
-   #io? Bit
-   #try? Bit
-   #output Noneable})
-
-(type: Static_Method Common_Method)
-(type: Virtual_Method Common_Method)
-
-(type: Method
-  (#Static Static_Method)
-  (#Virtual Virtual_Method))
-
-(def: common_method
-  (Parser Common_Method)
-  ($_ <>.and
-      .local_identifier
-      (<>.maybe (<>.after (.this! (' #as)) .local_identifier))
-      (.tuple (<>.some ..noneable))
-      (<>.parses? (.this! (' #io)))
-      (<>.parses? (.this! (' #try)))
-      ..noneable))
-
-(def: static_method
-  (<>.after ..static! ..common_method))
-
-(def: method
-  (Parser Method)
-  (.form (<>.or ..static_method
-                   ..common_method)))
-
-(type: Member
-  (#Constructor Constructor)
-  (#Field Field)
-  (#Method Method))
-
-(def: member
-  (Parser Member)
-  ($_ <>.or
-      ..constructor
-      ..field
-      ..method
-      ))
-
-(def: input_variables
-  (-> (List Noneable) (List [Bit Code]))
-  (|>> list.enumeration
-       (list\map (function (_ [idx [noneable? type]])
-                   [noneable? (|> idx %.nat code.local_identifier)]))))
-
-(def: (noneable_type [noneable? type])
-  (-> Noneable Code)
-  (if noneable?
-    (` (.Maybe (~ type)))
-    type))
-
-(def: (with_none g!temp [noneable? input])
-  (-> Code [Bit Code] Code)
-  (if noneable?
-    (` (case (~ input)
-         (#.Some (~ g!temp))
-         (~ g!temp)
-
-         #.None
-         ("python object none")))
-    input))
-
-(def: (without_none g!temp [noneable? outputT] output)
-  (-> Code Noneable Code Code)
-  (if noneable?
-    (` (let [(~ g!temp) (~ output)]
-         (if ("python object none?" (~ g!temp))
-           #.None
-           (#.Some (~ g!temp)))))
-    (` (let [(~ g!temp) (~ output)]
-         (if (not ("python object none?" (~ g!temp)))
-           (~ g!temp)
-           (.error! "None is an invalid value!"))))))
-
-(type: Import
-  (#Class [Text (List Member)])
-  (#Function Static_Method))
-
-(def: import
-  ($_ <>.or
-      ($_ <>.and
-          .local_identifier
-          (<>.some member))
-      (.form ..common_method)
-      ))
-
-(syntax: #export (try expression)
-  {#.doc (doc (case (try (risky_computation input))
-                (#.Right success)
-                (do_something success)
-
-                (#.Left error)
-                (recover_from_failure error)))}
-  (wrap (list (` ("lux try" ((~! io.io) (~ expression)))))))
-
-(def: (with_io with? without)
-  (-> Bit Code Code)
-  (if with?
-    (` (io.io (~ without)))
-    without))
-
-(def: (io_type io? rawT)
-  (-> Bit Code Code)
-  (if io?
-    (` (io.IO (~ rawT)))
-    rawT))
-
-(def: (with_try with? without_try)
-  (-> Bit Code Code)
-  (if with?
-    (` (..try (~ without_try)))
-    without_try))
-
-(def: (try_type try? rawT)
-  (-> Bit Code Code)
-  (if try?
-    (` (.Either .Text (~ rawT)))
-    rawT))
-
-(def: (make_function g!method g!temp source inputsT io? try? outputT)
-  (-> Code Code Code (List Noneable) Bit Bit Noneable Code)
-  (let [g!inputs (input_variables inputsT)]
-    (` (def: ((~ g!method)
-              [(~+ (list\map product.right g!inputs))])
-         (-> [(~+ (list\map noneable_type inputsT))]
-             (~ (|> (noneable_type outputT)
-                    (try_type try?)
-                    (io_type io?))))
-         (:assume
-          (~ (<| (with_io io?)
-                 (with_try try?)
-                 (without_none g!temp outputT)
-                 (` ("python apply"
-                     (:coerce ..Function (~ source))
-                     (~+ (list\map (with_none g!temp) g!inputs)))))))))))
-
-(syntax: #export (import: {import ..import})
-  (with_gensyms [g!temp]
-    (case import
-      (#Class [class members])
-      (with_gensyms [g!object]
-        (let [qualify (: (-> Text Code)
-                         (|>> (format class "::") code.local_identifier))
-              g!type (code.local_identifier class)
-              real_class (text.replace_all "/" "." class)
-              imported (case (text.split_all_with "/" class)
-                         (#.Cons head tail)
-                         (list\fold (function (_ sub super)
-                                      (` ("python object get" (~ (code.text sub))
-                                          (:coerce (..Object .Any) (~ super)))))
-                                    (` ("python import" (~ (code.text head))))
-                                    tail)
-                         
-                         #.Nil
-                         (` ("python import" (~ (code.text class)))))]
-          (wrap (list& (` (type: (~ g!type)
-                            (..Object (primitive (~ (code.text real_class))))))
-                       (list\map (function (_ member)
-                                   (case member
-                                     (#Constructor inputsT)
-                                     (let [g!inputs (input_variables inputsT)]
-                                       (` (def: ((~ (qualify "new"))
-                                                 [(~+ (list\map product.right g!inputs))])
-                                            (-> [(~+ (list\map noneable_type inputsT))]
-                                                (~ g!type))
-                                            (:assume
-                                             ("python apply"
-                                              (:coerce ..Function (~ imported))
-                                              (~+ (list\map (with_none g!temp) g!inputs)))))))
-                                     
-                                     (#Field [static? field fieldT])
-                                     (if static?
-                                       (` ((~! syntax:) ((~ (qualify field)))
-                                           (\ (~! meta.monad) (~' wrap)
-                                              (list (` (.:coerce (~ (noneable_type fieldT))
-                                                                 ("python object get" (~ (code.text field))
-                                                                  (:coerce (..Object .Any) (~ imported)))))))))
-                                       (` (def: ((~ (qualify field))
-                                                 (~ g!object))
-                                            (-> (~ g!type)
-                                                (~ (noneable_type fieldT)))
-                                            (:assume
-                                             (~ (without_none g!temp fieldT (` ("python object get" (~ (code.text field))
-                                                                                (:coerce (..Object .Any) (~ g!object))))))))))
-                                     
-                                     (#Method method)
-                                     (case method
-                                       (#Static [method alias inputsT io? try? outputT])
-                                       (..make_function (qualify (maybe.default method alias))
-                                                        g!temp
-                                                        (` ("python object get" (~ (code.text method))
-                                                            (:coerce (..Object .Any) (~ imported))))
-                                                        inputsT
-                                                        io?
-                                                        try?
-                                                        outputT)
-                                       
-                                       (#Virtual [method alias inputsT io? try? outputT])
-                                       (let [g!inputs (input_variables inputsT)]
-                                         (` (def: ((~ (qualify (maybe.default method alias)))
-                                                   [(~+ (list\map product.right g!inputs))]
-                                                   (~ g!object))
-                                              (-> [(~+ (list\map noneable_type inputsT))]
-                                                  (~ g!type)
-                                                  (~ (|> (noneable_type outputT)
-                                                         (try_type try?)
-                                                         (io_type io?))))
-                                              (:assume
-                                               (~ (<| (with_io io?)
-                                                      (with_try try?)
-                                                      (without_none g!temp outputT)
-                                                      (` ("python object do"
-                                                          (~ (code.text method))
-                                                          (~ g!object)
-                                                          (~+ (list\map (with_none g!temp) g!inputs)))))))))))))
-                                 members)))))
-      
-      (#Function [name alias inputsT io? try? outputT])
-      (wrap (list (..make_function (code.local_identifier (maybe.default name alias))
-                                   g!temp
-                                   (` ("python constant" (~ (code.text name))))
-                                   inputsT
-                                   io?
-                                   try?
-                                   outputT)))
-      )))
-
-(template: #export (lambda  )
-  (.:coerce ..Function
-            (`` ("python function"
-                 (~~ (template.count ))
-                 (.function (_ [])
-                   )))))
diff --git a/stdlib/source/lux/host.rb.lux b/stdlib/source/lux/host.rb.lux
deleted file mode 100644
index 63f14e8a3..000000000
--- a/stdlib/source/lux/host.rb.lux
+++ /dev/null
@@ -1,334 +0,0 @@
-(.module:
-  [lux (#- Alias)
-   ["." meta]
-   ["@" target]
-   [abstract
-    [monad (#+ do)]]
-   [control
-    ["." io]
-    ["<>" parser ("#\." monad)
-     ["<.>" code (#+ Parser)]]]
-   [data
-    ["." product]
-    ["." maybe]
-    ["." text
-     ["%" format (#+ format)]]
-    [collection
-     ["." list ("#\." functor fold)]]]
-   [type
-    abstract]
-   [macro (#+ with_gensyms)
-    [syntax (#+ syntax:)]
-    ["." code]
-    ["." template]]])
-
-(abstract: #export (Object brand) Any)
-
-(template []
-  [(with_expansions [ (template.identifier [ "'"])]
-     (abstract: #export  Any)
-     (type: #export 
-       (..Object )))]
-
-  [Nil]
-  [Function]
-  )
-
-(template [ ]
-  [(type: #export 
-     )]
-
-  [Boolean Bit]
-  [Integer Int]
-  [Float   Frac]
-  [String  Text]
-  )
-
-(type: Nilable
-  [Bit Code])
-
-(def: nilable
-  (Parser Nilable)
-  (let [token (' #?)]
-    (<| (<>.and (<>.parses? (.this! token)))
-        (<>.after (<>.not (.this! token)))
-        .any)))
-
-(type: Alias
-  Text)
-
-(def: alias
-  (Parser Alias)
-  (<>.after (.this! (' #as)) .local_identifier))
-
-(type: Field
-  [Bit Text (Maybe Alias) Nilable])
-
-(def: static!
-  (Parser Any)
-  (.this! (' #static)))
-
-(def: field
-  (Parser Field)
-  (.form ($_ <>.and
-                   (<>.parses? ..static!)
-                   .local_identifier
-                   (<>.maybe ..alias)
-                   ..nilable)))
-
-(def: constant
-  (Parser Field)
-  (.form ($_ <>.and
-                   (<>\wrap true)
-                   .local_identifier
-                   (<>.maybe ..alias)
-                   ..nilable)))
-
-(type: Common_Method
-  {#name Text
-   #alias (Maybe Alias)
-   #inputs (List Nilable)
-   #io? Bit
-   #try? Bit
-   #output Nilable})
-
-(type: Static_Method Common_Method)
-(type: Virtual_Method Common_Method)
-
-(type: Method
-  (#Static Static_Method)
-  (#Virtual Virtual_Method))
-
-(def: common_method
-  (Parser Common_Method)
-  ($_ <>.and
-      .local_identifier
-      (<>.maybe ..alias)
-      (.tuple (<>.some ..nilable))
-      (<>.parses? (.this! (' #io)))
-      (<>.parses? (.this! (' #try)))
-      ..nilable))
-
-(def: static_method
-  (<>.after ..static! ..common_method))
-
-(def: method
-  (Parser Method)
-  (.form (<>.or ..static_method
-                      ..common_method)))
-
-(type: Member
-  (#Field Field)
-  (#Method Method))
-
-(def: member
-  (Parser Member)
-  ($_ <>.or
-      ..field
-      ..method
-      ))
-
-(def: input_variables
-  (-> (List Nilable) (List [Bit Code]))
-  (|>> list.enumeration
-       (list\map (function (_ [idx [nilable? type]])
-                   [nilable? (|> idx %.nat code.local_identifier)]))))
-
-(def: (nilable_type [nilable? type])
-  (-> Nilable Code)
-  (if nilable?
-    (` (.Maybe (~ type)))
-    type))
-
-(def: (with_nil g!temp [nilable? input])
-  (-> Code [Bit Code] Code)
-  (if nilable?
-    (` (case (~ input)
-         (#.Some (~ g!temp))
-         (~ g!temp)
-
-         #.Nil
-         ("ruby object nil")))
-    input))
-
-(def: (without_nil g!temp [nilable? outputT] output)
-  (-> Code Nilable Code Code)
-  (if nilable?
-    (` (let [(~ g!temp) (~ output)]
-         (if ("ruby object nil?" (~ g!temp))
-           #.None
-           (#.Some (~ g!temp)))))
-    (` (let [(~ g!temp) (~ output)]
-         (if (not ("ruby object nil?" (~ g!temp)))
-           (~ g!temp)
-           (.error! "Nil is an invalid value!"))))))
-
-(type: Import
-  (#Class Text (Maybe Alias) (List Member))
-  (#Function Static_Method)
-  (#Constant Field))
-
-(def: import
-  (Parser [(Maybe Text) Import])
-  ($_ <>.and
-      (<>.maybe .text)
-      ($_ <>.or
-          ($_ <>.and
-              .local_identifier
-              (<>.maybe ..alias)
-              (<>.some member))
-          (.form ..common_method)
-          ..constant
-          )))
-
-(syntax: #export (try expression)
-  {#.doc (doc (case (try (risky_computation input))
-                (#.Right success)
-                (do_something success)
-
-                (#.Left error)
-                (recover_from_failure error)))}
-  (wrap (list (` ("lux try" ((~! io.io) (~ expression)))))))
-
-(def: (with_io with? without)
-  (-> Bit Code Code)
-  (if with?
-    (` (io.io (~ without)))
-    without))
-
-(def: (io_type io? rawT)
-  (-> Bit Code Code)
-  (if io?
-    (` (io.IO (~ rawT)))
-    rawT))
-
-(def: (with_try with? without_try)
-  (-> Bit Code Code)
-  (if with?
-    (` (..try (~ without_try)))
-    without_try))
-
-(def: (try_type try? rawT)
-  (-> Bit Code Code)
-  (if try?
-    (` (.Either .Text (~ rawT)))
-    rawT))
-
-(def: (make_function g!method g!temp source inputsT io? try? outputT)
-  (-> Code Code Code (List Nilable) Bit Bit Nilable Code)
-  (let [g!inputs (input_variables inputsT)]
-    (` (def: ((~ g!method)
-              [(~+ (list\map product.right g!inputs))])
-         (-> [(~+ (list\map nilable_type inputsT))]
-             (~ (|> (nilable_type outputT)
-                    (try_type try?)
-                    (io_type io?))))
-         (:assume
-          (~ (<| (with_io io?)
-                 (with_try try?)
-                 (without_nil g!temp outputT)
-                 (` ("ruby apply"
-                     (:coerce ..Function (~ source))
-                     (~+ (list\map (with_nil g!temp) g!inputs)))))))))))
-
-(syntax: #export (import: {[?module import] ..import})
-  (with_gensyms [g!temp]
-    (case import
-      (#Class [class alias members])
-      (with_gensyms [g!object]
-        (let [qualify (: (-> Text Code)
-                         (|>> (format (maybe.default class alias) "::") code.local_identifier))
-              g!type (code.local_identifier (maybe.default class alias))
-              module_import (: (List Code)
-                               (case ?module
-                                 (#.Some module)
-                                 (list (` ("ruby import" (~ (code.text module)))))
-
-                                 #.None
-                                 (list)))
-              class_import (` ("ruby constant" (~ (code.text class))))]
-          (wrap (list& (` (type: (~ g!type)
-                            (..Object (primitive (~ (code.text class))))))
-                       (list\map (function (_ member)
-                                   (case member
-                                     (#Field [static? field alias fieldT])
-                                     (if static?
-                                       (` ((~! syntax:) ((~ (qualify (maybe.default field alias))))
-                                           (\ (~! meta.monad) (~' wrap)
-                                              (list (` (.:coerce (~ (nilable_type fieldT))
-                                                                 (.exec
-                                                                   (~+ module_import)
-                                                                   ("ruby constant" (~ (code.text (format class "::" field)))))))))))
-                                       (` (def: ((~ (qualify field))
-                                                 (~ g!object))
-                                            (-> (~ g!type)
-                                                (~ (nilable_type fieldT)))
-                                            (:assume
-                                             (~ (without_nil g!temp fieldT (` ("ruby object get" (~ (code.text field))
-                                                                               (:coerce (..Object .Any) (~ g!object))))))))))
-                                     
-                                     (#Method method)
-                                     (case method
-                                       (#Static [method alias inputsT io? try? outputT])
-                                       (..make_function (qualify (maybe.default method alias))
-                                                        g!temp
-                                                        (` ("ruby object get" (~ (code.text method))
-                                                            (:coerce (..Object .Any)
-                                                                     (.exec
-                                                                       (~+ module_import)
-                                                                       ("ruby constant" (~ (code.text (format class "::" method))))))))
-                                                        inputsT
-                                                        io?
-                                                        try?
-                                                        outputT)
-                                       
-                                       (#Virtual [method alias inputsT io? try? outputT])
-                                       (let [g!inputs (input_variables inputsT)]
-                                         (` (def: ((~ (qualify (maybe.default method alias)))
-                                                   [(~+ (list\map product.right g!inputs))]
-                                                   (~ g!object))
-                                              (-> [(~+ (list\map nilable_type inputsT))]
-                                                  (~ g!type)
-                                                  (~ (|> (nilable_type outputT)
-                                                         (try_type try?)
-                                                         (io_type io?))))
-                                              (:assume
-                                               (~ (<| (with_io io?)
-                                                      (with_try try?)
-                                                      (without_nil g!temp outputT)
-                                                      (` ("ruby object do"
-                                                          (~ (code.text method))
-                                                          (~ g!object)
-                                                          (~+ (list\map (with_nil g!temp) g!inputs)))))))))))))
-                                 members)))))
-      
-      (#Function [name alias inputsT io? try? outputT])
-      (let [imported (` (.exec
-                          (~+ (case ?module
-                                (#.Some module)
-                                (list (` ("ruby import" (~ (code.text module)))))
-
-                                #.None
-                                (list)))
-                          ("ruby constant" (~ (code.text name)))))]
-        (wrap (list (..make_function (code.local_identifier (maybe.default name alias))
-                                     g!temp
-                                     imported
-                                     inputsT
-                                     io?
-                                     try?
-                                     outputT))))
-
-      (#Constant [_ name alias fieldT])
-      (let [imported (` (.exec
-                          (~+ (case ?module
-                                (#.Some module)
-                                (list (` ("ruby import" (~ (code.text module)))))
-
-                                #.None
-                                (list)))
-                          ("ruby constant" (~ (code.text name)))))]
-        (wrap (list (` ((~! syntax:) ((~ (code.local_identifier (maybe.default name alias))))
-                        (\ (~! meta.monad) (~' wrap)
-                           (list (` (.:coerce (~ (nilable_type fieldT)) (~ imported))))))))))
-      )))
diff --git a/stdlib/source/lux/host.scm.lux b/stdlib/source/lux/host.scm.lux
deleted file mode 100644
index 1dde8ab69..000000000
--- a/stdlib/source/lux/host.scm.lux
+++ /dev/null
@@ -1,219 +0,0 @@
-(.module:
-  [lux (#- Alias)
-   ["." meta]
-   ["@" target]
-   [abstract
-    [monad (#+ do)]]
-   [control
-    ["." io]
-    ["<>" parser ("#\." monad)
-     ["<.>" code (#+ Parser)]]]
-   [data
-    ["." product]
-    ["." maybe]
-    ["." text
-     ["%" format (#+ format)]]
-    [collection
-     ["." list ("#\." functor fold)]]]
-   [type
-    abstract]
-   [macro (#+ with_gensyms)
-    [syntax (#+ syntax:)]
-    ["." code]
-    ["." template]]])
-
-(abstract: #export (Object brand) Any)
-
-(template []
-  [(with_expansions [ (template.identifier [ "'"])]
-     (abstract: #export  Any)
-     (type: #export 
-       (..Object )))]
-
-  [Nil]
-  [Function]
-  )
-
-(template [ ]
-  [(type: #export 
-     )]
-
-  [Boolean Bit]
-  [Integer Int]
-  [Float   Frac]
-  [String  Text]
-  )
-
-(type: Nilable
-  [Bit Code])
-
-(def: nilable
-  (Parser Nilable)
-  (let [token (' #?)]
-    (<| (<>.and (<>.parses? (.this! token)))
-        (<>.after (<>.not (.this! token)))
-        .any)))
-
-(type: Alias
-  Text)
-
-(def: alias
-  (Parser Alias)
-  (<>.after (.this! (' #as)) .local_identifier))
-
-(type: Field
-  [Bit Text (Maybe Alias) Nilable])
-
-(def: static!
-  (Parser Any)
-  (.this! (' #static)))
-
-(def: field
-  (Parser Field)
-  (.form ($_ <>.and
-                   (<>.parses? ..static!)
-                   .local_identifier
-                   (<>.maybe ..alias)
-                   ..nilable)))
-
-(def: constant
-  (Parser Field)
-  (.form ($_ <>.and
-                   (<>\wrap true)
-                   .local_identifier
-                   (<>.maybe ..alias)
-                   ..nilable)))
-
-(type: Common_Method
-  {#name Text
-   #alias (Maybe Alias)
-   #inputs (List Nilable)
-   #io? Bit
-   #try? Bit
-   #output Nilable})
-
-(def: common_method
-  (Parser Common_Method)
-  ($_ <>.and
-      .local_identifier
-      (<>.maybe ..alias)
-      (.tuple (<>.some ..nilable))
-      (<>.parses? (.this! (' #io)))
-      (<>.parses? (.this! (' #try)))
-      ..nilable))
-
-(def: input_variables
-  (-> (List Nilable) (List [Bit Code]))
-  (|>> list.enumeration
-       (list\map (function (_ [idx [nilable? type]])
-                   [nilable? (|> idx %.nat code.local_identifier)]))))
-
-(def: (nilable_type [nilable? type])
-  (-> Nilable Code)
-  (if nilable?
-    (` (.Maybe (~ type)))
-    type))
-
-(def: (with_nil g!temp [nilable? input])
-  (-> Code [Bit Code] Code)
-  (if nilable?
-    (` (case (~ input)
-         (#.Some (~ g!temp))
-         (~ g!temp)
-
-         #.Nil
-         ("scheme object nil")))
-    input))
-
-(def: (without_nil g!temp [nilable? outputT] output)
-  (-> Code Nilable Code Code)
-  (if nilable?
-    (` (let [(~ g!temp) (~ output)]
-         (if ("scheme object nil?" (~ g!temp))
-           #.None
-           (#.Some (~ g!temp)))))
-    (` (let [(~ g!temp) (~ output)]
-         (if (not ("scheme object nil?" (~ g!temp)))
-           (~ g!temp)
-           (.error! "Nil is an invalid value!"))))))
-
-(type: Import
-  (#Function Common_Method)
-  (#Constant Field))
-
-(def: import
-  (Parser Import)
-  ($_ <>.or
-      (.form ..common_method)
-      ..constant
-      ))
-
-(syntax: #export (try expression)
-  {#.doc (doc (case (try (risky_computation input))
-                (#.Right success)
-                (do_something success)
-
-                (#.Left error)
-                (recover_from_failure error)))}
-  (wrap (list (` ("lux try" ((~! io.io) (~ expression)))))))
-
-(def: (with_io with? without)
-  (-> Bit Code Code)
-  (if with?
-    (` (io.io (~ without)))
-    without))
-
-(def: (io_type io? rawT)
-  (-> Bit Code Code)
-  (if io?
-    (` (io.IO (~ rawT)))
-    rawT))
-
-(def: (with_try with? without_try)
-  (-> Bit Code Code)
-  (if with?
-    (` (..try (~ without_try)))
-    without_try))
-
-(def: (try_type try? rawT)
-  (-> Bit Code Code)
-  (if try?
-    (` (.Either .Text (~ rawT)))
-    rawT))
-
-(def: (make_function g!method g!temp source inputsT io? try? outputT)
-  (-> Code Code Code (List Nilable) Bit Bit Nilable Code)
-  (let [g!inputs (input_variables inputsT)]
-    (` (def: ((~ g!method)
-              [(~+ (list\map product.right g!inputs))])
-         (-> [(~+ (list\map nilable_type inputsT))]
-             (~ (|> (nilable_type outputT)
-                    (try_type try?)
-                    (io_type io?))))
-         (:assume
-          (~ (<| (with_io io?)
-                 (with_try try?)
-                 (without_nil g!temp outputT)
-                 (` ("scheme apply"
-                     (:coerce ..Function (~ source))
-                     (~+ (list\map (with_nil g!temp) g!inputs)))))))))))
-
-(syntax: #export (import: {import ..import})
-  (with_gensyms [g!temp]
-    (case import
-      (#Function [name alias inputsT io? try? outputT])
-      (let [imported (` ("scheme constant" (~ (code.text name))))]
-        (wrap (list (..make_function (code.local_identifier (maybe.default name alias))
-                                     g!temp
-                                     imported
-                                     inputsT
-                                     io?
-                                     try?
-                                     outputT))))
-
-      (#Constant [_ name alias fieldT])
-      (let [imported (` ("scheme constant" (~ (code.text name))))]
-        (wrap (list (` ((~! syntax:) ((~ (code.local_identifier (maybe.default name alias))))
-                        (\ (~! meta.monad) (~' wrap)
-                           (list (` (.:coerce (~ (nilable_type fieldT)) (~ imported))))))))))
-      )))
diff --git a/stdlib/source/lux/target/jvm/bytecode.lux b/stdlib/source/lux/target/jvm/bytecode.lux
index a319ef2a7..d79ba042a 100644
--- a/stdlib/source/lux/target/jvm/bytecode.lux
+++ b/stdlib/source/lux/target/jvm/bytecode.lux
@@ -1,6 +1,6 @@
 (.module:
   [lux (#- Type int)
-   ["." host (#+ import:)]
+   ["." ffi (#+ import:)]
    [abstract
     [monoid (#+ Monoid)]
     ["." monad (#+ Monad do)]]
@@ -507,18 +507,18 @@
 (def: float_bits
   (-> java/lang/Float Int)
   (|>> java/lang/Float::floatToRawIntBits
-       host.int_to_long
+       ffi.int_to_long
        (:coerce Int)))
 
 (def: negative_zero_float_bits
-  (|> -0.0 (:coerce java/lang/Double) host.double_to_float ..float_bits))
+  (|> -0.0 (:coerce java/lang/Double) ffi.double_to_float ..float_bits))
 
 (def: #export (float value)
   (-> java/lang/Float (Bytecode Any))
   (if (i.= ..negative_zero_float_bits
            (..float_bits value))
     (..arbitrary_float value)
-    (case (|> value host.float_to_double (:coerce Frac))
+    (case (|> value ffi.float_to_double (:coerce Frac))
       (^template [ ]
         [ (..bytecode $0 $1 @_  [])])
       ([+0.0 _.fconst_0]
diff --git a/stdlib/source/lux/target/jvm/constant.lux b/stdlib/source/lux/target/jvm/constant.lux
index fbfbfebb3..5d44dfbd6 100644
--- a/stdlib/source/lux/target/jvm/constant.lux
+++ b/stdlib/source/lux/target/jvm/constant.lux
@@ -1,6 +1,6 @@
 (.module:
   [lux #*
-   ["." host (#+ import:)]
+   ["." ffi (#+ import:)]
    ["@" target]
    [abstract
     [monad (#+ do)]
@@ -118,7 +118,7 @@
                 (~~ (template.splice )))))]
 
     [integer_writer Integer [] [binaryF.bits/32]]
-    [float_writer Float [java/lang/Float::floatToRawIntBits host.int_to_long (:coerce I64)] [i32.i32 binaryF.bits/32]]
+    [float_writer Float [java/lang/Float::floatToRawIntBits ffi.int_to_long (:coerce I64)] [i32.i32 binaryF.bits/32]]
     [long_writer Long [] [binaryF.bits/64]]
     [double_writer Double [java/lang/Double::doubleToRawLongBits] [binaryF.bits/64]]
     [string_writer String [] [//index.writer]]
diff --git a/stdlib/source/lux/target/jvm/constant/pool.lux b/stdlib/source/lux/target/jvm/constant/pool.lux
index 95dac3986..8f378ed00 100644
--- a/stdlib/source/lux/target/jvm/constant/pool.lux
+++ b/stdlib/source/lux/target/jvm/constant/pool.lux
@@ -1,6 +1,6 @@
 (.module:
   [lux #*
-   ["." host]
+   ["." ffi]
    [abstract
     [equivalence (#+ Equivalence)]
     [monad (#+ Monad do)]]
diff --git a/stdlib/source/lux/target/jvm/loader.lux b/stdlib/source/lux/target/jvm/loader.lux
index a6a236e47..755f9526e 100644
--- a/stdlib/source/lux/target/jvm/loader.lux
+++ b/stdlib/source/lux/target/jvm/loader.lux
@@ -16,7 +16,7 @@
     [collection
      ["." array]
      ["." dictionary (#+ Dictionary)]]]
-   ["." host (#+ import: object do_to)]])
+   ["." ffi (#+ import: object do_to)]])
 
 (type: #export Library
   (Atom (Dictionary Text Binary)))
@@ -65,17 +65,17 @@
 (with_expansions [ (as_is (java/lang/Class java/lang/Object))]
   (def: java/lang/ClassLoader::defineClass
     java/lang/reflect/Method
-    (let [signature (|> (host.array  4)
-                        (host.array_write 0 (:coerce 
-                                                     (host.class_for java/lang/String)))
-                        (host.array_write 1 (java/lang/Object::getClass (host.array byte 0)))
-                        (host.array_write 2 (:coerce 
-                                                     (java/lang/Integer::TYPE)))
-                        (host.array_write 3 (:coerce 
-                                                     (java/lang/Integer::TYPE))))]
+    (let [signature (|> (ffi.array  4)
+                        (ffi.array_write 0 (:coerce 
+                                                    (ffi.class_for java/lang/String)))
+                        (ffi.array_write 1 (java/lang/Object::getClass (ffi.array byte 0)))
+                        (ffi.array_write 2 (:coerce 
+                                                    (java/lang/Integer::TYPE)))
+                        (ffi.array_write 3 (:coerce 
+                                                    (java/lang/Integer::TYPE))))]
       (do_to (java/lang/Class::getDeclaredMethod "defineClass"
                                                  signature
-                                                 (host.class_for java/lang/ClassLoader))
+                                                 (ffi.class_for java/lang/ClassLoader))
              (java/lang/reflect/AccessibleObject::setAccessible true)))))
 
 (def: #export (define class_name bytecode loader)
@@ -87,12 +87,12 @@
                                          (:coerce java/lang/Object
                                                   (|> 0
                                                       (:coerce (primitive "java.lang.Long"))
-                                                      host.long_to_int))
+                                                      ffi.long_to_int))
                                          (:coerce java/lang/Object
                                                   (|> bytecode
                                                       binary.size
                                                       (:coerce (primitive "java.lang.Long"))
-                                                      host.long_to_int))))]
+                                                      ffi.long_to_int))))]
     (java/lang/reflect/Method::invoke loader signature java/lang/ClassLoader::defineClass)))
 
 (def: #export (new_library _)
diff --git a/stdlib/source/lux/target/jvm/reflection.lux b/stdlib/source/lux/target/jvm/reflection.lux
index bb0a388e9..07afd5df0 100644
--- a/stdlib/source/lux/target/jvm/reflection.lux
+++ b/stdlib/source/lux/target/jvm/reflection.lux
@@ -1,6 +1,6 @@
 (.module:
   [lux (#- type)
-   ["." host (#+ import:)]
+   ["." ffi (#+ import:)]
    ["." type]
    [abstract
     ["." monad (#+ do)]]
@@ -142,7 +142,7 @@
   (-> (-> java/lang/reflect/Type (Try (/.Type Parameter)))
       java/lang/reflect/Type
       (Try (/.Type Class)))
-  (<| (case (host.check java/lang/Class reflection)
+  (<| (case (ffi.check java/lang/Class reflection)
         (#.Some class)
         (let [class_name (|> class
                              (:coerce (java/lang/Class java/lang/Object))
@@ -163,10 +163,10 @@
                 (exception.throw ..not_a_class reflection)
                 (#try.Success (/.class class_name (list))))))
         _)
-      (case (host.check java/lang/reflect/ParameterizedType reflection)
+      (case (ffi.check java/lang/reflect/ParameterizedType reflection)
         (#.Some reflection)
         (let [raw (java/lang/reflect/ParameterizedType::getRawType reflection)]
-          (case (host.check java/lang/Class raw)
+          (case (ffi.check java/lang/Class raw)
             (#.Some raw)
             (do {! try.monad}
               [paramsT (|> reflection
@@ -186,11 +186,11 @@
 
 (def: #export (parameter reflection)
   (-> java/lang/reflect/Type (Try (/.Type Parameter)))
-  (<| (case (host.check java/lang/reflect/TypeVariable reflection)
+  (<| (case (ffi.check java/lang/reflect/TypeVariable reflection)
         (#.Some reflection)
         (#try.Success (/.var (java/lang/reflect/TypeVariable::getName reflection)))
         _)
-      (case (host.check java/lang/reflect/WildcardType reflection)
+      (case (ffi.check java/lang/reflect/WildcardType reflection)
         (#.Some reflection)
         ## TODO: Instead of having single lower/upper bounds, should
         ## allow for multiple ones.
@@ -198,7 +198,7 @@
                (array.read 0 (java/lang/reflect/WildcardType::getUpperBounds reflection))]
           (^template [ ]
             [
-             (case (host.check java/lang/reflect/GenericArrayType bound)
+             (case (ffi.check java/lang/reflect/GenericArrayType bound)
                (#.Some _)
                ## TODO: Array bounds should not be "erased" as they
                ## are right now.
@@ -221,7 +221,7 @@
 
 (def: #export (type reflection)
   (-> java/lang/reflect/Type (Try (/.Type Value)))
-  (<| (case (host.check java/lang/Class reflection)
+  (<| (case (ffi.check java/lang/Class reflection)
         (#.Some reflection)
         (let [class_name (|> reflection
                              (:coerce (java/lang/Class java/lang/Object))
@@ -243,7 +243,7 @@
                       (.run /parser.value (|> class_name //name.internal //name.read))
                       (#try.Success (/.class class_name (list)))))))
         _)
-      (case (host.check java/lang/reflect/GenericArrayType reflection)
+      (case (ffi.check java/lang/reflect/GenericArrayType reflection)
         (#.Some reflection)
         (|> reflection
             java/lang/reflect/GenericArrayType::getGenericComponentType
@@ -256,7 +256,7 @@
 (def: #export (return reflection)
   (-> java/lang/reflect/Type (Try (/.Type Return)))
   (with_expansions [ (as_is (..type reflection))]
-    (case (host.check java/lang/Class reflection)
+    (case (ffi.check java/lang/Class reflection)
       (#.Some class)
       (let [class_name (|> reflection
                            (:coerce (java/lang/Class java/lang/Object))
@@ -358,7 +358,7 @@
 (def: #export deprecated?
   (-> (array.Array java/lang/annotation/Annotation) Bit)
   (|>> array.to_list
-       (list.all (|>> (host.check java/lang/Deprecated)))
+       (list.all (|>> (ffi.check java/lang/Deprecated)))
        list.empty?
        not))
 
diff --git a/stdlib/source/lux/target/lua.lux b/stdlib/source/lux/target/lua.lux
index 4213cd339..144fc2d7b 100644
--- a/stdlib/source/lux/target/lua.lux
+++ b/stdlib/source/lux/target/lua.lux
@@ -1,7 +1,6 @@
 (.module:
   [lux (#- Location Code int if cond function or and not let ^)
    ["@" target]
-   ["." host]
    [abstract
     [equivalence (#+ Equivalence)]
     [hash (#+ Hash)]
@@ -27,21 +26,11 @@
    [type
     abstract]])
 
-(for {@.old (as_is (host.import: java/lang/CharSequence)
-                   (host.import: java/lang/String
-                     ["#::."
-                      (replace [java/lang/CharSequence java/lang/CharSequence] java/lang/String)]))}
-     (as_is))
-
 (def: nest
   (-> Text Text)
   (.let [nested_new_line (format text.new_line text.tab)]
-    (for {@.old (|>> (format text.new_line)
-                     (:coerce java/lang/String)
-                     (java/lang/String::replace (:coerce java/lang/CharSequence text.new_line)
-                                                (:coerce java/lang/CharSequence nested_new_line)))}
-         (|>> (format text.new_line)
-              (text.replace_all text.new_line nested_new_line)))))
+    (|>> (format text.new_line)
+         (text.replace_all text.new_line nested_new_line))))
 
 (def: input_separator ", ")
 
diff --git a/stdlib/source/lux/target/php.lux b/stdlib/source/lux/target/php.lux
index 9ef2511a7..5b976a325 100644
--- a/stdlib/source/lux/target/php.lux
+++ b/stdlib/source/lux/target/php.lux
@@ -1,7 +1,6 @@
 (.module:
   [lux (#- Location Code Global static int if cond or and not comment for)
    ["@" target]
-   ["." host]
    [abstract
     [equivalence (#+ Equivalence)]
     [hash (#+ Hash)]
@@ -29,21 +28,11 @@
 (def: input_separator ", ")
 (def: statement_suffix ";")
 
-(.for {@.old (as_is (host.import: java/lang/CharSequence)
-                    (host.import: java/lang/String
-                      ["#::."
-                       (replace [java/lang/CharSequence java/lang/CharSequence] java/lang/String)]))}
-      (as_is))
-
 (def: nest
   (-> Text Text)
   (.let [nested_new_line (format text.new_line text.tab)]
-    (.for {@.old (|>> (format text.new_line)
-                      (:coerce java/lang/String)
-                      (java/lang/String::replace (:coerce java/lang/CharSequence text.new_line)
-                                                 (:coerce java/lang/CharSequence nested_new_line)))}
-          (|>> (format text.new_line)
-               (text.replace_all text.new_line nested_new_line)))))
+    (|>> (format text.new_line)
+         (text.replace_all text.new_line nested_new_line))))
 
 (def: block
   (-> Text Text)
diff --git a/stdlib/source/lux/target/python.lux b/stdlib/source/lux/target/python.lux
index 1ae1cca64..77cc7cf28 100644
--- a/stdlib/source/lux/target/python.lux
+++ b/stdlib/source/lux/target/python.lux
@@ -1,7 +1,7 @@
 (.module:
   [lux (#- Location Code not or and list if cond int comment exec)
    ["@" target]
-   ["." host]
+   ["." ffi]
    [abstract
     [equivalence (#+ Equivalence)]
     [hash (#+ Hash)]
@@ -30,8 +30,8 @@
   (-> Text Text)
   (text.enclose ["(" ")"]))
 
-(for {@.old (as_is (host.import: java/lang/CharSequence)
-                   (host.import: java/lang/String
+(for {@.old (as_is (ffi.import: java/lang/CharSequence)
+                   (ffi.import: java/lang/String
                      ["#::."
                       (replace [java/lang/CharSequence java/lang/CharSequence] java/lang/String)]))}
      (as_is))
diff --git a/stdlib/source/lux/target/ruby.lux b/stdlib/source/lux/target/ruby.lux
index 641cc8d2e..21a47c8d0 100644
--- a/stdlib/source/lux/target/ruby.lux
+++ b/stdlib/source/lux/target/ruby.lux
@@ -1,7 +1,6 @@
 (.module:
   [lux (#- Location Code static int if cond function or and not comment)
    ["@" target]
-   ["." host]
    [abstract
     [equivalence (#+ Equivalence)]
     [hash (#+ Hash)]
@@ -29,21 +28,11 @@
 (def: input_separator ", ")
 (def: statement_suffix ";")
 
-(for {@.old (as_is (host.import: java/lang/CharSequence)
-                   (host.import: java/lang/String
-                     ["#::."
-                      (replace [java/lang/CharSequence java/lang/CharSequence] java/lang/String)]))}
-     (as_is))
-
 (def: nest
   (-> Text Text)
   (.let [nested_new_line (format text.new_line text.tab)]
-    (for {@.old (|>> (format text.new_line)
-                     (:coerce java/lang/String)
-                     (java/lang/String::replace (:coerce java/lang/CharSequence text.new_line)
-                                                (:coerce java/lang/CharSequence nested_new_line)))}
-         (|>> (format text.new_line)
-              (text.replace_all text.new_line nested_new_line)))))
+    (|>> (format text.new_line)
+         (text.replace_all text.new_line nested_new_line))))
 
 (abstract: #export (Code brand)
   Text
diff --git a/stdlib/source/lux/target/scheme.lux b/stdlib/source/lux/target/scheme.lux
index 20bb08be3..408f1d9f1 100644
--- a/stdlib/source/lux/target/scheme.lux
+++ b/stdlib/source/lux/target/scheme.lux
@@ -1,7 +1,6 @@
 (.module:
   [lux (#- Code int or and if cond let)
    ["@" target]
-   ["." host]
    [abstract
     [equivalence (#+ Equivalence)]
     [hash (#+ Hash)]]
@@ -21,19 +20,10 @@
    [type
     abstract]])
 
-(for {@.old (as_is (host.import: java/lang/CharSequence)
-                   (host.import: java/lang/String
-                     ["#::."
-                      (replace [java/lang/CharSequence java/lang/CharSequence] java/lang/String)]))}
-     (as_is))
-
 (def: nest
   (-> Text Text)
   (.let [nested_new_line (format text.new_line text.tab)]
-    (for {@.old (|>> (:coerce java/lang/String)
-                     (java/lang/String::replace (:coerce java/lang/CharSequence text.new_line)
-                                                (:coerce java/lang/CharSequence nested_new_line)))}
-         (text.replace_all text.new_line nested_new_line))))
+    (text.replace_all text.new_line nested_new_line)))
 
 (abstract: #export (Code k)
   Text
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
index 1b29ee2e1..4203516d4 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
@@ -1,6 +1,6 @@
 (.module:
   [lux (#- Type Module primitive type char int)
-   ["." host (#+ import:)]
+   ["." ffi (#+ import:)]
    ["." meta]
    [abstract
     ["." monad (#+ do)]]
@@ -159,7 +159,7 @@
                (list& class super_class super_interfaces)))
 
 ## TODO: Get rid of this template block and use the definition in
-## lux/host.jvm.lux ASAP
+## lux/ffi.jvm.lux ASAP
 (template [ ]
   [(def: #export  .Type (#.Primitive  #.Nil))]
 
@@ -873,7 +873,7 @@
 
                  #.None
                  (if (java/lang/reflect/Modifier::isInterface (java/lang/Class::getModifiers from_class))
-                   (#.Cons (:coerce java/lang/reflect/Type (host.class_for java/lang/Object))
+                   (#.Cons (:coerce java/lang/reflect/Type (ffi.class_for java/lang/Object))
                            (array.to_list (java/lang/Class::getGenericInterfaces from_class)))
                    (array.to_list (java/lang/Class::getGenericInterfaces from_class)))))))
 
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux
index 96c39d8cb..12954ff51 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux
@@ -1,6 +1,6 @@
 (.module:
   [lux (#- Definition)
-   ["." host (#+ import: do-to object)]
+   ["." ffi (#+ import: do-to object)]
    [abstract
     [monad (#+ do)]]
    [control
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux
index 3b12fe741..b6fb709fb 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux
@@ -1,6 +1,6 @@
 (.module:
   [lux (#- i64)
-   ["." host (#+ import:)]
+   ["." ffi (#+ import:)]
    [abstract
     [monad (#+ do)]]
    [target
diff --git a/stdlib/source/lux/tool/compiler/meta/packager/jvm.lux b/stdlib/source/lux/tool/compiler/meta/packager/jvm.lux
index d92d1e686..15552a656 100644
--- a/stdlib/source/lux/tool/compiler/meta/packager/jvm.lux
+++ b/stdlib/source/lux/tool/compiler/meta/packager/jvm.lux
@@ -1,7 +1,7 @@
 (.module:
   [lux (#- Module Definition)
    [type (#+ :share)]
-   ["." host (#+ import: do_to)]
+   ["." ffi (#+ import: do_to)]
    [abstract
     ["." monad (#+ Monad do)]]
    [control
@@ -106,8 +106,8 @@
   (-> Context java/util/jar/Manifest)
   (let [manifest (java/util/jar/Manifest::new)]
     (exec (do_to (java/util/jar/Manifest::getMainAttributes manifest)
-            (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MAIN_CLASS) (|> program runtime.class_name name.internal name.external))
-            (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MANIFEST_VERSION) ..manifest_version))
+                 (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MAIN_CLASS) (|> program runtime.class_name name.internal name.external))
+                 (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MANIFEST_VERSION) ..manifest_version))
       manifest)))
 
 ## TODO: Delete ASAP
@@ -124,10 +124,10 @@
      content (!.use (\ artifact content) [])
      #let [class_path (format (runtime.class_name context) (get@ #static.artifact_extension static))]]
     (wrap (do_to sink
-            (java/util/jar/JarOutputStream::putNextEntry (java/util/jar/JarEntry::new class_path))
-            (java/util/zip/ZipOutputStream::write content +0 (.int (binary.size content)))
-            (java/io/Flushable::flush)
-            (java/util/zip/ZipOutputStream::closeEntry)))))
+                 (java/util/jar/JarOutputStream::putNextEntry (java/util/jar/JarEntry::new class_path))
+                 (java/util/zip/ZipOutputStream::write content +0 (.int (binary.size content)))
+                 (java/io/Flushable::flush)
+                 (java/util/zip/ZipOutputStream::closeEntry)))))
 
 (def: (write_module monad file_system static [module artifacts] sink)
   (All [!]
@@ -164,6 +164,6 @@
            sink (java/util/jar/JarOutputStream::new buffer (..manifest program))]
      sink (monad.fold ! (..write_module monad file_system static) sink order)
      #let [_ (do_to sink
-               (java/io/Flushable::flush)
-               (java/io/Closeable::close))]]
+                    (java/io/Flushable::flush)
+                    (java/io/Closeable::close))]]
     (wrap (java/io/ByteArrayOutputStream::toByteArray buffer))))
diff --git a/stdlib/source/lux/world/console.lux b/stdlib/source/lux/world/console.lux
index e5b17b7d6..9cf12bc5c 100644
--- a/stdlib/source/lux/world/console.lux
+++ b/stdlib/source/lux/world/console.lux
@@ -1,6 +1,6 @@
 (.module:
   [lux #*
-   [host (#+ import:)]
+   [ffi (#+ import:)]
    ["@" target]
    [abstract
     [monad (#+ do)]]
diff --git a/stdlib/source/lux/world/db/jdbc/input.lux b/stdlib/source/lux/world/db/jdbc/input.lux
index 625af00ba..f1183ab75 100644
--- a/stdlib/source/lux/world/db/jdbc/input.lux
+++ b/stdlib/source/lux/world/db/jdbc/input.lux
@@ -1,5 +1,6 @@
 (.module:
   [lux (#- and int)
+   [ffi (#+ import:)]
    [control
     [functor (#+ Contravariant)]
     [monad (#+ Monad do)]
@@ -8,8 +9,7 @@
     ["." instant (#+ Instant)]]
    ["." io (#+ IO)]
    [world
-    [binary (#+ Binary)]]
-   [host (#+ import:)]])
+    [binary (#+ Binary)]]])
 
 (import: java/lang/String)
 
diff --git a/stdlib/source/lux/world/db/jdbc/output.lux b/stdlib/source/lux/world/db/jdbc/output.lux
index 08a74a4b0..66578ac8d 100644
--- a/stdlib/source/lux/world/db/jdbc/output.lux
+++ b/stdlib/source/lux/world/db/jdbc/output.lux
@@ -1,5 +1,6 @@
 (.module:
   [lux (#- and int)
+   [ffi (#+ import:)]
    [control
     [functor (#+ Functor)]
     [apply (#+ Apply)]
@@ -10,8 +11,7 @@
     ["." instant (#+ Instant)]]
    ["." io (#+ IO)]
    [world
-    [binary (#+ Binary)]]
-   [host (#+ import:)]])
+    [binary (#+ Binary)]]])
 
 (import: java/lang/String)
 
diff --git a/stdlib/source/lux/world/file.lux b/stdlib/source/lux/world/file.lux
index 3b80a7ea8..48a024400 100644
--- a/stdlib/source/lux/world/file.lux
+++ b/stdlib/source/lux/world/file.lux
@@ -1,6 +1,6 @@
 (.module:
   [lux #*
-   ["." host]
+   ["." ffi]
    ["@" target]
    [abstract
     ["." monad (#+ Monad do)]]
@@ -231,9 +231,9 @@
                                       ["Instant" (%.instant instant)]
                                       ["Path" file]))
 
-                                   (host.import: java/lang/String)
+                                   (ffi.import: java/lang/String)
 
-                                   (`` (host.import: java/io/File
+                                   (`` (ffi.import: java/io/File
                                          ["#::."
                                           (new [java/lang/String])
                                           (~~ (template []
@@ -263,24 +263,24 @@
                                          _
                                          (wrap (exception.throw exception [path])))))
 
-                                   (host.import: java/lang/AutoCloseable
+                                   (ffi.import: java/lang/AutoCloseable
                                      ["#::."
                                       (close [] #io #try void)])
 
-                                   (host.import: java/io/OutputStream
+                                   (ffi.import: java/io/OutputStream
                                      ["#::."
                                       (write [[byte]] #io #try void)
                                       (flush [] #io #try void)])
 
-                                   (host.import: java/io/FileOutputStream
+                                   (ffi.import: java/io/FileOutputStream
                                      ["#::."
                                       (new [java/io/File boolean] #io #try)])
 
-                                   (host.import: java/io/InputStream
+                                   (ffi.import: java/io/InputStream
                                      ["#::."
                                       (read [[byte]] #io #try int)])
 
-                                   (host.import: java/io/FileInputStream
+                                   (ffi.import: java/io/FileInputStream
                                      ["#::."
                                       (new [java/io/File] #io #try)])
 
@@ -444,45 +444,45 @@
         @.jvm (as_is )
 
         @.js
-        (as_is (host.import: Buffer
+        (as_is (ffi.import: Buffer
                  (#static from [Binary] ..Buffer))
                
-               (host.import: FileDescriptor)
-
-               (host.import: Stats
-                 (size host.Number)
-                 (mtimeMs host.Number)
-                 (isFile [] #io #try host.Boolean)
-                 (isDirectory [] #io #try host.Boolean))
-
-               (host.import: FsConstants
-                 (F_OK host.Number)
-                 (R_OK host.Number)
-                 (W_OK host.Number)
-                 (X_OK host.Number))
+               (ffi.import: FileDescriptor)
+
+               (ffi.import: Stats
+                 (size ffi.Number)
+                 (mtimeMs ffi.Number)
+                 (isFile [] #io #try ffi.Boolean)
+                 (isDirectory [] #io #try ffi.Boolean))
+
+               (ffi.import: FsConstants
+                 (F_OK ffi.Number)
+                 (R_OK ffi.Number)
+                 (W_OK ffi.Number)
+                 (X_OK ffi.Number))
                
-               (host.import: Fs
+               (ffi.import: Fs
                  (constants FsConstants)
-                 (readFileSync [host.String] #io #try Binary)
-                 (appendFileSync [host.String Buffer] #io #try Any)
-                 (writeFileSync [host.String Buffer] #io #try Any)
-                 (statSync [host.String] #io #try Stats)
-                 (accessSync [host.String host.Number] #io #try Any)
-                 (renameSync [host.String host.String] #io #try Any)
-                 (utimesSync [host.String host.Number host.Number] #io #try Any)
-                 (unlink [host.String] #io #try Any)
-                 (readdirSync [host.String] #io #try (Array host.String))
-                 (mkdirSync [host.String] #io #try Any)
-                 (rmdirSync [host.String] #io #try Any))
-
-               (host.import: JsPath
-                 (sep host.String)
-                 (basename [host.String] host.String))
+                 (readFileSync [ffi.String] #io #try Binary)
+                 (appendFileSync [ffi.String Buffer] #io #try Any)
+                 (writeFileSync [ffi.String Buffer] #io #try Any)
+                 (statSync [ffi.String] #io #try Stats)
+                 (accessSync [ffi.String ffi.Number] #io #try Any)
+                 (renameSync [ffi.String ffi.String] #io #try Any)
+                 (utimesSync [ffi.String ffi.Number ffi.Number] #io #try Any)
+                 (unlink [ffi.String] #io #try Any)
+                 (readdirSync [ffi.String] #io #try (Array ffi.String))
+                 (mkdirSync [ffi.String] #io #try Any)
+                 (rmdirSync [ffi.String] #io #try Any))
+
+               (ffi.import: JsPath
+                 (sep ffi.String)
+                 (basename [ffi.String] ffi.String))
                
                (template [ ]
                  [(def: ( _)
-                    (-> [] (Maybe (-> host.String Any)))
-                    (host.constant (-> host.String Any) ))]
+                    (-> [] (Maybe (-> ffi.String Any)))
+                    (ffi.constant (-> ffi.String Any) ))]
 
                  [normal_require [require]]
                  [global_require [global require]]
@@ -490,7 +490,7 @@
                  )
 
                (def: (require _)
-                 (-> [] (-> host.String Any))
+                 (-> [] (-> ffi.String Any))
                  (case [(normal_require []) (global_require []) (process_load [])]
                    (^or [(#.Some require) _ _]
                         [_ (#.Some require) _]
@@ -675,7 +675,7 @@
                            ))
 
                      (def: separator
-                       (if host.on_node_js?
+                       (if ffi.on_node_js?
                          (JsPath::sep (..node_path []))
                          "/"))
                      ))
@@ -685,35 +685,35 @@
         (as_is (type: (Tuple/2 left right)
                  (primitive "python_tuple[2]" [left right]))
 
-               (host.import: PyFile
+               (ffi.import: PyFile
                  (read [] #io #try Binary)
                  (write [Binary] #io #try #? Any)
                  (close [] #io #try #? Any))
 
-               (host.import: (open [host.String host.String] #io #try PyFile))
-               (host.import: (tuple [[host.Integer host.Integer]] (Tuple/2 host.Integer host.Integer)))
-
-               (host.import: os
-                 (#static F_OK host.Integer)
-                 (#static R_OK host.Integer)
-                 (#static W_OK host.Integer)
-                 (#static X_OK host.Integer)
-
-                 (#static mkdir [host.String] #io #try #? Any)
-                 (#static access [host.String host.Integer] #io #try host.Boolean)
-                 (#static remove [host.String] #io #try #? Any)
-                 (#static rmdir [host.String] #io #try #? Any)
-                 (#static rename [host.String host.String] #io #try #? Any)
-                 (#static utime [host.String (Tuple/2 host.Integer host.Integer)] #io #try #? Any)
-                 (#static listdir [host.String] #io #try (Array host.String)))
-
-               (host.import: os/path
-                 (#static isfile [host.String] #io #try host.Boolean)
-                 (#static isdir [host.String] #io #try host.Boolean)
-                 (#static sep host.String)
-                 (#static basename [host.String] host.String)
-                 (#static getsize [host.String] #io #try host.Integer)
-                 (#static getmtime [host.String] #io #try host.Float))
+               (ffi.import: (open [ffi.String ffi.String] #io #try PyFile))
+               (ffi.import: (tuple [[ffi.Integer ffi.Integer]] (Tuple/2 ffi.Integer ffi.Integer)))
+
+               (ffi.import: os
+                 (#static F_OK ffi.Integer)
+                 (#static R_OK ffi.Integer)
+                 (#static W_OK ffi.Integer)
+                 (#static X_OK ffi.Integer)
+
+                 (#static mkdir [ffi.String] #io #try #? Any)
+                 (#static access [ffi.String ffi.Integer] #io #try ffi.Boolean)
+                 (#static remove [ffi.String] #io #try #? Any)
+                 (#static rmdir [ffi.String] #io #try #? Any)
+                 (#static rename [ffi.String ffi.String] #io #try #? Any)
+                 (#static utime [ffi.String (Tuple/2 ffi.Integer ffi.Integer)] #io #try #? Any)
+                 (#static listdir [ffi.String] #io #try (Array ffi.String)))
+
+               (ffi.import: os/path
+                 (#static isfile [ffi.String] #io #try ffi.Boolean)
+                 (#static isdir [ffi.String] #io #try ffi.Boolean)
+                 (#static sep ffi.String)
+                 (#static basename [ffi.String] ffi.String)
+                 (#static getsize [ffi.String] #io #try ffi.Integer)
+                 (#static getmtime [ffi.String] #io #try ffi.Float))
 
                (`` (structure: (file path)
                      (-> Path (File IO))
@@ -881,19 +881,19 @@
                )
 
         @.lua
-        (as_is (host.import: LuaFile
-                 (read [host.String] #io host.String)
-                 (write [host.String] #io #? LuaFile)
-                 (flush [] #io host.Boolean)
-                 (close [] #io host.Boolean))
+        (as_is (ffi.import: LuaFile
+                 (read [ffi.String] #io ffi.String)
+                 (write [ffi.String] #io #? LuaFile)
+                 (flush [] #io ffi.Boolean)
+                 (close [] #io ffi.Boolean))
 
-               (host.import: (io/open [host.String host.String] #io #? LuaFile))
+               (ffi.import: (io/open [ffi.String ffi.String] #io #? LuaFile))
 
-               (host.import: (package/config host.String))
+               (ffi.import: (package/config ffi.String))
 
-               (host.import: (os/rename [host.String host.String] #io #? host.Boolean))
-               (host.import: (os/remove [host.String] #io #? host.Boolean))
-               (host.import: (os/execute [host.String] #io #? host.Boolean))
+               (ffi.import: (os/rename [ffi.String ffi.String] #io #? ffi.Boolean))
+               (ffi.import: (os/remove [ffi.String] #io #? ffi.Boolean))
+               (ffi.import: (os/execute [ffi.String] #io #? ffi.Boolean))
 
                (def: default_separator
                  Text
@@ -1142,19 +1142,19 @@
                )
 
         @.ruby
-        (as_is (host.import: Time #as RubyTime
+        (as_is (ffi.import: Time #as RubyTime
                  (#static at [Frac] RubyTime)
                  
                  (to_f [] Frac))
 
-               (host.import: Stat #as RubyStat
+               (ffi.import: Stat #as RubyStat
                  (executable? [] Bit)
                  (size Int)
                  (mtime [] RubyTime))
 
-               (host.import: File #as RubyFile
-                 (#static SEPARATOR host.String)
-                 (#static open [Path host.String] #io #try RubyFile)
+               (ffi.import: File #as RubyFile
+                 (#static SEPARATOR ffi.String)
+                 (#static open [Path ffi.String] #io #try RubyFile)
                  (#static stat [Path] #io #try RubyStat)
                  (#static delete [Path] #io #try Int)
                  (#static file? [Path] #io #try Bit)
@@ -1166,13 +1166,13 @@
                  (flush [] #io #try #? Any)
                  (close [] #io #try #? Any))
 
-               (host.import: Dir #as RubyDir
+               (ffi.import: Dir #as RubyDir
                  (#static open [Path] #io #try RubyDir)
                  
                  (children [] #io #try (Array Path))
                  (close [] #io #try #? Any))
 
-               (host.import: "fileutils" FileUtils #as RubyFileUtils
+               (ffi.import: "fileutils" FileUtils #as RubyFileUtils
                  (#static touch [Path] #io #try #? Any)
                  (#static move [Path Path] #io #try #? Any)
                  (#static rmdir [Path] #io #try #? Any)
@@ -1353,34 +1353,34 @@
                )
 
         @.php
-        (as_is (host.import: (FILE_APPEND Int))
+        (as_is (ffi.import: (FILE_APPEND Int))
                ## https://www.php.net/manual/en/dir.constants.php
-               (host.import: (DIRECTORY_SEPARATOR host.String))
+               (ffi.import: (DIRECTORY_SEPARATOR ffi.String))
                ## https://www.php.net/manual/en/function.pack.php
                ## https://www.php.net/manual/en/function.unpack.php
-               (host.import: (unpack [host.String host.String] Binary))
+               (ffi.import: (unpack [ffi.String ffi.String] Binary))
                ## https://www.php.net/manual/en/ref.filesystem.php
                ## https://www.php.net/manual/en/function.file-get-contents.php
-               (host.import: (file_get_contents [Path] #io #try host.String))
+               (ffi.import: (file_get_contents [Path] #io #try ffi.String))
                ## https://www.php.net/manual/en/function.file-put-contents.php
-               (host.import: (file_put_contents [Path host.String Int] #io #try host.Integer))
-               (host.import: (filemtime [Path] #io #try host.Integer))
-               (host.import: (filesize [Path] #io #try host.Integer))
-               (host.import: (is_executable [Path] #io #try host.Boolean))
-               (host.import: (touch [Path host.Integer] #io #try host.Boolean))
-               (host.import: (rename [Path Path] #io #try host.Boolean))
-               (host.import: (unlink [Path] #io #try host.Boolean))
+               (ffi.import: (file_put_contents [Path ffi.String Int] #io #try ffi.Integer))
+               (ffi.import: (filemtime [Path] #io #try ffi.Integer))
+               (ffi.import: (filesize [Path] #io #try ffi.Integer))
+               (ffi.import: (is_executable [Path] #io #try ffi.Boolean))
+               (ffi.import: (touch [Path ffi.Integer] #io #try ffi.Boolean))
+               (ffi.import: (rename [Path Path] #io #try ffi.Boolean))
+               (ffi.import: (unlink [Path] #io #try ffi.Boolean))
 
                ## https://www.php.net/manual/en/function.rmdir.php
-               (host.import: (rmdir [Path] #io #try host.Boolean))
+               (ffi.import: (rmdir [Path] #io #try ffi.Boolean))
                ## https://www.php.net/manual/en/function.scandir.php
-               (host.import: (scandir [Path] #io #try (Array Path)))
+               (ffi.import: (scandir [Path] #io #try (Array Path)))
                ## https://www.php.net/manual/en/function.is-file.php
-               (host.import: (is_file [Path] #io #try host.Boolean))
+               (ffi.import: (is_file [Path] #io #try ffi.Boolean))
                ## https://www.php.net/manual/en/function.is-dir.php
-               (host.import: (is_dir [Path] #io #try host.Boolean))
+               (ffi.import: (is_dir [Path] #io #try ffi.Boolean))
                ## https://www.php.net/manual/en/function.mkdir.php
-               (host.import: (mkdir [Path] #io #try host.Boolean))
+               (ffi.import: (mkdir [Path] #io #try ffi.Boolean))
 
                (def: byte_array_format "C*")
                (def: default_separator (..DIRECTORY_SEPARATOR))
diff --git a/stdlib/source/lux/world/file/watch.lux b/stdlib/source/lux/world/file/watch.lux
index b3951068c..4695c1e00 100644
--- a/stdlib/source/lux/world/file/watch.lux
+++ b/stdlib/source/lux/world/file/watch.lux
@@ -1,7 +1,7 @@
 (.module:
   [lux #*
    ["@" target]
-   ["." host (#+ import:)]
+   ["." ffi (#+ import:)]
    [abstract
     [predicate (#+ Predicate)]
     ["." monad (#+ do)]]
diff --git a/stdlib/source/lux/world/program.lux b/stdlib/source/lux/world/program.lux
index 0abdb2225..07d7ad6be 100644
--- a/stdlib/source/lux/world/program.lux
+++ b/stdlib/source/lux/world/program.lux
@@ -1,7 +1,7 @@
 (.module:
   [lux #*
    ["@" target]
-   ["." host (#+ import:)]
+   ["." ffi (#+ import:)]
    [abstract
     ["." monad (#+ do)]]
    [control
@@ -124,12 +124,12 @@
                       (|>> %.int error! io.io))
 
                     (import: NodeJs_Process
-                      (exit [host.Number] #io Nothing)
+                      (exit [ffi.Number] #io Nothing)
                       (cwd [] #io Path))
 
                     (def: (exit_node_js! code)
                       (-> Exit (IO Nothing))
-                      (case (host.constant ..NodeJs_Process [process])
+                      (case (ffi.constant ..NodeJs_Process [process])
                         (#.Some process)
                         (NodeJs_Process::exit (i.frac code) process)
                         
@@ -144,8 +144,8 @@
 
                     (def: (exit_browser! code)
                       (-> Exit (IO Nothing))
-                      (case [(host.constant ..Browser_Window [window])
-                             (host.constant ..Browser_Location [location])]
+                      (case [(ffi.constant ..Browser_Window [window])
+                             (ffi.constant ..Browser_Location [location])]
                         [(#.Some window) (#.Some location)]
                         (exec
                           (Browser_Window::close [] window)
@@ -166,29 +166,29 @@
                         (..default_exit! code)))
 
                     (import: Object
-                      (#static entries [Object] (Array (Array host.String))))
+                      (#static entries [Object] (Array (Array ffi.String))))
 
                     (import: NodeJs_OS
                       (homedir [] #io Path))
 
-                    (import: (require [host.String] Any)))
+                    (import: (require [ffi.String] Any)))
         @.python (as_is (import: os
-                          (#static getcwd [] #io host.String)
-                          (#static _exit [host.Integer] #io Nothing))
+                          (#static getcwd [] #io ffi.String)
+                          (#static _exit [ffi.Integer] #io Nothing))
 
                         (import: os/path
-                          (#static expanduser [host.String] #io host.String))
+                          (#static expanduser [ffi.String] #io ffi.String))
 
                         (import: os/environ
-                          (#static keys [] #io (Array host.String))
-                          (#static get [host.String] #io host.String)))
-        @.lua (as_is (host.import: LuaFile
-                       (read [host.String] #io #? host.String)
-                       (close [] #io host.Boolean))
+                          (#static keys [] #io (Array ffi.String))
+                          (#static get [ffi.String] #io ffi.String)))
+        @.lua (as_is (ffi.import: LuaFile
+                       (read [ffi.String] #io #? ffi.String)
+                       (close [] #io ffi.Boolean))
 
-                     (host.import: (io/popen [host.String] #io #try #? LuaFile))
-                     (host.import: (os/getenv [host.String] #io #? host.String))
-                     (host.import: (os/exit [host.Integer] #io Nothing))
+                     (ffi.import: (io/popen [ffi.String] #io #try #? LuaFile))
+                     (ffi.import: (os/getenv [ffi.String] #io #? ffi.String))
+                     (ffi.import: (os/exit [ffi.Integer] #io Nothing))
 
                      (def: (run_command default command)
                        (-> Text Text (IO Text))
@@ -208,41 +208,41 @@
                            
                            (#try.Failure _)
                            (wrap default)))))
-        @.ruby (as_is (host.import: Env #as RubyEnv
+        @.ruby (as_is (ffi.import: Env #as RubyEnv
                         (#static keys [] (Array Text))
                         (#static fetch [Text] Text))
 
-                      (host.import: "fileutils" FileUtils #as RubyFileUtils
+                      (ffi.import: "fileutils" FileUtils #as RubyFileUtils
                         (#static pwd [] #io Path))
                       
-                      (host.import: Dir #as RubyDir
+                      (ffi.import: Dir #as RubyDir
                         (#static home [] #io Path))
 
-                      (host.import: Kernel #as RubyKernel
+                      (ffi.import: Kernel #as RubyKernel
                         (#static exit [Int] #io Nothing)))
 
         @.php
-        (as_is (host.import: (exit [Int] #io Nothing))
+        (as_is (ffi.import: (exit [Int] #io Nothing))
                ## https://www.php.net/manual/en/function.exit.php
-               (host.import: (getcwd [] #io host.String))
+               (ffi.import: (getcwd [] #io ffi.String))
                ## https://www.php.net/manual/en/function.getcwd.php
-               (host.import: (getenv #as getenv/1 [host.String] #io host.String))
-               (host.import: (getenv #as getenv/0 [] #io (Array host.String)))
+               (ffi.import: (getenv #as getenv/1 [ffi.String] #io ffi.String))
+               (ffi.import: (getenv #as getenv/0 [] #io (Array ffi.String)))
                ## https://www.php.net/manual/en/function.getenv.php
                ## https://www.php.net/manual/en/function.array-keys.php
-               (host.import: (array_keys [(Array host.String)] (Array host.String)))
+               (ffi.import: (array_keys [(Array ffi.String)] (Array ffi.String)))
                )
 
         @.scheme
-        (as_is (host.import: (exit [Int] #io Nothing))
+        (as_is (ffi.import: (exit [Int] #io Nothing))
                ## https://srfi.schemers.org/srfi-98/srfi-98.html
                (abstract: Pair Any)
                (abstract: PList Any)
-               (host.import: (get-environment-variables [] #io PList))
-               (host.import: (car [Pair] Text))
-               (host.import: (cdr [Pair] Text))
-               (host.import: (car #as head [PList] Pair))
-               (host.import: (cdr #as tail [PList] PList)))}
+               (ffi.import: (get-environment-variables [] #io PList))
+               (ffi.import: (car [Pair] Text))
+               (ffi.import: (cdr [Pair] Text))
+               (ffi.import: (car #as head [PList] Pair))
+               (ffi.import: (cdr #as tail [PList] PList)))}
        (as_is)))
 
 (structure: #export default
@@ -252,8 +252,8 @@
     (with_expansions [ ..jvm\\environment]
       (for {@.old 
             @.jvm 
-            @.js (io.io (if host.on_node_js?
-                          (case (host.constant Object [process env])
+            @.js (io.io (if ffi.on_node_js?
+                          (case (ffi.constant Object [process env])
                             (#.Some process/env)
                             (array\fold (function (_ entry environment)
                                           (<| (maybe.default environment)
@@ -306,7 +306,7 @@
                        (io.io (maybe.default "" (java/lang/System::getProperty "user.home")))]
       (for {@.old 
             @.jvm 
-            @.js (if host.on_node_js?
+            @.js (if ffi.on_node_js?
                    (|> (..require "os")
                        (:coerce NodeJs_OS)
                        (NodeJs_OS::homedir []))
@@ -327,8 +327,8 @@
                        (io.io (maybe.default "" (java/lang/System::getProperty "user.dir")))]
       (for {@.old 
             @.jvm 
-            @.js (if host.on_node_js?
-                   (case (host.constant ..NodeJs_Process [process])
+            @.js (if ffi.on_node_js?
+                   (case (ffi.constant ..NodeJs_Process [process])
                      (#.Some process)
                      (NodeJs_Process::cwd [] process)
                      
@@ -357,10 +357,10 @@
                               (wrap (undefined)))]
       (for {@.old 
             @.jvm 
-            @.js (cond host.on_node_js?
+            @.js (cond ffi.on_node_js?
                        (..exit_node_js! code)
 
-                       host.on_browser?
+                       ffi.on_browser?
                        (..exit_browser! code)
 
                        ## else
diff --git a/stdlib/source/lux/world/shell.lux b/stdlib/source/lux/world/shell.lux
index 10c3f4718..482100853 100644
--- a/stdlib/source/lux/world/shell.lux
+++ b/stdlib/source/lux/world/shell.lux
@@ -1,7 +1,7 @@
 (.module:
   [lux #*
    ["@" target]
-   ["jvm" host (#+ import:)]
+   ["jvm" ffi (#+ import:)]
    [abstract
     [monad (#+ do)]]
    [control
diff --git a/stdlib/source/program/aedifex/dependency/resolution.lux b/stdlib/source/program/aedifex/dependency/resolution.lux
index 1be540298..1d72f0937 100644
--- a/stdlib/source/program/aedifex/dependency/resolution.lux
+++ b/stdlib/source/program/aedifex/dependency/resolution.lux
@@ -1,7 +1,7 @@
 (.module:
   [lux (#- Name)
    ["." debug]
-   ["." host (#+ import:)]
+   ["." ffi (#+ import:)]
    [abstract
     [codec (#+ Codec)]
     [equivalence (#+ Equivalence)]
diff --git a/stdlib/source/program/aedifex/hash.lux b/stdlib/source/program/aedifex/hash.lux
index 336d9bc96..b94e2a0cf 100644
--- a/stdlib/source/program/aedifex/hash.lux
+++ b/stdlib/source/program/aedifex/hash.lux
@@ -1,6 +1,6 @@
 (.module:
   [lux #*
-   ["." host (#+ import:)]
+   ["." ffi (#+ import:)]
    [abstract
     [codec (#+ Codec)]
     [equivalence (#+ Equivalence)]
diff --git a/stdlib/source/program/aedifex/repository/identity.lux b/stdlib/source/program/aedifex/repository/identity.lux
index 2de3c6751..7ec3cceec 100644
--- a/stdlib/source/program/aedifex/repository/identity.lux
+++ b/stdlib/source/program/aedifex/repository/identity.lux
@@ -1,6 +1,6 @@
 (.module:
   [lux #*
-   ["." host (#+ import:)]
+   ["." ffi (#+ import:)]
    [abstract
     [equivalence (#+ Equivalence)]]
    [data
diff --git a/stdlib/source/program/aedifex/repository/local.lux b/stdlib/source/program/aedifex/repository/local.lux
index 7ac384efa..6b4575627 100644
--- a/stdlib/source/program/aedifex/repository/local.lux
+++ b/stdlib/source/program/aedifex/repository/local.lux
@@ -1,6 +1,6 @@
 (.module:
   [lux #*
-   [host (#+ import:)]
+   [ffi (#+ import:)]
    [abstract
     [monad (#+ do)]]
    [control
diff --git a/stdlib/source/program/aedifex/repository/remote.lux b/stdlib/source/program/aedifex/repository/remote.lux
index 4b61bc36c..fd0d65d6f 100644
--- a/stdlib/source/program/aedifex/repository/remote.lux
+++ b/stdlib/source/program/aedifex/repository/remote.lux
@@ -1,6 +1,6 @@
 (.module:
   [lux #*
-   [host (#+ import:)]
+   [ffi (#+ import:)]
    [abstract
     [monad (#+ do)]]
    [control
diff --git a/stdlib/source/spec/compositor/generation/structure.lux b/stdlib/source/spec/compositor/generation/structure.lux
index a8f820786..237ff5024 100644
--- a/stdlib/source/spec/compositor/generation/structure.lux
+++ b/stdlib/source/spec/compositor/generation/structure.lux
@@ -18,7 +18,7 @@
      ["." list ("#\." functor)]]]
    [math
     ["r" random]]
-   ["." host (#+ import:)]
+   ["." ffi (#+ import:)]
    [tool
     [compiler
      ["." analysis]
@@ -48,7 +48,7 @@
                               (let [tag-out (:coerce java/lang/Integer (maybe.assume (array.read 0 valueT)))
                                     last?-out (array.read 1 valueT)
                                     value-out (:coerce Any (maybe.assume (array.read 2 valueT)))
-                                    same-tag? (|> tag-out host.int-to-long (:coerce Nat) (n.= tag-in))
+                                    same-tag? (|> tag-out ffi.int-to-long (:coerce Nat) (n.= tag-in))
                                     same-flag? (case last?-out
                                                  (#.Some last?-out')
                                                  (and last?-in (text\= "" (:coerce Text last?-out')))
diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux
index 8532b3e12..40a797177 100644
--- a/stdlib/source/test/lux.lux
+++ b/stdlib/source/test/lux.lux
@@ -39,7 +39,7 @@
      ## ["#." tool] ## TODO: Update & expand tests for this
      ["#." type]
      ["#." world]
-     ["#." host]
+     ["#." ffi]
      ["#." extension]
      ["#." target #_
       ]]))
@@ -220,7 +220,7 @@
                           ## /tool.test
                           /type.test
                           /world.test
-                          /host.test
+                          /ffi.test
                           (for {@.jvm (#.Cons /target/jvm.test tail)
                                 @.old (#.Cons /target/jvm.test tail)}
                                tail)
diff --git a/stdlib/source/test/lux/control/function/contract.lux b/stdlib/source/test/lux/control/function/contract.lux
index 47962d04a..76eb07104 100644
--- a/stdlib/source/test/lux/control/function/contract.lux
+++ b/stdlib/source/test/lux/control/function/contract.lux
@@ -1,7 +1,7 @@
 (.module:
   [lux #*
    ["_" test (#+ Test)]
-   ["." host]
+   ["." ffi]
    [abstract
     [monad (#+ do)]]
    [control
@@ -20,16 +20,16 @@
         [expected random.nat])
       ($_ _.and
           (_.cover [/.pre]
-                   (case (host.try (/.pre (n.even? expected)
-                                          true))
+                   (case (ffi.try (/.pre (n.even? expected)
+                                         true))
                      (#try.Success output)
                      output
                      
                      (#try.Failure error)
                      (not (n.even? expected))))
           (_.cover [/.post]
-                   (case (host.try (/.post n.odd?
-                                           expected))
+                   (case (ffi.try (/.post n.odd?
+                                          expected))
                      (#try.Success actual)
                      (is? expected actual)
                      
diff --git a/stdlib/source/test/lux/ffi.js.lux b/stdlib/source/test/lux/ffi.js.lux
new file mode 100644
index 000000000..5ffe1fbeb
--- /dev/null
+++ b/stdlib/source/test/lux/ffi.js.lux
@@ -0,0 +1,88 @@
+(.module:
+  [lux #*
+   ["_" test (#+ Test)]
+   [abstract
+    [monad (#+ do)]]
+   [control
+    ["." try]]
+   [data
+    ["." text ("#\." equivalence)]]
+   [math
+    ["." random (#+ Random)]
+    [number
+     ["." nat]
+     ["." frac]]]]
+  {1
+   ["." /]})
+
+(/.import: Uint8Array)
+
+## On Nashorn
+(/.import: java/lang/String
+  (new [Uint8Array /.String])
+  (getBytes [/.String] Uint8Array))
+
+## On Node
+(/.import: Buffer
+  (#static from [/.String /.String] Buffer)
+  (toString [/.String] /.String))
+
+## On the browser
+(/.import: TextEncoder
+  (new [/.String])
+  (encode [/.String] Uint8Array))
+
+(/.import: TextDecoder
+  (new [/.String])
+  (decode [Uint8Array] /.String))
+
+(def: #export test
+  Test
+  (do {! random.monad}
+    [boolean random.bit
+     number (\ ! map (|>> (nat.% 100) nat.frac) random.nat)
+     string (random.ascii 5)
+     function (\ ! map (function (_ shift)
+                         (: (-> Nat Nat)
+                            (nat.+ shift)))
+                 random.nat)
+     ## I64s get compiled as JavaScript objects with a specific structure.
+     object random.nat]
+    (<| (_.covering /._)
+        ($_ _.and
+            (_.cover [/.on_browser? /.on_node_js? /.on_nashorn?]
+                     (or /.on_nashorn?
+                         /.on_node_js?
+                         /.on_browser?))
+            (_.cover [/.type_of]
+                     (and (text\= "boolean" (/.type_of boolean))
+                          (text\= "number" (/.type_of number))
+                          (text\= "string" (/.type_of string))
+                          (text\= "function" (/.type_of function))
+                          (text\= "object" (/.type_of object))))
+            (_.cover [/.try]
+                     (case (/.try (error! string))
+                       (#try.Success _)
+                       false
+                       
+                       (#try.Failure error)
+                       (text\= string error)))
+            (_.cover [/.import:]
+                     (let [encoding "utf8"]
+                       (text\= string
+                               (cond /.on_nashorn?
+                                     (let [binary (java/lang/String::getBytes [encoding] (:coerce java/lang/String string))]
+                                       (|> (java/lang/String::new [binary encoding])
+                                           (:coerce Text)))
+                                     
+                                     /.on_node_js?
+                                     (|> (Buffer::from [string encoding])
+                                         (Buffer::toString [encoding]))
+                                     
+                                     ## On the browser
+                                     (let [binary (|> (TextEncoder::new [encoding])
+                                                      (TextEncoder::encode [string]))]
+                                       (|> (TextDecoder::new [encoding])
+                                           (TextDecoder::decode [binary])))
+                                     ))))
+            ))))
diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux
new file mode 100644
index 000000000..9edaecd0c
--- /dev/null
+++ b/stdlib/source/test/lux/ffi.jvm.lux
@@ -0,0 +1,151 @@
+(.module:
+  [lux #*
+   [abstract/monad (#+ Monad do)]
+   [control
+    pipe]
+   [data
+    ["." text ("#\." equivalence)]]
+   [math
+    ["r" random]
+    [number
+     ["n" nat]
+     ["i" int]]]
+   ["_" test (#+ Test)]]
+  {1
+   ["." / (#+ import: class: interface: object)]})
+
+(import: (java/util/concurrent/Callable a))
+
+(import: java/lang/Long)
+
+(import: java/lang/String)
+
+(import: java/lang/Exception
+  ["#::."
+   (new [java/lang/String])])
+
+(import: java/lang/Object)
+
+(import: (java/lang/Class a)
+  ["#::."
+   (getName [] java/lang/String)])
+
+(import: java/lang/Runnable)
+
+(import: java/lang/System
+  ["#::."
+   (#static out java/io/PrintStream)
+   (#static currentTimeMillis [] #io long)
+   (#static getenv [java/lang/String] #io #? java/lang/String)])
+
+## TODO: Handle "class:" ASAP.
+## (class: #final (TestClass A) [java/lang/Runnable]
+##   ## Fields
+##   (#private foo boolean)
+##   (#private bar A)
+##   (#private baz java/lang/Object)
+##   ## Methods
+##   (#public [] (new self {value A}) []
+##            (exec (:= ::foo #1)
+##              (:= ::bar value)
+##              (:= ::baz "")
+##              []))
+##   (#public (virtual self) java/lang/Object
+##            "")
+##   (#public #static (static) java/lang/Object
+##            "")
+##   (java/lang/Runnable [] (run self) void
+##                       []))
+
+(def: test_runnable
+  (object [] [java/lang/Runnable]
+    []
+    (java/lang/Runnable
+     [] (run self) void
+     [])))
+
+(def: test_callable
+  (object [a] [(java/util/concurrent/Callable a)]
+    []
+    ((java/util/concurrent/Callable a)
+     [] (call self) a #throws [java/lang/Exception]
+     (undefined))))
+
+## (interface: TestInterface
+##   ([] foo [boolean java/lang/String] void #throws [java/lang/Exception]))
+
+(def: conversions
+  Test
+  (do r.monad
+    [sample r.int]
+    (`` ($_ _.and
+            (~~ (template [  ]
+                  [(_.test 
+                           (or (|> sample (:coerce java/lang/Long)   (:coerce Int) (i.= sample))
+                               (let [capped_sample (|> sample (:coerce java/lang/Long)  )]
+                                 (|> capped_sample   (:coerce Int) (i.= (:coerce Int capped_sample))))))]
+
+                  [/.long_to_byte /.byte_to_long "Can succesfully convert to/from byte."]
+                  [/.long_to_short /.short_to_long "Can succesfully convert to/from short."]
+                  [/.long_to_int /.int_to_long "Can succesfully convert to/from int."]
+                  [/.long_to_float /.float_to_long "Can succesfully convert to/from float."]
+                  [/.long_to_double /.double_to_long "Can succesfully convert to/from double."]
+                  [(<| /.int_to_char /.long_to_int) (<| /.int_to_long /.char_to_int) "Can succesfully convert to/from char."]
+                  ))
+            ))))
+
+(def: miscellaneous
+  Test
+  (do {! r.monad}
+    [sample (\ ! map (|>> (:coerce java/lang/Object))
+               (r.ascii 1))]
+    ($_ _.and
+        (_.test "Can check if an object is of a certain class."
+                (and (case (/.check java/lang/String sample) (#.Some _) true #.None false)
+                     (case (/.check java/lang/Long sample) (#.Some _) false #.None true)
+                     (case (/.check java/lang/Object sample) (#.Some _) true #.None false)
+                     (case (/.check java/lang/Object (/.null)) (#.Some _) false #.None true)))
+
+        (_.test "Can run code in a 'synchronized' block."
+                (/.synchronized sample #1))
+
+        (_.test "Can access Class instances."
+                (text\= "java.lang.Class" (java/lang/Class::getName (/.class_for java/lang/Class))))
+
+        (_.test "Can check if a value is null."
+                (and (/.null? (/.null))
+                     (not (/.null? sample))))
+
+        (_.test "Can safely convert nullable references into Maybe values."
+                (and (|> (: (Maybe java/lang/Object) (/.??? (/.null)))
+                         (case> #.None #1
+                                _ #0))
+                     (|> (: (Maybe java/lang/Object) (/.??? sample))
+                         (case> (#.Some _) #1
+                                _ #0))))
+        )))
+
+(def: arrays
+  Test
+  (do {! r.monad}
+    [size (|> r.nat (\ ! map (|>> (n.% 100) (n.max 1))))
+     idx (|> r.nat (\ ! map (n.% size)))
+     value (\ ! map (|>> (:coerce java/lang/Long)) r.int)]
+    ($_ _.and
+        (_.test "Can create arrays of some length."
+                (n.= size (/.array_length (/.array java/lang/Long size))))
+
+        (_.test "Can set and get array values."
+                (let [arr (/.array java/lang/Long size)]
+                  (exec (/.array_write idx value arr)
+                    (i.= (:coerce Int value)
+                         (:coerce Int (/.array_read idx arr)))))))))
+
+(def: #export test
+  ($_ _.and
+      (<| (_.context "Conversions.")
+          ..conversions)
+      (<| (_.context "Miscellaneous.")
+          ..miscellaneous)
+      (<| (_.context "Arrays.")
+          ..arrays)))
diff --git a/stdlib/source/test/lux/ffi.lua.lux b/stdlib/source/test/lux/ffi.lua.lux
new file mode 100644
index 000000000..0b6cac81b
--- /dev/null
+++ b/stdlib/source/test/lux/ffi.lua.lux
@@ -0,0 +1,24 @@
+(.module:
+  [lux #*
+   ["_" test (#+ Test)]
+   [abstract
+    [monad (#+ do)]]
+   [control
+    ["." try]]
+   [data
+    ["." text ("#\." equivalence)]]
+   [math
+    ["." random (#+ Random)]
+    [number
+     ["." nat]
+     ["." frac]]]]
+  {1
+   ["." /]})
+
+(def: #export test
+  Test
+  (do {! random.monad}
+    []
+    (<| (_.covering /._)
+        (_.test "TBD"
+                true))))
diff --git a/stdlib/source/test/lux/ffi.old.lux b/stdlib/source/test/lux/ffi.old.lux
new file mode 100644
index 000000000..b14dac30d
--- /dev/null
+++ b/stdlib/source/test/lux/ffi.old.lux
@@ -0,0 +1,145 @@
+(.module:
+  [lux #*
+   [abstract/monad (#+ Monad do)]
+   [control
+    pipe]
+   [data
+    ["." text ("#\." equivalence)]]
+   [math
+    ["r" random]
+    [number
+     ["n" nat]
+     ["i" int]]]
+   ["_" test (#+ Test)]]
+  {1
+   ["." / (#+ import: class: interface: object)]})
+
+(import: (java/util/concurrent/Callable a))
+
+(import: java/lang/Object)
+(import: java/lang/String)
+
+(import: java/lang/Exception
+  ["#::."
+   (new [java/lang/String])])
+
+(import: java/lang/Runnable)
+
+(import: (java/lang/Class a)
+  ["#::."
+   (getName [] java/lang/String)])
+
+(import: java/lang/System
+  ["#::."
+   (#static out java/io/PrintStream)
+   (#static currentTimeMillis [] #io long)
+   (#static getenv [java/lang/String] #io #? java/lang/String)])
+
+(class: #final (TestClass A) [java/lang/Runnable]
+  ## Fields
+  (#private foo boolean)
+  (#private bar A)
+  (#private baz java/lang/Object)
+  ## Methods
+  (#public [] (new {value A}) []
+           (exec (:= ::foo #1)
+             (:= ::bar value)
+             (:= ::baz "")
+             []))
+  (#public (virtual self) java/lang/Object
+           "")
+  (#public #static (static) java/lang/Object
+           "")
+  (java/lang/Runnable [] (run self) void
+                      []))
+
+(def: test_runnable
+  (object [] [java/lang/Runnable]
+    []
+    (java/lang/Runnable [] (run self) void
+                        [])))
+
+(def: test_callable
+  (object [a] [(java/util/concurrent/Callable a)]
+    []
+    (java/util/concurrent/Callable [] (call self) a
+                                   (undefined))))
+
+(interface: TestInterface
+  ([] foo [boolean java/lang/String] void #throws [java/lang/Exception]))
+
+(def: conversions
+  Test
+  (do r.monad
+    [sample r.int]
+    (`` ($_ _.and
+            (~~ (template [  ]
+                  [(_.test 
+                           (or (|> sample   (i.= sample))
+                               (let [capped_sample (|> sample  )]
+                                 (|> capped_sample   (i.= capped_sample)))))]
+
+                  [/.long_to_byte /.byte_to_long "Can succesfully convert to/from byte."]
+                  [/.long_to_short /.short_to_long "Can succesfully convert to/from short."]
+                  [/.long_to_int /.int_to_long "Can succesfully convert to/from int."]
+                  [/.long_to_float /.float_to_long "Can succesfully convert to/from float."]
+                  [/.long_to_double /.double_to_long "Can succesfully convert to/from double."]
+                  [(<| /.int_to_char /.long_to_int) (<| /.int_to_long /.char_to_int) "Can succesfully convert to/from char."]
+                  ))
+            ))))
+
+(def: miscellaneous
+  Test
+  (do r.monad
+    [sample (r.ascii 1)]
+    ($_ _.and
+        (_.test "Can check if an object is of a certain class."
+                (and (case (/.check java/lang/String sample) (#.Some _) true #.None false)
+                     (case (/.check java/lang/Long sample) (#.Some _) false #.None true)
+                     (case (/.check java/lang/Object sample) (#.Some _) true #.None false)
+                     (case (/.check java/lang/Object (/.null)) (#.Some _) false #.None true)))
+
+        (_.test "Can run code in a 'synchronized' block."
+                (/.synchronized sample #1))
+
+        (_.test "Can access Class instances."
+                (text\= "java.lang.Class" (java/lang/Class::getName (/.class_for java/lang/Class))))
+
+        (_.test "Can check if a value is null."
+                (and (/.null? (/.null))
+                     (not (/.null? sample))))
+
+        (_.test "Can safely convert nullable references into Maybe values."
+                (and (|> (: (Maybe java/lang/Object) (/.??? (/.null)))
+                         (case> #.None #1
+                                _ #0))
+                     (|> (: (Maybe java/lang/Object) (/.??? sample))
+                         (case> (#.Some _) #1
+                                _ #0))))
+        )))
+
+(def: arrays
+  Test
+  (do {! r.monad}
+    [size (|> r.nat (\ ! map (|>> (n.% 100) (n.max 1))))
+     idx (|> r.nat (\ ! map (n.% size)))
+     value r.int]
+    ($_ _.and
+        (_.test "Can create arrays of some length."
+                (n.= size (/.array_length (/.array java/lang/Long size))))
+
+        (_.test "Can set and get array values."
+                (let [arr (/.array java/lang/Long size)]
+                  (exec (/.array_write idx value arr)
+                    (i.= value (/.array_read idx arr)))))
+        )))
+
+(def: #export test
+  ($_ _.and
+      (<| (_.context "Conversions.")
+          ..conversions)
+      (<| (_.context "Miscellaneous.")
+          ..miscellaneous)
+      (<| (_.context "Arrays.")
+          ..arrays)
+      ))
diff --git a/stdlib/source/test/lux/ffi.php.lux b/stdlib/source/test/lux/ffi.php.lux
new file mode 100644
index 000000000..0b6cac81b
--- /dev/null
+++ b/stdlib/source/test/lux/ffi.php.lux
@@ -0,0 +1,24 @@
+(.module:
+  [lux #*
+   ["_" test (#+ Test)]
+   [abstract
+    [monad (#+ do)]]
+   [control
+    ["." try]]
+   [data
+    ["." text ("#\." equivalence)]]
+   [math
+    ["." random (#+ Random)]
+    [number
+     ["." nat]
+     ["." frac]]]]
+  {1
+   ["." /]})
+
+(def: #export test
+  Test
+  (do {! random.monad}
+    []
+    (<| (_.covering /._)
+        (_.test "TBD"
+                true))))
diff --git a/stdlib/source/test/lux/ffi.py.lux b/stdlib/source/test/lux/ffi.py.lux
new file mode 100644
index 000000000..0b6cac81b
--- /dev/null
+++ b/stdlib/source/test/lux/ffi.py.lux
@@ -0,0 +1,24 @@
+(.module:
+  [lux #*
+   ["_" test (#+ Test)]
+   [abstract
+    [monad (#+ do)]]
+   [control
+    ["." try]]
+   [data
+    ["." text ("#\." equivalence)]]
+   [math
+    ["." random (#+ Random)]
+    [number
+     ["." nat]
+     ["." frac]]]]
+  {1
+   ["." /]})
+
+(def: #export test
+  Test
+  (do {! random.monad}
+    []
+    (<| (_.covering /._)
+        (_.test "TBD"
+                true))))
diff --git a/stdlib/source/test/lux/ffi.rb.lux b/stdlib/source/test/lux/ffi.rb.lux
new file mode 100644
index 000000000..0b6cac81b
--- /dev/null
+++ b/stdlib/source/test/lux/ffi.rb.lux
@@ -0,0 +1,24 @@
+(.module:
+  [lux #*
+   ["_" test (#+ Test)]
+   [abstract
+    [monad (#+ do)]]
+   [control
+    ["." try]]
+   [data
+    ["." text ("#\." equivalence)]]
+   [math
+    ["." random (#+ Random)]
+    [number
+     ["." nat]
+     ["." frac]]]]
+  {1
+   ["." /]})
+
+(def: #export test
+  Test
+  (do {! random.monad}
+    []
+    (<| (_.covering /._)
+        (_.test "TBD"
+                true))))
diff --git a/stdlib/source/test/lux/ffi.scm.lux b/stdlib/source/test/lux/ffi.scm.lux
new file mode 100644
index 000000000..0b6cac81b
--- /dev/null
+++ b/stdlib/source/test/lux/ffi.scm.lux
@@ -0,0 +1,24 @@
+(.module:
+  [lux #*
+   ["_" test (#+ Test)]
+   [abstract
+    [monad (#+ do)]]
+   [control
+    ["." try]]
+   [data
+    ["." text ("#\." equivalence)]]
+   [math
+    ["." random (#+ Random)]
+    [number
+     ["." nat]
+     ["." frac]]]]
+  {1
+   ["." /]})
+
+(def: #export test
+  Test
+  (do {! random.monad}
+    []
+    (<| (_.covering /._)
+        (_.test "TBD"
+                true))))
diff --git a/stdlib/source/test/lux/host.js.lux b/stdlib/source/test/lux/host.js.lux
deleted file mode 100644
index 5ffe1fbeb..000000000
--- a/stdlib/source/test/lux/host.js.lux
+++ /dev/null
@@ -1,88 +0,0 @@
-(.module:
-  [lux #*
-   ["_" test (#+ Test)]
-   [abstract
-    [monad (#+ do)]]
-   [control
-    ["." try]]
-   [data
-    ["." text ("#\." equivalence)]]
-   [math
-    ["." random (#+ Random)]
-    [number
-     ["." nat]
-     ["." frac]]]]
-  {1
-   ["." /]})
-
-(/.import: Uint8Array)
-
-## On Nashorn
-(/.import: java/lang/String
-  (new [Uint8Array /.String])
-  (getBytes [/.String] Uint8Array))
-
-## On Node
-(/.import: Buffer
-  (#static from [/.String /.String] Buffer)
-  (toString [/.String] /.String))
-
-## On the browser
-(/.import: TextEncoder
-  (new [/.String])
-  (encode [/.String] Uint8Array))
-
-(/.import: TextDecoder
-  (new [/.String])
-  (decode [Uint8Array] /.String))
-
-(def: #export test
-  Test
-  (do {! random.monad}
-    [boolean random.bit
-     number (\ ! map (|>> (nat.% 100) nat.frac) random.nat)
-     string (random.ascii 5)
-     function (\ ! map (function (_ shift)
-                         (: (-> Nat Nat)
-                            (nat.+ shift)))
-                 random.nat)
-     ## I64s get compiled as JavaScript objects with a specific structure.
-     object random.nat]
-    (<| (_.covering /._)
-        ($_ _.and
-            (_.cover [/.on_browser? /.on_node_js? /.on_nashorn?]
-                     (or /.on_nashorn?
-                         /.on_node_js?
-                         /.on_browser?))
-            (_.cover [/.type_of]
-                     (and (text\= "boolean" (/.type_of boolean))
-                          (text\= "number" (/.type_of number))
-                          (text\= "string" (/.type_of string))
-                          (text\= "function" (/.type_of function))
-                          (text\= "object" (/.type_of object))))
-            (_.cover [/.try]
-                     (case (/.try (error! string))
-                       (#try.Success _)
-                       false
-                       
-                       (#try.Failure error)
-                       (text\= string error)))
-            (_.cover [/.import:]
-                     (let [encoding "utf8"]
-                       (text\= string
-                               (cond /.on_nashorn?
-                                     (let [binary (java/lang/String::getBytes [encoding] (:coerce java/lang/String string))]
-                                       (|> (java/lang/String::new [binary encoding])
-                                           (:coerce Text)))
-                                     
-                                     /.on_node_js?
-                                     (|> (Buffer::from [string encoding])
-                                         (Buffer::toString [encoding]))
-                                     
-                                     ## On the browser
-                                     (let [binary (|> (TextEncoder::new [encoding])
-                                                      (TextEncoder::encode [string]))]
-                                       (|> (TextDecoder::new [encoding])
-                                           (TextDecoder::decode [binary])))
-                                     ))))
-            ))))
diff --git a/stdlib/source/test/lux/host.jvm.lux b/stdlib/source/test/lux/host.jvm.lux
deleted file mode 100644
index 9edaecd0c..000000000
--- a/stdlib/source/test/lux/host.jvm.lux
+++ /dev/null
@@ -1,151 +0,0 @@
-(.module:
-  [lux #*
-   [abstract/monad (#+ Monad do)]
-   [control
-    pipe]
-   [data
-    ["." text ("#\." equivalence)]]
-   [math
-    ["r" random]
-    [number
-     ["n" nat]
-     ["i" int]]]
-   ["_" test (#+ Test)]]
-  {1
-   ["." / (#+ import: class: interface: object)]})
-
-(import: (java/util/concurrent/Callable a))
-
-(import: java/lang/Long)
-
-(import: java/lang/String)
-
-(import: java/lang/Exception
-  ["#::."
-   (new [java/lang/String])])
-
-(import: java/lang/Object)
-
-(import: (java/lang/Class a)
-  ["#::."
-   (getName [] java/lang/String)])
-
-(import: java/lang/Runnable)
-
-(import: java/lang/System
-  ["#::."
-   (#static out java/io/PrintStream)
-   (#static currentTimeMillis [] #io long)
-   (#static getenv [java/lang/String] #io #? java/lang/String)])
-
-## TODO: Handle "class:" ASAP.
-## (class: #final (TestClass A) [java/lang/Runnable]
-##   ## Fields
-##   (#private foo boolean)
-##   (#private bar A)
-##   (#private baz java/lang/Object)
-##   ## Methods
-##   (#public [] (new self {value A}) []
-##            (exec (:= ::foo #1)
-##              (:= ::bar value)
-##              (:= ::baz "")
-##              []))
-##   (#public (virtual self) java/lang/Object
-##            "")
-##   (#public #static (static) java/lang/Object
-##            "")
-##   (java/lang/Runnable [] (run self) void
-##                       []))
-
-(def: test_runnable
-  (object [] [java/lang/Runnable]
-    []
-    (java/lang/Runnable
-     [] (run self) void
-     [])))
-
-(def: test_callable
-  (object [a] [(java/util/concurrent/Callable a)]
-    []
-    ((java/util/concurrent/Callable a)
-     [] (call self) a #throws [java/lang/Exception]
-     (undefined))))
-
-## (interface: TestInterface
-##   ([] foo [boolean java/lang/String] void #throws [java/lang/Exception]))
-
-(def: conversions
-  Test
-  (do r.monad
-    [sample r.int]
-    (`` ($_ _.and
-            (~~ (template [  ]
-                  [(_.test 
-                           (or (|> sample (:coerce java/lang/Long)   (:coerce Int) (i.= sample))
-                               (let [capped_sample (|> sample (:coerce java/lang/Long)  )]
-                                 (|> capped_sample   (:coerce Int) (i.= (:coerce Int capped_sample))))))]
-
-                  [/.long_to_byte /.byte_to_long "Can succesfully convert to/from byte."]
-                  [/.long_to_short /.short_to_long "Can succesfully convert to/from short."]
-                  [/.long_to_int /.int_to_long "Can succesfully convert to/from int."]
-                  [/.long_to_float /.float_to_long "Can succesfully convert to/from float."]
-                  [/.long_to_double /.double_to_long "Can succesfully convert to/from double."]
-                  [(<| /.int_to_char /.long_to_int) (<| /.int_to_long /.char_to_int) "Can succesfully convert to/from char."]
-                  ))
-            ))))
-
-(def: miscellaneous
-  Test
-  (do {! r.monad}
-    [sample (\ ! map (|>> (:coerce java/lang/Object))
-               (r.ascii 1))]
-    ($_ _.and
-        (_.test "Can check if an object is of a certain class."
-                (and (case (/.check java/lang/String sample) (#.Some _) true #.None false)
-                     (case (/.check java/lang/Long sample) (#.Some _) false #.None true)
-                     (case (/.check java/lang/Object sample) (#.Some _) true #.None false)
-                     (case (/.check java/lang/Object (/.null)) (#.Some _) false #.None true)))
-
-        (_.test "Can run code in a 'synchronized' block."
-                (/.synchronized sample #1))
-
-        (_.test "Can access Class instances."
-                (text\= "java.lang.Class" (java/lang/Class::getName (/.class_for java/lang/Class))))
-
-        (_.test "Can check if a value is null."
-                (and (/.null? (/.null))
-                     (not (/.null? sample))))
-
-        (_.test "Can safely convert nullable references into Maybe values."
-                (and (|> (: (Maybe java/lang/Object) (/.??? (/.null)))
-                         (case> #.None #1
-                                _ #0))
-                     (|> (: (Maybe java/lang/Object) (/.??? sample))
-                         (case> (#.Some _) #1
-                                _ #0))))
-        )))
-
-(def: arrays
-  Test
-  (do {! r.monad}
-    [size (|> r.nat (\ ! map (|>> (n.% 100) (n.max 1))))
-     idx (|> r.nat (\ ! map (n.% size)))
-     value (\ ! map (|>> (:coerce java/lang/Long)) r.int)]
-    ($_ _.and
-        (_.test "Can create arrays of some length."
-                (n.= size (/.array_length (/.array java/lang/Long size))))
-
-        (_.test "Can set and get array values."
-                (let [arr (/.array java/lang/Long size)]
-                  (exec (/.array_write idx value arr)
-                    (i.= (:coerce Int value)
-                         (:coerce Int (/.array_read idx arr)))))))))
-
-(def: #export test
-  ($_ _.and
-      (<| (_.context "Conversions.")
-          ..conversions)
-      (<| (_.context "Miscellaneous.")
-          ..miscellaneous)
-      (<| (_.context "Arrays.")
-          ..arrays)))
diff --git a/stdlib/source/test/lux/host.lua.lux b/stdlib/source/test/lux/host.lua.lux
deleted file mode 100644
index 0b6cac81b..000000000
--- a/stdlib/source/test/lux/host.lua.lux
+++ /dev/null
@@ -1,24 +0,0 @@
-(.module:
-  [lux #*
-   ["_" test (#+ Test)]
-   [abstract
-    [monad (#+ do)]]
-   [control
-    ["." try]]
-   [data
-    ["." text ("#\." equivalence)]]
-   [math
-    ["." random (#+ Random)]
-    [number
-     ["." nat]
-     ["." frac]]]]
-  {1
-   ["." /]})
-
-(def: #export test
-  Test
-  (do {! random.monad}
-    []
-    (<| (_.covering /._)
-        (_.test "TBD"
-                true))))
diff --git a/stdlib/source/test/lux/host.old.lux b/stdlib/source/test/lux/host.old.lux
deleted file mode 100644
index b14dac30d..000000000
--- a/stdlib/source/test/lux/host.old.lux
+++ /dev/null
@@ -1,145 +0,0 @@
-(.module:
-  [lux #*
-   [abstract/monad (#+ Monad do)]
-   [control
-    pipe]
-   [data
-    ["." text ("#\." equivalence)]]
-   [math
-    ["r" random]
-    [number
-     ["n" nat]
-     ["i" int]]]
-   ["_" test (#+ Test)]]
-  {1
-   ["." / (#+ import: class: interface: object)]})
-
-(import: (java/util/concurrent/Callable a))
-
-(import: java/lang/Object)
-(import: java/lang/String)
-
-(import: java/lang/Exception
-  ["#::."
-   (new [java/lang/String])])
-
-(import: java/lang/Runnable)
-
-(import: (java/lang/Class a)
-  ["#::."
-   (getName [] java/lang/String)])
-
-(import: java/lang/System
-  ["#::."
-   (#static out java/io/PrintStream)
-   (#static currentTimeMillis [] #io long)
-   (#static getenv [java/lang/String] #io #? java/lang/String)])
-
-(class: #final (TestClass A) [java/lang/Runnable]
-  ## Fields
-  (#private foo boolean)
-  (#private bar A)
-  (#private baz java/lang/Object)
-  ## Methods
-  (#public [] (new {value A}) []
-           (exec (:= ::foo #1)
-             (:= ::bar value)
-             (:= ::baz "")
-             []))
-  (#public (virtual self) java/lang/Object
-           "")
-  (#public #static (static) java/lang/Object
-           "")
-  (java/lang/Runnable [] (run self) void
-                      []))
-
-(def: test_runnable
-  (object [] [java/lang/Runnable]
-    []
-    (java/lang/Runnable [] (run self) void
-                        [])))
-
-(def: test_callable
-  (object [a] [(java/util/concurrent/Callable a)]
-    []
-    (java/util/concurrent/Callable [] (call self) a
-                                   (undefined))))
-
-(interface: TestInterface
-  ([] foo [boolean java/lang/String] void #throws [java/lang/Exception]))
-
-(def: conversions
-  Test
-  (do r.monad
-    [sample r.int]
-    (`` ($_ _.and
-            (~~ (template [  ]
-                  [(_.test 
-                           (or (|> sample   (i.= sample))
-                               (let [capped_sample (|> sample  )]
-                                 (|> capped_sample   (i.= capped_sample)))))]
-
-                  [/.long_to_byte /.byte_to_long "Can succesfully convert to/from byte."]
-                  [/.long_to_short /.short_to_long "Can succesfully convert to/from short."]
-                  [/.long_to_int /.int_to_long "Can succesfully convert to/from int."]
-                  [/.long_to_float /.float_to_long "Can succesfully convert to/from float."]
-                  [/.long_to_double /.double_to_long "Can succesfully convert to/from double."]
-                  [(<| /.int_to_char /.long_to_int) (<| /.int_to_long /.char_to_int) "Can succesfully convert to/from char."]
-                  ))
-            ))))
-
-(def: miscellaneous
-  Test
-  (do r.monad
-    [sample (r.ascii 1)]
-    ($_ _.and
-        (_.test "Can check if an object is of a certain class."
-                (and (case (/.check java/lang/String sample) (#.Some _) true #.None false)
-                     (case (/.check java/lang/Long sample) (#.Some _) false #.None true)
-                     (case (/.check java/lang/Object sample) (#.Some _) true #.None false)
-                     (case (/.check java/lang/Object (/.null)) (#.Some _) false #.None true)))
-
-        (_.test "Can run code in a 'synchronized' block."
-                (/.synchronized sample #1))
-
-        (_.test "Can access Class instances."
-                (text\= "java.lang.Class" (java/lang/Class::getName (/.class_for java/lang/Class))))
-
-        (_.test "Can check if a value is null."
-                (and (/.null? (/.null))
-                     (not (/.null? sample))))
-
-        (_.test "Can safely convert nullable references into Maybe values."
-                (and (|> (: (Maybe java/lang/Object) (/.??? (/.null)))
-                         (case> #.None #1
-                                _ #0))
-                     (|> (: (Maybe java/lang/Object) (/.??? sample))
-                         (case> (#.Some _) #1
-                                _ #0))))
-        )))
-
-(def: arrays
-  Test
-  (do {! r.monad}
-    [size (|> r.nat (\ ! map (|>> (n.% 100) (n.max 1))))
-     idx (|> r.nat (\ ! map (n.% size)))
-     value r.int]
-    ($_ _.and
-        (_.test "Can create arrays of some length."
-                (n.= size (/.array_length (/.array java/lang/Long size))))
-
-        (_.test "Can set and get array values."
-                (let [arr (/.array java/lang/Long size)]
-                  (exec (/.array_write idx value arr)
-                    (i.= value (/.array_read idx arr)))))
-        )))
-
-(def: #export test
-  ($_ _.and
-      (<| (_.context "Conversions.")
-          ..conversions)
-      (<| (_.context "Miscellaneous.")
-          ..miscellaneous)
-      (<| (_.context "Arrays.")
-          ..arrays)
-      ))
diff --git a/stdlib/source/test/lux/host.php.lux b/stdlib/source/test/lux/host.php.lux
deleted file mode 100644
index 0b6cac81b..000000000
--- a/stdlib/source/test/lux/host.php.lux
+++ /dev/null
@@ -1,24 +0,0 @@
-(.module:
-  [lux #*
-   ["_" test (#+ Test)]
-   [abstract
-    [monad (#+ do)]]
-   [control
-    ["." try]]
-   [data
-    ["." text ("#\." equivalence)]]
-   [math
-    ["." random (#+ Random)]
-    [number
-     ["." nat]
-     ["." frac]]]]
-  {1
-   ["." /]})
-
-(def: #export test
-  Test
-  (do {! random.monad}
-    []
-    (<| (_.covering /._)
-        (_.test "TBD"
-                true))))
diff --git a/stdlib/source/test/lux/host.py.lux b/stdlib/source/test/lux/host.py.lux
deleted file mode 100644
index 0b6cac81b..000000000
--- a/stdlib/source/test/lux/host.py.lux
+++ /dev/null
@@ -1,24 +0,0 @@
-(.module:
-  [lux #*
-   ["_" test (#+ Test)]
-   [abstract
-    [monad (#+ do)]]
-   [control
-    ["." try]]
-   [data
-    ["." text ("#\." equivalence)]]
-   [math
-    ["." random (#+ Random)]
-    [number
-     ["." nat]
-     ["." frac]]]]
-  {1
-   ["." /]})
-
-(def: #export test
-  Test
-  (do {! random.monad}
-    []
-    (<| (_.covering /._)
-        (_.test "TBD"
-                true))))
diff --git a/stdlib/source/test/lux/host.rb.lux b/stdlib/source/test/lux/host.rb.lux
deleted file mode 100644
index 0b6cac81b..000000000
--- a/stdlib/source/test/lux/host.rb.lux
+++ /dev/null
@@ -1,24 +0,0 @@
-(.module:
-  [lux #*
-   ["_" test (#+ Test)]
-   [abstract
-    [monad (#+ do)]]
-   [control
-    ["." try]]
-   [data
-    ["." text ("#\." equivalence)]]
-   [math
-    ["." random (#+ Random)]
-    [number
-     ["." nat]
-     ["." frac]]]]
-  {1
-   ["." /]})
-
-(def: #export test
-  Test
-  (do {! random.monad}
-    []
-    (<| (_.covering /._)
-        (_.test "TBD"
-                true))))
diff --git a/stdlib/source/test/lux/host.scm.lux b/stdlib/source/test/lux/host.scm.lux
deleted file mode 100644
index 0b6cac81b..000000000
--- a/stdlib/source/test/lux/host.scm.lux
+++ /dev/null
@@ -1,24 +0,0 @@
-(.module:
-  [lux #*
-   ["_" test (#+ Test)]
-   [abstract
-    [monad (#+ do)]]
-   [control
-    ["." try]]
-   [data
-    ["." text ("#\." equivalence)]]
-   [math
-    ["." random (#+ Random)]
-    [number
-     ["." nat]
-     ["." frac]]]]
-  {1
-   ["." /]})
-
-(def: #export test
-  Test
-  (do {! random.monad}
-    []
-    (<| (_.covering /._)
-        (_.test "TBD"
-                true))))
diff --git a/stdlib/source/test/lux/math/number/frac.lux b/stdlib/source/test/lux/math/number/frac.lux
index 5f37be2ef..ddeab3763 100644
--- a/stdlib/source/test/lux/math/number/frac.lux
+++ b/stdlib/source/test/lux/math/number/frac.lux
@@ -2,7 +2,7 @@
   [lux #*
    ["_" test (#+ Test)]
    ["@" target]
-   ["." host]
+   ["." ffi]
    [abstract
     [monad (#+ do)]
     {[0 #spec]
@@ -118,7 +118,7 @@
                 ))
           )))
 
-(with_expansions [ (as_is (host.import: java/lang/Double
+(with_expansions [ (as_is (ffi.import: java/lang/Double
                                  ["#::."
                                   (#static doubleToRawLongBits [double] long)
                                   (#static longBitsToDouble [long] double)]))]
diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux
index f2c8963d3..6e22d611f 100644
--- a/stdlib/source/test/lux/target/jvm.lux
+++ b/stdlib/source/test/lux/target/jvm.lux
@@ -1,6 +1,6 @@
 (.module:
   [lux (#- Type type primitive int)
-   ["." host (#+ import:)]
+   ["." ffi (#+ import:)]
    ["@" target]
    [abstract
     ["." monad (#+ do)]]
@@ -96,7 +96,7 @@
 (def: (get_method name class)
   (-> Text (java/lang/Class java/lang/Object) java/lang/reflect/Method)
   (java/lang/Class::getDeclaredMethod name
-                                      (host.array (java/lang/Class java/lang/Object) 0)
+                                      (ffi.array (java/lang/Class java/lang/Object) 0)
                                       class))
 
 (def: $Object (/type.class "java.lang.Object" (list)))
@@ -124,8 +124,8 @@
                          loader (/loader.memory (/loader.new_library []))]
                    _ (/loader.define class_name bytecode loader)
                    class (io.run (/loader.load class_name loader))
-                   method (host.try (get_method method_name class))]
-                  (java/lang/reflect/Method::invoke (host.null) (host.array java/lang/Object 0) method))
+                   method (ffi.try (get_method method_name class))]
+                  (java/lang/reflect/Method::invoke (ffi.null) (ffi.array java/lang/Object 0) method))
             (#try.Success actual)
             (test actual)
             
@@ -165,10 +165,10 @@
   (/.invokestatic ..$Byte "valueOf" (/type.method [(list /type.byte) ..$Byte (list)])))
 (def: $Byte::random
   (Random java/lang/Byte)
-  (\ random.monad map (|>> (:coerce java/lang/Long) host.long_to_byte) random.int))
+  (\ random.monad map (|>> (:coerce java/lang/Long) ffi.long_to_byte) random.int))
 (def: $Byte::literal
   (-> java/lang/Byte (Bytecode Any))
-  (|>> host.byte_to_long (:coerce I64) i32.i32 /.int))
+  (|>> ffi.byte_to_long (:coerce I64) i32.i32 /.int))
 (def: $Byte::primitive
   (Primitive java/lang/Byte)
   {#unboxed /type.byte
@@ -183,10 +183,10 @@
   (/.invokestatic ..$Short "valueOf" (/type.method [(list /type.short) ..$Short (list)])))
 (def: $Short::random
   (Random java/lang/Short)
-  (\ random.monad map (|>> (:coerce java/lang/Long) host.long_to_short) random.int))
+  (\ random.monad map (|>> (:coerce java/lang/Long) ffi.long_to_short) random.int))
 (def: $Short::literal
   (-> java/lang/Short (Bytecode Any))
-  (|>> host.short_to_long (:coerce I64) i32.i32 /.int))
+  (|>> ffi.short_to_long (:coerce I64) i32.i32 /.int))
 (def: $Short::primitive
   (Primitive java/lang/Short)
   {#unboxed /type.short
@@ -201,10 +201,10 @@
   (/.invokestatic ..$Integer "valueOf" (/type.method [(list /type.int) ..$Integer (list)])))
 (def: $Integer::random
   (Random java/lang/Integer)
-  (\ random.monad map (|>> (:coerce java/lang/Long) host.long_to_int) random.int))
+  (\ random.monad map (|>> (:coerce java/lang/Long) ffi.long_to_int) random.int))
 (def: $Integer::literal
   (-> java/lang/Integer (Bytecode Any))
-  (|>> host.int_to_long (:coerce I64) i32.i32 /.int))
+  (|>> ffi.int_to_long (:coerce I64) i32.i32 /.int))
 (def: $Integer::primitive
   (Primitive java/lang/Integer)
   {#unboxed /type.int
@@ -230,12 +230,12 @@
 (def: $Float::random
   (Random java/lang/Float)
   (\ random.monad map
-     (|>> (:coerce java/lang/Double) host.double_to_float)
+     (|>> (:coerce java/lang/Double) ffi.double_to_float)
      random.frac))
 (def: $Float::literal /.float)
 (def: valid_float
   (Random java/lang/Float)
-  (random.filter (|>> host.float_to_double (:coerce Frac) f.not_a_number? not)
+  (random.filter (|>> ffi.float_to_double (:coerce Frac) f.not_a_number? not)
                  ..$Float::random))
 (def: $Float::primitive
   (Primitive java/lang/Float)
@@ -269,10 +269,10 @@
   (/.invokestatic ..$Character "valueOf" (/type.method [(list /type.char) ..$Character (list)])))
 (def: $Character::random
   (Random java/lang/Character)
-  (\ random.monad map (|>> (:coerce java/lang/Long) host.long_to_int host.int_to_char) random.int))
+  (\ random.monad map (|>> (:coerce java/lang/Long) ffi.long_to_int ffi.int_to_char) random.int))
 (def: $Character::literal
   (-> java/lang/Character (Bytecode Any))
-  (|>> host.char_to_long (:coerce I64) i32.i32 /.int))
+  (|>> ffi.char_to_long (:coerce I64) i32.i32 /.int))
 (def: $Character::primitive
   (Primitive java/lang/Character)
   {#unboxed /type.char
@@ -314,8 +314,8 @@
              [_ ( (|> expected .int  try.assume))]
              ))))]
 
-  [byte 7 java/lang/Byte /.bipush ..$Byte::wrap "BIPUSH" host.byte_to_long /signed.s1]
-  [short 15 java/lang/Short /.sipush ..$Short::wrap "SIPUSH" host.short_to_long /signed.s2]
+  [byte 7 java/lang/Byte /.bipush ..$Byte::wrap "BIPUSH" ffi.byte_to_long /signed.s1]
+  [short 15 java/lang/Short /.sipush ..$Short::wrap "SIPUSH" ffi.short_to_long /signed.s2]
   )
 
 (template [ ]
@@ -382,7 +382,7 @@
         shift (: (-> (-> java/lang/Integer java/lang/Integer java/lang/Integer) (Bytecode Any) (Random Bit))
                  (function (_ reference instruction)
                    (do {! random.monad}
-                     [parameter (\ ! map (|>> (n.% 32) .int (:coerce java/lang/Long) host.long_to_int) random.nat)
+                     [parameter (\ ! map (|>> (n.% 32) .int (:coerce java/lang/Long) ffi.long_to_int) random.nat)
                       subject ..$Integer::random]
                      (int (reference parameter subject)
                           (do /.monad
@@ -390,13 +390,13 @@
                              _ (..$Integer::literal parameter)]
                             instruction)))))
         literal ($_ _.and
-                    (_.lift "ICONST_M1" (int (host.long_to_int (:coerce java/lang/Long -1)) /.iconst_m1))
-                    (_.lift "ICONST_0" (int (host.long_to_int (:coerce java/lang/Long +0)) /.iconst_0))
-                    (_.lift "ICONST_1" (int (host.long_to_int (:coerce java/lang/Long +1)) /.iconst_1))
-                    (_.lift "ICONST_2" (int (host.long_to_int (:coerce java/lang/Long +2)) /.iconst_2))
-                    (_.lift "ICONST_3" (int (host.long_to_int (:coerce java/lang/Long +3)) /.iconst_3))
-                    (_.lift "ICONST_4" (int (host.long_to_int (:coerce java/lang/Long +4)) /.iconst_4))
-                    (_.lift "ICONST_5" (int (host.long_to_int (:coerce java/lang/Long +5)) /.iconst_5))
+                    (_.lift "ICONST_M1" (int (ffi.long_to_int (:coerce java/lang/Long -1)) /.iconst_m1))
+                    (_.lift "ICONST_0" (int (ffi.long_to_int (:coerce java/lang/Long +0)) /.iconst_0))
+                    (_.lift "ICONST_1" (int (ffi.long_to_int (:coerce java/lang/Long +1)) /.iconst_1))
+                    (_.lift "ICONST_2" (int (ffi.long_to_int (:coerce java/lang/Long +2)) /.iconst_2))
+                    (_.lift "ICONST_3" (int (ffi.long_to_int (:coerce java/lang/Long +3)) /.iconst_3))
+                    (_.lift "ICONST_4" (int (ffi.long_to_int (:coerce java/lang/Long +4)) /.iconst_4))
+                    (_.lift "ICONST_5" (int (ffi.long_to_int (:coerce java/lang/Long +5)) /.iconst_5))
                     (_.lift "LDC_W/INTEGER"
                             (do random.monad
                               [expected ..$Integer::random]
@@ -410,7 +410,7 @@
                        (_.lift "INEG" (unary (function (_ value)
                                                ((int/2 "jvm isub" "jvm int -")
                                                 value
-                                                (host.long_to_int (:coerce java/lang/Long +0))))
+                                                (ffi.long_to_int (:coerce java/lang/Long +0))))
                                              /.ineg)))
         bitwise ($_ _.and
                     (_.lift "IAND" (binary (int/2 "jvm iand" "jvm int and") /.iand))
@@ -463,10 +463,10 @@
                    (do {! random.monad}
                      [parameter (\ ! map (|>> (n.% 64) (:coerce java/lang/Long)) random.nat)
                       subject ..$Long::random]
-                     (long (reference (host.long_to_int parameter) subject)
+                     (long (reference (ffi.long_to_int parameter) subject)
                            (do /.monad
                              [_ (..$Long::literal subject)
-                              _ (..$Integer::literal (host.long_to_int parameter))]
+                              _ (..$Integer::literal (ffi.long_to_int parameter))]
                              instruction)))))
         literal ($_ _.and
                     (_.lift "LCONST_0" (long (:coerce java/lang/Long +0) /.lconst_0))
@@ -534,14 +534,14 @@
                    (<| (..bytecode (for {@.old
                                          (function (_ actual)
                                            (or (|> actual (:coerce java/lang/Float) ("jvm feq" expected))
-                                               (and (f.not_a_number? (:coerce Frac (host.float_to_double expected)))
-                                                    (f.not_a_number? (:coerce Frac (host.float_to_double (:coerce java/lang/Float actual)))))))
+                                               (and (f.not_a_number? (:coerce Frac (ffi.float_to_double expected)))
+                                                    (f.not_a_number? (:coerce Frac (ffi.float_to_double (:coerce java/lang/Float actual)))))))
                                          
                                          @.jvm
                                          (function (_ actual)
                                            (or (|> actual (:coerce java/lang/Float) "jvm object cast" ("jvm float =" ("jvm object cast" expected)))
-                                               (and (f.not_a_number? (:coerce Frac (host.float_to_double expected)))
-                                                    (f.not_a_number? (:coerce Frac (host.float_to_double (:coerce java/lang/Float actual)))))))}))
+                                               (and (f.not_a_number? (:coerce Frac (ffi.float_to_double expected)))
+                                                    (f.not_a_number? (:coerce Frac (ffi.float_to_double (:coerce java/lang/Float actual)))))))}))
                        (do /.monad
                          [_ bytecode]
                          ..$Float::wrap))))
@@ -568,9 +568,9 @@
                                 _ (..$Float::literal parameter)]
                                instruction)))))
         literal ($_ _.and
-                    (_.lift "FCONST_0" (float (host.double_to_float (:coerce java/lang/Double +0.0)) /.fconst_0))
-                    (_.lift "FCONST_1" (float (host.double_to_float (:coerce java/lang/Double +1.0)) /.fconst_1))
-                    (_.lift "FCONST_2" (float (host.double_to_float (:coerce java/lang/Double +2.0)) /.fconst_2))
+                    (_.lift "FCONST_0" (float (ffi.double_to_float (:coerce java/lang/Double +0.0)) /.fconst_0))
+                    (_.lift "FCONST_1" (float (ffi.double_to_float (:coerce java/lang/Double +1.0)) /.fconst_1))
+                    (_.lift "FCONST_2" (float (ffi.double_to_float (:coerce java/lang/Double +2.0)) /.fconst_2))
                     (_.lift "LDC_W/FLOAT"
                             (do random.monad
                               [expected ..$Float::random]
@@ -584,12 +584,12 @@
                        (_.lift "FNEG" (unary (function (_ value)
                                                ((float/2 "jvm fsub" "jvm float -")
                                                 value
-                                                (host.double_to_float (:coerce java/lang/Double +0.0))))
+                                                (ffi.double_to_float (:coerce java/lang/Double +0.0))))
                                              /.fneg)))
         comparison (: (-> (Bytecode Any) (-> java/lang/Float java/lang/Float Bit) (Random Bit))
                       (function (_ instruction standard)
                         (do random.monad
-                          [#let [valid_float (random.filter (|>> host.float_to_double (:coerce Frac) f.not_a_number? not)
+                          [#let [valid_float (random.filter (|>> ffi.float_to_double (:coerce Frac) f.not_a_number? not)
                                                             ..$Float::random)]
                            reference valid_float
                            subject valid_float
@@ -892,8 +892,8 @@
             (case (do try.monad
                     [_ (/loader.define class_name bytecode loader)
                      class (io.run (/loader.load class_name loader))
-                     method (host.try (get_method static_method class))
-                     output (java/lang/reflect/Method::invoke (host.null) (host.array java/lang/Object 0) method)]
+                     method (ffi.try (get_method static_method class))
+                     output (java/lang/reflect/Method::invoke (ffi.null) (ffi.array java/lang/Object 0) method)]
                     (wrap (:coerce Int output)))
               (#try.Success actual)
               (i.= (:coerce Int expected) (:coerce Int actual))
@@ -927,7 +927,7 @@
                                 (-> a Any Bit)
                                 (Random Bit)))
                           (function (_ size constructor value literal [*store *load *wrap] test)
-                            (let [!index ($Integer::literal (host.long_to_int (:coerce java/lang/Long +0)))]
+                            (let [!index ($Integer::literal (ffi.long_to_int (:coerce java/lang/Long +0)))]
                               (<| (..bytecode (test value))
                                   (do /.monad
                                     [_ (!length size)
@@ -957,18 +957,18 @@
                    (array (/.newarray /instruction.t_byte) $Byte::random $Byte::literal [/.bastore /.baload $Byte::wrap]
                           (function (_ expected)
                             (for {@.old
-                                  (|>> (:coerce java/lang/Byte) host.byte_to_long ("jvm leq" (host.byte_to_long expected)))
+                                  (|>> (:coerce java/lang/Byte) ffi.byte_to_long ("jvm leq" (ffi.byte_to_long expected)))
                                   
                                   @.jvm
-                                  (|>> (:coerce java/lang/Byte) host.byte_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (host.byte_to_long (:coerce java/lang/Byte expected)))))}))))
+                                  (|>> (:coerce java/lang/Byte) ffi.byte_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (ffi.byte_to_long (:coerce java/lang/Byte expected)))))}))))
         (_.context "short"
                    (array (/.newarray /instruction.t_short) $Short::random $Short::literal [/.sastore /.saload $Short::wrap]
                           (function (_ expected)
                             (for {@.old
-                                  (|>> (:coerce java/lang/Short) host.short_to_long ("jvm leq" (host.short_to_long expected)))
+                                  (|>> (:coerce java/lang/Short) ffi.short_to_long ("jvm leq" (ffi.short_to_long expected)))
                                   
                                   @.jvm
-                                  (|>> (:coerce java/lang/Short) host.short_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (host.short_to_long (:coerce java/lang/Short expected)))))}))))
+                                  (|>> (:coerce java/lang/Short) ffi.short_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (ffi.short_to_long (:coerce java/lang/Short expected)))))}))))
         (_.context "int"
                    (array (/.newarray /instruction.t_int) $Integer::random $Integer::literal [/.iastore /.iaload $Integer::wrap]
                           (function (_ expected)
@@ -1028,7 +1028,7 @@
               (<| (_.lift "MULTIANEWARRAY")
                   (..bytecode (|>> (:coerce Nat) (n.= sizesH)))
                   (do {! /.monad}
-                    [_ (monad.map ! (|>> (:coerce java/lang/Long) host.long_to_int ..$Integer::literal)
+                    [_ (monad.map ! (|>> (:coerce java/lang/Long) ffi.long_to_int ..$Integer::literal)
                                   (#.Cons sizesH sizesT))
                      _ (/.multianewarray type (|> dimensions /unsigned.u1 try.assume))
                      _ ?length]
@@ -1064,40 +1064,40 @@
     ($_ _.and
         (<| (_.context "int")
             ($_ _.and
-                (_.lift "I2L" (conversion ..$Integer::primitive ..$Long::primitive /.i2l (|>> host.int_to_long) long::=))
-                (_.lift "I2F" (conversion ..$Integer::primitive ..$Float::primitive /.i2f (|>> host.int_to_float) float::=))
-                (_.lift "I2D" (conversion ..$Integer::primitive ..$Double::primitive /.i2d (|>> host.int_to_double) double::=))
-                (_.lift "I2B" (conversion ..$Integer::primitive ..$Byte::primitive /.i2b (|>> host.int_to_byte)
+                (_.lift "I2L" (conversion ..$Integer::primitive ..$Long::primitive /.i2l (|>> ffi.int_to_long) long::=))
+                (_.lift "I2F" (conversion ..$Integer::primitive ..$Float::primitive /.i2f (|>> ffi.int_to_float) float::=))
+                (_.lift "I2D" (conversion ..$Integer::primitive ..$Double::primitive /.i2d (|>> ffi.int_to_double) double::=))
+                (_.lift "I2B" (conversion ..$Integer::primitive ..$Byte::primitive /.i2b (|>> ffi.int_to_byte)
                                           (function (_ expected)
                                             (for {@.old
-                                                  (|>> (:coerce java/lang/Byte) host.byte_to_long ("jvm leq" (host.byte_to_long expected)))
+                                                  (|>> (:coerce java/lang/Byte) ffi.byte_to_long ("jvm leq" (ffi.byte_to_long expected)))
                                                   
                                                   @.jvm
-                                                  (|>> (:coerce java/lang/Byte) host.byte_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (host.byte_to_long (:coerce java/lang/Byte expected)))))}))))
-                (_.lift "I2C" (conversion ..$Integer::primitive ..$Character::primitive /.i2c (|>> host.int_to_char)
+                                                  (|>> (:coerce java/lang/Byte) ffi.byte_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (ffi.byte_to_long (:coerce java/lang/Byte expected)))))}))))
+                (_.lift "I2C" (conversion ..$Integer::primitive ..$Character::primitive /.i2c (|>> ffi.int_to_char)
                                           (!::= java/lang/Character "jvm ceq" "jvm char =")))
-                (_.lift "I2S" (conversion ..$Integer::primitive ..$Short::primitive /.i2s (|>> host.int_to_short)
+                (_.lift "I2S" (conversion ..$Integer::primitive ..$Short::primitive /.i2s (|>> ffi.int_to_short)
                                           (function (_ expected)
                                             (for {@.old
-                                                  (|>> (:coerce java/lang/Short) host.short_to_long ("jvm leq" (host.short_to_long expected)))
+                                                  (|>> (:coerce java/lang/Short) ffi.short_to_long ("jvm leq" (ffi.short_to_long expected)))
                                                   
                                                   @.jvm
-                                                  (|>> (:coerce java/lang/Short) host.short_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (host.short_to_long (:coerce java/lang/Short expected)))))}))))))
+                                                  (|>> (:coerce java/lang/Short) ffi.short_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (ffi.short_to_long (:coerce java/lang/Short expected)))))}))))))
         (<| (_.context "long")
             ($_ _.and
-                (_.lift "L2I" (conversion ..$Long::primitive ..$Integer::primitive /.l2i (|>> host.long_to_int) int::=))
-                (_.lift "L2F" (conversion ..$Long::primitive ..$Float::primitive /.l2f (|>> host.long_to_float) float::=))
-                (_.lift "L2D" (conversion ..$Long::primitive ..$Double::primitive /.l2d (|>> host.long_to_double) double::=))))
+                (_.lift "L2I" (conversion ..$Long::primitive ..$Integer::primitive /.l2i (|>> ffi.long_to_int) int::=))
+                (_.lift "L2F" (conversion ..$Long::primitive ..$Float::primitive /.l2f (|>> ffi.long_to_float) float::=))
+                (_.lift "L2D" (conversion ..$Long::primitive ..$Double::primitive /.l2d (|>> ffi.long_to_double) double::=))))
         (<| (_.context "float")
             ($_ _.and
-                (_.lift "F2I" (conversion ..$Float::primitive ..$Integer::primitive /.f2i (|>> host.float_to_int) int::=))
-                (_.lift "F2L" (conversion ..$Float::primitive ..$Long::primitive /.f2l (|>> host.float_to_long) long::=))
-                (_.lift "F2D" (conversion ..$Float::primitive ..$Double::primitive /.f2d (|>> host.float_to_double) double::=))))
+                (_.lift "F2I" (conversion ..$Float::primitive ..$Integer::primitive /.f2i (|>> ffi.float_to_int) int::=))
+                (_.lift "F2L" (conversion ..$Float::primitive ..$Long::primitive /.f2l (|>> ffi.float_to_long) long::=))
+                (_.lift "F2D" (conversion ..$Float::primitive ..$Double::primitive /.f2d (|>> ffi.float_to_double) double::=))))
         (<| (_.context "double")
             ($_ _.and
-                (_.lift "D2I" (conversion ..$Double::primitive ..$Integer::primitive /.d2i (|>> host.double_to_int) int::=))
-                (_.lift "D2L" (conversion ..$Double::primitive ..$Long::primitive /.d2l (|>> host.double_to_long) long::=))
-                (_.lift "D2F" (conversion ..$Double::primitive ..$Float::primitive /.d2f (|>> host.double_to_float) float::=))))
+                (_.lift "D2I" (conversion ..$Double::primitive ..$Integer::primitive /.d2i (|>> ffi.double_to_int) int::=))
+                (_.lift "D2L" (conversion ..$Double::primitive ..$Long::primitive /.d2l (|>> ffi.double_to_long) long::=))
+                (_.lift "D2F" (conversion ..$Double::primitive ..$Float::primitive /.d2f (|>> ffi.double_to_float) float::=))))
         )))
 
 (def: value
@@ -1156,13 +1156,13 @@
                              #let [expected (: java/lang/Long
                                                (for {@.old
                                                      ("jvm ladd"
-                                                      (host.byte_to_long base)
+                                                      (ffi.byte_to_long base)
                                                       (.int (/unsigned.value increment)))
                                                      
                                                      @.jvm
                                                      ("jvm object cast"
                                                       ("jvm long +"
-                                                       ("jvm object cast" (host.byte_to_long base))
+                                                       ("jvm object cast" (ffi.byte_to_long base))
                                                        ("jvm object cast" (:coerce java/lang/Long (/unsigned.value increment)))))}))]]
                             (..bytecode (|>> (:coerce Int) (i.= (:coerce Int expected)))
                                         (do /.monad
@@ -1357,8 +1357,8 @@
                                                      loader (/loader.memory (/loader.new_library []))]
                                                _ (/loader.define class_name bytecode loader)
                                                class (io.run (/loader.load class_name loader))
-                                               method (host.try (get_method object_method_name class))]
-                                              (java/lang/reflect/Method::invoke (host.null) (host.array java/lang/Object 0) method))
+                                               method (ffi.try (get_method object_method_name class))]
+                                              (java/lang/reflect/Method::invoke (ffi.null) (ffi.array java/lang/Object 0) method))
                                         (#try.Success actual)
                                         (test expected actual)
 
@@ -1498,7 +1498,7 @@
                         random.nat)
              choice (\ ! map (n.% options) random.nat)
              options (|> random.int
-                         (\ ! map (|>> (:coerce java/lang/Long) host.long_to_int host.int_to_long (:coerce Int)))
+                         (\ ! map (|>> (:coerce java/lang/Long) ffi.long_to_int ffi.int_to_long (:coerce Int)))
                          (random.set i.hash options)
                          (\ ! map set.to_list))
              #let [choice (maybe.assume (list.nth choice options))]
@@ -1509,7 +1509,7 @@
             [@right /.new_label
              @wrong /.new_label
              @return /.new_label
-             _ (..$Integer::literal (host.long_to_int (:coerce java/lang/Long choice)))
+             _ (..$Integer::literal (ffi.long_to_int (:coerce java/lang/Long choice)))
              _ (/.lookupswitch @wrong (list\map (function (_ option)
                                                   [(|> option /signed.s4 try.assume)
                                                    (if (i.= choice option) @right @wrong)])
@@ -1709,8 +1709,8 @@
                      _ (/loader.define interface_class interface_bytecode loader)
                      _ (/loader.define concrete_class concrete_bytecode loader)
                      class (io.run (/loader.load concrete_class loader))
-                     method (host.try (get_method static_method class))
-                     output (java/lang/reflect/Method::invoke (host.null) (host.array java/lang/Object 0) method)]
+                     method (ffi.try (get_method static_method class))
+                     output (java/lang/reflect/Method::invoke (ffi.null) (ffi.array java/lang/Object 0) method)]
                     (wrap (:coerce Int output)))
               (#try.Success actual)
               (i.= (:coerce Int expected) (:coerce Int actual))
diff --git a/stdlib/source/test/lux/time/instant.lux b/stdlib/source/test/lux/time/instant.lux
index 4f6080b48..316ef8783 100644
--- a/stdlib/source/test/lux/time/instant.lux
+++ b/stdlib/source/test/lux/time/instant.lux
@@ -1,7 +1,7 @@
 (.module:
   [lux #*
    ["_" test (#+ Test)]
-   ["." host]
+   ["." ffi]
    [abstract
     [monad (#+ do)]
     {[0 #spec]
@@ -97,7 +97,7 @@
                             (apply duration.inverse day\pred 6)
                             (apply duration.inverse day\pred 7)))))
           (_.cover [/.now]
-                   (case (host.try /.now)
+                   (case (ffi.try /.now)
                      (#try.Success _)
                      true
                      
-- 
cgit v1.2.3