diff options
Diffstat (limited to 'stdlib/source/library')
290 files changed, 6093 insertions, 6161 deletions
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index aa4d89179..7339ac34d 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -37,8 +37,9 @@ #1) ... (type: .public (List a) -... #End -... {#Item a (List a)}) +... (Variant +... {#End} +... {#Item a (List a)})) ("lux def type tagged" List {9 #1 [..prelude_module "List"] @@ -53,14 +54,14 @@ {9 #0 {4 #0 1} {4 #0 0}}}}}} - {"End" "Item"} + {"#End" "#Item"} #1) ("lux def" Bit ("lux type check type" {9 #1 [..prelude_module "Bit"] - {0 #0 "#Bit" #End}}) + {0 #0 "#Bit" {#End}}}) #1) ("lux def" I64 @@ -69,42 +70,42 @@ [..prelude_module "I64"] {7 #0 {0 #0} - {0 #0 "#I64" {#Item {4 #0 1} #End}}}}) + {0 #0 "#I64" {#Item {4 #0 1} {#End}}}}}) #1) ("lux def" Nat ("lux type check type" {9 #1 [..prelude_module "Nat"] - {0 #0 "#I64" {#Item {0 #0 "#Nat" #End} #End}}}) + {0 #0 "#I64" {#Item {0 #0 "#Nat" {#End}} {#End}}}}) #1) ("lux def" Int ("lux type check type" {9 #1 [..prelude_module "Int"] - {0 #0 "#I64" {#Item {0 #0 "#Int" #End} #End}}}) + {0 #0 "#I64" {#Item {0 #0 "#Int" {#End}} {#End}}}}) #1) ("lux def" Rev ("lux type check type" {9 #1 [..prelude_module "Rev"] - {0 #0 "#I64" {#Item {0 #0 "#Rev" #End} #End}}}) + {0 #0 "#I64" {#Item {0 #0 "#Rev" {#End}} {#End}}}}) #1) ("lux def" Frac ("lux type check type" {9 #1 [..prelude_module "Frac"] - {0 #0 "#Frac" #End}}) + {0 #0 "#Frac" {#End}}}) #1) ("lux def" Text ("lux type check type" {9 #1 [..prelude_module "Text"] - {0 #0 "#Text" #End}}) + {0 #0 "#Text" {#End}}}) #1) ("lux def" Name @@ -115,19 +116,19 @@ #1) ... (type: .public (Maybe a) -... #None +... {#None} ... {#Some a}) ("lux def type tagged" Maybe {9 #1 [..prelude_module "Maybe"] {7 #0 - #End + {#End} {1 #0 ... None Any ... Some {4 #0 1}}}} - {"None" "Some"} + {"#None" "#Some"} #1) ... (type: .public Type @@ -150,9 +151,9 @@ ({Type_List ({Type_Pair {9 #0 - {0 #0 ["" #End]} + {0 #0 ["" {#End}]} {7 #0 - #End + {#End} {1 #0 ... Primitive {2 #0 Text Type_List} @@ -187,8 +188,8 @@ {2 #0 Name Type}}}}}}}}}}}}}} ("lux type check type" {2 #0 Type Type}))} ("lux type check type" {9 #0 Type List}))} - ("lux type check type" {9 #0 {0 #0 ["" #End]} {4 #0 0}}))} - {"Primitive" "Sum" "Product" "Function" "Parameter" "Var" "Ex" "UnivQ" "ExQ" "Apply" "Named"} + ("lux type check type" {9 #0 {0 #0 ["" {#End}]} {4 #0 0}}))} + {"#Primitive" "#Sum" "#Product" "#Function" "#Parameter" "#Var" "#Ex" "#UnivQ" "#ExQ" "#Apply" "#Named"} #1) ... (type: .public Location @@ -199,7 +200,7 @@ ("lux def type tagged" Location {#Named [..prelude_module "Location"] {#Product Text {#Product Nat Nat}}} - ["module" "line" "column"] + ["#module" "#line" "#column"] #1) ... (type: .public (Ann m v) @@ -208,12 +209,12 @@ ... #datum v])) ("lux def type tagged" Ann {#Named [..prelude_module "Ann"] - {#UnivQ #End - {#UnivQ #End + {#UnivQ {#End} + {#UnivQ {#End} {#Product {#Parameter 3} {#Parameter 1}}}}} - ["meta" "datum"] + ["#meta" "#datum"] #1) ... (type: .public (Code' w) @@ -224,7 +225,6 @@ ... {#Frac Frac} ... {#Text Text} ... {#Identifier Name} -... {#Tag Name} ... {#Form (List (w (Code' w)))} ... {#Variant (List (w (Code' w)))} ... {#Tuple (List (w (Code' w)))}) @@ -232,7 +232,7 @@ {#Named [..prelude_module "Code'"] ({Code ({Code_List - {#UnivQ #End + {#UnivQ {#End} {#Sum ... Bit Bit @@ -255,23 +255,20 @@ ... Identifier Name {#Sum - ... Tag - Name + ... Form + Code_List {#Sum - ... Form + ... Variant + Code_List + ... Tuple Code_List - {#Sum - ... Variant - Code_List - ... Tuple - Code_List - }}}}}}}}}} + }}}}}}}}} }} ("lux type check type" {#Apply Code List}))} ("lux type check type" {#Apply {#Apply {#Parameter 1} {#Parameter 0}} {#Parameter 1}}))} - {"Bit" "Nat" "Int" "Rev" "Frac" "Text" "Identifier" "Tag" "Form" "Variant" "Tuple"} + {"#Bit" "#Nat" "#Int" "#Rev" "#Frac" "#Text" "#Identifier" "#Form" "#Variant" "#Tuple"} #1) ... (type: .public Code @@ -348,16 +345,6 @@ ([_ name] (_ann {#Identifier ["" name]}))) #0) -("lux def" tag$ - ("lux type check" {#Function Name Code} - ([_ name] (_ann {#Tag name}))) - #0) - -("lux def" local_tag$ - ("lux type check" {#Function Text Code} - ([_ name] (_ann {#Tag ["" name]}))) - #0) - ("lux def" form$ ("lux type check" {#Function {#Apply Code List} Code} ([_ tokens] (_ann {#Form tokens}))) @@ -413,7 +400,7 @@ {#Sum Label {#Sum Label Alias}}}}} - {"Definition" "Type" "Label" "Slot" "Alias"} + {"#Definition" "#Type" "#Label" "#Slot" "#Alias"} .public) ... (type: .public (Bindings k v) @@ -422,8 +409,8 @@ ... #mappings (List [k v])])) ("lux def type tagged" Bindings {#Named [..prelude_module "Bindings"] - {#UnivQ #End - {#UnivQ #End + {#UnivQ {#End} + {#UnivQ {#End} {#Product ... counter Nat @@ -431,7 +418,7 @@ {#Apply {#Product {#Parameter 3} {#Parameter 1}} List}}}}} - ["counter" "mappings"] + ["#counter" "#mappings"] .public) ... (type: .public Ref @@ -443,7 +430,7 @@ Nat ... Captured Nat}} - {"Local" "Captured"} + {"#Local" "#Captured"} .public) ... (type: .public Scope @@ -462,7 +449,7 @@ {#Apply {#Product Type Nat} {#Apply Text Bindings}} ... captured {#Apply {#Product Type Ref} {#Apply Text Bindings}}}}}} - ["name" "inner" "locals" "captured"] + ["#name" "#inner" "#locals" "#captured"] .public) ("lux def" Code_List @@ -475,14 +462,14 @@ ... {#Right r}) ("lux def type tagged" Either {#Named [..prelude_module "Either"] - {#UnivQ #End - {#UnivQ #End + {#UnivQ {#End} + {#UnivQ {#End} {#Sum ... Left {#Parameter 3} ... Right {#Parameter 1}}}}} - {"Left" "Right"} + {"#Left" "#Right"} .public) ... (type: .public Source @@ -507,7 +494,7 @@ Any ... #Cached Any}}} - {"Active" "Compiled" "Cached"} + {"#Active" "#Compiled" "#Cached"} .public) ... (type: .public Module @@ -534,7 +521,7 @@ ... module_state Module_State }}}}} - ["module_hash" "module_aliases" "definitions" "imports" "module_state"] + ["#module_hash" "#module_aliases" "#definitions" "#imports" "#module_state"] .public) ... (type: .public Type_Context @@ -551,7 +538,7 @@ ... var_bindings {#Apply {#Product Nat {#Apply Type Maybe}} List}}}} - ["ex_counter" "var_counter" "var_bindings"] + ["#ex_counter" "#var_counter" "#var_bindings"] .public) ... (type: .public Mode @@ -566,7 +553,7 @@ Any ... Interpreter Any}}} - {"Build" "Eval" "Interpreter"} + {"#Build" "#Eval" "#Interpreter"} .public) ... (type: .public Info @@ -584,7 +571,7 @@ Text ... mode Mode}}} - ["target" "version" "mode"] + ["#target" "#version" "#mode"] .public) ... (type: .public Lux @@ -605,8 +592,8 @@ ("lux def type tagged" Lux {#Named [..prelude_module "Lux"] ({Lux - {#Apply {0 #0 ["" #End]} - {#UnivQ #End + {#Apply {0 #0 ["" {#End}]} + {#UnivQ {#End} {#Product ... info Info @@ -648,8 +635,8 @@ {#Sum Text {#Product Lux Any}}}}} ... host Any}}}}}}}}}}}}}}} - {#Apply {0 #0 ["" #End]} {#Parameter 0}})} - ["info" "source" "location" "current_module" "modules" "scopes" "type_context" "expected" "seed" "scope_type_vars" "extensions" "eval" "host"] + {#Apply {0 #0 ["" {#End}]} {#Parameter 0}})} + ["#info" "#source" "#location" "#current_module" "#modules" "#scopes" "#type_context" "#expected" "#seed" "#scope_type_vars" "#extensions" "#eval" "#host"] .public) ... (type: .public (Meta a) @@ -657,7 +644,7 @@ ("lux def" Meta ("lux type check type" {#Named [..prelude_module "Meta"] - {#UnivQ #End + {#UnivQ {#End} {#Function Lux {#Apply {#Product Lux {#Parameter 1}} {#Apply Text Either}}}}}) @@ -676,13 +663,13 @@ ("lux def" Macro ("lux type check type" {#Named [..prelude_module "Macro"] - {#Primitive "#Macro" #End}}) + {#Primitive "#Macro" {#End}}}) .public) ... Base functions & macros ("lux def" in_meta ("lux type check" - {#UnivQ #End + {#UnivQ {#End} {#Function {#Parameter 1} {#Function Lux {#Apply {#Product Lux @@ -695,7 +682,7 @@ ("lux def" failure ("lux type check" - {#UnivQ #End + {#UnivQ {#End} {#Function Text {#Function Lux {#Apply {#Product Lux @@ -709,10 +696,10 @@ ("lux def" let'' ("lux macro" ([_ tokens] - ({{#Item lhs {#Item rhs {#Item body #End}}} - (in_meta {#Item (form$ {#Item (variant$ {#Item lhs {#Item body #End}}) - {#Item rhs #End}}) - #End}) + ({{#Item lhs {#Item rhs {#Item body {#End}}}} + (in_meta {#Item (form$ {#Item (variant$ {#Item lhs {#Item body {#End}}}) + {#Item rhs {#End}}}) + {#End}}) _ (failure "Wrong syntax for let''")} @@ -722,71 +709,49 @@ ("lux def" function'' ("lux macro" ([_ tokens] - ({{#Item [_ {#Tuple {#Item arg args'}}] {#Item body #End}} + ({{#Item [_ {#Tuple {#Item arg args'}}] {#Item body {#End}}} (in_meta {#Item (_ann {#Form {#Item (_ann {#Tuple {#Item (_ann {#Identifier ["" ""]}) - {#Item arg #End}}}) - {#Item ({#End + {#Item arg {#End}}}}) + {#Item ({{#End} body _ (_ann {#Form {#Item (_ann {#Identifier [..prelude_module "function''"]}) {#Item (_ann {#Tuple args'}) - {#Item body #End}}}})} + {#Item body {#End}}}}})} args') - #End}}}) - #End}) + {#End}}}}) + {#End}}) - {#Item [_ {#Identifier ["" self]}] {#Item [_ {#Tuple {#Item arg args'}}] {#Item body #End}}} + {#Item [_ {#Identifier ["" self]}] {#Item [_ {#Tuple {#Item arg args'}}] {#Item body {#End}}}} (in_meta {#Item (_ann {#Form {#Item (_ann {#Tuple {#Item (_ann {#Identifier ["" self]}) - {#Item arg #End}}}) - {#Item ({#End + {#Item arg {#End}}}}) + {#Item ({{#End} body _ (_ann {#Form {#Item (_ann {#Identifier [..prelude_module "function''"]}) {#Item (_ann {#Tuple args'}) - {#Item body #End}}}})} + {#Item body {#End}}}}})} args') - #End}}}) - #End}) + {#End}}}}) + {#End}}) _ (failure "Wrong syntax for function''")} tokens))) #0) -("lux def" location_code - ("lux type check" Code - (tuple$ {#Item (text$ "") {#Item (nat$ 0) {#Item (nat$ 0) #End}}})) - #0) - -("lux def" meta_code - ("lux type check" {#Function Name {#Function Code Code}} - ([_ tag] - ([_ value] - (tuple$ {#Item location_code - {#Item (form$ {#Item (tag$ tag) {#Item value #End}}) - #End}})))) - #0) - -("lux def" flag_meta - ("lux type check" {#Function Text Code} - ([_ tag] - (tuple$ {#Item [(meta_code [..prelude_module "Tag"] (tuple$ {#Item (text$ ..prelude_module) {#Item (text$ tag) #End}})) - {#Item [(meta_code [..prelude_module "Bit"] (bit$ #1)) - #End]}]}))) - #0) - ("lux def" as_def ("lux type check" {#Function Code {#Function Code {#Function Code Code}}} (function'' [name value export_policy] - (form$ {#Item (text$ "lux def") {#Item name {#Item value {#Item export_policy #End}}}}))) + (form$ {#Item (text$ "lux def") {#Item name {#Item value {#Item export_policy {#End}}}}}))) #0) ("lux def" as_checked ("lux type check" {#Function Code {#Function Code Code}} (function'' [type value] - (form$ {#Item (text$ "lux type check") {#Item type {#Item value #End}}}))) + (form$ {#Item (text$ "lux type check") {#Item type {#Item value {#End}}}}))) #0) ("lux def" as_function @@ -795,7 +760,7 @@ (form$ {#Item (identifier$ [..prelude_module "function''"]) {#Item self {#Item (tuple$ inputs) - {#Item output #End}}}}))) + {#Item output {#End}}}}}))) #0) ("lux def" as_macro @@ -803,7 +768,7 @@ (function'' [expression] (form$ {#Item (text$ "lux macro") {#Item expression - #End}}))) + {#End}}}))) #0) ("lux def" def:'' @@ -811,16 +776,16 @@ (function'' [tokens] ({{#Item [export_policy {#Item [[_ {#Form {#Item [name args]}}] - {#Item [type {#Item [body #End]}]}]}]} + {#Item [type {#Item [body {#End}]}]}]}]} (in_meta {#Item [(as_def name (as_checked type (as_function name args body)) export_policy) - #End]}) + {#End}]}) - {#Item [export_policy {#Item [name {#Item [type {#Item [body #End]}]}]}]} + {#Item [export_policy {#Item [name {#Item [type {#Item [body {#End}]}]}]}]} (in_meta {#Item [(as_def name (as_checked type body) export_policy) - #End]}) + {#End}]}) _ (failure "Wrong syntax for def''")} @@ -830,10 +795,10 @@ ("lux def" macro:' ("lux macro" (function'' [tokens] - ({{#Item export_policy {#Item [_ {#Form {#Item name args}}] {#Item body #End}}} + ({{#Item export_policy {#Item [_ {#Form {#Item name args}}] {#Item body {#End}}}} (in_meta {#Item (as_def name (as_macro (as_function name args body)) export_policy) - #End}) + {#End}}) _ (failure "Wrong syntax for macro:'")} @@ -841,31 +806,31 @@ #0) (macro:' .public (comment tokens) - (in_meta #End)) + (in_meta {#End})) (macro:' .private ($' tokens) - ({{#Item x #End} + ({{#Item x {#End}} (in_meta tokens) {#Item x {#Item y xs}} (in_meta {#Item (form$ {#Item (identifier$ [..prelude_module "$'"]) - {#Item (variant$ {#Item (tag$ [..prelude_module "Apply"]) - {#Item y {#Item x #End}}}) + {#Item (variant$ {#Item (identifier$ [..prelude_module "#Apply"]) + {#Item y {#Item x {#End}}}}) xs}}) - #End}) + {#End}}) _ (failure "Wrong syntax for $'")} tokens)) (def:'' .private (list\each f xs) - {#UnivQ #End - {#UnivQ #End + {#UnivQ {#End} + {#UnivQ {#End} {#Function {#Function {#Parameter 3} {#Parameter 1}} {#Function ($' List {#Parameter 3}) ($' List {#Parameter 1})}}}} - ({#End - #End + ({{#End} + {#End} {#Item x xs'} {#Item (f x) (list\each f xs')}} @@ -881,7 +846,7 @@ {#Item [x y] (replacement_environment xs' ys')} _ - #End} + {#End}} [xs ys])) (def:'' .private (text\= reference sample) @@ -890,8 +855,8 @@ (def:'' .private (replacement for environment) {#Function Text {#Function Replacement_Environment ($' Maybe Code)}} - ({#End - #None + ({{#End} + {#None} {#Item [k v] environment'} ({#1 @@ -908,7 +873,7 @@ ({{#Some replacement} replacement - #None + {#None} syntax} (..replacement name reps)) @@ -934,13 +899,13 @@ (def:'' .private (list\mix f init xs) ... (All (_ a b) (-> (-> b a a) a (List b) a)) - {#UnivQ #End {#UnivQ #End {#Function {#Function {#Parameter 1} - {#Function {#Parameter 3} - {#Parameter 3}}} - {#Function {#Parameter 3} - {#Function ($' List {#Parameter 1}) - {#Parameter 3}}}}}} - ({#End + {#UnivQ {#End} {#UnivQ {#End} {#Function {#Function {#Parameter 1} + {#Function {#Parameter 3} + {#Parameter 3}}} + {#Function {#Parameter 3} + {#Function ($' List {#Parameter 1}) + {#Parameter 3}}}}}} + ({{#End} init {#Item x xs'} @@ -948,22 +913,33 @@ xs)) (def:'' .private (list\size list) - {#UnivQ #End + {#UnivQ {#End} {#Function ($' List {#Parameter 1}) Nat}} (list\mix (function'' [_ acc] ("lux i64 +" 1 acc)) 0 list)) (def:'' .private (let$ binding value body) {#Function Code {#Function Code {#Function Code Code}}} - (form$ {#Item (variant$ {#Item binding {#Item body #End}}) - {#Item value #End}})) + (form$ {#Item (variant$ {#Item binding {#Item body {#End}}}) + {#Item value {#End}}})) + +(def:'' .private |#End| + Code + (variant$ {#Item (identifier$ [..prelude_module "#End"]) {#End}})) + +(def:'' .private (|#Item| head tail) + {#Function Code {#Function Code Code}} + (variant$ {#Item (identifier$ [..prelude_module "#Item"]) + {#Item head + {#Item tail + {#End}}}})) (def:'' .private (UnivQ$ body) {#Function Code Code} - (variant$ {#Item (tag$ [..prelude_module "UnivQ"]) {#Item (tag$ [..prelude_module "End"]) {#Item body #End}}})) + (variant$ {#Item (identifier$ [..prelude_module "#UnivQ"]) {#Item ..|#End| {#Item body {#End}}}})) (def:'' .private (ExQ$ body) {#Function Code Code} - (variant$ {#Item (tag$ [..prelude_module "ExQ"]) {#Item (tag$ [..prelude_module "End"]) {#Item body #End}}})) + (variant$ {#Item (identifier$ [..prelude_module "#ExQ"]) {#Item ..|#End| {#Item body {#End}}}})) (def:'' .private quantification_level Text @@ -977,12 +953,12 @@ (def:'' .private (quantified_type_parameter idx) {#Function Nat Code} - (variant$ {#Item (tag$ [..prelude_module "Parameter"]) + (variant$ {#Item (identifier$ [..prelude_module "#Parameter"]) {#Item (form$ {#Item (text$ "lux i64 +") {#Item (local_identifier$ ..quantification_level) {#Item (nat$ idx) - #End}}}) - #End}})) + {#End}}}}) + {#End}}})) (def:'' .private (next_level depth) {#Function Nat Nat} @@ -1052,7 +1028,7 @@ {#Item (local_identifier$ ..quantification_level) {#Item (nat$ 0) {#Item body - #End}}}})) + {#End}}}}})) (def:'' .private (with_quantification depth body) {#Function Nat {#Function Code Code}} @@ -1064,7 +1040,7 @@ ("lux i64 *" +2 ("lux type as" Int depth)))) - #End}}}) + {#End}}}}) body)} (local_identifier$ ..quantification_level))) @@ -1081,8 +1057,7 @@ #mappings locals]] (list\mix (function'' [local verdict] ({[local _] - ({#1 #1 - _ ("lux text =" ..quantification_level local)} + ({#1 #1 _ ("lux text =" ..quantification_level local)} verdict)} local)) #0 @@ -1095,13 +1070,13 @@ (macro:' .public (All tokens lux) ({{#Item [_ {#Form {#Item self_name args}}] - {#Item body #End}} + {#Item body {#End}}} {#Right [lux {#Item ({raw ({#1 raw #0 (..quantified raw)} (initialized_quantification? lux))} - ({#End + ({{#End} body {#Item head tail} @@ -1119,7 +1094,7 @@ body)] args))))} args)) - #End}]} + {#End}}]} _ {#Left "Wrong syntax for All"}} @@ -1127,13 +1102,13 @@ (macro:' .public (Ex tokens lux) ({{#Item [_ {#Form {#Item self_name args}}] - {#Item body #End}} + {#Item body {#End}}} {#Right [lux {#Item ({raw ({#1 raw #0 (..quantified raw)} (initialized_quantification? lux))} - ({#End + ({{#End} body {#Item head tail} @@ -1151,7 +1126,7 @@ body)] args))))} args)) - #End}]} + {#End}}]} _ {#Left "Wrong syntax for Ex"}} @@ -1163,58 +1138,49 @@ (list\mix ("lux type check" (All (_ a) {#Function a {#Function ($' List a) ($' List a)}}) (function'' [head tail] {#Item head tail})) - #End + {#End} list)) (macro:' .public (-> tokens) ({{#Item output inputs} (in_meta {#Item (list\mix ("lux type check" {#Function Code {#Function Code Code}} - (function'' [i o] (variant$ {#Item (tag$ [..prelude_module "Function"]) {#Item i {#Item o #End}}}))) + (function'' [i o] (variant$ {#Item (identifier$ [..prelude_module "#Function"]) {#Item i {#Item o {#End}}}}))) output inputs) - #End}) + {#End}}) _ (failure "Wrong syntax for ->")} (list\reversed tokens))) (macro:' .public (list xs) - (in_meta {#Item (list\mix (function'' [head tail] - (variant$ {#Item (tag$ [..prelude_module "Item"]) - {#Item (tuple$ {#Item [head {#Item [tail #End]}]}) - #End}})) - (tag$ [..prelude_module "End"]) - (list\reversed xs)) - #End})) + (in_meta {#Item (list\mix |#Item| |#End| (list\reversed xs)) + {#End}})) (macro:' .public (list& xs) ({{#Item last init} - (in_meta (list (list\mix (function'' [head tail] - (variant$ (list (tag$ [..prelude_module "Item"]) - (tuple$ (list head tail))))) - last - init))) + (in_meta (list (list\mix |#Item| last init))) _ (failure "Wrong syntax for list&")} (list\reversed xs))) (macro:' .public (Union tokens) - ({#End + ({{#End} (in_meta (list (identifier$ [..prelude_module "Nothing"]))) {#Item last prevs} - (in_meta (list (list\mix (function'' [left right] (variant$ (list (tag$ [..prelude_module "Sum"]) left right))) + (in_meta (list (list\mix (function'' [left right] (variant$ (list (identifier$ [..prelude_module "#Sum"]) left right))) last prevs)))} (list\reversed tokens))) (macro:' .public (Tuple tokens) - ({#End + ({{#End} (in_meta (list (identifier$ [..prelude_module "Any"]))) {#Item last prevs} - (in_meta (list (list\mix (function'' [left right] (variant$ (list (tag$ [..prelude_module "Product"]) left right))) + (in_meta (list (list\mix (function'' [left right] (variant$ (list (identifier$ [..prelude_module "#Product"]) left right))) last prevs)))} (list\reversed tokens))) @@ -1226,8 +1192,8 @@ _ ["" tokens]} tokens) - ({{#Item [[_ {#Tuple args}] {#Item [body #End]}]} - ({#End + ({{#Item [[_ {#Tuple args}] {#Item [body {#End}]}]} + ({{#End} (failure "function' requires a non-empty arguments tuple.") {#Item [harg targs]} @@ -1248,7 +1214,7 @@ (macro:' .private (def:''' tokens) ({{#Item [export_policy {#Item [[_ {#Form {#Item [name args]}}] - {#Item [type {#Item [body #End]}]}]}]} + {#Item [type {#Item [body {#End}]}]}]}]} (in_meta (list (form$ (list (text$ "lux def") name (form$ (list (text$ "lux type check") @@ -1259,7 +1225,7 @@ body)))) export_policy)))) - {#Item [export_policy {#Item [name {#Item [type {#Item [body #End]}]}]}]} + {#Item [export_policy {#Item [name {#Item [type {#Item [body {#End}]}]}]}]} (in_meta (list (form$ (list (text$ "lux def") name (form$ (list (text$ "lux type check") @@ -1285,11 +1251,11 @@ {#Item [x y] (pairs xs')} _ - #End} + {#End}} xs)) (macro:' .private (let' tokens) - ({{#Item [[_ {#Tuple bindings}] {#Item [body #End]}]} + ({{#Item [[_ {#Tuple bindings}] {#Item [body {#End}]}]} (in_meta (list (list\mix ("lux type check" (-> (Tuple Code Code) Code Code) (function' [binding body] @@ -1306,7 +1272,7 @@ (def:''' .private (any? p xs) (All (_ a) (-> (-> a Bit) ($' List a) Bit)) - ({#End + ({{#End} #0 {#Item x xs'} @@ -1322,13 +1288,11 @@ (def:''' .private (untemplated_list tokens) (-> ($' List Code) Code) - ({#End - (_ann {#Tag [..prelude_module "End"]}) + ({{#End} + |#End| - {#Item [token tokens']} - (_ann {#Variant (list (_ann {#Tag [..prelude_module "Item"]}) - token - (untemplated_list tokens'))})} + {#Item token tokens'} + (|#Item| token (untemplated_list tokens'))} tokens)) (def:''' .private (list\composite xs ys) @@ -1336,7 +1300,7 @@ ({{#Item x xs'} {#Item x (list\composite xs' ys)} - #End + {#End} ys} xs)) @@ -1384,9 +1348,9 @@ ... (type: (Monad m) ... (Interface ... (: (All (_ a) (-> a (m a))) -... in) +... #in) ... (: (All (_ a b) (-> (-> a (m b)) (m a) (m b))) -... then))) +... #then))) ("lux def type tagged" Monad {#Named [..prelude_module "Monad"] (All (_ !) @@ -1396,7 +1360,7 @@ (-> (-> a ($' ! b)) ($' ! a) ($' ! b)))))} - ["in" "then"] + ["#in" "#then"] #0) (def:''' .private maybe_monad @@ -1406,8 +1370,8 @@ #then (function' [f ma] - ({#None #None - {#Some a} (f a)} + ({{#None} {#None} + {#Some a} (f a)} ma))]) (def:''' .private meta_monad @@ -1428,7 +1392,7 @@ (ma state))))]) (macro:' .private (do tokens) - ({{#Item monad {#Item [_ {#Tuple bindings}] {#Item body #End}}} + ({{#Item monad {#Item [_ {#Tuple bindings}] {#Item body {#End}}}} (let' [g!in (local_identifier$ "in") g!then (local_identifier$ " then ") body' (list\mix ("lux type check" (-> (Tuple Code Code) Code Code) @@ -1452,8 +1416,8 @@ var)))) body (list\reversed (pairs bindings)))] - (in_meta (list (form$ (list (variant$ (list (tuple$ (list (tag$ [..prelude_module "in"]) g!in - (tag$ [..prelude_module "then"]) g!then)) + (in_meta (list (form$ (list (variant$ (list (tuple$ (list (identifier$ [..prelude_module "#in"]) g!in + (identifier$ [..prelude_module "#then"]) g!then)) body')) monad))))) @@ -1468,8 +1432,8 @@ ($' List a) ($' m ($' List b)))) (let' [[#in in #then _] m] - ({#End - (in #End) + ({{#End} + (in {#End}) {#Item x xs'} (do m @@ -1486,7 +1450,7 @@ ($' List a) ($' m b))) (let' [[#in in #then _] m] - ({#End + ({{#End} (in y) {#Item x xs'} @@ -1496,7 +1460,7 @@ xs))) (macro:' .public (if tokens) - ({{#Item test {#Item then {#Item else #End}}} + ({{#Item test {#Item then {#Item else {#End}}}} (in_meta (list (form$ (list (variant$ (list (bit$ #1) then (bit$ #0) else)) test)))) @@ -1517,8 +1481,8 @@ {#Some v} (plist\value k plist')) - #End - #None} + {#End} + {#None}} plist)) (def:''' .private (text\composite x y) @@ -1541,33 +1505,26 @@ #scope_type_vars scope_type_vars #eval _eval] state] ({{#Some [#module_hash _ #module_aliases _ #definitions definitions #imports _ #module_state _]} ({{#Some constant} - ({{#Alias real_name} - {#Right [state real_name]} - - {#Definition [exported? def_type def_value]} - {#Right [state full_name]} + ({{#Definition _} {#Right [state full_name]} + {#Label _} {#Right [state full_name]} + {#Slot _} {#Right [state full_name]} + {#Type _} {#Right [state full_name]} - {#Type [exported? type labels]} - {#Right [state full_name]} - - {#Label _} - {#Left ($_ text\composite "Unknown definition: " (name\encoded full_name))} - - {#Slot _} - {#Left ($_ text\composite "Unknown definition: " (name\encoded full_name))}} + {#Alias real_name} + {#Right [state real_name]}} constant) - #None + {#None} {#Left ($_ text\composite "Unknown definition: " (name\encoded full_name))}} (plist\value name definitions)) - #None + {#None} {#Left ($_ text\composite "Unknown module: " module " @ " (name\encoded full_name))}} (plist\value module modules)))) -(def:''' .private (code_list expression) +(def:''' .private (:List<Code> expression) (-> Code Code) - (let' [type (variant$ (list (tag$ [..prelude_module "Apply"]) + (let' [type (variant$ (list (identifier$ [..prelude_module "#Apply"]) (identifier$ [..prelude_module "Code"]) (identifier$ [..prelude_module "List"])))] (form$ (list (text$ "lux type check") type expression)))) @@ -1575,32 +1532,31 @@ (def:''' .private (spliced replace? untemplated elems) (-> Bit (-> Code ($' Meta Code)) ($' List Code) ($' Meta Code)) ({#1 - ({#End - (in_meta (tag$ [..prelude_module "End"])) + ({{#End} + (in_meta |#End|) {#Item lastI inits} (do meta_monad - [lastO ({[_ {#Form {#Item [[_ {#Identifier ["" "~+"]}] {#Item [spliced #End]}]}}] - (in (code_list spliced)) + [lastO ({[_ {#Form {#Item [[_ {#Identifier ["" "~+"]}] {#Item [spliced {#End}]}]}}] + (in (:List<Code> spliced)) _ (do meta_monad [lastO (untemplated lastI)] - (in (code_list (variant$ (list (tag$ [..prelude_module "Item"]) - (tuple$ (list lastO (tag$ [..prelude_module "End"]))))))))} + (in (:List<Code> (|#Item| lastO |#End|))))} lastI)] (monad\mix meta_monad (function' [leftI rightO] - ({[_ {#Form {#Item [[_ {#Identifier ["" "~+"]}] {#Item [spliced #End]}]}}] + ({[_ {#Form {#Item [[_ {#Identifier ["" "~+"]}] {#Item [spliced {#End}]}]}}] (let' [g!in-module (form$ (list (text$ "lux in-module") (text$ ..prelude_module) (identifier$ [..prelude_module "list\composite"])))] - (in (form$ (list g!in-module (code_list spliced) rightO)))) + (in (form$ (list g!in-module (:List<Code> spliced) rightO)))) _ (do meta_monad [leftO (untemplated leftI)] - (in (variant$ (list (tag$ [..prelude_module "Item"]) (tuple$ (list leftO rightO))))))} + (in (|#Item| leftO rightO)))} leftI)) lastO inits))} @@ -1613,40 +1569,28 @@ (def:''' .private (untemplated_text value) (-> Text Code) - (with_location (variant$ (list (tag$ [..prelude_module "Text"]) (text$ value))))) + (with_location (variant$ (list (identifier$ [..prelude_module "#Text"]) (text$ value))))) (def:''' .private (untemplated replace? subst token) (-> Bit Text Code ($' Meta Code)) ({[_ [_ {#Bit value}]] - (in_meta (with_location (variant$ (list (tag$ [..prelude_module "Bit"]) (bit$ value))))) + (in_meta (with_location (variant$ (list (identifier$ [..prelude_module "#Bit"]) (bit$ value))))) [_ [_ {#Nat value}]] - (in_meta (with_location (variant$ (list (tag$ [..prelude_module "Nat"]) (nat$ value))))) + (in_meta (with_location (variant$ (list (identifier$ [..prelude_module "#Nat"]) (nat$ value))))) [_ [_ {#Int value}]] - (in_meta (with_location (variant$ (list (tag$ [..prelude_module "Int"]) (int$ value))))) + (in_meta (with_location (variant$ (list (identifier$ [..prelude_module "#Int"]) (int$ value))))) [_ [_ {#Rev value}]] - (in_meta (with_location (variant$ (list (tag$ [..prelude_module "Rev"]) (rev$ value))))) + (in_meta (with_location (variant$ (list (identifier$ [..prelude_module "#Rev"]) (rev$ value))))) [_ [_ {#Frac value}]] - (in_meta (with_location (variant$ (list (tag$ [..prelude_module "Frac"]) (frac$ value))))) + (in_meta (with_location (variant$ (list (identifier$ [..prelude_module "#Frac"]) (frac$ value))))) [_ [_ {#Text value}]] (in_meta (untemplated_text value)) - [#0 [_ {#Tag [module name]}]] - (in_meta (with_location (variant$ (list (tag$ [..prelude_module "Tag"]) (tuple$ (list (text$ module) (text$ name))))))) - - [#1 [_ {#Tag [module name]}]] - (let' [module' ({"" - subst - - _ - module} - module)] - (in_meta (with_location (variant$ (list (tag$ [..prelude_module "Tag"]) (tuple$ (list (text$ module') (text$ name)))))))) - [#1 [_ {#Identifier [module name]}]] (do meta_monad [real_name ({"" @@ -1658,52 +1602,52 @@ (in [module name])} module) .let' [[module name] real_name]] - (in_meta (with_location (variant$ (list (tag$ [..prelude_module "Identifier"]) (tuple$ (list (text$ module) (text$ name)))))))) + (in_meta (with_location (variant$ (list (identifier$ [..prelude_module "#Identifier"]) (tuple$ (list (text$ module) (text$ name)))))))) [#0 [_ {#Identifier [module name]}]] - (in_meta (with_location (variant$ (list (tag$ [..prelude_module "Identifier"]) (tuple$ (list (text$ module) (text$ name))))))) + (in_meta (with_location (variant$ (list (identifier$ [..prelude_module "#Identifier"]) (tuple$ (list (text$ module) (text$ name))))))) - [#1 [_ {#Form {#Item [[_ {#Identifier ["" "~"]}] {#Item [unquoted #End]}]}}]] + [#1 [_ {#Form {#Item [[_ {#Identifier ["" "~"]}] {#Item [unquoted {#End}]}]}}]] (in_meta (form$ (list (text$ "lux type check") (identifier$ [..prelude_module "Code"]) unquoted))) - [#1 [_ {#Form {#Item [[_ {#Identifier ["" "~!"]}] {#Item [dependent #End]}]}}]] + [#1 [_ {#Form {#Item [[_ {#Identifier ["" "~!"]}] {#Item [dependent {#End}]}]}}]] (do meta_monad [independent (untemplated replace? subst dependent)] - (in (with_location (variant$ (list (tag$ [..prelude_module "Form"]) + (in (with_location (variant$ (list (identifier$ [..prelude_module "#Form"]) (untemplated_list (list (untemplated_text "lux in-module") (untemplated_text subst) independent))))))) - [#1 [_ {#Form {#Item [[_ {#Identifier ["" "~'"]}] {#Item [keep_quoted #End]}]}}]] + [#1 [_ {#Form {#Item [[_ {#Identifier ["" "~'"]}] {#Item [keep_quoted {#End}]}]}}]] (untemplated #0 subst keep_quoted) [_ [meta {#Form elems}]] (do meta_monad [output (spliced replace? (untemplated replace? subst) elems) - .let' [[_ output'] (with_location (variant$ (list (tag$ [..prelude_module "Form"]) output)))]] + .let' [[_ output'] (with_location (variant$ (list (identifier$ [..prelude_module "#Form"]) output)))]] (in [meta output'])) [_ [meta {#Variant elems}]] (do meta_monad [output (spliced replace? (untemplated replace? subst) elems) - .let' [[_ output'] (with_location (variant$ (list (tag$ [..prelude_module "Variant"]) output)))]] + .let' [[_ output'] (with_location (variant$ (list (identifier$ [..prelude_module "#Variant"]) output)))]] (in [meta output'])) [_ [meta {#Tuple elems}]] (do meta_monad [output (spliced replace? (untemplated replace? subst) elems) - .let' [[_ output'] (with_location (variant$ (list (tag$ [..prelude_module "Tuple"]) output)))]] + .let' [[_ output'] (with_location (variant$ (list (identifier$ [..prelude_module "#Tuple"]) output)))]] (in [meta output']))} [replace? token])) (macro:' .public (primitive tokens) - ({{#Item [_ {#Text class_name}] #End} - (in_meta (list (variant$ (list (tag$ [..prelude_module "Primitive"]) (text$ class_name) (tag$ [..prelude_module "End"]))))) + ({{#Item [_ {#Text class_name}] {#End}} + (in_meta (list (variant$ (list (identifier$ [..prelude_module "#Primitive"]) (text$ class_name) |#End|)))) - {#Item [_ {#Text class_name}] {#Item [_ {#Tuple params}] #End}} - (in_meta (list (variant$ (list (tag$ [..prelude_module "Primitive"]) (text$ class_name) (untemplated_list params))))) + {#Item [_ {#Text class_name}] {#Item [_ {#Tuple params}] {#End}}} + (in_meta (list (variant$ (list (identifier$ [..prelude_module "#Primitive"]) (text$ class_name) (untemplated_list params))))) _ (failure "Wrong syntax for primitive")} @@ -1724,7 +1668,7 @@ state)) (macro:' .public (` tokens) - ({{#Item template #End} + ({{#Item template {#End}} (do meta_monad [current_module current_module_name =template (untemplated #1 current_module template)] @@ -1737,7 +1681,7 @@ tokens)) (macro:' .public (`' tokens) - ({{#Item template #End} + ({{#Item template {#End}} (do meta_monad [=template (untemplated #1 "" template)] (in (list (form$ (list (text$ "lux type check") (identifier$ [..prelude_module "Code"]) =template))))) @@ -1747,7 +1691,7 @@ tokens)) (macro:' .public (' tokens) - ({{#Item template #End} + ({{#Item template {#End}} (do meta_monad [=template (untemplated #0 "" template)] (in (list (form$ (list (text$ "lux type check") (identifier$ [..prelude_module "Code"]) =template))))) @@ -1769,9 +1713,6 @@ [_ {#Form parts}] (form$ (list\composite parts (list acc))) - [_ {#Tag _}] - (` {(~ app) (~ acc)}) - _ (` ((~ app) (~ acc)))} app))) @@ -1795,9 +1736,6 @@ [_ {#Form parts}] (form$ (list\composite parts (list acc))) - [_ {#Tag name}] - (` {(~ app) (~ acc)}) - _ (` ((~ app) (~ acc)))} app))) @@ -1819,16 +1757,7 @@ {#Some sname} _ - #None} - x)) - -(def:''' .private (tag_name x) - (-> Code ($' Maybe Name)) - ({[_ {#Tag sname}] - {#Some sname} - - _ - #None} + {#None}} x)) (def:''' .private (identifier_short x) @@ -1837,7 +1766,7 @@ {#Some sname} _ - #None} + {#None}} x)) (def:''' .private (tuple_list tuple) @@ -1846,7 +1775,7 @@ {#Some members} _ - #None} + {#None}} tuple)) (def:''' .private (realized_template env template) @@ -1904,7 +1833,7 @@ (def:''' .private (list\conjoint xs) (All (_ a) (-> ($' List ($' List a)) ($' List a))) - (list\mix list\composite #End (list\reversed xs))) + (list\mix list\composite {#End} (list\reversed xs))) (macro:' .public (template tokens) ({{#Item [[_ {#Tuple bindings}] {#Item [[_ {#Tuple templates}] data]}]} @@ -2026,7 +1955,7 @@ (def:''' .private (macro_type? type) (-> Type Bit) - ({{#Named ["library/lux" "Macro"] {#Primitive "#Macro" #End}} + ({{#Named ["library/lux" "Macro"] {#Primitive "#Macro" {#End}}} #1 _ @@ -2050,17 +1979,17 @@ {#Some ("lux type as" Macro def_value)} (if (text\= module current_module) {#Some ("lux type as" Macro def_value)} - #None)) - #None) + {#None})) + {#None}) {#Type [exported? type labels]} - #None + {#None} {#Label _} - #None + {#None} {#Slot _} - #None} + {#None}} ("lux type check" Global gdef)))) (def:''' .private (normal name) @@ -2094,16 +2023,16 @@ [name (normal name) output (macro' name)] (in ({{#Some _} #1 - #None #0} + {#None} #0} output)))) (def:''' .private (list\interposed sep xs) (All (_ a) (-> a ($' List a) ($' List a))) - ({#End + ({{#End} xs - {#Item [x #End]} + {#Item [x {#End}]} xs {#Item [x xs']} @@ -2119,7 +2048,7 @@ ({{#Some macro} (("lux type as" Macro' macro) args) - #None + {#None} (in (list token))} ?macro)) @@ -2139,7 +2068,7 @@ recursive_expansion (monad\each meta_monad expansion top_level_expansion)] (in (list\conjoint recursive_expansion))) - #None + {#None} (in (list token))} ?macro)) @@ -2159,7 +2088,7 @@ expansion' (monad\each meta_monad full_expansion expansion)] (in (list\conjoint expansion'))) - #None + {#None} (do meta_monad [args' (monad\each meta_monad full_expansion args)] (in (list (form$ {#Item (identifier$ name) (list\conjoint args')}))))} @@ -2213,11 +2142,6 @@ name ($_ text\composite module "." name)) - [_ {#Tag [module name]}] - (if (text\= "" module) - ($_ text\composite "#" name) - ($_ text\composite "#" module "." name)) - [_ {#Form xs}] ($_ text\composite "(" (|> xs (list\each code\encoded) @@ -2242,11 +2166,8 @@ (def:''' .private (normal_type type) (-> Code Code) - ({[_ {#Variant {#Item [_ {#Tag tag}] parts}}] - (` {(~ (tag$ tag)) (~+ (list\each normal_type parts))}) - - [_ {#Variant members}] - (` (Or (~+ (list\each normal_type members)))) + ({[_ {#Variant {#Item [_ {#Identifier identifier}] parts}}] + (` {(~ (identifier$ identifier)) (~+ (list\each normal_type parts))}) [_ {#Tuple members}] (` (Tuple (~+ (list\each normal_type members)))) @@ -2254,33 +2175,33 @@ [_ {#Form {#Item [_ {#Text "lux in-module"}] {#Item [_ {#Text module}] {#Item type' - #End}}}}] + {#End}}}}}] (` ("lux in-module" (~ (text$ module)) (~ (normal_type type')))) - [_ {#Form {#Item [_ {#Identifier ["" ":~"]}] {#Item expression #End}}}] + [_ {#Form {#Item [_ {#Identifier ["" ":~"]}] {#Item expression {#End}}}}] expression - [_0 {#Form {#Item [_1 {#Variant {#Item binding {#Item body #End}}}] + [_0 {#Form {#Item [_1 {#Variant {#Item binding {#Item body {#End}}}}] {#Item value - #End}}}] - [_0 {#Form {#Item [_1 {#Variant {#Item binding {#Item (normal_type body) #End}}}] + {#End}}}}] + [_0 {#Form {#Item [_1 {#Variant {#Item binding {#Item (normal_type body) {#End}}}}] {#Item value - #End}}}] + {#End}}}}] [_0 {#Form {#Item [_1 {#Identifier ["library/lux" "__adjusted_quantified_type__"]}] {#Item _permission {#Item _level {#Item body - #End}}}}}] + {#End}}}}}}] [_0 {#Form {#Item [_1 {#Identifier [..prelude_module "__adjusted_quantified_type__"]}] {#Item _permission {#Item _level {#Item (normal_type body) - #End}}}}}] + {#End}}}}}}] [_ {#Form {#Item type_fn args}}] (list\mix ("lux type check" (-> Code Code Code) - (function' [arg type_fn] (` {#.Apply (~ arg) (~ type_fn)}))) + (function' [arg type_fn] (` {.#Apply (~ arg) (~ type_fn)}))) (normal_type type_fn) (list\each normal_type args)) @@ -2289,13 +2210,13 @@ type)) (macro:' .public (type tokens) - ({{#Item type #End} + ({{#Item type {#End}} (do meta_monad [initialized_quantification? (function' [lux] {#Right [lux (initialized_quantification? lux)]})] (if initialized_quantification? (do meta_monad [type+ (full_expansion type)] - ({{#Item type' #End} + ({{#Item type' {#End}} (in (list (normal_type type'))) _ @@ -2308,7 +2229,7 @@ tokens)) (macro:' .public (: tokens) - ({{#Item type {#Item value #End}} + ({{#Item type {#Item value {#End}}} (in_meta (list (` ("lux type check" (..type (~ type)) (~ value))))) @@ -2318,7 +2239,7 @@ tokens)) (macro:' .public (:as tokens) - ({{#Item type {#Item value #End}} + ({{#Item type {#Item value {#End}}} (in_meta (list (` ("lux type as" (..type (~ type)) (~ value))))) @@ -2330,8 +2251,8 @@ (def:''' .private (empty? xs) (All (_ a) (-> ($' List a) Bit)) - ({#End #1 - _ #0} + ({{#End} #1 + _ #0} xs)) (template [<name> <type> <value>] @@ -2374,23 +2295,23 @@ (macro:' .private (def:' tokens) (let' [parts (: (Maybe [Code Code (List Code) (Maybe Code) Code]) - ({{#Item export_policy {#Item [_ {#Form {#Item name args}}] {#Item type {#Item body #End}}}} + ({{#Item export_policy {#Item [_ {#Form {#Item name args}}] {#Item type {#Item body {#End}}}}} {#Some [export_policy name args {#Some type} body]} - {#Item export_policy {#Item name {#Item type {#Item body #End}}}} - {#Some [export_policy name #End {#Some type} body]} + {#Item export_policy {#Item name {#Item type {#Item body {#End}}}}} + {#Some [export_policy name {#End} {#Some type} body]} - {#Item export_policy {#Item [_ {#Form {#Item name args}}] {#Item body #End}}} - {#Some [export_policy name args #None body]} + {#Item export_policy {#Item [_ {#Form {#Item name args}}] {#Item body {#End}}}} + {#Some [export_policy name args {#None} body]} - {#Item export_policy {#Item name {#Item body #End}}} - {#Some [export_policy name #End #None body]} + {#Item export_policy {#Item name {#Item body {#End}}}} + {#Some [export_policy name {#End} {#None} body]} _ - #None} + {#None}} tokens))] ({{#Some [export_policy name args ?type body]} - (let' [body' ({#End + (let' [body' ({{#End} body _ @@ -2399,14 +2320,14 @@ body'' ({{#Some type} (` (: (~ type) (~ body'))) - #None + {#None} body'} ?type)] (in_meta (list (` ("lux def" (~ name) (~ body'') (~ export_policy)))))) - #None + {#None} (failure "Wrong syntax for def'")} parts))) @@ -2432,7 +2353,7 @@ [sub_expansion (expander branches')] (in (list& pattern body sub_expansion))) - #End + {#End} (do meta_monad [] (in (list))) _ @@ -2455,11 +2376,11 @@ (macro:' .public (^ tokens) (case tokens - {#Item [_ {#Form {#Item pattern #End}}] {#Item body branches}} + {#Item [_ {#Form {#Item pattern {#End}}}] {#Item body branches}} (do meta_monad [pattern+ (full_expansion pattern)] (case pattern+ - {#Item pattern' #End} + {#Item pattern' {#End}} (in (list& pattern' body branches)) _ @@ -2472,7 +2393,7 @@ (case tokens (^ (list& [_ {#Form patterns}] body branches)) (case patterns - #End + {#End} (failure "^or cannot have 0 patterns") _ @@ -2518,7 +2439,7 @@ {#Some name head tail body} _ - #None)) + {#None})) {#Some g!name head tail body} (let [g!blank (local_identifier$ "") nest (: (-> Code (-> Code Code Code)) @@ -2531,7 +2452,7 @@ (in_meta (list (nest (..local_identifier$ g!name) head (list\mix (nest g!blank) body (list\reversed tail)))))) - #None + {#None} (failure "Wrong syntax for function"))) (def:' .private (endP tokens) @@ -2541,7 +2462,7 @@ {#Some []} _ - #None)) + {#None})) (def:' .private (anyP tokens) (-> (List Code) (Maybe [(List Code) Code])) @@ -2550,7 +2471,7 @@ {#Some [tokens' code]} _ - #None)) + {#None})) (def:' .private (local_identifierP tokens) (-> (List Code) (Maybe [(List Code) Text])) @@ -2559,14 +2480,14 @@ {#Some [tokens' local_identifier]} _ - #None)) + {#None})) (template [<parser> <item_type> <item_parser>] [(def:' .private (<parser> tokens) (-> (List Code) (Maybe (List <item_type>))) (case tokens - #End - {#Some #End} + {#End} + {#Some {#End}} _ (do maybe_monad @@ -2594,7 +2515,7 @@ (do maybe_monad [% (local_identifierP tokens) .let' [[tokens' name] %]] - (in [tokens' [name #End]]))))] + (in [tokens' [name {#End}]]))))] [local_declarationP Text parametersP] [enhanced_local_declarationP Code enhanced_parametersP] @@ -2642,10 +2563,10 @@ ... B (^ (list& body tokens')) - {#Some [tokens' [#None body]]} + {#Some [tokens' [{#None} body]]} _ - #None)) + {#None})) (def:' .private (definitionP tokens) (-> (List Code) (Maybe [Code Text (List Code) (Maybe Code) Code])) @@ -2661,7 +2582,7 @@ (case (definitionP tokens) {#Some [export_policy name parameters ?type body]} (let [body (case parameters - #End + {#End} body _ @@ -2672,13 +2593,13 @@ (` (: (~ type) (~ body))) - #None + {#None} body)] (in_meta (list (` ("lux def" (~ (..local_identifier$ name)) (~ body) (~ export_policy)))))) - #None + {#None} (failure "Wrong syntax for def:"))) (def:' .private (macroP tokens) @@ -2696,7 +2617,7 @@ {#Some [export_policy name args body]} (let [name (local_identifier$ name) body (case args - #End + {#End} body _ @@ -2706,19 +2627,19 @@ (~ body) (~ export_policy)))))) - #None + {#None} (failure "Wrong syntax for macro:"))) (def: (list\one f xs) (All (_ a b) (-> (-> a (Maybe b)) (List a) (Maybe b))) (case xs - #End - #None + {#End} + {#None} {#Item x xs'} (case (f x) - #None + {#None} (list\one f xs') {#Some y} @@ -2752,10 +2673,10 @@ (^ (list else maybe)) (let [g!temp (: Code [dummy_location {#Identifier ["" ""]}]) code (` (case (~ maybe) - {#.Some (~ g!temp)} + {.#Some (~ g!temp)} (~ g!temp) - #.None + {.#None} (~ else)))] {#Right [state (list code)]}) @@ -2765,7 +2686,7 @@ (def: (text\all_split_by splitter input) (-> Text Text (List Text)) (case (..index splitter input) - #None + {#None} (list input) {#Some idx} @@ -2781,8 +2702,8 @@ (All (_ a) (-> Nat (List a) (Maybe a))) (case xs - #End - #None + {#End} + {#None} {#Item x xs'} (if ("lux i64 =" 0 idx) @@ -2804,7 +2725,7 @@ {#UnivQ ?local_env ?local_def} (case ?local_env - #End + {#End} {#UnivQ env ?local_def} _ @@ -2812,7 +2733,7 @@ {#ExQ ?local_env ?local_def} (case ?local_env - #End + {#End} {#ExQ env ?local_def} _ @@ -2854,7 +2775,7 @@ (applied_type param type) _ - #None)) + {#None})) (template [<name> <tag>] [(def: (<name> type) @@ -2902,7 +2823,7 @@ (interface_methods type) {#Sum _} - #None + {#None} _ {#Some (list type)})) @@ -2926,7 +2847,7 @@ (do meta_monad [=module (..module module) .let [[#module_hash _ #module_aliases _ #definitions definitions #imports _ #module_state _] =module]] - (case (plist\value (text\composite "#" name) definitions) + (case (plist\value name definitions) {#Some {#Slot [exported type group index]}} (in_meta [index (list\each (function (_ slot) @@ -2963,13 +2884,13 @@ members]}) _ - (in_meta #None)) + (in_meta {#None})) _ (record_slots unnamed))) _ - (in_meta #None))) + (in_meta {#None}))) (def: expected_type (Meta Type) @@ -2982,7 +2903,7 @@ {#Some type} {#Right state type} - #None + {#None} {#Left "Not expecting any type."})))) (def: (type\encoded type) @@ -2990,7 +2911,7 @@ (case type {#Primitive name params} (case params - #End + {#End} name _ @@ -3046,19 +2967,21 @@ "No tags available for type: " (type\encoded struct_type))))) .let [tag_mappings (: (List [Text Code]) - (list\each (function (_ tag) [(product\right tag) (tag$ tag)]) + (list\each (function (_ tag) + [(product\right tag) + (identifier$ tag)]) tags))] members (monad\each meta_monad (: (-> Code (Meta (List Code))) (function (_ token) (case token - (^ [_ {#Form (list [_ {#Text "lux def"}] [_ {#Identifier ["" tag_name]}] value export_policy)}]) - (case (plist\value tag_name tag_mappings) + (^ [_ {#Form (list [_ {#Text "lux def"}] [_ {#Identifier ["" slot_name]}] value export_policy)}]) + (case (plist\value slot_name tag_mappings) {#Some tag} (in (list tag value)) _ - (failure (text\composite "Unknown implementation member: " tag_name))) + (failure (text\composite "Unknown implementation member: " slot_name))) _ (failure "Invalid implementation member.")))) @@ -3068,7 +2991,7 @@ (def: (text\interposed separator parts) (-> Text (List Text) Text) (case parts - #End + {#End} "" {#Item head tail} @@ -3080,8 +3003,8 @@ (def: (remainderP tokens) (-> (List Code) (Maybe (List Code))) (case tokens - #End - #None + {#End} + {#None} _ {#Item tokens})) @@ -3100,7 +3023,7 @@ (case (implementationP tokens) {#Some [export_policy name args type definitions]} (let [usage (case args - #End + {#End} (local_identifier$ name) _ @@ -3110,7 +3033,7 @@ (implementation (~+ definitions))))))) - #None + {#None} (failure "Wrong syntax for implementation:"))) (def: (function\identity value) @@ -3131,24 +3054,24 @@ {#Item _} (everyP itP tokens') - #End + {#End} (in (list)))] (in (list& head tail))) - #End + {#End} {#Some (list)})) (def: (caseP tokens) (-> (List Code) (Maybe [(List Code) [Text Code]])) (case tokens - (^ (list& [_ {#Tag ["" niladic]}] tokens')) + (^ (list& [_ {#Variant (list [_ {#Identifier ["" niladic]}])}] tokens')) {#Some [tokens' [niladic (` .Any)]]} - (^ (list& [_ {#Variant (list& [_ {#Tag ["" polyadic]}] caseT)}] tokens')) + (^ (list& [_ {#Variant (list& [_ {#Identifier ["" polyadic]}] caseT)}] tokens')) {#Some [tokens' [polyadic (` (..Tuple (~+ caseT)))]]} _ - #None)) + {#None})) (macro: .public (Variant tokens) (case (everyP caseP tokens) @@ -3158,17 +3081,17 @@ (text$ (product\left case))) cases)))) - #None + {#None} (failure "Wrong syntax for Variant"))) (def: (slotP tokens) (-> (List Code) (Maybe [(List Code) [Text Code]])) (case tokens - (^ (list& [_ {#Tag ["" slot]}] type tokens')) + (^ (list& [_ {#Identifier ["" slot]}] type tokens')) {#Some [tokens' [slot type]]} _ - #None)) + {#None})) (macro: .public (Record tokens) (case tokens @@ -3180,7 +3103,7 @@ (text$ (product\left slot))) slots)))) - #None + {#None} (failure "Wrong syntax for Record")) _ @@ -3203,7 +3126,7 @@ {#Some [tokens' it]} _ - #None)) + {#None})) (def: (type_declaration it) (-> Code (Meta (Tuple Code (Maybe (Either (List Text) (List Text)))))) @@ -3216,7 +3139,7 @@ {#Some tags} (in_meta [type {#Some {#Left tags}}]) - #None + {#None} (failure "Improper type-definition syntax")) (^ (list type [_ {#Tuple slots}])) @@ -3224,17 +3147,17 @@ {#Some slots} (in_meta [type {#Some {#Right slots}}]) - #None + {#None} (failure "Improper type-definition syntax")) (^ (list type)) - (in_meta [it #None]) + (in_meta [it {#None}]) _ (failure "Improper type-definition syntax"))) type - (in_meta [type #None])} + (in_meta [type {#None}])} it)) (macro: .public (type: tokens) @@ -3247,7 +3170,7 @@ [type labels??] type+labels?? type' (: (Maybe Code) (case args - #End + {#End} {#Some type} _ @@ -3255,7 +3178,7 @@ (~ type)))}))]] (case type' {#Some type''} - (let [typeC (` {#.Named [(~ (text$ module_name)) + (let [typeC (` {.#Named [(~ (text$ module_name)) (~ (text$ name))] (.type (~ type''))})] (in_meta (list (case labels?? @@ -3276,10 +3199,10 @@ (~ typeC)) (~ export_policy))))))) - #None + {#None} (failure "Wrong syntax for type:"))) - #None + {#None} (failure "Wrong syntax for type:"))) (template [<name> <to>] @@ -3295,11 +3218,11 @@ (type: Referrals (Variant - #All + {#All} {#Only (List Text)} {#Exclude (List Text)} - #Ignore - #Nothing)) + {#Ignore} + {#Nothing})) (type: Openings [Text (List Text)]) @@ -3345,20 +3268,20 @@ (^or (^ (list& [_ {#Text "*"}] tokens')) (^ (list& [_ {#Text "all"}] tokens'))) - (in_meta [#All tokens']) + (in_meta [{#All} tokens']) (^or (^ (list& [_ {#Text "_"}] tokens')) (^ (list& [_ {#Text "ignore"}] tokens'))) - (in_meta [#Ignore tokens']) + (in_meta [{#Ignore} tokens']) _ - (in_meta [#Nothing tokens]))) + (in_meta [{#Nothing} tokens]))) (def: (openings_parser parts) (-> (List Code) (Meta [(List Openings) (List Code)])) (case parts - #End - (in_meta [#End #End]) + {#End} + (in_meta [{#End} {#End}]) (^ (list& [_ {#Form (list& [_ {#Text prefix}] structs)}] parts')) (do meta_monad @@ -3377,7 +3300,7 @@ remainder]))) _ - (in_meta [#End parts]))) + (in_meta [{#End} parts]))) (def: (text\split_at' at x) (-> Nat Text [Text Text]) @@ -3400,7 +3323,7 @@ {#Some [pre post]} (recur ($_ "lux text concat" left pre replacement) post) - #None + {#None} ("lux text concat" left right)))) "" template)) @@ -3443,12 +3366,12 @@ {#Some (normal_parallel_path' hierarchy root')} _ - #None)) + {#None})) (def: (relative_ups relatives input) (-> Nat Text Nat) (case ("lux text index" relatives ..module_separator input) - #None + {#None} relatives {#Some found} @@ -3459,7 +3382,7 @@ (def: (list\after amount list) (All (_ a) (-> Nat (List a) (List a))) (case [amount list] - (^or [0 _] [_ #End]) + (^or [0 _] [_ {#End}]) list [_ {#Item _ tail}] @@ -3504,8 +3427,8 @@ (do meta_monad [absolute_module_name (..absolute_module_name nested? relative_root module_name)] (in (list [#import_name absolute_module_name - #import_alias #None - #import_refer [#refer_defs #All + #import_alias {#None} + #import_refer [#refer_defs {#All} #refer_open (list)]]))) ... Nested @@ -3515,7 +3438,7 @@ {#Some parallel_path} (in parallel_path) - #None + {#None} (..absolute_module_name nested? relative_root module_name)) referral+extra (referrals_parser extra) .let [[referral extra] referral+extra] @@ -3523,12 +3446,12 @@ .let [[openings extra] openings+extra] sub_imports (imports_parser #1 absolute_module_name context extra)] (in (case [referral openings] - [#Nothing #End] + [{#Nothing} {#End}] sub_imports _ (list& [#import_name absolute_module_name - #import_alias #None + #import_alias {#None} #import_refer [#refer_defs referral #refer_open openings]] sub_imports)))) @@ -3539,7 +3462,7 @@ {#Some parallel_path} (in parallel_path) - #None + {#None} (..absolute_module_name nested? relative_root module_name)) referral+extra (referrals_parser extra) .let [[referral extra] referral+extra] @@ -3548,7 +3471,7 @@ module_alias (..module_alias {#Item module_name context} alias)] sub_imports (imports_parser #1 absolute_module_name {#Item module_alias context} extra)] (in (case [referral openings] - [#Ignore #End] + [{#Ignore} {#End}] sub_imports _ @@ -3604,14 +3527,14 @@ definitions))] {#Right state (list\conjoint to_alias)}) - #None + {#None} {#Left ($_ text\composite "Unknown module: " (text\encoded module) ..\n "Current module: " (case current_module {#Some current_module} (text\encoded current_module) - #None + {#None} "???") ..\n "Known modules: " (|> modules (list\each (function (_ [name module]) @@ -3624,7 +3547,7 @@ (All (_ a) (-> (-> a Bit) (List a) (List a))) (case xs - #End + {#End} (list) {#Item x xs'} @@ -3645,7 +3568,7 @@ (All (_ a b) (-> (-> a (Maybe b)) a a (Maybe b))) (case (f x1) - #None (f x2) + {#None} (f x2) {#Some y} {#Some y})) (def: (in_env name state) @@ -3666,7 +3589,7 @@ (function (_ [bname [type _]]) (if (text\= name bname) {#Some type} - #None)))) + {#None})))) (: (List [Text [Type Any]]) locals) (: (List [Text [Type Any]]) closure))))) scopes))) @@ -3679,13 +3602,13 @@ #seed seed #expected expected #location location #extensions extensions #scope_type_vars scope_type_vars #eval _eval] state] (case (plist\value v_module modules) - #None - #None + {#None} + {#None} {#Some [#definitions definitions #module_hash _ #module_aliases _ #imports _ #module_state _]} (case (plist\value v_name definitions) - #None - #None + {#None} + {#None} {#Some definition} (case definition @@ -3699,10 +3622,10 @@ {#Some ..Type} {#Label _} - #None + {#None} {#Slot _} - #None))))) + {#None}))))) (def: (definition_value name state) (-> Name (Meta [Type Any])) @@ -3712,12 +3635,12 @@ #seed seed #expected expected #location location #extensions extensions #scope_type_vars scope_type_vars #eval _eval] state] (case (plist\value v_module modules) - #None + {#None} {#Left (text\composite "Unknown definition: " (name\encoded name))} {#Some [#definitions definitions #module_hash _ #module_aliases _ #imports _ #module_state _]} (case (plist\value v_name definitions) - #None + {#None} {#Left (text\composite "Unknown definition: " (name\encoded name))} {#Some definition} @@ -3740,8 +3663,8 @@ (def: (type_variable idx bindings) (-> Nat (List [Nat (Maybe Type)]) (Maybe Type)) (case bindings - #End - #End + {#End} + {#End} {#Item [var bound] bindings'} (if ("lux i64 =" idx var) @@ -3780,7 +3703,7 @@ #scope_type_vars _ #eval _eval] compiler [#ex_counter _ #var_counter _ #var_bindings var_bindings] type_context] (case (type_variable type_id var_bindings) - #None + {#None} temp {#Some actualT} @@ -3817,7 +3740,7 @@ [init_type (type_definition name) struct_evidence (record_slots init_type)] (case struct_evidence - #None + {#None} (failure (text\composite "Can only 'open' structs: " (type\encoded init_type))) {#Some tags&members} @@ -3825,12 +3748,18 @@ [full_body ((: (-> Name [(List Name) (List Type)] Code (Meta Code)) (function (recur source [tags members] target) (let [locals (list\each (function (_ [t_module t_name]) - ["" (..module_alias (list t_name) alias)]) + [[t_module t_name] + ["" (..module_alias (list t_name) alias)]]) tags) - pattern (tuple$ (list\each identifier$ locals))] + pattern (|> locals + (list\each (function (_ [slot binding]) + (list (identifier$ slot) + (identifier$ binding)))) + list\conjoint + tuple$)] (do meta_monad [enhanced_target (monad\mix meta_monad - (function (_ [m_local m_type] enhanced_target) + (function (_ [[_ m_local] m_type] enhanced_target) (do meta_monad [m_implementation (record_slots m_type)] (case m_implementation @@ -3839,7 +3768,7 @@ m_tags&members enhanced_target) - #None + {#None} (in enhanced_target)))) target (zipped/2 locals members))] @@ -3872,8 +3801,8 @@ {#Item x xs'} {#Item [idx x] (enumeration' ("lux i64 +" 1 idx) xs')} - #End - #End)) + {#End} + {#End})) (def: (enumeration xs) (All (_ a) @@ -3882,7 +3811,7 @@ (macro: .public (value@ tokens) (case tokens - (^ (list [_ {#Tag slot'}] record)) + (^ (list [_ {#Identifier slot'}] record)) (do meta_monad [slot (normal slot') output (..type_slot slot) @@ -3894,7 +3823,7 @@ (let [pattern (|> (zipped/2 tags (enumeration members)) (list\each (: (-> [Name [Nat Type]] (List Code)) (function (_ [[r_module r_name] [r_idx r_type]]) - (list (tag$ [r_module r_name]) + (list (identifier$ [r_module r_name]) (if ("lux i64 =" idx r_idx) g!output g!_))))) @@ -4008,7 +3937,7 @@ .let [[openings options] openings+options] current_module current_module_name] (case options - #End + {#End} (in [#refer_defs referral #refer_open openings]) @@ -4033,7 +3962,7 @@ (failure ($_ text\composite _def " is not defined in module " module_name " @ " current_module))))) referred_defs)))] defs' (case r_defs - #All + {#All} (exported_definitions module_name) {#Only +defs} @@ -4048,10 +3977,10 @@ _ (test_referrals module_name *defs _defs)] (in (..list\only (|>> (is_member? _defs) not) *defs))) - #Ignore + {#Ignore} (in (list)) - #Nothing + {#Nothing} (in (list))) .let [defs (list\each (: (-> Text Code) (function (_ def) @@ -4081,7 +4010,7 @@ (let [module_alias (..maybe\else module_name module_alias') localizations (: (List Code) (case r_defs - #All + {#All} (list (' "*")) {#Only defs} @@ -4090,10 +4019,10 @@ {#Exclude defs} (list (variant$ (list (' "-") (tuple$ (list\each local_identifier$ defs))))) - #Ignore + {#Ignore} (list) - #Nothing + {#Nothing} (list))) openings (list\each (function (_ [alias structs]) (form$ (list& (text$ (..module_alias (list (alias_stand_in 0) module_alias) alias)) @@ -4106,7 +4035,7 @@ (macro: .public (module: _imports) (do meta_monad [current_module current_module_name - imports (imports_parser #0 current_module #End _imports) + imports (imports_parser #0 current_module {#End} _imports) .let [=imports (|> imports (list\each (: (-> Importation Code) (function (_ [module_name m_alias =refer]) @@ -4132,7 +4061,7 @@ (macro: .public (with@ tokens) (case tokens - (^ (list [_ {#Tag slot'}] value record)) + (^ (list [_ {#Identifier slot'}] value record)) (do meta_monad [slot (normal slot') output (..type_slot slot) @@ -4150,14 +4079,14 @@ (let [pattern (|> pattern' (list\each (: (-> [Name Nat Code] (List Code)) (function (_ [r_slot_name r_idx r_var]) - (list (tag$ r_slot_name) + (list (identifier$ r_slot_name) r_var)))) list\conjoint tuple$) output (|> pattern' (list\each (: (-> [Name Nat Code] (List Code)) (function (_ [r_slot_name r_idx r_var]) - (list (tag$ r_slot_name) + (list (identifier$ r_slot_name) (if ("lux i64 =" idx r_idx) value r_var))))) @@ -4170,7 +4099,7 @@ (^ (list [_ {#Tuple slots}] value record)) (case slots - #End + {#End} (failure "Wrong syntax for with@") _ @@ -4189,7 +4118,7 @@ (function (_ [new_slot new_binding] [old_record accesses']) [(` (value@ (~ new_slot) (~ new_binding))) {#Item (list new_binding old_record) accesses'}])) - [record (: (List (List Code)) #End)] + [record (: (List (List Code)) {#End})] pairs) accesses (list\conjoint (list\reversed accesses'))]] (in (list (` (let [(~+ accesses)] @@ -4215,7 +4144,7 @@ (macro: .public (revised@ tokens) (case tokens - (^ (list [_ {#Tag slot'}] fun record)) + (^ (list [_ {#Identifier slot'}] fun record)) (do meta_monad [slot (normal slot') output (..type_slot slot) @@ -4233,14 +4162,14 @@ (let [pattern (|> pattern' (list\each (: (-> [Name Nat Code] (List Code)) (function (_ [r_slot_name r_idx r_var]) - (list (tag$ r_slot_name) + (list (identifier$ r_slot_name) r_var)))) list\conjoint tuple$) output (|> pattern' (list\each (: (-> [Name Nat Code] (List Code)) (function (_ [r_slot_name r_idx r_var]) - (list (tag$ r_slot_name) + (list (identifier$ r_slot_name) (if ("lux i64 =" idx r_idx) (` ((~ fun) (~ r_var))) r_var))))) @@ -4253,7 +4182,7 @@ (^ (list [_ {#Tuple slots}] fun record)) (case slots - #End + {#End} (failure "Wrong syntax for revised@") _ @@ -4301,11 +4230,11 @@ (list\each (function\composite apply (replacement_environment bindings'))) list\conjoint in)) - #None)))) + {#None})))) {#Some output} (in_meta (list\composite output branches)) - #None + {#None} (failure "Wrong syntax for ^template")) _ @@ -4325,13 +4254,13 @@ (All (_ a) (-> (List a) (List a) (List a))) (case xs - #End - #End + {#End} + {#End} {#Item x xs'} (case ys - #End - #End + {#End} + {#End} {#Item y ys'} (list& x y (interleaved xs' ys'))))) @@ -4340,30 +4269,30 @@ (-> Type Code) (case type {#Primitive name params} - (` {#.Primitive (~ (text$ name)) (~ (untemplated_list (list\each type_code params)))}) + (` {.#Primitive (~ (text$ name)) (~ (untemplated_list (list\each type_code params)))}) (^template [<tag>] [{<tag> left right} (` {<tag> (~ (type_code left)) (~ (type_code right))})]) - ([#.Sum] [#.Product] - [#.Function] - [#.Apply]) + ([.#Sum] [.#Product] + [.#Function] + [.#Apply]) (^template [<tag>] [{<tag> id} (` {<tag> (~ (nat$ id))})]) - ([#.Parameter] [#.Var] [#.Ex]) + ([.#Parameter] [.#Var] [.#Ex]) (^template [<tag>] [{<tag> env type} (let [env' (untemplated_list (list\each type_code env))] (` {<tag> (~ env') (~ (type_code type))}))]) - ([#.UnivQ] [#.ExQ]) + ([.#UnivQ] [.#ExQ]) {#Named [module name] anonymous} ... TODO: Generate the explicit type definition instead of using ... the "identifier$" shortcut below. - ... (` {#.Named [(~ (text$ module)) (~ (text$ name))] + ... (` {.#Named [(~ (text$ module)) (~ (text$ name))] ... (~ (type_code anonymous))}) (identifier$ [module name]))) @@ -4376,7 +4305,7 @@ {#Some [(local_identifier$ "recur") bindings body]} _ - #None)] + {#None})] (case ?params {#Some [name bindings body]} (let [pairs (pairs bindings) @@ -4387,7 +4316,7 @@ [inits' (: (Meta (List Name)) (case (monad\each maybe_monad identifier_name inits) {#Some inits'} (in_meta inits') - #None (failure "Wrong syntax for loop"))) + {#None} (failure "Wrong syntax for loop"))) init_types (monad\each meta_monad type_definition inits') expected ..expected_type] (in_meta (list (` (("lux type check" @@ -4406,7 +4335,7 @@ [(~+ (..interleaved vars aliases))] (~ body))))))))) - #None + {#None} (failure "Wrong syntax for loop")))) (macro: .public (^slots tokens) @@ -4416,13 +4345,13 @@ [slots (: (Meta [Name (List Name)]) (case (: (Maybe [Name (List Name)]) (do maybe_monad - [hslot (..tag_name hslot') - tslots (monad\each maybe_monad ..tag_name tslots')] + [hslot (..identifier_name hslot') + tslots (monad\each maybe_monad ..identifier_name tslots')] (in [hslot tslots]))) {#Some slots} (in_meta slots) - #None + {#None} (failure "Wrong syntax for ^slots"))) .let [[hslot tslots] slots] hslot (..normal hslot) @@ -4437,10 +4366,10 @@ pattern (|> tags (list\each (: (-> Name (List Code)) (function (_ [module name]) - (let [tag (tag$ [module name])] + (let [tag (identifier$ [module name])] (case (plist\value name slot_pairings) {#Some binding} (list tag binding) - #None (list tag g!_)))))) + {#None} (list tag g!_)))))) list\conjoint tuple$)]] (in_meta (list& pattern body branches))) @@ -4451,7 +4380,7 @@ (def: (with_expansions' label tokens target) (-> Text (List Code) Code (List Code)) (case target - (^or [_ {#Bit _}] [_ {#Nat _}] [_ {#Int _}] [_ {#Rev _}] [_ {#Frac _}] [_ {#Text _}] [_ {#Tag _}]) + (^or [_ {#Bit _}] [_ {#Nat _}] [_ {#Int _}] [_ {#Rev _}] [_ {#Frac _}] [_ {#Text _}]) (list target) [_ {#Identifier [module name]}] @@ -4479,7 +4408,7 @@ [(~+ bindings')] (~+ bodies)))))) - #End + {#End} (in_meta bodies) _ @@ -4546,7 +4475,7 @@ [#Tuple]) _ - (\ meta_monad in_meta token) + (in_meta token) ... TODO: Figure out why this doesn't work: ... (\ meta_monad in token) )) @@ -4577,7 +4506,7 @@ (def: (multi_level_case^ levels) (-> (List Code) (Meta Multi_Level_Case)) (case levels - #End + {#End} (failure "Multi-level patterns cannot be empty.") {#Item init extras} @@ -4600,8 +4529,8 @@ (~+ (if bind? (list) - (list g!_ (` #.None)))))))) - (` {#.Some (~ body)}) + (list g!_ (` {.#None})))))))) + (` {.#Some (~ body)}) (: (List [Code Code]) (list\reversed levels)))] (list init_pattern inner_pattern_body))) @@ -4619,19 +4548,19 @@ expected ..expected_type g!temp (..identifier "temp")] (let [output (list g!temp - (` ({{#Some (~ g!temp)} + (` ({{.#Some (~ g!temp)} (~ g!temp) - #None + {.#None} (case (~ g!temp) (~+ next_branches))} - ("lux type check" {#.Apply (~ (type_code expected)) Maybe} + ("lux type check" {.#Apply (~ (type_code expected)) Maybe} (case (~ g!temp) (~+ (multi_level_case$ g!temp [mlc body])) (~+ (if initial_bind? (list) - (list g!temp (` #.None)))))))))] + (list g!temp (` {.#None})))))))))] (in output))) _ @@ -4647,11 +4576,8 @@ (macro: .public (name_of tokens) (case tokens - (^template [<tag>] - [(^ (list [_ {<tag> [module name]}])) - (in_meta (list (` [(~ (text$ module)) (~ (text$ name))])))]) - ([#Identifier] - [#Tag]) + (^ (list [_ {#Identifier [module name]}])) + (in_meta (list (` [(~ (text$ module)) (~ (text$ name))]))) _ (failure (..wrong_syntax_error [..prelude_module "name_of"])))) @@ -4672,9 +4598,9 @@ [stvs ..scope_type_vars] (case (..item idx (list\reversed stvs)) {#Some var_id} - (in (list (` {#Ex (~ (nat$ var_id))}))) + (in (list (` {.#Ex (~ (nat$ var_id))}))) - #None + {#None} (failure (text\composite "Indexed-type does not exist: " (nat\encoded idx))))) _ @@ -4725,7 +4651,7 @@ (macro: .public (undefined tokens) (case tokens - #End + {#End} (do meta_monad [location ..location .let [[module line column] location @@ -4759,7 +4685,7 @@ {#Some [tokens' tuple]} _ - #None)) + {#None})) (def: (templateP tokens) (-> (List Code) (Maybe [Code Text (List Text) (List Code)])) @@ -4786,16 +4712,16 @@ ((~ (local_identifier$ name)) (~ g!tokens) (~ g!compiler)) (case (~ g!tokens) (^ (list (~+ (list\each local_identifier$ args)))) - {#.Right [(~ g!compiler) + {.#Right [(~ g!compiler) (list (~+ (list\each (function (_ template) (` (`' (~ (with_replacements rep_env template))))) input_templates)))]} (~ g!_) - {#.Left (~ (text$ (..wrong_syntax_error [this_module name])))})))))) + {.#Left (~ (text$ (..wrong_syntax_error [this_module name])))})))))) - #None + {#None} (failure (..wrong_syntax_error (name_of ..template:))))) (macro: .public (as_is tokens compiler) @@ -4807,7 +4733,7 @@ (|> input "lux text size" ("lux i64 =" 1))) (|> input ("lux text char" 0) nat$ list - [compiler] #Right) + [compiler] {#Right}) _ {#Left (..wrong_syntax_error (name_of ..char))})) @@ -4829,8 +4755,8 @@ type+value (..definition_value identifier) .let [[type value] type+value]] (case (..flat_alias type) - (^or {#Primitive "#Text" #End} - {#Named ["library/lux" "Text"] {#Primitive "#Text" #End}}) + (^or {#Primitive "#Text" {#End}} + {#Named ["library/lux" "Text"] {#Primitive "#Text" {#End}}}) (in (:as ..Text value)) _ @@ -4846,9 +4772,9 @@ (def: (target_pick target options default) (-> Text (List [Code Code]) (Maybe Code) (Meta (List Code))) (case options - #End + {#End} (case default - #None + {#None} (failure ($_ text\composite "No code for target platform: " target)) {#Some default} @@ -4868,7 +4794,7 @@ (n/% 2) ("lux i64 =" 0)) {#Some (pairs tokens)} - #None)) + {#None})) (macro: .public (for tokens) (do meta_monad @@ -4877,9 +4803,9 @@ (^ (list [_ {#Tuple options}])) (case (pairs' options) {#Some options} - (target_pick target options #None) + (target_pick target options {#None}) - #None + {#None} (failure (..wrong_syntax_error (name_of ..for)))) (^ (list [_ {#Tuple options}] default)) @@ -4887,7 +4813,7 @@ {#Some options} (target_pick target options {#Some default}) - #None + {#None} (failure (..wrong_syntax_error (name_of ..for)))) _ @@ -4935,18 +4861,18 @@ (def: (untemplated_list& last inits) (-> Code (List Code) Code) (case inits - #End + {#End} last {#Item [init inits']} - (` {#.Item (~ init) (~ (untemplated_list& last inits'))}))) + (` {.#Item (~ init) (~ (untemplated_list& last inits'))}))) (template [<tag> <name>] [(def: (<name> g!meta untemplated_pattern elems) (-> Code (-> Code (Meta Code)) (-> (List Code) (Meta Code))) (case (list\reversed elems) - {#Item [_ {#Form {#Item [[_ {#Identifier ["" "~+"]}] {#Item [spliced #End]}]}}] + {#Item [_ {#Form {#Item [[_ {#Identifier ["" "~+"]}] {#Item [spliced {#End}]}]}}] inits} (do meta_monad [=inits (monad\each meta_monad untemplated_pattern (list\reversed inits))] @@ -4957,9 +4883,9 @@ [=elems (monad\each meta_monad untemplated_pattern elems)] (in (` [(~ g!meta) {<tag> (~ (untemplated_list =elems))}])))))] - [#.Form untemplated_form] - [#.Tuple untemplated_tuple] - [#.Variant untemplated_variant] + [.#Form untemplated_form] + [.#Tuple untemplated_tuple] + [.#Variant untemplated_variant] ) (def: (untemplated_pattern pattern) @@ -4970,19 +4896,18 @@ (^template [<tag> <gen>] [[_ {<tag> value}] (in (` [(~ g!meta) {<tag> (~ (<gen> value))}]))]) - ([#.Bit bit$] - [#.Nat nat$] - [#.Int int$] - [#.Rev rev$] - [#.Frac frac$] - [#.Text text$] - [#.Tag name$] - [#.Identifier name$]) - - [_ {#Form {#Item [[_ {#Identifier ["" "~"]}] {#Item [unquoted #End]}]}}] + ([.#Bit bit$] + [.#Nat nat$] + [.#Int int$] + [.#Rev rev$] + [.#Frac frac$] + [.#Text text$] + [.#Identifier name$]) + + [_ {#Form {#Item [[_ {#Identifier ["" "~"]}] {#Item [unquoted {#End}]}]}}] (in_meta unquoted) - [_ {#Form {#Item [[_ {#Identifier ["" "~+"]}] {#Item [spliced #End]}]}}] + [_ {#Form {#Item [[_ {#Identifier ["" "~+"]}] {#Item [spliced {#End}]}]}}] (failure "Cannot use (~+) inside of ^code unless it is the last element in a form or a tuple.") (^template [<tag> <untemplated>] @@ -5051,7 +4976,7 @@ {#Some [tokens' [name type]]} _ - #None)) + {#None})) (macro: .public (Interface tokens) (do meta_monad @@ -5061,13 +4986,13 @@ (in (list (` (..Tuple (~+ (list\each product\right methods)))) (tuple$ (list\each (|>> product\left text$) methods)))) - #None + {#None} (failure "Wrong syntax for Interface")))) (def: (recursive_type g!self g!dummy name body) (-> Code Code Text Code Code) (` ((.All ((~ g!self) (~ g!dummy)) - (~ (let$ (local_identifier$ name) (` {#.Apply (..primitive "") (~ g!self)}) + (~ (let$ (local_identifier$ name) (` {.#Apply (..primitive "") (~ g!self)}) body))) (..primitive "")))) diff --git a/stdlib/source/library/lux/abstract/apply.lux b/stdlib/source/library/lux/abstract/apply.lux index f1b2b9344..366e2e750 100644 --- a/stdlib/source/library/lux/abstract/apply.lux +++ b/stdlib/source/library/lux/abstract/apply.lux @@ -21,8 +21,8 @@ (Apply (All (_ a) (F (G a)))))) (def: &functor - (functor.composite (value@ #&functor f_apply) - (value@ #&functor g_apply))) + (functor.composite (value@ &functor f_apply) + (value@ &functor g_apply))) (def: (on fgx fgf) ... TODO: Switch from this version to the one below (in comments) ASAP. diff --git a/stdlib/source/library/lux/abstract/comonad.lux b/stdlib/source/library/lux/abstract/comonad.lux index 20e24bcb5..d649ea244 100644 --- a/stdlib/source/library/lux/abstract/comonad.lux +++ b/stdlib/source/library/lux/abstract/comonad.lux @@ -26,19 +26,19 @@ (macro: .public (be tokens state) (case (: (Maybe [(Maybe Text) Code (List Code) Code]) (case tokens - (^ (list [_ {#.Tuple (list [_ {#.Identifier ["" name]}] comonad)}] [_ {#.Tuple bindings}] body)) - {#.Some [{#.Some name} comonad bindings body]} + (^ (list [_ {.#Tuple (list [_ {.#Identifier ["" name]}] comonad)}] [_ {.#Tuple bindings}] body)) + {.#Some [{.#Some name} comonad bindings body]} - (^ (list comonad [_ {#.Tuple bindings}] body)) - {#.Some [#.None comonad bindings body]} + (^ (list comonad [_ {.#Tuple bindings}] body)) + {.#Some [{.#None} comonad bindings body]} _ - #.None)) - {#.Some [?name comonad bindings body]} + {.#None})) + {.#Some [?name comonad bindings body]} (if (|> bindings list.size (n.% 2) (n.= 0)) (let [[module short] (name_of ..be) identifier (: (-> Text Code) - (|>> ($_ "lux text concat" module " " short " ") [""] #.Identifier [location.dummy])) + (|>> ($_ "lux text concat" module " " short " ") [""] {.#Identifier} [location.dummy])) g!_ (identifier "_") g!each (identifier "each") g!disjoint (identifier "disjoint") @@ -47,30 +47,30 @@ (with_expansions [<default> (` (|> (~ value) (~ g!disjoint) ((~ g!each) (function ((~ g!_) (~ var)) (~ body')))))] (let [[var value] binding] (case var - [_ {#.Identifier ["" _]}] + [_ {.#Identifier ["" _]}] <default> - [_ {#.Identifier _}] + [_ {.#Identifier _}] (` ((~ var) (~ value) (~ body'))) _ <default>))))) body (list.reversed (list.pairs bindings)))] - {#.Right [state (list (case ?name - {#.Some name} - (let [name [location.dummy {#.Identifier ["" name]}]] + {.#Right [state (list (case ?name + {.#Some name} + (let [name [location.dummy {.#Identifier ["" name]}]] (` (.case (~ comonad) (~ name) (.case (~ name) [(~ g!each) (~' out) (~ g!disjoint)] (~ body'))))) - #.None + {.#None} (` (.case (~ comonad) [(~ g!each) (~' out) (~ g!disjoint)] (~ body')))))]}) - {#.Left "'be' bindings must have an even number of parts."}) + {.#Left "'be' bindings must have an even number of parts."}) - #.None - {#.Left "Wrong syntax for 'be'"})) + {.#None} + {.#Left "Wrong syntax for 'be'"})) diff --git a/stdlib/source/library/lux/abstract/enum.lux b/stdlib/source/library/lux/abstract/enum.lux index c78a0711f..1b86ebc1d 100644 --- a/stdlib/source/library/lux/abstract/enum.lux +++ b/stdlib/source/library/lux/abstract/enum.lux @@ -14,12 +14,12 @@ (All (_ a) (-> (Enum a) a a (List a))) (let [(^open "[0]") enum] (loop [end to - output #.End] + output {.#End}] (cond (< end from) - (recur (pred end) {#.Item end output}) + (recur (pred end) {.#Item end output}) (< from end) - (recur (succ end) {#.Item end output}) + (recur (succ end) {.#Item end output}) ... (= end from) - {#.Item end output})))) + {.#Item end output})))) diff --git a/stdlib/source/library/lux/abstract/functor.lux b/stdlib/source/library/lux/abstract/functor.lux index 5b7b4d3f1..36aab9aeb 100644 --- a/stdlib/source/library/lux/abstract/functor.lux +++ b/stdlib/source/library/lux/abstract/functor.lux @@ -20,11 +20,11 @@ (implementation (def: (each f fa|ga) (case fa|ga - {#.Left fa} - {#.Left (f\each f fa)} + {.#Left fa} + {.#Left (f\each f fa)} - {#.Right ga} - {#.Right (g\each f ga)})))) + {.#Right ga} + {.#Right (g\each f ga)})))) (type: .public (And f g) (All (_ a) (.And (f a) (g a)))) diff --git a/stdlib/source/library/lux/abstract/interval.lux b/stdlib/source/library/lux/abstract/interval.lux index c39ac868c..a6337b770 100644 --- a/stdlib/source/library/lux/abstract/interval.lux +++ b/stdlib/source/library/lux/abstract/interval.lux @@ -76,21 +76,21 @@ (implementation: .public (union left right) (All (_ a) (-> (Interval a) (Interval a) (Interval a))) - (def: &enum (value@ #&enum right)) + (def: &enum (value@ &enum right)) (def: bottom (order.min (\ right &order) (\ left bottom) (\ right bottom))) (def: top (order.max (\ right &order) (\ left top) (\ right top)))) (implementation: .public (intersection left right) (All (_ a) (-> (Interval a) (Interval a) (Interval a))) - (def: &enum (value@ #&enum right)) + (def: &enum (value@ &enum right)) (def: bottom (order.max (\ right &order) (\ left bottom) (\ right bottom))) (def: top (order.min (\ right &order) (\ left top) (\ right top)))) (implementation: .public (complement interval) (All (_ a) (-> (Interval a) (Interval a))) - (def: &enum (value@ #&enum interval)) + (def: &enum (value@ &enum interval)) (def: bottom (\ interval succ (\ interval top))) (def: top (\ interval pred (\ interval bottom)))) diff --git a/stdlib/source/library/lux/abstract/monad.lux b/stdlib/source/library/lux/abstract/monad.lux index c915945a1..2aca8a09a 100644 --- a/stdlib/source/library/lux/abstract/monad.lux +++ b/stdlib/source/library/lux/abstract/monad.lux @@ -10,10 +10,10 @@ (All (_ a b) (-> (-> b a a) a (List b) a)) (case xs - #.End + {.#End} init - {#.Item x xs'} + {.#Item x xs'} (list\mix f (f x init) xs'))) (def: (list\size xs) @@ -21,27 +21,27 @@ (loop [counter 0 xs xs] (case xs - #.End + {.#End} counter - {#.Item _ xs'} + {.#Item _ xs'} (recur (++ counter) xs')))) (def: (reversed xs) (All (_ a) (-> (List a) (List a))) - (list\mix (function (_ head tail) {#.Item head tail}) - #.End + (list\mix (function (_ head tail) {.#Item head tail}) + {.#End} xs)) (def: (pairs xs) (All (_ a) (-> (List a) (List [a a]))) (case xs - {#.Item x1 {#.Item x2 xs'}} - {#.Item [x1 x2] (pairs xs')} + {.#Item x1 {.#Item x2 xs'}} + {.#Item [x1 x2] (pairs xs')} _ - #.End)) + {.#End})) (type: .public (Monad m) (Interface @@ -57,19 +57,19 @@ (macro: .public (do tokens state) (case (: (Maybe [(Maybe Text) Code (List Code) Code]) (case tokens - (^ (list [_ {#.Tuple (list [_ {#.Identifier ["" name]}] monad)}] [_ {#.Tuple bindings}] body)) - {#.Some [{#.Some name} monad bindings body]} + (^ (list [_ {.#Tuple (list [_ {.#Identifier ["" name]}] monad)}] [_ {.#Tuple bindings}] body)) + {.#Some [{.#Some name} monad bindings body]} - (^ (list monad [_ {#.Tuple bindings}] body)) - {#.Some [#.None monad bindings body]} + (^ (list monad [_ {.#Tuple bindings}] body)) + {.#Some [{.#None} monad bindings body]} _ - #.None)) - {#.Some [?name monad bindings body]} + {.#None})) + {.#Some [?name monad bindings body]} (if (|> bindings list\size .int ("lux i64 %" +2) ("lux i64 =" +0)) (let [[module short] (name_of ..do) identifier (: (-> Text Code) - (|>> ($_ "lux text concat" module " " short " ") [""] #.Identifier [location.dummy])) + (|>> ($_ "lux text concat" module " " short " ") [""] {.#Identifier} [location.dummy])) g!_ (identifier "_") g!each (identifier "each") g!conjoint (identifier "conjoint") @@ -78,33 +78,33 @@ (with_expansions [<default> (` (|> (~ value) ((~ g!each) (function ((~ g!_) (~ var)) (~ body'))) (~ g!conjoint)))] (let [[var value] binding] (case var - [_ {#.Identifier ["" _]}] + [_ {.#Identifier ["" _]}] <default> - [_ {#.Identifier _}] + [_ {.#Identifier _}] (` ((~ var) (~ value) (~ body'))) _ <default>))))) body (reversed (pairs bindings)))] - {#.Right [state (list (case ?name - {#.Some name} - (let [name [location.dummy {#.Identifier ["" name]}]] + {.#Right [state (list (case ?name + {.#Some name} + (let [name [location.dummy {.#Identifier ["" name]}]] (` (.case (~ monad) (~ name) (.case (~ name) [(~ g!each) (~' in) (~ g!conjoint)] (~ body'))))) - #.None + {.#None} (` (.case (~ monad) [(~ g!each) (~' in) (~ g!conjoint)] (~ body')))))]}) - {#.Left "'do' bindings must have an even number of parts."}) + {.#Left "'do' bindings must have an even number of parts."}) - #.None - {#.Left "Wrong syntax for 'do'"})) + {.#None} + {.#Left "Wrong syntax for 'do'"})) (def: .public (then monad f) (All (_ ! a b) @@ -120,13 +120,13 @@ (let [(^open "!\[0]") monad] (function (recur xs) (case xs - #.End - (!\in #.End) + {.#End} + (!\in {.#End}) - {#.Item x xs'} + {.#Item x xs'} (|> x (!\each (function (_ _x) - (!\each (|>> {#.Item _x}) (recur xs')))) + (!\each (|>> {.#Item _x}) (recur xs')))) !\conjoint))))) (def: .public (each monad f) @@ -136,13 +136,13 @@ (let [(^open "!\[0]") monad] (function (recur xs) (case xs - #.End - (!\in #.End) + {.#End} + (!\in {.#End}) - {#.Item x xs'} + {.#Item x xs'} (|> (f x) (!\each (function (_ _x) - (!\each (|>> {#.Item _x}) (recur xs')))) + (!\each (|>> {.#Item _x}) (recur xs')))) !\conjoint))))) (def: .public (only monad f) @@ -152,15 +152,15 @@ (let [(^open "!\[0]") monad] (function (recur xs) (case xs - #.End - (!\in #.End) + {.#End} + (!\in {.#End}) - {#.Item head xs'} + {.#Item head xs'} (|> (f head) (!\each (function (_ verdict) (!\each (function (_ tail) (if verdict - {#.Item head tail} + {.#Item head tail} tail)) (recur xs')))) !\conjoint))))) @@ -170,10 +170,10 @@ (-> (Monad M) (-> b a (M a)) a (List b) (M a))) (case xs - #.End + {.#End} (\ monad in init) - {#.Item x xs'} + {.#Item x xs'} (do monad [init' (f x init)] (mix monad f init' xs')))) diff --git a/stdlib/source/library/lux/abstract/monad/indexed.lux b/stdlib/source/library/lux/abstract/monad/indexed.lux index 3051aba52..8a6b6818b 100644 --- a/stdlib/source/library/lux/abstract/monad/indexed.lux +++ b/stdlib/source/library/lux/abstract/monad/indexed.lux @@ -55,10 +55,10 @@ (def: named_monad (Parser [(Maybe Text) Code]) - (<>.either (<code>.tuple (<>.and (\ <>.monad each (|>> #.Some) + (<>.either (<code>.tuple (<>.and (\ <>.monad each (|>> {.#Some}) <code>.local_identifier) <code>.any)) - (\ <>.monad each (|>> [#.None]) + (\ <>.monad each (|>> [{.#None}]) <code>.any))) (syntax: .public (do [[?name monad] ..named_monad @@ -80,14 +80,14 @@ expression (list.reversed context))] (in (list (case ?name - {#.Some name} + {.#Some name} (let [name (code.local_identifier name)] (` (let [(~ name) (~ monad) - [#..in (~' in) - #..then (~ g!then)] (~ name)] + [..in (~' in) + ..then (~ g!then)] (~ name)] (~ body)))) - #.None - (` (let [[#..in (~' in) - #..then (~ g!then)] (~ monad)] + {.#None} + (` (let [[..in (~' in) + ..then (~ g!then)] (~ monad)] (~ body))))))))) diff --git a/stdlib/source/library/lux/control/concatenative.lux b/stdlib/source/library/lux/control/concatenative.lux index 2e70ed49e..4d377e5c5 100644 --- a/stdlib/source/library/lux/control/concatenative.lux +++ b/stdlib/source/library/lux/control/concatenative.lux @@ -52,7 +52,7 @@ (Parser Stack) (<>.either (<>.and (<>.maybe bottom^) ..top^) - (<>.and (<>\each (|>> #.Some) bottom^) + (<>.and (<>\each (|>> {.#Some}) bottom^) (<>\in (list))))) (def: (stack_mix tops bottom) @@ -67,7 +67,7 @@ (monad.do meta.monad [expansion expander] (case expansion - {#.Item singleton #.End} + {.#Item singleton {.#End}} (in singleton) _ @@ -87,7 +87,7 @@ aliases))] (case [(value@ #bottom inputs) (value@ #bottom outputs)] - [{#.Some bottomI} {#.Some bottomO}] + [{.#Some bottomI} {.#Some bottomO}] (monad.do meta.monad [inputC (singleton (macro.full_expansion (stack_mix (value@ #top inputs) bottomI))) outputC (singleton (macro.full_expansion (stack_mix (value@ #top outputs) bottomO)))] diff --git a/stdlib/source/library/lux/control/concurrency/actor.lux b/stdlib/source/library/lux/control/concurrency/actor.lux index c275d546f..64ab1c283 100644 --- a/stdlib/source/library/lux/control/concurrency/actor.lux +++ b/stdlib/source/library/lux/control/concurrency/actor.lux @@ -54,12 +54,12 @@ (do [! io.monad] [current (async.value read)] (case current - {#.Some [head tail]} - (\ ! each (|>> {#.Item head}) + {.#Some [head tail]} + (\ ! each (|>> {.#Item head}) (pending tail)) - #.None - (in #.End)))) + {.#None} + (in {.#End})))) (abstract: .public (Actor s) (Record @@ -94,15 +94,15 @@ [[head tail] |mailbox| ?state' (on_mail head state self)] (case ?state' - {#try.Failure error} + {try.#Failure error} (let [[_ resolve] (value@ #obituary (:representation self))] (exec (io.run! (do io.monad [pending (..pending tail)] - (resolve [error state {#.Item head pending}]))) + (resolve [error state {.#Item head pending}]))) (in []))) - {#try.Success state'} + {try.#Success state'} (recur state' tail))))] self))) @@ -112,7 +112,7 @@ (|> obituary async.value (\ io.functor each - (|>> (case> #.None + (|>> (case> {.#None} bit.yes _ @@ -141,16 +141,16 @@ (do ! [|mailbox| (async.value |mailbox|)] (case |mailbox| - #.None + {.#None} (do ! [resolved? (resolve entry)] (if resolved? (do ! [_ (atom.write! (product.right entry) (value@ #mailbox (:representation actor)))] - (in {#try.Success []})) + (in {try.#Success []})) (recur |mailbox|&resolve))) - {#.Some [_ |mailbox|']} + {.#Some [_ |mailbox|']} (recur |mailbox|')))))) (in (exception.except ..dead []))))) @@ -171,15 +171,15 @@ (do [! async.monad] [outcome (message state self)] (case outcome - {#try.Success [state' return]} + {try.#Success [state' return]} (exec - (io.run! (resolve {#try.Success return})) - (async.resolved {#try.Success state'})) + (io.run! (resolve {try.#Success return})) + (async.resolved {try.#Success state'})) - {#try.Failure error} + {try.#Failure error} (exec - (io.run! (resolve {#try.Failure error})) - (async.resolved {#try.Failure error})))))])) + (io.run! (resolve {try.#Failure error})) + (async.resolved {try.#Failure error})))))])) (def: .public (tell! message actor) (All (_ s o) (-> (Message s o) (Actor s) (Async (Try o)))) @@ -187,11 +187,11 @@ (do async.monad [outcome (async.future (..mail! mail actor))] (case outcome - {#try.Success} + {try.#Success} async - {#try.Failure error} - (in {#try.Failure error}))))) + {try.#Failure error} + (in {try.#Failure error}))))) ) ) @@ -240,10 +240,10 @@ (def: (on_mail g!_ ?on_mail) (-> Code (Maybe On_MailC) Code) (case ?on_mail - #.None + {.#None} (` (~! ..default_on_mail)) - {#.Some [[mailN stateN selfN] bodyC]} + {.#Some [[mailN stateN selfN] bodyC]} (` (function ((~ g!_) (~ (code.local_identifier mailN)) (~ (code.local_identifier stateN)) @@ -270,8 +270,8 @@ (def: (~ export_policy) (~ g!actor) (All ((~ g!_) (~+ g!vars)) (..Behavior (~ state_type) ((~ g!type) (~+ g!vars)))) - [#..on_init (|>> ((~! abstract.:abstraction) (~ g!type))) - #..on_mail (~ (..on_mail g!_ ?on_mail))]) + [..#on_init (|>> ((~! abstract.:abstraction) (~ g!type))) + ..#on_mail (~ (..on_mail g!_ ?on_mail))]) (~+ messages)))))))) @@ -280,8 +280,8 @@ (with_identifiers [g!_] (in (list (` (: ((~! io.IO) (..Actor (~ state_type))) (..spawn! (: (..Behavior (~ state_type) (~ state_type)) - [#..on_init (|>>) - #..on_mail (~ (..on_mail g!_ ?on_mail))]) + [..#on_init (|>>) + ..#on_mail (~ (..on_mail g!_ ?on_mail))]) (: (~ state_type) (~ init))))))))) @@ -319,9 +319,9 @@ (with_identifiers [g!_ g!return] (do meta.monad [actor_scope abstract.current - .let [g!type (code.local_identifier (value@ #abstract.name actor_scope)) + .let [g!type (code.local_identifier (value@ abstract.#name actor_scope)) g!message (code.local_identifier (value@ #name signature)) - g!actor_vars (value@ #abstract.type_vars actor_scope) + g!actor_vars (value@ abstract.#type_vars actor_scope) g!all_vars (|> signature (value@ #vars) (list\each code.local_identifier) (list\composite g!actor_vars)) g!inputsC (|> signature (value@ #inputs) (list\each product.left)) g!inputsT (|> signature (value@ #inputs) (list\each product.right)) @@ -330,15 +330,15 @@ (in (list (` (def: (~ export_policy) ((~ g!message) (~+ g!inputsC)) (All ((~ g!_) (~+ g!all_vars)) (-> (~+ g!inputsT) - (..Message (~ (value@ #abstract.abstraction actor_scope)) + (..Message (~ (value@ abstract.#abstraction actor_scope)) (~ output_type)))) (function ((~ g!_) (~ g!state) (~ g!self)) - (let [(~ g!state) (:as (~ (value@ #abstract.representation actor_scope)) + (let [(~ g!state) (:as (~ (value@ abstract.#representation actor_scope)) (~ g!state))] (|> (~ body) - (: ((~! async.Async) ((~! try.Try) [(~ (value@ #abstract.representation actor_scope)) + (: ((~! async.Async) ((~! try.Try) [(~ (value@ abstract.#representation actor_scope)) (~ output_type)]))) - (:as ((~! async.Async) ((~! try.Try) [(~ (value@ #abstract.abstraction actor_scope)) + (:as ((~! async.Async) ((~! try.Try) [(~ (value@ abstract.#abstraction actor_scope)) (~ output_type)])))))))) ))))) @@ -361,5 +361,5 @@ (|> actor (..mail! (action event stop)) (\ ! each try.maybe)) - (in #.None)))) + (in {.#None})))) channel))) diff --git a/stdlib/source/library/lux/control/concurrency/async.lux b/stdlib/source/library/lux/control/concurrency/async.lux index 477870a86..0342da425 100644 --- a/stdlib/source/library/lux/control/concurrency/async.lux +++ b/stdlib/source/library/lux/control/concurrency/async.lux @@ -31,12 +31,12 @@ (do [! io.monad] [(^@ old [_value _observers]) (atom.read! async)] (case _value - {#.Some _} + {.#Some _} (in #0) - #.None + {.#None} (do ! - [.let [new [{#.Some value} #.None]] + [.let [new [{.#Some value} {.#None}]] succeeded? (atom.compare_and_swap! old new async)] (if succeeded? (do ! @@ -47,11 +47,11 @@ (def: .public (resolved value) (All (_ a) (-> a (Async a))) - (:abstraction (atom [{#.Some value} (list)]))) + (:abstraction (atom [{.#Some value} (list)]))) (def: .public (async _) (All (_ a) (-> Any [(Async a) (Resolver a)])) - (let [async (:abstraction (atom [#.None (list)]))] + (let [async (:abstraction (atom [{.#None} (list)]))] [async (..resolver async)])) (def: .public value @@ -66,11 +66,11 @@ [.let [async (:representation async)] (^@ old [_value _observers]) (atom.read! async)] (case _value - {#.Some value} + {.#Some value} (f value) - #.None - (let [new [_value {#.Item f _observers}]] + {.#None} + (let [new [_value {.#Item f _observers}]] (do ! [swapped? (atom.compare_and_swap! old new async)] (if swapped? @@ -82,10 +82,10 @@ (All (_ a) (-> (Async a) (IO Bit))) (|>> ..value (\ io.functor each - (|>> (case> #.None + (|>> (case> {.#None} #0 - {#.Some _} + {.#Some _} #1))))) (implementation: .public functor @@ -144,10 +144,10 @@ (let [[a|b resolve] (..async [])] (with_expansions [<sides> (template [<async> <tag>] - [(io.run! (upon! (|>> <tag> resolve) <async>))] + [(io.run! (upon! (|>> {<tag>} resolve) <async>))] - [left #.Left] - [right #.Right] + [left .#Left] + [right .#Right] )] (exec <sides> diff --git a/stdlib/source/library/lux/control/concurrency/frp.lux b/stdlib/source/library/lux/control/concurrency/frp.lux index 5498eeb06..ebf3728ca 100644 --- a/stdlib/source/library/lux/control/concurrency/frp.lux +++ b/stdlib/source/library/lux/control/concurrency/frp.lux @@ -39,10 +39,10 @@ (loop [_ []] (do [! io.monad] [current (atom.read! sink) - stopped? (current #.None)] + stopped? (current {.#None})] (if stopped? ... I closed the sink. - (in {#try.Success []}) + (in {try.#Success []}) ... Someone else interacted with the sink. (do ! [latter (atom.read! sink)] @@ -63,12 +63,12 @@ [(Async (Maybe [a (Channel a)])) (async.Resolver (Maybe [a (Channel a)]))] (async.async []))] - fed? (current {#.Some [value next]})] + fed? (current {.#Some [value next]})] (if fed? ... I fed the sink. (do ! [_ (atom.compare_and_swap! current resolve_next sink)] - (in {#try.Success []})) + (in {try.#Success []})) ... Someone else interacted with the sink. (do ! [latter (atom.read! sink)] @@ -102,15 +102,15 @@ [item_f ff item_a fa] (case [item_f item_a] - [{#.Some [head_f tail_f]} {#.Some [head_a tail_a]}] - (in {#.Some [(head_f head_a) (on tail_a tail_f)]}) + [{.#Some [head_f tail_f]} {.#Some [head_a tail_a]}] + (in {.#Some [(head_f head_a) (on tail_a tail_f)]}) _ - (in #.None))))) + (in {.#None}))))) (def: empty Channel - (async.resolved #.None)) + (async.resolved {.#None})) (implementation: .public monad (Monad Channel) @@ -118,7 +118,7 @@ (def: &functor ..functor) (def: (in a) - (async.resolved {#.Some [a ..empty]})) + (async.resolved {.#Some [a ..empty]})) (def: (conjoint mma) (let [[output sink] (channel [])] @@ -128,22 +128,22 @@ (do [! async.monad] [?mma mma] (case ?mma - {#.Some [ma mma']} + {.#Some [ma mma']} (do ! [_ (loop [ma ma] (do ! [?ma ma] (case ?ma - {#.Some [a ma']} + {.#Some [a ma']} (exec (io.run! (\ sink feed a)) (recur ma')) - #.None + {.#None} (in []))))] (recur mma')) - #.None + {.#None} (in (: Any (io.run! (\ sink close)))))))) output)))) @@ -158,15 +158,15 @@ (do async.monad [item channel] (case item - {#.Some [head tail]} + {.#Some [head tail]} (case (io.run! (subscriber head)) - {#.Some _} + {.#Some _} (recur tail) - #.None + {.#None} (in [])) - #.None + {.#None} (in []))))) []))) @@ -175,19 +175,19 @@ (do async.monad [item channel] (case item - {#.Some [head tail]} + {.#Some [head tail]} (let [tail' (only pass? tail)] (if (pass? head) - (in {#.Some [head tail']}) + (in {.#Some [head tail']}) tail')) - #.None - (in #.None)))) + {.#None} + (in {.#None})))) (def: .public (of_async async) (All (_ a) (-> (Async a) (Channel a))) (async\each (function (_ value) - {#.Some [value ..empty]}) + {.#Some [value ..empty]}) async)) (def: .public (mix f init channel) @@ -197,10 +197,10 @@ (do [! async.monad] [item channel] (case item - #.None + {.#None} (in init) - {#.Some [head tail]} + {.#Some [head tail]} (do ! [init' (f head init)] (mix f init' tail))))) @@ -212,13 +212,13 @@ (do [! async.monad] [item channel] (case item - #.None - (in {#.Some [init (in #.None)]}) + {.#None} + (in {.#Some [init (in {.#None})]}) - {#.Some [head tail]} + {.#Some [head tail]} (do ! [init' (f head init)] - (in {#.Some [init (mixes f init' tail)]}))))) + (in {.#Some [init (mixes f init' tail)]}))))) (def: .public (poll milli_seconds action) (All (_ a) @@ -241,55 +241,55 @@ (do async.monad [?next (f init)] (case ?next - {#.Some [state output]} - (in {#.Some [output (iterations f state)]}) + {.#Some [state output]} + (in {.#Some [output (iterations f state)]}) - #.None - (in #.None)))) + {.#None} + (in {.#None})))) (def: (distinct' equivalence previous channel) (All (_ a) (-> (Equivalence a) a (Channel a) (Channel a))) (do async.monad [item channel] (case item - {#.Some [head tail]} + {.#Some [head tail]} (if (\ equivalence = previous head) (distinct' equivalence previous tail) - (in {#.Some [head (distinct' equivalence head tail)]})) + (in {.#Some [head (distinct' equivalence head tail)]})) - #.None - (in #.None)))) + {.#None} + (in {.#None})))) (def: .public (distinct equivalence channel) (All (_ a) (-> (Equivalence a) (Channel a) (Channel a))) (do async.monad [item channel] (in (case item - {#.Some [head tail]} - {#.Some [head (distinct' equivalence head tail)]} + {.#Some [head tail]} + {.#Some [head (distinct' equivalence head tail)]} - #.None - #.None)))) + {.#None} + {.#None})))) (def: .public (list channel) (All (_ a) (-> (Channel a) (Async (List a)))) (do [! async.monad] [item channel] (case item - {#.Some [head tail]} - (\ ! each (|>> {#.Item head}) + {.#Some [head tail]} + (\ ! each (|>> {.#Item head}) (list tail)) - #.None - (in #.End)))) + {.#None} + (in {.#End})))) (def: .public (sequential milli_seconds values) (All (_ a) (-> Nat (List a) (Channel a))) (case values - #.End + {.#End} ..empty - {#.Item head tail} - (async.resolved {#.Some [head (do async.monad + {.#Item head tail} + (async.resolved {.#Some [head (do async.monad [_ (async.delay milli_seconds)] (sequential milli_seconds tail))]}))) diff --git a/stdlib/source/library/lux/control/concurrency/semaphore.lux b/stdlib/source/library/lux/control/concurrency/semaphore.lux index 1a0ef82f9..268cf3736 100644 --- a/stdlib/source/library/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/library/lux/control/concurrency/semaphore.lux @@ -86,12 +86,12 @@ (in (exception.except ..semaphore_is_maxed_out [(value@ #max_positions pre)])) (do ! [_ (case (queue.front (value@ #waiting_list pre)) - #.None + {.#None} (in true) - {#.Some sink} + {.#Some sink} (sink []))] - (in {#try.Success (value@ #open_positions post)}))))))) + (in {try.#Success (value@ #open_positions post)}))))))) ) (abstract: .public Mutex diff --git a/stdlib/source/library/lux/control/concurrency/stm.lux b/stdlib/source/library/lux/control/concurrency/stm.lux index 6e468b90a..d2355b689 100644 --- a/stdlib/source/library/lux/control/concurrency/stm.lux +++ b/stdlib/source/library/lux/control/concurrency/stm.lux @@ -54,10 +54,10 @@ (do ! [result (\ sink feed new_value)] (case result - {#try.Success _} + {try.#Success _} (in []) - {#try.Failure _} + {try.#Failure _} (un_follow! sink var)))) observers)] (in [])) @@ -68,7 +68,7 @@ (do io.monad [.let [[channel sink] (frp.channel [])] _ (atom.update! (function (_ [value observers]) - [value {#.Item sink observers}]) + [value {.#Item sink observers}]) (:representation target))] (in [channel sink]))) ) @@ -99,28 +99,28 @@ (All (_ a) (-> (Var a) (STM a))) (function (_ tx) (case (var_value var tx) - {#.Some value} + {.#Some value} [tx value] - #.None + {.#None} (let [value (..read! var)] - [{#.Item [var value value] tx} + [{.#Item [var value value] tx} value])))) (def: (with_updated_var var value tx) (All (_ a) (-> (Var a) a Tx Tx)) (case tx - #.End - #.End + {.#End} + {.#End} - {#.Item [_var _original _current] tx'} + {.#Item [_var _original _current] tx'} (if (same? (:as (Var Any) var) (:as (Var Any) _var)) - {#.Item [#var (:as (Var Any) _var) + {.#Item [#var (:as (Var Any) _var) #original (:as Any _original) #current (:as Any value)] tx'} - {#.Item [#var _var + {.#Item [#var _var #original _original #current _current] (with_updated_var var value tx')}))) @@ -129,12 +129,12 @@ (All (_ a) (-> a (Var a) (STM Any))) (function (_ tx) (case (var_value var tx) - {#.Some _} + {.#Some _} [(with_updated_var var value tx) []] - #.None - [{#.Item [var (..read! var) value] tx} + {.#None} + [{.#Item [var (..read! var) value] tx} []]))) (implementation: .public functor @@ -216,14 +216,14 @@ (do ! [|commits| (async.value |commits|)] (case |commits| - #.None + {.#None} (do io.monad [resolved? (resolve entry)] (if resolved? (atom.write! (product.right entry) pending_commits) (recur |commits|&resolve))) - {#.Some [head tail]} + {.#Some [head tail]} (recur tail))))))) (def: (process_commit! commit) diff --git a/stdlib/source/library/lux/control/concurrency/thread.lux b/stdlib/source/library/lux/control/concurrency/thread.lux index f52b7f319..5696bcdc9 100644 --- a/stdlib/source/library/lux/control/concurrency/thread.lux +++ b/stdlib/source/library/lux/control/concurrency/thread.lux @@ -91,14 +91,14 @@ (def: (execute! action) (-> (IO Any) Any) (case (try (io.run! action)) - {#try.Failure error} + {try.#Failure error} (exec ("lux io log" ($_ "lux text concat" "ERROR DURING THREAD EXECUTION:" text.new_line error)) []) - {#try.Success _} + {try.#Success _} [])) (def: .public (schedule! milli_seconds action) @@ -129,7 +129,7 @@ ... Default (do [! io.monad] [now (\ ! each (|>> instant.millis .nat) instant.now) - _ (atom.update! (|>> {#.Item [#creation now + _ (atom.update! (|>> {.#Item [#creation now #delay milli_seconds #action action]}) ..runner)] @@ -152,7 +152,7 @@ [threads (atom.read! ..runner)] (case threads ... And... we're done! - #.End + {.#End} (in []) _ diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux index 5c8231e72..455318e39 100644 --- a/stdlib/source/library/lux/control/exception.lux +++ b/stdlib/source/library/lux/control/exception.lux @@ -40,40 +40,40 @@ (-> (Exception e) (-> Text a) (Try a) (Try a))) (case try - {#//.Success output} - {#//.Success output} + {//.#Success output} + {//.#Success output} - {#//.Failure error} + {//.#Failure error} (let [reference (value@ #label exception)] (if (text.starts_with? reference error) - {#//.Success (|> error + {//.#Success (|> error (text.clip_since (text.size reference)) maybe.trusted then)} - {#//.Failure error})))) + {//.#Failure error})))) (def: .public (otherwise else try) (All (_ a) (-> (-> Text a) (Try a) a)) (case try - {#//.Success output} + {//.#Success output} output - {#//.Failure error} + {//.#Failure error} (else error))) (def: .public (error exception message) (All (_ e) (-> (Exception e) e Text)) - ((value@ #..constructor exception) message)) + ((value@ ..#constructor exception) message)) (def: .public (except exception message) (All (_ e a) (-> (Exception e) e (Try a))) - {#//.Failure (..error exception message)}) + {//.#Failure (..error exception message)}) (def: .public (assertion exception message test) (All (_ e) (-> (Exception e) e Bit (Try Any))) (if test - {#//.Success []} + {//.#Success []} (..except exception message))) (def: exception @@ -99,10 +99,10 @@ (in (list (` (def: (~ export_policy) (~ g!self) (All ((~ g!_) (~+ (list\each |type_variable|.format t_vars))) - (..Exception [(~+ (list\each (value@ #|input|.type) inputs))])) + (..Exception [(~+ (list\each (value@ |input|.#type) inputs))])) (let [(~ g!descriptor) (~ (code.text descriptor))] - [#..label (~ g!descriptor) - #..constructor (function ((~ g!self) [(~+ (list\each (value@ #|input|.binding) inputs))]) + [..#label (~ g!descriptor) + ..#constructor (function ((~ g!self) [(~+ (list\each (value@ |input|.#binding) inputs))]) ((~! text\composite) (~ g!descriptor) (~ (maybe.else (' "") body))))])))))))) @@ -128,10 +128,10 @@ (text.replaced text.new_line on_new_line) ($_ text\composite padding header header_separator)))))] (case entries - #.End + {.#End} "" - {#.Item head tail} + {.#Item head tail} (list\mix (function (_ post pre) ($_ text\composite pre text.new_line (on_entry post))) (on_entry head) @@ -148,9 +148,9 @@ (|> entries (list\mix (function (_ entry [index next]) [(++ index) - {#.Item [(n\encoded index) (format entry)] + {.#Item [(n\encoded index) (format entry)] next}]) - [0 #.End]) + [0 {.#End}]) product.right list.reversed ..report')) @@ -173,8 +173,8 @@ (def: .public (with exception message computation) (All (_ e a) (-> (Exception e) e (Try a) (Try a))) (case computation - {#//.Failure error} - {#//.Failure (case error + {//.#Failure error} + {//.#Failure (case error "" (..error exception message) diff --git a/stdlib/source/library/lux/control/function/memo.lux b/stdlib/source/library/lux/control/function/memo.lux index cccc36bf4..f5d32635f 100644 --- a/stdlib/source/library/lux/control/function/memo.lux +++ b/stdlib/source/library/lux/control/function/memo.lux @@ -23,10 +23,10 @@ (do [! state.monad] [memory state.get] (case (dictionary.value input memory) - {#.Some output} + {.#Some output} (in output) - #.None + {.#None} (do ! [output (delegate input) _ (state.update (dictionary.has input output))] diff --git a/stdlib/source/library/lux/control/function/mutual.lux b/stdlib/source/library/lux/control/function/mutual.lux index 820d40253..282779593 100644 --- a/stdlib/source/library/lux/control/function/mutual.lux +++ b/stdlib/source/library/lux/control/function/mutual.lux @@ -55,11 +55,11 @@ (syntax: .public (let [functions (<code>.tuple (<>.some ..mutual)) body <code>.any]) (case functions - #.End + {.#End} (in (list body)) - {#.Item mutual #.End} - (.let [g!name (|> mutual (value@ [#declaration #declaration.name]) code.local_identifier)] + {.#Item mutual {.#End}} + (.let [g!name (|> mutual (value@ [#declaration declaration.#name]) code.local_identifier)] (in (list (` (.let [(~ g!name) (: (~ (value@ #type mutual)) (function (~ (declaration.format (value@ #declaration mutual))) (~ (value@ #body mutual))))] @@ -77,10 +77,10 @@ context_types (list\each (function (_ mutual) (` (-> (~ g!context) (~ (value@ #type mutual))))) functions) - user_names (list\each (|>> (value@ [#declaration #declaration.name]) code.local_identifier) + user_names (list\each (|>> (value@ [#declaration declaration.#name]) code.local_identifier) functions)] g!pop (local.push (list\each (function (_ [g!name mutual]) - [[here_name (value@ [#declaration #declaration.name] mutual)] + [[here_name (value@ [#declaration declaration.#name] mutual)] (..macro g!context g!name)]) (list.zipped/2 hidden_names functions)))] @@ -107,15 +107,15 @@ (syntax: .public (def: [functions (<>.many ..definition)]) (case functions - #.End + {.#End} (in (list)) - {#.Item definition #.End} + {.#Item definition {.#End}} (.let [(^slots [#export_policy #mutual]) definition - (^slots [#declaration #type #body]) mutual] - (in (list (` (.def: (~ export_policy) (~ (declaration.format declaration)) - (~ type) - (~ body)))))) + (^slots [#declaration #type #body]) #mutual] + (in (list (` (.def: (~ #export_policy) (~ (declaration.format #declaration)) + (~ #type) + (~ #body)))))) _ (macro.with_identifiers [g!context g!output] @@ -129,10 +129,10 @@ context_types (list\each (function (_ mutual) (` (-> (~ g!context) (~ (value@ [#mutual #type] mutual))))) functions) - user_names (list\each (|>> (value@ [#mutual #declaration #declaration.name]) code.local_identifier) + user_names (list\each (|>> (value@ [#mutual #declaration declaration.#name]) code.local_identifier) functions)] g!pop (local.push (list\each (function (_ [g!name mutual]) - [[here_name (value@ [#mutual #declaration #declaration.name] mutual)] + [[here_name (value@ [#mutual #declaration declaration.#name] mutual)] (..macro g!context g!name)]) (list.zipped/2 hidden_names functions)))] @@ -147,7 +147,7 @@ user_names))]))) g!pop (list\each (function (_ mutual) - (.let [g!name (|> mutual (value@ [#mutual #declaration #declaration.name]) code.local_identifier)] + (.let [g!name (|> mutual (value@ [#mutual #declaration declaration.#name]) code.local_identifier)] (` (.def: (~ (value@ #export_policy mutual)) (~ g!name) diff --git a/stdlib/source/library/lux/control/lazy.lux b/stdlib/source/library/lux/control/lazy.lux index 5819243a4..f827e65a3 100644 --- a/stdlib/source/library/lux/control/lazy.lux +++ b/stdlib/source/library/lux/control/lazy.lux @@ -22,16 +22,16 @@ (def: (lazy' generator) (All (_ a) (-> (-> [] a) (Lazy a))) - (let [cache (atom.atom #.None)] + (let [cache (atom.atom {.#None})] (:abstraction (function (_ _) (case (io.run! (atom.read! cache)) - {#.Some value} + {.#Some value} value _ (let [value (generator [])] (exec - (io.run! (atom.compare_and_swap! _ {#.Some value} cache)) + (io.run! (atom.compare_and_swap! _ {.#Some value} cache)) value))))))) (def: .public (value lazy) diff --git a/stdlib/source/library/lux/control/maybe.lux b/stdlib/source/library/lux/control/maybe.lux index 0387618a8..2deaa50d2 100644 --- a/stdlib/source/library/lux/control/maybe.lux +++ b/stdlib/source/library/lux/control/maybe.lux @@ -12,29 +12,30 @@ ["[0]" location]]]]) ... (type: (Maybe a) -... #.None -... {#.Some a}) +... {.#None} +... {.#Some a}) (implementation: .public monoid (All (_ a) (Monoid (Maybe a))) - (def: identity #.None) + (def: identity + {.#None}) (def: (composite mx my) (case mx - #.None + {.#None} my - {#.Some x} - {#.Some x}))) + {.#Some x} + {.#Some x}))) (implementation: .public functor (Functor Maybe) (def: (each f ma) (case ma - #.None #.None - {#.Some a} {#.Some (f a)}))) + {.#None} {.#None} + {.#Some a} {.#Some (f a)}))) (implementation: .public apply (Apply Maybe) @@ -43,11 +44,11 @@ (def: (on fa ff) (case [ff fa] - [{#.Some f} {#.Some a}] - {#.Some (f a)} + [{.#Some f} {.#Some a}] + {.#Some (f a)} _ - #.None))) + {.#None}))) (implementation: .public monad (Monad Maybe) @@ -55,14 +56,14 @@ (def: &functor ..functor) (def: (in x) - {#.Some x}) + {.#Some x}) (def: (conjoint mma) (case mma - #.None - #.None + {.#None} + {.#None} - {#.Some mx} + {.#Some mx} mx))) (implementation: .public (equivalence super) @@ -70,10 +71,10 @@ (def: (= mx my) (case [mx my] - [#.None #.None] + [{.#None} {.#None}] #1 - [{#.Some x} {#.Some y}] + [{.#Some x} {.#Some y}] (\ super = x y) _ @@ -87,17 +88,17 @@ (def: (hash value) (case value - #.None + {.#None} 0 - {#.Some value} + {.#Some value} (\ super hash value)))) (implementation: .public (with monad) (All (_ M) (-> (Monad M) (Monad (All (_ a) (M (Maybe a)))))) (def: &functor - (functor.composite (value@ #monad.&functor monad) + (functor.composite (value@ monad.&functor monad) ..functor)) (def: in (|>> (\ ..monad in) (\ monad in))) @@ -106,10 +107,10 @@ (do monad [mMma MmMma] (case mMma - #.None - (in #.None) + {.#None} + (in {.#None}) - {#.Some Mma} + {.#Some Mma} Mma)))) (def: .public (lifted monad) @@ -119,16 +120,16 @@ (macro: .public (else tokens state) (case tokens (^ (.list else maybe)) - (let [g!temp (: Code [location.dummy {#.Identifier ["" ""]}])] - {#.Right [state (.list (` (case (~ maybe) - {#.Some (~ g!temp)} + (let [g!temp (: Code [location.dummy {.#Identifier ["" ""]}])] + {.#Right [state (.list (` (case (~ maybe) + {.#Some (~ g!temp)} (~ g!temp) - #.None + {.#None} (~ else))))]}) _ - {#.Left "Wrong syntax for else"})) + {.#Left "Wrong syntax for else"})) (def: .public trusted (All (_ a) (-> (Maybe a) a)) @@ -137,18 +138,18 @@ (def: .public (list value) (All (_ a) (-> (Maybe a) (List a))) (case value - #.None - #.End + {.#None} + {.#End} - {#.Some value} - {#.Item value #.End})) + {.#Some value} + {.#Item value {.#End}})) (macro: .public (when tokens state) (case tokens (^ (.list test then)) - {#.Right [state (.list (` (.if (~ test) + {.#Right [state (.list (` (.if (~ test) (~ then) - #.None)))]} + {.#None})))]} _ - {#.Left "Wrong syntax for when"})) + {.#Left "Wrong syntax for when"})) diff --git a/stdlib/source/library/lux/control/parser.lux b/stdlib/source/library/lux/control/parser.lux index 17731a079..3d78dd546 100644 --- a/stdlib/source/library/lux/control/parser.lux +++ b/stdlib/source/library/lux/control/parser.lux @@ -25,11 +25,11 @@ (def: (each f ma) (function (_ input) (case (ma input) - {#try.Failure msg} - {#try.Failure msg} + {try.#Failure msg} + {try.#Failure msg} - {#try.Success [input' a]} - {#try.Success [input' (f a)]})))) + {try.#Success [input' a]} + {try.#Success [input' (f a)]})))) (implementation: .public apply (All (_ s) (Apply (Parser s))) @@ -39,16 +39,16 @@ (def: (on fa ff) (function (_ input) (case (ff input) - {#try.Success [input' f]} + {try.#Success [input' f]} (case (fa input') - {#try.Success [input'' a]} - {#try.Success [input'' (f a)]} + {try.#Success [input'' a]} + {try.#Success [input'' (f a)]} - {#try.Failure msg} - {#try.Failure msg}) + {try.#Failure msg} + {try.#Failure msg}) - {#try.Failure msg} - {#try.Failure msg})))) + {try.#Failure msg} + {try.#Failure msg})))) (implementation: .public monad (All (_ s) (Monad (Parser s))) @@ -57,34 +57,34 @@ (def: (in x) (function (_ input) - {#try.Success [input x]})) + {try.#Success [input x]})) (def: (conjoint mma) (function (_ input) (case (mma input) - {#try.Failure msg} - {#try.Failure msg} + {try.#Failure msg} + {try.#Failure msg} - {#try.Success [input' ma]} + {try.#Success [input' ma]} (ma input'))))) (def: .public (assertion message test) (All (_ s) (-> Text Bit (Parser s Any))) (function (_ input) (if test - {#try.Success [input []]} - {#try.Failure message}))) + {try.#Success [input []]} + {try.#Failure message}))) (def: .public (maybe parser) (All (_ s a) (-> (Parser s a) (Parser s (Maybe a)))) (function (_ input) (case (parser input) - {#try.Failure _} - {#try.Success [input #.None]} + {try.#Failure _} + {try.#Success [input {.#None}]} - {#try.Success [input' x]} - {#try.Success [input' {#.Some x}]}))) + {try.#Success [input' x]} + {try.#Success [input' {.#Some x}]}))) (def: .public (result parser input) (All (_ s a) @@ -103,23 +103,23 @@ (-> (Parser s a) (Parser s b) (Parser s (Or a b)))) (function (_ tokens) (case (left tokens) - {#try.Success [tokens' output]} - {#try.Success [tokens' {0 #0 output}]} + {try.#Success [tokens' output]} + {try.#Success [tokens' {0 #0 output}]} - {#try.Failure _} + {try.#Failure _} (case (right tokens) - {#try.Success [tokens' output]} - {#try.Success [tokens' {0 #1 output}]} + {try.#Success [tokens' output]} + {try.#Success [tokens' {0 #1 output}]} - {#try.Failure error} - {#try.Failure error})))) + {try.#Failure error} + {try.#Failure error})))) (def: .public (either this that) (All (_ s a) (-> (Parser s a) (Parser s a) (Parser s a))) (function (_ tokens) (case (this tokens) - {#try.Failure _} + {try.#Failure _} (that tokens) output @@ -130,10 +130,10 @@ (-> (Parser s a) (Parser s (List a)))) (function (_ input) (case (parser input) - {#try.Failure _} - {#try.Success [input (list)]} + {try.#Failure _} + {try.#Success [input (list)]} - {#try.Success [input' head]} + {try.#Success [input' head]} (..result (\ ..monad each (|>> (list& head)) (some parser)) input')))) @@ -143,7 +143,7 @@ (-> (Parser s a) (Parser s (List a)))) (|> (..some parser) (..and parser) - (\ ..monad each (|>> #.Item)))) + (\ ..monad each (|>> {.#Item})))) (def: .public (exactly amount parser) (All (_ s a) (-> Nat (Parser s a) (Parser s (List a)))) @@ -153,7 +153,7 @@ [x parser] (|> parser (exactly (-- amount)) - (\ ! each (|>> {#.Item x})))))) + (\ ! each (|>> {.#Item x})))))) (def: .public (at_least amount parser) (All (_ s a) (-> Nat (Parser s a) (Parser s (List a)))) @@ -167,11 +167,11 @@ 0 (\ ..monad in (list)) _ (function (_ input) (case (parser input) - {#try.Failure msg} - {#try.Success [input (list)]} + {try.#Failure msg} + {try.#Success [input (list)]} - {#try.Success [input' x]} - (..result (\ ..monad each (|>> {#.Item x}) + {try.#Success [input' x]} + (..result (\ ..monad each (|>> {.#Item x}) (at_most (-- amount) parser)) input'))))) @@ -189,54 +189,54 @@ (do [! ..monad] [?x (..maybe parser)] (case ?x - #.None - (in #.End) + {.#None} + (in {.#End}) - {#.Some x} + {.#Some x} (|> parser (..and separator) ..some - (\ ! each (|>> (list\each product.right) {#.Item x})))))) + (\ ! each (|>> (list\each product.right) {.#Item x})))))) (def: .public (not parser) (All (_ s a) (-> (Parser s a) (Parser s Any))) (function (_ input) (case (parser input) - {#try.Failure msg} - {#try.Success [input []]} + {try.#Failure msg} + {try.#Success [input []]} _ - {#try.Failure "Expected to fail; yet succeeded."}))) + {try.#Failure "Expected to fail; yet succeeded."}))) (def: .public (failure message) (All (_ s a) (-> Text (Parser s a))) (function (_ input) - {#try.Failure message})) + {try.#Failure message})) (def: .public (lifted operation) (All (_ s a) (-> (Try a) (Parser s a))) (function (_ input) (case operation - {#try.Success output} - {#try.Success [input output]} + {try.#Success output} + {try.#Success [input output]} - {#try.Failure error} - {#try.Failure error}))) + {try.#Failure error} + {try.#Failure error}))) (def: .public (else value parser) (All (_ s a) (-> a (Parser s a) (Parser s a))) (function (_ input) (case (parser input) - {#try.Failure error} - {#try.Success [input value]} + {try.#Failure error} + {try.#Success [input value]} - {#try.Success [input' output]} - {#try.Success [input' output]}))) + {try.#Success [input' output]} + {try.#Success [input' output]}))) (def: .public remaining (All (_ s) (Parser s s)) (function (_ inputs) - {#try.Success [inputs inputs]})) + {try.#Success [inputs inputs]})) (def: .public (rec parser) (All (_ s a) (-> (-> (Parser s a) (Parser s a)) (Parser s a))) @@ -267,28 +267,28 @@ (All (_ s a) (-> (Parser s a) (Parser s Bit))) (function (_ input) (case (parser input) - {#try.Failure error} - {#try.Success [input false]} + {try.#Failure error} + {try.#Success [input false]} - {#try.Success [input' _]} - {#try.Success [input' true]}))) + {try.#Success [input' _]} + {try.#Success [input' true]}))) (def: .public (parses parser) (All (_ s a) (-> (Parser s a) (Parser s Any))) (function (_ input) (case (parser input) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success [input' _]} - {#try.Success [input' []]}))) + {try.#Success [input' _]} + {try.#Success [input' []]}))) (def: .public (speculative parser) (All (_ s a) (-> (Parser s a) (Parser s a))) (function (_ input) (case (parser input) - {#try.Success [input' output]} - {#try.Success [input output]} + {try.#Success [input' output]} + {try.#Success [input output]} output output))) @@ -297,13 +297,13 @@ (All (_ s a z) (-> (Codec a z) (Parser s a) (Parser s z))) (function (_ input) (case (parser input) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success [input' to_decode]} + {try.#Success [input' to_decode]} (case (\ codec decoded to_decode) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success value} - {#try.Success [input' value]})))) + {try.#Success value} + {try.#Success [input' value]})))) diff --git a/stdlib/source/library/lux/control/parser/analysis.lux b/stdlib/source/library/lux/control/parser/analysis.lux index 0c5f47cb3..03b29e3f3 100644 --- a/stdlib/source/library/lux/control/parser/analysis.lux +++ b/stdlib/source/library/lux/control/parser/analysis.lux @@ -53,39 +53,39 @@ (def: .public (result parser input) (All (_ a) (-> (Parser a) (List Analysis) (Try a))) (case (parser input) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success [#.End value]} - {#try.Success value} + {try.#Success [{.#End} value]} + {try.#Success value} - {#try.Success [unconsumed _]} + {try.#Success [unconsumed _]} (exception.except ..unconsumed_input unconsumed))) (def: .public any (Parser Analysis) (function (_ input) (case input - #.End + {.#End} (exception.except ..cannot_parse input) - {#.Item [head tail]} - {#try.Success [tail head]}))) + {.#Item [head tail]} + {try.#Success [tail head]}))) (def: .public end! (Parser Any) (function (_ tokens) (case tokens - #.End {#try.Success [tokens []]} - _ {#try.Failure (format "Expected list of tokens to be empty!" - (remaining_inputs tokens))}))) + {.#End} {try.#Success [tokens []]} + _ {try.#Failure (format "Expected list of tokens to be empty!" + (remaining_inputs tokens))}))) (def: .public end? (Parser Bit) (function (_ tokens) - {#try.Success [tokens (case tokens - #.End true - _ false)]})) + {try.#Success [tokens (case tokens + {.#End} true + _ false)]})) (template [<query> <assertion> <tag> <type> <eq>] [(`` (as_is (def: .public <query> @@ -93,7 +93,7 @@ (function (_ input) (case input (^ (list& (<tag> x) input')) - {#try.Success [input' x]} + {try.#Success [input' x]} _ (exception.except ..cannot_parse input)))) @@ -104,7 +104,7 @@ (case input (^ (list& (<tag> actual) input')) (if (\ <eq> = expected actual) - {#try.Success [input' []]} + {try.#Success [input' []]} (exception.except ..cannot_parse input)) _ @@ -128,7 +128,7 @@ (^ (list& (/.tuple head) tail)) (do try.monad [output (..result parser head)] - {#try.Success [tail output]}) + {try.#Success [tail output]}) _ (exception.except ..cannot_parse input)))) diff --git a/stdlib/source/library/lux/control/parser/binary.lux b/stdlib/source/library/lux/control/parser/binary.lux index 0f5e925e1..c37298d24 100644 --- a/stdlib/source/library/lux/control/parser/binary.lux +++ b/stdlib/source/library/lux/control/parser/binary.lux @@ -41,29 +41,29 @@ (def: .public (result parser input) (All (_ a) (-> (Parser a) Binary (Try a))) (case (parser [0 input]) - {#try.Failure msg} - {#try.Failure msg} + {try.#Failure msg} + {try.#Failure msg} - {#try.Success [[end _] output]} + {try.#Success [[end _] output]} (let [length (/.size input)] (if (n.= end length) - {#try.Success output} + {try.#Success output} (exception.except ..binary_was_not_fully_read [length end]))))) (def: .public end? (Parser Bit) (function (_ (^@ input [offset data])) - {#try.Success [input (n.= offset (/.size data))]})) + {try.#Success [input (n.= offset (/.size data))]})) (def: .public offset (Parser Offset) (function (_ (^@ input [offset data])) - {#try.Success [input offset]})) + {try.#Success [input offset]})) (def: .public remaining (Parser Nat) (function (_ (^@ input [offset data])) - {#try.Success [input (n.- offset (/.size data))]})) + {try.#Success [input (n.- offset (/.size data))]})) (type: .public Size Nat) @@ -78,11 +78,11 @@ (Parser I64) (function (_ [offset binary]) (case (<read> offset binary) - {#try.Success data} - {#try.Success [(n.+ <size> offset) binary] data} + {try.#Success data} + {try.#Success [(n.+ <size> offset) binary] data} - {#try.Failure error} - {#try.Failure error})))] + {try.#Failure error} + {try.#Failure error})))] [bits/8 ..size/8 /.read/8!] [bits/16 ..size/16 /.read/16!] @@ -122,8 +122,8 @@ (def: .public (or left right) (All (_ l r) (-> (Parser l) (Parser r) (Parser (Or l r)))) - (!variant [[0 [#.Left] left] - [1 [#.Right] right]])) + (!variant [[0 [.#Left] left] + [1 [.#Right] right]])) (def: .public (rec body) (All (_ a) (-> (-> (Parser a) (Parser a)) (Parser a))) @@ -154,7 +154,7 @@ (-> Nat (Parser Binary)) (function (_ [offset binary]) (case size - 0 {#try.Success [[offset binary] (/.empty 0)]} + 0 {try.#Success [[offset binary] (/.empty 0)]} _ (|> binary (/.slice offset size) (\ try.monad each (|>> [[(n.+ size offset) binary]])))))) @@ -246,17 +246,17 @@ (let [pair (//.and type type) indexed ..nat quantified (//.and (..list type) type)] - (!variant [[0 [#.Primitive] (//.and ..text (..list type))] - [1 [#.Sum] pair] - [2 [#.Product] pair] - [3 [#.Function] pair] - [4 [#.Parameter] indexed] - [5 [#.Var] indexed] - [6 [#.Ex] indexed] - [7 [#.UnivQ] quantified] - [8 [#.ExQ] quantified] - [9 [#.Apply] pair] - [10 [#.Named] (//.and ..name type)]]))))) + (!variant [[0 [.#Primitive] (//.and ..text (..list type))] + [1 [.#Sum] pair] + [2 [.#Product] pair] + [3 [.#Function] pair] + [4 [.#Parameter] indexed] + [5 [.#Var] indexed] + [6 [.#Ex] indexed] + [7 [.#UnivQ] quantified] + [8 [.#ExQ] quantified] + [9 [.#Apply] pair] + [10 [.#Named] (//.and ..name type)]]))))) (def: .public location (Parser Location) @@ -268,14 +268,13 @@ (function (_ recur) (let [sequence (..list recur)] (//.and ..location - (!variant [[00 [#.Bit] ..bit] - [01 [#.Nat] ..nat] - [02 [#.Int] ..int] - [03 [#.Rev] ..rev] - [04 [#.Frac] ..frac] - [05 [#.Text] ..text] - [06 [#.Identifier] ..name] - [07 [#.Tag] ..name] - [08 [#.Form] sequence] - [09 [#.Variant] sequence] - [10 [#.Tuple] sequence]])))))) + (!variant [[0 [.#Bit] ..bit] + [1 [.#Nat] ..nat] + [2 [.#Int] ..int] + [3 [.#Rev] ..rev] + [4 [.#Frac] ..frac] + [5 [.#Text] ..text] + [6 [.#Identifier] ..name] + [7 [.#Form] sequence] + [8 [.#Variant] sequence] + [9 [.#Tuple] sequence]])))))) diff --git a/stdlib/source/library/lux/control/parser/cli.lux b/stdlib/source/library/lux/control/parser/cli.lux index aca4512fb..f68605f14 100644 --- a/stdlib/source/library/lux/control/parser/cli.lux +++ b/stdlib/source/library/lux/control/parser/cli.lux @@ -16,26 +16,26 @@ (def: .public (result parser inputs) (All (_ a) (-> (Parser a) (List Text) (Try a))) (case (//.result parser inputs) - {#try.Success [remaining output]} + {try.#Success [remaining output]} (case remaining - #.End - {#try.Success output} + {.#End} + {try.#Success output} _ - {#try.Failure (format "Remaining CLI inputs: " (text.interposed " " remaining))}) + {try.#Failure (format "Remaining CLI inputs: " (text.interposed " " remaining))}) - {#try.Failure try} - {#try.Failure try})) + {try.#Failure try} + {try.#Failure try})) (def: .public any (Parser Text) (function (_ inputs) (case inputs - {#.Item arg inputs'} - {#try.Success [inputs' arg]} + {.#Item arg inputs'} + {try.#Success [inputs' arg]} _ - {#try.Failure "Cannot parse empty arguments."}))) + {try.#Failure "Cannot parse empty arguments."}))) (def: .public (parse parser) (All (_ a) (-> (-> Text (Try a)) (Parser a))) @@ -52,33 +52,33 @@ [[remaining raw] (any inputs)] (if (text\= reference raw) (in [remaining []]) - {#try.Failure (format "Missing token: '" reference "'")})))) + {try.#Failure (format "Missing token: '" reference "'")})))) (def: .public (somewhere cli) (All (_ a) (-> (Parser a) (Parser a))) (function (_ inputs) (loop [immediate inputs] (case (//.result cli immediate) - {#try.Success [remaining output]} - {#try.Success [remaining output]} + {try.#Success [remaining output]} + {try.#Success [remaining output]} - {#try.Failure try} + {try.#Failure try} (case immediate - #.End - {#try.Failure try} + {.#End} + {try.#Failure try} - {#.Item to_omit immediate'} + {.#Item to_omit immediate'} (do try.monad [[remaining output] (recur immediate')] - (in [{#.Item to_omit remaining} + (in [{.#Item to_omit remaining} output]))))))) (def: .public end (Parser Any) (function (_ inputs) (case inputs - #.End {#try.Success [inputs []]} - _ {#try.Failure (format "Unknown parameters: " (text.interposed " " inputs))}))) + {.#End} {try.#Success [inputs []]} + _ {try.#Failure (format "Unknown parameters: " (text.interposed " " inputs))}))) (def: .public (named name value) (All (_ a) (-> Text (Parser a) (Parser a))) diff --git a/stdlib/source/library/lux/control/parser/code.lux b/stdlib/source/library/lux/control/parser/code.lux index d58874cf4..4e31cb1b4 100644 --- a/stdlib/source/library/lux/control/parser/code.lux +++ b/stdlib/source/library/lux/control/parser/code.lux @@ -24,8 +24,8 @@ (def: (un_paired pairs) (All (_ a) (-> (List [a a]) (List a))) (case pairs - #.End #.End - {#.Item [[x y] pairs']} (list& x y (un_paired pairs')))) + {.#End} {.#End} + {.#Item [[x y] pairs']} (list& x y (un_paired pairs')))) (type: .public Parser (//.Parser (List Code))) @@ -40,30 +40,30 @@ (Parser Code) (function (_ tokens) (case tokens - #.End - {#try.Failure "There are no tokens to parse!"} + {.#End} + {try.#Failure "There are no tokens to parse!"} - {#.Item [t tokens']} - {#try.Success [tokens' t]}))) + {.#Item [t tokens']} + {try.#Success [tokens' t]}))) (def: .public next (Parser Code) (function (_ tokens) (case tokens - #.End - {#try.Failure "There are no tokens to parse!"} + {.#End} + {try.#Failure "There are no tokens to parse!"} - {#.Item next _} - {#try.Success [tokens next]}))) + {.#Item next _} + {try.#Success [tokens next]}))) (template [<query> <check> <type> <tag> <eq> <desc>] - [(with_expansions [<failure> (as_is {#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))})] + [(with_expansions [<failure> (as_is {try.#Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))})] (def: .public <query> (Parser <type>) (function (_ tokens) (case tokens - {#.Item [[_ {<tag> x}] tokens']} - {#try.Success [tokens' x]} + {.#Item [[_ {<tag> x}] tokens']} + {try.#Success [tokens' x]} _ <failure>))) @@ -72,45 +72,44 @@ (-> <type> (Parser Any)) (function (_ tokens) (case tokens - {#.Item [[_ {<tag> actual}] tokens']} + {.#Item [[_ {<tag> actual}] tokens']} (if (\ <eq> = expected actual) - {#try.Success [tokens' []]} + {try.#Success [tokens' []]} <failure>) _ <failure>))))] - [bit bit! Bit #.Bit bit.equivalence "bit"] - [nat nat! Nat #.Nat nat.equivalence "nat"] - [int int! Int #.Int int.equivalence "int"] - [rev rev! Rev #.Rev rev.equivalence "rev"] - [frac frac! Frac #.Frac frac.equivalence "frac"] - [text text! Text #.Text text.equivalence "text"] - [identifier identifier! Name #.Identifier name.equivalence "identifier"] - [tag tag! Name #.Tag name.equivalence "tag"] + [bit bit! Bit .#Bit bit.equivalence "bit"] + [nat nat! Nat .#Nat nat.equivalence "nat"] + [int int! Int .#Int int.equivalence "int"] + [rev rev! Rev .#Rev rev.equivalence "rev"] + [frac frac! Frac .#Frac frac.equivalence "frac"] + [text text! Text .#Text text.equivalence "text"] + [identifier identifier! Name .#Identifier name.equivalence "identifier"] ) (def: .public (this! code) (-> Code (Parser Any)) (function (_ tokens) (case tokens - {#.Item [token tokens']} + {.#Item [token tokens']} (if (code\= code token) - {#try.Success [tokens' []]} - {#try.Failure ($_ text\composite "Expected a " (code.format code) " but instead got " (code.format token) + {try.#Success [tokens' []]} + {try.#Failure ($_ text\composite "Expected a " (code.format code) " but instead got " (code.format token) (remaining_inputs tokens))}) _ - {#try.Failure "There are no tokens to parse!"}))) + {try.#Failure "There are no tokens to parse!"}))) (template [<query> <check> <tag> <eq> <desc>] - [(with_expansions [<failure> (as_is {#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))})] + [(with_expansions [<failure> (as_is {try.#Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))})] (def: .public <query> (Parser Text) (function (_ tokens) (case tokens - {#.Item [[_ {<tag> ["" x]}] tokens']} - {#try.Success [tokens' x]} + {.#Item [[_ {<tag> ["" x]}] tokens']} + {try.#Success [tokens' x]} _ <failure>))) @@ -119,16 +118,15 @@ (-> Text (Parser Any)) (function (_ tokens) (case tokens - {#.Item [[_ {<tag> ["" actual]}] tokens']} + {.#Item [[_ {<tag> ["" actual]}] tokens']} (if (\ <eq> = expected actual) - {#try.Success [tokens' []]} + {try.#Success [tokens' []]} <failure>) _ <failure>))))] - [local_identifier local_identifier! #.Identifier text.equivalence "local identifier"] - [ local_tag local_tag! #.Tag text.equivalence "local tag"] + [local_identifier local_identifier! .#Identifier text.equivalence "local identifier"] ) (template [<name> <tag> <desc>] @@ -137,46 +135,46 @@ (-> (Parser a) (Parser a))) (function (_ tokens) (case tokens - {#.Item [[_ {<tag> members}] tokens']} + {.#Item [[_ {<tag> members}] tokens']} (case (p members) - {#try.Success [#.End x]} {#try.Success [tokens' x]} - _ {#try.Failure ($_ text\composite "Parser was expected to fully consume " <desc> (remaining_inputs tokens))}) + {try.#Success [{.#End} x]} {try.#Success [tokens' x]} + _ {try.#Failure ($_ text\composite "Parser was expected to fully consume " <desc> (remaining_inputs tokens))}) _ - {#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))})))] + {try.#Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))})))] - [form #.Form "form"] - [variant #.Variant "variant"] - [tuple #.Tuple "tuple"] + [form .#Form "form"] + [variant .#Variant "variant"] + [tuple .#Tuple "tuple"] ) (def: .public end! (Parser Any) (function (_ tokens) (case tokens - #.End {#try.Success [tokens []]} - _ {#try.Failure ($_ text\composite "Expected list of tokens to be empty!" (remaining_inputs tokens))}))) + {.#End} {try.#Success [tokens []]} + _ {try.#Failure ($_ text\composite "Expected list of tokens to be empty!" (remaining_inputs tokens))}))) (def: .public end? (Parser Bit) (function (_ tokens) - {#try.Success [tokens (case tokens - #.End true - _ false)]})) + {try.#Success [tokens (case tokens + {.#End} true + _ false)]})) (def: .public (result parser inputs) (All (_ a) (-> (Parser a) (List Code) (Try a))) (case (parser inputs) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success [unconsumed value]} + {try.#Success [unconsumed value]} (case unconsumed - #.End - {#try.Success value} + {.#End} + {try.#Success value} _ - {#try.Failure (|> unconsumed + {try.#Failure (|> unconsumed (list\each code.format) (text.interposed ", ") (text\composite "Unconsumed inputs: "))}))) @@ -195,5 +193,5 @@ result (//.or parser ..any)] (case result - {#.Left _} (//.failure (text\composite "Did NOT expect to parse code: " (code.format sample))) - {#.Right output} (in output)))) + {.#Left _} (//.failure (text\composite "Did NOT expect to parse code: " (code.format sample))) + {.#Right output} (in output)))) diff --git a/stdlib/source/library/lux/control/parser/environment.lux b/stdlib/source/library/lux/control/parser/environment.lux index ce254222e..b6a788e24 100644 --- a/stdlib/source/library/lux/control/parser/environment.lux +++ b/stdlib/source/library/lux/control/parser/environment.lux @@ -33,10 +33,10 @@ (-> Property (Parser Text)) (function (_ environment) (case (dictionary.value name environment) - {#.Some value} - {#try.Success [environment value]} + {.#Some value} + {try.#Success [environment value]} - #.None + {.#None} (exception.except ..unknown_property [name])))) (def: .public (result parser environment) diff --git a/stdlib/source/library/lux/control/parser/json.lux b/stdlib/source/library/lux/control/parser/json.lux index 3a0d76c1f..979d7c8a8 100644 --- a/stdlib/source/library/lux/control/parser/json.lux +++ b/stdlib/source/library/lux/control/parser/json.lux @@ -34,26 +34,26 @@ (def: .public (result parser json) (All (_ a) (-> (Parser a) JSON (Try a))) (case (//.result parser (list json)) - {#try.Success [remainder output]} + {try.#Success [remainder output]} (case remainder - #.End - {#try.Success output} + {.#End} + {try.#Success output} _ (exception.except ..unconsumed_input remainder)) - {#try.Failure error} - {#try.Failure error})) + {try.#Failure error} + {try.#Failure error})) (def: .public any (Parser JSON) (<| (function (_ inputs)) (case inputs - #.End + {.#End} (exception.except ..empty_input []) - {#.Item head tail} - {#try.Success [tail head]}))) + {.#Item head tail} + {try.#Success [tail head]}))) (exception: .public (unexpected_value [value JSON]) (exception.report @@ -71,10 +71,10 @@ _ (//.failure (exception.error ..unexpected_value [head])))))] - [null /.Null #/.Null] - [boolean /.Boolean #/.Boolean] - [number /.Number #/.Number] - [string /.String #/.String] + [null /.Null /.#Null] + [boolean /.Boolean /.#Boolean] + [number /.Number /.#Number] + [string /.String /.#String] ) (exception: .public [a] (value_mismatch [reference JSON @@ -108,9 +108,9 @@ _ (//.failure (exception.error ..unexpected_value [head])))))] - [boolean? boolean! /.Boolean bit.equivalence #/.Boolean] - [number? number! /.Number frac.equivalence #/.Number] - [string? string! /.String text.equivalence #/.String] + [boolean? boolean! /.Boolean bit.equivalence /.#Boolean] + [number? number! /.Number frac.equivalence /.#Number] + [string? string! /.String text.equivalence /.#String] ) (def: .public (nullable parser) @@ -123,14 +123,14 @@ (do //.monad [head ..any] (case head - {#/.Array values} + {/.#Array values} (case (//.result parser (row.list values)) - {#try.Failure error} + {try.#Failure error} (//.failure error) - {#try.Success [remainder output]} + {try.#Success [remainder output]} (case remainder - #.End + {.#End} (in output) _ @@ -144,19 +144,19 @@ (do //.monad [head ..any] (case head - {#/.Object kvs} + {/.#Object kvs} (case (|> kvs dictionary.entries (list\each (function (_ [key value]) - (list {#/.String key} value))) + (list {/.#String key} value))) list.together (//.result parser)) - {#try.Failure error} + {try.#Failure error} (//.failure error) - {#try.Success [remainder output]} + {try.#Success [remainder output]} (case remainder - #.End + {.#End} (in output) _ @@ -169,23 +169,23 @@ (All (_ a) (-> Text (Parser a) (Parser a))) (function (recur inputs) (case inputs - (^ (list& {#/.String key} value inputs')) + (^ (list& {/.#String key} value inputs')) (if (text\= key field_name) (case (//.result parser (list value)) - {#try.Success [#.End output]} - {#try.Success [inputs' output]} + {try.#Success [{.#End} output]} + {try.#Success [inputs' output]} - {#try.Success [inputs'' _]} + {try.#Success [inputs'' _]} (exception.except ..unconsumed_input inputs'') - {#try.Failure error} - {#try.Failure error}) + {try.#Failure error} + {try.#Failure error}) (do try.monad [[inputs'' output] (recur inputs')] - (in [(list& {#/.String key} value inputs'') + (in [(list& {/.#String key} value inputs'') output]))) - #.End + {.#End} (exception.except ..empty_input []) _ diff --git a/stdlib/source/library/lux/control/parser/synthesis.lux b/stdlib/source/library/lux/control/parser/synthesis.lux index 1578f9115..0a8db3267 100644 --- a/stdlib/source/library/lux/control/parser/synthesis.lux +++ b/stdlib/source/library/lux/control/parser/synthesis.lux @@ -53,38 +53,38 @@ (def: .public (result parser input) (All (_ a) (-> (Parser a) (List Synthesis) (Try a))) (case (parser input) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success [#.End value]} - {#try.Success value} + {try.#Success [{.#End} value]} + {try.#Success value} - {#try.Success [unconsumed _]} + {try.#Success [unconsumed _]} (exception.except ..unconsumed_input unconsumed))) (def: .public any (Parser Synthesis) (.function (_ input) (case input - #.End + {.#End} (exception.except ..empty_input []) - {#.Item [head tail]} - {#try.Success [tail head]}))) + {.#Item [head tail]} + {try.#Success [tail head]}))) (def: .public end! (Parser Any) (.function (_ tokens) (case tokens - #.End {#try.Success [tokens []]} - _ (exception.except ..expected_empty_input [tokens])))) + {.#End} {try.#Success [tokens []]} + _ (exception.except ..expected_empty_input [tokens])))) (def: .public end? (Parser Bit) (.function (_ tokens) - {#try.Success [tokens (case tokens - #.End true - _ false)]})) + {try.#Success [tokens (case tokens + {.#End} true + _ false)]})) (template [<query> <assertion> <tag> <type> <eq>] [(`` (def: .public <query> @@ -92,7 +92,7 @@ (.function (_ input) (case input (^ (list& (<tag> x) input')) - {#try.Success [input' x]} + {try.#Success [input' x]} _ (exception.except ..cannot_parse input))))) @@ -103,7 +103,7 @@ (case input (^ (list& (<tag> actual) input')) (if (\ <eq> = expected actual) - {#try.Success [input' []]} + {try.#Success [input' []]} (exception.except ..cannot_parse input)) _ @@ -125,7 +125,7 @@ (^ (list& (/.tuple head) tail)) (do try.monad [output (..result parser head)] - {#try.Success [tail output]}) + {try.#Success [tail output]}) _ (exception.except ..cannot_parse input)))) @@ -138,7 +138,7 @@ (if (n.= expected actual) (do try.monad [output (..result parser (list body))] - {#try.Success [tail [environment output]]}) + {try.#Success [tail [environment output]]}) (exception.except ..wrong_arity [expected actual])) _ @@ -152,7 +152,7 @@ (do try.monad [inits (..result init_parsers inits) iteration (..result iteration_parser (list iteration))] - {#try.Success [tail [start inits iteration]]}) + {try.#Success [tail [start inits iteration]]}) _ (exception.except ..cannot_parse input)))) diff --git a/stdlib/source/library/lux/control/parser/text.lux b/stdlib/source/library/lux/control/parser/text.lux index 8594dc353..b887806ba 100644 --- a/stdlib/source/library/lux/control/parser/text.lux +++ b/stdlib/source/library/lux/control/parser/text.lux @@ -58,18 +58,18 @@ (def: .public (result parser input) (All (_ a) (-> (Parser a) Text (Try a))) (case (parser [start_offset input]) - {#try.Failure msg} - {#try.Failure msg} + {try.#Failure msg} + {try.#Failure msg} - {#try.Success [[end_offset _] output]} + {try.#Success [[end_offset _] output]} (if (n.= end_offset (/.size input)) - {#try.Success output} + {try.#Success output} (exception.except ..unconsumed_input [end_offset input])))) (def: .public offset (Parser Offset) (function (_ (^@ input [offset tape])) - {#try.Success [input offset]})) + {try.#Success [input offset]})) (def: (with_slices parser) (-> (Parser (List Slice)) (Parser Slice)) @@ -87,8 +87,8 @@ (Parser Text) (function (_ [offset tape]) (case (/.char offset tape) - {#.Some output} - {#try.Success [[("lux i64 +" 1 offset) tape] (/.of_char output)]} + {.#Some output} + {try.#Success [[("lux i64 +" 1 offset) tape] (/.of_char output)]} _ (exception.except ..cannot_parse [])))) @@ -97,8 +97,8 @@ (Parser Slice) (function (_ [offset tape]) (case (/.char offset tape) - {#.Some _} - {#try.Success [[("lux i64 +" 1 offset) tape] + {.#Some _} + {try.#Success [[("lux i64 +" 1 offset) tape] [#basis offset #distance 1]]} @@ -110,7 +110,7 @@ (All (_ a) (-> (Parser a) (Parser <type>))) (function (_ input) (case (parser input) - {#try.Failure msg} + {try.#Failure msg} (<any> input) _ @@ -128,9 +128,9 @@ (-> Text (Parser Any)) (function (_ [offset tape]) (case (/.index_since offset reference tape) - {#.Some where} + {.#Some where} (if (n.= offset where) - {#try.Success [[("lux i64 +" (/.size reference) offset) tape] + {try.#Success [[("lux i64 +" (/.size reference) offset) tape] []]} (exception.except ..cannot_match [reference])) @@ -141,15 +141,15 @@ (Parser Any) (function (_ (^@ input [offset tape])) (if (n.= offset (/.size tape)) - {#try.Success [input []]} + {try.#Success [input []]} (exception.except ..unconsumed_input input)))) (def: .public next (Parser Text) (function (_ (^@ input [offset tape])) (case (/.char offset tape) - {#.Some output} - {#try.Success [input (/.of_char output)]} + {.#Some output} + {try.#Success [input (/.of_char output)]} _ (exception.except ..cannot_parse [])))) @@ -157,7 +157,7 @@ (def: .public remaining (Parser Text) (function (_ (^@ input [offset tape])) - {#try.Success [input (..left_over offset tape)]})) + {try.#Success [input (..left_over offset tape)]})) (def: .public (range bottom top) (-> Nat Nat (Parser Text)) @@ -211,10 +211,10 @@ (-> Text (Parser Text)) (function (_ [offset tape]) (case (/.char offset tape) - {#.Some output} + {.#Some output} (let [output' (/.of_char output)] (if (<modifier> (/.contains? output' options)) - {#try.Success [[("lux i64 +" 1 offset) tape] output']} + {try.#Success [[("lux i64 +" 1 offset) tape] output']} (exception.except <exception> [options output]))) _ @@ -229,10 +229,10 @@ (-> Text (Parser Slice)) (function (_ [offset tape]) (case (/.char offset tape) - {#.Some output} + {.#Some output} (let [output' (/.of_char output)] (if (<modifier> (/.contains? output' options)) - {#try.Success [[("lux i64 +" 1 offset) tape] + {try.#Success [[("lux i64 +" 1 offset) tape] [#basis offset #distance 1]]} (exception.except <exception> [options output]))) @@ -252,9 +252,9 @@ (-> (-> Char Bit) (Parser Text)) (function (_ [offset tape]) (case (/.char offset tape) - {#.Some output} + {.#Some output} (if (parser output) - {#try.Success [[("lux i64 +" 1 offset) tape] (/.of_char output)]} + {try.#Success [[("lux i64 +" 1 offset) tape] (/.of_char output)]} (exception.except ..character_does_not_satisfy_predicate [output])) _ @@ -340,11 +340,11 @@ (All (_ a) (-> Text (Parser a) (Parser a))) (function (_ real_input) (case (..result parser local_input) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success value} - {#try.Success [real_input value]}))) + {try.#Success value} + {try.#Success [real_input value]}))) (def: .public (slice parser) (-> (Parser Slice) (Parser Text)) @@ -352,10 +352,10 @@ [[basis distance] parser] (function (_ (^@ input [offset tape])) (case (/.clip basis distance tape) - {#.Some output} - {#try.Success [input output]} + {.#Some output} + {try.#Success [input output]} - #.None + {.#None} (exception.except ..cannot_slice []))))) (def: .public (then structured text) diff --git a/stdlib/source/library/lux/control/parser/tree.lux b/stdlib/source/library/lux/control/parser/tree.lux index 68b4336a5..4d331c84f 100644 --- a/stdlib/source/library/lux/control/parser/tree.lux +++ b/stdlib/source/library/lux/control/parser/tree.lux @@ -28,7 +28,7 @@ (def: .public value (All (_ t) (Parser t t)) (function (_ zipper) - {#try.Success [zipper (zipper.value zipper)]})) + {try.#Success [zipper (zipper.value zipper)]})) (exception: .public cannot_move_further) @@ -37,11 +37,11 @@ (All (_ t) (Parser t [])) (function (_ zipper) (case (<direction> zipper) - #.None + {.#None} (exception.except ..cannot_move_further []) - {#.Some next} - {#try.Success [next []]})))] + {.#Some next} + {try.#Success [next []]})))] [down zipper.down] [up zipper.up] diff --git a/stdlib/source/library/lux/control/parser/type.lux b/stdlib/source/library/lux/control/parser/type.lux index 4e2414934..29fab0aa4 100644 --- a/stdlib/source/library/lux/control/parser/type.lux +++ b/stdlib/source/library/lux/control/parser/type.lux @@ -23,7 +23,7 @@ ["[0]" //]) (template: (|recursion_dummy|) - [{#.Primitive "" #.End}]) + [{.#Primitive "" {.#End}}]) (template [<name>] [(exception: .public (<name> [type Type]) @@ -74,13 +74,13 @@ (def: (result' env poly types) (All (_ a) (-> Env (Parser a) (List Type) (Try a))) (case (//.result poly [env types]) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success [[env' remaining] output]} + {try.#Success [[env' remaining] output]} (case remaining - #.End - {#try.Success output} + {.#End} + {try.#Success output} _ (exception.except ..unconsumed_input remaining)))) @@ -92,47 +92,47 @@ (def: .public env (Parser Env) (.function (_ [env inputs]) - {#try.Success [[env inputs] env]})) + {try.#Success [[env inputs] env]})) (def: (with_env temp poly) (All (_ a) (-> Env (Parser a) (Parser a))) (.function (_ [env inputs]) (case (//.result poly [temp inputs]) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success [[_ remaining] output]} - {#try.Success [[env remaining] output]}))) + {try.#Success [[_ remaining] output]} + {try.#Success [[env remaining] output]}))) (def: .public next (Parser Type) (.function (_ [env inputs]) (case inputs - #.End + {.#End} (exception.except ..empty_input []) - {#.Item headT tail} - {#try.Success [[env inputs] headT]}))) + {.#Item headT tail} + {try.#Success [[env inputs] headT]}))) (def: .public any (Parser Type) (.function (_ [env inputs]) (case inputs - #.End + {.#End} (exception.except ..empty_input []) - {#.Item headT tail} - {#try.Success [[env tail] headT]}))) + {.#Item headT tail} + {try.#Success [[env tail] headT]}))) (def: .public (local types poly) (All (_ a) (-> (List Type) (Parser a) (Parser a))) (.function (_ [env pass_through]) (case (result' env poly types) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success output} - {#try.Success [[env pass_through] output]}))) + {try.#Success output} + {try.#Success [[env pass_through] output]}))) (def: (label idx) (-> Nat Code) @@ -146,13 +146,13 @@ (case (//.result poly [(dictionary.has current_id [type g!var] env) inputs]) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success [[_ inputs'] output]} - {#try.Success [[env inputs'] [g!var output]]})))) + {try.#Success [[_ inputs'] output]} + {try.#Success [[env inputs'] [g!var output]]})))) -(template [<name> <flattener> <tag> <exception>] +(template [<name> <flattener> <exception>] [(`` (def: .public (<name> poly) (All (_ a) (-> (Parser a) (Parser a))) (do //.monad @@ -162,8 +162,8 @@ (local members poly) (//.failure (exception.error <exception> headT)))))))] - [variant type.flat_variant #.Sum ..not_variant] - [tuple type.flat_tuple #.Product ..not_tuple] + [variant type.flat_variant ..not_variant] + [tuple type.flat_tuple ..not_tuple] ) (def: polymorphic' @@ -192,8 +192,8 @@ (recur (++ current_arg) (|> env' (dictionary.has funcI [headT funcL]) - (dictionary.has (++ funcI) [{#.Parameter (++ funcI)} varL])) - {#.Item varL all_varsL})) + (dictionary.has (++ funcI) [{.#Parameter (++ funcI)} varL])) + {.#Item varL all_varsL})) (let [partialI (|> current_arg (n.* 2) (n.+ funcI)) partial_varI (++ partialI) partial_varL (label partial_varI) @@ -203,8 +203,8 @@ (recur (++ current_arg) (|> env' (dictionary.has partialI [(|recursion_dummy|) partialC]) - (dictionary.has partial_varI [{#.Parameter partial_varI} partial_varL])) - {#.Item partial_varL all_varsL}))) + (dictionary.has partial_varI [{.#Parameter partial_varI} partial_varL])) + {.#Item partial_varL all_varsL}))) [all_varsL env']))]] (<| (with_env env') (local (list non_poly)) @@ -229,7 +229,7 @@ .let [[funcT paramsT] (type.flat_application (type.anonymous headT))]] (if (n.= 0 (list.size paramsT)) (//.failure (exception.error ..not_application headT)) - (..local {#.Item funcT paramsT} poly)))) + (..local {.#Item funcT paramsT} poly)))) (template [<name> <test>] [(def: .public (<name> expected) @@ -258,12 +258,12 @@ [env ..env headT any] (case headT - {#.Parameter idx} + {.#Parameter idx} (case (dictionary.value (adjusted_idx env idx) env) - {#.Some [poly_type poly_code]} + {.#Some [poly_type poly_code]} (in poly_code) - #.None + {.#None} (//.failure (exception.error ..unknown_parameter headT))) _ @@ -275,10 +275,10 @@ [env ..env headT any] (case headT - {#.Parameter idx} + {.#Parameter idx} (if (n.= id (adjusted_idx env idx)) (in []) - (//.failure (exception.error ..wrong_parameter [{#.Parameter id} headT]))) + (//.failure (exception.error ..wrong_parameter [{.#Parameter id} headT]))) _ (//.failure (exception.error ..not_parameter headT))))) @@ -288,7 +288,7 @@ (do //.monad [headT any] (case headT - {#.Ex ex_id} + {.#Ex ex_id} (in ex_id) _ @@ -299,7 +299,7 @@ (do //.monad [inputT any] (case inputT - {#.Named name anonymousT} + {.#Named name anonymousT} (in [name anonymousT]) _ @@ -310,7 +310,7 @@ (do [! //.monad] [headT any] (case (type.anonymous headT) - (^ {#.Apply (|recursion_dummy|) {#.UnivQ _ headT'}}) + (^ {.#Apply (|recursion_dummy|) {.#UnivQ _ headT'}}) (do ! [[recT _ output] (|> poly (with_extension (|recursion_dummy|)) @@ -327,9 +327,9 @@ [env ..env headT any] (case (type.anonymous headT) - (^multi (^ {#.Apply (|recursion_dummy|) {#.Parameter funcT_idx}}) + (^multi (^ {.#Apply (|recursion_dummy|) {.#Parameter funcT_idx}}) (n.= 0 (adjusted_idx env funcT_idx)) - [(dictionary.value 0 env) {#.Some [self_type self_call]}]) + [(dictionary.value 0 env) {.#Some [self_type self_call]}]) (in self_call) _ diff --git a/stdlib/source/library/lux/control/parser/xml.lux b/stdlib/source/library/lux/control/parser/xml.lux index 6a1eb1206..71fb6fab9 100644 --- a/stdlib/source/library/lux/control/parser/xml.lux +++ b/stdlib/source/library/lux/control/parser/xml.lux @@ -42,13 +42,13 @@ (def: (result' parser attrs documents) (All (_ a) (-> (Parser a) Attrs (List XML) (Try a))) (case (//.result parser [attrs documents]) - {#try.Success [[attrs' remaining] output]} + {try.#Success [[attrs' remaining] output]} (if (list.empty? remaining) - {#try.Success output} + {try.#Success output} (exception.except ..unconsumed_inputs remaining)) - {#try.Failure error} - {#try.Failure error})) + {try.#Failure error} + {try.#Failure error})) (def: .public (result parser documents) (All (_ a) (-> (Parser a) (List XML) (Try a))) @@ -58,55 +58,55 @@ (Parser Text) (function (_ [attrs documents]) (case documents - #.End + {.#End} (exception.except ..empty_input []) - {#.Item head tail} + {.#Item head tail} (case head - {#/.Text value} - {#try.Success [[attrs tail] value]} + {/.#Text value} + {try.#Success [[attrs tail] value]} - {#/.Node _} + {/.#Node _} (exception.except ..unexpected_input []))))) (def: .public tag (Parser Tag) (function (_ [attrs documents]) (case documents - #.End + {.#End} (exception.except ..empty_input []) - {#.Item head _} + {.#Item head _} (case head - {#/.Text _} + {/.#Text _} (exception.except ..unexpected_input []) - {#/.Node tag _ _} - {#try.Success [[attrs documents] tag]})))) + {/.#Node tag _ _} + {try.#Success [[attrs documents] tag]})))) (def: .public (attribute name) (-> Attribute (Parser Text)) (function (_ [attrs documents]) (case (dictionary.value name attrs) - #.None + {.#None} (exception.except ..unknown_attribute [name (dictionary.keys attrs)]) - {#.Some value} - {#try.Success [[attrs documents] value]}))) + {.#Some value} + {try.#Success [[attrs documents] value]}))) (def: .public (node expected parser) (All (_ a) (-> Tag (Parser a) (Parser a))) (function (_ [attrs documents]) (case documents - #.End + {.#End} (exception.except ..empty_input []) - {#.Item head tail} + {.#Item head tail} (case head - {#/.Text _} + {/.#Text _} (exception.except ..unexpected_input []) - {#/.Node actual attrs' children} + {/.#Node actual attrs' children} (if (name\= expected actual) (|> children (..result' parser attrs') @@ -117,11 +117,11 @@ (Parser XML) (function (_ [attrs documents]) (case documents - #.End + {.#End} (exception.except ..empty_input []) - {#.Item head tail} - {#try.Success [[attrs tail] head]}))) + {.#Item head tail} + {try.#Success [[attrs tail] head]}))) (exception: .public nowhere) @@ -129,16 +129,16 @@ (All (_ a) (-> (Parser a) (Parser a))) (function (recur [attrs input]) (case (//.result parser [attrs input]) - {#try.Success [[attrs remaining] output]} - {#try.Success [[attrs remaining] output]} + {try.#Success [[attrs remaining] output]} + {try.#Success [[attrs remaining] output]} - {#try.Failure error} + {try.#Failure error} (case input - #.End + {.#End} (exception.except ..nowhere []) - {#.Item head tail} + {.#Item head tail} (do try.monad [[[attrs tail'] output] (recur [attrs tail])] - (in [[attrs {#.Item head tail'}] + (in [[attrs {.#Item head tail'}] output])))))) diff --git a/stdlib/source/library/lux/control/pipe.lux b/stdlib/source/library/lux/control/pipe.lux index 2f9c81229..7ce13b79d 100644 --- a/stdlib/source/library/lux/control/pipe.lux +++ b/stdlib/source/library/lux/control/pipe.lux @@ -37,7 +37,7 @@ (def: _reversed_ (Parser Any) (function (_ tokens) - {#try.Success [(list.reversed tokens) []]})) + {try.#Success [(list.reversed tokens) []]})) (syntax: .public (cond> [_ _reversed_ prev <code>.any diff --git a/stdlib/source/library/lux/control/reader.lux b/stdlib/source/library/lux/control/reader.lux index e7c59e57b..09431e513 100644 --- a/stdlib/source/library/lux/control/reader.lux +++ b/stdlib/source/library/lux/control/reader.lux @@ -53,7 +53,7 @@ (All (_ M) (-> (Monad M) (All (_ e) (Monad (All (_ a) (Reader e (M a))))))) (def: &functor - (functor.composite ..functor (value@ #monad.&functor monad))) + (functor.composite ..functor (value@ monad.&functor monad))) (def: in (|>> (\ monad in) (\ ..monad in))) diff --git a/stdlib/source/library/lux/control/region.lux b/stdlib/source/library/lux/control/region.lux index 65b8e53e9..0082844a2 100644 --- a/stdlib/source/library/lux/control/region.lux +++ b/stdlib/source/library/lux/control/region.lux @@ -35,20 +35,20 @@ output (Try a)]) (format error (case output - {#try.Success _} + {try.#Success _} "" - {#try.Failure error|output} + {try.#Failure error|output} (format separator error|output)))) (def: (clean clean_up output) (All (_ a) (-> (Try Any) (Try a) (Try a))) (case clean_up - {#try.Success _} + {try.#Success _} output - {#try.Failure error} + {try.#Failure error} (exception.except ..clean_up_error [error output]))) (def: .public (run! monad computation) @@ -65,9 +65,9 @@ (All (_ ! a) (-> (Monad !) (-> a (! (Try Any))) a (All (_ r) (Region r ! a)))) (function (_ [region cleaners]) - (\ monad in [{#.Item (function (_ region) (cleaner value)) + (\ monad in [{.#Item (function (_ region) (cleaner value)) cleaners} - {#try.Success value}]))) + {try.#Success value}]))) (implementation: .public (functor super) (All (_ !) @@ -80,11 +80,11 @@ (\ super each (function (_ [cleaners' temp]) [cleaners' (case temp - {#try.Success value} - {#try.Success (f value)} + {try.#Success value} + {try.#Success (f value)} - {#try.Failure error} - {#try.Failure error})]) + {try.#Failure error} + {try.#Failure error})]) (fa region+cleaners)))))) (implementation: .public (apply super) @@ -93,7 +93,7 @@ (All (_ r) (Apply (Region r !))))) (def: &functor - (..functor (value@ #monad.&functor super))) + (..functor (value@ monad.&functor super))) (def: (on fa ff) (function (_ [region cleaners]) @@ -101,16 +101,16 @@ [[cleaners ef] (ff [region cleaners]) [cleaners ea] (fa [region cleaners])] (case ef - {#try.Success f} + {try.#Success f} (case ea - {#try.Success a} - (in [cleaners {#try.Success (f a)}]) + {try.#Success a} + (in [cleaners {try.#Success (f a)}]) - {#try.Failure error} - (in [cleaners {#try.Failure error}])) + {try.#Failure error} + (in [cleaners {try.#Failure error}])) - {#try.Failure error} - (in [cleaners {#try.Failure error}])))))) + {try.#Failure error} + (in [cleaners {try.#Failure error}])))))) (implementation: .public (monad super) (All (_ !) @@ -118,29 +118,29 @@ (All (_ r) (Monad (Region r !))))) (def: &functor - (..functor (value@ #monad.&functor super))) + (..functor (value@ monad.&functor super))) (def: (in value) (function (_ [region cleaners]) - (\ super in [cleaners {#try.Success value}]))) + (\ super in [cleaners {try.#Success value}]))) (def: (conjoint ffa) (function (_ [region cleaners]) (do super [[cleaners efa] (ffa [region cleaners])] (case efa - {#try.Success fa} + {try.#Success fa} (fa [region cleaners]) - {#try.Failure error} - (in [cleaners {#try.Failure error}])))))) + {try.#Failure error} + (in [cleaners {try.#Failure error}])))))) (def: .public (failure monad error) (All (_ ! a) (-> (Monad !) Text (All (_ r) (Region r ! a)))) (function (_ [region cleaners]) - (\ monad in [cleaners {#try.Failure error}]))) + (\ monad in [cleaners {try.#Failure error}]))) (def: .public (except monad exception message) (All (_ ! e a) @@ -154,5 +154,5 @@ (All (_ r) (Region r ! a)))) (function (_ [region cleaners]) (\ monad each - (|>> {#try.Success} [cleaners]) + (|>> {try.#Success} [cleaners]) operation))) diff --git a/stdlib/source/library/lux/control/remember.lux b/stdlib/source/library/lux/control/remember.lux index dcf7c1c8b..b7047517d 100644 --- a/stdlib/source/library/lux/control/remember.lux +++ b/stdlib/source/library/lux/control/remember.lux @@ -30,10 +30,10 @@ ["Today" (%.date today)] ["Message" message] ["Code" (case focus - {#.Some focus} + {.#Some focus} (%.code focus) - #.None + {.#None} "")])) (def: deadline @@ -44,10 +44,10 @@ (do <>.monad [raw <c>.text] (case (\ date.codec decoded raw) - {#try.Success date} + {try.#Success date} (in date) - {#try.Failure message} + {try.#Failure message} (<>.failure message))))) (syntax: .public (remember [deadline ..deadline @@ -57,10 +57,10 @@ today (instant.date now)] (if (date\< deadline today) (in (case focus - {#.Some focus} + {.#Some focus} (list focus) - #.None + {.#None} (list))) (meta.failure (exception.error ..must_remember [deadline today message focus]))))) @@ -71,10 +71,10 @@ (in (list (` (..remember (~ (code.text (%.date deadline))) (~ (code.text (format <message> " " message))) (~+ (case focus - {#.Some focus} + {.#Some focus} (list focus) - #.None + {.#None} (list)))))))))] [to_do "TODO"] diff --git a/stdlib/source/library/lux/control/try.lux b/stdlib/source/library/lux/control/try.lux index b18a38dd8..eb078497f 100644 --- a/stdlib/source/library/lux/control/try.lux +++ b/stdlib/source/library/lux/control/try.lux @@ -64,7 +64,8 @@ (All (_ !) (-> (Monad !) (Monad (All (_ a) (! (Try a)))))) (def: &functor - (functor.composite (value@ #monad.&functor monad) ..functor)) + (functor.composite (value@ monad.&functor monad) + ..functor)) (def: in (|>> (\ ..monad in) @@ -114,19 +115,19 @@ (-> (Try a) (Maybe a))) (case try {#Success value} - {#.Some value} + {.#Some value} {#Failure message} - #.None)) + {.#None})) (def: .public (of_maybe maybe) (All (_ a) (-> (Maybe a) (Try a))) (case maybe - {#.Some value} + {.#Some value} {#Success value} - #.None + {.#None} {#Failure (`` (("lux in-module" (~~ (static .prelude_module)) .name\encoded) (name_of ..of_maybe)))})) @@ -134,10 +135,10 @@ (case tokens (^ (list else try)) {#Success [compiler (list (` (case (~ try) - {#..Success (~' g!temp)} + {..#Success (~' g!temp)} (~' g!temp) - {#..Failure (~ [location.dummy {#.Identifier ["" ""]}])} + {..#Failure (~ [location.dummy {.#Identifier ["" ""]}])} (~ else))))]} _ diff --git a/stdlib/source/library/lux/control/writer.lux b/stdlib/source/library/lux/control/writer.lux index bcf7e8d77..c30494e56 100644 --- a/stdlib/source/library/lux/control/writer.lux +++ b/stdlib/source/library/lux/control/writer.lux @@ -53,7 +53,7 @@ (All (_ l M) (-> (Monoid l) (Monad M) (Monad (All (_ a) (M (Writer l a)))))) (def: &functor - (functor.composite (value@ #monad.&functor monad) + (functor.composite (value@ monad.&functor monad) ..functor)) (def: in @@ -63,8 +63,8 @@ (def: (conjoint MlMla) (do monad [[l1 Mla] (for [@.old - (: {#.Apply (Writer (:parameter 0) - {#.Apply (Writer (:parameter 0) + (: {.#Apply (Writer (:parameter 0) + {.#Apply (Writer (:parameter 0) (:parameter 2)) (:parameter 1)}) (:parameter 1)} diff --git a/stdlib/source/library/lux/data/binary.lux b/stdlib/source/library/lux/data/binary.lux index e4a07b788..312f74be1 100644 --- a/stdlib/source/library/lux/data/binary.lux +++ b/stdlib/source/library/lux/data/binary.lux @@ -198,13 +198,13 @@ (def: .public (read/8! index binary) (-> Nat Binary (Try I64)) (if (n.< (..!size binary) index) - {#try.Success (!read index binary)} + {try.#Success (!read index binary)} (exception.except ..index_out_of_bounds [(..!size binary) index]))) (def: .public (read/16! index binary) (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 1 index)) - {#try.Success ($_ i64.or + {try.#Success ($_ i64.or (i64.left_shifted 8 (!read index binary)) (!read (n.+ 1 index) binary))} (exception.except ..index_out_of_bounds [(..!size binary) index]))) @@ -212,7 +212,7 @@ (def: .public (read/32! index binary) (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 3 index)) - {#try.Success ($_ i64.or + {try.#Success ($_ i64.or (i64.left_shifted 24 (!read index binary)) (i64.left_shifted 16 (!read (n.+ 1 index) binary)) (i64.left_shifted 8 (!read (n.+ 2 index) binary)) @@ -222,7 +222,7 @@ (def: .public (read/64! index binary) (-> Nat Binary (Try I64)) (if (n.< (..!size binary) (n.+ 7 index)) - {#try.Success ($_ i64.or + {try.#Success ($_ i64.or (i64.left_shifted 56 (!read index binary)) (i64.left_shifted 48 (!read (n.+ 1 index) binary)) (i64.left_shifted 40 (!read (n.+ 2 index) binary)) @@ -236,14 +236,14 @@ (def: .public (write/8! index value binary) (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) index) - {#try.Success (|> binary + {try.#Success (|> binary (!write index value))} (exception.except ..index_out_of_bounds [(..!size binary) index]))) (def: .public (write/16! index value binary) (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) (n.+ 1 index)) - {#try.Success (|> binary + {try.#Success (|> binary (!write index (i64.right_shifted 8 value)) (!write (n.+ 1 index) value))} (exception.except ..index_out_of_bounds [(..!size binary) index]))) @@ -251,7 +251,7 @@ (def: .public (write/32! index value binary) (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (..!size binary) (n.+ 3 index)) - {#try.Success (|> binary + {try.#Success (|> binary (!write index (i64.right_shifted 24 value)) (!write (n.+ 1 index) (i64.right_shifted 16 value)) (!write (n.+ 2 index) (i64.right_shifted 8 value)) @@ -269,8 +269,8 @@ (!write (n.+ 5 index) (i64.right_shifted 16 value)) (!write (n.+ 6 index) (i64.right_shifted 8 value)) (!write (n.+ 7 index) value))] - (|> binary write_high write_low #try.Success))] - {#try.Success (|> binary + (|> binary write_high write_low {try.#Success}))] + {try.#Success (|> binary (!write index (i64.right_shifted 56 value)) (!write (n.+ 1 index) (i64.right_shifted 48 value)) (!write (n.+ 2 index) (i64.right_shifted 40 value)) @@ -329,7 +329,7 @@ (!read (n.+ source_offset index) source) target) (recur (++ index))) - {#try.Success target}))))))) + {try.#Success target}))))))) (def: .public (slice offset length binary) (-> Nat Nat Binary (Try Binary)) @@ -337,7 +337,7 @@ limit (n.+ length offset)] (if (n.> size limit) (exception.except ..slice_out_of_bounds [size offset length]) - (with_expansions [<jvm> (as_is {#try.Success (java/util/Arrays::copyOfRange binary (.int offset) (.int limit))})] + (with_expansions [<jvm> (as_is {try.#Success (java/util/Arrays::copyOfRange binary (.int offset) (.int limit))})] (for [@.old <jvm> @.jvm <jvm>] @@ -350,10 +350,10 @@ 0 binary _ (let [distance (n.- bytes (..!size binary))] (case (..slice bytes distance binary) - {#try.Success slice} + {try.#Success slice} slice - {#try.Failure _} + {try.#Failure _} (..empty 0))))) (implementation: .public monoid diff --git a/stdlib/source/library/lux/data/bit.lux b/stdlib/source/library/lux/data/bit.lux index d78777213..831497deb 100644 --- a/stdlib/source/library/lux/data/bit.lux +++ b/stdlib/source/library/lux/data/bit.lux @@ -56,9 +56,9 @@ (def: (decoded input) (case input - "#1" {#.Right #1} - "#0" {#.Right #0} - _ {#.Left "Wrong syntax for Bit."}))) + "#1" {.#Right #1} + "#0" {.#Right #0} + _ {.#Left "Wrong syntax for Bit."}))) (def: .public complement (All (_ a) (-> (-> a Bit) (-> a Bit))) diff --git a/stdlib/source/library/lux/data/collection/array.lux b/stdlib/source/library/lux/data/collection/array.lux index 73cc3e9d0..08cfac991 100644 --- a/stdlib/source/library/lux/data/collection/array.lux +++ b/stdlib/source/library/lux/data/collection/array.lux @@ -22,7 +22,7 @@ "#Array") (type: .public (Array a) - {#.Primitive ..type_name {#.Item a #.End}}) + {.#Primitive ..type_name {.#Item a {.#End}}}) (with_expansions [<index_type> (primitive "java.lang.Long") <elem_type> (primitive "java.lang.Object") @@ -78,8 +78,8 @@ (template: (!read! <read!> <null?>) [(let [output (<read!> index array)] (if (<null?> output) - #.None - {#.Some output}))]) + {.#None} + {.#Some output}))]) (def: .public (read! index array) (All (_ a) @@ -88,16 +88,16 @@ (for [@.old (let [value ("jvm aaload" array index)] (if ("jvm object null?" value) - #.None - {#.Some value})) + {.#None} + {.#Some value})) @.jvm (let [value (|> array (:as <array_type>) ("jvm array read object" (!int index)))] (if ("jvm object null?" value) - #.None - {#.Some (:expected value)})) + {.#None} + {.#Some (:expected value)})) @.js (!read! "js array read" "js object undefined?") @.python (!read! "python array read" "python object none?") @@ -105,7 +105,7 @@ @.ruby (!read! "ruby array read" "ruby object nil?") @.php (!read! "php array read" "php object null?") @.scheme (!read! "scheme array read" "scheme object nil?")]) - #.None)) + {.#None})) (def: .public (write! index value array) (All (_ a) @@ -149,7 +149,7 @@ (All (_ a) (-> Nat (Array a) Bit)) (case (..read! index array) - {#.Some _} + {.#Some _} true _ @@ -159,10 +159,10 @@ (All (_ a) (-> Nat (-> a a) (Array a) (Array a))) (case (read! index array) - #.None + {.#None} array - {#.Some value} + {.#Some value} (write! index (transform value) array))) (def: .public (upsert! index default transform array) @@ -180,10 +180,10 @@ dest_array (list\mix (function (_ offset target) (case (read! (n.+ offset src_start) src_array) - #.None + {.#None} target - {#.Some value} + {.#Some value} (write! (n.+ offset dest_start) value target))) dest_array (list.indices length)))) @@ -192,10 +192,10 @@ (All (_ a) (-> (Array a) Nat)) (list\mix (function (_ idx count) (case (read! idx array) - #.None + {.#None} count - {#.Some _} + {.#Some _} (++ count))) 0 (list.indices (size array)))) @@ -209,10 +209,10 @@ (-> (Predicate a) (Array a) (Array a))) (list\mix (function (_ idx xs') (case (read! idx xs) - #.None + {.#None} xs' - {#.Some x} + {.#Some x} (if (p x) xs' (delete! idx xs')))) @@ -226,14 +226,14 @@ (loop [idx 0] (if (n.< arr_size idx) (case (read! idx xs) - #.None + {.#None} (recur (++ idx)) - {#.Some x} + {.#Some x} (if (p x) - {#.Some x} + {.#Some x} (recur (++ idx)))) - #.None)))) + {.#None})))) (def: .public (example+ p xs) (All (_ a) @@ -242,24 +242,24 @@ (loop [idx 0] (if (n.< arr_size idx) (case (read! idx xs) - #.None + {.#None} (recur (++ idx)) - {#.Some x} + {.#Some x} (if (p idx x) - {#.Some [idx x]} + {.#Some [idx x]} (recur (++ idx)))) - #.None)))) + {.#None})))) (def: .public (clone xs) (All (_ a) (-> (Array a) (Array a))) (let [arr_size (size xs)] (list\mix (function (_ idx ys) (case (read! idx xs) - #.None + {.#None} ys - {#.Some x} + {.#Some x} (write! idx x ys))) (empty arr_size) (list.indices arr_size)))) @@ -278,7 +278,7 @@ (def: (list|-default array) (All (_ a) (-> (Array a) (List a))) (loop [idx (-- (size array)) - output #.End] + output {.#End}] (case idx (^ (static ..underflow)) output @@ -286,32 +286,32 @@ _ (recur (-- idx) (case (read! idx array) - {#.Some head} - {#.Item head output} + {.#Some head} + {.#Item head output} - #.None + {.#None} output))))) (def: (list|+default default array) (All (_ a) (-> a (Array a) (List a))) (loop [idx (-- (size array)) - output #.End] + output {.#End}] (case idx (^ (static ..underflow)) output _ (recur (-- idx) - {#.Item (maybe.else default (read! idx array)) + {.#Item (maybe.else default (read! idx array)) output})))) (def: .public (list default array) (All (_ a) (-> (Maybe a) (Array a) (List a))) (case default - {#.Some default} + {.#Some default} (list|+default default array) - #.None + {.#None} (list|-default array))) (implementation: .public (equivalence (^open ",\[0]")) @@ -324,10 +324,10 @@ (list\mix (function (_ idx prev) (and prev (case [(read! idx xs) (read! idx ys)] - [#.None #.None] + [{.#None} {.#None}] true - [{#.Some x} {#.Some y}] + [{.#Some x} {.#Some y}] (,\= x y) _ @@ -356,10 +356,10 @@ (empty arr_size) (list\mix (function (_ idx mb) (case (read! idx ma) - #.None + {.#None} mb - {#.Some x} + {.#Some x} (write! idx (f x) mb))) (empty arr_size) (list.indices arr_size)) @@ -374,10 +374,10 @@ idx 0] (if (n.< arr_size idx) (case (read! idx xs) - #.None + {.#None} (recur so_far (++ idx)) - {#.Some value} + {.#Some value} (recur (f value so_far) (++ idx))) so_far))))) @@ -390,11 +390,11 @@ (loop [idx 0] (if (n.< size idx) (case (..read! idx array) - {#.Some value} + {.#Some value} (<op> (predicate value) (recur (++ idx))) - #.None + {.#None} (recur (++ idx))) <init>)))))] diff --git a/stdlib/source/library/lux/data/collection/dictionary.lux b/stdlib/source/library/lux/data/collection/dictionary.lux index 0b9690eb3..bdfc2638a 100644 --- a/stdlib/source/library/lux/data/collection/dictionary.lux +++ b/stdlib/source/library/lux/data/collection/dictionary.lux @@ -240,12 +240,12 @@ (product.right (list\mix (function (_ idx [insertion_idx node]) (let [[bitmap base] node] (case (array.read! idx h_array) - #.None [insertion_idx node] - {#.Some sub_node} (if (n.= except_idx idx) + {.#None} [insertion_idx node] + {.#Some sub_node} (if (n.= except_idx idx) [insertion_idx node] [(++ insertion_idx) [(with_bit_position (to_bit_position idx) bitmap) - (array.write! insertion_idx {#.Left sub_node} base)]]) + (array.write! insertion_idx {.#Left sub_node} base)]]) ))) [0 [clean_bitmap (array.empty (-- h_size))]] @@ -268,15 +268,15 @@ bitmap) [(++ base_idx) (case (array.read! base_idx base) - {#.Some {#.Left sub_node}} + {.#Some {.#Left sub_node}} (array.write! hierarchy_idx sub_node h_array) - {#.Some {#.Right [key' val']}} + {.#Some {.#Right [key' val']}} (array.write! hierarchy_idx (node\has (level_up level) (\ key_hash hash key') key' val' key_hash empty_node) h_array) - #.None + {.#None} (undefined))] default)) [0 @@ -303,7 +303,7 @@ {#Hierarchy _size hierarchy} (let [idx (level_index level hash) [_size' sub_node] (case (array.read! idx hierarchy) - {#.Some sub_node} + {.#Some sub_node} [_size sub_node] _ @@ -321,18 +321,18 @@ (let [idx (base_index bit bitmap)] (case (array.read! idx base) ... If it's being used by a node, add the KV to it. - {#.Some {#.Left sub_node}} + {.#Some {.#Left sub_node}} (let [sub_node' (node\has (level_up level) hash key val key_hash sub_node)] - {#Base bitmap (array\revised idx {#.Left sub_node'} base)}) + {#Base bitmap (array\revised idx {.#Left sub_node'} base)}) ... Otherwise, if it's being used by a KV, compare the keys. - {#.Some {#.Right key' val'}} + {.#Some {.#Right key' val'}} (if (\ key_hash = key key') ... If the same key is found, replace the value. - {#Base bitmap (array\revised idx {#.Right key val} base)} + {#Base bitmap (array\revised idx {.#Right key val} base)} ... Otherwise, compare the hashes of the keys. {#Base bitmap (array\revised idx - {#.Left (let [hash' (\ key_hash hash key')] + {.#Left (let [hash' (\ key_hash hash key')] (if (n.= hash hash') ... If the hashes are ... the same, a new @@ -352,7 +352,7 @@ (node\has next_level hash key val key_hash)))))} base)}) - #.None + {.#None} (undefined))) ... However, if the Bit_Position has not been used yet, check ... whether this #Base node is ready for a promotion. @@ -361,7 +361,7 @@ ... If so, resize the #Base node to accommodate the ... new KV-pair. {#Base (with_bit_position bit bitmap) - (array\has (base_index bit bitmap) {#.Right [key val]} base)} + (array\has (base_index bit bitmap) {.#Right [key val]} base)} ... Otherwise, promote it to a #Hierarchy node, and add the new ... KV-pair as a singleton node to it. {#Hierarchy (++ base_count) @@ -378,17 +378,17 @@ (case (collision_index key_hash key _colls) ... If the key was already present in the collisions-list, its ... value gets updated. - {#.Some coll_idx} + {.#Some coll_idx} {#Collisions _hash (array\revised coll_idx [key val] _colls)} ... Otherwise, the KV-pair is added to the collisions-list. - #.None + {.#None} {#Collisions _hash (array\has (array.size _colls) [key val] _colls)}) ... If the hashes are not equal, create a new #Base node that ... contains the old #Collisions node, plus the new KV-pair. (|> {#Base (level_bit_position level _hash) (|> (array.empty 1) - (array.write! 0 {#.Left node}))} + (array.write! 0 {.#Left node}))} (node\has level hash key val key_hash))) )) @@ -401,11 +401,11 @@ (let [idx (level_index level hash)] (case (array.read! idx h_array) ... If not, there's nothing to remove. - #.None + {.#None} node ... But if there is, try to remove the key from the sub-node. - {#.Some sub_node} + {.#Some sub_node} (let [sub_node' (node\lacks (level_up level) hash key key_hash sub_node)] ... Then check if a removal was actually done. (if (same? sub_node sub_node') @@ -431,7 +431,7 @@ (case (array.read! idx base) ... If set, check if it's a sub_node, and remove the KV ... from it. - {#.Some {#.Left sub_node}} + {.#Some {.#Left sub_node}} (let [sub_node' (node\lacks (level_up level) hash key key_hash sub_node)] ... Verify that it was removed. (if (same? sub_node sub_node') @@ -450,10 +450,10 @@ ... But, if it did not come out empty, then the ... position is kept, and the node gets updated. {#Base bitmap - (array\revised idx {#.Left sub_node'} base)}))) + (array\revised idx {.#Left sub_node'} base)}))) ... If, however, there was a KV-pair instead of a sub-node. - {#.Some {#.Right [key' val']}} + {.#Some {.#Right [key' val']}} ... Check if the keys match. (if (\ key_hash = key key') ... If so, remove the KV-pair and unset the Bit_Position. @@ -462,7 +462,7 @@ ... Otherwise, there's nothing to remove. node) - #.None + {.#None} (undefined))) ... If the Bit_Position is not set, there's nothing to remove. node)) @@ -471,11 +471,11 @@ {#Collisions _hash _colls} (case (collision_index key_hash key _colls) ... If not, then there's nothing to remove. - #.None + {.#None} node ... But if so, then check the size of the collisions list. - {#.Some idx} + {.#Some idx} (if (n.= 1 (array.size _colls)) ... If there's only one left, then removing it leaves us with ... an empty node. @@ -490,25 +490,25 @@ ... For #Hierarchy nodes, just look-up the key on its children. {#Hierarchy _size hierarchy} (case (array.read! (level_index level hash) hierarchy) - #.None #.None - {#.Some sub_node} (node\value (level_up level) hash key key_hash sub_node)) + {.#None} {.#None} + {.#Some sub_node} (node\value (level_up level) hash key key_hash sub_node)) ... For #Base nodes, check the leaves, and recursively check the branches. {#Base bitmap base} (let [bit (level_bit_position level hash)] (if (with_bit_position? bit bitmap) (case (array.read! (base_index bit bitmap) base) - {#.Some {#.Left sub_node}} + {.#Some {.#Left sub_node}} (node\value (level_up level) hash key key_hash sub_node) - {#.Some {#.Right [key' val']}} + {.#Some {.#Right [key' val']}} (if (\ key_hash = key key') - {#.Some val'} - #.None) + {.#Some val'} + {.#None}) - #.None + {.#None} (undefined)) - #.None)) + {.#None})) ... For #Collisions nodes, do a linear scan of all the known KV-pairs. {#Collisions _hash _colls} @@ -526,8 +526,8 @@ {#Base _ base} (array\mix n.+ 0 (array\each (function (_ sub_node') (case sub_node' - {#.Left sub_node} (node\size sub_node) - {#.Right _} 1)) + {.#Left sub_node} (node\size sub_node) + {.#Right _} 1)) base)) {#Collisions hash colls} @@ -539,23 +539,23 @@ (case node {#Hierarchy _size hierarchy} (array\mix (function (_ sub_node tail) (list\composite (node\entries sub_node) tail)) - #.End + {.#End} hierarchy) {#Base bitmap base} (array\mix (function (_ branch tail) (case branch - {#.Left sub_node} + {.#Left sub_node} (list\composite (node\entries sub_node) tail) - {#.Right [key' val']} - {#.Item [key' val'] tail})) - #.End + {.#Right [key' val']} + {.#Item [key' val'] tail})) + {.#End} base) {#Collisions hash colls} - (array\mix (function (_ [key' val'] tail) {#.Item [key' val'] tail}) - #.End + (array\mix (function (_ [key' val'] tail) {.#Item [key' val'] tail}) + {.#End} colls))) (type: .public (Dictionary k v) @@ -565,7 +565,7 @@ (def: .public key_hash (All (_ k v) (-> (Dictionary k v) (Hash k))) - (value@ #..hash)) + (value@ ..#hash)) (def: .public (empty key_hash) (All (_ k v) (-> (Hash k) (Dictionary k v))) @@ -590,24 +590,24 @@ (def: .public (key? dict key) (All (_ k v) (-> (Dictionary k v) k Bit)) (case (value key dict) - #.None #0 - {#.Some _} #1)) + {.#None} #0 + {.#Some _} #1)) (exception: .public key_already_exists) (def: .public (has' key val dict) (All (_ k v) (-> k v (Dictionary k v) (Try (Dictionary k v)))) (case (value key dict) - #.None {#try.Success (has key val dict)} - {#.Some _} (exception.except ..key_already_exists []))) + {.#None} {try.#Success (has key val dict)} + {.#Some _} (exception.except ..key_already_exists []))) (def: .public (revised key f dict) (All (_ k v) (-> k (-> v v) (Dictionary k v) (Dictionary k v))) (case (value key dict) - #.None + {.#None} dict - {#.Some val} + {.#Some val} (has key (f val) dict))) (def: .public (revised' key default f dict) @@ -641,8 +641,8 @@ (All (_ k v) (-> (Dictionary k v) (List <side>))) (|>> ..entries (list\mix (function (_ [k v] bundle) - {#.Item <side> bundle}) - #.End)))] + {.#Item <side> bundle}) + {.#End})))] [k keys] [v values] @@ -658,10 +658,10 @@ (All (_ k v) (-> (-> v v v) (Dictionary k v) (Dictionary k v) (Dictionary k v))) (list\mix (function (_ [key val2] dict) (case (value key dict) - #.None + {.#None} (has key val2 dict) - {#.Some val1} + {.#Some val1} (has key (f val2 val1) dict))) dict1 (entries dict2))) @@ -669,10 +669,10 @@ (def: .public (re_bound from_key to_key dict) (All (_ k v) (-> k k (Dictionary k v) (Dictionary k v))) (case (value from_key dict) - #.None + {.#None} dict - {#.Some val} + {.#Some val} (|> dict (lacks from_key) (has to_key val)))) @@ -682,8 +682,8 @@ (let [[key_hash _] dict] (list\mix (function (_ key new_dict) (case (value key dict) - #.None new_dict - {#.Some val} (has key val new_dict))) + {.#None} new_dict + {.#Some val} (has key val new_dict))) (empty key_hash) keys))) @@ -695,7 +695,7 @@ (..size subject)) (list.every? (function (_ [k rv]) (case (..value k subject) - {#.Some sv} + {.#Some sv} (,\= rv sv) _ @@ -713,11 +713,11 @@ {#Base bitmap base} {#Base bitmap (array\each (function (_ either) (case either - {#.Left fa'} - {#.Left (each f fa')} + {.#Left fa'} + {.#Left (each f fa')} - {#.Right [k v]} - {#.Right [k (f v)]})) + {.#Right [k v]} + {.#Right [k (f v)]})) base)} {#Collisions hash collisions} diff --git a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux index d6376e88b..1fc2e3ea5 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux @@ -20,8 +20,8 @@ (type: Color (Variant - #Red - #Black)) + {#Red} + {#Black})) (type: (Node k v) (Record @@ -34,7 +34,7 @@ (template [<create> <color>] [(def: (<create> key value left right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) - [#color <color> + [#color {<color>} #key key #value value #left left @@ -52,7 +52,7 @@ (def: .public (empty order) (All (_ k v) (-> (Order k) (Dictionary k v))) [#&order order - #root #.None]) + #root {.#None}]) ... TODO: Doing inneficient access of Order functions due to compiler bug. ... TODO: Must improve it as soon as bug is fixed. @@ -62,14 +62,14 @@ ] (loop [node (value@ #root dict)] (case node - #.None - #.None + {.#None} + {.#None} - {#.Some node} + {.#Some node} (let [node_key (value@ #key node)] (cond (\ dict = node_key key) ... (_\= node_key key) - {#.Some (value@ #value node)} + {.#Some (value@ #value node)} (\ dict < node_key key) ... (_\< node_key key) @@ -87,10 +87,10 @@ ] (loop [node (value@ #root dict)] (case node - #.None + {.#None} #0 - {#.Some node} + {.#Some node} (let [node_key (value@ #key node)] (or (\ dict = node_key key) ... (_\= node_key key) @@ -103,16 +103,16 @@ [(def: .public (<name> dict) (All (_ k v) (-> (Dictionary k v) (Maybe v))) (case (value@ #root dict) - #.None - #.None + {.#None} + {.#None} - {#.Some node} + {.#Some node} (loop [node node] (case (value@ <side> node) - #.None - {#.Some (value@ #value node)} + {.#None} + {.#Some (value@ #value node)} - {#.Some side} + {.#Some side} (recur side)))))] [min #left] @@ -123,10 +123,10 @@ (All (_ k v) (-> (Dictionary k v) Nat)) (loop [node (value@ #root dict)] (case node - #.None + {.#None} 0 - {#.Some node} + {.#Some node} (++ (n.+ (recur (value@ #left node)) (recur (value@ #right node))))))) @@ -138,10 +138,10 @@ [(def: (<name> self) (All (_ k v) (-> (Node k v) (Node k v))) (case (value@ #color self) - <other_color> - (with@ #color <self_color> self) + {<other_color>} + (with@ #color {<self_color>} self) - <self_color> + {<self_color>} <no_change> ))] @@ -152,42 +152,42 @@ (def: (with_left addition center) (All (_ k v) (-> (Node k v) (Node k v) (Node k v))) (case (value@ #color center) - #Red + {#Red} (red (value@ #key center) (value@ #value center) - {#.Some addition} + {.#Some addition} (value@ #right center)) - #Black + {#Black} (with_expansions [<default_behavior> (as_is (black (value@ #key center) (value@ #value center) - {#.Some addition} + {.#Some addition} (value@ #right center)))] (case (value@ #color addition) - #Red + {#Red} (case (value@ #left addition) - (^multi {#.Some left} - [(value@ #color left) #Red]) + (^multi {.#Some left} + [(value@ #color left) {#Red}]) (red (value@ #key addition) (value@ #value addition) - {#.Some (blackened left)} - {#.Some (black (value@ #key center) + {.#Some (blackened left)} + {.#Some (black (value@ #key center) (value@ #value center) (value@ #right addition) (value@ #right center))}) _ (case (value@ #right addition) - (^multi {#.Some right} - [(value@ #color right) #Red]) + (^multi {.#Some right} + [(value@ #color right) {#Red}]) (red (value@ #key right) (value@ #value right) - {#.Some (black (value@ #key addition) + {.#Some (black (value@ #key addition) (value@ #value addition) (value@ #left addition) (value@ #left right))} - {#.Some (black (value@ #key center) + {.#Some (black (value@ #key center) (value@ #value center) (value@ #right right) (value@ #right center))}) @@ -195,48 +195,48 @@ _ <default_behavior>)) - #Black + {#Black} <default_behavior>)))) (def: (with_right addition center) (All (_ k v) (-> (Node k v) (Node k v) (Node k v))) (case (value@ #color center) - #Red + {#Red} (red (value@ #key center) (value@ #value center) (value@ #left center) - {#.Some addition}) + {.#Some addition}) - #Black + {#Black} (with_expansions [<default_behavior> (as_is (black (value@ #key center) (value@ #value center) (value@ #left center) - {#.Some addition}))] + {.#Some addition}))] (case (value@ #color addition) - #Red + {#Red} (case (value@ #right addition) - (^multi {#.Some right} - [(value@ #color right) #Red]) + (^multi {.#Some right} + [(value@ #color right) {#Red}]) (red (value@ #key addition) (value@ #value addition) - {#.Some (black (value@ #key center) + {.#Some (black (value@ #key center) (value@ #value center) (value@ #left center) (value@ #left addition))} - {#.Some (blackened right)}) + {.#Some (blackened right)}) _ (case (value@ #left addition) - (^multi {#.Some left} - [(value@ #color left) #Red]) + (^multi {.#Some left} + [(value@ #color left) {#Red}]) (red (value@ #key left) (value@ #value left) - {#.Some (black (value@ #key center) + {.#Some (black (value@ #key center) (value@ #value center) (value@ #left center) (value@ #left left))} - {#.Some (black (value@ #key addition) + {.#Some (black (value@ #key addition) (value@ #value addition) (value@ #right left) (value@ #right addition))}) @@ -244,7 +244,7 @@ _ <default_behavior>)) - #Black + {#Black} <default_behavior>)))) (def: .public (has key value dict) @@ -252,10 +252,10 @@ (let [(^open "_\[0]") (value@ #&order dict) root' (loop [?root (value@ #root dict)] (case ?root - #.None - {#.Some (red key value #.None #.None)} + {.#None} + {.#Some (red key value {.#None} {.#None})} - {#.Some root} + {.#Some root} (let [reference (value@ #key root)] (`` (cond (~~ (template [<comp> <tag> <add>] [(<comp> reference key) @@ -263,15 +263,15 @@ outcome (recur side_root)] (if (same? side_root outcome) ?root - {#.Some (<add> (maybe.trusted outcome) + {.#Some (<add> (maybe.trusted outcome) root)}))] - [_\< #left ..with_left] + [_\< #left ..with_left] [(order.> (value@ #&order dict)) #right ..with_right] )) ... (_\= reference key) - {#.Some (with@ #value value root)} + {.#Some (with@ #value value root)} ))) ))] (with@ #root root' dict))) @@ -279,26 +279,26 @@ (def: (left_balanced key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?left - (^multi {#.Some left} - [(value@ #color left) #Red] - [(value@ #left left) {#.Some left>>left}] - [(value@ #color left>>left) #Red]) + (^multi {.#Some left} + [(value@ #color left) {#Red}] + [(value@ #left left) {.#Some left>>left}] + [(value@ #color left>>left) {#Red}]) (red (value@ #key left) (value@ #value left) - {#.Some (blackened left>>left)} - {#.Some (black key value (value@ #right left) ?right)}) + {.#Some (blackened left>>left)} + {.#Some (black key value (value@ #right left) ?right)}) - (^multi {#.Some left} - [(value@ #color left) #Red] - [(value@ #right left) {#.Some left>>right}] - [(value@ #color left>>right) #Red]) + (^multi {.#Some left} + [(value@ #color left) {#Red}] + [(value@ #right left) {.#Some left>>right}] + [(value@ #color left>>right) {#Red}]) (red (value@ #key left>>right) (value@ #value left>>right) - {#.Some (black (value@ #key left) + {.#Some (black (value@ #key left) (value@ #value left) (value@ #left left) (value@ #left left>>right))} - {#.Some (black key value + {.#Some (black key value (value@ #right left>>right) ?right)}) @@ -308,23 +308,23 @@ (def: (right_balanced key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?right - (^multi {#.Some right} - [(value@ #color right) #Red] - [(value@ #right right) {#.Some right>>right}] - [(value@ #color right>>right) #Red]) + (^multi {.#Some right} + [(value@ #color right) {#Red}] + [(value@ #right right) {.#Some right>>right}] + [(value@ #color right>>right) {#Red}]) (red (value@ #key right) (value@ #value right) - {#.Some (black key value ?left (value@ #left right))} - {#.Some (blackened right>>right)}) + {.#Some (black key value ?left (value@ #left right))} + {.#Some (blackened right>>right)}) - (^multi {#.Some right} - [(value@ #color right) #Red] - [(value@ #left right) {#.Some right>>left}] - [(value@ #color right>>left) #Red]) + (^multi {.#Some right} + [(value@ #color right) {#Red}] + [(value@ #left right) {.#Some right>>left}] + [(value@ #color right>>left) {#Red}]) (red (value@ #key right>>left) (value@ #value right>>left) - {#.Some (black key value ?left (value@ #left right>>left))} - {#.Some (black (value@ #key right) + {.#Some (black key value ?left (value@ #left right>>left))} + {.#Some (black (value@ #key right) (value@ #value right) (value@ #right right>>left) (value@ #right right))}) @@ -335,24 +335,24 @@ (def: (without_left key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?left - (^multi {#.Some left} - [(value@ #color left) #Red]) - (red key value {#.Some (blackened left)} ?right) + (^multi {.#Some left} + [(value@ #color left) {#Red}]) + (red key value {.#Some (blackened left)} ?right) _ (case ?right - (^multi {#.Some right} - [(value@ #color right) #Black]) - (right_balanced key value ?left {#.Some (reddened right)}) - - (^multi {#.Some right} - [(value@ #color right) #Red] - [(value@ #left right) {#.Some right>>left}] - [(value@ #color right>>left) #Black]) + (^multi {.#Some right} + [(value@ #color right) {#Black}]) + (right_balanced key value ?left {.#Some (reddened right)}) + + (^multi {.#Some right} + [(value@ #color right) {#Red}] + [(value@ #left right) {.#Some right>>left}] + [(value@ #color right>>left) {#Black}]) (red (value@ #key right>>left) (value@ #value right>>left) - {#.Some (black key value ?left (value@ #left right>>left))} - {#.Some (right_balanced (value@ #key right) + {.#Some (black key value ?left (value@ #left right>>left))} + {.#Some (right_balanced (value@ #key right) (value@ #value right) (value@ #right right>>left) (\ maybe.functor each reddened (value@ #right right)))}) @@ -364,27 +364,27 @@ (def: (without_right key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?right - (^multi {#.Some right} - [(value@ #color right) #Red]) - (red key value ?left {#.Some (blackened right)}) + (^multi {.#Some right} + [(value@ #color right) {#Red}]) + (red key value ?left {.#Some (blackened right)}) _ (case ?left - (^multi {#.Some left} - [(value@ #color left) #Black]) - (left_balanced key value {#.Some (reddened left)} ?right) - - (^multi {#.Some left} - [(value@ #color left) #Red] - [(value@ #right left) {#.Some left>>right}] - [(value@ #color left>>right) #Black]) + (^multi {.#Some left} + [(value@ #color left) {#Black}]) + (left_balanced key value {.#Some (reddened left)} ?right) + + (^multi {.#Some left} + [(value@ #color left) {#Red}] + [(value@ #right left) {.#Some left>>right}] + [(value@ #color left>>right) {#Black}]) (red (value@ #key left>>right) (value@ #value left>>right) - {#.Some (left_balanced (value@ #key left) + {.#Some (left_balanced (value@ #key left) (value@ #value left) (\ maybe.functor each reddened (value@ #left left)) (value@ #left left>>right))} - {#.Some (black key value (value@ #right left>>right) ?right)}) + {.#Some (black key value (value@ #right left>>right) ?right)}) _ (panic! error_message) @@ -393,76 +393,76 @@ (def: (prepended ?left ?right) (All (_ k v) (-> (Maybe (Node k v)) (Maybe (Node k v)) (Maybe (Node k v)))) (case [?left ?right] - [#.None _] + [{.#None} _] ?right - [_ #.None] + [_ {.#None}] ?left - [{#.Some left} {#.Some right}] + [{.#Some left} {.#Some right}] (case [(value@ #color left) (value@ #color right)] - [#Red #Red] + [{#Red} {#Red}] (do maybe.monad [fused (prepended (value@ #right left) (value@ #right right))] (case (value@ #color fused) - #Red + {#Red} (in (red (value@ #key fused) (value@ #value fused) - {#.Some (red (value@ #key left) + {.#Some (red (value@ #key left) (value@ #value left) (value@ #left left) (value@ #left fused))} - {#.Some (red (value@ #key right) + {.#Some (red (value@ #key right) (value@ #value right) (value@ #right fused) (value@ #right right))})) - #Black + {#Black} (in (red (value@ #key left) (value@ #value left) (value@ #left left) - {#.Some (red (value@ #key right) + {.#Some (red (value@ #key right) (value@ #value right) - {#.Some fused} + {.#Some fused} (value@ #right right))})))) - [#Red #Black] - {#.Some (red (value@ #key left) + [{#Red} {#Black}] + {.#Some (red (value@ #key left) (value@ #value left) (value@ #left left) (prepended (value@ #right left) ?right))} - [#Black #Red] - {#.Some (red (value@ #key right) + [{#Black} {#Red}] + {.#Some (red (value@ #key right) (value@ #value right) (prepended ?left (value@ #left right)) (value@ #right right))} - [#Black #Black] + [{#Black} {#Black}] (do maybe.monad [fused (prepended (value@ #right left) (value@ #left right))] (case (value@ #color fused) - #Red + {#Red} (in (red (value@ #key fused) (value@ #value fused) - {#.Some (black (value@ #key left) + {.#Some (black (value@ #key left) (value@ #value left) (value@ #left left) (value@ #left fused))} - {#.Some (black (value@ #key right) + {.#Some (black (value@ #key right) (value@ #value right) (value@ #right fused) (value@ #right right))})) - #Black + {#Black} (in (without_left (value@ #key left) (value@ #value left) (value@ #left left) - {#.Some (black (value@ #key right) + {.#Some (black (value@ #key right) (value@ #value right) - {#.Some fused} + {.#Some fused} (value@ #right right))})) )) ) @@ -475,10 +475,10 @@ (let [(^open "_\[0]") (value@ #&order dict) [?root found?] (loop [?root (value@ #root dict)] (case ?root - #.None - [#.None #0] + {.#None} + [{.#None} #0] - {#.Some root} + {.#Some root} (let [root_key (value@ #key root) root_val (value@ #value root)] (if (_\= root_key key) @@ -489,49 +489,49 @@ (case (recur (if go_left? (value@ #left root) (value@ #right root))) - [#.None #0] - [#.None #0] + [{.#None} #0] + [{.#None} #0] [side_outcome _] (if go_left? (case (value@ #left root) - (^multi {#.Some left} - [(value@ #color left) #Black]) - [{#.Some (without_left root_key root_val side_outcome (value@ #right root))} + (^multi {.#Some left} + [(value@ #color left) {#Black}]) + [{.#Some (without_left root_key root_val side_outcome (value@ #right root))} #0] _ - [{#.Some (red root_key root_val side_outcome (value@ #right root))} + [{.#Some (red root_key root_val side_outcome (value@ #right root))} #0]) (case (value@ #right root) - (^multi {#.Some right} - [(value@ #color right) #Black]) - [{#.Some (without_right root_key root_val (value@ #left root) side_outcome)} + (^multi {.#Some right} + [(value@ #color right) {#Black}]) + [{.#Some (without_right root_key root_val (value@ #left root) side_outcome)} #0] _ - [{#.Some (red root_key root_val (value@ #left root) side_outcome)} + [{.#Some (red root_key root_val (value@ #left root) side_outcome)} #0]) ))) )) ))] (case ?root - #.None + {.#None} (if found? (with@ #root ?root dict) dict) - {#.Some root} - (with@ #root {#.Some (blackened root)} dict) + {.#Some root} + (with@ #root {.#Some (blackened root)} dict) ))) (def: .public (revised key transform dict) (All (_ k v) (-> k (-> v v) (Dictionary k v) (Dictionary k v))) (case (..value key dict) - {#.Some old} + {.#Some old} (..has key (transform old) dict) - #.None + {.#None} dict)) (def: .public (of_list order list) @@ -546,10 +546,10 @@ (All (_ k v) (-> (Dictionary k v) (List <type>))) (loop [node (value@ #root dict)] (case node - #.None + {.#None} (list) - {#.Some node'} + {.#Some node'} ($_ list\composite (recur (value@ #left node')) (list <output>) @@ -568,10 +568,10 @@ (loop [entriesR (entries reference) entriesS (entries sample)] (case [entriesR entriesS] - [#.End #.End] + [{.#End} {.#End}] #1 - [{#.Item [keyR valueR] entriesR'} {#.Item [keyS valueS] entriesS'}] + [{.#Item [keyR valueR] entriesR'} {.#Item [keyS valueS] entriesS'}] (and (/\= keyR keyS) (,\= valueR valueS) (recur entriesR' entriesS')) diff --git a/stdlib/source/library/lux/data/collection/dictionary/plist.lux b/stdlib/source/library/lux/data/collection/dictionary/plist.lux index bb7f63265..8ffa6682a 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/plist.lux @@ -18,7 +18,7 @@ (def: .public empty PList - #.End) + {.#End}) (def: .public size (All (_ a) (-> (PList a) Nat)) @@ -31,12 +31,12 @@ (def: .public (value key properties) (All (_ a) (-> Text (PList a) (Maybe a))) (case properties - #.End - #.None + {.#End} + {.#None} - {#.Item [k' v'] properties'} + {.#Item [k' v'] properties'} (if (text\= key k') - {#.Some v'} + {.#Some v'} (value key properties')))) (template [<name> <type> <access>] @@ -51,46 +51,46 @@ (def: .public (contains? key properties) (All (_ a) (-> Text (PList a) Bit)) (case (..value key properties) - {#.Some _} + {.#Some _} true - #.None + {.#None} false)) (def: .public (has key val properties) (All (_ a) (-> Text a (PList a) (PList a))) (case properties - #.End + {.#End} (list [key val]) - {#.Item [k' v'] properties'} + {.#Item [k' v'] properties'} (if (text\= key k') - {#.Item [key val] + {.#Item [key val] properties'} - {#.Item [k' v'] + {.#Item [k' v'] (has key val properties')}))) (def: .public (revised key f properties) (All (_ a) (-> Text (-> a a) (PList a) (PList a))) (case properties - #.End - #.End + {.#End} + {.#End} - {#.Item [k' v'] properties'} + {.#Item [k' v'] properties'} (if (text\= key k') - {#.Item [k' (f v')] properties'} - {#.Item [k' v'] (revised key f properties')}))) + {.#Item [k' (f v')] properties'} + {.#Item [k' v'] (revised key f properties')}))) (def: .public (lacks key properties) (All (_ a) (-> Text (PList a) (PList a))) (case properties - #.End + {.#End} properties - {#.Item [k' v'] properties'} + {.#Item [k' v'] properties'} (if (text\= key k') properties' - {#.Item [k' v'] + {.#Item [k' v'] (lacks key properties')}))) (def: .public equivalence diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux index e2cb06a42..4232af895 100644 --- a/stdlib/source/library/lux/data/collection/list.lux +++ b/stdlib/source/library/lux/data/collection/list.lux @@ -28,60 +28,61 @@ (def: (mix f init xs) (case xs - #.End + {.#End} init - {#.Item x xs'} + {.#Item x xs'} (mix f (f x init) xs')))) (def: .public (mixes f init inputs) (All (_ a b) (-> (-> a b b) b (List a) (List b))) (case inputs - #.End + {.#End} (list init) - {#.Item [head tail]} - {#.Item [init (mixes f (f head init) tail)]})) + {.#Item [head tail]} + {.#Item [init (mixes f (f head init) tail)]})) (def: .public (reversed xs) (All (_ a) (-> (List a) (List a))) - (mix (function (_ head tail) {#.Item head tail}) - #.End + (mix (function (_ head tail) + {.#Item head tail}) + {.#End} xs)) (def: .public (only keep? xs) (All (_ a) (-> (Predicate a) (List a) (List a))) (case xs - #.End - #.End + {.#End} + {.#End} - {#.Item x xs'} + {.#Item x xs'} (if (keep? x) - {#.Item x (only keep? xs')} + {.#Item x (only keep? xs')} (only keep? xs')))) (def: .public (partition satisfies? list) (All (_ a) (-> (Predicate a) (List a) [(List a) (List a)])) (case list - #.End - [#.End #.End] + {.#End} + [{.#End} {.#End}] - {#.Item head tail} + {.#Item head tail} (let [[in out] (partition satisfies? tail)] (if (satisfies? head) - [{#.Item head in} out] - [in {#.Item head out}])))) + [{.#Item head in} out] + [in {.#Item head out}])))) (def: .public (pairs xs) (All (_ a) (-> (List a) (List [a a]))) (case xs (^ (list& x1 x2 xs')) - {#.Item [x1 x2] (pairs xs')} + {.#Item [x1 x2] (pairs xs')} _ - #.End)) + {.#End})) (template [<name> <then> <else>] [(def: .public (<name> n xs) @@ -89,14 +90,14 @@ (-> Nat (List a) (List a))) (if (n.> 0 n) (case xs - #.End - #.End + {.#End} + {.#End} - {#.Item x xs'} + {.#Item x xs'} <then>) <else>))] - [first {#.Item x (first (-- n) xs')} #.End] + [first {.#Item x (first (-- n) xs')} {.#End}] [after (after (-- n) xs') xs] ) @@ -105,15 +106,15 @@ (All (_ a) (-> (Predicate a) (List a) (List a))) (case xs - #.End - #.End + {.#End} + {.#End} - {#.Item x xs'} + {.#Item x xs'} (if (predicate x) <then> <else>)))] - [while {#.Item x (while predicate xs')} #.End] + [while {.#Item x (while predicate xs')} {.#End}] [until (until predicate xs') xs] ) @@ -122,82 +123,82 @@ (-> Nat (List a) [(List a) (List a)])) (if (n.> 0 n) (case xs - #.End - [#.End #.End] + {.#End} + [{.#End} {.#End}] - {#.Item x xs'} + {.#Item x xs'} (let [[tail rest] (split_at (-- n) xs')] - [{#.Item x tail} rest])) - [#.End xs])) + [{.#Item x tail} rest])) + [{.#End} xs])) (def: (split_when' predicate ys xs) (All (_ a) (-> (Predicate a) (List a) (List a) [(List a) (List a)])) (case xs - #.End + {.#End} [ys xs] - {#.Item x xs'} + {.#Item x xs'} (if (predicate x) [ys xs] - (split_when' predicate {#.Item x ys} xs')))) + (split_when' predicate {.#Item x ys} xs')))) (def: .public (split_when predicate xs) (All (_ a) (-> (Predicate a) (List a) [(List a) (List a)])) - (let [[ys' xs'] (split_when' predicate #.End xs)] + (let [[ys' xs'] (split_when' predicate {.#End} xs)] [(reversed ys') xs'])) (def: .public (sub size list) (All (_ a) (-> Nat (List a) (List (List a)))) (case list - #.End - #.End + {.#End} + {.#End} _ (let [[pre post] (split_at size list)] - {#.Item pre (sub size post)}))) + {.#Item pre (sub size post)}))) (def: .public (repeated n x) (All (_ a) (-> Nat a (List a))) (case n - 0 #.End - _ {#.Item x (repeated (-- n) x)})) + 0 {.#End} + _ {.#Item x (repeated (-- n) x)})) (def: (iterations' f x) (All (_ a) (-> (-> a (Maybe a)) a (List a))) (case (f x) - {#.Some x'} - {#.Item x (iterations' f x')} + {.#Some x'} + {.#Item x (iterations' f x')} - #.None + {.#None} (list))) (def: .public (iterations f x) (All (_ a) (-> (-> a (Maybe a)) a (List a))) (case (f x) - {#.Some x'} - {#.Item x (iterations' f x')} + {.#Some x'} + {.#Item x (iterations' f x')} - #.None + {.#None} (list x))) (def: .public (one check xs) (All (_ a b) (-> (-> a (Maybe b)) (List a) (Maybe b))) (case xs - #.End - #.None + {.#End} + {.#None} - {#.Item x xs'} + {.#Item x xs'} (case (check x) - {#.Some output} - {#.Some output} + {.#Some output} + {.#Some output} - #.None + {.#None} (one check xs')))) (def: .public (all check xs) @@ -207,23 +208,23 @@ @.js (mix (function (_ head tail) (case (check head) - {#.Some head} - {#.Item head tail} + {.#Some head} + {.#Item head tail} - #.None + {.#None} tail)) - #.End + {.#End} (reversed xs))] (case xs - #.End - #.End + {.#End} + {.#End} - {#.Item x xs'} + {.#Item x xs'} (case (check x) - {#.Some output} - {#.Item output (all check xs')} + {.#Some output} + {.#Item output (all check xs')} - #.None + {.#None} (all check xs'))))) (def: .public (example predicate xs) @@ -231,21 +232,21 @@ (-> (Predicate a) (List a) (Maybe a))) (..one (function (_ value) (if (predicate value) - {#.Some value} - #.None)) + {.#Some value} + {.#None})) xs)) (def: .public (interposed sep xs) (All (_ a) (-> a (List a) (List a))) (case xs - #.End + {.#End} xs - {#.Item x #.End} + {.#Item x {.#End}} xs - {#.Item x xs'} + {.#Item x xs'} (list& x sep (interposed sep xs')))) (def: .public (size list) @@ -257,10 +258,10 @@ (All (_ a) (-> (Predicate a) (List a) Bit)) (case items - #.End + {.#End} <init> - {#.Item head tail} + {.#Item head tail} (<op> (predicate head) (<name> predicate tail))))] @@ -272,12 +273,12 @@ (All (_ a) (-> Nat (List a) (Maybe a))) (case xs - #.End - #.None + {.#End} + {.#None} - {#.Item x xs'} + {.#Item x xs'} (case i - 0 {#.Some x} + 0 {.#Some x} _ (item (-- i) xs')))) (implementation: .public (equivalence Equivalence<a>) @@ -285,10 +286,10 @@ (def: (= xs ys) (case [xs ys] - [#.End #.End] + [{.#End} {.#End}] #1 - [{#.Item x xs'} {#.Item y ys'}] + [{.#Item x xs'} {.#Item y ys'}] (and (\ Equivalence<a> = x y) (= xs' ys')) @@ -311,14 +312,15 @@ (implementation: .public monoid (All (_ a) (Monoid (List a))) - (def: identity #.End) + (def: identity + {.#End}) (def: (composite xs ys) (case xs - #.End + {.#End} ys - {#.Item x xs'} - {#.Item x (composite xs' ys)}))) + {.#Item x xs'} + {.#Item x (composite xs' ys)}))) (open: "[0]" ..monoid) @@ -327,11 +329,11 @@ (def: (each f ma) (case ma - #.End - #.End + {.#End} + {.#End} - {#.Item a ma'} - {#.Item (f a) (each f ma')}))) + {.#Item a ma'} + {.#Item (f a) (each f ma')}))) (open: "[0]" ..functor) @@ -342,10 +344,10 @@ (def: (on fa ff) (case ff - #.End - #.End + {.#End} + {.#End} - {#.Item f ff'} + {.#Item f ff'} (|> ff' (on fa) (composite (each f fa)))))) @@ -356,7 +358,7 @@ (def: &functor ..functor) (def: (in a) - {#.Item a #.End}) + {.#Item a {.#End}}) (def: conjoint (|>> reversed (mix composite identity)))) @@ -364,14 +366,14 @@ (def: .public (sorted < xs) (All (_ a) (-> (-> a a Bit) (List a) (List a))) (case xs - #.End + {.#End} (list) - {#.Item x xs'} + {.#Item x xs'} (let [[pre post] (mix (function (_ x' [pre post]) (if (< x x') - [{#.Item x' pre} post] - [pre {#.Item x' post}])) + [{.#Item x' pre} post] + [pre {.#Item x' post}])) [(list) (list)] xs')] ($_ composite (sorted < pre) (list x) (sorted < post))))) @@ -379,7 +381,7 @@ (def: .public (empty? xs) (All (_ a) (Predicate (List a))) (case xs - #.End + {.#End} true _ @@ -388,10 +390,10 @@ (def: .public (member? eq xs x) (All (_ a) (-> (Equivalence a) (List a) a Bit)) (case xs - #.End + {.#End} #0 - {#.Item x' xs'} + {.#Item x' xs'} (or (\ eq = x x') (member? eq xs' x)))) @@ -399,11 +401,11 @@ [(def: .public (<name> xs) (All (_ a) (-> (List a) (Maybe <output>))) (case xs - #.End - #.None + {.#End} + {.#None} - {#.Item x xs'} - {#.Some <side>}))] + {.#Item x xs'} + {.#Some <side>}))] [head a x] [tail (List a) xs'] @@ -417,7 +419,7 @@ (def: (identifier$ name) (-> Text Code) - [["" 0 0] {#.Identifier "" name}]) + [["" 0 0] {.#Identifier "" name}]) (def: (nat\encoded value) (-> Nat Text) @@ -443,7 +445,7 @@ (macro: .public (zipped tokens state) (case tokens - (^ (list [_ {#.Nat num_lists}])) + (^ (list [_ {.#Nat num_lists}])) (if (n.> 0 num_lists) (let [(^open "[0]") ..functor indices (..indices num_lists) @@ -458,7 +460,7 @@ (let [base (nat\encoded idx)] [(identifier$ base) (identifier$ ("lux text concat" base "'"))])))) - pattern (` [(~+ (each (function (_ [v vs]) (` {#.Item (~ v) (~ vs)})) + pattern (` [(~+ (each (function (_ [v vs]) (` {.#Item (~ v) (~ vs)})) vars+lists))]) g!step (identifier$ "0step0") g!blank (identifier$ "0,0") @@ -467,23 +469,23 @@ (function ((~ g!step) (~+ list_vars)) (case [(~+ list_vars)] (~ pattern) - {#.Item [(~+ (each product.left vars+lists))] + {.#Item [(~+ (each product.left vars+lists))] ((~ g!step) (~+ list_vars))} (~ g!blank) - #.End))))] - {#.Right [state (list code)]}) - {#.Left "Cannot zipped 0 lists."}) + {.#End}))))] + {.#Right [state (list code)]}) + {.#Left "Cannot zipped 0 lists."}) _ - {#.Left "Wrong syntax for zipped"})) + {.#Left "Wrong syntax for zipped"})) (def: .public zipped/2 (zipped 2)) (def: .public zipped/3 (zipped 3)) (macro: .public (zipped_with tokens state) (case tokens - (^ (list [_ {#.Nat num_lists}])) + (^ (list [_ {.#Nat num_lists}])) (if (n.> 0 num_lists) (let [(^open "[0]") ..functor indices (..indices num_lists) @@ -501,7 +503,7 @@ (let [base (nat\encoded idx)] [(identifier$ base) (identifier$ ("lux text concat" base "'"))])))) - pattern (` [(~+ (each (function (_ [v vs]) (` {#.Item (~ v) (~ vs)})) + pattern (` [(~+ (each (function (_ [v vs]) (` {.#Item (~ v) (~ vs)})) vars+lists))]) g!step (identifier$ "0step0") g!blank (identifier$ "0,0") @@ -510,16 +512,16 @@ (function ((~ g!step) (~ g!func) (~+ list_vars)) (case [(~+ list_vars)] (~ pattern) - {#.Item ((~ g!func) (~+ (each product.left vars+lists))) + {.#Item ((~ g!func) (~+ (each product.left vars+lists))) ((~ g!step) (~ g!func) (~+ list_vars))} (~ g!blank) - #.End))))] - {#.Right [state (list code)]}) - {#.Left "Cannot zipped_with 0 lists."}) + {.#End}))))] + {.#Right [state (list code)]}) + {.#Left "Cannot zipped_with 0 lists."}) _ - {#.Left "Wrong syntax for zipped_with"})) + {.#Left "Wrong syntax for zipped_with"})) (def: .public zipped_with/2 (zipped_with 2)) (def: .public zipped_with/3 (zipped_with 3)) @@ -527,31 +529,31 @@ (def: .public (last xs) (All (_ a) (-> (List a) (Maybe a))) (case xs - #.End - #.None + {.#End} + {.#None} - {#.Item x #.End} - {#.Some x} + {.#Item x {.#End}} + {.#Some x} - {#.Item x xs'} + {.#Item x xs'} (last xs'))) (def: .public (inits xs) (All (_ a) (-> (List a) (Maybe (List a)))) (case xs - #.End - #.None + {.#End} + {.#None} - {#.Item x #.End} - {#.Some #.End} + {.#Item x {.#End}} + {.#Some {.#End}} - {#.Item x xs'} + {.#Item x xs'} (case (inits xs') - #.None + {.#None} (undefined) - {#.Some tail} - {#.Some {#.Item x tail}}) + {.#Some tail} + {.#Some {.#Item x tail}}) )) (def: .public together @@ -562,7 +564,7 @@ (All (_ M) (-> (Monad M) (Monad (All (_ a) (M (List a)))))) (def: &functor - (functor.composite (value@ #monad.&functor monad) + (functor.composite (value@ monad.&functor monad) ..functor)) (def: in @@ -573,9 +575,8 @@ [lMla MlMla ... TODO: Remove this version ASAP and use one below. lla (for [@.old - (: {#.Apply - (type (List (List (:parameter 1)))) - (:parameter 0)} + (: {.#Apply (type (List (List (:parameter 1)))) + (:parameter 0)} (monad.all ! lMla))] (monad.all ! lMla))] (in (..together lla))))) @@ -589,18 +590,18 @@ (loop [idx 0 xs xs] (case xs - #.End - #.End + {.#End} + {.#End} - {#.Item x xs'} - {#.Item [idx x] (recur (++ idx) xs')}))) + {.#Item x xs'} + {.#Item [idx x] (recur (++ idx) xs')}))) (macro: .public (when tokens state) (case tokens (^ (.list test then)) - {#.Right [state (.list (` (.if (~ test) + {.#Right [state (.list (` (.if (~ test) (~ then) (.list))))]} _ - {#.Left "Wrong syntax for when"})) + {.#Left "Wrong syntax for when"})) diff --git a/stdlib/source/library/lux/data/collection/queue.lux b/stdlib/source/library/lux/data/collection/queue.lux index 7a52a1e9f..4fc1e31a1 100644 --- a/stdlib/source/library/lux/data/collection/queue.lux +++ b/stdlib/source/library/lux/data/collection/queue.lux @@ -29,7 +29,7 @@ (def: .public (list queue) (All (_ a) (-> (Queue a) (List a))) (let [(^slots [#front #rear]) queue] - (list\composite front (list.reversed rear)))) + (list\composite #front (list.reversed #rear)))) (def: .public front (All (_ a) (-> (Queue a) (Maybe a))) @@ -38,8 +38,8 @@ (def: .public (size queue) (All (_ a) (-> (Queue a) Nat)) (let [(^slots [#front #rear]) queue] - (n.+ (list.size front) - (list.size rear)))) + (n.+ (list.size #front) + (list.size #rear)))) (def: .public empty? (All (_ a) (-> (Queue a) Bit)) @@ -48,8 +48,8 @@ (def: .public (member? equivalence queue member) (All (_ a) (-> (Equivalence a) (Queue a) a Bit)) (let [(^slots [#front #rear]) queue] - (or (list.member? equivalence front member) - (list.member? equivalence rear member)))) + (or (list.member? equivalence #front member) + (list.member? equivalence #rear member)))) (def: .public (next queue) (All (_ a) (-> (Queue a) (Queue a))) @@ -72,11 +72,11 @@ (def: .public (end val queue) (All (_ a) (-> a (Queue a) (Queue a))) (case (value@ #front queue) - #.End + {.#End} (with@ #front (.list val) queue) _ - (revised@ #rear (|>> {#.Item val}) queue))) + (revised@ #rear (|>> {.#Item val}) queue))) (implementation: .public (equivalence super) (All (_ a) (-> (Equivalence a) (Equivalence (Queue a)))) diff --git a/stdlib/source/library/lux/data/collection/queue/priority.lux b/stdlib/source/library/lux/data/collection/queue/priority.lux index d277ec515..e9069fa5e 100644 --- a/stdlib/source/library/lux/data/collection/queue/priority.lux +++ b/stdlib/source/library/lux/data/collection/queue/priority.lux @@ -42,7 +42,7 @@ (def: .public empty Queue - (:abstraction #.None)) + (:abstraction {.#None})) (def: .public (front queue) (All (_ a) (-> (Queue a) (Maybe a))) @@ -54,10 +54,10 @@ (def: .public (size queue) (All (_ a) (-> (Queue a) Nat)) (case (:representation queue) - #.None + {.#None} 0 - {#.Some tree} + {.#Some tree} (loop [node tree] (case (tree.root node) {0 #0 _} @@ -69,10 +69,10 @@ (def: .public (member? equivalence queue member) (All (_ a) (-> (Equivalence a) (Queue a) a Bit)) (case (:representation queue) - #.None + {.#None} false - {#.Some tree} + {.#Some tree} (loop [node tree] (case (tree.root node) {0 #0 reference} @@ -92,34 +92,34 @@ (case (tree.root node) {0 #0 reference} (if (n.= highest_priority (tree.tag node)) - #.None - {#.Some node}) + {.#None} + {.#Some node}) {0 #1 left right} (if (n.= highest_priority (tree.tag left)) (case (recur left) - #.None - {#.Some right} + {.#None} + {.#Some right} - {#.Some =left} - {#.Some (\ ..builder branch =left right)}) + {.#Some =left} + {.#Some (\ ..builder branch =left right)}) (case (recur right) - #.None - {#.Some left} + {.#None} + {.#Some left} - {#.Some =right} - {#.Some (\ ..builder branch left =right)}))))))) + {.#Some =right} + {.#Some (\ ..builder branch left =right)}))))))) (def: .public (end priority value queue) (All (_ a) (-> Priority a (Queue a) (Queue a))) (let [addition (\ ..builder leaf priority value)] (:abstraction (case (:representation queue) - #.None - {#.Some addition} + {.#None} + {.#Some addition} - {#.Some tree} - {#.Some (\ ..builder branch tree addition)})))) + {.#Some tree} + {.#Some (\ ..builder branch tree addition)})))) ) (def: .public empty? diff --git a/stdlib/source/library/lux/data/collection/row.lux b/stdlib/source/library/lux/data/collection/row.lux index aa8c6d0f7..a39ea8af3 100644 --- a/stdlib/source/library/lux/data/collection/row.lux +++ b/stdlib/source/library/lux/data/collection/row.lux @@ -96,7 +96,7 @@ {#Base tail} (|> (empty_hierarchy []) (array.write! 0 (path (level_down level) tail)) - #Hierarchy))) + {#Hierarchy}))) (def: (tail singleton) (All (_ a) (-> a (Base a))) @@ -113,10 +113,10 @@ ... Otherwise, check whether there's a vacant spot (case (array.read! sub_idx parent) ... If so, set the path to the tail - #.None + {.#None} (..path (level_down level) tail) ... If not, push the tail onto the sub_node. - {#.Some {#Hierarchy sub_node}} + {.#Some {#Hierarchy sub_node}} {#Hierarchy (with_tail size (level_down level) tail sub_node)} _ @@ -136,16 +136,16 @@ (All (_ a) (-> Level Index a (Hierarchy a) (Hierarchy a))) (let [sub_idx (branch_idx (i64.right_shifted level idx))] (case (array.read! sub_idx hierarchy) - {#.Some {#Hierarchy sub_node}} + {.#Some {#Hierarchy sub_node}} (|> (array.clone hierarchy) (array.write! sub_idx {#Hierarchy (hierarchy\has (level_down level) idx val sub_node)})) - (^multi {#.Some {#Base base}} + (^multi {.#Some {#Base base}} (n.= 0 (level_down level))) (|> (array.clone hierarchy) (array.write! sub_idx (|> (array.clone base) (array.write! (branch_idx idx) val) - #Base))) + {#Base}))) _ (undefined)))) @@ -154,7 +154,7 @@ (All (_ a) (-> Nat Level (Hierarchy a) (Maybe (Hierarchy a)))) (let [sub_idx (branch_idx (i64.right_shifted level (n.- 2 size)))] (cond (n.= 0 sub_idx) - #.None + {.#None} (n.> branching_exponent level) (do maybe.monad @@ -167,27 +167,27 @@ (undefined))] (|> (array.clone hierarchy) (array.write! sub_idx {#Hierarchy sub}) - #.Some)) + {.#Some})) ... Else... (|> (array.clone hierarchy) (array.delete! sub_idx) - #.Some) + {.#Some}) ))) (def: (node\list node) (All (_ a) (-> (Node a) (List a))) (case node {#Base base} - (array.list #.None base) + (array.list {.#None} base) {#Hierarchy hierarchy} (|> hierarchy - (array.list #.None) + (array.list {.#None}) list.reversed (list\mix (function (_ sub acc) (list\composite (node\list sub) acc)) - #.End)))) + {.#End})))) (type: .public (Row a) (Record @@ -261,18 +261,18 @@ hierarchy (value@ #root row)] (case [(n.> branching_exponent level) (array.read! (branch_idx (i64.right_shifted level idx)) hierarchy)] - [#1 {#.Some {#Hierarchy sub}}] + [#1 {.#Some {#Hierarchy sub}}] (recur (level_down level) sub) - [#0 {#.Some {#Base base}}] - {#try.Success base} + [#0 {.#Some {#Base base}}] + {try.#Success base} - [_ #.None] + [_ {.#None}] (exception.except ..base_was_not_found []) _ (exception.except ..incorrect_row_structure []))) - {#try.Success (value@ #tail row)}) + {try.#Success (value@ #tail row)}) (exception.except ..index_out_of_bounds [row idx]))) (def: .public (item idx row) @@ -280,17 +280,17 @@ (do try.monad [base (base_for idx row)] (case (array.read! (branch_idx idx) base) - {#.Some value} - {#try.Success value} + {.#Some value} + {try.#Success value} - #.None + {.#None} (exception.except ..incorrect_row_structure [])))) (def: .public (has idx val row) (All (_ a) (-> Nat a (Row a) (Try (Row a)))) (let [row_size (value@ #size row)] (if (within_bounds? row idx) - {#try.Success (if (n.< (tail_off row_size) idx) + {try.#Success (if (n.< (tail_off row_size) idx) (revised@ #root (hierarchy\has (value@ #level row) idx val) row) (revised@ #tail (for [@.old @@ -332,10 +332,10 @@ (without_tail row_size init_level (value@ #root row)))] (if (n.> branching_exponent level) (case [(array.read! 1 root) (array.read! 0 root)] - [#.None {#.Some {#Hierarchy sub_node}}] + [{.#None} {.#Some {#Hierarchy sub_node}}] (recur (level_down level) sub_node) - ... [#.None {#.Some {#Base _}}] + ... [{.#None} {.#Some {#Base _}}] ... (undefined) _ @@ -492,8 +492,8 @@ (<array> (help predicate) hierarchy))))] (function (<name> predicate row) (let [(^slots [#root #tail]) row] - (<op> (help predicate {#Hierarchy root}) - (help predicate {#Base tail}))))))] + (<op> (help predicate {#Hierarchy #root}) + (help predicate {#Base #tail}))))))] [every? array.every? #1 and] [any? array.any? #0 or] diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux index 6e4e0b801..fccc576df 100644 --- a/stdlib/source/library/lux/data/collection/sequence.lux +++ b/stdlib/source/library/lux/data/collection/sequence.lux @@ -39,10 +39,10 @@ (loop [head start tail next] (//.pending [head (case tail - #.End + {.#End} (recur start next) - {#.Item head' tail'} + {.#Item head' tail'} (recur head' tail'))]))) (template [<name> <return>] @@ -91,7 +91,7 @@ (if <pred_test> [(list) xs] (let [[tail next] (<splitter> <pred_step> xs')] - [{#.Item [x tail]} next]))))] + [{.#Item [x tail]} next]))))] [split_when (-> a Bit) (pred x) pred] [split_at Nat (n.= 0 pred) (-- pred)] diff --git a/stdlib/source/library/lux/data/collection/set/multi.lux b/stdlib/source/library/lux/data/collection/set/multi.lux index 2d4c3975b..b325c793a 100644 --- a/stdlib/source/library/lux/data/collection/set/multi.lux +++ b/stdlib/source/library/lux/data/collection/set/multi.lux @@ -43,13 +43,13 @@ (case multiplicity 0 set _ (case (dictionary.value elem (:representation set)) - {#.Some current} + {.#Some current} (:abstraction (if (n.> multiplicity current) (dictionary.revised elem (n.- multiplicity) (:representation set)) (dictionary.lacks elem (:representation set)))) - #.None + {.#None} set))) (def: .public (multiplicity set elem) @@ -62,7 +62,7 @@ dictionary.entries (list\mix (function (_ [elem multiplicity] output) (list\composite (list.repeated multiplicity elem) output)) - #.End))) + {.#End}))) (template [<name> <composite>] [(def: .public (<name> parameter subject) diff --git a/stdlib/source/library/lux/data/collection/set/ordered.lux b/stdlib/source/library/lux/data/collection/set/ordered.lux index 72344d090..2fea2876a 100644 --- a/stdlib/source/library/lux/data/collection/set/ordered.lux +++ b/stdlib/source/library/lux/data/collection/set/ordered.lux @@ -58,13 +58,13 @@ (All (_ a) (-> (Set a) (Set a) (Set a))) (|> (..list right) (list.only (..member? left)) - (..of_list (value@ #/.&order (:representation right))))) + (..of_list (value@ /.#&order (:representation right))))) (def: .public (difference param subject) (All (_ a) (-> (Set a) (Set a) (Set a))) (|> (..list subject) (list.only (|>> (..member? param) not)) - (..of_list (value@ #/.&order (:representation subject))))) + (..of_list (value@ /.#&order (:representation subject))))) (implementation: .public equivalence (All (_ a) (Equivalence (Set a))) diff --git a/stdlib/source/library/lux/data/collection/stack.lux b/stdlib/source/library/lux/data/collection/stack.lux index e90d53f84..8c55178f9 100644 --- a/stdlib/source/library/lux/data/collection/stack.lux +++ b/stdlib/source/library/lux/data/collection/stack.lux @@ -28,24 +28,24 @@ (def: .public (value stack) (All (_ a) (-> (Stack a) (Maybe a))) (case (:representation stack) - #.End - #.None + {.#End} + {.#None} - {#.Item value _} - {#.Some value})) + {.#Item value _} + {.#Some value})) (def: .public (next stack) (All (_ a) (-> (Stack a) (Maybe [a (Stack a)]))) (case (:representation stack) - #.End - #.None + {.#End} + {.#None} - {#.Item top stack'} - {#.Some [top (:abstraction stack')]})) + {.#Item top stack'} + {.#Some [top (:abstraction stack')]})) (def: .public (top value stack) (All (_ a) (-> a (Stack a) (Stack a))) - (:abstraction {#.Item value (:representation stack)})) + (:abstraction {.#Item value (:representation stack)})) (implementation: .public (equivalence super) (All (_ a) diff --git a/stdlib/source/library/lux/data/collection/tree.lux b/stdlib/source/library/lux/data/collection/tree.lux index 281e9f2ed..4beb81cf3 100644 --- a/stdlib/source/library/lux/data/collection/tree.lux +++ b/stdlib/source/library/lux/data/collection/tree.lux @@ -27,7 +27,7 @@ (value@ #children) (list\each flat) list\conjoint - {#.Item (value@ #value tree)})) + {.#Item (value@ #value tree)})) (def: .public (leaf value) (All (_ a) (-> a (Tree a))) diff --git a/stdlib/source/library/lux/data/collection/tree/finger.lux b/stdlib/source/library/lux/data/collection/tree/finger.lux index 5cef4d130..01e125e9d 100644 --- a/stdlib/source/library/lux/data/collection/tree/finger.lux +++ b/stdlib/source/library/lux/data/collection/tree/finger.lux @@ -91,21 +91,21 @@ _node root] (case _node {0 #0 value} - {#.Some value} + {.#Some value} {0 #1 [left right]} (let [shifted_tag (tag//composite _tag (..tag left))] (if (predicate shifted_tag) (recur _tag (value@ #root (:representation left))) (recur shifted_tag (value@ #root (:representation right)))))))) - #.None))) + {.#None}))) ) (def: .public (exists? predicate tree) (All (_ @ t v) (-> (Predicate t) (Tree @ t v) Bit)) (case (..one predicate tree) - {#.Some _} + {.#Some _} true - #.None + {.#None} false)) diff --git a/stdlib/source/library/lux/data/collection/tree/zipper.lux b/stdlib/source/library/lux/data/collection/tree/zipper.lux index 60c11d032..767365e6f 100644 --- a/stdlib/source/library/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/library/lux/data/collection/tree/zipper.lux @@ -46,7 +46,7 @@ (def: .public (zipper tree) (All (_ a) (-> (Tree a) (Zipper a))) - [#family #.None + [#family {.#None} #node tree]) (def: .public tree @@ -55,19 +55,19 @@ (def: .public value (All (_ a) (-> (Zipper a) a)) - (value@ [#node #//.value])) + (value@ [#node //.#value])) (def: .public (set value zipper) (All (_ a) (-> a (Zipper a) (Zipper a))) - (with@ [#node #//.value] value zipper)) + (with@ [#node //.#value] value zipper)) (def: .public (update transform zipper) (All (_ a) (-> (-> a a) (Zipper a) (Zipper a))) - (revised@ [#node #//.value] transform zipper)) + (revised@ [#node //.#value] transform zipper)) (def: children (All (_ a) (-> (Zipper a) (List (Tree a)))) - (value@ [#node #//.children])) + (value@ [#node //.#children])) (def: .public leaf? (All (_ a) (-> (Zipper a) Bit)) @@ -80,7 +80,7 @@ (def: .public (start? zipper) (All (_ a) (-> (Zipper a) Bit)) (case (value@ #family zipper) - #.None + {.#None} true _ @@ -89,12 +89,12 @@ (def: .public (down zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (..children zipper) - #.End - #.None + {.#End} + {.#None} - {#.Item head tail} - {#.Some [#family {#.Some [#parent (with@ [#node #//.children] (list) zipper) - #lefts #.End + {.#Item head tail} + {.#Some [#family {.#Some [#parent (with@ [#node //.#children] (list) zipper) + #lefts {.#End} #rights tail]} #node head]})) @@ -106,64 +106,64 @@ (for [@.old (revised@ #node (: (-> (Tree (:parameter 0)) (Tree (:parameter 0))) - (with@ #//.children (list\composite (list.reversed lefts) - {#.Item (value@ #node zipper) - rights}))) - parent)] - (with@ [#node #//.children] - (list\composite (list.reversed lefts) - {#.Item (value@ #node zipper) - rights}) - parent)))))) + (with@ //.#children (list\composite (list.reversed #lefts) + {.#Item (value@ #node zipper) + #rights}))) + #parent)] + (with@ [#node //.#children] + (list\composite (list.reversed #lefts) + {.#Item (value@ #node zipper) + #rights}) + #parent)))))) (template [<one> <all> <side> <op_side>] [(def: .public (<one> zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (value@ #family zipper) - {#.Some family} + {.#Some family} (case (value@ <side> family) - {#.Item next side'} - {#.Some (for [@.old - [#family {#.Some (|> family + {.#Item next side'} + {.#Some (for [@.old + [#family {.#Some (|> family (with@ <side> side') - (revised@ <op_side> (|>> {#.Item (value@ #node zipper)})))} + (revised@ <op_side> (|>> {.#Item (value@ #node zipper)})))} #node next]] (let [move (: (All (_ a) (-> (List (Tree a)) (Zipper a) (Family Zipper a) (Family Zipper a))) (function (_ side' zipper) (|>> (with@ <side> side') - (revised@ <op_side> (|>> {#.Item (value@ #node zipper)})))))] - [#family {#.Some (move side' zipper family)} + (revised@ <op_side> (|>> {.#Item (value@ #node zipper)})))))] + [#family {.#Some (move side' zipper family)} #node next]))} - #.End - #.None) + {.#End} + {.#None}) - #.None - #.None)) + {.#None} + {.#None})) (def: .public (<all> zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (value@ #family zipper) - #.None - #.None + {.#None} + {.#None} - {#.Some family} + {.#Some family} (case (list.reversed (value@ <side> family)) - #.End - #.None + {.#End} + {.#None} - {#.Item last prevs} - {#.Some (for [@.old [#family {#.Some (|> family - (with@ <side> #.End) - (revised@ <op_side> (|>> {#.Item (value@ #node zipper)} + {.#Item last prevs} + {.#Some (for [@.old [#family {.#Some (|> family + (with@ <side> {.#End}) + (revised@ <op_side> (|>> {.#Item (value@ #node zipper)} (list\composite prevs))))} #node last]] (let [move (: (All (_ a) (-> (List (Tree a)) (Zipper a) (Family Zipper a) (Family Zipper a))) (function (_ prevs zipper) - (|>> (with@ <side> #.End) - (revised@ <op_side> (|>> {#.Item (value@ #node zipper)} + (|>> (with@ <side> {.#End}) + (revised@ <op_side> (|>> {.#Item (value@ #node zipper)} (list\composite prevs))))))] - [#family {#.Some (move prevs zipper family)} + [#family {.#Some (move prevs zipper family)} #node last]))})))] [right rightmost #rights #lefts] @@ -173,16 +173,16 @@ (def: .public (next zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (..down zipper) - {#.Some forward} - {#.Some forward} + {.#Some forward} + {.#Some forward} - #.None + {.#None} (loop [@ zipper] (case (..right @) - {#.Some forward} - {#.Some forward} + {.#Some forward} + {.#Some forward} - #.None + {.#None} (do maybe.monad [@ (..up @)] (recur @)))))) @@ -190,45 +190,45 @@ (def: (bottom zipper) (All (_ a) (-> (Zipper a) (Zipper a))) (case (..right zipper) - {#.Some forward} + {.#Some forward} (bottom forward) - #.None + {.#None} (case (..down zipper) - {#.Some forward} + {.#Some forward} (bottom forward) - #.None + {.#None} zipper))) (def: .public (previous zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (..left zipper) - #.None + {.#None} (..up zipper) - {#.Some backward} - {#.Some (case (..down backward) - {#.Some then} + {.#Some backward} + {.#Some (case (..down backward) + {.#Some then} (..bottom then) - #.None + {.#None} backward)})) (template [<name> <move>] [(def: .public (<name> zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (<move> zipper) - #.None - #.None + {.#None} + {.#None} - {#.Some @} + {.#Some @} (loop [@ @] (case (<move> @) - #.None - {#.Some @} + {.#None} + {.#Some @} - {#.Some @} + {.#Some @} (recur @)))))] [end ..next] @@ -238,22 +238,22 @@ (def: .public (end? zipper) (All (_ a) (-> (Zipper a) Bit)) (case (..end zipper) - #.None + {.#None} true - {#.Some _} + {.#Some _} false)) (def: .public (interpose value zipper) (All (_ a) (-> a (Zipper a) (Zipper a))) - (revised@ [#node #//.children] + (revised@ [#node //.#children] (|>> (//.branch value) list) zipper)) (def: .public (adopt value zipper) (All (_ a) (-> a (Zipper a) (Zipper a))) - (revised@ [#node #//.children] - (|>> {#.Item (//.leaf value)}) + (revised@ [#node //.#children] + (|>> {.#Item (//.leaf value)}) zipper)) (def: .public (remove zipper) @@ -261,28 +261,28 @@ (do maybe.monad [family (value@ #family zipper)] (case (value@ #lefts family) - #.End - (in (with@ [#node #//.children] + {.#End} + (in (with@ [#node //.#children] (value@ #rights family) (value@ #parent family))) - {#.Item next side} + {.#Item next side} (in (|> zipper (with@ #family (|> family (with@ #lefts side) - #.Some)) + {.#Some})) (with@ #node next)))))) (template [<name> <side>] [(def: .public (<name> value zipper) (All (_ a) (-> a (Zipper a) (Maybe (Zipper a)))) (case (value@ #family zipper) - #.None - #.None + {.#None} + {.#None} - {#.Some family} - {#.Some (with@ #family - {#.Some (revised@ <side> (|>> {#.Item (//.leaf value)}) family)} + {.#Some family} + {.#Some (with@ #family + {.#Some (revised@ <side> (|>> {.#Item (//.leaf value)}) family)} zipper)}))] [insert_left #lefts] @@ -294,29 +294,31 @@ (def: (each f (^slots [#family #node])) [#family (maybe\each (function (_ (^slots [#parent #lefts #rights])) - [#parent (each f parent) - #lefts (list\each (//\each f) lefts) - #rights (list\each (//\each f) rights)]) - family) - #node (//\each f node)])) + [#parent (each f #parent) + #lefts (list\each (//\each f) #lefts) + #rights (list\each (//\each f) #rights)]) + #family) + #node (//\each f #node)])) (implementation: .public comonad (CoMonad Zipper) - (def: &functor ..functor) + (def: &functor + ..functor) - (def: out (value@ [#node #//.value])) + (def: out + (value@ [#node //.#value])) (def: (disjoint (^slots [#family #node])) (let [tree_splitter (: (All (_ a) (-> (Tree a) (Tree (Zipper a)))) (function (tree_splitter tree) - [#//.value (..zipper tree) - #//.children (|> tree - (value@ #//.children) + [//.#value (..zipper tree) + //.#children (|> tree + (value@ //.#children) (list\each tree_splitter))]))] [#family (maybe\each (function (_ (^slots [#parent #lefts #rights])) - [#parent (disjoint parent) - #lefts (list\each tree_splitter lefts) - #rights (list\each tree_splitter rights)]) - family) - #node (tree_splitter node)]))) + [..#parent (disjoint #parent) + ..#lefts (list\each tree_splitter #lefts) + ..#rights (list\each tree_splitter #rights)]) + #family) + #node (tree_splitter #node)]))) diff --git a/stdlib/source/library/lux/data/color/named.lux b/stdlib/source/library/lux/data/color/named.lux index 822708ccc..26deaeaa6 100644 --- a/stdlib/source/library/lux/data/color/named.lux +++ b/stdlib/source/library/lux/data/color/named.lux @@ -8,9 +8,9 @@ (template [<red> <green> <blue> <name>] [(`` (def: .public <name> Color - (//.of_rgb [#//.red (hex <red>) - #//.green (hex <green>) - #//.blue (hex <blue>)])))] + (//.of_rgb [//.#red (hex <red>) + //.#green (hex <green>) + //.#blue (hex <blue>)])))] ["F0" "F8" "FF" alice_blue] ["FA" "EB" "D7" antique_white] diff --git a/stdlib/source/library/lux/data/format/binary.lux b/stdlib/source/library/lux/data/format/binary.lux index 0fcc94723..8905c32bf 100644 --- a/stdlib/source/library/lux/data/format/binary.lux +++ b/stdlib/source/library/lux/data/format/binary.lux @@ -94,8 +94,8 @@ try.trusted [(.++ offset)] caseT))])]) - ([0 #.Left left] - [1 #.Right right]) + ([0 .#Left left] + [1 .#Right right]) ))) (def: .public (and pre post) @@ -242,17 +242,17 @@ try.trusted [(.++ offset)] caseT))])]) - ([0 #.Primitive (..and ..text (..list recur))] - [1 #.Sum pair] - [2 #.Product pair] - [3 #.Function pair] - [4 #.Parameter indexed] - [5 #.Var indexed] - [6 #.Ex indexed] - [7 #.UnivQ quantified] - [8 #.ExQ quantified] - [9 #.Apply pair] - [10 #.Named (..and ..name recur)]) + ([0 .#Primitive (..and ..text (..list recur))] + [1 .#Sum pair] + [2 .#Product pair] + [3 .#Function pair] + [4 .#Parameter indexed] + [5 .#Var indexed] + [6 .#Ex indexed] + [7 .#UnivQ quantified] + [8 .#ExQ quantified] + [9 .#Apply pair] + [10 .#Named (..and ..name recur)]) )))))) (def: .public location @@ -277,15 +277,14 @@ try.trusted [(.++ offset)] caseT))])]) - ([00 #.Bit ..bit] - [01 #.Nat ..nat] - [02 #.Int ..int] - [03 #.Rev ..rev] - [04 #.Frac ..frac] - [05 #.Text ..text] - [06 #.Identifier ..name] - [07 #.Tag ..name] - [08 #.Form sequence] - [09 #.Variant sequence] - [10 #.Tuple sequence]) + ([0 .#Bit ..bit] + [1 .#Nat ..nat] + [2 .#Int ..int] + [3 .#Rev ..rev] + [4 .#Frac ..frac] + [5 .#Text ..text] + [6 .#Identifier ..name] + [7 .#Form sequence] + [8 .#Variant sequence] + [9 .#Tuple sequence]) ))))))) diff --git a/stdlib/source/library/lux/data/format/css.lux b/stdlib/source/library/lux/data/format/css.lux index 488ccba64..90cb8ad54 100644 --- a/stdlib/source/library/lux/data/format/css.lux +++ b/stdlib/source/library/lux/data/format/css.lux @@ -49,19 +49,19 @@ (def: .public (font font) (-> Font (CSS Special)) - (let [with_unicode (case (value@ #/font.unicode_range font) - {#.Some unicode_range} - (let [unicode_range' (format "U+" (\ nat.hex encoded (value@ #/font.start unicode_range)) - "-" (\ nat.hex encoded (value@ #/font.end unicode_range)))] + (let [with_unicode (case (value@ /font.#unicode_range font) + {.#Some unicode_range} + (let [unicode_range' (format "U+" (\ nat.hex encoded (value@ /font.#start unicode_range)) + "-" (\ nat.hex encoded (value@ /font.#end unicode_range)))] (list ["unicode-range" unicode_range'])) - #.None + {.#None} (list))] - (|> (list& ["font-family" (value@ #/font.family font)] - ["src" (format "url(" (value@ #/font.source font) ")")] - ["font-stretch" (|> font (value@ #/font.stretch) (maybe.else /value.normal_stretch) /value.value)] - ["font-style" (|> font (value@ #/font.style) (maybe.else /value.normal_style) /value.value)] - ["font-weight" (|> font (value@ #/font.weight) (maybe.else /value.normal_weight) /value.value)] + (|> (list& ["font-family" (value@ /font.#family font)] + ["src" (format "url(" (value@ /font.#source font) ")")] + ["font-stretch" (|> font (value@ /font.#stretch) (maybe.else /value.normal_stretch) /value.value)] + ["font-style" (|> font (value@ /font.#style) (maybe.else /value.normal_style) /value.value)] + ["font-weight" (|> font (value@ /font.#weight) (maybe.else /value.normal_weight) /value.value)] with_unicode) (list\each (function (_ [property value]) (format property ": " value ";"))) @@ -74,10 +74,10 @@ (-> URL (Maybe Query) (CSS Special)) (:abstraction (format (format "@import url(" (%.text url) ")") (case query - {#.Some query} + {.#Some query} (format " " (/query.query query)) - #.None + {.#None} "") ";"))) diff --git a/stdlib/source/library/lux/data/format/css/value.lux b/stdlib/source/library/lux/data/format/css/value.lux index 25b09fb71..ba082cb05 100644 --- a/stdlib/source/library/lux/data/format/css/value.lux +++ b/stdlib/source/library/lux/data/format/css/value.lux @@ -827,7 +827,7 @@ (def: .public (rgba pigment) (-> color.Pigment (Value Color)) - (let [(^slots [#color.color #color.alpha]) pigment + (let [(^slots [color.#color color.#alpha]) pigment [red green blue] (color.rgb color)] (..apply "rgba" (list (%.nat red) (%.nat green) @@ -919,10 +919,10 @@ (def: (with_hint [hint stop]) (-> [(Maybe Hint) Stop] Text) (case hint - #.None + {.#None} (:representation Stop stop) - {#.Some hint} + {.#Some hint} (format (:representation Hint hint) ..value_separator (:representation Stop stop)))))) (type: .public (List/1 a) @@ -1078,10 +1078,10 @@ (Value Image)) (let [after_extent (format "at " (:representation location)) with_extent (case extent - {#.Some extent} + {.#Some extent} (format (..extent extent) " " after_extent) - #.None + {.#None} after_extent) where (format (..shape shape) " " with_extent) [now after] next] @@ -1158,13 +1158,13 @@ (def: .public (font_family options) (-> (List Font) (Value Font)) (case options - {#.Item _} + {.#Item _} (|> options (list\each ..font_name) (text.interposed ",") (:abstraction Value)) - #.End + {.#End} ..initial))]) (def: .public font_size diff --git a/stdlib/source/library/lux/data/format/html.lux b/stdlib/source/library/lux/data/format/html.lux index 72ec3e7a1..60c405963 100644 --- a/stdlib/source/library/lux/data/format/html.lux +++ b/stdlib/source/library/lux/data/format/html.lux @@ -176,10 +176,10 @@ (-> URL (Maybe Target) Meta) (let [partial (list ["href" href]) full (case target - {#.Some target} + {.#Some target} (list& ["target" (..target target)] partial) - #.None + {.#None} partial)] (..simple "base" full))) @@ -213,7 +213,7 @@ (def: .public (image source attributes) (-> URL Attributes Image) (|> attributes - {#.Item ["src" source]} + {.#Item ["src" source]} (..simple "img"))) (def: .public (svg attributes content) @@ -300,10 +300,10 @@ ($_ ..and for (case (list\each (product.uncurried ..area) areas) - #.End + {.#End} (..empty "map" attributes) - {#.Item head tail} + {.#Item head tail} (..tag "map" attributes (list\mix (function.flipped ..and) head tail))))) @@ -348,12 +348,12 @@ (-> (Maybe Content) Attributes <type> <type>) (..tag <container_tag> attributes (case description - {#.Some description} + {.#Some description} ($_ ..and (..tag <description_tag> (list) description) content) - #.None + {.#None} content)))] [details "details" "summary" Element] @@ -466,10 +466,10 @@ (..term term) (..description description))) descriptions) - #.End + {.#End} (..empty "dl" attributes) - {#.Item head tail} + {.#Item head tail} (..tag "dl" attributes (list\mix (function.flipped ..and) head tail)))) @@ -524,32 +524,32 @@ (-> Attributes (Maybe Content) (Maybe Column) Header (List Cell) (Maybe Cell) Element) (let [head (..table_head (..table_row headers)) content (case (list\each table_row rows) - #.End + {.#End} head - {#.Item first rest} + {.#Item first rest} (..and head (..table_body (list\mix (function.flipped ..and) first rest)))) content (case footer - #.None + {.#None} content - {#.Some footer} + {.#Some footer} (..and content (..table_foot (..table_row footer)))) content (case columns - #.None + {.#None} content - {#.Some columns} + {.#Some columns} (..and (..columns_group columns) content)) content (case caption - #.None + {.#None} content - {#.Some caption} + {.#Some caption} (..and (:as HTML caption) content))] (..tag "table" attributes diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux index f29042a83..734a38177 100644 --- a/stdlib/source/library/lux/data/format/json.lux +++ b/stdlib/source/library/lux/data/format/json.lux @@ -60,12 +60,12 @@ (def: .public null? (Predicate JSON) - (|>> (case> #Null true + (|>> (case> {#Null} true _ false))) (def: .public object (-> (List [String JSON]) JSON) - (|>> (dictionary.of_list text.hash) #..Object)) + (|>> (dictionary.of_list text.hash) {..#Object})) (type: JSON' (Rec JSON' @@ -83,7 +83,7 @@ (<>.rec (function (_ jsonP) ($_ <>.or - (<code>.local_tag! "null") + (<code>.form (<>\in [])) <code>.bit <code>.frac <code>.text @@ -98,20 +98,20 @@ (-> JSON' Code) (case token {#Null' _} - (` #..Null) + (` {..#Null}) (^template [<ctor> <input_tag> <output_tag>] [{<input_tag> value} (` {<output_tag> (~ (<ctor> value))})]) - ([code.bit #..Boolean' #..Boolean] - [code.frac #..Number' #..Number] - [code.text #..String' #..String]) + ([code.bit ..#Boolean' ..#Boolean] + [code.frac ..#Number' ..#Number] + [code.text ..#String' ..#String]) {#Array' members} - (` {#..Array ((~! row.row) (~+ (row.list (row\each jsonF members))))}) + (` {..#Array ((~! row.row) (~+ (row.list (row\each jsonF members))))}) {#Object' pairs} - (` {#..Object ((~! dictionary.of_list) + (` {..#Object ((~! dictionary.of_list) (~! text.hash) (list (~+ (|> pairs dictionary.entries @@ -128,46 +128,46 @@ (-> JSON (Try (List String))) (case json {#Object obj} - {#try.Success (dictionary.keys obj)} + {try.#Success (dictionary.keys obj)} _ - {#try.Failure ($_ text\composite "Cannot get the fields of a non-object.")})) + {try.#Failure ($_ text\composite "Cannot get the fields of a non-object.")})) (def: .public (field key json) (-> String JSON (Try JSON)) (case json {#Object obj} (case (dictionary.value key obj) - {#.Some value} - {#try.Success value} + {.#Some value} + {try.#Success value} - #.None - {#try.Failure ($_ text\composite "Missing field '" key "' on object.")}) + {.#None} + {try.#Failure ($_ text\composite "Missing field '" key "' on object.")}) _ - {#try.Failure ($_ text\composite "Cannot get field '" key "' on a non-object.")})) + {try.#Failure ($_ text\composite "Cannot get field '" key "' on a non-object.")})) (def: .public (has key value json) (-> String JSON JSON (Try JSON)) (case json {#Object obj} - {#try.Success {#Object (dictionary.has key value obj)}} + {try.#Success {#Object (dictionary.has key value obj)}} _ - {#try.Failure ($_ text\composite "Cannot set field '" key "' on a non-object.")})) + {try.#Failure ($_ text\composite "Cannot set field '" key "' on a non-object.")})) (template [<name> <tag> <type>] [(def: .public (<name> key json) (-> Text JSON (Try <type>)) (case (field key json) - {#try.Success {<tag> value}} - {#try.Success value} + {try.#Success {<tag> value}} + {try.#Success value} - {#try.Success _} - {#try.Failure ($_ text\composite "Wrong value type at key: " key)} + {try.#Success _} + {try.#Failure ($_ text\composite "Wrong value type at key: " key)} - {#try.Failure error} - {#try.Failure error}))] + {try.#Failure error} + {try.#Failure error}))] [boolean_field #Boolean Boolean] [number_field #Number Number] @@ -181,7 +181,7 @@ (def: (= x y) (case [x y] - [#Null #Null] + [{#Null} {#Null}] #1 (^template [<tag> <struct>] @@ -208,8 +208,8 @@ (list\mix (function (_ [xk xv] prev) (and prev (case (dictionary.value xk ys) - #.None #0 - {#.Some yv} (= xv yv)))) + {.#None} #0 + {.#Some yv} (= xv yv)))) #1 (dictionary.entries xs))) @@ -352,10 +352,10 @@ offset (<text>.many <text>.decimal)] (in ($_ text\composite mark (if signed?' "-" "") offset))))] (case (f\decoded ($_ text\composite (if signed? "-" "") digits "." decimals exp)) - {#try.Failure message} + {try.#Failure message} (<>.failure message) - {#try.Success value} + {try.#Success value} (in value)))) (def: escaped_parser diff --git a/stdlib/source/library/lux/data/format/markdown.lux b/stdlib/source/library/lux/data/format/markdown.lux index 8f64a70f0..0e45ec331 100644 --- a/stdlib/source/library/lux/data/format/markdown.lux +++ b/stdlib/source/library/lux/data/format/markdown.lux @@ -110,14 +110,14 @@ (list\each (function (_ [idx [summary detail]]) (format "1. " (:representation summary) (case detail - {#.Some detail} + {.#Some detail} (|> detail :representation ..indent (text.enclosed [text.new_line text.new_line]) (format text.new_line)) - #.None + {.#None} "")))) (text.interposed text.new_line) ..block)) @@ -128,14 +128,14 @@ (|>> (list\each (function (_ [summary detail]) (format "* " (:representation summary) (case detail - {#.Some detail} + {.#Some detail} (|> detail :representation ..indent (text.enclosed [text.new_line text.new_line]) (format text.new_line)) - #.None + {.#None} "")))) (text.interposed text.new_line) ..block)) diff --git a/stdlib/source/library/lux/data/format/tar.lux b/stdlib/source/library/lux/data/format/tar.lux index c33250527..bfc337c87 100644 --- a/stdlib/source/library/lux/data/format/tar.lux +++ b/stdlib/source/library/lux/data/format/tar.lux @@ -76,7 +76,7 @@ (def: .public (<in> value) (-> Nat (Try <type>)) (if (n.< <limit> value) - {#try.Success (:abstraction value)} + {try.#Success (:abstraction value)} (exception.except <exception> [value]))) (def: .public <out> @@ -230,10 +230,10 @@ (def: (un_padded string) (-> Binary (Try Binary)) (case (binary.size string) - 0 {#try.Success string} + 0 {try.#Success string} size (loop [end (-- size)] (case end - 0 {#try.Success (\ utf8.codec encoded "")} + 0 {try.#Success (\ utf8.codec encoded "")} _ (do try.monad [last_char (binary.read/8! end string)] (`` (case (.nat last_char) @@ -261,7 +261,7 @@ binary.size (n.> <size>)) (exception.except <exception> [value]) - {#try.Success (:abstraction value)}) + {try.#Success (:abstraction value)}) (exception.except ..not_ascii [value]))) (def: .public <out> @@ -848,14 +848,14 @@ (def: entry_parser (Parser Entry) ($_ <>.either - (\ <>.monad each (|>> #..Normal) + (\ <>.monad each (|>> {..#Normal}) (<>.either (..file_parser ..normal) (..file_parser ..old_normal))) - (\ <>.monad each (|>> #..Symbolic_Link) + (\ <>.monad each (|>> {..#Symbolic_Link}) (..file_name_parser ..symbolic_link (value@ #link_name))) - (\ <>.monad each (|>> #..Directory) + (\ <>.monad each (|>> {..#Directory}) (..file_name_parser ..directory (value@ #path))) - (\ <>.monad each (|>> #..Contiguous) + (\ <>.monad each (|>> {..#Contiguous}) (..file_parser ..contiguous)))) ... It's safe to implement the parser this way because the range of values for Nat is 2^64 diff --git a/stdlib/source/library/lux/data/format/xml.lux b/stdlib/source/library/lux/data/format/xml.lux index 90aaa1b1e..f2064c166 100644 --- a/stdlib/source/library/lux/data/format/xml.lux +++ b/stdlib/source/library/lux/data/format/xml.lux @@ -58,10 +58,10 @@ (|> (do <>.monad [hex? (<>.maybe (<text>.this "x")) code (case hex? - #.None + {.#None} (<>.codec int.decimal (<text>.many <text>.decimal)) - {#.Some _} + {.#Some _} (<>.codec int.decimal (<text>.many <text>.hexadecimal)))] (in (|> code .nat text.of_char))) (<>.before (<text>.this ";")) @@ -92,10 +92,10 @@ [first_part xml_identifier ?second_part (<| <>.maybe (<>.after (<text>.this ..namespace_separator)) xml_identifier)] (case ?second_part - #.None + {.#None} (in ["" first_part]) - {#.Some second_part} + {.#Some second_part} (in [first_part second_part])))) (def: tag^ namespaced_symbol^) @@ -159,7 +159,7 @@ (Parser XML) (|> (..spaced^ (<text>.many xml_char^)) (<>.either cdata^) - (<>\each (|>> #Text)))) + (<>\each (|>> {#Text})))) (def: null^ (Parser Any) diff --git a/stdlib/source/library/lux/data/name.lux b/stdlib/source/library/lux/data/name.lux index 79d1feef3..86f813cf7 100644 --- a/stdlib/source/library/lux/data/name.lux +++ b/stdlib/source/library/lux/data/name.lux @@ -53,10 +53,10 @@ (def: (decoded input) (case (text.all_split_by ..separator input) (^ (list short)) - {#.Right ["" short]} + {.#Right ["" short]} (^ (list module short)) - {#.Right [module short]} + {.#Right [module short]} _ - {#.Left (text\composite "Invalid format for Name: " input)}))) + {.#Left (text\composite "Invalid format for Name: " input)}))) diff --git a/stdlib/source/library/lux/data/sum.lux b/stdlib/source/library/lux/data/sum.lux index 174a2936f..cd66c8aa4 100644 --- a/stdlib/source/library/lux/data/sum.lux +++ b/stdlib/source/library/lux/data/sum.lux @@ -36,13 +36,13 @@ [(def: .public (<name> items) (All (_ a b) (-> (List (Or a b)) (List <side>))) (case items - #.End - #.End + {.#End} + {.#End} - {#.Item {0 <right?> x} items'} - {#.Item [x (<name> items')]} + {.#Item {0 <right?> x} items'} + {.#Item [x (<name> items')]} - {#.Item _ items'} + {.#Item _ items'} (<name> items')))] [lefts a #0] @@ -52,24 +52,24 @@ (def: .public (partition xs) (All (_ a b) (-> (List (Or a b)) [(List a) (List b)])) (case xs - #.End - [#.End #.End] + {.#End} + [{.#End} {.#End}] - {#.Item x xs'} + {.#Item x xs'} (let [[lefts rights] (partition xs')] (case x - {0 #0 x'} [{#.Item x' lefts} rights] - {0 #1 x'} [lefts {#.Item x' rights}])))) + {0 #0 x'} [{.#Item x' lefts} rights] + {0 #1 x'} [lefts {.#Item x' rights}])))) (def: .public (equivalence left right) (All (_ l r) (-> (Equivalence l) (Equivalence r) (Equivalence (Or l r)))) (implementation (def: (= reference sample) (case [reference sample] - [{#.Left reference} {#.Left sample}] + [{.#Left reference} {.#Left sample}] (\ left = reference sample) - [{#.Right reference} {#.Right sample}] + [{.#Right reference} {.#Right sample}] (\ right = reference sample) _ @@ -83,8 +83,8 @@ (\ right &equivalence))) (def: (hash value) (case value - {#.Left value} + {.#Left value} (\ left hash value) - {#.Right value} + {.#Right value} (\ right hash value))))) diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux index 7823bd333..a95490493 100644 --- a/stdlib/source/library/lux/data/text.lux +++ b/stdlib/source/library/lux/data/text.lux @@ -53,8 +53,8 @@ (def: .public (char index input) (-> Nat Text (Maybe Char)) (if (n.< ("lux text size" input) index) - {#.Some ("lux text char" index input)} - #.None)) + {.#Some ("lux text char" index input)} + {.#None})) (def: .public (index_since offset pattern input) (-> Nat Text Text (Maybe Nat)) @@ -68,19 +68,19 @@ (-> Text Text (Maybe Nat)) (loop [offset 0 output (: (Maybe Nat) - #.None)] + {.#None})] (let [output' ("lux text index" offset part text)] (case output' - #.None + {.#None} output - {#.Some offset'} + {.#Some offset'} (recur (++ offset') output'))))) (def: .public (starts_with? prefix x) (-> Text Text Bit) (case (index prefix x) - {#.Some 0} + {.#Some 0} true _ @@ -89,7 +89,7 @@ (def: .public (ends_with? postfix x) (-> Text Text Bit) (case (last_index postfix x) - {#.Some n} + {.#Some n} (n.= (size x) (n.+ (size postfix) n)) @@ -104,7 +104,7 @@ (def: .public (contains? sub text) (-> Text Text Bit) (case ("lux text index" 0 sub text) - {#.Some _} + {.#Some _} true _ @@ -133,24 +133,24 @@ (def: .public (clip offset size input) (-> Nat Nat Text (Maybe Text)) (if (|> size (n.+ offset) (n.> ("lux text size" input))) - #.None - {#.Some ("lux text clip" offset size input)})) + {.#None} + {.#Some ("lux text clip" offset size input)})) (def: .public (clip_since offset input) (-> Nat Text (Maybe Text)) (let [size ("lux text size" input)] (if (n.> size offset) - #.None - {#.Some ("lux text clip" offset (n.- offset size) input)}))) + {.#None} + {.#Some ("lux text clip" offset (n.- offset size) input)}))) (def: .public (split_at at x) (-> Nat Text (Maybe [Text Text])) (case [(..clip 0 at x) (..clip_since at x)] - [{#.Some pre} {#.Some post}] - {#.Some [pre post]} + [{.#Some pre} {.#Some post}] + {.#Some [pre post]} _ - #.None)) + {.#None})) (def: .public (split_by token sample) (-> Text Text (Maybe [Text Text])) @@ -165,14 +165,14 @@ (loop [input sample output (: (List Text) (list))] (case (..split_by token input) - {#.Some [pre post]} + {.#Some [pre post]} (|> output - {#.Item pre} + {.#Item pre} (recur post)) - #.None + {.#None} (|> output - {#.Item input} + {.#Item input} list.reversed)))) (def: .public (replaced/1 pattern replacement template) @@ -219,10 +219,10 @@ (loop [left "" right template] (case (..split_by pattern right) - {#.Some [pre post]} + {.#Some [pre post]} (recur ($_ "lux text concat" left pre replacement) post) - #.None + {.#None} ("lux text concat" left right))))) (implementation: .public equivalence diff --git a/stdlib/source/library/lux/data/text/encoding/utf8.lux b/stdlib/source/library/lux/data/text/encoding/utf8.lux index fc063228e..40b58a7dc 100644 --- a/stdlib/source/library/lux/data/text/encoding/utf8.lux +++ b/stdlib/source/library/lux/data/text/encoding/utf8.lux @@ -113,7 +113,7 @@ (def: (decoded value) (-> Binary (Try Text)) - (with_expansions [<jvm> {#try.Success (java/lang/String::new value (//.name //.utf_8))}] + (with_expansions [<jvm> {try.#Success (java/lang/String::new value (//.name //.utf_8))}] (for [@.old <jvm> @.jvm <jvm> @@ -121,23 +121,23 @@ (cond ffi.on_nashorn? (|> ("js object new" ("js constant" "java.lang.String") [value "utf8"]) (:as Text) - #try.Success) + {try.#Success}) ffi.on_node_js? (|> (Buffer::from|decoded [value]) (Buffer::toString ["utf8"]) - #try.Success) + {try.#Success}) ... On the browser (|> (TextDecoder::new [(//.name //.utf_8)]) (TextDecoder::decode [value]) - #try.Success)) + {try.#Success})) @.python (try (:as Text ("python object do" "decode" (:expected value) "utf-8"))) @.lua - {#try.Success ("lua utf8 decode" value)} + {try.#Success ("lua utf8 decode" value)} @.ruby (|> value @@ -145,17 +145,17 @@ (RubyArray::pack ["C*"]) (:as RubyString) (RubyString::force_encoding ["UTF-8"]) - #try.Success) + {try.#Success}) @.php (|> value ("php pack" ..php_byte_array_format) - #try.Success) + {try.#Success}) @.scheme (|> value ..utf8->string - #try.Success)]))) + {try.#Success})]))) (implementation: .public codec (Codec Binary Text) diff --git a/stdlib/source/library/lux/data/text/escape.lux b/stdlib/source/library/lux/data/text/escape.lux index 422239a27..67e31e72c 100644 --- a/stdlib/source/library/lux/data/text/escape.lux +++ b/stdlib/source/library/lux/data/text/escape.lux @@ -182,15 +182,15 @@ (case (|> current ("lux text clip" (n.+ ..ascii_escape_offset offset) ..code_size) (\ n.hex decoded)) - {#try.Success char} + {try.#Success char} (let [limit' (|> limit (n.- offset) (n.- ..unicode_escape_offset))] - {#try.Success [(format previous + {try.#Success [(format previous ("lux text clip" 0 offset current) (//.of_char char)) ("lux text clip" (n.+ ..unicode_escape_offset offset) limit' current) limit']}) - {#try.Failure error} + {try.#Failure error} (exception.except ..invalid_unicode_escape [current offset]))) (def: .public (un_escaped text) @@ -234,14 +234,14 @@ _ (recur (++ offset) previous current limit)) - {#try.Success (case previous + {try.#Success (case previous "" current _ (format previous current))}))) (syntax: .public (literal [literal <code>.text]) (case (..un_escaped literal) - {#try.Success un_escaped} + {try.#Success un_escaped} (in (list (code.text un_escaped))) - {#try.Failure error} + {try.#Failure error} (meta.failure error))) diff --git a/stdlib/source/library/lux/data/text/format.lux b/stdlib/source/library/lux/data/text/format.lux index b22f3ce00..03de3ed04 100644 --- a/stdlib/source/library/lux/data/text/format.lux +++ b/stdlib/source/library/lux/data/text/format.lux @@ -125,8 +125,8 @@ (All (_ a) (-> (Format a) (Format (Maybe a)))) (function (_ value) (case value - #.None - "#.None" + {.#None} + "{.#None}" - {#.Some value} - (..format "{#.Some " (format value) "}")))) + {.#Some value} + (..format "{.#Some " (format value) "}")))) diff --git a/stdlib/source/library/lux/data/text/regex.lux b/stdlib/source/library/lux/data/text/regex.lux index 63b112bb4..189665302 100644 --- a/stdlib/source/library/lux/data/text/regex.lux +++ b/stdlib/source/library/lux/data/text/regex.lux @@ -110,8 +110,8 @@ re_range^ re_options^))] (in (case negate? - {#.Some _} (` ((~! <text>.not) ($_ ((~! <>.either)) (~+ parts)))) - #.None (` ($_ ((~! <>.either)) (~+ parts))))))) + {.#Some _} (` ((~! <text>.not) ($_ ((~! <>.either)) (~+ parts)))) + {.#None} (` ($_ ((~! <>.either)) (~+ parts))))))) (def: re_user_class^ (Parser Code) @@ -272,7 +272,7 @@ (type: Re_Group (Variant - #Non_Capturing + {#Non_Capturing} {#Capturing [(Maybe Text) Nat]})) (def: (re_sequential^ capturing? re_scoped^ current_module) @@ -290,19 +290,20 @@ [Nat (List Code) (List (List Code))]) (function (_ part [idx names steps]) (case part - (^or {#.Left complex} {#.Right [#Non_Capturing complex]}) + (^or {.#Left complex} + {.#Right [{#Non_Capturing} complex]}) [idx names (list& (list g!temp complex (` .let) (` [(~ g!total) (\ (~! //.monoid) (~' composite) (~ g!total) (~ g!temp))])) steps)] - {#.Right [{#Capturing [?name num_captures]} scoped]} + {.#Right [{#Capturing [?name num_captures]} scoped]} (let [[idx! name!] (case ?name - {#.Some _name} + {.#Some _name} [idx (code.identifier ["" _name])] - #.None + {.#None} [(++ idx) (code.identifier ["" (n\encoded idx)])]) access (if (n.> 0 num_captures) (` ((~! product.left) (~ name!))) @@ -334,31 +335,31 @@ (All (_ l r) (-> (Parser [Text l]) (Parser [Text r]) (Parser [Text (Or l r)]))) (function (_ input) (case (left input) - {#try.Success [input' [lt lv]]} - {#try.Success [input' [lt {0 #0 lv}]]} + {try.#Success [input' [lt lv]]} + {try.#Success [input' [lt {0 #0 lv}]]} - {#try.Failure _} + {try.#Failure _} (case (right input) - {#try.Success [input' [rt rv]]} - {#try.Success [input' [rt {0 #1 rv}]]} + {try.#Success [input' [rt rv]]} + {try.#Success [input' [rt {0 #1 rv}]]} - {#try.Failure error} - {#try.Failure error})))) + {try.#Failure error} + {try.#Failure error})))) (def: (|||_^ left right) (All (_ l r) (-> (Parser [Text l]) (Parser [Text r]) (Parser Text))) (function (_ input) (case (left input) - {#try.Success [input' [lt lv]]} - {#try.Success [input' lt]} + {try.#Success [input' [lt lv]]} + {try.#Success [input' lt]} - {#try.Failure _} + {try.#Failure _} (case (right input) - {#try.Success [input' [rt rv]]} - {#try.Success [input' rt]} + {try.#Success [input' [rt rv]]} + {try.#Success [input' rt]} - {#try.Failure error} - {#try.Failure error})))) + {try.#Failure error} + {try.#Failure error})))) (def: (prep_alternative [num_captures alt]) (-> [Nat Code] Code) @@ -391,22 +392,22 @@ [_ (<text>.this "(?:") [_ scoped] (re_alternative^ #0 re_scoped^ current_module) _ (<text>.this ")")] - (in [#Non_Capturing scoped])) + (in [{#Non_Capturing} scoped])) (do <>.monad [complex (re_complex^ current_module)] - (in [#Non_Capturing complex])) + (in [{#Non_Capturing} complex])) (do <>.monad [_ (<text>.this "(?<") captured_name name_part^ _ (<text>.this ">") [num_captures pattern] (re_alternative^ #1 re_scoped^ current_module) _ (<text>.this ")")] - (in [{#Capturing [{#.Some captured_name} num_captures]} pattern])) + (in [{#Capturing [{.#Some captured_name} num_captures]} pattern])) (do <>.monad [_ (<text>.this "(") [num_captures pattern] (re_alternative^ #1 re_scoped^ current_module) _ (<text>.this ")")] - (in [{#Capturing [#.None num_captures]} pattern])))) + (in [{#Capturing [{.#None} num_captures]} pattern])))) (def: (regex^ current_module) (-> Text (Parser Code)) @@ -417,11 +418,11 @@ [current_module meta.current_module_name] (case (<text>.result (regex^ current_module) pattern) - {#try.Failure error} + {try.#Failure error} (meta.failure (format "Error while parsing regular-expression:" //.new_line error)) - {#try.Success regex} + {try.#Success regex} (in (list regex))))) (syntax: .public (^regex [[pattern bindings] (<code>.form (<>.and <code>.text (<>.maybe <code>.any))) @@ -430,6 +431,6 @@ (with_identifiers [g!temp] (in (list& (` (^multi (~ g!temp) [((~! <text>.result) (..regex (~ (code.text pattern))) (~ g!temp)) - {#try.Success (~ (maybe.else g!temp bindings))}])) + {try.#Success (~ (maybe.else g!temp bindings))}])) body branches)))) diff --git a/stdlib/source/library/lux/data/text/unicode/block.lux b/stdlib/source/library/lux/data/text/unicode/block.lux index 5abc56ffc..770ae8554 100644 --- a/stdlib/source/library/lux/data/text/unicode/block.lux +++ b/stdlib/source/library/lux/data/text/unicode/block.lux @@ -43,14 +43,14 @@ (-> Block Char) (|>> :representation (value@ <slot>)))] - [start #interval.bottom] - [end #interval.top] + [start interval.bottom] + [end interval.top] ) (def: .public (size block) (-> Block Nat) - (let [start (value@ #interval.bottom (:representation block)) - end (value@ #interval.top (:representation block))] + (let [start (value@ interval.bottom (:representation block)) + end (value@ interval.top (:representation block))] (|> end (n.- start) ++))) (def: .public (within? block char) diff --git a/stdlib/source/library/lux/data/trace.lux b/stdlib/source/library/lux/data/trace.lux index 156497e43..5fdf1b1c4 100644 --- a/stdlib/source/library/lux/data/trace.lux +++ b/stdlib/source/library/lux/data/trace.lux @@ -25,7 +25,7 @@ (def: (out wa) ((value@ #trace wa) - (value@ [#monoid #monoid.identity] wa))) + (value@ [#monoid monoid.#identity] wa))) (def: (disjoint wa) (let [monoid (value@ #monoid wa)] diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index 7b107d8e5..6e582e3fa 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -125,8 +125,8 @@ (loop [idx 0] (let [member ("lua array read" idx tuple)] (if ("lua object nil?" member) - #.End - {#.Item member (recur (++ idx))})))))] + {.#End} + {.#Item member (recur (++ idx))})))))] (as_is)) (def: (tuple_inspection inspection) @@ -135,7 +135,7 @@ (~~ (as_is)))] (`` (|>> (:as (array.Array Any)) <adaption> - (array.list #.None) + (array.list {.#None}) (list\each inspection) (text.interposed " ") (text.enclosed ["[" "]"]))))) @@ -145,9 +145,9 @@ (with_expansions [<jvm> (let [object (:as java/lang/Object value)] (`` (<| (~~ (template [<class> <processing>] [(case (ffi.check <class> object) - {#.Some value} + {.#Some value} (`` (|> value (~~ (template.spliced <processing>)))) - #.None)] + {.#None})] [java/lang/Boolean [(:as .Bit) %.bit]] [java/lang/Long [(:as .Int) %.int]] @@ -155,17 +155,17 @@ [java/lang/String [(:as .Text) %.text]] )) (case (ffi.check [java/lang/Object] object) - {#.Some value} + {.#Some value} (let [value (:as (array.Array java/lang/Object) value)] (case (array.read! 0 value) - (^multi {#.Some tag} + (^multi {.#Some tag} [(ffi.check java/lang/Integer tag) - {#.Some tag}] + {.#Some tag}] [[(array.read! 1 value) (array.read! 2 value)] - [last? {#.Some choice}]]) + [last? {.#Some choice}]]) (let [last? (case last? - {#.Some _} #1 - #.None #0)] + {.#Some _} #1 + {.#None} #0)] (|> (%.format (%.nat (.nat (java/lang/Integer::longValue tag))) " " (%.bit last?) " " (inspection choice)) @@ -173,7 +173,7 @@ _ (tuple_inspection inspection value))) - #.None) + {.#None}) (java/lang/Object::toString object))))] (for [@.old <jvm> @.jvm <jvm> @@ -256,8 +256,8 @@ "number" (case (math::type [value]) - {#.Some "integer"} (|> value (:as .Int) %.int) - {#.Some "float"} (|> value (:as .Frac) %.frac) + {.#Some "integer"} (|> value (:as .Int) %.int) + {.#Some "float"} (|> value (:as .Frac) %.frac) _ (..tostring value)) @@ -300,7 +300,7 @@ [("ruby object nil") Any (new> "nil" [])] )) - (same? (class_of #.None) value_class) + (same? (class_of {.#None}) value_class) (let [variant_tag ("ruby object get" "_lux_tag" value) variant_flag ("ruby object get" "_lux_flag" value) variant_value ("ruby object get" "_lux_value" value)] @@ -447,18 +447,18 @@ representations membersR+ variantV variantV] (case representations - {#.Item leftR {#.Item rightR extraR+}} + {.#Item leftR {.#Item rightR extraR+}} (case (:as (Or Any Any) variantV) - {#.Left left} + {.#Left left} [lefts #0 (leftR left)] - {#.Right right} + {.#Right right} (case extraR+ - #.End + {.#End} [lefts #1 (rightR right)] _ - (recur (++ lefts) {#.Item rightR extraR+} right))) + (recur (++ lefts) {.#Item rightR extraR+} right))) _ (undefined)))] @@ -472,13 +472,13 @@ (let [tuple_body (loop [representations membersR+ tupleV tupleV] (case representations - #.End + {.#End} "" - {#.Item lastR #.End} + {.#Item lastR {.#End}} (lastR tupleV) - {#.Item headR tailR} + {.#Item headR tailR} (let [[leftV rightV] (:as [Any Any] tupleV)] (%.format (headR leftV) " " (recur tailR rightV)))))] (%.format "[" tuple_body "]")))))) @@ -496,10 +496,10 @@ (do <>.monad [[funcT inputsT+] (<type>.applied (<>.and <type>.any (<>.many <type>.any)))] (case (type.applied inputsT+ funcT) - {#.Some outputT} + {.#Some outputT} (<type>.local (list outputT) representation) - #.None + {.#None} (<>.failure ""))) (do <>.monad @@ -512,10 +512,10 @@ (def: .public (representation type value) (-> Type Any (Try Text)) (case (<type>.result ..representation_parser type) - {#try.Success representation} - {#try.Success (representation value)} + {try.#Success representation} + {try.#Success (representation value)} - {#try.Failure _} + {try.#Failure _} (exception.except ..cannot_represent_value type))) (syntax: .public (private [definition <code>.identifier]) @@ -546,9 +546,9 @@ (def: target (<code>.Parser Target) (<>.either (<>.and <code>.local_identifier - (\ <>.monad in #.None)) + (\ <>.monad in {.#None})) (<code>.tuple (<>.and <code>.local_identifier - (\ <>.monad each (|>> #.Some) <code>.any))))) + (\ <>.monad each (|>> {.#Some}) <code>.any))))) (exception: .public (unknown_local_binding [name Text]) (exception.report @@ -569,10 +569,10 @@ (dictionary.of_list text.hash))] targets (: (Meta (List Target)) (case targets - #.End + {.#End} (|> environment dictionary.keys - (list\each (function (_ local) [local #.None])) + (list\each (function (_ local) [local {.#None}])) in) _ @@ -586,10 +586,10 @@ ((~! exception.report) (~+ (list\each (function (_ [name format]) (let [format (case format - #.None + {.#None} (` (~! ..inspection)) - {#.Some format} + {.#Some format} format)] (` [(~ (code.text name)) ((~ format) (~ (code.local_identifier name)))]))) diff --git a/stdlib/source/library/lux/documentation.lux b/stdlib/source/library/lux/documentation.lux index 7ebe3cfdf..818f08761 100644 --- a/stdlib/source/library/lux/documentation.lux +++ b/stdlib/source/library/lux/documentation.lux @@ -35,7 +35,7 @@ ["[0]" syntax]]]]]]]) (template: (|recursion_dummy|) - [{#.Primitive "" #.End}]) + [{.#Primitive "" {.#End}}]) (type: Fragment (Variant @@ -53,23 +53,22 @@ (^template [<tag>] [[[_ _ column] {<tag> _}] column]) - ([#.Bit] - [#.Nat] - [#.Int] - [#.Rev] - [#.Frac] - [#.Text] - [#.Identifier] - [#.Tag]) + ([.#Bit] + [.#Nat] + [.#Int] + [.#Rev] + [.#Frac] + [.#Text] + [.#Identifier]) (^template [<tag>] [[[_ _ column] {<tag> members}] (|> members (list\each reference_column) (list\mix n.min column))]) - ([#.Form] - [#.Variant] - [#.Tuple]) + ([.#Form] + [.#Variant] + [.#Tuple]) )) (def: (padding reference_column [_ old_line old_column] [_ new_line new_column]) @@ -88,49 +87,45 @@ (def: (code_documentation expected_module old_location reference_column example) (-> Text Location Nat Code [Location Text]) (case example - (^template [<tag> <prefix>] - [[new_location {<tag> [module short]}] - (let [documentation (<| (text.prefix <prefix>) - (cond (text\= expected_module module) - short - - (text\= .prelude_module module) - (format "." short) - - ... else - (%.name [module short])))] - [(revised@ #.column (n.+ (text.size documentation)) new_location) - (format (padding reference_column old_location new_location) - documentation)])]) - ([#.Identifier ""] - [#.Tag syntax.sigil]) + [new_location {.#Identifier [module short]}] + (let [documentation (cond (text\= expected_module module) + short + + (text\= .prelude_module module) + (format "." short) + + ... else + (%.name [module short]))] + [(revised@ .#column (n.+ (text.size documentation)) new_location) + (format (padding reference_column old_location new_location) + documentation)]) (^template [<tag> <format>] [[new_location {<tag> value}] (let [documentation (`` (|> value (~~ (template.spliced <format>))))] - [(revised@ #.column (n.+ (text.size documentation)) new_location) + [(revised@ .#column (n.+ (text.size documentation)) new_location) (format (padding reference_column old_location new_location) documentation)])]) - ([#.Bit [%.bit]] - [#.Nat [%.nat]] - [#.Int [%.int]] - [#.Rev [%.rev]] - [#.Frac [%.frac]] - [#.Text [%.text]]) + ([.#Bit [%.bit]] + [.#Nat [%.nat]] + [.#Int [%.int]] + [.#Rev [%.rev]] + [.#Frac [%.frac]] + [.#Text [%.text]]) (^template [|<| |>| <tag>] [[group_location {<tag> members}] (let [[group_location' members_documentation] (list\mix (function (_ part [last_location text_accum]) (let [[member_location member_documentation] (code_documentation expected_module last_location reference_column part)] [member_location (format text_accum member_documentation)])) - [(revised@ #.column ++ group_location) ""] + [(revised@ .#column ++ group_location) ""] members)] - [(revised@ #.column ++ group_location') + [(revised@ .#column ++ group_location') (format (padding reference_column old_location group_location) |<| members_documentation |>|)])]) - ([syntax.open_form syntax.close_form #.Form] - [syntax.open_variant syntax.close_variant #.Variant] - [syntax.open_tuple syntax.close_tuple #.Tuple]) + ([syntax.open_form syntax.close_form .#Form] + [syntax.open_variant syntax.close_variant .#Variant] + [syntax.open_tuple syntax.close_tuple .#Tuple]) )) (def: blank_line @@ -151,7 +146,7 @@ (let [reference_column (..reference_column example) [location _] example] (|> example - (..code_documentation module (with@ #.column reference_column location) reference_column) + (..code_documentation module (with@ .#column reference_column location) reference_column) product.right)))) (def: parameter_name_options "abcdefghijklmnopqrstuvwxyz") @@ -161,10 +156,10 @@ (-> Nat Text) (format "_" (%.nat id)) ... (case (text.char id ..parameter_name_options) - ... {#.Some char} + ... {.#Some char} ... (text.of_char char) - ... #.None + ... {.#None} ... (format (parameter_type_name (n./ parameter_name_options_count id)) ... (parameter_type_name (n.% parameter_name_options_count id)))) ) @@ -192,7 +187,7 @@ (if (type_parameter? id) (let [parameter_id (..parameter_id level id)] (case (list.item parameter_id type_function_arguments) - {#.Some found} + {.#Some found} found _ @@ -222,29 +217,29 @@ (def: (%type' level type_function_name nestable? module type) (-> Nat Text Bit Text Type Text) (case type - {#.Primitive name params} + {.#Primitive name params} (|> params (list\each (|>> (%type' level type_function_name false module) (format " "))) - {#.Item (%.text name)} + {.#Item (%.text name)} text.together (text.enclosed ["(primitive " ")"])) - {#.Sum _} + {.#Sum _} (|> type type.flat_variant (list\each (%type' level type_function_name false module)) (text.interposed " ") (text.enclosed ["(Or " ")"])) - {#.Product _} + {.#Product _} (|> type type.flat_tuple (list\each (%type' level type_function_name false module)) (text.interposed " ") (text.enclosed ["[" "]"])) - {#.Function input output} + {.#Function input output} (let [[ins out] (type.flat_function type)] (format "(-> " (|> ins (list\each (%type' level type_function_name false module)) (text.interposed " ")) @@ -252,14 +247,14 @@ (%type' level type_function_name false module out) ")")) - {#.Parameter idx} + {.#Parameter idx} (parameter_name [type_function_name (list)] level idx) (^template [<tag> <pre> <post>] [{<tag> id} (format <pre> (%.nat id) <post>)]) - ([#.Var "⌈" "⌋"] - [#.Ex "⟨" "⟩"]) + ([.#Var "⌈" "⌋"] + [.#Ex "⟨" "⟩"]) (^template [<tag> <name> <flat>] [{<tag> _} @@ -271,18 +266,18 @@ (format \n (nested " " body_doc)) (format " " body_doc)) ")"))]) - ([#.UnivQ "All" type.flat_univ_q] - [#.ExQ "Ex" type.flat_ex_q]) + ([.#UnivQ "All" type.flat_univ_q] + [.#ExQ "Ex" type.flat_ex_q]) - (^ {#.Apply (|recursion_dummy|) {#.Parameter 0}}) + (^ {.#Apply (|recursion_dummy|) {.#Parameter 0}}) type_function_name - (^ {#.Apply (|recursion_dummy|) {#.UnivQ _ body}}) + (^ {.#Apply (|recursion_dummy|) {.#UnivQ _ body}}) (format "(Rec " type_function_name \n (nested " " (%type' level type_function_name nestable? module body)) ")") - {#.Apply param fun} + {.#Apply param fun} (let [[type_func type_arguments] (type.flat_application type)] (format "(" (%type' level type_function_name false module type_func) " " (|> type_arguments @@ -290,7 +285,7 @@ (text.interposed " ")) ")")) - {#.Named [_module _name] type} + {.#Named [_module _name] type} (cond (text\= module _module) _name @@ -308,38 +303,38 @@ (def: (parameterized_type arity type) (-> Nat Type (Maybe Type)) (case arity - 0 {#.Some type} + 0 {.#Some type} _ (case type - {#.UnivQ _env _type} + {.#UnivQ _env _type} (parameterized_type (-- arity) _type) _ - #.None))) + {.#None}))) (def: (type_definition' nestable? level arity type_function_info tags module type) (-> Bit Nat Nat [Text (List Text)] (List Text) Text Type Text) (case tags (^ (list single_tag)) (format "(Record" \n - " [#" single_tag " " (type_definition' false level arity type_function_info #.None module type) "])") + " [#" single_tag " " (type_definition' false level arity type_function_info {.#None} module type) "])") _ (case type - {#.Primitive name params} + {.#Primitive name params} (case params - #.End + {.#End} (format "(primitive " (%.text name) ")") _ - (format "(primitive " (%.text name) " " (|> params (list\each (type_definition' false level arity type_function_info #.None module)) (text.interposed " ")) ")")) + (format "(primitive " (%.text name) " " (|> params (list\each (type_definition' false level arity type_function_info {.#None} module)) (text.interposed " ")) ")")) - {#.Sum _} + {.#Sum _} (let [members (type.flat_variant type)] (case tags - #.End + {.#End} (format "(Or " (|> members - (list\each (type_definition' false level arity type_function_info #.None module)) + (list\each (type_definition' false level arity type_function_info {.#None} module)) (text.interposed " ")) ")") @@ -348,49 +343,49 @@ (list.zipped/2 tags) (list\each (function (_ [t_name type]) (case type - {#.Product _} + {.#Product _} (let [types (type.flat_tuple type)] - (format " {#" t_name " " + (format " {" t_name " " (|> types - (list\each (type_definition' false level arity type_function_info #.None module)) + (list\each (type_definition' false level arity type_function_info {.#None} module)) (text.interposed " ")) "}")) _ - (format " {#" t_name " " (type_definition' false level arity type_function_info #.None module type) "}")))) + (format " {" t_name " " (type_definition' false level arity type_function_info {.#None} module type) "}")))) (text.interposed \n) (text.enclosed [(format "(Variant" \n) ")"])))) - {#.Product _} + {.#Product _} (let [members (type.flat_tuple type)] (case tags - #.End - (format "[" (|> members (list\each (type_definition' false level arity type_function_info #.None module)) (text.interposed " ")) "]") + {.#End} + (format "[" (|> members (list\each (type_definition' false level arity type_function_info {.#None} module)) (text.interposed " ")) "]") _ (|> members (list.zipped/2 tags) (list\each (function (_ [t_name type]) - (format "#" t_name " " (type_definition' false level arity type_function_info #.None module type)))) + (format t_name " " (type_definition' false level arity type_function_info {.#None} module type)))) (text.interposed (format \n " ")) (text.enclosed [" [" "]"]) (text.enclosed [(format "(Record" \n) ")"])))) - {#.Function input output} + {.#Function input output} (let [[ins out] (type.flat_function type)] - (format "(-> " (|> ins (list\each (type_definition' false level arity type_function_info #.None module)) (text.interposed " ")) + (format "(-> " (|> ins (list\each (type_definition' false level arity type_function_info {.#None} module)) (text.interposed " ")) " " - (type_definition' false level arity type_function_info #.None module out) + (type_definition' false level arity type_function_info {.#None} module out) ")")) - {#.Parameter idx} + {.#Parameter idx} (parameter_name type_function_info level idx) (^template [<tag> <pre>] [{<tag> id} (format <pre> (%.nat id))]) - ([#.Var "-"] - [#.Ex "+"]) + ([.#Var "-"] + [.#Ex "+"]) (^template [<tag> <name> <flat>] [{<tag> _} @@ -398,21 +393,21 @@ args (level_parameters (n.- arity level) level') body_doc (type_definition' nestable? (n.+ level level') arity type_function_info tags module body) fn_name (case type_function_info - [fn_name #.End] fn_name + [fn_name {.#End}] fn_name _ "_")] (format "(" <name> " " "(" fn_name " " (text.interposed " " args) ")" (if nestable? (format \n (..nested " " body_doc)) (format " " body_doc)) ")"))]) - ([#.UnivQ "All" type.flat_univ_q] - [#.ExQ "Ex" type.flat_ex_q]) + ([.#UnivQ "All" type.flat_univ_q] + [.#ExQ "Ex" type.flat_ex_q]) ... Recursive call - (^ {#.Apply (|recursion_dummy|) {#.Parameter 0}}) + (^ {.#Apply (|recursion_dummy|) {.#Parameter 0}}) (product.left type_function_info) - (^ {#.Apply (|recursion_dummy|) {#.UnivQ _ body}}) + (^ {.#Apply (|recursion_dummy|) {.#UnivQ _ body}}) (|> (type_definition' nestable? level arity type_function_info tags module body) (text.all_split_by \n) (list\each (text.prefix " ")) @@ -420,15 +415,15 @@ (text.enclosed [(format "(Rec " (product.left type_function_info) \n) ")"])) - {#.Apply param fun} + {.#Apply param fun} (let [[type_func type_arguments] (type.flat_application type)] (format "(" (type_definition' false level arity type_function_info tags module type_func) " " (|> type_arguments - (list\each (type_definition' false level arity type_function_info #.None module)) + (list\each (type_definition' false level arity type_function_info {.#None} module)) (text.interposed " ")) ")")) - {#.Named [_module _name] type} + {.#Named [_module _name] type} (cond (text\= module _module) _name @@ -443,10 +438,10 @@ (-> Text [Text (List Text)] (List Text) Type Text) (let [arity (list.size parameters)] (case (parameterized_type arity type) - {#.Some type} + {.#Some type} (type_definition' true (-- arity) arity [name parameters] tags module type) - #.None + {.#None} (..type module type)))) (def: description @@ -515,7 +510,7 @@ (<| ((~! md.heading/3)) (~ (code.text (%.code (let [g!name (|> name product.right code.local_identifier)] (case parameters - #.End + {.#End} g!name _ @@ -552,16 +547,16 @@ (~+ (list\each code.local_identifier parameters)))) ... Description (~+ (case description - {#.Some description} + {.#Some description} (list (` (<| ((~! md.paragraph)) ((~! md.text)) (~ description)))) - #.None + {.#None} (list))) ... Examples (~+ (case examples - #.End + {.#End} (list) _ @@ -587,8 +582,8 @@ (syntax: .public (default [[name parameters] ..declaration]) (let [[_ short] name] (in (list (` (: (.List ..Definition) - (list [#..definition (~ (code.text short)) - #..documentation ((~! ..minimal_definition_documentation) + (list [..#definition (~ (code.text short)) + ..#documentation ((~! ..minimal_definition_documentation) ((~ (code.identifier name)) (~+ (list\each code.local_identifier parameters))))]))))))) @@ -597,8 +592,8 @@ (let [[_ short] name] (in (list (` (.def: .public (~ (code.local_identifier short)) (.List ..Definition) - (.list [#..definition (~ (code.text short)) - #..documentation ((~! ..definition_documentation) + (.list [..#definition (~ (code.text short)) + ..#documentation ((~! ..definition_documentation) ((~ (code.identifier name)) (~+ (list\each code.local_identifier parameters))) (~+ extra))]))))))) @@ -635,13 +630,13 @@ (do meta.monad [expected (meta.exports name)] (in (list (` (: (List Module) - (list& [#..module (~ (code.text name)) - #..description (~ description) - #..expected ((~! ..expected) + (list& [..#module (~ (code.text name)) + ..#description (~ description) + ..#expected ((~! ..expected) (~ (code.text (|> expected (list\each product.left) ..expected_format)))) - #..definitions ((~! list.together) (list (~+ definitions)))] + ..#definitions ((~! list.together) (list (~+ definitions)))] ($_ (\ (~! list.monoid) (~' composite)) (: (List Module) (\ (~! list.monoid) (~' identity))) @@ -652,12 +647,12 @@ (|>> (list.sorted text\<) (list\each (function (_ definition) [(md.snippet definition) - #.None])) + {.#None}])) md.numbered_list)) (def: (module_documentation module) (-> Module (Markdown Block)) - (let [(^slots [#expected]) module] + (let [(^open "_[0]") module] ($_ md.then ... Name (md.heading/1 (value@ #module module)) @@ -672,16 +667,16 @@ (|> module (value@ #definitions) (list.only (|>> (value@ #definition) - (set.member? expected))) + (set.member? _#expected))) ..definitions_documentation) ... Missing documentation (case (|> module (value@ #definitions) (list\mix (function (_ definition missing) (set.lacks (value@ #definition definition) missing)) - expected) + _#expected) set.list) - #.End + {.#End} md.empty missing @@ -691,9 +686,11 @@ ... Un-expected documentation (case (|> module (value@ #definitions) - (list.only (|>> (value@ #definition) (set.member? expected) not)) + (list.only (|>> (value@ #definition) + (set.member? _#expected) + not)) (list\each (value@ #definition))) - #.End + {.#End} md.empty un_expected diff --git a/stdlib/source/library/lux/extension.lux b/stdlib/source/library/lux/extension.lux index e4b320a27..e7851f2d3 100644 --- a/stdlib/source/library/lux/extension.lux +++ b/stdlib/source/library/lux/extension.lux @@ -51,10 +51,10 @@ (~ g!_) <end>] (.\ (~! <>.monad) (~' in) (~ body))) (~ g!inputs)) - {#.Right (~ g!_)} + {.#Right (~ g!_)} (~ g!_) - {#.Left (~ g!error)} + {.#Left (~ g!error)} ((~! phase.failure) (~ g!error))) ))))))))] diff --git a/stdlib/source/library/lux/ffi.js.lux b/stdlib/source/library/lux/ffi.js.lux index b827c962f..8230be249 100644 --- a/stdlib/source/library/lux/ffi.js.lux +++ b/stdlib/source/library/lux/ffi.js.lux @@ -144,10 +144,10 @@ (-> Code [Bit Code] Code) (if nullable? (` (case (~ input) - {#.Some (~ g!temp)} + {.#Some (~ g!temp)} (~ g!temp) - #.None + {.#None} ("js object null"))) input)) @@ -164,8 +164,8 @@ (if nullable? (` (let [(~ g!temp) (~ output)] (if ("js object null?" (~ g!temp)) - #.None - {#.Some (~ g!temp)}))) + {.#None} + {.#Some (~ g!temp)}))) (` (let [(~ g!temp) (~ output)] (if (not ("js object null?" (~ g!temp))) (~ g!temp) @@ -330,21 +330,21 @@ (with_identifiers [g!_] (let [constant (` ("js constant" (~ (code.text head))))] (case tail - #.End + {.#End} (in (list (` (: (.Maybe (~ type)) (case (..type_of (~ constant)) "undefined" - #.None + {.#None} (~ g!_) - {#.Some (:as (~ type) (~ constant))}))))) + {.#Some (:as (~ type) (~ constant))}))))) - {#.Item [next tail]} + {.#Item [next tail]} (let [separator "."] (in (list (` (: (.Maybe (~ type)) (case (..type_of (~ constant)) "undefined" - #.None + {.#None} (~ g!_) (..constant (~ type) [(~ (code.local_identifier (%.format head "." next))) @@ -352,10 +352,10 @@ (template: (!defined? <constant>) [(.case (..constant Any <constant>) - #.None + {.#None} .false - {#.Some _} + {.#Some _} .true)]) (template [<name> <constant>] @@ -370,7 +370,7 @@ (def: .public on_node_js? Bit (case (..constant (Object Any) [process]) - {#.Some process} + {.#Some process} (case (:as Text ("js apply" ("js constant" "Object.prototype.toString.call") process)) "[object process]" @@ -379,7 +379,7 @@ _ false) - #.None + {.#None} false)) (template: .public (closure <inputs> <output>) diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux index 10f8723c0..c4056320a 100644 --- a/stdlib/source/library/lux/ffi.jvm.lux +++ b/stdlib/source/library/lux/ffi.jvm.lux @@ -56,7 +56,7 @@ (template [<name> <class>] [(`` (def: .public <name> .Type - {#.Primitive <class> #.End}))] + {.#Primitive <class> {.#End}}))] [Boolean box.boolean] [Byte box.byte] @@ -71,7 +71,7 @@ (template [<name> <class>] [(`` (def: .public <name> .Type - {#.Primitive (reflection.reflection <class>) #.End}))] + {.#Primitive (reflection.reflection <class>) {.#End}}))] ... Primitives [boolean reflection.boolean] @@ -178,32 +178,32 @@ (type: Primitive_Mode (Variant - #ManualPrM - #AutoPrM)) + {#ManualPrM} + {#AutoPrM})) (type: .public Privacy (Variant - #PublicP - #PrivateP - #ProtectedP - #DefaultP)) + {#PublicP} + {#PrivateP} + {#ProtectedP} + {#DefaultP})) (type: .public State (Variant - #VolatileS - #FinalS - #DefaultS)) + {#VolatileS} + {#FinalS} + {#DefaultS})) (type: .public Inheritance (Variant - #FinalI - #AbstractI - #DefaultI)) + {#FinalI} + {#AbstractI} + {#DefaultI})) (type: Class_Kind (Variant - #Class - #Interface)) + {#Class} + {#Interface})) (type: StackFrame (primitive "java/lang/StackTraceElement")) @@ -284,8 +284,8 @@ (type: ImportMethodKind (Variant - #StaticIMK - #VirtualIMK)) + {#StaticIMK} + {#VirtualIMK})) (type: ImportMethodCommons (Record @@ -326,7 +326,7 @@ (def: (primitive_type mode type) (-> Primitive_Mode (Type Primitive) Code) (case mode - #ManualPrM + {#ManualPrM} (cond (\ type.equivalence = type.boolean type) (` ..Boolean) (\ type.equivalence = type.byte type) (` ..Byte) (\ type.equivalence = type.short type) (` ..Short) @@ -338,7 +338,7 @@ ... else (undefined)) - #AutoPrM + {#AutoPrM} (cond (\ type.equivalence = type.boolean type) (` .Bit) @@ -362,10 +362,10 @@ (-> (Type Parameter) Code) (`` (<| (~~ (template [<when> <binding> <then>] [(case (<when> type) - {#.Some <binding>} + {.#Some <binding>} <then> - #.None)] + {.#None})] [parser.var? name (code.identifier ["" name])] [parser.wildcard? _ (` .Any)] @@ -382,20 +382,20 @@ (-> Primitive_Mode (Type Value) Code) (`` (<| (~~ (template [<when> <binding> <then>] [(case (<when> type) - {#.Some <binding>} + {.#Some <binding>} <then> - #.None)] + {.#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)))) #.End}) + {.#Some elementT} + (` {.#Primitive (~ (code.text (..reflection (type.array elementT)))) {.#End}}) - #.None - (` {#.Primitive (~ (code.text array.type_name)) - {#.Item (~ (value_type mode elementT)) #.End}}))])) + {.#None} + (` {.#Primitive (~ (code.text array.type_name)) + {.#Item (~ (value_type mode elementT)) {.#End}}}))])) (undefined) ))) @@ -435,9 +435,9 @@ (^template [<tag>] [[meta {<tag> parts}] [meta {<tag> (list\each (replaced f) parts)}]]) - ([#.Form] - [#.Variant] - [#.Tuple]) + ([.#Form] + [.#Variant] + [.#Tuple]) ast' ast')) @@ -445,7 +445,7 @@ (def: (parser->replacer p ast) (-> (Parser Code) (-> Code Code)) (case (<>.result p (list ast)) - {#.Right [#.End ast']} + {.#Right [.#End ast']} ast' _ @@ -700,7 +700,7 @@ (def: annotation_parameters^ (Parser (List Annotation_Parameter)) - (<code>.tuple (<>.some (<>.and <code>.local_tag <code>.any)))) + (<code>.tuple (<>.some (<>.and <code>.text <code>.any)))) (def: annotation^ (Parser Annotation) @@ -734,10 +734,10 @@ inputs (<code>.tuple (<>.some (..type^ total_vars))) output (..return^ total_vars) exs (..throws_decl^ total_vars)] - (in [[name #PublicP anns] [#method_tvars tvars - #method_inputs inputs - #method_output output - #method_exs exs]])))) + (in [[name {#PublicP} anns] [#method_tvars tvars + #method_inputs inputs + #method_output output + #method_exs exs]])))) (def: state_modifier^ (Parser State) @@ -754,7 +754,7 @@ anns ..annotations^ type (..type^ type_vars) body <code>.any] - (in [[name #PublicP anns] {#ConstantField [type body]}]))) + (in [[name {#PublicP} anns] {#ConstantField [type body]}]))) (<code>.form (do <>.monad [pm privacy_modifier^ sm state_modifier^ @@ -838,7 +838,7 @@ annotations ..annotations^ body <code>.any] (in [[#member_name name - #member_privacy #PublicP + #member_privacy {#PublicP} #member_anns annotations] {#OverridenMethod strict_fp? owner_class method_vars self_name arguments return_type body exs}])))) @@ -947,9 +947,9 @@ ?prim_mode (<>.maybe primitive_mode^) args (..import_member_args^ total_vars) [io? try? maybe?] import_member_return_flags^] - (in {#ConstructorDecl [[#import_member_mode (maybe.else #AutoPrM ?prim_mode) + (in {#ConstructorDecl [[#import_member_mode (maybe.else {#AutoPrM} ?prim_mode) #import_member_alias (maybe.else "new" ?alias) - #import_member_kind #VirtualIMK + #import_member_kind {#VirtualIMK} #import_member_tvars tvars #import_member_args args #import_member_maybe? maybe? @@ -969,7 +969,7 @@ args (..import_member_args^ total_vars) [io? try? maybe?] import_member_return_flags^ return (..return^ total_vars)] - (in {#MethodDecl [[#import_member_mode (maybe.else #AutoPrM ?prim_mode) + (in {#MethodDecl [[#import_member_mode (maybe.else {#AutoPrM} ?prim_mode) #import_member_alias (maybe.else name ?alias) #import_member_kind kind #import_member_tvars tvars @@ -986,7 +986,7 @@ gtype (..type^ owner_vars) maybe? (<>.parses? (<code>.this! (' "?"))) setter? (<>.parses? (<code>.this! (' #!)))] - (in {#FieldAccessDecl [#import_field_mode (maybe.else #AutoPrM ?prim_mode) + (in {#FieldAccessDecl [#import_field_mode (maybe.else {#AutoPrM} ?prim_mode) #import_field_name name #import_field_static? static? #import_field_maybe? maybe? @@ -1004,17 +1004,17 @@ (def: (privacy_modifier$ pm) (-> Privacy Code) (case pm - #PublicP (code.text "public") - #PrivateP (code.text "private") - #ProtectedP (code.text "protected") - #DefaultP (code.text "default"))) + {#PublicP} (code.text "public") + {#PrivateP} (code.text "private") + {#ProtectedP} (code.text "protected") + {#DefaultP} (code.text "default"))) (def: (inheritance_modifier$ im) (-> Inheritance Code) (case im - #FinalI (code.text "final") - #AbstractI (code.text "abstract") - #DefaultI (code.text "default"))) + {#FinalI} (code.text "final") + {#AbstractI} (code.text "abstract") + {#DefaultI} (code.text "default"))) (def: (annotation_parameter$ [name value]) (-> Annotation_Parameter Code) @@ -1046,17 +1046,17 @@ (let [(^slots [#method_tvars #method_inputs #method_output #method_exs]) method_decl] (` ((~ (code.text name)) [(~+ (list\each annotation$ anns))] - [(~+ (list\each var$ method_tvars))] - [(~+ (list\each class$ method_exs))] - [(~+ (list\each value$ method_inputs))] - (~ (return$ method_output)))))) + [(~+ (list\each var$ #method_tvars))] + [(~+ (list\each class$ #method_exs))] + [(~+ (list\each value$ #method_inputs))] + (~ (return$ #method_output)))))) (def: (state_modifier$ sm) (-> State Code) (case sm - #VolatileS (' "volatile") - #FinalS (' "final") - #DefaultS (' "default"))) + {#VolatileS} (' "volatile") + {#FinalS} (' "final") + {#DefaultS} (' "default"))) (def: (field_decl$ [[name pm anns] field]) (-> [Member_Declaration FieldDecl] Code) @@ -1254,16 +1254,16 @@ (with_identifiers [g!temp] (in (list (` (let [(~ g!temp) (~ expr)] (if ("jvm object null?" (~ g!temp)) - #.None - {#.Some (~ g!temp)}))))))) + {.#None} + {.#Some (~ g!temp)}))))))) (syntax: .public (!!! [expr <code>.any]) (with_identifiers [g!value] (in (list (` (.case (~ expr) - {#.Some (~ g!value)} + {.#Some (~ g!value)} (~ g!value) - #.None + {.#None} ("jvm object null"))))))) (syntax: .public (check [class (..type^ (list)) @@ -1273,16 +1273,16 @@ 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 (.:as (~ class_type) + {.#Some (.:as (~ class_type) (~ g!unchecked))} - #.None))] + {.#None}))] (case unchecked - {#.Some unchecked} + {.#Some unchecked} (in (list (` (: (~ check_type) (let [(~ g!unchecked) (~ unchecked)] (~ check_code)))))) - #.None + {.#None} (in (list (` (: (-> (primitive "java.lang.Object") (~ check_type)) (function ((~ g!_) (~ g!unchecked)) (~ check_code)))))) @@ -1319,7 +1319,7 @@ {#MethodDecl [commons _]} (case (value@ #import_member_kind commons) - #StaticIMK + {#StaticIMK} (value@ #import_member_tvars commons) _ @@ -1339,15 +1339,15 @@ (function (_ [maybe? _]) (with_identifiers [arg_name] (in [maybe? arg_name])))) - import_member_args) - .let [input_jvm_types (list\each product.right import_member_args) + #import_member_args) + .let [input_jvm_types (list\each product.right #import_member_args) arg_types (list\each (: (-> [Bit (Type Value)] Code) (function (_ [maybe? arg]) (let [arg_type (value_type (value@ #import_member_mode commons) arg)] (if maybe? (` (Maybe (~ arg_type))) arg_type)))) - import_member_args)]] + #import_member_args)]] (in [arg_inputs input_jvm_types arg_types]))) _ @@ -1399,10 +1399,10 @@ (-> Primitive_Mode [(Type Value) Code] Code) (let [[unboxed refined post] (: [(Type Value) Code (List Code)] (case mode - #ManualPrM + {#ManualPrM} [unboxed raw (list)] - #AutoPrM + {#AutoPrM} (with_expansions [<special+>' (template.spliced <special+>) <cond_cases> (template [<old> <new> <pre> <post>] [(\ type.equivalence = <old> unboxed) @@ -1420,13 +1420,13 @@ raw) (list)])))) unboxed/boxed (case (dictionary.value unboxed ..boxes) - {#.Some boxed} + {.#Some boxed} (<unbox/box> unboxed boxed refined) - #.None + {.#None} refined)] (case post - #.End + {.#End} unboxed/boxed _ @@ -1495,7 +1495,7 @@ (do meta.monad [.let [enum_type (: Code (case class_tvars - #.End + {.#End} (` (primitive (~ (code.text full_name)))) _ @@ -1535,18 +1535,18 @@ (^slots [#import_member_kind]) commons (^slots [#import_method_name]) method [jvm_op object_ast] (: [Text (List Code)] - (case import_member_kind - #StaticIMK + (case #import_member_kind + {#StaticIMK} ["jvm member invoke static" (list)] - #VirtualIMK + {#VirtualIMK} (case kind - #Class + {#Class} ["jvm member invoke virtual" (list g!obj)] - #Interface + {#Interface} ["jvm member invoke interface" (list g!obj)] ))) @@ -1555,7 +1555,7 @@ (` ((~ (code.text jvm_op)) [(~+ (list\each ..var$ class_tvars))] (~ (code.text full_name)) - (~ (code.text import_method_name)) + (~ (code.text #import_method_name)) [(~+ (list\each ..var$ (value@ #import_member_tvars commons)))] (~+ (|> object_ast (list\each ..un_quoted) @@ -1566,7 +1566,7 @@ (list\each ..decorate_input)))))) jvm_interop (: Code (case (type.void? method_return) - {#.Left method_return} + {.#Left method_return} (|> [method_return callC] (with_automatic_output_conversion (value@ #import_member_mode commons)) @@ -1575,7 +1575,7 @@ (with_return_io member)) - {#.Right method_return} + {.#Right method_return} (|> callC (with_return_try member) (with_return_io member))))]] @@ -1655,12 +1655,12 @@ (-> (Type Declaration) (Meta Class_Kind)) (let [[class_name _] (parser.declaration declaration)] (case (load_class class_name) - {#.Right class} + {.#Right class} (\ meta.monad in (if (interface? class) - #Interface - #Class)) + {#Interface} + {#Class})) - {#.Left _} + {.#Left _} (meta.failure (format "Unknown class: " class_name))))) (syntax: .public (import: [declaration ..declaration^ @@ -1695,7 +1695,7 @@ [type.double "jvm array new double"] [type.char "jvm array new char"])) ... else - (in (list (` (: (~ (value_type #ManualPrM (type.array type))) + (in (list (` (: (~ (value_type {#ManualPrM} (type.array type))) ("jvm array new object" (~ g!size)))))))))) (exception: .public (cannot_convert_to_jvm_type [type .Type]) @@ -1708,11 +1708,11 @@ (if (lux_type\= .Any type) (\ meta.monad in $Object) (case type - {#.Primitive name params} + {.#Primitive name params} (`` (cond (~~ (template [<type>] [(text\= (..reflection <type>) name) (case params - #.End + {.#End} (\ meta.monad in <type>) _ @@ -1730,7 +1730,7 @@ (~~ (template [<type>] [(text\= (..reflection (type.array <type>)) name) (case params - #.End + {.#End} (\ meta.monad in (type.array <type>)) _ @@ -1747,7 +1747,7 @@ (text\= array.type_name name) (case params - {#.Item elementLT #.End} + {.#Item elementLT {.#End}} (\ meta.monad each type.array (lux_type->jvm_type elementLT)) @@ -1756,10 +1756,10 @@ (text.starts_with? descriptor.array_prefix name) (case params - #.End + {.#End} (let [[_ unprefixed] (maybe.trusted (text.split_by descriptor.array_prefix name))] (\ meta.monad each type.array - (lux_type->jvm_type {#.Primitive unprefixed (list)}))) + (lux_type->jvm_type {.#Primitive unprefixed (list)}))) _ <failure>) @@ -1772,22 +1772,22 @@ (do meta.monad [paramJT (lux_type->jvm_type paramLT)] (case (parser.parameter? paramJT) - {#.Some paramJT} + {.#Some paramJT} (in paramJT) - #.None + {.#None} <failure>))) params))))) - {#.Apply A F} + {.#Apply A F} (case (lux_type.applied (list A) F) - #.None + {.#None} <failure> - {#.Some type'} + {.#Some type'} (lux_type->jvm_type type')) - {#.Named _ type'} + {.#Named _ type'} (lux_type->jvm_type type') _ @@ -1795,7 +1795,7 @@ (syntax: .public (length [array <code>.any]) (case array - [_ {#.Identifier array_name}] + [_ {.#Identifier array_name}] (do meta.monad [array_type (meta.type array_name) array_jvm_type (lux_type->jvm_type array_type) @@ -1830,7 +1830,7 @@ (syntax: .public (read! [idx <code>.any array <code>.any]) (case array - [_ {#.Identifier array_name}] + [_ {.#Identifier array_name}] (do meta.monad [array_type (meta.type array_name) array_jvm_type (lux_type->jvm_type array_type) @@ -1868,7 +1868,7 @@ value <code>.any array <code>.any]) (case array - [_ {#.Identifier array_name}] + [_ {.#Identifier array_name}] (do meta.monad [array_type (meta.type array_name) array_jvm_type (lux_type->jvm_type array_type) @@ -1907,7 +1907,7 @@ (in (list (` ("jvm object class" (~ (code.text (..reflection type)))))))) (syntax: .public (type [type (..type^ (list))]) - (in (list (..value_type #ManualPrM type)))) + (in (list (..value_type {#ManualPrM} type)))) (exception: .public (cannot_cast_to_non_object [type (Type Value)]) (exception.report @@ -1918,8 +1918,8 @@ object <code>.any]) (case [(parser.array? type) (parser.class? type)] - (^or [{#.Some _} _] [_ {#.Some _}]) - (in (list (` (.: (~ (..value_type #ManualPrM type)) + (^or [{.#Some _} _] [_ {.#Some _}]) + (in (list (` (.: (~ (..value_type {#ManualPrM} type)) ("jvm object cast" (~ object)))))) _ diff --git a/stdlib/source/library/lux/ffi.lua.lux b/stdlib/source/library/lux/ffi.lua.lux index ab6437d36..bfe88282e 100644 --- a/stdlib/source/library/lux/ffi.lua.lux +++ b/stdlib/source/library/lux/ffi.lua.lux @@ -140,10 +140,10 @@ (-> Code [Bit Code] Code) (if nilable? (` (case (~ input) - {#.Some (~ g!temp)} + {.#Some (~ g!temp)} (~ g!temp) - #.None + {.#None} ("lua object nil"))) input)) @@ -152,8 +152,8 @@ (if nilable? (` (let [(~ g!temp) (~ output)] (if ("lua object nil?" (~ g!temp)) - #.None - {#.Some (~ g!temp)}))) + {.#None} + {.#Some (~ g!temp)}))) (` (let [(~ g!temp) (~ output)] (if (not ("lua object nil?" (~ g!temp))) (~ g!temp) @@ -217,7 +217,7 @@ (~+ (list\each (with_nil g!temp) g!inputs))))))))))) (syntax: .public (import: [import ..import]) - ... {#.doc (example "Easily import types, methods, functions and constants." + ... {.#doc (example "Easily import types, methods, functions and constants." ... (import: (os/getenv [..String] "io" "?" ..String)))} (with_identifiers [g!temp] (case import @@ -232,14 +232,14 @@ g!type (code.local_identifier class) real_class (text.replaced "/" "." class) imported (case (text.all_split_by "/" class) - {#.Item head tail} + {.#Item head tail} (list\mix (function (_ sub super) (` ("lua object get" (~ (code.text sub)) (:as (..Object .Any) (~ super))))) (` ("lua import" (~ (code.text head)))) tail) - #.End + {.#End} (` ("lua import" (~ (code.text class)))))] (in (list& (` (type: (~ g!type) (..Object (primitive (~ (code.text real_class)))))) @@ -309,7 +309,7 @@ ))) (template: .public (closure <inputs> <output>) - ... {#.doc (example "Allows defining closures/anonymous-functions in the form that Lua expects." + ... {.#doc (example "Allows defining closures/anonymous-functions in the form that Lua expects." ... "This is useful for adapting Lux functions for usage by Lua code." ... (: ..Function ... (closure [left right] diff --git a/stdlib/source/library/lux/ffi.old.lux b/stdlib/source/library/lux/ffi.old.lux index c59ae94e8..f54bd2b6b 100644 --- a/stdlib/source/library/lux/ffi.old.lux +++ b/stdlib/source/library/lux/ffi.old.lux @@ -72,8 +72,8 @@ (type: BoundKind (Variant - #UpperBound - #LowerBound)) + {#UpperBound} + {#LowerBound})) (type: GenericType (Rec GenericType @@ -88,32 +88,32 @@ (type: Primitive_Mode (Variant - #ManualPrM - #AutoPrM)) + {#ManualPrM} + {#AutoPrM})) (type: .public Privacy (Variant - #PublicP - #PrivateP - #ProtectedP - #DefaultP)) + {#PublicP} + {#PrivateP} + {#ProtectedP} + {#DefaultP})) (type: .public State (Variant - #VolatileS - #FinalS - #DefaultS)) + {#VolatileS} + {#FinalS} + {#DefaultS})) (type: .public Inheritance (Variant - #FinalI - #AbstractI - #DefaultI)) + {#FinalI} + {#AbstractI} + {#DefaultI})) (type: Class_Kind (Variant - #Class - #Interface)) + {#Class} + {#Interface})) (type: Class_Declaration (Record @@ -211,8 +211,8 @@ (type: ImportMethodKind (Variant - #StaticIMK - #VirtualIMK)) + {#StaticIMK} + {#VirtualIMK})) (type: ImportMethodCommons (Record @@ -256,7 +256,7 @@ (case class (^template [<prim> <type>] [<prim> - {#.Some (' <type>)}]) + {.#Some (' <type>)}]) (["boolean" (primitive "java.lang.Boolean")] ["byte" (primitive "java.lang.Byte")] ["short" (primitive "java.lang.Short")] @@ -268,14 +268,14 @@ ["void" .Any]) _ - #.None)) + {.#None})) (def: (auto_primitive_type class) (-> Text (Maybe Code)) (case class (^template [<prim> <type>] [<prim> - {#.Some (' <type>)}]) + {.#Some (' <type>)}]) (["boolean" .Bit] ["byte" .Int] ["short" .Int] @@ -286,7 +286,7 @@ ["void" .Any]) _ - #.None)) + {.#None})) (def: safe (-> Text Text) @@ -298,14 +298,14 @@ (-> Primitive_Mode (List Type_Parameter) Bit GenericType Code) Code) (case [name+params mode in_array?] - (^multi [[prim #.End] #ManualPrM #0] + (^multi [[prim {.#End}] {#ManualPrM} #0] [(manual_primitive_type prim) - {#.Some output}]) + {.#Some output}]) output - (^multi [[prim #.End] #AutoPrM #0] + (^multi [[prim {.#End}] {#AutoPrM} #0] [(auto_primitive_type prim) - {#.Some output}]) + {.#Some output}]) output [[name params] _ _] @@ -321,10 +321,10 @@ (and (text\= name pname) (not (list.empty? pbounds)))) type_params) - #.None + {.#None} (code.identifier ["" name]) - {#.Some [pname pbounds]} + {.#Some [pname pbounds]} (class_type' mode type_params in_array? (maybe.trusted (list.head pbounds)))) {#GenericClass name+params} @@ -335,10 +335,11 @@ (let [=param (class_type' mode type_params #1 param)] (` ((~! array.Array) (~ =param)))) - (^or {#GenericWildcard #.None} {#GenericWildcard {#.Some [#LowerBound _]}}) + (^or {#GenericWildcard {.#None}} + {#GenericWildcard {.#Some [{#LowerBound} _]}}) (` .Any) - {#GenericWildcard {#.Some [#UpperBound upper_bound]}} + {#GenericWildcard {.#Some [{#UpperBound} upper_bound]}} (class_type' mode type_params in_array? upper_bound) )) @@ -355,13 +356,13 @@ (let [=params (list\each (: (-> Type_Parameter Code) (function (_ [pname pbounds]) (case pbounds - #.End + {.#End} (code.identifier ["" pname]) - {#.Item bound1 _} - (class_type #ManualPrM class_params bound1)))) - class_params)] - (` (primitive (~ (code.text (safe class_name))) + {.#Item bound1 _} + (class_type {#ManualPrM} #class_params bound1)))) + #class_params)] + (` (primitive (~ (code.text (safe #class_name))) [(~+ =params)])))) (def: type_var_class Text "java.lang.Object") @@ -374,16 +375,17 @@ (and (text\= name pname) (not (list.empty? pbounds)))) env) - #.None + {.#None} type_var_class - {#.Some [pname pbounds]} + {.#Some [pname pbounds]} (simple_class$ env (maybe.trusted (list.head pbounds)))) - (^or {#GenericWildcard #.None} {#GenericWildcard {#.Some [#LowerBound _]}}) + (^or {#GenericWildcard {.#None}} + {#GenericWildcard {.#Some [{#LowerBound} _]}}) type_var_class - {#GenericWildcard {#.Some [#UpperBound upper_bound]}} + {#GenericWildcard {.#Some [{#UpperBound} upper_bound]}} (simple_class$ env upper_bound) {#GenericClass name env} @@ -395,7 +397,7 @@ (format "[" (simple_class$ env param)) (^template [<prim> <class>] - [{#GenericClass <prim> #.End} + [{#GenericClass <prim> {.#End}} <class>]) (["boolean" "[Z"] ["byte" "[B"] @@ -438,9 +440,9 @@ (^template [<tag>] [[meta {<tag> parts}] [meta {<tag> (list\each (pre_walk_replace f) parts)}]]) - ([#.Form] - [#.Variant] - [#.Tuple]) + ([.#Form] + [.#Variant] + [.#Tuple]) ast' ast')) @@ -448,7 +450,7 @@ (def: (parser_replacer p ast) (-> (Parser Code) (-> Code Code)) (case (<>.result p (list ast)) - {#.Right [#.End ast']} + {.#Right [{.#End} ast']} ast' _ @@ -556,12 +558,12 @@ ($_ <>.either (do <>.monad [_ (<code>.this! (' ?))] - (in {#GenericWildcard #.None})) + (in {#GenericWildcard {.#None}})) (<code>.tuple (do <>.monad [_ (<code>.this! (' ?)) bound_kind bound_kind^ bound recur^] - (in {#GenericWildcard {#.Some [bound_kind bound]}}))) + (in {#GenericWildcard {.#Some [bound_kind bound]}}))) (do <>.monad [name <code>.local_identifier _ (no_periods_assertion name)] @@ -572,7 +574,7 @@ [component recur^] (case component (^template [<class> <name>] - [{#GenericClass <name> #.End} + [{#GenericClass <name> {.#End}} (in {#GenericClass <class> (list)})]) (["[Z" "boolean"] ["[B" "byte"] @@ -639,7 +641,7 @@ (def: annotation_params^ (Parser (List AnnotationParam)) - (<code>.tuple (<>.some (<>.and <code>.local_tag <code>.any)))) + (<code>.tuple (<>.some (<>.and <code>.text <code>.any)))) (def: annotation^ (Parser Annotation) @@ -682,10 +684,10 @@ inputs (<code>.tuple (<>.some (..generic_type^ type_vars))) output (..generic_type^ type_vars) exs (..throws_decl^ type_vars)] - (in [[name #PublicP anns] [#method_tvars tvars - #method_inputs inputs - #method_output output - #method_exs exs]])))) + (in [[name {#PublicP} anns] [#method_tvars tvars + #method_inputs inputs + #method_output output + #method_exs exs]])))) (def: state_modifier^ (Parser State) @@ -702,7 +704,7 @@ anns ..annotations^ type (..generic_type^ type_vars) body <code>.any] - (in [[name #PublicP anns] {#ConstantField [type body]}]))) + (in [[name {#PublicP} anns] {#ConstantField [type body]}]))) (<code>.form (do <>.monad [pm privacy_modifier^ sm state_modifier^ @@ -786,7 +788,7 @@ annotations ..annotations^ body <code>.any] (in [[#member_name name - #member_privacy #PublicP + #member_privacy {#PublicP} #member_anns annotations] {#OverridenMethod strict_fp? owner_class method_vars @@ -894,9 +896,9 @@ ?prim_mode (<>.maybe primitive_mode^) args (..import_member_args^ total_vars) [io? try? maybe?] import_member_return_flags^] - (in {#ConstructorDecl [[#import_member_mode (maybe.else #AutoPrM ?prim_mode) + (in {#ConstructorDecl [[#import_member_mode (maybe.else {#AutoPrM} ?prim_mode) #import_member_alias (maybe.else "new" ?alias) - #import_member_kind #VirtualIMK + #import_member_kind {#VirtualIMK} #import_member_tvars tvars #import_member_args args #import_member_maybe? maybe? @@ -915,7 +917,7 @@ args (..import_member_args^ total_vars) [io? try? maybe?] import_member_return_flags^ return (..generic_type^ total_vars)] - (in {#MethodDecl [[#import_member_mode (maybe.else #AutoPrM ?prim_mode) + (in {#MethodDecl [[#import_member_mode (maybe.else {#AutoPrM} ?prim_mode) #import_member_alias (maybe.else name ?alias) #import_member_kind kind #import_member_tvars tvars @@ -931,8 +933,8 @@ ?prim_mode (<>.maybe primitive_mode^) gtype (..generic_type^ owner_vars) maybe? (<>.parses? (<code>.this! (' "?"))) - setter? (<>.parses? (<code>.this! (' #!)))] - (in {#FieldAccessDecl [#import_field_mode (maybe.else #AutoPrM ?prim_mode) + setter? (<>.parses? (<code>.this! (' "!")))] + (in {#FieldAccessDecl [#import_field_mode (maybe.else {#AutoPrM} ?prim_mode) #import_field_name name #import_field_static? static? #import_field_maybe? maybe? @@ -963,17 +965,17 @@ (def: (privacy_modifier$ pm) (-> Privacy JVM_Code) (case pm - #PublicP "public" - #PrivateP "private" - #ProtectedP "protected" - #DefaultP "default")) + {#PublicP} "public" + {#PrivateP} "private" + {#ProtectedP} "protected" + {#DefaultP} "default")) (def: (inheritance_modifier$ im) (-> Inheritance JVM_Code) (case im - #FinalI "final" - #AbstractI "abstract" - #DefaultI "default")) + {#FinalI} "final" + {#AbstractI} "abstract" + {#DefaultI} "default")) (def: (annotation_param$ [name value]) (-> AnnotationParam JVM_Code) @@ -986,8 +988,8 @@ (def: (bound_kind$ kind) (-> BoundKind JVM_Code) (case kind - #UpperBound "<" - #LowerBound ">")) + {#UpperBound} "<" + {#LowerBound} ">")) (def: (generic_type$ gtype) (-> GenericType JVM_Code) @@ -1001,10 +1003,10 @@ {#GenericArray param} (format "(" array.type_name " " (generic_type$ param) ")") - {#GenericWildcard #.None} + {#GenericWildcard {.#None}} "?" - {#GenericWildcard {#.Some [bound_kind bound]}} + {#GenericWildcard {.#Some [bound_kind bound]}} (format (bound_kind$ bound_kind) (generic_type$ bound)))) (def: (type_param$ [name bounds]) @@ -1013,11 +1015,13 @@ (def: (class_decl$ (^open "[0]")) (-> Class_Declaration JVM_Code) - (format "(" (safe class_name) " " (spaced (list\each type_param$ class_params)) ")")) + (format "(" (safe #class_name) " " (spaced (list\each type_param$ #class_params)) ")")) (def: (super_class_decl$ (^slots [#super_class_name #super_class_params])) (-> Super_Class_Decl JVM_Code) - (format "(" (safe super_class_name) " " (spaced (list\each generic_type$ super_class_params)) ")")) + (format "(" (safe #super_class_name) + " " (spaced (list\each generic_type$ #super_class_params)) + ")")) (def: (method_decl$ [[name pm anns] method_decl]) (-> [Member_Declaration MethodDecl] JVM_Code) @@ -1025,18 +1029,18 @@ (with_parens (spaced (list name (with_brackets (spaced (list\each annotation$ anns))) - (with_brackets (spaced (list\each type_param$ method_tvars))) - (with_brackets (spaced (list\each generic_type$ method_exs))) - (with_brackets (spaced (list\each generic_type$ method_inputs))) - (generic_type$ method_output)) + (with_brackets (spaced (list\each type_param$ #method_tvars))) + (with_brackets (spaced (list\each generic_type$ #method_exs))) + (with_brackets (spaced (list\each generic_type$ #method_inputs))) + (generic_type$ #method_output)) )))) (def: (state_modifier$ sm) (-> State JVM_Code) (case sm - #VolatileS "volatile" - #FinalS "final" - #DefaultS "default")) + {#VolatileS} "volatile" + {#FinalS} "final" + {#DefaultS} "default")) (def: (field_decl$ [[name pm anns] field]) (-> [Member_Declaration FieldDecl] JVM_Code) @@ -1241,16 +1245,16 @@ (with_identifiers [g!temp] (in (list (` (let [(~ g!temp) (~ expr)] (if ("jvm object null?" (~ g!temp)) - #.None - {#.Some (~ g!temp)}))))))) + {.#None} + {.#Some (~ g!temp)}))))))) (syntax: .public (!!! [expr <code>.any]) (with_identifiers [g!value] (in (list (` (.case (~ expr) - {#.Some (~ g!value)} + {.#Some (~ g!value)} (~ g!value) - #.None + {.#None} ("jvm object null"))))))) (syntax: .public (check [class (..generic_type^ (list)) @@ -1260,16 +1264,16 @@ 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 (.:as (~ class_type) + {.#Some (.:as (~ class_type) (~ g!unchecked))} - #.None))] + {.#None}))] (case unchecked - {#.Some unchecked} + {.#Some unchecked} (in (list (` (: (~ check_type) (let [(~ g!unchecked) (~ unchecked)] (~ check_code)))))) - #.None + {.#None} (in (list (` (: (-> (primitive "java.lang.Object") (~ check_type)) (function ((~ g!_) (~ g!unchecked)) (~ check_code)))))) @@ -1304,7 +1308,7 @@ {#MethodDecl [commons _]} (case (value@ #import_member_kind commons) - #StaticIMK + {#StaticIMK} (value@ #import_member_tvars commons) _ @@ -1324,17 +1328,17 @@ (function (_ [maybe? _]) (with_identifiers [arg_name] (in [maybe? arg_name])))) - import_member_args) + #import_member_args) .let [arg_classes (: (List Text) - (list\each (|>> product.right (simple_class$ (list\composite type_params import_member_tvars))) - import_member_args)) + (list\each (|>> product.right (simple_class$ (list\composite type_params #import_member_tvars))) + #import_member_args)) arg_types (list\each (: (-> [Bit GenericType] Code) (function (_ [maybe? arg]) (let [arg_type (class_type (value@ #import_member_mode commons) type_params arg)] (if maybe? (` (Maybe (~ arg_type))) arg_type)))) - import_member_args)]] + #import_member_args)]] (in [arg_inputs arg_classes arg_types]))) _ @@ -1377,8 +1381,8 @@ (def: (free_type_param? [name bounds]) (-> Type_Parameter Bit) (case bounds - #.End #1 - _ #0)) + {.#End} #1 + _ #0)) (def: (lux_type_parameter [name _]) (-> Type_Parameter Code) @@ -1388,10 +1392,10 @@ [(def: (<name> mode [class expression]) (-> Primitive_Mode [Text Code] Code) (case mode - #ManualPrM + {#ManualPrM} expression - #AutoPrM + {#AutoPrM} (case class "byte" (` (<byte> (~ expression))) "short" (` (<short> (~ expression))) @@ -1442,7 +1446,7 @@ (do [! meta.monad] [.let [enum_type (: Code (case class_tvars - #.End + {.#End} (` (primitive (~ (code.text full_name)))) _ @@ -1477,22 +1481,22 @@ (^slots [#import_member_kind]) commons (^slots [#import_method_name]) method [jvm_op object_ast] (: [Text (List Code)] - (case import_member_kind - #StaticIMK + (case #import_member_kind + {#StaticIMK} ["invokestatic" (list)] - #VirtualIMK + {#VirtualIMK} (case kind - #Class + {#Class} ["invokevirtual" (list g!obj)] - #Interface + {#Interface} ["invokeinterface" (list g!obj)] ))) - jvm_extension (code.text (format "jvm " jvm_op ":" full_name ":" import_method_name ":" (text.interposed "," arg_classes))) + jvm_extension (code.text (format "jvm " jvm_op ":" full_name ":" #import_method_name ":" (text.interposed "," arg_classes))) jvm_interop (|> [(simple_class$ (list) (value@ #import_method_return method)) (` ((~ jvm_extension) (~+ (list\each un_quote object_ast)) (~+ (jvm_extension_inputs (value@ #import_member_mode commons) arg_classes arg_function_inputs))))] @@ -1507,52 +1511,52 @@ {#FieldAccessDecl fad} (do meta.monad [.let [(^open "[0]") fad - base_gtype (class_type import_field_mode type_params import_field_type) + base_gtype (class_type #import_field_mode type_params #import_field_type) classC (class_decl_type$ class) - typeC (if import_field_maybe? + typeC (if #import_field_maybe? (` (Maybe (~ base_gtype))) base_gtype) tvar_asts (: (List Code) (|> class_tvars (list.only free_type_param?) (list\each lux_type_parameter))) - 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_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_identifiers [g!obj] - (let [getter_call (if import_field_static? + (let [getter_call (if #import_field_static? (` ((~ getter_name) [])) (` ((~ getter_name) [(~ g!obj) (~! <code>.any)]))) - 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))] + 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))] + (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 (if #import_field_maybe? (` ((~! ???) (~ getter_body))) getter_body) - getter_body (if import_field_setter? + getter_body (if #import_field_setter? (` ((~! io.io) (~ getter_body))) getter_body)] (in (` ((~! syntax:) (~ getter_call) ((~' in) (.list (.` (~ getter_body))))))))) setter_interop (: (Meta (List Code)) - (if import_field_setter? + (if #import_field_setter? (with_identifiers [g!obj g!value] - (let [setter_call (if import_field_static? + (let [setter_call (if #import_field_static? (` ((~ setter_name) [(~ g!value) (~! <code>.any)])) (` ((~ setter_name) [(~ g!value) (~! <code>.any) (~ g!obj) (~! <code>.any)]))) - 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 (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) + setter_command (format (if #import_field_static? "jvm putstatic" "jvm putfield") + ":" full_name ":" #import_field_name) g!obj+ (: (List Code) - (if import_field_static? + (if #import_field_static? (list) (list (un_quote g!obj))))] (in (list (` ((~! syntax:) (~ setter_call) @@ -1583,12 +1587,12 @@ (-> Class_Declaration (Meta Class_Kind)) (let [class_name (..safe class_name)] (case (..load_class class_name) - {#try.Success class} + {try.#Success class} (\ meta.monad in (if (interface? class) - #Interface - #Class)) + {#Interface} + {#Class})) - {#try.Failure error} + {try.#Failure error} (meta.failure (format "Cannot load class: " class_name text.new_line error))))) @@ -1629,18 +1633,18 @@ (if (type\= Any type) (\ meta.monad in "java.lang.Object") (case type - {#.Primitive name params} + {.#Primitive name params} (\ meta.monad in name) - {#.Apply A F} + {.#Apply A F} (case (type.applied (list A) F) - #.None + {.#None} (meta.failure (format "Cannot apply type: " (type.format F) " to " (type.format A))) - {#.Some type'} + {.#Some type'} (type_class_name type')) - {#.Named _ type'} + {.#Named _ type'} (type_class_name type') _ @@ -1649,7 +1653,7 @@ (syntax: .public (read! [idx <code>.any array <code>.any]) (case array - [_ {#.Identifier array_name}] + [_ {.#Identifier array_name}] (do meta.monad [array_type (meta.type array_name) array_jvm_type (type_class_name array_type)] @@ -1678,7 +1682,7 @@ value <code>.any array <code>.any]) (case array - [_ {#.Identifier array_name}] + [_ {.#Identifier array_name}] (do meta.monad [array_type (meta.type array_name) array_jvm_type (type_class_name array_type)] @@ -1707,4 +1711,4 @@ (in (list (` ("jvm object class" (~ (code.text (simple_class$ (list) type)))))))) (syntax: .public (type [type (..generic_type^ (list))]) - (in (list (..class_type #ManualPrM (list) type)))) + (in (list (..class_type {#ManualPrM} (list) type)))) diff --git a/stdlib/source/library/lux/ffi.php.lux b/stdlib/source/library/lux/ffi.php.lux index f39cd314a..94732874e 100644 --- a/stdlib/source/library/lux/ffi.php.lux +++ b/stdlib/source/library/lux/ffi.php.lux @@ -148,10 +148,10 @@ (-> Code [Bit Code] Code) (if nullable? (` (case (~ input) - {#.Some (~ g!temp)} + {.#Some (~ g!temp)} (~ g!temp) - #.Null + {.#Null} ("php object null"))) input)) @@ -160,8 +160,8 @@ (if nullable? (` (let [(~ g!temp) (~ output)] (if ("php object null?" (~ g!temp)) - #.None - {#.Some (~ g!temp)}))) + {.#None} + {.#Some (~ g!temp)}))) (` (let [(~ g!temp) (~ output)] (if (not ("php object null?" (~ g!temp))) (~ g!temp) @@ -187,11 +187,11 @@ )) (syntax: .public (try [expression <code>.any]) - ... {#.doc (example (case (try (risky_computation input)) - ... {#.Right success} + ... {.#doc (example (case (try (risky_computation input)) + ... {.#Right success} ... (do_something success) - ... {#.Left error} + ... {.#Left error} ... (recover_from_failure error)))} (in (list (` ("lux try" ((~! io.io) (~ expression))))))) diff --git a/stdlib/source/library/lux/ffi.py.lux b/stdlib/source/library/lux/ffi.py.lux index fafac379e..b425c9f3b 100644 --- a/stdlib/source/library/lux/ffi.py.lux +++ b/stdlib/source/library/lux/ffi.py.lux @@ -143,10 +143,10 @@ (-> Code [Bit Code] Code) (if noneable? (` (case (~ input) - {#.Some (~ g!temp)} + {.#Some (~ g!temp)} (~ g!temp) - #.None + {.#None} ("python object none"))) input)) @@ -155,8 +155,8 @@ (if noneable? (` (let [(~ g!temp) (~ output)] (if ("python object none?" (~ g!temp)) - #.None - {#.Some (~ g!temp)}))) + {.#None} + {.#Some (~ g!temp)}))) (` (let [(~ g!temp) (~ output)] (if (not ("python object none?" (~ g!temp))) (~ g!temp) @@ -217,7 +217,7 @@ (~+ (list\each (with_none g!temp) g!inputs))))))))))) (syntax: .public (import: [import ..import]) - ... {#.doc (example "Easily import types, methods, functions and constants." + ... {.#doc (example "Easily import types, methods, functions and constants." ... (import: os ... ["[1]::[0]" ... ("static" F_OK ..Integer) @@ -252,14 +252,14 @@ g!type (code.local_identifier class) real_class (text.replaced "/" "." class) imported (case (text.all_split_by "/" class) - {#.Item head tail} + {.#Item head tail} (list\mix (function (_ sub super) (` ("python object get" (~ (code.text sub)) (:as (..Object .Any) (~ super))))) (` ("python import" (~ (code.text head)))) tail) - #.End + {.#End} (` ("python import" (~ (code.text class)))))] (in (list& (` (type: (~ g!type) (..Object (primitive (~ (code.text real_class)))))) @@ -334,7 +334,7 @@ ))) (template: .public (lambda <inputs> <output>) - ... {#.doc (example "Allows defining closures/anonymous-functions in the form that Python expects." + ... {.#doc (example "Allows defining closures/anonymous-functions in the form that Python expects." ... "This is useful for adapting Lux functions for usage by Python code." ... (: ..Function ... (lambda [left right] diff --git a/stdlib/source/library/lux/ffi.rb.lux b/stdlib/source/library/lux/ffi.rb.lux index d025b4b23..366dc65de 100644 --- a/stdlib/source/library/lux/ffi.rb.lux +++ b/stdlib/source/library/lux/ffi.rb.lux @@ -148,10 +148,10 @@ (-> Code [Bit Code] Code) (if nilable? (` (case (~ input) - {#.Some (~ g!temp)} + {.#Some (~ g!temp)} (~ g!temp) - #.None + {.#None} ("ruby object nil"))) input)) @@ -160,8 +160,8 @@ (if nilable? (` (let [(~ g!temp) (~ output)] (if ("ruby object nil?" (~ g!temp)) - #.None - {#.Some (~ g!temp)}))) + {.#None} + {.#Some (~ g!temp)}))) (` (let [(~ g!temp) (~ output)] (if (not ("ruby object nil?" (~ g!temp))) (~ g!temp) @@ -243,10 +243,10 @@ g!type (code.local_identifier (maybe.else class alias)) module_import (: (List Code) (case ?module - {#.Some module} + {.#Some module} (list (` ("ruby import" (~ (code.text module))))) - #.None + {.#None} (list))) class_import (` ("ruby constant" (~ (code.text class))))] (in (list& (` (type: (~ g!type) @@ -307,10 +307,10 @@ {#Function [name alias inputsT io? try? outputT]} (let [imported (` (.exec (~+ (case ?module - {#.Some module} + {.#Some module} (list (` ("ruby import" (~ (code.text module))))) - #.None + {.#None} (list))) ("ruby constant" (~ (code.text name)))))] (in (list (..make_function (code.local_identifier (maybe.else name alias)) @@ -324,10 +324,10 @@ {#Constant [_ name alias fieldT]} (let [imported (` (.exec (~+ (case ?module - {#.Some module} + {.#Some module} (list (` ("ruby import" (~ (code.text module))))) - #.None + {.#None} (list))) ("ruby constant" (~ (code.text name)))))] (in (list (` ((~! syntax:) ((~ (code.local_identifier (maybe.else name alias))) []) diff --git a/stdlib/source/library/lux/ffi.scm.lux b/stdlib/source/library/lux/ffi.scm.lux index 5d78822f3..ba47e81ca 100644 --- a/stdlib/source/library/lux/ffi.scm.lux +++ b/stdlib/source/library/lux/ffi.scm.lux @@ -120,10 +120,10 @@ (-> Code [Bit Code] Code) (if nilable? (` (case (~ input) - {#.Some (~ g!temp)} + {.#Some (~ g!temp)} (~ g!temp) - #.None + {.#None} ("scheme object nil"))) input)) @@ -132,8 +132,8 @@ (if nilable? (` (let [(~ g!temp) (~ output)] (if ("scheme object nil?" (~ g!temp)) - #.None - {#.Some (~ g!temp)}))) + {.#None} + {.#Some (~ g!temp)}))) (` (let [(~ g!temp) (~ output)] (if (not ("scheme object nil?" (~ g!temp))) (~ g!temp) @@ -152,11 +152,11 @@ )) (syntax: .public (try [expression <code>.any]) - ... {#.doc (example (case (try (risky_computation input)) - ... {#.Right success} + ... {.#doc (example (case (try (risky_computation input)) + ... {.#Right success} ... (do_something success) - ... {#.Left error} + ... {.#Left error} ... (recover_from_failure error)))} (in (list (` ("lux try" ((~! io.io) (~ expression))))))) diff --git a/stdlib/source/library/lux/macro.lux b/stdlib/source/library/lux/macro.lux index 5962e36fa..c1b8db599 100644 --- a/stdlib/source/library/lux/macro.lux +++ b/stdlib/source/library/lux/macro.lux @@ -21,14 +21,14 @@ (def: .public (single_expansion syntax) (-> Code (Meta (List Code))) (case syntax - [_ {#.Form {#.Item [[_ {#.Identifier name}] args]}}] + [_ {.#Form {.#Item [[_ {.#Identifier name}] args]}}] (do //.monad [?macro (//.macro name)] (case ?macro - {#.Some macro} + {.#Some macro} ((:as Macro' macro) args) - #.None + {.#None} (\ //.monad in (list syntax)))) _ @@ -37,18 +37,18 @@ (def: .public (expansion syntax) (-> Code (Meta (List Code))) (case syntax - [_ {#.Form {#.Item [[_ {#.Identifier name}] args]}}] + [_ {.#Form {.#Item [[_ {.#Identifier name}] args]}}] (do //.monad [?macro (//.macro name)] (case ?macro - {#.Some macro} + {.#Some macro} (do [! //.monad] [top_level_expansion ((:as Macro' macro) args)] (|> top_level_expansion (monad.each //.monad expansion) (\ ! each list\conjoint))) - #.None + {.#None} (\ //.monad in (list syntax)))) _ @@ -57,33 +57,33 @@ (def: .public (full_expansion syntax) (-> Code (Meta (List Code))) (case syntax - [_ {#.Form {#.Item [[_ {#.Identifier name}] args]}}] + [_ {.#Form {.#Item [[_ {.#Identifier name}] args]}}] (do //.monad [?macro (//.macro name)] (case ?macro - {#.Some macro} + {.#Some macro} (do //.monad [expansion ((:as Macro' macro) args) expansion' (monad.each //.monad full_expansion expansion)] (in (list\conjoint expansion'))) - #.None + {.#None} (do //.monad [parts' (monad.each //.monad full_expansion (list& (code.identifier name) args))] (in (list (code.form (list\conjoint parts'))))))) - [_ {#.Form {#.Item [harg targs]}}] + [_ {.#Form {.#Item [harg targs]}}] (do //.monad [harg+ (full_expansion harg) targs+ (monad.each //.monad full_expansion targs)] (in (list (code.form (list\composite harg+ (list\conjoint (: (List (List Code)) targs+))))))) - [_ {#.Variant members}] + [_ {.#Variant members}] (do //.monad [members' (monad.each //.monad full_expansion members)] (in (list (code.variant (list\conjoint members'))))) - [_ {#.Tuple members}] + [_ {.#Tuple members}] (do //.monad [members' (monad.each //.monad full_expansion members)] (in (list (code.tuple (list\conjoint members'))))) @@ -103,7 +103,7 @@ (def: (local_identifier ast) (-> Code (Meta Text)) (case ast - [_ {#.Identifier [_ name]}] + [_ {.#Identifier [_ name]}] (\ //.monad in name) _ @@ -117,7 +117,7 @@ (macro: .public (with_identifiers tokens) (case tokens - (^ (list [_ {#.Tuple identifiers}] body)) + (^ (list [_ {.#Tuple identifiers}] body)) (do [! //.monad] [identifier_names (monad.each ! ..local_identifier identifiers) .let [identifier_defs (list\conjoint (list\each (: (-> Text (List Code)) @@ -148,16 +148,16 @@ macro_name [module short]] (case (: (Maybe [Bit Code]) (case tokens - (^ (list [_ {#.Text "omit"}] + (^ (list [_ {.#Text "omit"}] token)) - {#.Some [#1 token]} + {.#Some [#1 token]} (^ (list token)) - {#.Some [#0 token]} + {.#Some [#0 token]} _ - #.None)) - {#.Some [omit? token]} + {.#None})) + {.#Some [omit? token]} (do //.monad [location //.location output (<func> token) @@ -169,7 +169,7 @@ (list) output))) - #.None + {.#None} (//.failure (..wrong_syntax_error macro_name)))))] [log_single_expansion! ..single_expansion] diff --git a/stdlib/source/library/lux/macro/code.lux b/stdlib/source/library/lux/macro/code.lux index aaa054c96..b7c709482 100644 --- a/stdlib/source/library/lux/macro/code.lux +++ b/stdlib/source/library/lux/macro/code.lux @@ -20,17 +20,16 @@ ["[0]" location]]]]) ... (type: (Code' w) -... {#.Bit Bit} -... {#.Nat Nat} -... {#.Int Int} -... {#.Rev Rev} -... {#.Frac Frac} -... {#.Text Text} -... {#.Identifier Name} -... {#.Tag Name} -... {#.Form (List (w (Code' w)))} -... {#.Variant (List (w (Code' w)))} -... {#.Tuple (List (w (Code' w)))}) +... {.#Bit Bit} +... {.#Nat Nat} +... {.#Int Int} +... {.#Rev Rev} +... {.#Frac Frac} +... {.#Text Text} +... {.#Identifier Name} +... {.#Form (List (w (Code' w)))} +... {.#Variant (List (w (Code' w)))} +... {.#Tuple (List (w (Code' w)))}) ... (type: Code ... (Ann Location (Code' (Ann Location)))) @@ -40,17 +39,16 @@ (-> <type> Code) [location.dummy {<tag> x}])] - [bit Bit #.Bit] - [nat Nat #.Nat] - [int Int #.Int] - [rev Rev #.Rev] - [frac Frac #.Frac] - [text Text #.Text] - [identifier Name #.Identifier] - [tag Name #.Tag] - [form (List Code) #.Form] - [variant (List Code) #.Variant] - [tuple (List Code) #.Tuple] + [bit Bit .#Bit] + [nat Nat .#Nat] + [int Int .#Int] + [rev Rev .#Rev] + [frac Frac .#Frac] + [text Text .#Text] + [identifier Name .#Identifier] + [form (List Code) .#Form] + [variant (List Code) .#Variant] + [tuple (List Code) .#Tuple] ) (template [<name> <tag>] @@ -58,8 +56,7 @@ (-> Text Code) [location.dummy {<tag> ["" name]}])] - [local_identifier #.Identifier] - [local_tag #.Tag]) + [local_identifier .#Identifier]) (implementation: .public equivalence (Equivalence Code) @@ -69,21 +66,20 @@ (^template [<tag> <eq>] [[[_ {<tag> x'}] [_ {<tag> y'}]] (\ <eq> = x' y')]) - ([#.Bit bit.equivalence] - [#.Nat nat.equivalence] - [#.Int int.equivalence] - [#.Rev rev.equivalence] - [#.Frac frac.equivalence] - [#.Text text.equivalence] - [#.Identifier name.equivalence] - [#.Tag name.equivalence]) + ([.#Bit bit.equivalence] + [.#Nat nat.equivalence] + [.#Int int.equivalence] + [.#Rev rev.equivalence] + [.#Frac frac.equivalence] + [.#Text text.equivalence] + [.#Identifier name.equivalence]) (^template [<tag>] [[[_ {<tag> xs'}] [_ {<tag> ys'}]] (\ (list.equivalence =) = xs' ys')]) - ([#.Form] - [#.Variant] - [#.Tuple]) + ([.#Form] + [.#Variant] + [.#Tuple]) _ false))) @@ -94,19 +90,16 @@ (^template [<tag> <struct>] [[_ {<tag> value}] (\ <struct> encoded value)]) - ([#.Bit bit.codec] - [#.Nat nat.decimal] - [#.Int int.decimal] - [#.Rev rev.decimal] - [#.Frac frac.decimal] - [#.Identifier name.codec]) + ([.#Bit bit.codec] + [.#Nat nat.decimal] + [.#Int int.decimal] + [.#Rev rev.decimal] + [.#Frac frac.decimal] + [.#Identifier name.codec]) - [_ {#.Text value}] + [_ {.#Text value}] (text.format value) - [_ {#.Tag name}] - (text\composite "#" (\ name.codec encoded name)) - (^template [<tag> <open> <close>] [[_ {<tag> members}] ($_ text\composite @@ -119,9 +112,9 @@ "" members) <close>)]) - ([#.Form "(" ")"] - [#.Variant "{" "}"] - [#.Tuple "[" "]"]) + ([.#Form "(" ")"] + [.#Variant "{" "}"] + [.#Tuple "[" "]"]) )) (def: .public (replaced original substitute ast) @@ -132,9 +125,9 @@ (^template [<tag>] [[location {<tag> parts}] [location {<tag> (list\each (replaced original substitute) parts)}]]) - ([#.Form] - [#.Variant] - [#.Tuple]) + ([.#Form] + [.#Variant] + [.#Tuple]) _ ast))) diff --git a/stdlib/source/library/lux/macro/local.lux b/stdlib/source/library/lux/macro/local.lux index f53a6473b..7fd34c7b3 100644 --- a/stdlib/source/library/lux/macro/local.lux +++ b/stdlib/source/library/lux/macro/local.lux @@ -35,34 +35,34 @@ (def: (with_module name body) (All (_ a) (-> Text (-> Module (Try [Module a])) (Meta a))) (function (_ compiler) - (case (|> compiler (value@ #.modules) (plist.value name)) - {#.Some module} + (case (|> compiler (value@ .#modules) (plist.value name)) + {.#Some module} (case (body module) - {#try.Success [module' output]} - {#try.Success [(revised@ #.modules (plist.has name module') compiler) + {try.#Success [module' output]} + {try.#Success [(revised@ .#modules (plist.has name module') compiler) output]} - {#try.Failure error} - {#try.Failure error}) + {try.#Failure error} + {try.#Failure error}) - #.None + {.#None} (exception.except ..unknown_module [name])))) (def: (push_one [name macro]) (-> [Name Macro] (Meta Any)) (do meta.monad [[module_name definition_name] (meta.normal name) - .let [definition (: Global {#.Definition [false .Macro macro]}) + .let [definition (: Global {.#Definition [false .Macro macro]}) add_macro! (: (-> (PList Global) (PList Global)) (plist.has definition_name definition))]] (..with_module module_name (function (_ module) - (case (|> module (value@ #.definitions) (plist.value definition_name)) - #.None - {#try.Success [(revised@ #.definitions add_macro! module) + (case (|> module (value@ .#definitions) (plist.value definition_name)) + {.#None} + {try.#Success [(revised@ .#definitions add_macro! module) []]} - {#.Some _} + {.#Some _} (exception.except ..cannot_shadow_definition [module_name definition_name])))))) (def: (pop_one name) @@ -73,12 +73,12 @@ (plist.lacks definition_name))]] (..with_module module_name (function (_ module) - (case (|> module (value@ #.definitions) (plist.value definition_name)) - {#.Some _} - {#try.Success [(revised@ #.definitions lacks_macro! module) + (case (|> module (value@ .#definitions) (plist.value definition_name)) + {.#Some _} + {try.#Success [(revised@ .#definitions lacks_macro! module) []]} - #.None + {.#None} (exception.except ..unknown_definition [module_name definition_name])))))) (def: (pop_all macros self) @@ -89,11 +89,11 @@ [_ (monad.each ! ..pop_one macros) _ (..pop_one self) compiler meta.compiler_state] - (in (case (value@ #.expected compiler) - {#.Some _} + (in (case (value@ .#expected compiler) + {.#Some _} (list (' [])) - #.None + {.#None} (list))))))) (def: .public (push macros) diff --git a/stdlib/source/library/lux/macro/syntax.lux b/stdlib/source/library/lux/macro/syntax.lux index 3b885c86a..dcf042ead 100644 --- a/stdlib/source/library/lux/macro/syntax.lux +++ b/stdlib/source/library/lux/macro/syntax.lux @@ -29,19 +29,19 @@ (All (_ a) (-> Code (Parser a) (Parser a))) (function (_ tokens) (case (parser tokens) - {#try.Success [tokens output]} - {#try.Success [tokens output]} + {try.#Success [tokens output]} + {try.#Success [tokens output]} - {#try.Failure error} - {#try.Failure ($_ text\composite + {try.#Failure error} + {try.#Failure ($_ text\composite "Failed to parse: " (code.format binding) text.new_line error)}))) (def: (un_paired pairs) (All (_ a) (-> (List [a a]) (List a))) (case pairs - #.End #.End - {#.Item [[x y] pairs']} (list& x y (un_paired pairs')))) + {.#End} {.#End} + {.#Item [[x y] pairs']} (list& x y (un_paired pairs')))) (def: syntax (Parser [Code [Text (List Code)] Code]) @@ -54,7 +54,7 @@ (macro: .public (syntax: tokens) (case (</>.result ..syntax tokens) - {#try.Success [export_policy [name args] body]} + {try.#Success [export_policy [name args] body]} (with_identifiers [g!tokens g!body g!error] (do [! meta.monad] [_ (if (|> args list.size nat.even?) @@ -67,10 +67,10 @@ (` ((~! ..self_documenting) (' (~ var)) (~ parser)))])] (case var - [_ {#.Identifier ["" _]}] + [_ {.#Identifier ["" _]}] <default> - [_ {#.Identifier _}] + [_ {.#Identifier _}] (in [var parser]) _ @@ -86,11 +86,11 @@ [(~+ (..un_paired vars+parsers))] ((~' in) (~ body)))) (~ g!tokens)) - {#try.Success (~ g!body)} + {try.#Success (~ g!body)} ((~ g!body) (~ g!state)) - {#try.Failure (~ g!error)} - {#try.Failure ((~! text.interposed) (~! text.new_line) (list (~ error_msg) (~ g!error)))}))))))) + {try.#Failure (~ g!error)} + {try.#Failure ((~! text.interposed) (~! text.new_line) (list (~ error_msg) (~ g!error)))}))))))) - {#try.Failure error} + {try.#Failure error} (meta.failure (macro.wrong_syntax_error (name_of ..syntax:))))) diff --git a/stdlib/source/library/lux/macro/syntax/check.lux b/stdlib/source/library/lux/macro/syntax/check.lux index 54558b914..bdc4d9a98 100644 --- a/stdlib/source/library/lux/macro/syntax/check.lux +++ b/stdlib/source/library/lux/macro/syntax/check.lux @@ -32,8 +32,8 @@ (def: .public (format (^slots [#type #value])) (-> Check Code) (` ((~ (code.text ..extension)) - (~ type) - (~ value)))) + (~ #type) + (~ #value)))) (def: .public parser (Parser Check) diff --git a/stdlib/source/library/lux/macro/syntax/declaration.lux b/stdlib/source/library/lux/macro/syntax/declaration.lux index db8d135ca..bb7abe7b0 100644 --- a/stdlib/source/library/lux/macro/syntax/declaration.lux +++ b/stdlib/source/library/lux/macro/syntax/declaration.lux @@ -37,7 +37,7 @@ (-> Declaration Code) (let [g!name (code.local_identifier (value@ #name value))] (case (value@ #arguments value) - #.End + {.#End} g!name arguments diff --git a/stdlib/source/library/lux/macro/syntax/definition.lux b/stdlib/source/library/lux/macro/syntax/definition.lux index 9cbe2fb1a..feb0f908a 100644 --- a/stdlib/source/library/lux/macro/syntax/definition.lux +++ b/stdlib/source/library/lux/macro/syntax/definition.lux @@ -47,21 +47,21 @@ (def: dummy Code - (` [#.module (~ (code.text (value@ #.module location.dummy))) - #.line (~ (code.nat (value@ #.line location.dummy))) - #.column (~ (code.nat (value@ #.column location.dummy)))])) + (` [.#module (~ (code.text (value@ .#module location.dummy))) + .#line (~ (code.nat (value@ .#line location.dummy))) + .#column (~ (code.nat (value@ .#column location.dummy)))])) (def: .public (format (^slots [#name #value #export?])) (-> Definition Code) (` ((~ (code.text ..extension)) - (~ (code.local_identifier name)) - (~ (case value - {#.Left check} + (~ (code.local_identifier #name)) + (~ (case #value + {.#Left check} (//check.format check) - {#.Right value} + {.#Right value} value)) - (~ (code.bit export?))))) + (~ (code.bit #export?))))) (def: .public (parser compiler) (-> Lux (Parser Definition)) @@ -90,9 +90,9 @@ (do <>.monad [definition (..parser compiler) _ (case (value@ #value definition) - {#.Left _} + {.#Left _} (in []) - {#.Right _} + {.#Right _} (<>.lifted (exception.except ..lacks_type [definition])))] (in definition))) diff --git a/stdlib/source/library/lux/macro/syntax/export.lux b/stdlib/source/library/lux/macro/syntax/export.lux index 2d33f7098..6fe7afd4b 100644 --- a/stdlib/source/library/lux/macro/syntax/export.lux +++ b/stdlib/source/library/lux/macro/syntax/export.lux @@ -16,11 +16,11 @@ (do [! <>.monad] [candiate <code>.next] (case candiate - [_ {#.Identifier ["" _]}] + [_ {.#Identifier ["" _]}] (in default_policy) - (^or [_ {#.Bit _}] - [_ {#.Identifier _}]) + (^or [_ {.#Bit _}] + [_ {.#Identifier _}]) (do ! [_ <code>.any] (in candiate)) diff --git a/stdlib/source/library/lux/macro/template.lux b/stdlib/source/library/lux/macro/template.lux index 8be738131..6a5136d15 100644 --- a/stdlib/source/library/lux/macro/template.lux +++ b/stdlib/source/library/lux/macro/template.lux @@ -56,18 +56,13 @@ (def: (snippet module_side?) (-> Bit (Parser Text)) - (.let [full_identifier (..name_side module_side? <code>.identifier) - full_tag (..name_side module_side? <code>.tag)] + (.let [full_identifier (..name_side module_side? <code>.identifier)] ($_ <>.either <code>.text (if module_side? full_identifier (<>.either <code>.local_identifier full_identifier)) - (if module_side? - full_tag - (<>.either <code>.local_tag - full_tag)) (<>\each bit\encoded <code>.bit) (<>\each nat\encoded <code>.nat) (<>\each int\encoded <code>.int) @@ -86,15 +81,14 @@ [(syntax: .public (<name> [name (<>.or (<>.and (..part true) (..part false)) (..part false))]) (case name - {#.Left [simple complex]} + {.#Left [simple complex]} (in (list (<complex> [(text.interposed "" simple) (text.interposed "" complex)]))) - {#.Right simple} + {.#Right simple} (in (list (|> simple (text.interposed "") <simple>)))))] [identifier code.local_identifier code.identifier] - [tag code.local_tag code.tag] ) (type: Environment @@ -103,20 +97,20 @@ (def: (applied env template) (-> Environment Code Code) (case template - [_ {#.Identifier "" name}] + [_ {.#Identifier "" name}] (case (dictionary.value name env) - {#.Some substitute} + {.#Some substitute} substitute - #.None + {.#None} template) (^template [<tag>] [[meta {<tag> elems}] [meta {<tag> (list\each (applied env) elems)}]]) - ([#.Form] - [#.Variant] - [#.Tuple]) + ([.#Form] + [.#Variant] + [.#Tuple]) _ template)) @@ -137,13 +131,13 @@ (-> Local Macro) ("lux macro" (function (_ inputs compiler) - (.let [parameters_amount (list.size parameters) + (.let [parameters_amount (list.size #parameters) inputs_amount (list.size inputs)] (if (nat.= parameters_amount inputs_amount) (.let [environment (: Environment - (|> (list.zipped/2 parameters inputs) + (|> (list.zipped/2 #parameters inputs) (dictionary.of_list text.hash)))] - {#.Right [compiler (list\each (..applied environment) template)]}) + {.#Right [compiler (list\each (..applied environment) #template)]}) (exception.except ..irregular_arguments [parameters_amount inputs_amount])))))) (def: local @@ -162,11 +156,11 @@ [here_name meta.current_module_name expression? (: (Meta Bit) (function (_ lux) - {#try.Success [lux (case (value@ #.expected lux) - #.None + {try.#Success [lux (case (value@ .#expected lux) + {.#None} false - {#.Some _} + {.#Some _} true)]})) g!pop (local.push (list\each (function (_ local) [[here_name (value@ #name local)] diff --git a/stdlib/source/library/lux/math/infix.lux b/stdlib/source/library/lux/math/infix.lux index de54af790..36dd132d6 100644 --- a/stdlib/source/library/lux/math/infix.lux +++ b/stdlib/source/library/lux/math/infix.lux @@ -35,8 +35,7 @@ (<>\each code.rev <code>.rev) (<>\each code.frac <code>.frac) (<>\each code.text <code>.text) - (<>\each code.identifier <code>.identifier) - (<>\each code.tag <code>.tag))) + (<>\each code.identifier <code>.identifier))) (def: expression (Parser Infix) diff --git a/stdlib/source/library/lux/math/modular.lux b/stdlib/source/library/lux/math/modular.lux index fe9ab2bf9..19d08eb66 100644 --- a/stdlib/source/library/lux/math/modular.lux +++ b/stdlib/source/library/lux/math/modular.lux @@ -136,8 +136,8 @@ (let [[modulus value] (:representation modular) [[vk mk] gcd] (i.extended_gcd value (//.divisor modulus))] (case gcd - +1 {#.Some (..modular modulus vk)} - _ #.None))) + +1 {.#Some (..modular modulus vk)} + _ {.#None}))) ) (exception: .public [r% s%] (moduli_are_not_equal [reference (Modulus r%) @@ -151,6 +151,6 @@ (-> (Modulus r%) (Modulus s%) (Try (-> (Mod s%) (Mod r%))))) (if (//.= reference subject) - {#try.Success (|>> ..value + {try.#Success (|>> ..value (..modular reference))} (exception.except ..moduli_are_not_equal [reference subject]))) diff --git a/stdlib/source/library/lux/math/modulus.lux b/stdlib/source/library/lux/math/modulus.lux index c94cbde14..9a0b91b99 100644 --- a/stdlib/source/library/lux/math/modulus.lux +++ b/stdlib/source/library/lux/math/modulus.lux @@ -27,7 +27,7 @@ (Ex (_ %) (-> Int (Try (Modulus %)))) (if (i.= +0 value) (exception.except ..zero_cannot_be_a_modulus []) - {#try.Success (:abstraction value)})) + {try.#Success (:abstraction value)})) (def: .public divisor (All (_ %) (-> (Modulus %) Int)) diff --git a/stdlib/source/library/lux/math/number.lux b/stdlib/source/library/lux/math/number.lux index 4c20fd9fd..b525754f2 100644 --- a/stdlib/source/library/lux/math/number.lux +++ b/stdlib/source/library/lux/math/number.lux @@ -19,7 +19,7 @@ (def: (separator_prefixed? number) (-> Text Bit) (case ("lux text index" 0 ..separator number) - {#.Some 0} + {.#Some 0} #1 _ @@ -32,34 +32,34 @@ (template [<macro> <nat> <int> <rev> <frac> <error>] [(macro: .public (<macro> tokens state) (case tokens - {#.Item [meta {#.Text repr'}] #.End} + {.#Item [meta {.#Text repr'}] {.#End}} (if (..separator_prefixed? repr') - {#try.Failure <error>} + {try.#Failure <error>} (let [repr (..without_separators repr')] (case (\ <nat> decoded repr) - {#try.Success value} - {#try.Success [state (list [meta {#.Nat value}])]} + {try.#Success value} + {try.#Success [state (list [meta {.#Nat value}])]} - (^multi {#try.Failure _} + (^multi {try.#Failure _} [(\ <int> decoded repr) - {#try.Success value}]) - {#try.Success [state (list [meta {#.Int value}])]} + {try.#Success value}]) + {try.#Success [state (list [meta {.#Int value}])]} - (^multi {#try.Failure _} + (^multi {try.#Failure _} [(\ <rev> decoded repr) - {#try.Success value}]) - {#try.Success [state (list [meta {#.Rev value}])]} + {try.#Success value}]) + {try.#Success [state (list [meta {.#Rev value}])]} - (^multi {#try.Failure _} + (^multi {try.#Failure _} [(\ <frac> decoded repr) - {#try.Success value}]) - {#try.Success [state (list [meta {#.Frac value}])]} + {try.#Success value}]) + {try.#Success [state (list [meta {.#Frac value}])]} _ - {#try.Failure <error>}))) + {try.#Failure <error>}))) _ - {#try.Failure <error>}))] + {try.#Failure <error>}))] [bin /nat.binary /int.binary /rev.binary /frac.binary "Invalid binary syntax."] [oct /nat.octal /int.octal /rev.octal /frac.octal "Invalid octal syntax."] diff --git a/stdlib/source/library/lux/math/number/complex.lux b/stdlib/source/library/lux/math/number/complex.lux index 8e649252e..e6b447d69 100644 --- a/stdlib/source/library/lux/math/number/complex.lux +++ b/stdlib/source/library/lux/math/number/complex.lux @@ -29,8 +29,8 @@ (syntax: .public (complex [real <code>.any ?imaginary (<>.maybe <code>.any)]) - (in (list (` [#..real (~ real) - #..imaginary (~ (maybe.else (' +0.0) ?imaginary))])))) + (in (list (` [..#real (~ real) + ..#imaginary (~ (maybe.else (' +0.0) ?imaginary))])))) (def: .public i Complex @@ -112,22 +112,22 @@ (def: .public (/ param input) (-> Complex Complex Complex) (let [(^slots [#real #imaginary]) param] - (if (f.< (f.abs imaginary) - (f.abs real)) - (let [quot (f./ imaginary real) - denom (|> real (f.* quot) (f.+ imaginary))] - [#real (|> (value@ #real input) (f.* quot) (f.+ (value@ #imaginary input)) (f./ denom)) - #imaginary (|> (value@ #imaginary input) (f.* quot) (f.- (value@ #real input)) (f./ denom))]) - (let [quot (f./ real imaginary) - denom (|> imaginary (f.* quot) (f.+ real))] - [#real (|> (value@ #imaginary input) (f.* quot) (f.+ (value@ #real input)) (f./ denom)) - #imaginary (|> (value@ #imaginary input) (f.- (f.* quot (value@ #real input))) (f./ denom))])))) + (if (f.< (f.abs #imaginary) + (f.abs #real)) + (let [quot (f./ #imaginary #real) + denom (|> #real (f.* quot) (f.+ #imaginary))] + [..#real (|> (value@ ..#real input) (f.* quot) (f.+ (value@ ..#imaginary input)) (f./ denom)) + ..#imaginary (|> (value@ ..#imaginary input) (f.* quot) (f.- (value@ ..#real input)) (f./ denom))]) + (let [quot (f./ #real #imaginary) + denom (|> #imaginary (f.* quot) (f.+ #real))] + [..#real (|> (value@ ..#imaginary input) (f.* quot) (f.+ (value@ ..#real input)) (f./ denom)) + ..#imaginary (|> (value@ ..#imaginary input) (f.- (f.* quot (value@ ..#real input))) (f./ denom))])))) (def: .public (/' param subject) (-> Frac Complex Complex) (let [(^slots [#real #imaginary]) subject] - [#real (f./ param real) - #imaginary (f./ param imaginary)])) + [..#real (f./ param #real) + ..#imaginary (f./ param #imaginary)])) (def: .public (% param input) (-> Complex Complex Complex) @@ -141,81 +141,81 @@ (def: .public (cos subject) (-> Complex Complex) (let [(^slots [#real #imaginary]) subject] - [#real (f.* (math.cosh imaginary) - (math.cos real)) - #imaginary (f.opposite (f.* (math.sinh imaginary) - (math.sin real)))])) + [..#real (f.* (math.cosh #imaginary) + (math.cos #real)) + ..#imaginary (f.opposite (f.* (math.sinh #imaginary) + (math.sin #real)))])) (def: .public (cosh subject) (-> Complex Complex) (let [(^slots [#real #imaginary]) subject] - [#real (f.* (math.cos imaginary) - (math.cosh real)) - #imaginary (f.* (math.sin imaginary) - (math.sinh real))])) + [..#real (f.* (math.cos #imaginary) + (math.cosh #real)) + ..#imaginary (f.* (math.sin #imaginary) + (math.sinh #real))])) (def: .public (sin subject) (-> Complex Complex) (let [(^slots [#real #imaginary]) subject] - [#real (f.* (math.cosh imaginary) - (math.sin real)) - #imaginary (f.* (math.sinh imaginary) - (math.cos real))])) + [..#real (f.* (math.cosh #imaginary) + (math.sin #real)) + ..#imaginary (f.* (math.sinh #imaginary) + (math.cos #real))])) (def: .public (sinh subject) (-> Complex Complex) (let [(^slots [#real #imaginary]) subject] - [#real (f.* (math.cos imaginary) - (math.sinh real)) - #imaginary (f.* (math.sin imaginary) - (math.cosh real))])) + [..#real (f.* (math.cos #imaginary) + (math.sinh #real)) + ..#imaginary (f.* (math.sin #imaginary) + (math.cosh #real))])) (def: .public (tan subject) (-> Complex Complex) (let [(^slots [#real #imaginary]) subject - r2 (f.* +2.0 real) - i2 (f.* +2.0 imaginary) + r2 (f.* +2.0 #real) + i2 (f.* +2.0 #imaginary) d (f.+ (math.cos r2) (math.cosh i2))] - [#real (f./ d (math.sin r2)) - #imaginary (f./ d (math.sinh i2))])) + [..#real (f./ d (math.sin r2)) + ..#imaginary (f./ d (math.sinh i2))])) (def: .public (tanh subject) (-> Complex Complex) (let [(^slots [#real #imaginary]) subject - r2 (f.* +2.0 real) - i2 (f.* +2.0 imaginary) + r2 (f.* +2.0 #real) + i2 (f.* +2.0 #imaginary) d (f.+ (math.cosh r2) (math.cos i2))] - [#real (f./ d (math.sinh r2)) - #imaginary (f./ d (math.sin i2))])) + [..#real (f./ d (math.sinh r2)) + ..#imaginary (f./ d (math.sin i2))])) (def: .public (abs subject) (-> Complex Frac) (let [(^slots [#real #imaginary]) subject] - (if (f.< (f.abs imaginary) - (f.abs real)) - (if (f.= +0.0 imaginary) - (f.abs real) - (let [q (f./ imaginary real)] + (if (f.< (f.abs #imaginary) + (f.abs #real)) + (if (f.= +0.0 #imaginary) + (f.abs #real) + (let [q (f./ #imaginary #real)] (f.* (math.pow +0.5 (f.+ +1.0 (f.* q q))) - (f.abs imaginary)))) - (if (f.= +0.0 real) - (f.abs imaginary) - (let [q (f./ real imaginary)] + (f.abs #imaginary)))) + (if (f.= +0.0 #real) + (f.abs #imaginary) + (let [q (f./ #real #imaginary)] (f.* (math.pow +0.5 (f.+ +1.0 (f.* q q))) - (f.abs real))))))) + (f.abs #real))))))) (def: .public (exp subject) (-> Complex Complex) (let [(^slots [#real #imaginary]) subject - r_exp (math.exp real)] - [#real (f.* r_exp (math.cos imaginary)) - #imaginary (f.* r_exp (math.sin imaginary))])) + r_exp (math.exp #real)] + [..#real (f.* r_exp (math.cos #imaginary)) + ..#imaginary (f.* r_exp (math.sin #imaginary))])) (def: .public (log subject) (-> Complex Complex) (let [(^slots [#real #imaginary]) subject] - [#real (|> subject ..abs math.log) - #imaginary (math.atan/2 real imaginary)])) + [..#real (|> subject ..abs math.log) + ..#imaginary (math.atan/2 #real #imaginary)])) (template [<name> <type> <op>] [(def: .public (<name> param input) @@ -233,14 +233,14 @@ (def: .public (root/2 input) (-> Complex Complex) (let [(^slots [#real #imaginary]) input - t (|> input ..abs (f.+ (f.abs real)) (f./ +2.0) (math.pow +0.5))] - (if (f.< +0.0 real) - [#real (f./ (f.* +2.0 t) - (f.abs imaginary)) - #imaginary (f.* t (..with_sign imaginary +1.0))] - [#real t - #imaginary (f./ (f.* +2.0 t) - imaginary)]))) + t (|> input ..abs (f.+ (f.abs #real)) (f./ +2.0) (math.pow +0.5))] + (if (f.< +0.0 #real) + [..#real (f./ (f.* +2.0 t) + (f.abs #imaginary)) + ..#imaginary (f.* t (..with_sign #imaginary +1.0))] + [..#real t + ..#imaginary (f./ (f.* +2.0 t) + #imaginary)]))) (def: (root/2-1z input) (-> Complex Complex) @@ -248,18 +248,18 @@ (def: .public (reciprocal (^slots [#real #imaginary])) (-> Complex Complex) - (if (f.< (f.abs imaginary) - (f.abs real)) - (let [q (f./ imaginary real) - scale (f./ (|> real (f.* q) (f.+ imaginary)) + (if (f.< (f.abs #imaginary) + (f.abs #real)) + (let [q (f./ #imaginary #real) + scale (f./ (|> #real (f.* q) (f.+ #imaginary)) +1.0)] - [#real (f.* q scale) - #imaginary (f.opposite scale)]) - (let [q (f./ real imaginary) - scale (f./ (|> imaginary (f.* q) (f.+ real)) + [..#real (f.* q scale) + ..#imaginary (f.opposite scale)]) + (let [q (f./ #real #imaginary) + scale (f./ (|> #imaginary (f.* q) (f.+ #real)) +1.0)] - [#real scale - #imaginary (|> scale f.opposite (f.* q))]))) + [..#real scale + ..#imaginary (|> scale f.opposite (f.* q))]))) (def: .public (acos input) (-> Complex Complex) @@ -286,7 +286,7 @@ (def: .public (argument (^slots [#real #imaginary])) (-> Complex Frac) - (math.atan/2 real imaginary)) + (math.atan/2 #real #imaginary)) (def: .public (roots nth input) (-> Nat Complex (List Complex)) @@ -305,14 +305,14 @@ (math.cos inner)) imaginary (f.* nth_root_of_abs (math.sin inner))] - [#real real - #imaginary imaginary]))))))) + [..#real real + ..#imaginary imaginary]))))))) (def: .public (approximately? margin_of_error standard value) (-> Frac Complex Complex Bit) (and (f.approximately? margin_of_error - (value@ #..real standard) - (value@ #..real value)) + (value@ ..#real standard) + (value@ ..#real value)) (f.approximately? margin_of_error - (value@ #..imaginary standard) - (value@ #..imaginary value)))) + (value@ ..#imaginary standard) + (value@ ..#imaginary value)))) diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux index 230f18c1d..892274c28 100644 --- a/stdlib/source/library/lux/math/number/frac.lux +++ b/stdlib/source/library/lux/math/number/frac.lux @@ -201,11 +201,11 @@ (def: (decoded input) (case ("lux f64 decode" input) - {#.Some value} - {#try.Success value} + {.#Some value} + {try.#Success value} - #.None - {#try.Failure "Could not decode Frac"}))) + {.#None} + {try.#Failure "Could not decode Frac"}))) (def: log/2 (-> Frac Frac) @@ -355,13 +355,13 @@ (\ codec decoded))] (in [("lux text clip" 0 split_index representation) (//int.* <factor> (.int exponent))]))]) - ([+1 (^or [{#.Some split_index} #.None #.None #.None] - [#.None {#.Some split_index} #.None #.None])] - [-1 (^or [#.None #.None {#.Some split_index} #.None] - [#.None #.None #.None {#.Some split_index}])]) + ([+1 (^or [{.#Some split_index} {.#None} {.#None} {.#None}] + [{.#None} {.#Some split_index} {.#None} {.#None}])] + [-1 (^or [{.#None} {.#None} {.#Some split_index} {.#None}] + [{.#None} {.#None} {.#None} {.#Some split_index}])]) _ - {#try.Success [representation +0]})) + {try.#Success [representation +0]})) (template [<struct> <nat> <int> <error>] [(implementation: .public <struct> @@ -388,7 +388,7 @@ (do [! try.monad] [[mantissa exponent] (..representation_exponent <nat> representation) [whole decimal] (case ("lux text index" 0 "." mantissa) - {#.Some split_index} + {.#Some split_index} (do ! [.let [after_offset (++ split_index) after_length (//nat.- after_offset ("lux text size" mantissa))] @@ -398,8 +398,8 @@ (in [("lux text clip" 0 split_index mantissa) decimal])) - #.None - {#try.Failure ("lux text concat" <error> representation)}) + {.#None} + {try.#Failure ("lux text concat" <error> representation)}) .let [whole ("lux text clip" 1 (-- ("lux text size" whole)) whole)] mantissa (\ <nat> decoded (case decimal 0 whole @@ -410,7 +410,7 @@ (//i64.left_shifted ..sign_offset (.i64 sign)) (//i64.left_shifted ..mantissa_size (.i64 (//int.+ (.int ..double_bias) exponent))) (//i64.zero ..mantissa_size (.i64 mantissa)))))) - {#try.Failure ("lux text concat" <error> representation)}))))] + {try.#Failure ("lux text concat" <error> representation)}))))] [binary //nat.binary //int.binary "Invalid binary syntax: "] [octal //nat.octal //int.octal "Invalid octaladecimal syntax: "] diff --git a/stdlib/source/library/lux/math/number/i16.lux b/stdlib/source/library/lux/math/number/i16.lux index d16ebb6a3..b191de971 100644 --- a/stdlib/source/library/lux/math/number/i16.lux +++ b/stdlib/source/library/lux/math/number/i16.lux @@ -21,6 +21,6 @@ (I64 size))) (def: .public equivalence (Equivalence I16) (\ ..sub &equivalence)) -(def: .public width Nat (\ ..sub width)) +(def: .public width Nat (\ ..sub bits)) (def: .public i16 (-> I64 I16) (\ ..sub narrow)) (def: .public i64 (-> I16 I64) (\ ..sub wide)) diff --git a/stdlib/source/library/lux/math/number/i32.lux b/stdlib/source/library/lux/math/number/i32.lux index 9c71cfdff..8d0e7e2b3 100644 --- a/stdlib/source/library/lux/math/number/i32.lux +++ b/stdlib/source/library/lux/math/number/i32.lux @@ -21,6 +21,6 @@ (I64 size))) (def: .public equivalence (Equivalence I32) (\ ..sub &equivalence)) -(def: .public width Nat (\ ..sub width)) +(def: .public width Nat (\ ..sub bits)) (def: .public i32 (-> I64 I32) (\ ..sub narrow)) (def: .public i64 (-> I32 I64) (\ ..sub wide)) diff --git a/stdlib/source/library/lux/math/number/i64.lux b/stdlib/source/library/lux/math/number/i64.lux index 8ccf4b8c8..cc36ed7c5 100644 --- a/stdlib/source/library/lux/math/number/i64.lux +++ b/stdlib/source/library/lux/math/number/i64.lux @@ -183,7 +183,7 @@ (: (Equivalence (I64 size)) &equivalence) (: Nat - width) + bits) (: (-> I64 (I64 size)) narrow) (: (-> (I64 size) I64) @@ -197,10 +197,10 @@ sign (..bit (-- width)) mantissa (..mask (-- width)) co_mantissa (..xor (.i64 -1) mantissa)] - {#.Some (: Sub + {.#Some (: Sub (implementation (def: &equivalence ..equivalence) - (def: width width) + (def: bits width) (def: (narrow value) (..or (|> value (..and ..sign) (..right_shifted sign_shift)) (|> value (..and mantissa)))) @@ -208,4 +208,4 @@ (.i64 (case (.nat (..and sign value)) 0 value _ (..or co_mantissa value))))))}) - #.None)) + {.#None})) diff --git a/stdlib/source/library/lux/math/number/i8.lux b/stdlib/source/library/lux/math/number/i8.lux index 6f6c77175..4f6695535 100644 --- a/stdlib/source/library/lux/math/number/i8.lux +++ b/stdlib/source/library/lux/math/number/i8.lux @@ -21,6 +21,6 @@ (I64 size))) (def: .public equivalence (Equivalence I8) (\ ..sub &equivalence)) -(def: .public width Nat (\ ..sub width)) +(def: .public width Nat (\ ..sub bits)) (def: .public i8 (-> I64 I8) (\ ..sub narrow)) (def: .public i64 (-> I8 I64) (\ ..sub wide)) diff --git a/stdlib/source/library/lux/math/number/int.lux b/stdlib/source/library/lux/math/number/int.lux index 5c4ff3cd6..9c91fa83b 100644 --- a/stdlib/source/library/lux/math/number/int.lux +++ b/stdlib/source/library/lux/math/number/int.lux @@ -229,8 +229,8 @@ (\ try.functor each (|>> -- .int ..opposite --))) _ - {#try.Failure <error>}) - {#try.Failure <error>}))))] + {try.#Failure <error>}) + {try.#Failure <error>}))))] [binary //nat.binary "Invalid binary syntax for Int: "] [octal //nat.octal "Invalid octal syntax for Int: "] diff --git a/stdlib/source/library/lux/math/number/nat.lux b/stdlib/source/library/lux/math/number/nat.lux index 0b0bf4105..428b8a68e 100644 --- a/stdlib/source/library/lux/math/number/nat.lux +++ b/stdlib/source/library/lux/math/number/nat.lux @@ -191,9 +191,9 @@ (def: (binary_value digit) (-> Nat (Maybe Nat)) (case digit - (^ (char "0")) {#.Some 0} - (^ (char "1")) {#.Some 1} - _ #.None)) + (^ (char "0")) {.#Some 0} + (^ (char "1")) {.#Some 1} + _ {.#None})) (def: (octal_character value) (-> Nat Text) @@ -211,15 +211,15 @@ (def: (octal_value digit) (-> Nat (Maybe Nat)) (case digit - (^ (char "0")) {#.Some 0} - (^ (char "1")) {#.Some 1} - (^ (char "2")) {#.Some 2} - (^ (char "3")) {#.Some 3} - (^ (char "4")) {#.Some 4} - (^ (char "5")) {#.Some 5} - (^ (char "6")) {#.Some 6} - (^ (char "7")) {#.Some 7} - _ #.None)) + (^ (char "0")) {.#Some 0} + (^ (char "1")) {.#Some 1} + (^ (char "2")) {.#Some 2} + (^ (char "3")) {.#Some 3} + (^ (char "4")) {.#Some 4} + (^ (char "5")) {.#Some 5} + (^ (char "6")) {.#Some 6} + (^ (char "7")) {.#Some 7} + _ {.#None})) (def: (decimal_character value) (-> Nat Text) @@ -239,17 +239,17 @@ (def: (decimal_value digit) (-> Nat (Maybe Nat)) (case digit - (^ (char "0")) {#.Some 0} - (^ (char "1")) {#.Some 1} - (^ (char "2")) {#.Some 2} - (^ (char "3")) {#.Some 3} - (^ (char "4")) {#.Some 4} - (^ (char "5")) {#.Some 5} - (^ (char "6")) {#.Some 6} - (^ (char "7")) {#.Some 7} - (^ (char "8")) {#.Some 8} - (^ (char "9")) {#.Some 9} - _ #.None)) + (^ (char "0")) {.#Some 0} + (^ (char "1")) {.#Some 1} + (^ (char "2")) {.#Some 2} + (^ (char "3")) {.#Some 3} + (^ (char "4")) {.#Some 4} + (^ (char "5")) {.#Some 5} + (^ (char "6")) {.#Some 6} + (^ (char "7")) {.#Some 7} + (^ (char "8")) {.#Some 8} + (^ (char "9")) {.#Some 9} + _ {.#None})) (def: (hexadecimal_character value) (-> Nat Text) @@ -276,15 +276,15 @@ (-> Nat (Maybe Nat)) (case digit (^template [<character> <number>] - [(^ (char <character>)) {#.Some <number>}]) + [(^ (char <character>)) {.#Some <number>}]) (["0" 0] ["1" 1] ["2" 2] ["3" 3] ["4" 4] ["5" 5] ["6" 6] ["7" 7] ["8" 8] ["9" 9]) (^template [<lower> <upper> <number>] - [(^or (^ (char <lower>)) (^ (char <upper>))) {#.Some <number>}]) + [(^or (^ (char <lower>)) (^ (char <upper>))) {.#Some <number>}]) (["a" "A" 10] ["b" "B" 11] ["c" "C" 12] ["d" "D" 13] ["e" "E" 14] ["f" "F" 15]) - _ #.None)) + _ {.#None})) (template [<shift> <struct> <to_character> <to_value> <error>] [(implementation: .public <struct> @@ -312,16 +312,16 @@ output 0] (if (..< input_size idx) (case (<to_value> ("lux text char" idx repr)) - {#.Some digit_value} + {.#Some digit_value} (recur (++ idx) (|> output ("lux i64 left-shift" <shift>) ("lux i64 or" digit_value))) _ - {#try.Failure ("lux text concat" <error> repr)}) - {#try.Success output})) - {#try.Failure ("lux text concat" <error> repr)}))))] + {try.#Failure ("lux text concat" <error> repr)}) + {try.#Success output})) + {try.#Failure ("lux text concat" <error> repr)}))))] [1 binary binary_character binary_value "Invalid binary syntax for Nat: "] [3 octal octal_character octal_value "Invalid octal syntax for Nat: "] @@ -345,19 +345,19 @@ (def: (decoded repr) (let [input_size ("lux text size" repr)] - (with_expansions [<failure> {#try.Failure ("lux text concat" "Invalid decimal syntax for Nat: " repr)}] + (with_expansions [<failure> {try.#Failure ("lux text concat" "Invalid decimal syntax for Nat: " repr)}] (if (..> 0 input_size) (loop [idx 0 output 0] (if (..< input_size idx) (case (decimal_value ("lux text char" idx repr)) - #.None + {.#None} <failure> - {#.Some digit_value} + {.#Some digit_value} (recur (++ idx) (|> output (..* 10) (..+ digit_value)))) - {#try.Success output})) + {try.#Success output})) <failure>))))) (implementation: .public hash diff --git a/stdlib/source/library/lux/math/number/ratio.lux b/stdlib/source/library/lux/math/number/ratio.lux index be5bb235a..b7ef79ccb 100644 --- a/stdlib/source/library/lux/math/number/ratio.lux +++ b/stdlib/source/library/lux/math/number/ratio.lux @@ -30,19 +30,19 @@ (def: .public (nat value) (-> Ratio (Maybe Nat)) (case (value@ #denominator value) - 1 {#.Some (value@ #numerator value)} - _ #.None)) + 1 {.#Some (value@ #numerator value)} + _ {.#None})) (def: (normal (^slots [#numerator #denominator])) (-> Ratio Ratio) - (let [common (n.gcd numerator denominator)] - [#numerator (n./ common numerator) - #denominator (n./ common denominator)])) + (let [common (n.gcd #numerator #denominator)] + [..#numerator (n./ common #numerator) + ..#denominator (n./ common #denominator)])) (syntax: .public (ratio [numerator <code>.any ?denominator (<>.maybe <code>.any)]) - (in (list (` ((~! ..normal) [#..numerator (~ numerator) - #..denominator (~ (maybe.else (' 1) ?denominator))]))))) + (in (list (` ((~! ..normal) [..#numerator (~ numerator) + ..#denominator (~ (maybe.else (' 1) ?denominator))]))))) (def: .public (= parameter subject) (-> Ratio Ratio Bit) @@ -123,8 +123,8 @@ (def: .public (reciprocal (^slots [#numerator #denominator])) (-> Ratio Ratio) - [#numerator denominator - #denominator numerator]) + [..#numerator #denominator + ..#denominator #numerator]) (def: separator ":") @@ -132,19 +132,19 @@ (Codec Text Ratio) (def: (encoded (^slots [#numerator #denominator])) - ($_ text\composite (n\encoded numerator) ..separator (n\encoded denominator))) + ($_ text\composite (n\encoded #numerator) ..separator (n\encoded #denominator))) (def: (decoded input) (case (text.split_by ..separator input) - {#.Some [num denom]} + {.#Some [num denom]} (do try.monad [numerator (n\decoded num) denominator (n\decoded denom)] (in (normal [#numerator numerator #denominator denominator]))) - #.None - {#.Left (text\composite "Invalid syntax for ratio: " input)}))) + {.#None} + {.#Left (text\composite "Invalid syntax for ratio: " input)}))) (template [<identity> <composite> <name>] [(implementation: .public <name> diff --git a/stdlib/source/library/lux/math/number/rev.lux b/stdlib/source/library/lux/math/number/rev.lux index a652d3913..9228d6a65 100644 --- a/stdlib/source/library/lux/math/number/rev.lux +++ b/stdlib/source/library/lux/math/number/rev.lux @@ -225,7 +225,7 @@ ("lux text clip" 1 (-- ("lux text size" input)) input)) (template [<struct> <codec> <char_bit_size> <error>] - [(with_expansions [<error_output> (as_is {#try.Failure ("lux text concat" <error> repr)})] + [(with_expansions [<error_output> (as_is {try.#Failure ("lux text concat" <error> repr)})] (implementation: .public <struct> (Codec Text Rev) @@ -253,8 +253,8 @@ (case ("lux text char" 0 repr) (^ (char ".")) (case (\ <codec> decoded (..decimals repr)) - {#try.Success output} - {#try.Success (.rev output)} + {try.#Success output} + {try.#Success (.rev output)} _ <error_output>) @@ -357,18 +357,18 @@ (-> Text (Maybe Digits)) (let [length ("lux text size" input)] (if (//nat.> //i64.width length) - #.None + {.#None} (loop [idx 0 output (..digits [])] (if (//nat.< length idx) (case ("lux text index" 0 ("lux text clip" idx 1 input) "0123456789") - #.None - #.None + {.#None} + {.#None} - {#.Some digit} + {.#Some digit} (recur (++ idx) (digits\put! idx digit output))) - {#.Some output}))))) + {.#Some output}))))) (def: (digits\< param subject) (-> Digits Digits Bit) @@ -425,7 +425,7 @@ (def: (decoded input) (let [dotted? (case ("lux text index" 0 "." input) - {#.Some 0} + {.#Some 0} true _ @@ -435,7 +435,7 @@ (//nat.<= (++ //i64.width)))] (if (and dotted? within_limits?) (case (|> input ..decimals ..text_digits) - {#.Some digits} + {.#Some digits} (loop [digits digits idx 0 output 0] @@ -447,9 +447,9 @@ (recur (digits\-! power digits) (++ idx) (//i64.one (//nat.- idx (-- //i64.width)) output)))) - {#try.Success (.rev output)})) + {try.#Success (.rev output)})) - #.None - {#try.Failure ("lux text concat" "Wrong syntax for Rev: " input)}) - {#try.Failure ("lux text concat" "Wrong syntax for Rev: " input)})) + {.#None} + {try.#Failure ("lux text concat" "Wrong syntax for Rev: " input)}) + {try.#Failure ("lux text concat" "Wrong syntax for Rev: " input)})) )) diff --git a/stdlib/source/library/lux/math/random.lux b/stdlib/source/library/lux/math/random.lux index b7dd727d7..6db4dc53f 100644 --- a/stdlib/source/library/lux/math/random.lux +++ b/stdlib/source/library/lux/math/random.lux @@ -91,10 +91,10 @@ (do ..monad [sample random] (case (check sample) - {#.Some output} + {.#Some output} (in output) - #.None + {.#None} (one check random)))) (def: .public (refined refiner gen) @@ -102,10 +102,10 @@ (do ..monad [sample gen] (case (refiner sample) - {#.Some refined} + {.#Some refined} (in refined) - #.None + {.#None} (refined refiner gen)))) (def: .public bit @@ -233,8 +233,8 @@ (if some? (do ! [value value_gen] - (in {#.Some value})) - (in #.None)))) + (in {.#Some value})) + (in {.#None})))) (def: .public (list size value_gen) (All (_ a) (-> Nat (Random a) (Random (List a)))) @@ -242,7 +242,7 @@ (do ..monad [x value_gen xs (list (-- size) value_gen)] - (in {#.Item x xs})) + (in {.#Item x xs})) (\ ..monad in (.list)))) (def: .public (row size value_gen) @@ -314,29 +314,29 @@ (def: .public month (Random Month) (let [(^open "\[0]") ..monad] - (..either (..either (..either (\in #month.January) - (..either (\in #month.February) - (\in #month.March))) - (..either (\in #month.April) - (..either (\in #month.May) - (\in #month.June)))) - (..either (..either (\in #month.July) - (..either (\in #month.August) - (\in #month.September))) - (..either (\in #month.October) - (..either (\in #month.November) - (\in #month.December))))))) + (..either (..either (..either (\in {month.#January}) + (..either (\in {month.#February}) + (\in {month.#March}))) + (..either (\in {month.#April}) + (..either (\in {month.#May}) + (\in {month.#June})))) + (..either (..either (\in {month.#July}) + (..either (\in {month.#August}) + (\in {month.#September}))) + (..either (\in {month.#October}) + (..either (\in {month.#November}) + (\in {month.#December}))))))) (def: .public day (Random Day) (let [(^open "\[0]") ..monad] - (..either (..either (\in #day.Sunday) - (..either (\in #day.Monday) - (\in #day.Tuesday))) - (..either (..either (\in #day.Wednesday) - (\in #day.Thursday)) - (..either (\in #day.Friday) - (\in #day.Saturday)))))) + (..either (..either (\in {day.#Sunday}) + (..either (\in {day.#Monday}) + (\in {day.#Tuesday}))) + (..either (..either (\in {day.#Wednesday}) + (\in {day.#Thursday})) + (..either (\in {day.#Friday}) + (\in {day.#Saturday})))))) (def: .public (result prng calc) (All (_ a) (-> PRNG (Random a) [PRNG a])) diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux index 433d76d91..dbd7924ce 100644 --- a/stdlib/source/library/lux/meta.lux +++ b/stdlib/source/library/lux/meta.lux @@ -34,11 +34,11 @@ (def: (each f fa) (function (_ lux) (case (fa lux) - {#try.Failure msg} - {#try.Failure msg} + {try.#Failure msg} + {try.#Failure msg} - {#try.Success [lux' a]} - {#try.Success [lux' (f a)]})))) + {try.#Success [lux' a]} + {try.#Success [lux' (f a)]})))) (implementation: .public apply (Apply Meta) @@ -48,16 +48,16 @@ (def: (on fa ff) (function (_ lux) (case (ff lux) - {#try.Success [lux' f]} + {try.#Success [lux' f]} (case (fa lux') - {#try.Success [lux'' a]} - {#try.Success [lux'' (f a)]} + {try.#Success [lux'' a]} + {try.#Success [lux'' (f a)]} - {#try.Failure msg} - {#try.Failure msg}) + {try.#Failure msg} + {try.#Failure msg}) - {#try.Failure msg} - {#try.Failure msg})))) + {try.#Failure msg} + {try.#Failure msg})))) (implementation: .public monad (Monad Meta) @@ -66,15 +66,15 @@ (def: (in x) (function (_ lux) - {#try.Success [lux x]})) + {try.#Success [lux x]})) (def: (conjoint mma) (function (_ lux) (case (mma lux) - {#try.Failure msg} - {#try.Failure msg} + {try.#Failure msg} + {try.#Failure msg} - {#try.Success [lux' ma]} + {try.#Success [lux' ma]} (ma lux'))))) (def: .public (result' lux action) @@ -84,54 +84,54 @@ (def: .public (result lux action) (All (_ a) (-> Lux (Meta a) (Try a))) (case (action lux) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success [_ output]} - {#try.Success output})) + {try.#Success [_ output]} + {try.#Success output})) (def: .public (either left right) (All (_ a) (-> (Meta a) (Meta a) (Meta a))) (function (_ lux) (case (left lux) - {#try.Failure error} + {try.#Failure error} (right lux) - {#try.Success [lux' output]} - {#try.Success [lux' output]}))) + {try.#Success [lux' output]} + {try.#Success [lux' output]}))) (def: .public (assertion message test) (-> Text Bit (Meta Any)) (function (_ lux) (if test - {#try.Success [lux []]} - {#try.Failure message}))) + {try.#Success [lux []]} + {try.#Failure message}))) (def: .public (failure error) (All (_ a) (-> Text (Meta a))) (function (_ state) - {#try.Failure (location.with (value@ #.location state) error)})) + {try.#Failure (location.with (value@ .#location state) error)})) (def: .public (module name) (-> Text (Meta Module)) (function (_ lux) - (case (plist.value name (value@ #.modules lux)) - {#.Some module} - {#try.Success [lux module]} + (case (plist.value name (value@ .#modules lux)) + {.#Some module} + {try.#Success [lux module]} _ - {#try.Failure ($_ text\composite "Unknown module: " name)}))) + {try.#Failure ($_ text\composite "Unknown module: " name)}))) (def: .public current_module_name (Meta Text) (function (_ lux) - (case (value@ #.current_module lux) - {#.Some current_module} - {#try.Success [lux current_module]} + (case (value@ .#current_module lux) + {.#Some current_module} + {try.#Success [lux current_module]} _ - {#try.Failure "No current module."}))) + {try.#Failure "No current module."}))) (def: .public current_module (Meta Module) @@ -143,7 +143,7 @@ (def: (macro_type? type) (-> Type Bit) (`` (case type - {#.Named [(~~ (static .prelude_module)) "Macro"] {#.Primitive "#Macro" #.End}} + {.#Named [(~~ (static .prelude_module)) "Macro"] {.#Primitive "#Macro" {.#End}}} true _ @@ -166,13 +166,13 @@ [[module name] (..normal full_name)] (: (Meta (Maybe Macro)) (function (_ lux) - {#try.Success [lux + {try.#Success [lux (case (..current_module_name lux) - {#try.Failure error} - #.None + {try.#Failure error} + {.#None} - {#try.Success [_ this_module]} - (let [modules (value@ #.modules lux)] + {try.#Success [_ this_module]} + (let [modules (value@ .#modules lux)] (loop [module module name name] (do maybe.monad @@ -180,56 +180,56 @@ definition (: (Maybe Global) (|> $module (: Module) - (value@ #.definitions) + (value@ .#definitions) (plist.value name)))] (case definition - {#.Alias [r_module r_name]} + {.#Alias [r_module r_name]} (recur r_module r_name) - {#.Definition [exported? def_type def_value]} + {.#Definition [exported? def_type def_value]} (if (macro_type? def_type) - {#.Some (:as Macro def_value)} - #.None) + {.#Some (:as Macro def_value)} + {.#None}) - {#.Type [exported? type labels]} - #.None + {.#Type [exported? type labels]} + {.#None} - {#.Label _} - #.None + {.#Label _} + {.#None} - {#.Slot _} - #.None)))))]})))) + {.#Slot _} + {.#None})))))]})))) (def: .public seed (Meta Nat) (function (_ lux) - {#try.Success [(revised@ #.seed ++ lux) - (value@ #.seed lux)]})) + {try.#Success [(revised@ .#seed ++ lux) + (value@ .#seed lux)]})) (def: .public (module_exists? module) (-> Text (Meta Bit)) (function (_ lux) - {#try.Success [lux (case (plist.value module (value@ #.modules lux)) - {#.Some _} + {try.#Success [lux (case (plist.value module (value@ .#modules lux)) + {.#Some _} #1 - #.None + {.#None} #0)]})) (def: (on_either f x1 x2) (All (_ a b) (-> (-> a (Maybe b)) a a (Maybe b))) (case (f x1) - #.None (f x2) - {#.Some y} {#.Some y})) + {.#None} (f x2) + {.#Some y} {.#Some y})) (def: (type_variable idx bindings) (-> Nat (List [Nat (Maybe Type)]) (Maybe Type)) (case bindings - #.End - #.None + {.#End} + {.#None} - {#.Item [var bound] bindings'} + {.#Item [var bound] bindings'} (if (n.= idx var) bound (type_variable idx bindings')))) @@ -237,16 +237,16 @@ (def: (clean_type type) (-> Type (Meta Type)) (case type - {#.Var var} + {.#Var var} (function (_ lux) (case (|> lux - (value@ [#.type_context #.var_bindings]) + (value@ [.#type_context .#var_bindings]) (type_variable var)) - (^or #.None {#.Some {#.Var _}}) - {#try.Success [lux type]} + (^or {.#None} {.#Some {.#Var _}}) + {try.#Success [lux type]} - {#.Some type'} - {#try.Success [lux type']})) + {.#Some type'} + {try.#Success [lux type']})) _ (\ ..monad in type))) @@ -259,21 +259,21 @@ (case (do maybe.monad [scope (list.example (function (_ env) (or (list.any? test (: (List [Text [Type Any]]) - (value@ [#.locals #.mappings] env))) + (value@ [.#locals .#mappings] env))) (list.any? test (: (List [Text [Type Any]]) - (value@ [#.captured #.mappings] env))))) - (value@ #.scopes lux)) + (value@ [.#captured .#mappings] env))))) + (value@ .#scopes lux)) [_ [type _]] (on_either (list.example test) (: (List [Text [Type Any]]) - (value@ [#.locals #.mappings] scope)) + (value@ [.#locals .#mappings] scope)) (: (List [Text [Type Any]]) - (value@ [#.captured #.mappings] scope)))] + (value@ [.#captured .#mappings] scope)))] (in type)) - {#.Some var_type} + {.#Some var_type} ((clean_type var_type) lux) - #.None - {#try.Failure ($_ text\composite "Unknown variable: " name)})))) + {.#None} + {try.#Failure ($_ text\composite "Unknown variable: " name)})))) (def: without_lux_runtime (-> (List Text) (List Text)) @@ -299,54 +299,54 @@ (function (_ lux) (case (: (Maybe Global) (do maybe.monad - [(^slots [#.definitions]) (|> lux - (value@ #.modules) + [(^slots [.#definitions]) (|> lux + (value@ .#modules) (plist.value normal_module))] - (plist.value normal_short definitions))) - {#.Some definition} - {#try.Success [lux definition]} + (plist.value normal_short #definitions))) + {.#Some definition} + {try.#Success [lux definition]} _ - (let [current_module (|> lux (value@ #.current_module) (maybe.else "???")) + (let [current_module (|> lux (value@ .#current_module) (maybe.else "???")) all_known_modules (|> lux - (value@ #.modules) + (value@ .#modules) (list\each product.left) ..module_listing)] - {#try.Failure ($_ text\composite + {try.#Failure ($_ text\composite "Unknown definition: " (name\encoded name) text.new_line " Current module: " current_module text.new_line - (case (plist.value current_module (value@ #.modules lux)) - {#.Some this_module} + (case (plist.value current_module (value@ .#modules lux)) + {.#Some this_module} (let [candidates (|> lux - (value@ #.modules) + (value@ .#modules) (list\each (function (_ [module_name module]) (|> module - (value@ #.definitions) + (value@ .#definitions) (list.all (function (_ [def_name global]) (case global - (^or {#.Definition [exported? _]} - {#.Type [exported? _]}) + (^or {.#Definition [exported? _]} + {.#Type [exported? _]}) (if (and exported? (text\= normal_short def_name)) - {#.Some (name\encoded [module_name def_name])} - #.None) + {.#Some (name\encoded [module_name def_name])} + {.#None}) - {#.Alias _} - #.None + {.#Alias _} + {.#None} - {#.Label _} - #.None + {.#Label _} + {.#None} - {#.Slot _} - #.None)))))) + {.#Slot _} + {.#None})))))) list.together (list.sorted text\<) (text.interposed ..listing_separator)) imports (|> this_module - (value@ #.imports) + (value@ .#imports) ..module_listing) aliases (|> this_module - (value@ #.module_aliases) + (value@ .#module_aliases) (list\each (function (_ [alias real]) ($_ text\composite alias " => " real))) (list.sorted text\<) (text.interposed ..listing_separator))] @@ -364,28 +364,28 @@ (do ..monad [definition (..definition name)] (case definition - {#.Definition definition} + {.#Definition definition} (let [[exported? def_type def_value] definition] (if exported? (in definition) (failure ($_ text\composite "Definition is not an export: " (name\encoded name))))) - {#.Type [exported? type labels]} + {.#Type [exported? type labels]} (if exported? (in [exported? .Type type]) (failure ($_ text\composite "Type is not an export: " (name\encoded name)))) - {#.Alias de_aliased} + {.#Alias de_aliased} (failure ($_ text\composite "Aliases are not considered exports: " (name\encoded name))) - {#.Label _} + {.#Label _} (failure ($_ text\composite "Tags are not considered exports: " (name\encoded name))) - {#.Slot _} + {.#Slot _} (failure ($_ text\composite "Slots are not considered exports: " (name\encoded name)))))) @@ -395,21 +395,21 @@ (do ..monad [definition (definition name)] (case definition - {#.Alias de_aliased} + {.#Alias de_aliased} (definition_type de_aliased) - {#.Definition [exported? def_type def_value]} + {.#Definition [exported? def_type def_value]} (clean_type def_type) - {#.Type [exported? type labels]} + {.#Type [exported? type labels]} (in .Type) - {#.Label _} + {.#Label _} (failure ($_ text\composite "Tags have no type: " (name\encoded name))) - {#.Slot _} + {.#Slot _} (failure ($_ text\composite "Slots have no type: " (name\encoded name)))))) @@ -429,10 +429,10 @@ (do ..monad [definition (definition name)] (case definition - {#.Alias de_aliased} + {.#Alias de_aliased} (type_definition de_aliased) - {#.Definition [exported? def_type def_value]} + {.#Definition [exported? def_type def_value]} (let [type_code (`` ("lux in-module" (~~ (static .prelude_module)) .type_code))] (if (or (same? .Type def_type) (\ code.equivalence = @@ -441,44 +441,44 @@ (in (:as Type def_value)) (..failure ($_ text\composite "Definition is not a type: " (name\encoded name))))) - {#.Type [exported? type labels]} + {.#Type [exported? type labels]} (in type) - {#.Label _} + {.#Label _} (..failure ($_ text\composite "Tag is not a type: " (name\encoded name))) - {#.Slot _} + {.#Slot _} (..failure ($_ text\composite "Slot is not a type: " (name\encoded name)))))) (def: .public (globals module) (-> Text (Meta (List [Text Global]))) (function (_ lux) - (case (plist.value module (value@ #.modules lux)) - #.None - {#try.Failure ($_ text\composite "Unknown module: " module)} + (case (plist.value module (value@ .#modules lux)) + {.#None} + {try.#Failure ($_ text\composite "Unknown module: " module)} - {#.Some module} - {#try.Success [lux (value@ #.definitions module)]}))) + {.#Some module} + {try.#Success [lux (value@ .#definitions module)]}))) (def: .public (definitions module) (-> Text (Meta (List [Text Definition]))) (\ ..monad each (list.all (function (_ [name global]) (case global - {#.Alias de_aliased} - #.None + {.#Alias de_aliased} + {.#None} - {#.Definition definition} - {#.Some [name definition]} + {.#Definition definition} + {.#Some [name definition]} - {#.Type [exported? type labels]} - {#.Some [name [exported? .Type type]]} + {.#Type [exported? type labels]} + {.#Some [name [exported? .Type type]]} - {#.Label _} - #.None + {.#Label _} + {.#None} - {#.Slot _} - #.None))) + {.#Slot _} + {.#None}))) (..globals module))) (def: .public (exports module_name) @@ -495,57 +495,57 @@ (Meta (List [Text Module])) (function (_ lux) (|> lux - (value@ #.modules) + (value@ .#modules) [lux] - #try.Success))) + {try.#Success}))) (def: .public (tags_of type_name) (-> Name (Meta (Maybe (List Name)))) (do ..monad [.let [[module_name name] type_name] module (..module module_name)] - (case (plist.value name (value@ #.definitions module)) - {#.Some {#.Type [exported? type labels]}} + (case (plist.value name (value@ .#definitions module)) + {.#Some {.#Type [exported? type labels]}} (case labels - (^or {#.Left labels} - {#.Right labels}) - (in {#.Some (list\each (|>> [module_name]) - {#.Item labels})})) + (^or {.#Left labels} + {.#Right labels}) + (in {.#Some (list\each (|>> [module_name]) + {.#Item labels})})) _ - (in #.None)))) + (in {.#None})))) (def: .public location (Meta Location) (function (_ lux) - {#try.Success [lux (value@ #.location lux)]})) + {try.#Success [lux (value@ .#location lux)]})) (def: .public expected_type (Meta Type) (function (_ lux) - (case (value@ #.expected lux) - {#.Some type} - {#try.Success [lux type]} + (case (value@ .#expected lux) + {.#Some type} + {try.#Success [lux type]} - #.None - {#try.Failure "Not expecting any type."}))) + {.#None} + {try.#Failure "Not expecting any type."}))) (def: .public (imported_modules module_name) (-> Text (Meta (List Text))) (do ..monad - [(^slots [#.imports]) (..module module_name)] - (in imports))) + [(^slots [.#imports]) (..module module_name)] + (in #imports))) (def: .public (imported_by? import module) (-> Text Text (Meta Bit)) (do ..monad - [(^slots [#.imports]) (..module module)] - (in (list.any? (text\= import) imports)))) + [(^slots [.#imports]) (..module module)] + (in (list.any? (text\= import) #imports)))) (def: .public (imported? import) (-> Text (Meta Bit)) (\ ..functor each - (|>> (value@ #.imports) (list.any? (text\= import))) + (|>> (value@ .#imports) (list.any? (text\= import))) ..current_module)) (template [<name> <tag> <description>] @@ -555,8 +555,8 @@ [.let [[module name] tag_name] =module (..module module) this_module_name ..current_module_name] - (case (plist.value (text\composite "#" name) (value@ #.definitions =module)) - {#.Some {<tag> [exported? type group idx]}} + (case (plist.value name (value@ .#definitions =module)) + {.#Some {<tag> [exported? type group idx]}} (if (or (text\= this_module_name module) exported?) (in [idx (list\each (|>> [module]) group) type]) @@ -566,8 +566,8 @@ (..failure ($_ text\composite "Unknown " <description> ": " (name\encoded tag_name))))))] - [tag #.Label "tag"] - [slot #.Slot "slot"] + [tag .#Label "tag"] + [slot .#Slot "slot"] ) (def: .public (tag_lists module) @@ -577,33 +577,33 @@ this_module_name ..current_module_name] (in (list.all (function (_ [short global]) (case global - {#.Type [exported? type labels]} + {.#Type [exported? type labels]} (if (or exported? (text\= this_module_name module)) - {#.Some [(list\each (|>> [module]) + {.#Some [(list\each (|>> [module]) (case labels - {#.Left tags} - {#.Item tags} + {.#Left tags} + {.#Item tags} - {#.Right slots} - {#.Item slots})) + {.#Right slots} + {.#Item slots})) type]} - #.None) + {.#None}) _ - #.None)) - (value@ #.definitions =module))))) + {.#None})) + (value@ .#definitions =module))))) (def: .public locals (Meta (List (List [Text Type]))) (function (_ lux) - (case (list.inits (value@ #.scopes lux)) - #.None - {#try.Failure "No local environment"} + (case (list.inits (value@ .#scopes lux)) + {.#None} + {try.#Failure "No local environment"} - {#.Some scopes} - {#try.Success [lux - (list\each (|>> (value@ [#.locals #.mappings]) + {.#Some scopes} + {try.#Success [lux + (list\each (|>> (value@ [.#locals .#mappings]) (list\each (function (_ [name [type _]]) [name type]))) scopes)]}))) @@ -613,44 +613,44 @@ (do ..monad [constant (..definition def_name)] (in (case constant - {#.Alias real_def_name} + {.#Alias real_def_name} real_def_name - {#.Definition _} + {.#Definition _} def_name - {#.Type _} + {.#Type _} def_name - {#.Label _} + {.#Label _} def_name - {#.Slot _} + {.#Slot _} def_name)))) (def: .public compiler_state (Meta Lux) (function (_ lux) - {#try.Success [lux lux]})) + {try.#Success [lux lux]})) (def: .public type_context (Meta Type_Context) (function (_ lux) - {#try.Success [lux (value@ #.type_context lux)]})) + {try.#Success [lux (value@ .#type_context lux)]})) (def: .public (lifted result) (All (_ a) (-> (Try a) (Meta a))) (case result - {#try.Success output} + {try.#Success output} (\ ..monad in output) - {#try.Failure error} + {try.#Failure error} (..failure error))) (def: .public (eval type code) (-> Type Code (Meta Any)) (do [! ..monad] - [eval (\ ! each (value@ #.eval) + [eval (\ ! each (value@ .#eval) ..compiler_state)] (eval type code))) @@ -658,8 +658,8 @@ (All (_ it) (-> (Meta it) (Meta (Try it)))) (function (_ lux) (case (computation lux) - {#try.Success [lux' output]} - {#try.Success [lux' {#try.Success output}]} + {try.#Success [lux' output]} + {try.#Success [lux' {try.#Success output}]} - {#try.Failure error} - {#try.Success [lux {#try.Failure error}]}))) + {try.#Failure error} + {try.#Success [lux {try.#Failure error}]}))) diff --git a/stdlib/source/library/lux/meta/location.lux b/stdlib/source/library/lux/meta/location.lux index 3c797eda0..963c65712 100644 --- a/stdlib/source/library/lux/meta/location.lux +++ b/stdlib/source/library/lux/meta/location.lux @@ -8,28 +8,28 @@ (Equivalence Location) (def: (= reference subject) - (and ("lux text =" (value@ #.module reference) (value@ #.module subject)) - ("lux i64 =" (value@ #.line reference) (value@ #.line subject)) - ("lux i64 =" (value@ #.column reference) (value@ #.column subject))))) + (and ("lux text =" (value@ .#module reference) (value@ .#module subject)) + ("lux i64 =" (value@ .#line reference) (value@ .#line subject)) + ("lux i64 =" (value@ .#column reference) (value@ .#column subject))))) (def: .public dummy Location - [#.module "" - #.line 0 - #.column 0]) + [.#module "" + .#line 0 + .#column 0]) (macro: .public (here tokens compiler) (case tokens - #.End - (let [location (value@ #.location compiler)] - {#.Right [compiler + {.#End} + (let [location (value@ .#location compiler)] + {.#Right [compiler (list (` (.: .Location - [(~ [..dummy {#.Text (value@ #.module location)}]) - (~ [..dummy {#.Nat (value@ #.line location)}]) - (~ [..dummy {#.Nat (value@ #.column location)}])])))]}) + [(~ [..dummy {.#Text (value@ .#module location)}]) + (~ [..dummy {.#Nat (value@ .#line location)}]) + (~ [..dummy {.#Nat (value@ .#column location)}])])))]}) _ - {#.Left (`` (("lux in-module" (~~ (static .prelude_module)) wrong_syntax_error) (name_of ..here)))})) + {.#Left (`` (("lux in-module" (~~ (static .prelude_module)) wrong_syntax_error) (name_of ..here)))})) (def: .public (format it) (-> Location Text) diff --git a/stdlib/source/library/lux/program.lux b/stdlib/source/library/lux/program.lux index 844da6654..f78141b02 100644 --- a/stdlib/source/library/lux/program.lux +++ b/stdlib/source/library/lux/program.lux @@ -55,8 +55,8 @@ (~ g!_) (~! <cli>.end)] ((~' in) (~ initialization+event_loop)))) (~ g!args)) - {#.Right (~ g!output)} + {.#Right (~ g!output)} (~ g!output) - {#.Left (~ g!message)} + {.#Left (~ g!message)} (.panic! (~ g!message)))))))))))))) diff --git a/stdlib/source/library/lux/target/common_lisp.lux b/stdlib/source/library/lux/target/common_lisp.lux index 253896c2f..77270308d 100644 --- a/stdlib/source/library/lux/target/common_lisp.lux +++ b/stdlib/source/library/lux/target/common_lisp.lux @@ -153,10 +153,10 @@ (def: .public (args& singles rest) (-> (List Var/1) Var/1 Var/*) (|> (case singles - #.End + {.#End} "" - {#.Item _} + {.#Item _} (|> singles (list\each ..code) (text.interposed " ") @@ -174,7 +174,7 @@ (def: .public (call/* func) (-> (Expression Any) (-> (List (Expression Any)) (Computation Any))) - (|>> {#.Item func} ..form)) + (|>> {.#Item func} ..form)) (template [<name> <function>] [(def: .public <name> @@ -403,10 +403,10 @@ [(def: .public (<name> conditions expression) (-> (List Text) (Expression Any) (Expression Any)) (case conditions - #.End + {.#End} expression - {#.Item single #.End} + {.#Item single {.#End}} (:abstraction (format <prefix> single " " (:representation expression))) diff --git a/stdlib/source/library/lux/target/js.lux b/stdlib/source/library/lux/target/js.lux index 1519e639b..7f5d30f02 100644 --- a/stdlib/source/library/lux/target/js.lux +++ b/stdlib/source/library/lux/target/js.lux @@ -406,11 +406,12 @@ (text.interposed text.new_line)) text.new_line (case default - {#.Some default} + {.#Some default} (format "default:" (..nested (:representation default))) - #.None "")) + {.#None} + "")) :abstraction ..block)))) ) diff --git a/stdlib/source/library/lux/target/jvm.lux b/stdlib/source/library/lux/target/jvm.lux index 0d07ab2aa..4e04312ff 100644 --- a/stdlib/source/library/lux/target/jvm.lux +++ b/stdlib/source/library/lux/target/jvm.lux @@ -24,63 +24,63 @@ {#SIPUSH Int} - #ICONST_M1 - #ICONST_0 - #ICONST_1 - #ICONST_2 - #ICONST_3 - #ICONST_4 - #ICONST_5 - - #LCONST_0 - #LCONST_1 + {#ICONST_M1} + {#ICONST_0} + {#ICONST_1} + {#ICONST_2} + {#ICONST_3} + {#ICONST_4} + {#ICONST_5} + + {#LCONST_0} + {#LCONST_1} - #FCONST_0 - #FCONST_1 - #FCONST_2 + {#FCONST_0} + {#FCONST_1} + {#FCONST_2} - #DCONST_0 - #DCONST_1 + {#DCONST_0} + {#DCONST_1} - #ACONST_NULL + {#ACONST_NULL} {#LDC Literal})) (type: .public Int_Arithmetic (Variant - #IADD - #ISUB - #IMUL - #IDIV - #IREM - #INEG)) + {#IADD} + {#ISUB} + {#IMUL} + {#IDIV} + {#IREM} + {#INEG})) (type: .public Long_Arithmetic (Variant - #LADD - #LSUB - #LMUL - #LDIV - #LREM - #LNEG)) + {#LADD} + {#LSUB} + {#LMUL} + {#LDIV} + {#LREM} + {#LNEG})) (type: .public Float_Arithmetic (Variant - #FADD - #FSUB - #FMUL - #FDIV - #FREM - #FNEG)) + {#FADD} + {#FSUB} + {#FMUL} + {#FDIV} + {#FREM} + {#FNEG})) (type: .public Double_Arithmetic (Variant - #DADD - #DSUB - #DMUL - #DDIV - #DREM - #DNEG)) + {#DADD} + {#DSUB} + {#DMUL} + {#DDIV} + {#DREM} + {#DNEG})) (type: .public Arithmetic (Variant @@ -91,21 +91,21 @@ (type: .public Int_Bitwise (Variant - #IOR - #IXOR - #IAND - #ISHL - #ISHR - #IUSHR)) + {#IOR} + {#IXOR} + {#IAND} + {#ISHL} + {#ISHR} + {#IUSHR})) (type: .public Long_Bitwise (Variant - #LOR - #LXOR - #LAND - #LSHL - #LSHR - #LUSHR)) + {#LOR} + {#LXOR} + {#LAND} + {#LSHL} + {#LSHR} + {#LUSHR})) (type: .public Bitwise (Variant @@ -114,55 +114,55 @@ (type: .public Conversion (Variant - #I2B - #I2S - #I2L - #I2F - #I2D - #I2C - - #L2I - #L2F - #L2D - - #F2I - #F2L - #F2D + {#I2B} + {#I2S} + {#I2L} + {#I2F} + {#I2D} + {#I2C} + + {#L2I} + {#L2F} + {#L2D} + + {#F2I} + {#F2L} + {#F2D} - #D2I - #D2L - #D2F)) + {#D2I} + {#D2L} + {#D2F})) (type: .public Array (Variant - #ARRAYLENGTH + {#ARRAYLENGTH} {#NEWARRAY (Type Primitive)} {#ANEWARRAY (Type category.Object)} - #BALOAD - #BASTORE + {#BALOAD} + {#BASTORE} - #SALOAD - #SASTORE + {#SALOAD} + {#SASTORE} - #IALOAD - #IASTORE + {#IALOAD} + {#IASTORE} - #LALOAD - #LASTORE + {#LALOAD} + {#LASTORE} - #FALOAD - #FASTORE + {#FALOAD} + {#FASTORE} - #DALOAD - #DASTORE + {#DALOAD} + {#DASTORE} - #CALOAD - #CASTORE + {#CALOAD} + {#CASTORE} - #AALOAD - #AASTORE)) + {#AALOAD} + {#AASTORE})) (type: .public Object (Variant @@ -221,25 +221,25 @@ (type: .public Stack (Variant - #DUP - #DUP_X1 - #DUP_X2 - #DUP2 - #DUP2_X1 - #DUP2_X2 - #SWAP - #POP - #POP2)) + {#DUP} + {#DUP_X1} + {#DUP_X2} + {#DUP2} + {#DUP2_X1} + {#DUP2_X2} + {#SWAP} + {#POP} + {#POP2})) (type: .public Comparison (Variant - #LCMP + {#LCMP} - #FCMPG - #FCMPL + {#FCMPG} + {#FCMPL} - #DCMPG - #DCMPL)) + {#DCMPG} + {#DCMPL})) (type: .public Label Nat) @@ -270,21 +270,21 @@ (type: .public (Exception label) (Variant {#Try label label label (Type Class)} - #ATHROW)) + {#ATHROW})) (type: .public Concurrency (Variant - #MONITORENTER - #MONITOREXIT)) + {#MONITORENTER} + {#MONITOREXIT})) (type: .public Return (Variant - #RETURN - #IRETURN - #LRETURN - #FRETURN - #DRETURN - #ARETURN)) + {#RETURN} + {#IRETURN} + {#LRETURN} + {#FRETURN} + {#DRETURN} + {#ARETURN})) (type: .public (Control label) (Variant @@ -296,7 +296,7 @@ (type: .public (Instruction embedded label) (Variant - #NOP + {#NOP} {#Constant Constant} {#Arithmetic Arithmetic} {#Bitwise Bitwise} diff --git a/stdlib/source/library/lux/target/jvm/attribute.lux b/stdlib/source/library/lux/target/jvm/attribute.lux index ed10a42c6..bf99e9f2e 100644 --- a/stdlib/source/library/lux/target/jvm/attribute.lux +++ b/stdlib/source/library/lux/target/jvm/attribute.lux @@ -84,7 +84,8 @@ (^template [<tag>] [{<tag> [name length info]} (|> length //unsigned.value (n.+ ..common_attribute_length))]) - ([#Constant] [#Code]))) + ([#Constant] + [#Code]))) ... TODO: Inline ASAP (def: (constant' @name index) diff --git a/stdlib/source/library/lux/target/jvm/bytecode.lux b/stdlib/source/library/lux/target/jvm/bytecode.lux index d999f5320..daf475a97 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode.lux @@ -78,7 +78,7 @@ (def: relative_identity Relative - (function.constant {#try.Success [..no_exceptions _.empty]})) + (function.constant {try.#Success [..no_exceptions _.empty]})) (implementation: relative_monoid (Monoid Relative) @@ -106,7 +106,7 @@ (def: .public new_label (Bytecode Label) (function (_ [pool environment tracker]) - {#try.Success [[pool + {try.#Success [[pool environment (revised@ #next ++ tracker)] [..relative_identity @@ -131,7 +131,7 @@ (with_expansions [<success> (as_is (in [[pool environment (revised@ #known - (dictionary.has label [actual {#.Some @here}]) + (dictionary.has label [actual {.#Some @here}]) tracker)] [..relative_identity []]]))] @@ -140,18 +140,18 @@ (function (_ [pool environment tracker]) (let [@here (value@ #program_counter tracker)] (case (dictionary.value label (value@ #known tracker)) - {#.Some [expected {#.Some address}]} + {.#Some [expected {.#Some address}]} (exception.except ..label_has_already_been_set [label]) - {#.Some [expected #.None]} + {.#Some [expected {.#None}]} (do try.monad [[actual environment] (/environment.continue expected environment)] <success>) - #.None + {.#None} (do try.monad [[actual environment] (/environment.continue (|> environment - (value@ #/environment.stack) + (value@ /environment.#stack) (maybe.else /stack.empty)) environment)] <success>)))))) @@ -167,7 +167,7 @@ (def: .public failure (-> Text Bytecode) - (|>> #try.Failure function.constant)) + (|>> {try.#Failure} function.constant)) (def: .public (except exception value) (All (_ e) (-> (exception.Exception e) e Bytecode)) @@ -201,7 +201,8 @@ []]])))) (template [<name> <frames>] - [(def: <name> U2 (|> <frames> //unsigned.u2 try.trusted))] + [(def: <name> U2 + (|> <frames> //unsigned.u2 try.trusted))] [$0 0] [$1 1] @@ -455,10 +456,10 @@ (do ..monad [index (..lifted (//constant/pool.string value))] (case (|> index //index.value //unsigned.value //unsigned.u1) - {#try.Success index} + {try.#Success index} (..bytecode $0 $1 @_ _.ldc [index]) - {#try.Failure _} + {try.#Failure _} (..bytecode $0 $1 @_ _.ldc_w/string [index])))) (import: java/lang/Float @@ -480,10 +481,10 @@ _ (do ..monad [index (..lifted (<constant> (<constructor> value)))] (case (|> index //index.value //unsigned.value //unsigned.u1) - {#try.Success index} + {try.#Success index} (..bytecode $0 $1 @_ _.ldc [index]) - {#try.Failure _} + {try.#Failure _} (..bytecode $0 $1 @_ <wide> [index])))))] [int I32 //constant.integer //constant/pool.integer _.ldc_w/integer @@ -502,10 +503,10 @@ (do ..monad [index (..lifted (//constant/pool.float (//constant.float value)))] (case (|> index //index.value //unsigned.value //unsigned.u1) - {#try.Success index} + {try.#Success index} (..bytecode $0 $1 @_ _.ldc [index]) - {#try.Failure _} + {try.#Failure _} (..bytecode $0 $1 @_ _.ldc_w/float [index])))) (def: float_bits @@ -583,10 +584,10 @@ (def: (register id) (-> Nat (Bytecode Register)) (case (//unsigned.u1 id) - {#try.Success register} + {try.#Success register} (\ ..monad in register) - {#try.Failure error} + {try.#Failure error} (..except ..invalid_register [id]))) (template [<for> <size> <name> <general> <specials>] @@ -705,8 +706,8 @@ +1) jump)))] (if big? - (\ ! each (|>> #.Left) (//signed.s4 jump)) - (\ ! each (|>> #.Right) (//signed.s2 jump)))))) + (\ ! each (|>> {.#Left}) (//signed.s4 jump)) + (\ ! each (|>> {.#Right}) (//signed.s2 jump)))))) (exception: .public (unset_label [label Label]) (exception.report @@ -715,23 +716,23 @@ (def: (resolve_label label resolver) (-> Label Resolver (Try [Stack Address])) (case (dictionary.value label resolver) - {#.Some [actual {#.Some address}]} - {#try.Success [actual address]} + {.#Some [actual {.#Some address}]} + {try.#Success [actual address]} - {#.Some [actual #.None]} + {.#Some [actual {.#None}]} (exception.except ..unset_label [label]) - #.None + {.#None} (exception.except ..unknown_label [label]))) (def: (acknowledge_label stack label tracker) (-> Stack Label Tracker Tracker) (case (dictionary.value label (value@ #known tracker)) - {#.Some _} + {.#Some _} tracker - #.None - (revised@ #known (dictionary.has label [stack #.None]) tracker))) + {.#None} + (revised@ #known (dictionary.has label [stack {.#None}]) tracker))) (template [<consumption> <name> <instruction>] [(def: .public (<name> label) @@ -757,10 +758,10 @@ (\ /stack.equivalence = expected actual)) jump (..jump @from @to)] (case jump - {#.Left jump} + {.#Left jump} (exception.except ..cannot_do_a_big_jump [label @from jump]) - {#.Right jump} + {.#Right jump} (in [..no_exceptions (bytecode jump)])))) []]])))))))] @@ -802,22 +803,22 @@ (with@ #program_counter program_counter'))] [(function (_ resolver) (case (dictionary.value label resolver) - {#.Some [expected {#.Some @to}]} + {.#Some [expected {.#Some @to}]} (do try.monad [_ (exception.assertion ..mismatched_environments [(name_of <instruction>) label @here expected actual] (\ /stack.equivalence = expected actual)) jump (..jump @from @to)] (case jump - {#.Left jump} + {.#Left jump} <on_long_jump> - {#.Right jump} + {.#Right jump} <on_short_jump>)) - {#.Some [expected #.None]} + {.#Some [expected {.#None}]} (exception.except ..unset_label [label]) - #.None + {.#None} (exception.except ..unknown_label [label]))) []]]))))))] @@ -832,10 +833,10 @@ (def: (big_jump jump) (-> Any_Jump Big_Jump) (case jump - {#.Left big} + {.#Left big} big - {#.Right small} + {.#Right small} (/jump.lifted small))) (exception: .public invalid_tableswitch) @@ -865,7 +866,7 @@ (monad.each ! get) (monad.then ! (monad.each ! product.right)))] (in [@default @at_minimum @afterwards])) - {#.Some [@default @at_minimum @afterwards]} + {.#Some [@default @at_minimum @afterwards]} (do [! try.monad] [>default (\ ! each ..big_jump (..jump @from @default)) >at_minimum (\ ! each ..big_jump (..jump @from @at_minimum)) @@ -873,7 +874,7 @@ @afterwards)] (in [..no_exceptions (bytecode minimum >default [>at_minimum >afterwards])])) - #.None + {.#None} (exception.except ..invalid_tableswitch [])))) []]])))))) @@ -907,7 +908,7 @@ (monad.each ! (|>> product.right get)) (monad.then ! (monad.each ! product.right)))] (in [@default @cases])) - {#.Some [@default @cases]} + {.#Some [@default @cases]} (do [! try.monad] [>default (\ ! each ..big_jump (..jump @from @default)) >cases (|> @cases @@ -915,7 +916,7 @@ (\ ! each (|>> (list.zipped/2 (list\each product.left cases)))))] (in [..no_exceptions (bytecode >default >cases)])) - #.None + {.#None} (exception.except ..invalid_lookupswitch [])))) []]])))))) @@ -976,8 +977,8 @@ (do ..monad [index (<| ..lifted (<method> (..reflection class)) - [#//constant/pool.name method - #//constant/pool.descriptor (type.descriptor type)]) + [//constant/pool.#name method + //constant/pool.#descriptor (type.descriptor type)]) .let [consumption (|> inputs (list\each ..type_size) (list\mix n.+ (if <static?> 0 1)) @@ -1001,8 +1002,8 @@ (do ..monad [index (<| ..lifted (//constant/pool.field (..reflection class)) - [#//constant/pool.name field - #//constant/pool.descriptor (type.descriptor type)])] + [//constant/pool.#name field + //constant/pool.#descriptor (type.descriptor type)])] (if (or (same? type.long type) (same? type.double type)) (..bytecode <consumption> $2 @_ <2> [index]) @@ -1025,7 +1026,7 @@ (do ..monad [@catch (..lifted (//constant/pool.class (//name.internal (..reflection catch))))] (function (_ [pool environment tracker]) - {#try.Success + {try.#Success [[pool environment (..acknowledge_label /stack.catch @handler tracker)] @@ -1037,10 +1038,10 @@ (in []) (exception.except ..invalid_range_for_try [@start @end])) [_ @handler] (..resolve_label @handler resolver)] - (in [(row.row [#//exception.start @start - #//exception.end @end - #//exception.handler @handler - #//exception.catch @catch]) + (in [(row.row [//exception.#start @start + //exception.#end @end + //exception.#handler @handler + //exception.#catch @catch]) _.empty]))) []]]}))) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux index c7b6481fb..5583757a7 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux @@ -28,7 +28,7 @@ (do try.monad [limit (<limit> type)] (in [#limit limit - #stack {#.Some /stack.empty}])))] + #stack {.#Some /stack.empty}])))] [static /limit.static] [virtual /limit.virtual] @@ -40,7 +40,8 @@ (implementation: .public monoid (Monoid Condition) - (def: identity (|>> #try.Success)) + (def: identity + (|>> {try.#Success})) (def: (composite left right) (function (_ environment) @@ -52,16 +53,16 @@ (def: .public (stack environment) (-> Environment (Try Stack)) - (case (value@ #..stack environment) - {#.Some stack} - {#try.Success stack} + (case (value@ ..#stack environment) + {.#Some stack} + {try.#Success stack} - #.None + {.#None} (exception.except ..discontinuity []))) (def: .public discontinue (-> Environment Environment) - (with@ #..stack #.None)) + (with@ ..#stack {.#None})) (exception: .public (mismatched_stacks [expected Stack actual Stack]) @@ -71,14 +72,14 @@ (def: .public (continue expected environment) (-> Stack Environment (Try [Stack Environment])) - (case (value@ #..stack environment) - {#.Some actual} + (case (value@ ..#stack environment) + {.#Some actual} (if (\ /stack.equivalence = expected actual) - {#try.Success [actual environment]} + {try.#Success [actual environment]} (exception.except ..mismatched_stacks [expected actual])) - #.None - {#try.Success [expected (with@ #..stack {#.Some expected} environment)]})) + {.#None} + {try.#Success [expected (with@ ..#stack {.#Some expected} environment)]})) (def: .public (consumes amount) (-> U2 Condition) @@ -88,7 +89,7 @@ (do try.monad [previous (..stack environment) current (/stack.pop amount previous)] - (in (with@ #..stack {#.Some current} environment))))) + (in (with@ ..#stack {.#Some current} environment))))) (def: .public (produces amount) (-> U2 Condition) @@ -97,13 +98,13 @@ [previous (..stack environment) current (/stack.push amount previous) .let [limit (|> environment - (value@ [#..limit #/limit.stack]) + (value@ [..#limit /limit.#stack]) (/stack.max current))]] (in (|> environment - (with@ #..stack {#.Some current}) - (with@ [#..limit #/limit.stack] limit)))))) + (with@ ..#stack {.#Some current}) + (with@ [..#limit /limit.#stack] limit)))))) (def: .public (has registry) (-> Registry Condition) - (|>> (revised@ [#..limit #/limit.registry] (/registry.has registry)) - #try.Success)) + (|>> (revised@ [..#limit /limit.#registry] (/registry.has registry)) + {try.#Success})) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux index c43e5ed0b..85f97d48f 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux @@ -635,12 +635,12 @@ _ (binary.write/32! offset (///signed.value maximum) binary)] (loop [offset (n.+ (///unsigned.value ..integer_size) offset) afterwards (: (List Big_Jump) - {#.Item at_minimum afterwards})] + {.#Item at_minimum afterwards})] (case afterwards - #.End + {.#End} (in binary) - {#.Item head tail} + {.#Item head tail} (do ! [_ (binary.write/32! offset (///signed.value head) binary)] (recur (n.+ (///unsigned.value ..big_jump_size) offset) @@ -696,10 +696,10 @@ (loop [offset (n.+ (///unsigned.value ..integer_size) offset) cases cases] (case cases - #.End + {.#End} (in binary) - {#.Item [value jump] tail} + {.#Item [value jump] tail} (do ! [_ (binary.write/32! offset (///signed.value value) binary) _ (binary.write/32! (n.+ (///unsigned.value ..integer_size) offset) (///signed.value jump) binary)] diff --git a/stdlib/source/library/lux/target/jvm/constant/pool.lux b/stdlib/source/library/lux/target/jvm/constant/pool.lux index 41ff5ad26..dc60b3c55 100644 --- a/stdlib/source/library/lux/target/jvm/constant/pool.lux +++ b/stdlib/source/library/lux/target/jvm/constant/pool.lux @@ -57,18 +57,18 @@ (with_expansions [<try_again> (as_is (recur (.++ idx)))] (loop [idx 0] (case (row.item idx pool) - {#try.Success entry} + {try.#Success entry} (case entry [index {<tag> reference}] (if (\ <equivalence> = reference <value>') - {#try.Success [[current pool] + {try.#Success [[current pool] index]} <try_again>) _ <try_again>) - {#try.Failure _} + {try.#Failure _} (let [new {<tag> <value>'}] (do [! try.monad] [@new (//unsigned.u2 (//.size new)) @@ -92,11 +92,11 @@ (Adder <type>) (!add <tag> <equivalence> value))] - [integer Integer #//.Integer (//.value_equivalence i32.equivalence)] - [float Float #//.Float (//.value_equivalence //.float_equivalence)] - [long Long #//.Long (//.value_equivalence int.equivalence)] - [double Double #//.Double (//.value_equivalence frac.equivalence)] - [utf8 UTF8 #//.UTF8 text.equivalence] + [integer Integer //.#Integer (//.value_equivalence i32.equivalence)] + [float Float //.#Float (//.value_equivalence //.float_equivalence)] + [long Long //.#Long (//.value_equivalence int.equivalence)] + [double Double //.#Double (//.value_equivalence frac.equivalence)] + [utf8 UTF8 //.#UTF8 text.equivalence] ) (def: .public (string value) @@ -104,21 +104,21 @@ (do ..monad [@value (utf8 value) .let [value (//.string @value)]] - (!add #//.String (//.value_equivalence //index.equivalence) value))) + (!add //.#String (//.value_equivalence //index.equivalence) value))) (def: .public (class name) (-> Internal (Resource (Index Class))) (do ..monad [@name (utf8 (//name.read name)) .let [value (//.class @name)]] - (!add #//.Class //.class_equivalence value))) + (!add //.#Class //.class_equivalence value))) (def: .public (descriptor value) (All (_ kind) (-> (Descriptor kind) (Resource (Index (Descriptor kind))))) (let [value (//descriptor.descriptor value)] - (!add #//.UTF8 text.equivalence value))) + (!add //.#UTF8 text.equivalence value))) (type: .public (Member of) (Record @@ -131,7 +131,7 @@ (do ..monad [@name (utf8 name) @descriptor (..descriptor descriptor)] - (!add #//.Name_And_Type //.name_and_type_equivalence [#//.name @name #//.descriptor @descriptor]))) + (!add //.#Name_And_Type //.name_and_type_equivalence [//.#name @name //.#descriptor @descriptor]))) (template [<name> <tag> <of>] [(def: .public (<name> class member) @@ -139,11 +139,11 @@ (do ..monad [@class (..class (//name.internal class)) @name_and_type (name_and_type member)] - (!add <tag> //.reference_equivalence [#//.class @class #//.name_and_type @name_and_type])))] + (!add <tag> //.reference_equivalence [//.#class @class //.#name_and_type @name_and_type])))] - [field #//.Field Value] - [method #//.Method Method] - [interface_method #//.Interface_Method Method] + [field //.#Field Value] + [method //.#Method Method] + [interface_method //.#Interface_Method Method] ) (def: .public writer diff --git a/stdlib/source/library/lux/target/jvm/encoding/signed.lux b/stdlib/source/library/lux/target/jvm/encoding/signed.lux index 1e7e57721..5135e4a76 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/signed.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/signed.lux @@ -67,7 +67,7 @@ (i64.or negative value) (i64.and positive value)) value) - {#try.Success (:abstraction value)} + {try.#Success (:abstraction value)} (exception.except ..value_exceeds_the_scope [value <size>]))))) (template [<abstract_operation> <concrete_operation>] diff --git a/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux b/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux index 804374a4e..1138d61ad 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux @@ -74,7 +74,7 @@ (-> Nat (Try <name>)) (if (n.> (:representation <maximum>) value) (exception.except ..value_exceeds_the_maximum [(name_of <name>) value <maximum>]) - {#try.Success (:abstraction value)})) + {try.#Success (:abstraction value)})) (def: .public (<+> parameter subject) (-> <name> <name> (Try <name>)) @@ -88,7 +88,7 @@ subject' (:representation subject)] (if (n.> subject' parameter') (exception.except ..subtraction_cannot_yield_negative_value [(name_of <name>) parameter subject]) - {#try.Success (:abstraction (n.- parameter' subject'))}))) + {try.#Success (:abstraction (n.- parameter' subject'))}))) (def: .public (<max> left right) (-> <name> <name> <name>) diff --git a/stdlib/source/library/lux/target/jvm/loader.lux b/stdlib/source/library/lux/target/jvm/loader.lux index 82999be00..00b26447d 100644 --- a/stdlib/source/library/lux/target/jvm/loader.lux +++ b/stdlib/source/library/lux/target/jvm/loader.lux @@ -116,15 +116,15 @@ (let [class_name (:as Text class_name) classes (|> library atom.read! io.run!)] (case (dictionary.value class_name classes) - {#.Some bytecode} + {.#Some bytecode} (case (..define class_name bytecode (<| <cast> self)) - {#try.Success class} + {try.#Success class} (:expected class) - {#try.Failure error} + {try.#Failure error} (panic! (exception.error ..cannot_define [class_name error]))) - #.None + {.#None} (panic! (exception.error ..unknown [class_name]))))))))) (def: .public (store name bytecode library) @@ -135,7 +135,7 @@ (in (exception.except ..already_stored name)) (do ! [_ (atom.update! (dictionary.has name bytecode) library)] - (in {#try.Success []}))))) + (in {try.#Success []}))))) (def: .public (load name loader) (-> Text java/lang/ClassLoader diff --git a/stdlib/source/library/lux/target/jvm/method.lux b/stdlib/source/library/lux/target/jvm/method.lux index a56b732c3..25338a20a 100644 --- a/stdlib/source/library/lux/target/jvm/method.lux +++ b/stdlib/source/library/lux/target/jvm/method.lux @@ -59,25 +59,25 @@ (monad.all !) (\ ! each row.of_list)) attributes (case code - {#.Some code} + {.#Some code} (do ! [environment (case (if (//modifier.has? static modifier) (//bytecode/environment.static type) (//bytecode/environment.virtual type)) - {#try.Success environment} + {try.#Success environment} (in environment) - {#try.Failure error} - (function (_ _) {#try.Failure error})) + {try.#Failure error} + (function (_ _) {try.#Failure error})) [environment exceptions instruction output] (//bytecode.resolve environment code) .let [bytecode (|> instruction //bytecode/instruction.result format.instance)] - @code (//attribute.code [#//attribute/code.limit (value@ #//bytecode/environment.limit environment) - #//attribute/code.code bytecode - #//attribute/code.exception_table exceptions - #//attribute/code.attributes (row.row)])] + @code (//attribute.code [//attribute/code.#limit (value@ //bytecode/environment.#limit environment) + //attribute/code.#code bytecode + //attribute/code.#exception_table exceptions + //attribute/code.#attributes (row.row)])] (in (row.suffix @code attributes))) - #.None + {.#None} (in attributes))] (in [#modifier modifier #name @name diff --git a/stdlib/source/library/lux/target/jvm/reflection.lux b/stdlib/source/library/lux/target/jvm/reflection.lux index 59a3d72d6..6c4467ae7 100644 --- a/stdlib/source/library/lux/target/jvm/reflection.lux +++ b/stdlib/source/library/lux/target/jvm/reflection.lux @@ -128,10 +128,10 @@ (def: .public (load class_loader name) (-> java/lang/ClassLoader External (Try (java/lang/Class java/lang/Object))) (case (java/lang/Class::forName name false class_loader) - {#try.Success class} - {#try.Success class} + {try.#Success class} + {try.#Success class} - {#try.Failure _} + {try.#Failure _} (exception.except ..unknown_class [name]))) (def: .public (sub? class_loader super sub) @@ -146,7 +146,7 @@ java/lang/reflect/Type (Try (/.Type Class))) (<| (case (ffi.check java/lang/Class reflection) - {#.Some class} + {.#Some class} (let [class_name (|> class (:as (java/lang/Class java/lang/Object)) java/lang/Class::getName)] @@ -164,17 +164,17 @@ [/reflection.char])) (text.starts_with? /descriptor.array_prefix class_name)) (exception.except ..not_a_class reflection) - {#try.Success (/.class class_name (list))}))) + {try.#Success (/.class class_name (list))}))) _) (case (ffi.check java/lang/reflect/ParameterizedType reflection) - {#.Some reflection} + {.#Some reflection} (let [raw (java/lang/reflect/ParameterizedType::getRawType reflection)] (case (ffi.check java/lang/Class raw) - {#.Some raw} + {.#Some raw} (do [! try.monad] [paramsT (|> reflection java/lang/reflect/ParameterizedType::getActualTypeArguments - (array.list #.None) + (array.list {.#None}) (monad.each ! parameter))] (in (/.class (|> raw (:as (java/lang/Class java/lang/Object)) @@ -190,11 +190,11 @@ (def: .public (parameter reflection) (-> java/lang/reflect/Type (Try (/.Type Parameter))) (<| (case (ffi.check java/lang/reflect/TypeVariable reflection) - {#.Some reflection} - {#try.Success (/.var (java/lang/reflect/TypeVariable::getName reflection))} + {.#Some reflection} + {try.#Success (/.var (java/lang/reflect/TypeVariable::getName reflection))} _) (case (ffi.check java/lang/reflect/WildcardType reflection) - {#.Some reflection} + {.#Some reflection} ... TODO: Instead of having single lower/upper bounds, should ... allow for multiple ones. (case [(array.read! 0 (java/lang/reflect/WildcardType::getLowerBounds reflection)) @@ -202,18 +202,18 @@ (^template [<pattern> <kind>] [<pattern> (case (ffi.check java/lang/reflect/GenericArrayType bound) - {#.Some _} + {.#Some _} ... TODO: Array bounds should not be "erased" as they ... are right now. - {#try.Success /.wildcard} + {try.#Success /.wildcard} _ (\ try.monad each <kind> (..class' parameter bound)))]) - ([[_ {#.Some bound}] /.upper] - [[{#.Some bound} _] /.lower]) + ([[_ {.#Some bound}] /.upper] + [[{.#Some bound} _] /.lower]) _ - {#try.Success /.wildcard}) + {try.#Success /.wildcard}) _) (..class' parameter reflection))) @@ -225,14 +225,14 @@ (def: .public (type reflection) (-> java/lang/reflect/Type (Try (/.Type Value))) (<| (case (ffi.check java/lang/Class reflection) - {#.Some reflection} + {.#Some reflection} (let [class_name (|> reflection (:as (java/lang/Class java/lang/Object)) java/lang/Class::getName)] (`` (cond (~~ (template [<reflection> <type>] [(text\= (/reflection.reflection <reflection>) class_name) - {#try.Success <type>}] + {try.#Success <type>}] [/reflection.boolean /.boolean] [/reflection.byte /.byte] @@ -244,10 +244,10 @@ [/reflection.char /.char])) (if (text.starts_with? /descriptor.array_prefix class_name) (<t>.result /parser.value (|> class_name //name.internal //name.read)) - {#try.Success (/.class class_name (list))})))) + {try.#Success (/.class class_name (list))})))) _) (case (ffi.check java/lang/reflect/GenericArrayType reflection) - {#.Some reflection} + {.#Some reflection} (|> reflection java/lang/reflect/GenericArrayType::getGenericComponentType type @@ -260,16 +260,16 @@ (-> java/lang/reflect/Type (Try (/.Type Return))) (with_expansions [<else> (as_is (..type reflection))] (case (ffi.check java/lang/Class reflection) - {#.Some class} + {.#Some class} (let [class_name (|> reflection (:as (java/lang/Class java/lang/Object)) java/lang/Class::getName)] (if (text\= (/reflection.reflection /reflection.void) class_name) - {#try.Success /.void} + {try.#Success /.void} <else>)) - #.None + {.#None} <else>))) (exception: .public (cannot_correspond [class (java/lang/Class java/lang/Object) @@ -295,9 +295,9 @@ (def: .public (correspond class type) (-> (java/lang/Class java/lang/Object) Type (Try Mapping)) (case type - {#.Primitive name params} + {.#Primitive name params} (let [class_name (java/lang/Class::getName class) - class_params (array.list #.None (java/lang/Class::getTypeParameters class)) + class_params (array.list {.#None} (java/lang/Class::getTypeParameters class)) num_class_params (list.size class_params) num_type_params (list.size params)] (if (text\= class_name name) @@ -308,19 +308,19 @@ (list\mix (function (_ [name paramT] mapping) (dictionary.has name paramT mapping)) /lux.fresh) - #try.Success) + {try.#Success}) (exception.except ..type_parameter_mismatch [num_class_params num_type_params class type])) (exception.except ..cannot_correspond [class type]))) - {#.Named name anonymousT} + {.#Named name anonymousT} (correspond class anonymousT) - {#.Apply inputT abstractionT} + {.#Apply inputT abstractionT} (case (type.applied (list inputT) abstractionT) - {#.Some outputT} + {.#Some outputT} (correspond class outputT) - #.None + {.#None} (exception.except ..non_jvm_type [type])) _ @@ -349,18 +349,18 @@ (def: .public (field field target) (-> Text (java/lang/Class java/lang/Object) (Try java/lang/reflect/Field)) (case (java/lang/Class::getDeclaredField field target) - {#try.Success field} + {try.#Success field} (let [owner (java/lang/reflect/Field::getDeclaringClass field)] (if (same? owner target) - {#try.Success field} + {try.#Success field} (exception.except ..mistaken_field_owner [field owner target]))) - {#try.Failure _} + {try.#Failure _} (exception.except ..unknown_field [field target]))) (def: .public deprecated? (-> (array.Array java/lang/annotation/Annotation) Bit) - (|>> (array.list #.None) + (|>> (array.list {.#None}) (list.all (|>> (ffi.check java/lang/Deprecated))) list.empty? not)) diff --git a/stdlib/source/library/lux/target/jvm/type.lux b/stdlib/source/library/lux/target/jvm/type.lux index 3a3235a7c..9042ebb03 100644 --- a/stdlib/source/library/lux/target/jvm/type.lux +++ b/stdlib/source/library/lux/target/jvm/type.lux @@ -177,8 +177,8 @@ [..float] [..double] [..char])))) - (|> type (:as (Type Primitive)) #.Right) - (|> type (:as (Type Object)) #.Left))) + (|> type (:as (Type Primitive)) {.#Right}) + (|> type (:as (Type Object)) {.#Left}))) (def: .public (void? type) (-> (Type Return) (Either (Type Value) @@ -187,8 +187,8 @@ [(\ ..equivalence = (: (Type Return) <type>) type)] [..void])))) - (|> type (:as (Type Void)) #.Right) - (|> type (:as (Type Value)) #.Left))) + (|> type (:as (Type Void)) {.#Right}) + (|> type (:as (Type Value)) {.#Left}))) ) (def: .public (class? type) @@ -204,7 +204,7 @@ (|> repr (text.clip prefix_size name_size) (\ maybe.monad each (|>> //name.internal //name.external)))) - #.None))) + {.#None}))) (def: .public format (All (_ a) (Format (Type a))) diff --git a/stdlib/source/library/lux/target/jvm/type/lux.lux b/stdlib/source/library/lux/target/jvm/type/lux.lux index ee5734d6d..7aeeea7d9 100644 --- a/stdlib/source/library/lux/target/jvm/type/lux.lux +++ b/stdlib/source/library/lux/target/jvm/type/lux.lux @@ -55,7 +55,7 @@ [(def: <name> (Parser (Check Type)) (<>.after <parser> - (<>\in (check\in {#.Primitive (//reflection.reflection <reflection>) #.End}))))] + (<>\in (check\in {.#Primitive (//reflection.reflection <reflection>) {.#End}}))))] [boolean //parser.boolean //reflection.boolean] [byte //parser.byte //reflection.byte] @@ -71,7 +71,7 @@ [(def: <name> (Parser (Check Type)) (<>.after <parser> - (<>\in (check\in {#.Primitive <box> #.End}))))] + (<>\in (check\in {.#Primitive <box> {.#End}}))))] [boxed_boolean //parser.boolean //box.boolean] [boxed_byte //parser.byte //box.byte] @@ -120,10 +120,10 @@ (do <>.monad [var //parser.var'] (in (case (dictionary.value var mapping) - #.None + {.#None} (check.except ..unknown_var [var]) - {#.Some type} + {.#Some type} (check\in type))))) (def: (class' parameter) @@ -136,7 +136,7 @@ (<>.else (list)))] (in (do [! check.monad] [parameters (monad.all ! parameters)] - (in {#.Primitive name parameters})))) + (in {.#Primitive name parameters})))) (<>.after (<text>.this //descriptor.class_prefix)) (<>.before (<text>.this //descriptor.class_suffix)))) @@ -173,7 +173,7 @@ (-> (Parser (Check Type)) (Parser (Check Type))) (|>> (<>\each (check\each (function (_ elementT) (case elementT - {#.Primitive name #.End} + {.#Primitive name {.#End}} (if (`` (or (~~ (template [<reflection>] [(text\= (//reflection.reflection <reflection>) name)] @@ -185,7 +185,7 @@ [//reflection.float] [//reflection.double] [//reflection.char])))) - {#.Primitive (|> name //reflection.class //reflection.array //reflection.reflection) #.End} + {.#Primitive (|> name //reflection.class //reflection.array //reflection.reflection) {.#End}} (|> elementT array.Array .type)) _ @@ -229,8 +229,8 @@ (def: .public (check operation input) (All (_ a) (-> (Parser (Check a)) Text (Check a))) (case (<text>.result operation input) - {#try.Success check} + {try.#Success check} check - {#try.Failure error} + {try.#Failure error} (check.failure error))) diff --git a/stdlib/source/library/lux/target/jvm/type/signature.lux b/stdlib/source/library/lux/target/jvm/type/signature.lux index b0a2c0303..e263d6c6a 100644 --- a/stdlib/source/library/lux/target/jvm/type/signature.lux +++ b/stdlib/source/library/lux/target/jvm/type/signature.lux @@ -90,7 +90,7 @@ (format //descriptor.class_prefix (|> name ///name.internal ///name.read) (case parameters - #.End + {.#End} "" _ @@ -127,7 +127,7 @@ (Signature Method)) (:abstraction (format (case type_variables - #.End + {.#End} "" _ (|> type_variables diff --git a/stdlib/source/library/lux/target/php.lux b/stdlib/source/library/lux/target/php.lux index 79272dd3e..97fa1edf4 100644 --- a/stdlib/source/library/lux/target/php.lux +++ b/stdlib/source/library/lux/target/php.lux @@ -215,7 +215,7 @@ (def: .public (closure uses arguments body!) (-> (List Argument) (List Argument) Statement Literal) (let [uses (case uses - #.End + {.#End} "" _ diff --git a/stdlib/source/library/lux/target/python.lux b/stdlib/source/library/lux/target/python.lux index 1a9796a44..8b2c5e6bb 100644 --- a/stdlib/source/library/lux/target/python.lux +++ b/stdlib/source/library/lux/target/python.lux @@ -371,11 +371,11 @@ (format "while " (:representation test) ":" (..nested (:representation body!)) (case else! - {#.Some else!} + {.#Some else!} (format text.new_line "else:" (..nested (:representation else!))) - #.None + {.#None} "")))) (def: .public (for_in var inputs body!) @@ -424,10 +424,10 @@ (def: .public (exec code globals) (-> (Expression Any) (Maybe (Expression Any)) (Statement Any)) (let [extra (case globals - {#.Some globals} + {.#Some globals} (.list globals) - #.None + {.#None} (.list))] (:abstraction (format "exec" (:representation (..tuple (list& code extra))))))) diff --git a/stdlib/source/library/lux/target/ruby.lux b/stdlib/source/library/lux/target/ruby.lux index f4f967335..8653d5203 100644 --- a/stdlib/source/library/lux/target/ruby.lux +++ b/stdlib/source/library/lux/target/ruby.lux @@ -370,10 +370,10 @@ (text.enclosed ["{" "}"]) (format "lambda "))] (|> (case name - #.None + {.#None} proc - {#.Some name} + {.#Some name} (format (:representation name) " = " proc)) (text.enclosed ["(" ")"]) :abstraction))) diff --git a/stdlib/source/library/lux/target/scheme.lux b/stdlib/source/library/lux/target/scheme.lux index 692e903bc..0e6dda75a 100644 --- a/stdlib/source/library/lux/target/scheme.lux +++ b/stdlib/source/library/lux/target/scheme.lux @@ -76,9 +76,9 @@ (def: (arguments [mandatory rest]) (-> Arguments (Code Any)) (case rest - {#.Some rest} + {.#Some rest} (case mandatory - #.End + {.#End} rest _ @@ -89,7 +89,7 @@ (text.enclosed ["(" ")"]) :abstraction)) - #.None + {.#None} (|> mandatory (list\each ..code) (text.interposed " ") @@ -156,20 +156,20 @@ (def: form (-> (List (Code Any)) Code) (.let [nested_new_line (format text.new_line text.tab)] - (|>> (case> #.End + (|>> (case> {.#End} (:abstraction "()") - {#.Item head tail} + {.#Item head tail} (|> tail (list\each (|>> :representation ..nested)) - {#.Item (:representation head)} + {.#Item (:representation head)} (text.interposed nested_new_line) (text.enclosed ["(" ")"]) :abstraction))))) (def: .public (apply/* args func) (-> (List Expression) Expression Computation) - (..form {#.Item func args})) + (..form {.#Item func args})) (template [<name> <function>] [(def: .public (<name> members) @@ -340,7 +340,7 @@ (-> Var Arguments Expression Computation) (..form (list (..var "define") (|> arguments - (revised@ #mandatory (|>> {#.Item name})) + (revised@ #mandatory (|>> {.#Item name})) ..arguments) body))) @@ -350,7 +350,7 @@ (def: .public begin (-> (List Expression) Computation) - (|>> {#.Item (..var "begin")} ..form)) + (|>> {.#Item (..var "begin")} ..form)) (def: .public (set! name value) (-> Var Expression Computation) @@ -368,10 +368,10 @@ (-> Var (List [Expression Expression]) (Maybe Expression) Expression Computation) (..form (list (..var "guard") (..form (|> (case else - #.None + {.#None} (list) - {#.Some else} + {.#Some else} (list (..form (list (..var "else") else)))) (list\composite (list\each (function (_ [when then]) (..form (list when then))) diff --git a/stdlib/source/library/lux/test.lux b/stdlib/source/library/lux/test.lux index 6aebcaadc..ea228316a 100644 --- a/stdlib/source/library/lux/test.lux +++ b/stdlib/source/library/lux/test.lux @@ -306,10 +306,10 @@ (loop [remaining encoding output (set.of_list name.hash (list))] (case (text.split_by ..coverage_separator remaining) - {#.Some [head tail]} + {.#Some [head tail]} (recur tail (set.has [module head] output)) - #.None + {.#None} (set.has [module remaining] output)))) (template [<macro> <function>] @@ -353,9 +353,9 @@ .let [coverage (|> definitions (list\mix (function (_ [short [exported? _]] aggregate) (if exported? - {#.Item short aggregate} + {.#Item short aggregate} aggregate)) - #.End) + {.#End}) ..encoded_coverage)]] (in (list (` ((~! ..covering') (~ (code.text module)) @@ -381,10 +381,10 @@ product.right (function (_ _)) "lux try" - (case> {#try.Success output} + (case> {try.#Success output} output - {#try.Failure error} + {try.#Failure error} (..assertion (exception.error ..error_during_execution [error]) false)) io.io async.future diff --git a/stdlib/source/library/lux/time.lux b/stdlib/source/library/lux/time.lux index 743516d24..6747215d7 100644 --- a/stdlib/source/library/lux/time.lux +++ b/stdlib/source/library/lux/time.lux @@ -86,7 +86,7 @@ (def: .public (of_millis milli_seconds) (-> Nat (Try Time)) (if (n.< ..limit milli_seconds) - {#try.Success (:abstraction milli_seconds)} + {try.#Success (:abstraction milli_seconds)} (exception.except ..time_exceeds_a_day [milli_seconds]))) (def: .public millis @@ -201,10 +201,10 @@ (-> Time Text) (let [(^slots [#hour #minute #second #milli_second]) (..clock time)] ($_ text\composite - (..padded hour) - ..separator (..padded minute) - ..separator (..padded second) - (..millis_format milli_second)))) + (..padded #hour) + ..separator (..padded #minute) + ..separator (..padded #second) + (..millis_format #milli_second)))) (implementation: .public codec (Codec Text Time) diff --git a/stdlib/source/library/lux/time/date.lux b/stdlib/source/library/lux/time/date.lux index 52742572d..fa5af30dc 100644 --- a/stdlib/source/library/lux/time/date.lux +++ b/stdlib/source/library/lux/time/date.lux @@ -79,7 +79,7 @@ (-> Year Month Nat (Try Date)) (if (..invalid_day? year month day_of_month) (exception.except ..invalid_day [year month day_of_month]) - {#try.Success + {try.#Success (:abstraction [#year year #month month @@ -89,7 +89,7 @@ Date (try.trusted (..date //year.epoch - #//month.January + {//month.#January} ..minimum_day))) (template [<name> <type> <field>] @@ -223,8 +223,8 @@ (n.* //year.days) (n.+ leaps::70)) ... The epoch is being calculated from March 1st, instead of January 1st. - january_&_february (n.+ (//month.days #//month.January) - (//month.days #//month.February))] + january_&_february (n.+ (//month.days {//month.#January}) + (//month.days {//month.#February}))] (|> 0 ... 1600/01/01 (n.+ (n.* 4 days_per_era)) diff --git a/stdlib/source/library/lux/time/day.lux b/stdlib/source/library/lux/time/day.lux index aee0a9f33..6bdbba5b2 100644 --- a/stdlib/source/library/lux/time/day.lux +++ b/stdlib/source/library/lux/time/day.lux @@ -11,7 +11,7 @@ ["[0]" try {"+" [Try]}] ["[0]" exception {"+" [exception:]}]] [data - ["[0]" text]] + ["[0]" text ("[1]#[0]" monoid)]] [macro ["[0]" template]] [math @@ -20,13 +20,13 @@ (type: .public Day (Variant - #Sunday - #Monday - #Tuesday - #Wednesday - #Thursday - #Friday - #Saturday)) + {#Sunday} + {#Monday} + {#Tuesday} + {#Wednesday} + {#Thursday} + {#Friday} + {#Saturday})) (implementation: .public equivalence (Equivalence Day) @@ -34,7 +34,7 @@ (def: (= reference sample) (case [reference sample] (^template [<tag>] - [[<tag> <tag>] + [[{<tag>} {<tag>}] #1]) ([#Sunday] [#Monday] @@ -50,13 +50,13 @@ (def: (nat day) (-> Day Nat) (case day - #Sunday 0 - #Monday 1 - #Tuesday 2 - #Wednesday 3 - #Thursday 4 - #Friday 5 - #Saturday 6)) + {#Sunday} 0 + {#Monday} 1 + {#Tuesday} 2 + {#Wednesday} 3 + {#Thursday} 4 + {#Friday} 5 + {#Saturday} 6)) (implementation: .public order (Order Day) @@ -73,23 +73,23 @@ (def: (succ day) (case day - #Sunday #Monday - #Monday #Tuesday - #Tuesday #Wednesday - #Wednesday #Thursday - #Thursday #Friday - #Friday #Saturday - #Saturday #Sunday)) + {#Sunday} {#Monday} + {#Monday} {#Tuesday} + {#Tuesday} {#Wednesday} + {#Wednesday} {#Thursday} + {#Thursday} {#Friday} + {#Friday} {#Saturday} + {#Saturday} {#Sunday})) (def: (pred day) (case day - #Monday #Sunday - #Tuesday #Monday - #Wednesday #Tuesday - #Thursday #Wednesday - #Friday #Thursday - #Saturday #Friday - #Sunday #Saturday))) + {#Monday} {#Sunday} + {#Tuesday} {#Monday} + {#Wednesday} {#Tuesday} + {#Thursday} {#Wednesday} + {#Friday} {#Thursday} + {#Saturday} {#Friday} + {#Sunday} {#Saturday}))) (exception: .public (not_a_day_of_the_week [value Text]) (exception.report @@ -101,36 +101,38 @@ (def: (encoded value) (case value (^template [<tag>] - [<tag> (template.text [<tag>])]) - ([#..Monday] - [#..Tuesday] - [#..Wednesday] - [#..Thursday] - [#..Friday] - [#..Saturday] - [#..Sunday]))) + [{<tag>} + (text.replaced "#" "" (template.text [<tag>]))]) + ([..#Monday] + [..#Tuesday] + [..#Wednesday] + [..#Thursday] + [..#Friday] + [..#Saturday] + [..#Sunday]))) (def: (decoded value) - (case value + (case (text#composite "#" value) (^template [<tag>] - [(^ (template.text [<tag>])) {#try.Success <tag>}]) - ([#..Monday] - [#..Tuesday] - [#..Wednesday] - [#..Thursday] - [#..Friday] - [#..Saturday] - [#..Sunday]) + [(^ (template.text [<tag>])) + {try.#Success {<tag>}}]) + ([..#Monday] + [..#Tuesday] + [..#Wednesday] + [..#Thursday] + [..#Friday] + [..#Saturday] + [..#Sunday]) _ (exception.except ..not_a_day_of_the_week [value])))) (def: .public week (List Day) - (list #Sunday - #Monday - #Tuesday - #Wednesday - #Thursday - #Friday - #Saturday)) + (list {#Sunday} + {#Monday} + {#Tuesday} + {#Wednesday} + {#Thursday} + {#Friday} + {#Saturday})) (with_expansions [<pairs> (as_is [01 #Sunday] [02 #Monday] @@ -143,24 +145,28 @@ (-> Day Nat) (case day (^template [<number> <day>] - [<day> <number>]) + [{<day>} + <number>]) (<pairs>))) (exception: .public (invalid_day [number Nat]) (exception.report ["Number" (\ n.decimal encoded number)] ["Valid range" ($_ "lux text concat" - (\ n.decimal encoded (..number #Sunday)) + (\ n.decimal encoded (..number {#Sunday})) " ~ " - (\ n.decimal encoded (..number #Saturday)))])) + (\ n.decimal encoded (..number {#Saturday})))])) (def: .public (by_number number) (-> Nat (Try Day)) (case number (^template [<number> <day>] - [<number> {#try.Success <day>}]) + [<number> + {try.#Success {<day>}}]) (<pairs>) - _ (exception.except ..invalid_day [number]))) + + _ + (exception.except ..invalid_day [number]))) ) (implementation: .public hash @@ -170,7 +176,7 @@ (def: (hash day) (case day (^template [<prime> <day>] - [<day> + [{<day>} <prime>]) ([02 #Sunday] [03 #Monday] diff --git a/stdlib/source/library/lux/time/duration.lux b/stdlib/source/library/lux/time/duration.lux index fd4a728f2..94b73e791 100644 --- a/stdlib/source/library/lux/time/duration.lux +++ b/stdlib/source/library/lux/time/duration.lux @@ -178,8 +178,8 @@ (..merged (..up seconds ..second)) (..merged (..up millis ..milli_second)))]] (in (case sign - {#.Left _} (..inverse span) - {#.Right _} span))))) + {.#Left _} (..inverse span) + {.#Right _} span))))) (implementation: .public codec (Codec Text Duration) diff --git a/stdlib/source/library/lux/time/instant.lux b/stdlib/source/library/lux/time/instant.lux index d5ffcdb7e..5fb300424 100644 --- a/stdlib/source/library/lux/time/instant.lux +++ b/stdlib/source/library/lux/time/instant.lux @@ -216,13 +216,13 @@ (i.+ days) (i.% +7) ... This is done to turn negative days into positive days. (i.+ +7) (i.% +7)) - +0 #day.Sunday - +1 #day.Monday - +2 #day.Tuesday - +3 #day.Wednesday - +4 #day.Thursday - +5 #day.Friday - +6 #day.Saturday + +0 {day.#Sunday} + +1 {day.#Monday} + +2 {day.#Tuesday} + +3 {day.#Wednesday} + +4 {day.#Thursday} + +5 {day.#Friday} + +6 {day.#Saturday} _ (undefined)))) (def: .public (of_date_time date time) diff --git a/stdlib/source/library/lux/time/month.lux b/stdlib/source/library/lux/time/month.lux index e2936b80e..0717ed1b9 100644 --- a/stdlib/source/library/lux/time/month.lux +++ b/stdlib/source/library/lux/time/month.lux @@ -11,7 +11,7 @@ ["[0]" try {"+" [Try]}] ["[0]" exception {"+" [exception:]}]] [data - ["[0]" text]] + ["[0]" text ("[1]#[0]" monoid)]] [macro ["[0]" template]] [math @@ -20,18 +20,18 @@ (type: .public Month (Variant - #January - #February - #March - #April - #May - #June - #July - #August - #September - #October - #November - #December)) + {#January} + {#February} + {#March} + {#April} + {#May} + {#June} + {#July} + {#August} + {#September} + {#October} + {#November} + {#December})) (implementation: .public equivalence (Equivalence Month) @@ -39,7 +39,7 @@ (def: (= reference sample) (case [reference sample] (^template [<tag>] - [[<tag> <tag>] + [[{<tag>} {<tag>}] true]) ([#January] [#February] @@ -73,24 +73,28 @@ (-> Month Nat) (case month (^template [<number> <month>] - [<month> <number>]) + [{<month>} + <number>]) (<pairs>))) (exception: .public (invalid_month [number Nat]) (exception.report ["Number" (\ n.decimal encoded number)] ["Valid range" ($_ "lux text concat" - (\ n.decimal encoded (..number #January)) + (\ n.decimal encoded (..number {#January})) " ~ " - (\ n.decimal encoded (..number #December)))])) + (\ n.decimal encoded (..number {#December})))])) (def: .public (by_number number) (-> Nat (Try Month)) (case number (^template [<number> <month>] - [<number> {#try.Success <month>}]) + [<number> + {try.#Success {<month>}}]) (<pairs>) - _ (exception.except ..invalid_month [number]))) + + _ + (exception.except ..invalid_month [number]))) ) (implementation: .public hash @@ -100,7 +104,7 @@ (def: (hash month) (case month (^template [<prime> <month>] - [<month> + [{<month>} <prime>]) ([02 #January] [03 #February] @@ -121,7 +125,8 @@ (def: &equivalence ..equivalence) (def: (< reference sample) - (n.< (..number reference) (..number sample)))) + (n.< (..number reference) + (..number sample)))) (implementation: .public enum (Enum Month) @@ -130,39 +135,40 @@ (def: (succ month) (case month - #January #February - #February #March - #March #April - #April #May - #May #June - #June #July - #July #August - #August #September - #September #October - #October #November - #November #December - #December #January)) + {#January} {#February} + {#February} {#March} + {#March} {#April} + {#April} {#May} + {#May} {#June} + {#June} {#July} + {#July} {#August} + {#August} {#September} + {#September} {#October} + {#October} {#November} + {#November} {#December} + {#December} {#January})) (def: (pred month) (case month - #February #January - #March #February - #April #March - #May #April - #June #May - #July #June - #August #July - #September #August - #October #September - #November #October - #December #November - #January #December))) + {#February} {#January} + {#March} {#February} + {#April} {#March} + {#May} {#April} + {#June} {#May} + {#July} {#June} + {#August} {#July} + {#September} {#August} + {#October} {#September} + {#November} {#October} + {#December} {#November} + {#January} {#December}))) (def: .public (days month) (-> Month Nat) (case month (^template [<days> <month>] - [<month> <days>]) + [{<month>} + <days>]) ([31 #January] [28 #February] [31 #March] @@ -182,23 +188,23 @@ (def: .public (leap_year_days month) (-> Month Nat) (case month - #February (++ (..days month)) + {#February} (++ (..days month)) _ (..days month))) (def: .public year (List Month) - (list #January - #February - #March - #April - #May - #June - #July - #August - #September - #October - #November - #December)) + (list {#January} + {#February} + {#March} + {#April} + {#May} + {#June} + {#July} + {#August} + {#September} + {#October} + {#November} + {#December})) (exception: .public (not_a_month_of_the_year [value Text]) (exception.report @@ -210,33 +216,35 @@ (def: (encoded value) (case value (^template [<tag>] - [<tag> (template.text [<tag>])]) - ([#..January] - [#..February] - [#..March] - [#..April] - [#..May] - [#..June] - [#..July] - [#..August] - [#..September] - [#..October] - [#..November] - [#..December]))) + [{<tag>} + (text.replaced "#" "" (template.text [<tag>]))]) + ([..#January] + [..#February] + [..#March] + [..#April] + [..#May] + [..#June] + [..#July] + [..#August] + [..#September] + [..#October] + [..#November] + [..#December]))) (def: (decoded value) - (case value + (case (text#composite "#" value) (^template [<tag>] - [(^ (template.text [<tag>])) {#try.Success <tag>}]) - ([#..January] - [#..February] - [#..March] - [#..April] - [#..May] - [#..June] - [#..July] - [#..August] - [#..September] - [#..October] - [#..November] - [#..December]) + [(^ (template.text [<tag>])) + {try.#Success {<tag>}}]) + ([..#January] + [..#February] + [..#March] + [..#April] + [..#May] + [..#June] + [..#July] + [..#August] + [..#September] + [..#October] + [..#November] + [..#December]) _ (exception.except ..not_a_month_of_the_year [value])))) diff --git a/stdlib/source/library/lux/time/year.lux b/stdlib/source/library/lux/time/year.lux index cff485bde..adc9c8f92 100644 --- a/stdlib/source/library/lux/time/year.lux +++ b/stdlib/source/library/lux/time/year.lux @@ -42,7 +42,7 @@ (-> Int (Try Year)) (case value +0 (exception.except ..there_is_no_year_0 []) - _ {#try.Success (:abstraction (..internal value))})) + _ {try.#Success (:abstraction (..internal value))})) (def: .public value (-> Year Int) @@ -118,8 +118,8 @@ digits (<text>.many <text>.decimal) raw_year (<>.codec i.decimal (in (text\composite "+" digits)))] (<>.lifted (..year (case sign - {#.Left _} (i.* -1 raw_year) - {#.Right _} raw_year))))) + {.#Left _} (i.* -1 raw_year) + {.#Right _} raw_year))))) (implementation: .public codec (Codec Text Year) diff --git a/stdlib/source/library/lux/tool/compiler/default/init.lux b/stdlib/source/library/lux/tool/compiler/default/init.lux index a43b9a4d9..d583a072a 100644 --- a/stdlib/source/library/lux/tool/compiler/default/init.lux +++ b/stdlib/source/library/lux/tool/compiler/default/init.lux @@ -67,12 +67,12 @@ analysis_state [(analysisE.bundle eval host_analysis) (///analysis.state (///analysis.info ///version.version target))]] [extension.empty - [#///directive.analysis [#///directive.state analysis_state - #///directive.phase (analysisP.phase expander)] - #///directive.synthesis [#///directive.state synthesis_state - #///directive.phase synthesisP.phase] - #///directive.generation [#///directive.state generation_state - #///directive.phase generate]]])) + [///directive.#analysis [///directive.#state analysis_state + ///directive.#phase (analysisP.phase expander)] + ///directive.#synthesis [///directive.#state synthesis_state + ///directive.#phase synthesisP.phase] + ///directive.#generation [///directive.#state generation_state + ///directive.#phase generate]]])) (def: .public (with_default_directives expander host_analysis program anchorT,expressionT,directiveT extender) (All (_ anchor expression directive) @@ -94,21 +94,21 @@ (def: (reader current_module aliases [location offset source_code]) (-> Module Aliases Source (///analysis.Operation Reader)) (function (_ [bundle state]) - {#try.Success [[bundle state] + {try.#Success [[bundle state] (///syntax.parse current_module aliases ("lux text size" source_code))]})) (def: (read source reader) (-> Source Reader (///analysis.Operation [Source Code])) (function (_ [bundle compiler]) (case (reader source) - {#.Left [source' error]} - {#try.Failure error} + {.#Left [source' error]} + {try.#Failure error} - {#.Right [source' output]} + {.#Right [source' output]} (let [[location _] output] - {#try.Success [[bundle (|> compiler - (with@ #.source source') - (with@ #.location location))] + {try.#Success [[bundle (|> compiler + (with@ .#source source') + (with@ .#location location))] [source' output]]})))) (type: (Operation a) @@ -125,13 +125,13 @@ (///directive.Operation anchor expression directive [Source (Payload directive)]))) (do ///phase.monad - [.let [module (value@ #///.module input)] + [.let [module (value@ ///.#module input)] _ (///directive.set_current_module module)] (///directive.lifted_analysis (do [! ///phase.monad] [_ (module.create hash module) _ (monad.each ! module.import dependencies) - .let [source (///analysis.source (value@ #///.module input) (value@ #///.code input))] + .let [source (///analysis.source (value@ ///.#module input) (value@ ///.#code input))] _ (///analysis.set_source_code source)] (in [source [///generation.empty_buffer artifact.empty]]))))) @@ -209,24 +209,24 @@ (..reader module aliases source))] (function (_ state) (case (///phase.result' state (..iteration' wrapper archive expander reader source pre_payload)) - {#try.Success [state source&requirements&buffer]} - {#try.Success [state {#.Some source&requirements&buffer}]} + {try.#Success [state source&requirements&buffer]} + {try.#Success [state {.#Some source&requirements&buffer}]} - {#try.Failure error} + {try.#Failure error} (if (exception.match? ///syntax.end_of_file error) - {#try.Success [state #.None]} - (exception.with ///.cannot_compile module {#try.Failure error})))))) + {try.#Success [state {.#None}]} + (exception.with ///.cannot_compile module {try.#Failure error})))))) (def: (default_dependencies prelude input) (-> Module ///.Input (List Module)) (list& archive.runtime_module - (if (text\= prelude (value@ #///.module input)) + (if (text\= prelude (value@ ///.#module input)) (list) (list prelude)))) (def: module_aliases (-> .Module Aliases) - (|>> (value@ #.module_aliases) (dictionary.of_list text.hash))) + (|>> (value@ .#module_aliases) (dictionary.of_list text.hash))) (def: .public (compiler wrapper expander prelude write_directive) (All (_ anchor expression directive) @@ -235,41 +235,41 @@ (let [execute! (directiveP.phase wrapper expander)] (function (_ key parameters input) (let [dependencies (default_dependencies prelude input)] - [#///.dependencies dependencies - #///.process (function (_ state archive) + [///.#dependencies dependencies + ///.#process (function (_ state archive) (do [! try.monad] - [.let [hash (text\hash (value@ #///.code input))] + [.let [hash (text\hash (value@ ///.#code input))] [state [source buffer]] (<| (///phase.result' state) (..begin dependencies hash input)) - .let [module (value@ #///.module input)]] + .let [module (value@ ///.#module input)]] (loop [iteration (<| (///phase.result' state) (..iteration wrapper archive expander module source buffer ///syntax.no_aliases))] (do ! [[state ?source&requirements&temporary_payload] iteration] (case ?source&requirements&temporary_payload - #.None + {.#None} (do ! [[state [analysis_module [final_buffer final_registry]]] (///phase.result' state (..end module)) - .let [descriptor [#descriptor.hash hash - #descriptor.name module - #descriptor.file (value@ #///.file input) - #descriptor.references (set.of_list text.hash dependencies) - #descriptor.state #.Compiled - #descriptor.registry final_registry]]] + .let [descriptor [descriptor.#hash hash + descriptor.#name module + descriptor.#file (value@ ///.#file input) + descriptor.#references (set.of_list text.hash dependencies) + descriptor.#state {.#Compiled} + descriptor.#registry final_registry]]] (in [state - {#.Right [descriptor + {.#Right [descriptor (document.write key analysis_module) (row\each (function (_ [artifact_id custom directive]) [artifact_id custom (write_directive directive)]) final_buffer)]}])) - {#.Some [source requirements temporary_payload]} + {.#Some [source requirements temporary_payload]} (let [[temporary_buffer temporary_registry] temporary_payload] (in [state - {#.Left [#///.dependencies (|> requirements - (value@ #///directive.imports) + {.#Left [///.#dependencies (|> requirements + (value@ ///directive.#imports) (list\each product.left)) - #///.process (function (_ state archive) + ///.#process (function (_ state archive) (recur (<| (///phase.result' state) (do [! ///phase.monad] [analysis_module (<| (: (Operation .Module)) @@ -281,7 +281,7 @@ _ (///directive.lifted_generation (///generation.set_registry temporary_registry)) _ (|> requirements - (value@ #///directive.referrals) + (value@ ///directive.#referrals) (monad.each ! (execute! archive))) temporary_payload (..get_current_payload temporary_payload)] (..iteration wrapper archive expander module source temporary_payload (..module_aliases analysis_module))))))]}])) diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux index f884282eb..eda9c6147 100644 --- a/stdlib/source/library/lux/tool/compiler/default/platform.lux +++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux @@ -131,12 +131,12 @@ (def: (runtime_descriptor registry) (-> Registry Descriptor) - [#descriptor.hash 0 - #descriptor.name archive.runtime_module - #descriptor.file "" - #descriptor.references (set.empty text.hash) - #descriptor.state #.Compiled - #descriptor.registry registry]) + [descriptor.#hash 0 + descriptor.#name archive.runtime_module + descriptor.#file "" + descriptor.#references (set.empty text.hash) + descriptor.#state {.#Compiled} + descriptor.#registry registry]) (def: runtime_document (Document .Module) @@ -234,7 +234,7 @@ Import (List Context) (Async (Try [<State+> Archive ///phase.Wrapper])))) (do [! (try.with async.monad)] - [.let [state (//init.state (value@ #static.host static) + [.let [state (//init.state (value@ static.#host static) module expander host_analysis @@ -276,11 +276,11 @@ (def: (module_compilation_log module) (All (_ <type_vars>) (-> Module <State+> Text)) - (|>> (value@ [#extension.state - #///directive.generation - #///directive.state - #extension.state - #///generation.log]) + (|>> (value@ [extension.#state + ///directive.#generation + ///directive.#state + extension.#state + ///generation.#log]) (row\mix (function (_ right left) (format left ..compilation_log_separator right)) module))) @@ -288,11 +288,11 @@ (def: with_reset_log (All (_ <type_vars>) (-> <State+> <State+>)) - (with@ [#extension.state - #///directive.generation - #///directive.state - #extension.state - #///generation.log] + (with@ [extension.#state + ///directive.#generation + ///directive.#state + extension.#state + ///generation.#log] row.empty)) (def: empty @@ -382,7 +382,7 @@ (exception.except ..cannot_import_circular_dependency [importer importee]) ... else - {#try.Success []})) + {try.#Success []})) (with_expansions [<Context> (as_is [Archive <State+>]) <Result> (as_is (Try <Context>)) @@ -423,30 +423,30 @@ [[_ dependence] (stm.update (..depend importer module) dependence)] (in dependence)))] (case (..verify_dependencies importer module dependence) - {#try.Failure error} - (in [(async.resolved {#try.Failure error}) - #.None]) + {try.#Failure error} + (in [(async.resolved {try.#Failure error}) + {.#None}]) - {#try.Success _} + {try.#Success _} (do ! [[archive state] (stm.read current)] (if (archive.archived? archive module) - (in [(async\in {#try.Success [archive state]}) - #.None]) + (in [(async\in {try.#Success [archive state]}) + {.#None}]) (do ! [@pending (stm.read pending)] (case (dictionary.value module @pending) - {#.Some [return signal]} + {.#Some [return signal]} (in [return - #.None]) + {.#None}]) - #.None + {.#None} (case (if (archive.reserved? archive module) (do try.monad [module_id (archive.id module archive)] (in [module_id archive])) (archive.reserve module archive)) - {#try.Success [module_id archive]} + {try.#Success [module_id archive]} (do ! [_ (stm.write [archive state] current) .let [[return signal] (:sharing [<type_vars>] @@ -457,31 +457,31 @@ (async.async []))] _ (stm.update (dictionary.has module [return signal]) pending)] (in [return - {#.Some [[archive state] + {.#Some [[archive state] module_id signal]}])) - {#try.Failure error} - (in [(async\in {#try.Failure error}) - #.None]))))))))))) + {try.#Failure error} + (in [(async\in {try.#Failure error}) + {.#None}]))))))))))) _ (case signal - #.None + {.#None} (in []) - {#.Some [context module_id resolver]} + {.#Some [context module_id resolver]} (do ! [result (compile importer import! module_id context module) result (case result - {#try.Failure error} + {try.#Failure error} (in result) - {#try.Success [resulting_archive resulting_state]} + {try.#Success [resulting_archive resulting_state]} (stm.commit! (do stm.monad [[_ [merged_archive _]] (stm.update (function (_ [archive state]) [(archive.merged resulting_archive archive) state]) current)] - (in {#try.Success [merged_archive resulting_state]})))) + (in {try.#Success [merged_archive resulting_state]})))) _ (async.future (resolver result))] (in [])))] return))))) @@ -500,14 +500,14 @@ .let [additions (|> modules (list\each product.left) (set.of_list text.hash))]] - (in (revised@ [#extension.state - #///directive.analysis - #///directive.state - #extension.state] + (in (revised@ [extension.#state + ///directive.#analysis + ///directive.#state + extension.#state] (function (_ analysis_state) (|> analysis_state (:as .Lux) - (revised@ #.modules (function (_ current) + (revised@ .#modules (function (_ current) (list\composite (list.only (|>> product.left (set.member? additions) not) @@ -544,14 +544,14 @@ importer import compilation_sources - (value@ #static.host_module_extension static) + (value@ static.#host_module_extension static) module)] (loop [[archive state] [archive state] compilation (base_compiler (:as ///.Input input)) all_dependencies (: (Set Module) (set.of_list text.hash (list)))] (do ! - [.let [new_dependencies (value@ #///.dependencies compilation) + [.let [new_dependencies (value@ ///.#dependencies compilation) continue! (:sharing [<type_vars>] <Platform> platform @@ -576,10 +576,10 @@ new_dependencies))] [archive state] (if (set.empty? duplicates) (case new_dependencies - #.End + {.#End} (in [archive state]) - {#.Item _} + {.#Item _} (do ! [archive,document+ (|> new_dependencies (list\each (import! module)) @@ -590,7 +590,7 @@ (in [archive (try.trusted (..updated_state archive state))]))) (async\in (exception.except ..cannot_import_twice [module duplicates])))] - (case ((value@ #///.process compilation) + (case ((value@ ///.#process compilation) ... TODO: The "///directive.set_current_module" below shouldn't be necessary. Remove it ASAP. ... TODO: The context shouldn't need to be re-set either. (|> (///directive.set_current_module module) @@ -598,27 +598,27 @@ try.trusted product.left) archive) - {#try.Success [state more|done]} + {try.#Success [state more|done]} (case more|done - {#.Left more} + {.#Left more} (continue! [archive state] more all_dependencies) - {#.Right [descriptor document output]} + {.#Right [descriptor document output]} (do ! [.let [_ (debug.log! (..module_compilation_log module state)) - descriptor (with@ #descriptor.references all_dependencies descriptor)] + descriptor (with@ descriptor.#references all_dependencies descriptor)] _ (..cache_module static platform module_id [descriptor document output])] (case (archive.has module [descriptor document output] archive) - {#try.Success archive} + {try.#Success archive} (in [archive (..with_reset_log state)]) - {#try.Failure error} - (async\in {#try.Failure error})))) + {try.#Failure error} + (async\in {try.#Failure error})))) - {#try.Failure error} + {try.#Failure error} (do ! [_ (ioW.freeze (value@ #&file_system platform) static archive)] - (async\in {#try.Failure error}))))))))] + (async\in {try.#Failure error}))))))))] (compiler archive.runtime_module compilation_module))) ))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux.lux index 251a543a3..39714d1c0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux.lux @@ -86,10 +86,10 @@ ... #imports (<b>.list <b>.text) ... #module_state - (\ <>.monad in #.Cached)))) + (\ <>.monad in {.#Cached})))) (def: .public key (Key .Module) - (key.key [#signature.name (name_of ..compiler) - #signature.version /version.version] + (key.key [signature.#name (name_of ..compiler) + signature.#version /version.version] (module.empty 0))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux index fb9566948..1fd1fe2b4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux @@ -37,7 +37,7 @@ (type: .public Primitive (.Variant - #Unit + {#Unit} {#Bit Bit} {#Nat Nat} {#Int Int} @@ -120,7 +120,7 @@ (def: (= reference sample) (case [reference sample] - [#Unit #Unit] + [{#Unit} {#Unit}] true (^template [<tag> <=>] @@ -213,7 +213,7 @@ [{#Case [reference_analysis reference_match]} {#Case [sample_analysis sample_match]}] (and (= reference_analysis sample_analysis) - (\ (list.equivalence (branch_equivalence =)) = {#.Item reference_match} {#.Item sample_match})) + (\ (list.equivalence (branch_equivalence =)) = {.#Item reference_match} {.#Item sample_match})) [{#Function [reference_environment reference_analysis]} {#Function [sample_environment sample_analysis]}] @@ -233,24 +233,24 @@ (template [<name> <tag>] [(template: .public (<name> content) - [(<tag> content)])] + [{<tag> content}])] - [control/case #..Case] + [control/case ..#Case] ) (template: .public (unit) - [{#..Primitive #..Unit}]) + [{..#Primitive {..#Unit}}]) (template [<name> <tag>] [(template: .public (<name> value) - [{#..Primitive {<tag> value}}])] - - [bit #..Bit] - [nat #..Nat] - [int #..Int] - [rev #..Rev] - [frac #..Frac] - [text #..Text] + [{..#Primitive {<tag> value}}])] + + [bit ..#Bit] + [nat ..#Nat] + [int ..#Int] + [rev ..#Rev] + [frac ..#Frac] + [text ..#Text] ) (type: .public (Abstraction c) @@ -265,11 +265,11 @@ (template: .public (no_op value) [(|> 1 - {#variable.Local} - {#reference.Variable} - {#..Reference} - {#..Function (list)} - {#..Apply value})]) + {variable.#Local} + {reference.#Variable} + {..#Reference} + {..#Function (list)} + {..#Apply value})]) (def: .public (apply [abstraction inputs]) (-> (Application Analysis) Analysis) @@ -284,19 +284,19 @@ inputs (list)] (case abstraction {#Apply input next} - (recur next {#.Item input inputs}) + (recur next {.#Item input inputs}) _ [abstraction inputs]))) (template [<name> <tag>] [(template: .public (<name> content) - [(.<| {#..Reference} + [(.<| {..#Reference} <tag> content)])] - [variable {#reference.Variable}] - [constant {#reference.Constant}] + [variable {reference.#Variable}] + [constant {reference.#Constant}] [variable/local (reference.local)] [variable/foreign (reference.foreign)] @@ -304,48 +304,48 @@ (template [<name> <tag>] [(template: .public (<name> content) - [(.<| {#..Complex} + [(.<| {..#Complex} <tag> content)])] - [pattern/variant {#..Variant}] - [pattern/tuple {#..Tuple}] + [pattern/variant {..#Variant}] + [pattern/tuple {..#Tuple}] ) (template [<name> <tag>] [(template: .public (<name> content) - [(.<| {#..Structure} + [(.<| {..#Structure} {<tag>} content)])] - [variant #..Variant] - [tuple #..Tuple] + [variant ..#Variant] + [tuple ..#Tuple] ) (template: .public (pattern/unit) - [{#..Simple #..Unit}]) + [{..#Simple {..#Unit}}]) (template [<name> <tag>] [(template: .public (<name> content) - [{#..Simple {<tag> content}}])] + [{..#Simple {<tag> content}}])] - [pattern/bit #..Bit] - [pattern/nat #..Nat] - [pattern/int #..Int] - [pattern/rev #..Rev] - [pattern/frac #..Frac] - [pattern/text #..Text] + [pattern/bit ..#Bit] + [pattern/nat ..#Nat] + [pattern/int ..#Int] + [pattern/rev ..#Rev] + [pattern/frac ..#Frac] + [pattern/text ..#Text] ) (template: .public (pattern/bind register) - [{#..Bind register}]) + [{..#Bind register}]) (def: .public (%analysis analysis) (Format Analysis) (case analysis {#Primitive primitive} (case primitive - #Unit + {#Unit} "[]" (^template [<tag> <format>] @@ -387,7 +387,7 @@ {#Apply _} (|> analysis ..application - {#.Item} + {.#Item} (list\each %analysis) (text.interposed " ") (text.enclosed ["(" ")"])) @@ -413,42 +413,42 @@ (def: .public (with_source_code source action) (All (_ a) (-> Source (Operation a) (Operation a))) (function (_ [bundle state]) - (let [old_source (value@ #.source state)] - (case (action [bundle (with@ #.source source state)]) - {#try.Success [[bundle' state'] output]} - {#try.Success [[bundle' (with@ #.source old_source state')] + (let [old_source (value@ .#source state)] + (case (action [bundle (with@ .#source source state)]) + {try.#Success [[bundle' state'] output]} + {try.#Success [[bundle' (with@ .#source old_source state')] output]} - {#try.Failure error} - {#try.Failure error})))) + {try.#Failure error} + {try.#Failure error})))) (def: fresh_bindings (All (_ k v) (Bindings k v)) - [#.counter 0 - #.mappings (list)]) + [.#counter 0 + .#mappings (list)]) (def: fresh_scope Scope - [#.name (list) - #.inner 0 - #.locals fresh_bindings - #.captured fresh_bindings]) + [.#name (list) + .#inner 0 + .#locals fresh_bindings + .#captured fresh_bindings]) (def: .public (with_scope action) (All (_ a) (-> (Operation a) (Operation [Scope a]))) (function (_ [bundle state]) - (case (action [bundle (revised@ #.scopes (|>> {#.Item fresh_scope}) state)]) - {#try.Success [[bundle' state'] output]} - (case (value@ #.scopes state') - {#.Item head tail} - {#try.Success [[bundle' (with@ #.scopes tail state')] + (case (action [bundle (revised@ .#scopes (|>> {.#Item fresh_scope}) state)]) + {try.#Success [[bundle' state'] output]} + (case (value@ .#scopes state') + {.#Item head tail} + {try.#Success [[bundle' (with@ .#scopes tail state')] [head output]]} - #.End - {#try.Failure "Impossible error: Drained scopes!"}) + {.#End} + {try.#Failure "Impossible error: Drained scopes!"}) - {#try.Failure error} - {#try.Failure error}))) + {try.#Failure error} + {try.#Failure error}))) (def: scope_reset (List Scope) @@ -457,33 +457,33 @@ (def: .public (without_scopes action) (All (_ a) (-> (Operation a) (Operation a))) (function (_ [bundle state]) - (case (action [bundle (with@ #.scopes ..scope_reset state)]) - {#try.Success [[bundle' state'] output]} - {#try.Success [[bundle' (with@ #.scopes (value@ #.scopes state) state')] + (case (action [bundle (with@ .#scopes ..scope_reset state)]) + {try.#Success [[bundle' state'] output]} + {try.#Success [[bundle' (with@ .#scopes (value@ .#scopes state) state')] output]} - {#try.Failure error} - {#try.Failure error}))) + {try.#Failure error} + {try.#Failure error}))) (def: .public (with_current_module name) (All (_ a) (-> Text (Operation a) (Operation a))) - (extension.localized (value@ #.current_module) - (with@ #.current_module) - (function.constant {#.Some name}))) + (extension.localized (value@ .#current_module) + (with@ .#current_module) + (function.constant {.#Some name}))) (def: .public (with_location location action) (All (_ a) (-> Location (Operation a) (Operation a))) (if (text\= "" (product.left location)) action (function (_ [bundle state]) - (let [old_location (value@ #.location state)] - (case (action [bundle (with@ #.location location state)]) - {#try.Success [[bundle' state'] output]} - {#try.Success [[bundle' (with@ #.location old_location state')] + (let [old_location (value@ .#location state)] + (case (action [bundle (with@ .#location location state)]) + {try.#Success [[bundle' state'] output]} + {try.#Success [[bundle' (with@ .#location old_location state')] output]} - {#try.Failure error} - {#try.Failure error}))))) + {try.#Failure error} + {try.#Failure error}))))) (def: (locate_error location error) (-> Location Text Text) @@ -493,7 +493,7 @@ (def: .public (failure error) (-> Text Operation) (function (_ [bundle state]) - {#try.Failure (locate_error (value@ #.location state) error)})) + {try.#Failure (locate_error (value@ .#location state) error)})) (def: .public (except exception parameters) (All (_ e) (-> (Exception e) e Operation)) @@ -508,7 +508,7 @@ (def: .public (failure' error) (-> Text (phase.Operation Lux)) (function (_ state) - {#try.Failure (locate_error (value@ #.location state) error)})) + {try.#Failure (locate_error (value@ .#location state) error)})) (def: .public (except' exception parameters) (All (_ e) (-> (Exception e) e (phase.Operation Lux))) @@ -519,17 +519,17 @@ (function (_ bundle,state) (case (exception.with exception message (action bundle,state)) - {#try.Success output} - {#try.Success output} + {try.#Success output} + {try.#Success output} - {#try.Failure error} + {try.#Failure error} (let [[bundle state] bundle,state] - {#try.Failure (locate_error (value@ #.location state) error)})))) + {try.#Failure (locate_error (value@ .#location state) error)})))) (def: .public (install state) (-> .Lux (Operation Any)) (function (_ [bundle _]) - {#try.Success [[bundle state] + {try.#Success [[bundle state] []]})) (template [<name> <type> <field> <value>] @@ -537,9 +537,9 @@ (-> <type> (Operation Any)) (extension.update (with@ <field> <value>)))] - [set_source_code Source #.source value] - [set_current_module Text #.current_module {#.Some value}] - [set_location Location #.location value] + [set_source_code Source .#source value] + [set_current_module Text .#current_module {.#Some value}] + [set_location Location .#location value] ) (def: .public (location file) @@ -556,28 +556,28 @@ (def: type_context Type_Context - [#.ex_counter 0 - #.var_counter 0 - #.var_bindings (list)]) + [.#ex_counter 0 + .#var_counter 0 + .#var_bindings (list)]) (def: .public (info version host) (-> Version Text Info) - [#.target host - #.version (%.nat version) - #.mode #.Build]) + [.#target host + .#version (%.nat version) + .#mode {.#Build}]) (def: .public (state info) (-> Info Lux) - [#.info info - #.source ..dummy_source - #.location location.dummy - #.current_module #.None - #.modules (list) - #.scopes (list) - #.type_context ..type_context - #.expected #.None - #.seed 0 - #.scope_type_vars (list) - #.extensions [] - #.eval (:as (-> Type Code (Meta Any)) []) - #.host []]) + [.#info info + .#source ..dummy_source + .#location location.dummy + .#current_module {.#None} + .#modules (list) + .#scopes (list) + .#type_context ..type_context + .#expected {.#None} + .#seed 0 + .#scope_type_vars (list) + .#extensions [] + .#eval (:as (-> Type Code (Meta Any)) []) + .#host []]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/macro.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/macro.lux index ed5983d14..428e8011a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/macro.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/macro.lux @@ -38,10 +38,10 @@ (do try.monad [output (expander macro inputs state)] (case output - {#try.Success output} - {#try.Success output} + {try.#Success output} + {try.#Success output} - {#try.Failure error} + {try.#Failure error} ((meta.failure (exception.error ..expansion_failed [name inputs error])) state))))) (def: .public (expand_one expander name macro inputs) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux index cd74d94f4..d11fa82cc 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux @@ -70,11 +70,11 @@ (All (_ anchor expression directive) (Operation anchor expression directive <phase>)) (function (_ [bundle state]) - {#try.Success [[bundle state] (value@ [<component> #..phase] state)]}))] + {try.#Success [[bundle state] (value@ [<component> ..#phase] state)]}))] - [analysis #..analysis analysis.Phase] - [synthesis #..synthesis synthesis.Phase] - [generation #..generation (generation.Phase anchor expression directive)] + [analysis ..#analysis analysis.Phase] + [synthesis ..#synthesis synthesis.Phase] + [generation ..#generation (generation.Phase anchor expression directive)] ) (template [<name> <component> <operation>] @@ -82,13 +82,13 @@ (All (_ anchor expression directive output) (-> (<operation> output) (Operation anchor expression directive output))) - (|>> (phase.sub [(value@ [<component> #..state]) - (with@ [<component> #..state])]) + (|>> (phase.sub [(value@ [<component> ..#state]) + (with@ [<component> ..#state])]) extension.lifted))] - [lifted_analysis #..analysis analysis.Operation] - [lifted_synthesis #..synthesis synthesis.Operation] - [lifted_generation #..generation (generation.Operation anchor expression directive)] + [lifted_analysis ..#analysis analysis.Operation] + [lifted_synthesis ..#synthesis synthesis.Operation] + [lifted_generation ..#generation (generation.Operation anchor expression directive)] ) (def: .public (set_current_module module) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux index 72a086650..ab139fc04 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux @@ -52,11 +52,11 @@ (type: .public (Host expression directive) (Interface (: (-> Context expression (Try Any)) - evaluate!) + evaluate) (: (-> directive (Try Any)) - execute!) + execute) (: (-> Context (Maybe Text) expression (Try [Text Any directive])) - define!) + define) (: (-> Context Binary directive) ingest) @@ -94,12 +94,12 @@ Module (..State anchor expression directive))) [#module module - #anchor #.None + #anchor {.#None} #host host - #buffer #.None + #buffer {.#None} #registry artifact.empty #counter 0 - #context #.None + #context {.#None} #log row.empty]) (def: .public empty_buffer @@ -115,30 +115,30 @@ (All (_ anchor expression directive output) <with_type>) (function (_ body) (function (_ [bundle state]) - (case (body [bundle (with@ <tag> {#.Some <with_value>} state)]) - {#try.Success [[bundle' state'] output]} - {#try.Success [[bundle' (with@ <tag> (value@ <tag> state) state')] + (case (body [bundle (with@ <tag> {.#Some <with_value>} state)]) + {try.#Success [[bundle' state'] output]} + {try.#Success [[bundle' (with@ <tag> (value@ <tag> state) state')] output]} - {#try.Failure error} - {#try.Failure error})))) + {try.#Failure error} + {try.#Failure error})))) (def: .public <get> (All (_ anchor expression directive) (Operation anchor expression directive <get_type>)) (function (_ (^@ stateE [bundle state])) (case (value@ <tag> state) - {#.Some output} - {#try.Success [stateE output]} + {.#Some output} + {try.#Success [stateE output]} - #.None + {.#None} (exception.except <exception> [])))) (def: .public (<set> value) (All (_ anchor expression directive) (-> <get_type> (Operation anchor expression directive Any))) (function (_ [bundle state]) - {#try.Success [[bundle (with@ <tag> {#.Some value} state)] + {try.#Success [[bundle (with@ <tag> {.#Some value} state)] []]}))] [#anchor @@ -160,13 +160,13 @@ (All (_ anchor expression directive) (Operation anchor expression directive artifact.Registry)) (function (_ (^@ stateE [bundle state])) - {#try.Success [stateE (value@ #registry state)]})) + {try.#Success [stateE (value@ #registry state)]})) (def: .public (set_registry value) (All (_ anchor expression directive) (-> artifact.Registry (Operation anchor expression directive Any))) (function (_ [bundle state]) - {#try.Success [[bundle (with@ #registry value state)] + {try.#Success [[bundle (with@ #registry value state)] []]})) (def: .public next @@ -196,33 +196,33 @@ (All (_ anchor expression directive) (-> Context expression (Operation anchor expression directive Any))) (function (_ (^@ state+ [bundle state])) - (case (\ (value@ #host state) evaluate! label code) - {#try.Success output} - {#try.Success [state+ output]} + (case (\ (value@ #host state) evaluate label code) + {try.#Success output} + {try.#Success [state+ output]} - {#try.Failure error} - (exception.except ..cannot_interpret error)))) + {try.#Failure error} + (exception.except ..cannot_interpret [error])))) (def: .public (execute! code) (All (_ anchor expression directive) (-> directive (Operation anchor expression directive Any))) (function (_ (^@ state+ [bundle state])) - (case (\ (value@ #host state) execute! code) - {#try.Success output} - {#try.Success [state+ output]} + (case (\ (value@ #host state) execute code) + {try.#Success output} + {try.#Success [state+ output]} - {#try.Failure error} + {try.#Failure error} (exception.except ..cannot_interpret error)))) (def: .public (define! context custom code) (All (_ anchor expression directive) (-> Context (Maybe Text) expression (Operation anchor expression directive [Text Any directive]))) (function (_ (^@ stateE [bundle state])) - (case (\ (value@ #host state) define! context custom code) - {#try.Success output} - {#try.Success [stateE output]} + (case (\ (value@ #host state) define context custom code) + {try.#Success output} + {try.#Success [stateE output]} - {#try.Failure error} + {try.#Failure error} (exception.except ..cannot_interpret error)))) (def: .public (save! artifact_id custom code) @@ -231,13 +231,13 @@ (do [! phase.monad] [?buffer (extension.read (value@ #buffer))] (case ?buffer - {#.Some buffer} + {.#Some buffer} ... TODO: Optimize by no longer checking for overwrites... (if (row.any? (|>> product.left (n.= artifact_id)) buffer) (phase.except ..cannot_overwrite_output [artifact_id]) - (extension.update (with@ #buffer {#.Some (row.suffix [artifact_id custom code] buffer)}))) + (extension.update (with@ #buffer {.#Some (row.suffix [artifact_id custom code] buffer)}))) - #.None + {.#None} (phase.except ..no_buffer_for_saving_code [artifact_id])))) (template [<name> <artifact>] @@ -246,7 +246,7 @@ (-> Text (Operation anchor expression directive artifact.ID))) (function (_ (^@ stateE [bundle state])) (let [[id registry'] (<artifact> name (value@ #registry state))] - {#try.Success [[bundle (with@ #registry registry' state)] + {try.#Success [[bundle (with@ #registry registry' state)] id]})))] [learn artifact.definition] @@ -272,16 +272,16 @@ (do try.monad [module_id (archive.id _module archive) registry (if (text\= (value@ #module state) _module) - {#try.Success (value@ #registry state)} + {try.#Success (value@ #registry state)} (do try.monad [[descriptor document] (archive.find _module archive)] - {#try.Success (value@ #descriptor.registry descriptor)}))] + {try.#Success (value@ descriptor.#registry descriptor)}))] (case (artifact.remember _name registry) - #.None + {.#None} (exception.except ..unknown_definition [name (artifact.definitions registry)]) - {#.Some id} - {#try.Success [stateE [module_id id]]}))))) + {.#Some id} + {try.#Success [stateE [module_id id]]}))))) (exception: .public no_context) @@ -298,10 +298,10 @@ (-> Archive (Operation anchor expression directive Context))) (function (_ (^@ stateE [bundle state])) (case (value@ #context state) - #.None + {.#None} (exception.except ..no_context []) - {#.Some id} + {.#Some id} (do try.monad [module_id (archive.id (value@ #module state) archive)] (in [stateE [module_id id]]))))) @@ -313,7 +313,7 @@ (Operation anchor expression directive a))) (function (_ [bundle state]) (do try.monad - [[[bundle' state'] output] (body [bundle (with@ #context {#.Some id} state)])] + [[[bundle' state'] output] (body [bundle (with@ #context {.#Some id} state)])] (in [[bundle' (with@ #context (value@ #context state) state')] output])))) @@ -326,7 +326,7 @@ (do try.monad [[[bundle' state'] output] (body [bundle (|> state (with@ #registry registry') - (with@ #context {#.Some id}))]) + (with@ #context {.#Some id}))]) module_id (archive.id (value@ #module state) archive)] (in [[bundle' (with@ #context (value@ #context state) state')] [[module_id id] @@ -336,6 +336,6 @@ (All (_ anchor expression directive a) (-> Text (Operation anchor expression directive Any))) (function (_ [bundle state]) - {#try.Success [[bundle + {try.#Success [[bundle (revised@ #log (row.suffix message) state)] []]})) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux index 5bebbcde9..c3b6434d2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux @@ -49,35 +49,32 @@ (^template [<tag> <analyser>] [{<tag> value} (<analyser> value)]) - ([#.Bit /primitive.bit] - [#.Nat /primitive.nat] - [#.Int /primitive.int] - [#.Rev /primitive.rev] - [#.Frac /primitive.frac] - [#.Text /primitive.text]) - - (^ {#.Variant (list& [_ {#.Tag tag}] + ([.#Bit /primitive.bit] + [.#Nat /primitive.nat] + [.#Int /primitive.int] + [.#Rev /primitive.rev] + [.#Frac /primitive.frac] + [.#Text /primitive.text]) + + (^ {.#Variant (list& [_ {.#Identifier tag}] values)}) (case values - {#.Item value #.End} + {.#Item value {.#End}} (/structure.tagged_sum compile tag archive value) _ (/structure.tagged_sum compile tag archive (` [(~+ values)]))) - (^ {#.Variant (list& [_ {#.Nat lefts}] [_ {#.Bit right?}] + (^ {.#Variant (list& [_ {.#Nat lefts}] [_ {.#Bit right?}] values)}) (case values - {#.Item value #.End} + {.#Item value .#End} (/structure.sum compile lefts right? archive value) _ (/structure.sum compile lefts right? archive (` [(~+ values)]))) - {#.Tag tag} - (/structure.tagged_sum compile tag archive (' [])) - - (^ {#.Tuple elems}) + (^ {.#Tuple elems}) (/structure.record archive compile elems) _ @@ -86,32 +83,32 @@ (def: (compile|others expander archive compile code') (-> Expander Archive Phase (-> (Code' (Ann Location)) (Operation Analysis))) (case code' - {#.Identifier reference} + {.#Identifier reference} (/reference.reference reference) - (^ {#.Form (list [_ {#.Variant branches}] input)}) + (^ {.#Form (list [_ {.#Variant branches}] input)}) (if (n.even? (list.size branches)) (/case.case compile (list.pairs branches) archive input) (//.except ..unrecognized_syntax [location.dummy code'])) - (^ {#.Form (list& [_ {#.Text extension_name}] extension_args)}) + (^ {.#Form (list& [_ {.#Text extension_name}] extension_args)}) (//extension.apply archive compile [extension_name extension_args]) - (^ {#.Form (list [_ {#.Tuple (list [_ {#.Identifier ["" function_name]}] - [_ {#.Identifier ["" arg_name]}])}] + (^ {.#Form (list [_ {.#Tuple (list [_ {.#Identifier ["" function_name]}] + [_ {.#Identifier ["" arg_name]}])}] body)}) (/function.function compile function_name arg_name archive body) - (^ {#.Form (list& functionC argsC+)}) + (^ {.#Form (list& functionC argsC+)}) (do [! //.monad] [[functionT functionA] (/type.with_inference (compile archive functionC))] (case functionA - {#/.Reference {#reference.Constant def_name}} + {/.#Reference {reference.#Constant def_name}} (do ! [?macro (//extension.lifted (meta.macro def_name))] (case ?macro - {#.Some macro} + {.#Some macro} (do ! [expansion (//extension.lifted (/macro.expand_one expander def_name macro argsC+))] (compile archive expansion)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux index 69307c2ac..5d6489898 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux @@ -69,11 +69,11 @@ (def: (re_quantify envs baseT) (-> (List (List Type)) Type Type) (.case envs - #.End + {.#End} baseT - {#.Item head tail} - (re_quantify tail {#.UnivQ head baseT}))) + {.#Item head tail} + (re_quantify tail {.#UnivQ head baseT}))) ... Type-checking on the input value is done during the analysis of a ... "case" expression, to ensure that the patterns being used make @@ -88,53 +88,53 @@ (list)) caseT caseT] (.case caseT - {#.Var id} + {.#Var id} (do ///.monad [?caseT' (//type.with_env (check.peek id))] (.case ?caseT' - {#.Some caseT'} + {.#Some caseT'} (recur envs caseT') _ (/.except ..cannot_simplify_for_pattern_matching caseT))) - {#.Named name unnamedT} + {.#Named name unnamedT} (recur envs unnamedT) - {#.UnivQ env unquantifiedT} - (recur {#.Item env envs} unquantifiedT) + {.#UnivQ env unquantifiedT} + (recur {.#Item env envs} unquantifiedT) - {#.ExQ _} + {.#ExQ _} (do ///.monad [[var_id varT] (//type.with_env check.var)] (recur envs (maybe.trusted (type.applied (list varT) caseT)))) - {#.Apply inputT funcT} + {.#Apply inputT funcT} (.case funcT - {#.Var funcT_id} + {.#Var funcT_id} (do ///.monad [funcT' (//type.with_env (do check.monad [?funct' (check.peek funcT_id)] (.case ?funct' - {#.Some funct'} + {.#Some funct'} (in funct') _ (check.except ..cannot_simplify_for_pattern_matching caseT))))] - (recur envs {#.Apply inputT funcT'})) + (recur envs {.#Apply inputT funcT'})) _ (.case (type.applied (list inputT) funcT) - {#.Some outputT} + {.#Some outputT} (recur envs outputT) - #.None + {.#None} (/.except ..cannot_simplify_for_pattern_matching caseT))) - {#.Product _} + {.#Product _} (|> caseT type.flat_tuple (list\each (re_quantify envs)) @@ -172,75 +172,75 @@ (def: (analyse_pattern num_tags inputT pattern next) (All (_ a) (-> (Maybe Nat) Type Code (Operation a) (Operation [Pattern a]))) (.case pattern - [location {#.Identifier ["" name]}] + [location {.#Identifier ["" name]}] (/.with_location location (do ///.monad [outputA (//scope.with_local [name inputT] next) idx //scope.next_local] - (in [{#/.Bind idx} outputA]))) + (in [{/.#Bind idx} outputA]))) (^template [<type> <input> <output>] [[location <input>] - (analyse_primitive <type> inputT location {#/.Simple <output>} next)]) - ([Bit {#.Bit pattern_value} {#/.Bit pattern_value}] - [Nat {#.Nat pattern_value} {#/.Nat pattern_value}] - [Int {#.Int pattern_value} {#/.Int pattern_value}] - [Rev {#.Rev pattern_value} {#/.Rev pattern_value}] - [Frac {#.Frac pattern_value} {#/.Frac pattern_value}] - [Text {#.Text pattern_value} {#/.Text pattern_value}] - [Any {#.Tuple #.End} #/.Unit]) + (analyse_primitive <type> inputT location {/.#Simple <output>} next)]) + ([Bit {.#Bit pattern_value} {/.#Bit pattern_value}] + [Nat {.#Nat pattern_value} {/.#Nat pattern_value}] + [Int {.#Int pattern_value} {/.#Int pattern_value}] + [Rev {.#Rev pattern_value} {/.#Rev pattern_value}] + [Frac {.#Frac pattern_value} {/.#Frac pattern_value}] + [Text {.#Text pattern_value} {/.#Text pattern_value}] + [Any {.#Tuple {.#End}} {/.#Unit}]) - (^ [location {#.Tuple (list singleton)}]) - (analyse_pattern #.None inputT singleton next) + (^ [location {.#Tuple (list singleton)}]) + (analyse_pattern {.#None} inputT singleton next) - [location {#.Tuple sub_patterns}] + [location {.#Tuple sub_patterns}] (do [! ///.monad] [record (//structure.normal sub_patterns) record_size,members,recordT (: (Operation (Maybe [Nat (List Code) Type])) (.case record - {#.Some record} + {.#Some record} (//structure.order record) - #.None - (in #.None)))] + {.#None} + (in {.#None})))] (.case record_size,members,recordT - {#.Some [record_size members recordT]} + {.#Some [record_size members recordT]} (do ! [_ (.case inputT - {#.Var _id} + {.#Var _id} (//type.with_env (check.check inputT recordT)) _ (in []))] - (analyse_pattern {#.Some record_size} inputT [location {#.Tuple members}] next)) + (analyse_pattern {.#Some record_size} inputT [location {.#Tuple members}] next)) - #.None + {.#None} (/.with_location location (do [! ///.monad] [inputT' (simplify_case inputT)] (.case inputT' - {#.Product _} + {.#Product _} (let [matches (loop [types (type.flat_tuple inputT') patterns sub_patterns output (: (List [Type Code]) - #.End)] + {.#End})] (.case [types patterns] - [#.End #.End] + [{.#End} {.#End}] output - [{#.Item headT #.End} {#.Item headP #.End}] - {#.Item [headT headP] output} + [{.#Item headT {.#End}} {.#Item headP {.#End}}] + {.#Item [headT headP] output} - [remainingT {#.Item headP #.End}] - {#.Item [(type.tuple remainingT) headP] output} + [remainingT {.#Item headP {.#End}}] + {.#Item [(type.tuple remainingT) headP] output} - [{#.Item headT #.End} remainingP] - {#.Item [headT (code.tuple remainingP)] output} + [{.#Item headT {.#End}} remainingP] + {.#Item [headT (code.tuple remainingP)] output} - [{#.Item headT tailT} {#.Item headP tailP}] - (recur tailT tailP {#.Item [headT headP] output}) + [{.#Item headT tailT} {.#Item headP tailP}] + (recur tailT tailP {.#Item [headT headP] output}) _ (undefined)))] @@ -252,7 +252,7 @@ (do ! [[memberP [memberP+ thenA]] ((:as (All (_ a) (-> (Maybe Nat) Type Code (Operation a) (Operation [Pattern a]))) analyse_pattern) - #.None memberT memberC then)] + {.#None} memberT memberC then)] (in [(list& memberP memberP+) thenA])))) (do ! [nextA next] @@ -264,38 +264,38 @@ _ (/.except ..cannot_match_with_pattern [inputT' pattern])))))) - [location {#.Tag tag}] + [location {.#Tag tag}] (/.with_location location - (analyse_pattern #.None inputT (` {(~ pattern)}) next)) + (analyse_pattern {.#None} inputT (` {(~ pattern)}) next)) - (^ [location {#.Variant (list& [_ {#.Nat lefts}] [_ {#.Bit right?}] values)}]) + (^ [location {.#Variant (list& [_ {.#Nat lefts}] [_ {.#Bit right?}] values)}]) (/.with_location location (do ///.monad [inputT' (simplify_case inputT)] (.case inputT' - {#.Sum _} + {.#Sum _} (let [flat_sum (type.flat_variant inputT') size_sum (list.size flat_sum) num_cases (maybe.else size_sum num_tags) idx (/.tag lefts right?)] (.case (list.item idx flat_sum) - (^multi {#.Some caseT} + (^multi {.#Some caseT} (n.< num_cases idx)) (do ///.monad [[testP nextA] (if (and (n.> num_cases size_sum) (n.= (-- num_cases) idx)) - (analyse_pattern #.None + (analyse_pattern {.#None} (type.variant (list.after (-- num_cases) flat_sum)) (` [(~+ values)]) next) - (analyse_pattern #.None caseT (` [(~+ values)]) next))] + (analyse_pattern {.#None} caseT (` [(~+ values)]) next))] (in [(/.pattern/variant [lefts right? testP]) nextA])) _ (/.except ..sum_has_no_case [idx inputT]))) - {#.UnivQ _} + {.#UnivQ _} (do ///.monad [[ex_id exT] (//type.with_env check.existential)] @@ -307,7 +307,7 @@ _ (/.except ..cannot_match_with_pattern [inputT' pattern])))) - (^ [location {#.Variant (list& [_ {#.Tag tag}] values)}]) + (^ [location {.#Variant (list& [_ {.#Tag tag}] values)}]) (/.with_location location (do ///.monad [tag (///extension.lifted (meta.normal tag)) @@ -315,7 +315,7 @@ _ (//type.with_env (check.check inputT variantT)) .let [[lefts right?] (/.choice (list.size group) idx)]] - (analyse_pattern {#.Some (list.size group)} inputT (` {(~ (code.nat lefts)) (~ (code.bit right?)) (~+ values)}) next))) + (analyse_pattern {.#Some (list.size group)} inputT (` {(~ (code.nat lefts)) (~ (code.bit right?)) (~+ values)}) next))) _ (/.except ..not_a_pattern pattern) @@ -324,25 +324,25 @@ (def: .public (case analyse branches archive inputC) (-> Phase (List [Code Code]) Phase) (.case branches - {#.Item [patternH bodyH] branchesT} + {.#Item [patternH bodyH] branchesT} (do [! ///.monad] [[inputT inputA] (//type.with_inference (analyse archive inputC)) - outputH (analyse_pattern #.None inputT patternH (analyse archive bodyH)) + outputH (analyse_pattern {.#None} inputT patternH (analyse archive bodyH)) outputT (monad.each ! (function (_ [patternT bodyT]) - (analyse_pattern #.None inputT patternT (analyse archive bodyT))) + (analyse_pattern {.#None} inputT patternT (analyse archive bodyT))) branchesT) outputHC (|> outputH product.left /coverage.determine) outputTC (monad.each ! (|>> product.left /coverage.determine) outputT) _ (.case (monad.mix try.monad /coverage.merged outputHC outputTC) - {#try.Success coverage} + {try.#Success coverage} (///.assertion non_exhaustive_pattern_matching [inputC branches coverage] (/coverage.exhaustive? coverage)) - {#try.Failure error} + {try.#Failure error} (/.failure error))] - (in {#/.Case inputA [outputH outputT]})) + (in {/.#Case inputA [outputH outputT]})) - #.End + {.#End} (/.except ..cannot_have_empty_branches ""))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux index 59ecb1717..813324061 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux @@ -50,12 +50,12 @@ (type: .public Coverage (Rec Coverage (.Variant - #Partial + {#Partial} {#Bit Bit} {#Variant (Maybe Nat) (Dictionary Nat Coverage)} {#Seq Coverage Coverage} {#Alt Coverage Coverage} - #Exhaustive))) + {#Exhaustive}))) (def: .public (exhaustive? coverage) (-> Coverage Bit) @@ -69,7 +69,7 @@ (def: .public (%coverage value) (Format Coverage) (case value - #Partial + {#Partial} "#Partial" {#Bit value'} @@ -93,41 +93,41 @@ {#Alt left right} (format "{#Alt " (%coverage left) " " (%coverage right) "}") - #Exhaustive + {#Exhaustive} "#Exhaustive")) (def: .public (determine pattern) (-> Pattern (Operation Coverage)) (case pattern - (^or {#/.Simple #/.Unit} - {#/.Bind _}) - (////\in #Exhaustive) + (^or {/.#Simple {/.#Unit}} + {/.#Bind _}) + (////\in {#Exhaustive}) ... Primitive patterns always have partial coverage because there ... are too many possibilities as far as values go. (^template [<tag>] - [{#/.Simple {<tag> _}} - (////\in #Partial)]) - ([#/.Nat] - [#/.Int] - [#/.Rev] - [#/.Frac] - [#/.Text]) + [{/.#Simple {<tag> _}} + (////\in {#Partial})]) + ([/.#Nat] + [/.#Int] + [/.#Rev] + [/.#Frac] + [/.#Text]) ... Bits are the exception, since there is only "#1" and ... "#0", which means it is possible for bit ... pattern-matching to become exhaustive if complementary parts meet. - {#/.Simple {#/.Bit value}} + {/.#Simple {/.#Bit value}} (////\in {#Bit value}) ... Tuple patterns can be exhaustive if there is exhaustiveness for all of ... their sub-patterns. - {#/.Complex {#/.Tuple membersP+}} + {/.#Complex {/.#Tuple membersP+}} (case (list.reversed membersP+) - (^or #.End {#.Item _ #.End}) + (^or {.#End} {.#Item _ {.#End}}) (/.except ..invalid_tuple_pattern []) - {#.Item lastP prevsP+} + {.#Item lastP prevsP+} (do ////.monad [lastC (determine lastP)] (monad.mix ////.monad @@ -135,7 +135,7 @@ (do ////.monad [leftC (determine leftP)] (case rightC - #Exhaustive + {#Exhaustive} (in leftC) _ @@ -144,15 +144,15 @@ ... Variant patterns can be shown to be exhaustive if all the possible ... cases are handled exhaustively. - {#/.Complex {#/.Variant [lefts right? value]}} + {/.#Complex {/.#Variant [lefts right? value]}} (do ////.monad [value_coverage (determine value) .let [idx (if right? (++ lefts) lefts)]] (in {#Variant (if right? - {#.Some idx} - #.None) + {.#Some idx} + {.#None}) (|> (dictionary.empty n.hash) (dictionary.has idx value_coverage))})))) @@ -185,7 +185,7 @@ (implementation: equivalence (Equivalence Coverage) (def: (= reference sample) (case [reference sample] - [#Exhaustive #Exhaustive] + [{#Exhaustive} {#Exhaustive}] #1 [{#Bit sideR} {#Bit sideS}] @@ -226,13 +226,13 @@ (def: .public (merged addition so_far) (-> Coverage Coverage (Try Coverage)) (case [addition so_far] - [#Partial #Partial] - (try\in #Partial) + [{#Partial} {#Partial}] + (try\in {#Partial}) ... 2 bit coverages are exhaustive if they complement one another. (^multi [{#Bit sideA} {#Bit sideSF}] (xor sideA sideSF)) - (try\in #Exhaustive) + (try\in {#Exhaustive}) [{#Variant allA casesA} {#Variant allSF casesSF}] (let [addition_cases (cases allSF) @@ -250,12 +250,12 @@ [casesM (monad.mix ! (function (_ [tagA coverageA] casesSF') (case (dictionary.value tagA casesSF') - {#.Some coverageSF} + {.#Some coverageSF} (do ! [coverageM (merged coverageA coverageSF)] (in (dictionary.has tagA coverageM casesSF'))) - #.None + {.#None} (in (dictionary.has tagA coverageA casesSF')))) casesSF (dictionary.entries casesA))] (in (if (and (or (known_cases? addition_cases) @@ -263,9 +263,9 @@ (n.= (++ (n.max addition_cases so_far_cases)) (dictionary.size casesM)) (list.every? exhaustive? (dictionary.values casesM))) - #Exhaustive + {#Exhaustive} {#Variant (case allSF - {#.Some _} + {.#Some _} allSF _ @@ -300,12 +300,12 @@ (exception.except ..redundant_pattern [so_far addition])) ... The addition cannot possibly improve the coverage. - [_ #Exhaustive] + [_ {#Exhaustive}] (exception.except ..redundant_pattern [so_far addition]) ... The addition completes the coverage. - [#Exhaustive _] - (try\in #Exhaustive) + [{#Exhaustive} _] + (try\in {#Exhaustive}) ... The left part will always match, so the addition is redundant. (^multi [{#Seq left right} single] @@ -334,41 +334,41 @@ (function (_ coverageA possibilitiesSF) (loop [altsSF possibilitiesSF] (case altsSF - #.End - (in [#.None (list coverageA)]) + {.#End} + (in [{.#None} (list coverageA)]) - {#.Item altSF altsSF'} + {.#Item altSF altsSF'} (case (merged coverageA altSF) - {#try.Success altMSF} + {try.#Success altMSF} (case altMSF {#Alt _} (do ! [[success altsSF+] (recur altsSF')] - (in [success {#.Item altSF altsSF+}])) + (in [success {.#Item altSF altsSF+}])) _ - (in [{#.Some altMSF} altsSF'])) + (in [{.#Some altMSF} altsSF'])) - {#try.Failure error} - {#try.Failure error}) + {try.#Failure error} + {try.#Failure error}) ))))] [successA possibilitiesSF] (fuse_once addition (flat_alt so_far))] (loop [successA successA possibilitiesSF possibilitiesSF] (case successA - {#.Some coverageA'} + {.#Some coverageA'} (do ! [[successA' possibilitiesSF'] (fuse_once coverageA' possibilitiesSF)] (recur successA' possibilitiesSF')) - #.None + {.#None} (case (list.reversed possibilitiesSF) - {#.Item last prevs} + {.#Item last prevs} (in (list\mix (function (_ left right) {#Alt left right}) last prevs)) - #.End + {.#End} (undefined))))) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux index 5b1ba0a7b..ab080a2b8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux @@ -54,15 +54,15 @@ (loop [expectedT functionT] (/.with_stack ..cannot_analyse [expectedT function_name arg_name body] (case expectedT - {#.Named name unnamedT} + {.#Named name unnamedT} (recur unnamedT) - {#.Apply argT funT} + {.#Apply argT funT} (case (type.applied (list argT) funT) - {#.Some value} + {.#Some value} (recur value) - #.None + {.#None} (/.failure (ex.error cannot_analyse [expectedT function_name arg_name body]))) (^template [<tag> <instancer>] @@ -70,15 +70,15 @@ (do ! [[_ instanceT] (//type.with_env <instancer>)] (recur (maybe.trusted (type.applied (list instanceT) expectedT))))]) - ([#.UnivQ check.existential] - [#.ExQ check.var]) + ([.#UnivQ check.existential] + [.#ExQ check.var]) - {#.Var id} + {.#Var id} (do ! [?expectedT' (//type.with_env (check.peek id))] (case ?expectedT' - {#.Some expectedT'} + {.#Some expectedT'} (recur expectedT') ... Inference @@ -86,15 +86,15 @@ (do ! [[input_id inputT] (//type.with_env check.var) [output_id outputT] (//type.with_env check.var) - .let [functionT {#.Function inputT outputT}] + .let [functionT {.#Function inputT outputT}] functionA (recur functionT) _ (//type.with_env (check.check expectedT functionT))] (in functionA)))) - {#.Function inputT outputT} + {.#Function inputT outputT} (<| (\ ! each (.function (_ [scope bodyA]) - {#/.Function (list\each (|>> /.variable) + {/.#Function (list\each (|>> /.variable) (//scope.environment scope)) bodyA})) /.with_scope diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux index 68fafe17f..e377fedb0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux @@ -66,20 +66,20 @@ (def: (replace parameter_idx replacement type) (-> Nat Type Type Type) (case type - {#.Primitive name params} - {#.Primitive name (list\each (replace parameter_idx replacement) params)} + {.#Primitive name params} + {.#Primitive name (list\each (replace parameter_idx replacement) params)} (^template [<tag>] [{<tag> left right} {<tag> (replace parameter_idx replacement left) (replace parameter_idx replacement right)}]) - ([#.Sum] - [#.Product] - [#.Function] - [#.Apply]) + ([.#Sum] + [.#Product] + [.#Function] + [.#Apply]) - {#.Parameter idx} + {.#Parameter idx} (if (n.= parameter_idx idx) replacement type) @@ -88,8 +88,8 @@ [{<tag> env quantified} {<tag> (list\each (replace parameter_idx replacement) env) (replace (n.+ 2 parameter_idx) replacement quantified)}]) - ([#.UnivQ] - [#.ExQ]) + ([.#UnivQ] + [.#ExQ]) _ type)) @@ -97,7 +97,7 @@ (def: (named_type location id) (-> Location Nat Type) (let [name (format "{New Type " (%.location location) " " (%.nat id) "}")] - {#.Primitive name (list)})) + {.#Primitive name (list)})) (def: new_named_type (Operation Type) @@ -116,22 +116,22 @@ (def: .public (general archive analyse inferT args) (-> Archive Phase Type (List Code) (Operation [Type (List Analysis)])) (case args - #.End + {.#End} (do ///.monad [_ (//type.infer inferT)] (in [inferT (list)])) - {#.Item argC args'} + {.#Item argC args'} (case inferT - {#.Named name unnamedT} + {.#Named name unnamedT} (general archive analyse unnamedT args) - {#.UnivQ _} + {.#UnivQ _} (do ///.monad [[var_id varT] (//type.with_env check.var)] (general archive analyse (maybe.trusted (type.applied (list varT) inferT)) args)) - {#.ExQ _} + {.#ExQ _} (do [! ///.monad] [[var_id varT] (//type.with_env check.var) output (general archive analyse @@ -147,12 +147,12 @@ (check.check varT newT))))] (in output)) - {#.Apply inputT transT} + {.#Apply inputT transT} (case (type.applied (list inputT) transT) - {#.Some outputT} + {.#Some outputT} (general archive analyse outputT args) - #.None + {.#None} (/.except ..invalid_type_application inferT)) ... Arguments are inferred back-to-front because, by convention, @@ -162,7 +162,7 @@ ... By inferring back-to-front, a lot of type-annotations can be ... avoided in Lux code, since the inference algorithm can piece ... things together more easily. - {#.Function inputT outputT} + {.#Function inputT outputT} (do ///.monad [[outputT' args'A] (general archive analyse outputT args') argA (<| (/.with_stack ..cannot_infer_argument [inputT argC]) @@ -170,12 +170,12 @@ (analyse archive argC))] (in [outputT' (list& argA args'A)])) - {#.Var infer_id} + {.#Var infer_id} (do ///.monad [?inferT' (//type.with_env (check.peek infer_id))] (case ?inferT' - {#.Some inferT'} + {.#Some inferT'} (general archive analyse inferT' args) _ @@ -189,15 +189,15 @@ (-> Nat Type Type Type) (function (recur base) (case base - {#.Primitive name parameters} - {#.Primitive name (list\each recur parameters)} + {.#Primitive name parameters} + {.#Primitive name (list\each recur parameters)} (^template [<tag>] [{<tag> left right} {<tag> (recur left) (recur right)}]) - ([#.Sum] [#.Product] [#.Function] [#.Apply]) + ([.#Sum] [.#Product] [.#Function] [.#Apply]) - {#.Parameter index} + {.#Parameter index} (if (n.= target index) sub base) @@ -205,7 +205,7 @@ (^template [<tag>] [{<tag> environment quantified} {<tag> (list\each recur environment) quantified}]) - ([#.UnivQ] [#.ExQ]) + ([.#UnivQ] [.#ExQ]) _ base))) @@ -214,7 +214,7 @@ (def: (record' record_size target originalT inferT) (-> Nat Nat Type Type (Operation Type)) (case inferT - {#.Named name unnamedT} + {.#Named name unnamedT} (record' record_size target originalT unnamedT) (^template [<tag>] @@ -222,18 +222,18 @@ (do ///.monad [bodyT+ (record' record_size (n.+ 2 target) originalT bodyT)] (in {<tag> env bodyT+}))]) - ([#.UnivQ] - [#.ExQ]) + ([.#UnivQ] + [.#ExQ]) - {#.Apply inputT funcT} + {.#Apply inputT funcT} (case (type.applied (list inputT) funcT) - {#.Some outputT} + {.#Some outputT} (record' record_size target originalT outputT) - #.None + {.#None} (/.except ..invalid_type_application inferT)) - {#.Product _} + {.#Product _} (let [[lefts right] (list.split_at (-- record_size) (type.flat_tuple inferT))] (///\in (|> inferT (type.function (list\composite lefts (list (type.tuple right)))) @@ -252,7 +252,7 @@ (loop [depth 0 currentT inferT] (case currentT - {#.Named name unnamedT} + {.#Named name unnamedT} (do ///.monad [unnamedT+ (recur depth unnamedT)] (in unnamedT+)) @@ -262,10 +262,10 @@ (do ///.monad [bodyT+ (recur (++ depth) bodyT)] (in {<tag> env bodyT+}))]) - ([#.UnivQ] - [#.ExQ]) + ([.#UnivQ] + [.#ExQ]) - {#.Sum _} + {.#Sum _} (let [cases (type.flat_variant currentT) actual_size (list.size cases) boundary (-- expected_size)] @@ -273,14 +273,14 @@ (and (n.> expected_size actual_size) (n.< boundary tag))) (case (list.item tag cases) - {#.Some caseT} + {.#Some caseT} (///\in (if (n.= 0 depth) (type.function (list caseT) currentT) (let [replace' (replace (|> depth -- (n.* 2)) inferT)] (type.function (list (replace' caseT)) (replace' currentT))))) - #.None + {.#None} (/.except ..variant_tag_out_of_bounds [expected_size tag inferT])) (n.< expected_size actual_size) @@ -297,12 +297,12 @@ ... else (/.except ..variant_tag_out_of_bounds [expected_size tag inferT]))) - {#.Apply inputT funcT} + {.#Apply inputT funcT} (case (type.applied (list inputT) funcT) - {#.Some outputT} + {.#Some outputT} (variant tag expected_size outputT) - #.None + {.#None} (/.except ..invalid_type_application inferT)) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux index 84124d32f..dde8eb173 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux @@ -44,19 +44,19 @@ (exception.report ["Definition" (%.name name)] ["Original" (case already_existing - {#.Alias alias} + {.#Alias alias} (format "alias " (%.name alias)) - {#.Definition definition} + {.#Definition definition} (format "definition " (%.name name)) - {#.Type _} + {.#Type _} (format "type " (%.name name)) - {#.Label _} + {.#Label _} (format "tag " (%.name name)) - {#.Slot _} + {.#Slot _} (format "slot " (%.name name)))])) (exception: .public (can_only_change_state_of_active_module [module Text @@ -64,17 +64,17 @@ (exception.report ["Module" module] ["Desired state" (case state - #.Active "Active" - #.Compiled "Compiled" - #.Cached "Cached")])) + {.#Active} "Active" + {.#Compiled} "Compiled" + {.#Cached} "Cached")])) (def: .public (empty hash) (-> Nat Module) - [#.module_hash hash - #.module_aliases (list) - #.definitions (list) - #.imports (list) - #.module_state #.Active]) + [.#module_hash hash + .#module_aliases (list) + .#definitions (list) + .#imports (list) + .#module_state {.#Active}]) (def: .public (import module) (-> Text (Operation Any)) @@ -82,12 +82,12 @@ (do ///.monad [self_name meta.current_module_name] (function (_ state) - {#try.Success [(revised@ #.modules - (plist.revised self_name (revised@ #.imports (function (_ current) + {try.#Success [(revised@ .#modules + (plist.revised self_name (revised@ .#imports (function (_ current) (if (list.any? (text\= module) current) current - {#.Item module current})))) + {.#Item module current})))) state) []]})))) @@ -97,9 +97,9 @@ (do ///.monad [self_name meta.current_module_name] (function (_ state) - {#try.Success [(revised@ #.modules - (plist.revised self_name (revised@ #.module_aliases (: (-> (List [Text Text]) (List [Text Text])) - (|>> {#.Item [alias module]})))) + {try.#Success [(revised@ .#modules + (plist.revised self_name (revised@ .#module_aliases (: (-> (List [Text Text]) (List [Text Text])) + (|>> {.#Item [alias module]})))) state) []]})))) @@ -108,10 +108,10 @@ (///extension.lifted (function (_ state) (|> state - (value@ #.modules) + (value@ .#modules) (plist.value module) - (case> {#.Some _} #1 #.None #0) - [state] {#try.Success})))) + (case> {.#Some _} #1 {.#None} #0) + [state] {try.#Success})))) (def: .public (define name definition) (-> Text Global (Operation Any)) @@ -120,25 +120,25 @@ [self_name meta.current_module_name self meta.current_module] (function (_ state) - (case (plist.value name (value@ #.definitions self)) - #.None - {#try.Success [(revised@ #.modules + (case (plist.value name (value@ .#definitions self)) + {.#None} + {try.#Success [(revised@ .#modules (plist.has self_name - (revised@ #.definitions + (revised@ .#definitions (: (-> (List [Text Global]) (List [Text Global])) - (|>> {#.Item [name definition]})) + (|>> {.#Item [name definition]})) self)) state) []]} - {#.Some already_existing} + {.#Some already_existing} ((/.except' ..cannot_define_more_than_once [[self_name name] already_existing]) state)))))) (def: .public (create hash name) (-> Nat Text (Operation Any)) (///extension.lifted (function (_ state) - {#try.Success [(revised@ #.modules + {try.#Success [(revised@ .#modules (plist.has name (..empty hash)) state) []]}))) @@ -157,50 +157,50 @@ (-> Text (Operation Any)) (///extension.lifted (function (_ state) - (case (|> state (value@ #.modules) (plist.value module_name)) - {#.Some module} - (let [active? (case (value@ #.module_state module) - #.Active #1 - _ #0)] + (case (|> state (value@ .#modules) (plist.value module_name)) + {.#Some module} + (let [active? (case (value@ .#module_state module) + {.#Active} #1 + _ #0)] (if active? - {#try.Success [(revised@ #.modules - (plist.has module_name (with@ #.module_state <tag> module)) + {try.#Success [(revised@ .#modules + (plist.has module_name (with@ .#module_state {<tag>} module)) state) []]} - ((/.except' can_only_change_state_of_active_module [module_name <tag>]) + ((/.except' can_only_change_state_of_active_module [module_name {<tag>}]) state))) - #.None + {.#None} ((/.except' unknown_module module_name) state))))) (def: .public (<asker> module_name) (-> Text (Operation Bit)) (///extension.lifted (function (_ state) - (case (|> state (value@ #.modules) (plist.value module_name)) - {#.Some module} - {#try.Success [state - (case (value@ #.module_state module) + (case (|> state (value@ .#modules) (plist.value module_name)) + {.#Some module} + {try.#Success [state + (case (value@ .#module_state module) <tag> #1 _ #0)]} - #.None + {.#None} ((/.except' unknown_module module_name) state)))))] - [set_active active? #.Active] - [set_compiled compiled? #.Compiled] - [set_cached cached? #.Cached] + [set_active active? .#Active] + [set_compiled compiled? .#Compiled] + [set_cached cached? .#Cached] ) (def: (hash module_name) (-> Text (Operation Nat)) (///extension.lifted (function (_ state) - (case (|> state (value@ #.modules) (plist.value module_name)) - {#.Some module} - {#try.Success [state (value@ #.module_hash module)]} + (case (|> state (value@ .#modules) (plist.value module_name)) + {.#Some module} + {try.#Success [state (value@ .#module_hash module)]} - #.None + {.#None} ((/.except' unknown_module module_name) state))))) (def: .public (declare_tags record? tags exported? type) @@ -208,7 +208,7 @@ (do [! ///.monad] [self_name (///extension.lifted meta.current_module_name) [type_module type_name] (case type - {#.Named type_name _} + {.#Named type_name _} (in type_name) _ @@ -216,8 +216,8 @@ _ (///.assertion cannot_declare_tags_for_foreign_type [tags type] (text\= self_name type_module))] (monad.each ! (function (_ [index short]) - (..define (format "#" short) + (..define short (if record? - {#.Slot [exported? type tags index]} - {#.Label [exported? type tags index]}))) + {.#Slot [exported? type tags index]} + {.#Label [exported? type tags index]}))) (list.enumeration tags)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/primitive.lux index ad481b931..fe8c61096 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/primitive.lux @@ -16,18 +16,18 @@ (-> <type> (Operation Analysis)) (do ///.monad [_ (//type.infer <type>)] - (in {#/.Primitive {<tag> value}})))] + (in {/.#Primitive {<tag> value}})))] - [bit .Bit #/.Bit] - [nat .Nat #/.Nat] - [int .Int #/.Int] - [rev .Rev #/.Rev] - [frac .Frac #/.Frac] - [text .Text #/.Text] + [bit .Bit /.#Bit] + [nat .Nat /.#Nat] + [int .Int /.#Int] + [rev .Rev /.#Rev] + [frac .Frac /.#Frac] + [text .Text /.#Text] ) (def: .public unit (Operation Analysis) (do ///.monad [_ (//type.infer .Any)] - (in {#/.Primitive #/.Unit}))) + (in {/.#Primitive {/.#Unit}}))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/reference.lux index 26946da08..05495f98d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/reference.lux @@ -36,14 +36,14 @@ (def: (definition def_name) (-> Name (Operation Analysis)) - (with_expansions [<return> (in (|> def_name ///reference.constant #/.Reference))] + (with_expansions [<return> (in (|> def_name ///reference.constant {/.#Reference}))] (do [! ///.monad] [constant (///extension.lifted (meta.definition def_name))] (case constant - {#.Alias real_def_name} + {.#Alias real_def_name} (definition real_def_name) - {#.Definition [exported? actualT _]} + {.#Definition [exported? actualT _]} (do ! [_ (//type.infer actualT) (^@ def_name [::module ::name]) (///extension.lifted (meta.normal def_name)) @@ -58,7 +58,7 @@ (/.except foreign_module_has_not_been_imported [current ::module]))) (/.except definition_has_not_been_exported def_name)))) - {#.Type [exported? value labels]} + {.#Type [exported? value labels]} (do ! [_ (//type.infer .Type) (^@ def_name [::module ::name]) (///extension.lifted (meta.normal def_name)) @@ -73,10 +73,10 @@ (/.except foreign_module_has_not_been_imported [current ::module]))) (/.except definition_has_not_been_exported def_name)))) - {#.Label _} + {.#Label _} (/.except labels_are_not_definitions [def_name]) - {#.Slot _} + {.#Slot _} (/.except labels_are_not_definitions [def_name]))))) (def: (variable var_name) @@ -84,13 +84,13 @@ (do [! ///.monad] [?var (//scope.find var_name)] (case ?var - {#.Some [actualT ref]} + {.#Some [actualT ref]} (do ! [_ (//type.infer actualT)] - (in {#.Some (|> ref ///reference.variable #/.Reference)})) + (in {.#Some (|> ref ///reference.variable {/.#Reference})})) - #.None - (in #.None)))) + {.#None} + (in {.#None})))) (def: .public (reference reference) (-> Name (Operation Analysis)) @@ -99,10 +99,10 @@ (do [! ///.monad] [?var (variable simple_name)] (case ?var - {#.Some varA} + {.#Some varA} (in varA) - #.None + {.#None} (do ! [this_module (///extension.lifted meta.current_module_name)] (definition [this_module simple_name])))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux index cb737d36d..d14adf09f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux @@ -32,35 +32,35 @@ (def: (local? name scope) (-> Text Scope Bit) (|> scope - (value@ [#.locals #.mappings]) + (value@ [.#locals .#mappings]) (plist.contains? name))) (def: (local name scope) (-> Text Scope (Maybe [Type Variable])) (|> scope - (value@ [#.locals #.mappings]) + (value@ [.#locals .#mappings]) (plist.value name) (maybe\each (function (_ [type value]) - [type {#variable.Local value}])))) + [type {variable.#Local value}])))) (def: (captured? name scope) (-> Text Scope Bit) (|> scope - (value@ [#.captured #.mappings]) + (value@ [.#captured .#mappings]) (plist.contains? name))) (def: (captured name scope) (-> Text Scope (Maybe [Type Variable])) (loop [idx 0 - mappings (value@ [#.captured #.mappings] scope)] + mappings (value@ [.#captured .#mappings] scope)] (case mappings - {#.Item [_name [_source_type _source_ref]] mappings'} + {.#Item [_name [_source_type _source_ref]] mappings'} (if (text\= name _name) - {#.Some [_source_type {#variable.Foreign idx}]} + {.#Some [_source_type {variable.#Foreign idx}]} (recur (++ idx) mappings')) - #.End - #.None))) + {.#End} + {.#None}))) (def: (reference? name scope) (-> Text Scope Bit) @@ -70,8 +70,8 @@ (def: (reference name scope) (-> Text Scope (Maybe [Type Variable])) (case (..local name scope) - {#.Some type} - {#.Some type} + {.#Some type} + {.#Some type} _ (..captured name scope))) @@ -81,29 +81,29 @@ (///extension.lifted (function (_ state) (let [[inner outer] (|> state - (value@ #.scopes) + (value@ .#scopes) (list.split_when (|>> (reference? name))))] (case outer - #.End - {#.Right [state #.None]} + {.#End} + {.#Right [state {.#None}]} - {#.Item top_outer _} + {.#Item top_outer _} (let [[ref_type init_ref] (maybe.else (undefined) (..reference name top_outer)) [ref inner'] (list\mix (: (-> Scope [Variable (List Scope)] [Variable (List Scope)]) (function (_ scope ref+inner) - [{#variable.Foreign (value@ [#.captured #.counter] scope)} - {#.Item (revised@ #.captured + [{variable.#Foreign (value@ [.#captured .#counter] scope)} + {.#Item (revised@ .#captured (: (-> Foreign Foreign) - (|>> (revised@ #.counter ++) - (revised@ #.mappings (plist.has name [ref_type (product.left ref+inner)])))) + (|>> (revised@ .#counter ++) + (revised@ .#mappings (plist.has name [ref_type (product.left ref+inner)])))) scope) (product.right ref+inner)}])) - [init_ref #.End] + [init_ref {.#End}] (list.reversed inner)) scopes (list\composite inner' outer)] - {#.Right [(with@ #.scopes scopes state) - {#.Some [ref_type ref]}]}) + {.#Right [(with@ .#scopes scopes state) + {.#Some [ref_type ref]}]}) ))))) (exception: .public cannot_create_local_binding_without_a_scope) @@ -112,30 +112,30 @@ (def: .public (with_local [name type] action) (All (_ a) (-> [Text Type] (Operation a) (Operation a))) (function (_ [bundle state]) - (case (value@ #.scopes state) - {#.Item head tail} - (let [old_mappings (value@ [#.locals #.mappings] head) - new_var_id (value@ [#.locals #.counter] head) - new_head (revised@ #.locals + (case (value@ .#scopes state) + {.#Item head tail} + (let [old_mappings (value@ [.#locals .#mappings] head) + new_var_id (value@ [.#locals .#counter] head) + new_head (revised@ .#locals (: (-> Local Local) - (|>> (revised@ #.counter ++) - (revised@ #.mappings (plist.has name [type new_var_id])))) + (|>> (revised@ .#counter ++) + (revised@ .#mappings (plist.has name [type new_var_id])))) head)] - (case (///.result' [bundle (with@ #.scopes {#.Item new_head tail} state)] + (case (///.result' [bundle (with@ .#scopes {.#Item new_head tail} state)] action) - {#try.Success [[bundle' state'] output]} - (case (value@ #.scopes state') - {#.Item head' tail'} - (let [scopes' {#.Item (with@ #.locals (value@ #.locals head) head') + {try.#Success [[bundle' state'] output]} + (case (value@ .#scopes state') + {.#Item head' tail'} + (let [scopes' {.#Item (with@ .#locals (value@ .#locals head) head') tail'}] - {#try.Success [[bundle' (with@ #.scopes scopes' state')] + {try.#Success [[bundle' (with@ .#scopes scopes' state')] output]}) _ (exception.except ..invalid_scope_alteration [])) - {#try.Failure error} - {#try.Failure error})) + {try.#Failure error} + {try.#Failure error})) _ (exception.except ..cannot_create_local_binding_without_a_scope [])) @@ -144,8 +144,8 @@ (template [<name> <val_type>] [(def: <name> (Bindings Text [Type <val_type>]) - [#.counter 0 - #.mappings (list)])] + [.#counter 0 + .#mappings (list)])] [init_locals Nat] [init_captured Variable] @@ -153,31 +153,31 @@ (def: (scope parent_name child_name) (-> (List Text) Text Scope) - [#.name (list& child_name parent_name) - #.inner 0 - #.locals init_locals - #.captured init_captured]) + [.#name (list& child_name parent_name) + .#inner 0 + .#locals init_locals + .#captured init_captured]) (def: .public (with_scope name action) (All (_ a) (-> Text (Operation a) (Operation a))) (function (_ [bundle state]) - (let [parent_name (case (value@ #.scopes state) - #.End + (let [parent_name (case (value@ .#scopes state) + {.#End} (list) - {#.Item top _} - (value@ #.name top))] - (case (action [bundle (revised@ #.scopes - (|>> {#.Item (scope parent_name name)}) + {.#Item top _} + (value@ .#name top))] + (case (action [bundle (revised@ .#scopes + (|>> {.#Item (scope parent_name name)}) state)]) - {#try.Success [[bundle' state'] output]} - {#try.Success [[bundle' (revised@ #.scopes + {try.#Success [[bundle' state'] output]} + {try.#Success [[bundle' (revised@ .#scopes (|>> list.tail (maybe.else (list))) state')] output]} - {#try.Failure error} - {#try.Failure error})))) + {try.#Failure error} + {try.#Failure error})))) (exception: .public cannot_get_next_reference_when_there_is_no_scope) @@ -185,24 +185,24 @@ (Operation Register) (///extension.lifted (function (_ state) - (case (value@ #.scopes state) - {#.Item top _} - {#try.Success [state (value@ [#.locals #.counter] top)]} + (case (value@ .#scopes state) + {.#Item top _} + {try.#Success [state (value@ [.#locals .#counter] top)]} - #.End + {.#End} (exception.except ..cannot_get_next_reference_when_there_is_no_scope []))))) (def: (ref_variable ref) (-> Ref Variable) (case ref - {#.Local register} - {#variable.Local register} + {.#Local register} + {variable.#Local register} - {#.Captured register} - {#variable.Foreign register})) + {.#Captured register} + {variable.#Foreign register})) (def: .public (environment scope) (-> Scope (List Variable)) (|> scope - (value@ [#.captured #.mappings]) + (value@ [.#captured .#mappings]) (list\each (function (_ [_ [_ ref]]) (ref_variable ref))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux index 0ccb8f1e0..188d8f7b8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux @@ -115,28 +115,28 @@ (check.clean expectedT))] (/.with_stack ..cannot_analyse_variant [expectedT' tag valueC] (case expectedT - {#.Sum _} + {.#Sum _} (let [flat (type.flat_variant expectedT)] (case (list.item tag flat) - {#.Some variant_type} + {.#Some variant_type} (do ! [valueA (//type.with_type variant_type (analyse archive valueC))] (in (/.variant [lefts right? valueA]))) - #.None + {.#None} (/.except //inference.variant_tag_out_of_bounds [(list.size flat) tag expectedT]))) - {#.Named name unnamedT} + {.#Named name unnamedT} (//type.with_type unnamedT (recur valueC)) - {#.Var id} + {.#Var id} (do ! [?expectedT' (//type.with_env (check.peek id))] (case ?expectedT' - {#.Some expectedT'} + {.#Some expectedT'} (//type.with_type expectedT' (recur valueC)) @@ -152,18 +152,18 @@ [[instance_id instanceT] (//type.with_env <instancer>)] (//type.with_type (maybe.trusted (type.applied (list instanceT) expectedT)) (recur valueC)))]) - ([#.UnivQ check.existential] - [#.ExQ check.var]) + ([.#UnivQ check.existential] + [.#ExQ check.var]) - {#.Apply inputT funT} + {.#Apply inputT funT} (case funT - {#.Var funT_id} + {.#Var funT_id} (do ! [?funT' (//type.with_env (check.peek funT_id))] (case ?funT' - {#.Some funT'} - (//type.with_type {#.Apply inputT funT'} + {.#Some funT'} + (//type.with_type {.#Apply inputT funT'} (recur valueC)) _ @@ -171,11 +171,11 @@ _ (case (type.applied (list inputT) funT) - {#.Some outputT} + {.#Some outputT} (//type.with_type outputT (recur valueC)) - #.None + {.#None} (/.except ..not_a_quantified_type funT))) _ @@ -189,26 +189,26 @@ (loop [membersT+ (type.flat_tuple expectedT) membersC+ members] (case [membersT+ membersC+] - [{#.Item memberT #.End} {#.Item memberC #.End}] + [{.#Item memberT {.#End}} {.#Item memberC {.#End}}] (do ! [memberA (//type.with_type memberT (analyse archive memberC))] (in (list memberA))) - [{#.Item memberT #.End} _] + [{.#Item memberT {.#End}} _] (//type.with_type memberT (\ ! each (|>> list) (analyse archive (code.tuple membersC+)))) - [_ {#.Item memberC #.End}] + [_ {.#Item memberC {.#End}}] (//type.with_type (type.tuple membersT+) (\ ! each (|>> list) (analyse archive memberC))) - [{#.Item memberT membersT+'} {#.Item memberC membersC+'}] + [{.#Item memberT membersT+'} {.#Item memberC membersC+'}] (do ! [memberA (//type.with_type memberT (analyse archive memberC)) memberA+ (recur membersT+' membersC+')] - (in {#.Item memberA memberA+})) + (in {.#Item memberA memberA+})) _ (/.except ..cannot_analyse_tuple [expectedT members]))))] @@ -220,19 +220,19 @@ [expectedT (///extension.lifted meta.expected_type)] (/.with_stack ..cannot_analyse_tuple [expectedT membersC] (case expectedT - {#.Product _} + {.#Product _} (..typed_product archive analyse membersC) - {#.Named name unnamedT} + {.#Named name unnamedT} (//type.with_type unnamedT (product archive analyse membersC)) - {#.Var id} + {.#Var id} (do ! [?expectedT' (//type.with_env (check.peek id))] (case ?expectedT' - {#.Some expectedT'} + {.#Some expectedT'} (//type.with_type expectedT' (product archive analyse membersC)) @@ -252,18 +252,18 @@ [[instance_id instanceT] (//type.with_env <instancer>)] (//type.with_type (maybe.trusted (type.applied (list instanceT) expectedT)) (product archive analyse membersC)))]) - ([#.UnivQ check.existential] - [#.ExQ check.var]) + ([.#UnivQ check.existential] + [.#ExQ check.var]) - {#.Apply inputT funT} + {.#Apply inputT funT} (case funT - {#.Var funT_id} + {.#Var funT_id} (do ! [?funT' (//type.with_env (check.peek funT_id))] (case ?funT' - {#.Some funT'} - (//type.with_type {#.Apply inputT funT'} + {.#Some funT'} + (//type.with_type {.#Apply inputT funT'} (product archive analyse membersC)) _ @@ -271,11 +271,11 @@ _ (case (type.applied (list inputT) funT) - {#.Some outputT} + {.#Some outputT} (//type.with_type outputT (product archive analyse membersC)) - #.None + {.#None} (/.except ..not_a_quantified_type funT))) _ @@ -291,7 +291,7 @@ [lefts right?] (/.choice case_size idx)] expectedT (///extension.lifted meta.expected_type)] (case expectedT - {#.Var _} + {.#Var _} (do ! [inferenceT (//inference.variant idx case_size variantT) [inferredT valueA+] (//inference.general archive analyse inferenceT (list valueC))] @@ -308,18 +308,18 @@ (-> (List Code) (Operation (Maybe (List [Name Code])))) (loop [input record output (: (List [Name Code]) - #.End)] + {.#End})] (case input - (^ (list& [_ {#.Tag slotH}] valueH tail)) + (^ (list& [_ {.#Tag slotH}] valueH tail)) (do ///.monad [slotH (///extension.lifted (meta.normal slotH))] - (recur tail {#.Item [slotH valueH] output})) + (recur tail {.#Item [slotH valueH] output})) - #.End - (\ ///.monad in {#.Some output}) + {.#End} + (\ ///.monad in {.#Some output}) _ - (\ ///.monad in #.None)))) + (\ ///.monad in {.#None})))) ... Lux already possesses the means to analyse tuples, so ... re-implementing the same functionality for records makes no sense. @@ -328,17 +328,17 @@ (-> (List [Name Code]) (Operation (Maybe [Nat (List Code) Type]))) (case record ... empty_record = empty_tuple = unit/any = [] - #.End - (\ ///.monad in {#.Some [0 (list) Any]}) + {.#End} + (\ ///.monad in {.#Some [0 (list) Any]}) - {#.Item [head_k head_v] _} + {.#Item [head_k head_v] _} (do [! ///.monad] [slotH' (///extension.lifted (do meta.monad [head_k (meta.normal head_k)] (meta.try (meta.slot head_k))))] (case slotH' - {#try.Success [_ slot_set recordT]} + {try.#Success [_ slot_set recordT]} (do ! [.let [size_record (list.size record) size_ts (list.size slot_set)] @@ -352,12 +352,12 @@ (do ! [key (///extension.lifted (meta.normal key))] (case (dictionary.value key tag->idx) - {#.Some idx} + {.#Some idx} (if (dictionary.key? idx->val idx) (/.except ..cannot_repeat_tag [key record]) (in (dictionary.has idx val idx->val))) - #.None + {.#None} (/.except ..slot_does_not_belong_to_record [key recordT])))) (: (Dictionary Nat Code) (dictionary.empty n.hash)) @@ -365,10 +365,10 @@ .let [ordered_tuple (list\each (function (_ idx) (maybe.trusted (dictionary.value idx idx->val))) tuple_range)]] - (in {#.Some [size_ts ordered_tuple recordT]})) + (in {.#Some [size_ts ordered_tuple recordT]})) - {#try.Failure error} - (in #.None))) + {try.#Failure error} + (in {.#None}))) )) (def: .public (record archive analyse members) @@ -380,12 +380,12 @@ (^ (list singletonC)) (analyse archive singletonC) - (^ (list [_ {#.Tag pseudo_slot}] singletonC)) + (^ (list [_ {.#Tag pseudo_slot}] singletonC)) (do [! ///.monad] [head_k (///extension.lifted (meta.normal pseudo_slot)) slot (///extension.lifted (meta.try (meta.slot head_k)))] (case slot - {#try.Success [_ slot_set recordT]} + {try.#Success [_ slot_set recordT]} (case (list.size slot_set) 1 (analyse archive singletonC) _ (..product archive analyse members)) @@ -397,21 +397,21 @@ (do [! ///.monad] [?members (normal members)] (case ?members - #.None + {.#None} (..product archive analyse members) - {#.Some slots} + {.#Some slots} (do ! [record_size,membersC,recordT (..order slots)] (case record_size,membersC,recordT - #.None + {.#None} (..product archive analyse members) - {#.Some [record_size membersC recordT]} + {.#Some [record_size membersC recordT]} (do ! [expectedT (///extension.lifted meta.expected_type)] (case expectedT - {#.Var _} + {.#Var _} (do ! [inferenceT (//inference.record record_size recordT) [inferredT membersA] (//inference.general archive analyse inferenceT membersC)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/type.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/type.lux index 33a8715d5..1f53c1154 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/type.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/type.lux @@ -18,23 +18,23 @@ (def: .public (with_type expected) (All (_ a) (-> Type (Operation a) (Operation a))) - (///extension.localized (value@ #.expected) (with@ #.expected) - (function.constant {#.Some expected}))) + (///extension.localized (value@ .#expected) (with@ .#expected) + (function.constant {.#Some expected}))) (def: .public (with_env action) (All (_ a) (-> (Check a) (Operation a))) (function (_ (^@ stateE [bundle state])) - (case (action (value@ #.type_context state)) - {#try.Success [context' output]} - {#try.Success [[bundle (with@ #.type_context context' state)] + (case (action (value@ .#type_context state)) + {try.#Success [context' output]} + {try.#Success [[bundle (with@ .#type_context context' state)] output]} - {#try.Failure error} + {try.#Failure error} ((/.failure error) stateE)))) (def: .public with_fresh_env (All (_ a) (-> (Operation a) (Operation a))) - (///extension.localized (value@ #.type_context) (with@ #.type_context) + (///extension.localized (value@ .#type_context) (with@ .#type_context) (function.constant check.fresh_context))) (def: .public (infer actualT) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux index dc47f7039..0d95f2262 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux @@ -48,13 +48,13 @@ Eval) (function (_ type code lux) (case (compiler_eval archive type code [bundle lux]) - {#try.Success [[_bundle lux'] value]} - {#try.Success [lux' value]} + {try.#Success [[_bundle lux'] value]} + {try.#Success [lux' value]} - {#try.Failure error} - {#try.Failure error}))) + {try.#Failure error} + {try.#Failure error}))) -(with_expansions [<lux_def_module> (as_is [|form_location| {#.Form (list& [|text_location| {#.Text "lux def module"}] annotations)}])] +(with_expansions [<lux_def_module> (as_is [|form_location| {.#Form (list& [|text_location| {.#Text "lux def module"}] annotations)}])] (def: .public (phase wrapper expander) (-> //.Wrapper Expander Phase) (let [analysis (//analysis.phase expander)] @@ -62,18 +62,18 @@ (do [! //.monad] [state //.get_state .let [compiler_eval (meta_eval archive - (value@ [#//extension.state #/.analysis #/.state #//extension.bundle] state) + (value@ [//extension.#state /.#analysis /.#state //extension.#bundle] state) (evaluation.evaluator expander - (value@ [#//extension.state #/.synthesis #/.state] state) - (value@ [#//extension.state #/.generation #/.state] state) - (value@ [#//extension.state #/.generation #/.phase] state))) + (value@ [//extension.#state /.#synthesis /.#state] state) + (value@ [//extension.#state /.#generation /.#state] state) + (value@ [//extension.#state /.#generation /.#phase] state))) extension_eval (:as Eval (wrapper (:expected compiler_eval)))] - _ (//.set_state (with@ [#//extension.state #/.analysis #/.state #//extension.state #.eval] extension_eval state))] + _ (//.set_state (with@ [//extension.#state /.#analysis /.#state //extension.#state .#eval] extension_eval state))] (case code - (^ [_ {#.Form (list& [_ {#.Text name}] inputs)}]) + (^ [_ {.#Form (list& [_ {.#Text name}] inputs)}]) (//extension.apply archive recur [name inputs]) - (^ [_ {#.Form (list& macro inputs)}]) + (^ [_ {.#Form (list& macro inputs)}]) (do ! [expansion (/.lifted_analysis (do ! @@ -84,10 +84,10 @@ (do ! [?macro (//extension.lifted (meta.macro macro_name)) macro (case ?macro - {#.Some macro} + {.#Some macro} (in macro) - #.None + {.#None} (//.except ..macro_was_not_found macro_name))] (//extension.lifted (///analysis/macro.expand expander macro_name macro inputs))) @@ -96,7 +96,7 @@ (case expansion (^ (list& <lux_def_module> referrals)) (|> (recur archive <lux_def_module>) - (\ ! each (revised@ #/.referrals (list\composite referrals)))) + (\ ! each (revised@ /.#referrals (list\composite referrals)))) _ (|> expansion diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux index 2fd695eef..7f3481817 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux @@ -97,8 +97,8 @@ (-> (Extender s i o) Text (Handler s i o) (Operation s i o Any))) (function (_ [bundle state]) (case (dictionary.value name bundle) - #.None - {#try.Success [[(dictionary.has name (extender handler) bundle) state] + {.#None} + {try.#Success [[(dictionary.has name (extender handler) bundle) state] []]} _ @@ -119,11 +119,11 @@ (-> Archive (Phase s i o) (Extension i) (Operation s i o o))) (function (_ (^@ stateE [bundle state])) (case (dictionary.value name bundle) - {#.Some handler} + {.#Some handler} (((handler name phase) archive parameters) stateE) - #.None + {.#None} (exception.except ..unknown [name bundle])))) (def: .public (localized get set transform) @@ -134,11 +134,11 @@ (function (_ [bundle state]) (let [old (get state)] (case (operation [bundle (set (transform old) state)]) - {#try.Success [[bundle' state'] output]} - {#try.Success [[bundle' (set old state')] output]} + {try.#Success [[bundle' state'] output]} + {try.#Success [[bundle' (set old state')] output]} - {#try.Failure error} - {#try.Failure error}))))) + {try.#Failure error} + {try.#Failure error}))))) (def: .public (temporary transform) (All (_ s i o v) @@ -147,11 +147,11 @@ (function (_ operation) (function (_ [bundle state]) (case (operation [bundle (transform state)]) - {#try.Success [[bundle' state'] output]} - {#try.Success [[bundle' state] output]} + {try.#Success [[bundle' state'] output]} + {try.#Success [[bundle' state] output]} - {#try.Failure error} - {#try.Failure error})))) + {try.#Failure error} + {try.#Failure error})))) (def: .public (with_state state) (All (_ s i o v) @@ -162,13 +162,13 @@ (All (_ s i o v) (-> (-> s v) (Operation s i o v))) (function (_ [bundle state]) - {#try.Success [[bundle state] (get state)]})) + {try.#Success [[bundle state] (get state)]})) (def: .public (update transform) (All (_ s i o) (-> (-> s s) (Operation s i o Any))) (function (_ [bundle state]) - {#try.Success [[bundle (transform state)] []]})) + {try.#Success [[bundle (transform state)] []]})) (def: .public (lifted action) (All (_ s i o v) @@ -176,8 +176,8 @@ (//.Operation [(Bundle s i o) s] v))) (function (_ [bundle state]) (case (action state) - {#try.Success [state' output]} - {#try.Success [[bundle state'] output]} + {try.#Success [state' output]} + {try.#Success [[bundle state'] output]} - {#try.Failure error} - {#try.Failure error}))) + {try.#Failure error} + {try.#Failure error}))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux index 36578eb15..6de21c89b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux @@ -38,7 +38,7 @@ (phase archive lengthC)) [var_id varT] (analysis/type.with_env check.var) _ (analysis/type.infer (type (Array varT)))] - (in {#analysis.Extension extension (list lengthA)})))])) + (in {analysis.#Extension extension (list lengthA)})))])) (def: array::length Handler @@ -50,7 +50,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer Nat)] - (in {#analysis.Extension extension (list arrayA)})))])) + (in {analysis.#Extension extension (list arrayA)})))])) (def: array::read Handler @@ -64,7 +64,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer varT)] - (in {#analysis.Extension extension (list indexA arrayA)})))])) + (in {analysis.#Extension extension (list indexA arrayA)})))])) (def: array::write Handler @@ -80,7 +80,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in {#analysis.Extension extension (list indexA valueA arrayA)})))])) + (in {analysis.#Extension extension (list indexA valueA arrayA)})))])) (def: array::delete Handler @@ -94,7 +94,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in {#analysis.Extension extension (list indexA arrayA)})))])) + (in {analysis.#Extension extension (list indexA arrayA)})))])) (def: bundle::array Bundle @@ -117,7 +117,7 @@ (phase archive constructorC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] - (in {#analysis.Extension extension (list& constructorA inputsA)})))])) + (in {analysis.#Extension extension (list& constructorA inputsA)})))])) (def: object::get Handler @@ -128,7 +128,7 @@ [objectA (analysis/type.with_type Any (phase archive objectC)) _ (analysis/type.infer .Any)] - (in {#analysis.Extension extension (list (analysis.text fieldC) + (in {analysis.#Extension extension (list (analysis.text fieldC) objectA)})))])) (def: object::do @@ -141,7 +141,7 @@ (phase archive objectC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] - (in {#analysis.Extension extension (list& (analysis.text methodC) + (in {analysis.#Extension extension (list& (analysis.text methodC) objectA inputsA)})))])) @@ -165,7 +165,7 @@ (function (_ extension phase archive name) (do phase.monad [_ (analysis/type.infer Any)] - (in {#analysis.Extension extension (list (analysis.text name))})))])) + (in {analysis.#Extension extension (list (analysis.text name))})))])) (def: js::apply Handler @@ -177,7 +177,7 @@ (phase archive abstractionC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] - (in {#analysis.Extension extension (list& abstractionA inputsA)})))])) + (in {analysis.#Extension extension (list& abstractionA inputsA)})))])) (def: js::type_of Handler @@ -188,7 +188,7 @@ [objectA (analysis/type.with_type Any (phase archive objectC)) _ (analysis/type.infer .Text)] - (in {#analysis.Extension extension (list objectA)})))])) + (in {analysis.#Extension extension (list objectA)})))])) (def: js::function Handler @@ -201,7 +201,7 @@ (phase archive abstractionC)) _ (analysis/type.infer (for [@.js ffi.Function] Any))] - (in {#analysis.Extension extension (list (analysis.nat arity) + (in {analysis.#Extension extension (list (analysis.nat arity) abstractionA)})))])) (def: .public bundle diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux index f9cf0b336..88b935e35 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux @@ -161,13 +161,13 @@ (def: inheritance_relationship_type_name "_jvm_inheritance") (def: .public (inheritance_relationship_type class super_class super_interfaces) (-> .Type .Type (List .Type) .Type) - {#.Primitive ..inheritance_relationship_type_name + {.#Primitive ..inheritance_relationship_type_name (list& class super_class super_interfaces)}) ... TODO: Get rid of this template block and use the definition in ... lux/ffi.jvm.lux ASAP (template [<name> <class>] - [(def: .public <name> .Type {#.Primitive <class> #.End})] + [(def: .public <name> .Type {.#Primitive <class> {.#End}})] ... Boxes [Boolean box.boolean] @@ -355,31 +355,31 @@ (def: (jvm_type luxT) (-> .Type (Operation (Type Value))) (case luxT - {#.Named name anonymousT} + {.#Named name anonymousT} (jvm_type anonymousT) - {#.Apply inputT abstractionT} + {.#Apply inputT abstractionT} (case (type.applied (list inputT) abstractionT) - {#.Some outputT} + {.#Some outputT} (jvm_type outputT) - #.None + {.#None} (/////analysis.except ..non_jvm_type luxT)) - (^ {#.Primitive (static array.type_name) (list elemT)}) + (^ {.#Primitive (static array.type_name) (list elemT)}) (phase\each jvm.array (jvm_type elemT)) - {#.Primitive class parametersT} + {.#Primitive class parametersT} (case (dictionary.value class ..boxes) - {#.Some [_ primitive_type]} + {.#Some [_ primitive_type]} (case parametersT - #.End + {.#End} (phase\in primitive_type) _ (/////analysis.except ..primitives_cannot_have_type_parameters class)) - #.None + {.#None} (do [! phase.monad] [parametersJT (: (Operation (List (Type Parameter))) (monad.each ! @@ -387,15 +387,15 @@ (do phase.monad [parameterJT (jvm_type parameterT)] (case (jvm_parser.parameter? parameterJT) - {#.Some parameterJT} + {.#Some parameterJT} (in parameterJT) - #.None + {.#None} (/////analysis.except ..non_parameter parameterT)))) parametersT))] (in (jvm.class class parametersJT)))) - {#.Ex _} + {.#Ex _} (phase\in (jvm.class ..object_class (list))) _ @@ -417,11 +417,11 @@ (^ (list arrayC)) (do phase.monad [_ (typeA.infer ..int) - arrayA (typeA.with_type {#.Primitive (|> (jvm.array primitive_type) + arrayA (typeA.with_type {.#Primitive (|> (jvm.array primitive_type) ..reflection) (list)} (analyse archive arrayC))] - (in {#/////analysis.Extension extension_name (list arrayA)})) + (in {/////analysis.#Extension extension_name (list arrayA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) @@ -438,7 +438,7 @@ (analyse archive arrayC)) varT (typeA.with_env (check.clean varT)) arrayJT (jvm_array_type (.type (array.Array varT)))] - (in {#/////analysis.Extension extension_name (list (/////analysis.text (..signature arrayJT)) + (in {/////analysis.#Extension extension_name (list (/////analysis.text (..signature arrayJT)) arrayA)})) _ @@ -452,9 +452,9 @@ (do phase.monad [lengthA (typeA.with_type ..int (analyse archive lengthC)) - _ (typeA.infer {#.Primitive (|> (jvm.array primitive_type) ..reflection) + _ (typeA.infer {.#Primitive (|> (jvm.array primitive_type) ..reflection) (list)})] - (in {#/////analysis.Extension extension_name (list lengthA)})) + (in {/////analysis.#Extension extension_name (list lengthA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) @@ -470,12 +470,12 @@ expectedT (///.lifted meta.expected_type) expectedJT (jvm_array_type expectedT) elementJT (case (jvm_parser.array? expectedJT) - {#.Some elementJT} + {.#Some elementJT} (in elementJT) - #.None + {.#None} (/////analysis.except ..non_array expectedT))] - (in {#/////analysis.Extension extension_name (list (/////analysis.text (..signature elementJT)) + (in {/////analysis.#Extension extension_name (list (/////analysis.text (..signature elementJT)) lengthA)})) _ @@ -484,11 +484,11 @@ (def: (check_parameter objectT) (-> .Type (Operation (Type Parameter))) (case objectT - (^ {#.Primitive (static array.type_name) + (^ {.#Primitive (static array.type_name) (list elementT)}) (/////analysis.except ..non_parameter objectT) - {#.Primitive name parameters} + {.#Primitive name parameters} (`` (cond (or (~~ (template [<type>] [(text\= (..reflection <type>) name)] @@ -506,27 +506,27 @@ ... else (phase\in (jvm.class name (list))))) - {#.Named name anonymous} + {.#Named name anonymous} (check_parameter anonymous) (^template [<tag>] [{<tag> id} (phase\in (jvm.class ..object_class (list)))]) - ([#.Var] - [#.Ex]) + ([.#Var] + [.#Ex]) (^template [<tag>] [{<tag> env unquantified} (check_parameter unquantified)]) - ([#.UnivQ] - [#.ExQ]) + ([.#UnivQ] + [.#ExQ]) - {#.Apply inputT abstractionT} + {.#Apply inputT abstractionT} (case (type.applied (list inputT) abstractionT) - {#.Some outputT} + {.#Some outputT} (check_parameter outputT) - #.None + {.#None} (/////analysis.except ..non_parameter objectT)) _ @@ -535,7 +535,7 @@ (def: (check_jvm objectT) (-> .Type (Operation (Type Value))) (case objectT - {#.Primitive name #.End} + {.#Primitive name {.#End}} (`` (cond (~~ (template [<type>] [(text\= (..reflection <type>) name) (phase\in <type>)] @@ -565,37 +565,37 @@ (text.starts_with? descriptor.array_prefix name) (let [[_ unprefixed] (maybe.trusted (text.split_by descriptor.array_prefix name))] (\ phase.monad each jvm.array - (check_jvm {#.Primitive unprefixed (list)}))) + (check_jvm {.#Primitive unprefixed (list)}))) ... else (phase\in (jvm.class name (list))))) - (^ {#.Primitive (static array.type_name) + (^ {.#Primitive (static array.type_name) (list elementT)}) (|> elementT check_jvm (phase\each jvm.array)) - {#.Primitive name parameters} + {.#Primitive name parameters} (do [! phase.monad] [parameters (monad.each ! check_parameter parameters)] (phase\in (jvm.class name parameters))) - {#.Named name anonymous} + {.#Named name anonymous} (check_jvm anonymous) (^template [<tag>] [{<tag> env unquantified} (check_jvm unquantified)]) - ([#.UnivQ] - [#.ExQ]) + ([.#UnivQ] + [.#ExQ]) - {#.Apply inputT abstractionT} + {.#Apply inputT abstractionT} (case (type.applied (list inputT) abstractionT) - {#.Some outputT} + {.#Some outputT} (check_jvm outputT) - #.None + {.#None} (/////analysis.except ..non_object objectT)) _ @@ -624,10 +624,10 @@ [_ (typeA.infer lux_type) idxA (typeA.with_type ..int (analyse archive idxC)) - arrayA (typeA.with_type {#.Primitive (|> (jvm.array jvm_type) ..reflection) + arrayA (typeA.with_type {.#Primitive (|> (jvm.array jvm_type) ..reflection) (list)} (analyse archive arrayC))] - (in {#/////analysis.Extension extension_name (list idxA arrayA)})) + (in {/////analysis.#Extension extension_name (list idxA arrayA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) @@ -647,7 +647,7 @@ arrayJT (jvm_array_type (.type (array.Array varT))) idxA (typeA.with_type ..int (analyse archive idxC))] - (in {#/////analysis.Extension extension_name (list (/////analysis.text (..signature arrayJT)) + (in {/////analysis.#Extension extension_name (list (/////analysis.text (..signature arrayJT)) idxA arrayA)})) @@ -656,7 +656,7 @@ (def: (write_primitive_array_handler lux_type jvm_type) (-> .Type (Type Primitive) Handler) - (let [array_type {#.Primitive (|> (jvm.array jvm_type) ..reflection) + (let [array_type {.#Primitive (|> (jvm.array jvm_type) ..reflection) (list)}] (function (_ extension_name analyse archive args) (case args @@ -669,7 +669,7 @@ (analyse archive valueC)) arrayA (typeA.with_type array_type (analyse archive arrayC))] - (in {#/////analysis.Extension extension_name (list idxA + (in {/////analysis.#Extension extension_name (list idxA valueA arrayA)})) @@ -693,7 +693,7 @@ (analyse archive idxC)) valueA (typeA.with_type varT (analyse archive valueC))] - (in {#/////analysis.Extension extension_name (list (/////analysis.text (..signature arrayJT)) + (in {/////analysis.#Extension extension_name (list (/////analysis.text (..signature arrayJT)) idxA valueA arrayA)})) @@ -759,7 +759,7 @@ (do phase.monad [expectedT (///.lifted meta.expected_type) _ (check_object expectedT)] - (in {#/////analysis.Extension extension_name (list)})) + (in {/////analysis.#Extension extension_name (list)})) _ (/////analysis.except ///.incorrect_arity [extension_name 0 (list.size args)])))) @@ -774,7 +774,7 @@ [objectT objectA] (typeA.with_inference (analyse archive objectC)) _ (check_object objectT)] - (in {#/////analysis.Extension extension_name (list objectA)})) + (in {/////analysis.#Extension extension_name (list objectA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) @@ -789,7 +789,7 @@ (analyse archive monitorC)) _ (check_object monitorT) exprA (analyse archive exprC)] - (in {#/////analysis.Extension extension_name (list monitorA exprA)})) + (in {/////analysis.#Extension extension_name (list monitorA exprA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) @@ -809,7 +809,7 @@ (if ? (in []) (/////analysis.except non_throwable exception_class)))] - (in {#/////analysis.Extension extension_name (list exceptionA)})) + (in {/////analysis.#Extension extension_name (list exceptionA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) @@ -820,12 +820,12 @@ (case args (^ (list classC)) (case classC - [_ {#.Text class}] + [_ {.#Text class}] (do phase.monad [_ (..ensure_fresh_class! class_loader class) - _ (typeA.infer {#.Primitive "java.lang.Class" (list {#.Primitive class (list)})}) + _ (typeA.infer {.#Primitive "java.lang.Class" (list {.#Primitive class (list)})}) _ (phase.lifted (reflection!.load class_loader class))] - (in {#/////analysis.Extension extension_name (list (/////analysis.text class))})) + (in {/////analysis.#Extension extension_name (list (/////analysis.text class))})) _ (/////analysis.except ///.invalid_syntax [extension_name %.code args])) @@ -846,18 +846,18 @@ object_class (check_object objectT) ? (phase.lifted (reflection!.sub? class_loader object_class sub_class))] (if ? - (in {#/////analysis.Extension extension_name (list (/////analysis.text sub_class) objectA)}) + (in {/////analysis.#Extension extension_name (list (/////analysis.text sub_class) objectA)}) (/////analysis.except cannot_possibly_be_an_instance (format sub_class " !<= " object_class)))))])) (template [<name> <category> <parser>] [(def: .public (<name> mapping typeJ) (-> Mapping (Type <category>) (Operation .Type)) (case (|> typeJ ..signature (<text>.result (<parser> mapping))) - {#try.Success check} + {try.#Success check} (typeA.with_env check) - {#try.Failure error} + {try.#Failure error} (phase.failure error)))] [boxed_reflection_type Value luxT.boxed_type] @@ -880,19 +880,19 @@ superT (reflection_type mapping superJT)] (in [[super_name superT] (java/lang/Class::isAssignableFrom super_class target_class)]))) (case (java/lang/Class::getGenericSuperclass source_class) - {#.Some super} - (list& super (array.list #.None (java/lang/Class::getGenericInterfaces source_class))) + {.#Some super} + (list& super (array.list {.#None} (java/lang/Class::getGenericInterfaces source_class))) - #.None + {.#None} (if (java/lang/reflect/Modifier::isInterface (java/lang/Class::getModifiers source_class)) - {#.Item (:as java/lang/reflect/Type (ffi.class_for java/lang/Object)) - (array.list #.None (java/lang/Class::getGenericInterfaces source_class))} - (array.list #.None (java/lang/Class::getGenericInterfaces source_class))))))) + {.#Item (:as java/lang/reflect/Type (ffi.class_for java/lang/Object)) + (array.list {.#None} (java/lang/Class::getGenericInterfaces source_class))} + (array.list {.#None} (java/lang/Class::getGenericInterfaces source_class))))))) (def: (inheritance_candidate_parents class_loader fromT target_class toT fromC) (-> java/lang/ClassLoader .Type (java/lang/Class java/lang/Object) .Type Code (Operation (List [[Text .Type] Bit]))) (case fromT - (^ {#.Primitive _ (list& self_classT super_classT super_interfacesT+)}) + (^ {.#Primitive _ (list& self_classT super_classT super_interfacesT+)}) (monad.each phase.monad (function (_ superT) (do [! phase.monad] @@ -959,13 +959,13 @@ (case (|> candidate_parents (list.only product.right) (list\each product.left)) - {#.Item [next_name nextT] _} + {.#Item [next_name nextT] _} (recur [next_name nextT]) - #.End + {.#End} (in false)))))))))] (if can_cast? - (in {#/////analysis.Extension extension_name (list (/////analysis.text source_name) + (in {/////analysis.#Extension extension_name (list (/////analysis.text source_name) (/////analysis.text target_name) fromA)}) (/////analysis.except ..cannot_cast [fromT toT fromC]))) @@ -1001,7 +1001,7 @@ (not deprecated?)) fieldT (reflection_type luxT.fresh fieldJT) _ (typeA.infer fieldT)] - (in (<| {#/////analysis.Extension extension_name} + (in (<| {/////analysis.#Extension extension_name} (list (/////analysis.text class) (/////analysis.text field) (/////analysis.text (|> fieldJT ..reflection)))))))])) @@ -1025,7 +1025,7 @@ fieldT (reflection_type luxT.fresh fieldJT) valueA (typeA.with_type fieldT (analyse archive valueC))] - (in (<| {#/////analysis.Extension extension_name} + (in (<| {/////analysis.#Extension extension_name} (list (/////analysis.text class) (/////analysis.text field) valueA)))))])) @@ -1049,7 +1049,7 @@ (not deprecated?)) fieldT (reflection_type mapping fieldJT) _ (typeA.infer fieldT)] - (in (<| {#/////analysis.Extension extension_name} + (in (<| {/////analysis.#Extension extension_name} (list (/////analysis.text class) (/////analysis.text field) (/////analysis.text (..reflection fieldJT)) @@ -1078,7 +1078,7 @@ fieldT (reflection_type mapping fieldJT) valueA (typeA.with_type fieldT (analyse archive valueC))] - (in (<| {#/////analysis.Extension extension_name} + (in (<| {/////analysis.#Extension extension_name} (list (/////analysis.text class) (/////analysis.text field) (/////analysis.text (..reflection fieldJT)) @@ -1087,30 +1087,30 @@ (type: Method_Style (Variant - #Static - #Abstract - #Virtual - #Special - #Interface)) + {#Static} + {#Abstract} + {#Virtual} + {#Special} + {#Interface})) (def: (check_method aliasing class method_name method_style inputsJT method) (-> Aliasing (java/lang/Class java/lang/Object) Text Method_Style (List (Type Value)) java/lang/reflect/Method (Operation Bit)) (do phase.monad [parameters (|> (java/lang/reflect/Method::getGenericParameterTypes method) - (array.list #.None) + (array.list {.#None}) (monad.each try.monad reflection!.type) phase.lifted) .let [modifiers (java/lang/reflect/Method::getModifiers method) correct_class? (java/lang/Object::equals class (java/lang/reflect/Method::getDeclaringClass method)) correct_method? (text\= method_name (java/lang/reflect/Method::getName method)) static_matches? (case method_style - #Static + {#Static} (java/lang/reflect/Modifier::isStatic modifiers) _ true) special_matches? (case method_style - #Special + {#Special} (not (or (java/lang/reflect/Modifier::isInterface (java/lang/Class::getModifiers class)) (java/lang/reflect/Modifier::isAbstract modifiers))) @@ -1122,13 +1122,13 @@ (and prev (jvm\= expectedJC (: (Type Value) (case (jvm_parser.var? actualJC) - {#.Some name} + {.#Some name} (|> aliasing (dictionary.value name) (maybe.else name) jvm.var) - #.None + {.#None} actualJC))))) true (list.zipped/2 parameters inputsJT)))]] @@ -1143,7 +1143,7 @@ (-> Aliasing (java/lang/Class java/lang/Object) (List (Type Value)) (java/lang/reflect/Constructor java/lang/Object) (Operation Bit)) (do phase.monad [parameters (|> (java/lang/reflect/Constructor::getGenericParameterTypes constructor) - (array.list #.None) + (array.list {.#None}) (monad.each try.monad reflection!.type) phase.lifted)] (in (and (java/lang/Object::equals class (java/lang/reflect/Constructor::getDeclaringClass constructor)) @@ -1151,19 +1151,19 @@ (list.every? (function (_ [expectedJC actualJC]) (jvm\= expectedJC (: (Type Value) (case (jvm_parser.var? actualJC) - {#.Some name} + {.#Some name} (|> aliasing (dictionary.value name) (maybe.else name) jvm.var) - #.None + {.#None} actualJC)))) (list.zipped/2 parameters inputsJT)))))) (def: index_parameter (-> Nat .Type) - (|>> (n.* 2) ++ #.Parameter)) + (|>> (n.* 2) ++ {.#Parameter})) (def: (jvm_type_var_mapping owner_tvars method_tvars) (-> (List Text) (List Text) [(List .Type) Mapping]) @@ -1183,20 +1183,20 @@ (-> Method_Style java/lang/reflect/Method (Operation Method_Signature)) (let [owner (java/lang/reflect/Method::getDeclaringClass method) owner_tvars (case method_style - #Static + {#Static} (list) _ (|> (java/lang/Class::getTypeParameters owner) - (array.list #.None) + (array.list {.#None}) (list\each (|>> java/lang/reflect/TypeVariable::getName)))) method_tvars (|> (java/lang/reflect/Method::getTypeParameters method) - (array.list #.None) + (array.list {.#None}) (list\each (|>> java/lang/reflect/TypeVariable::getName))) [owner_tvarsT mapping] (jvm_type_var_mapping owner_tvars method_tvars)] (do [! phase.monad] [inputsT (|> (java/lang/reflect/Method::getGenericParameterTypes method) - (array.list #.None) + (array.list {.#None}) (monad.each ! (|>> reflection!.type phase.lifted)) (phase\each (monad.each ! (..reflection_type mapping))) phase\conjoint) @@ -1207,17 +1207,17 @@ (phase\each (..reflection_return mapping)) phase\conjoint) exceptionsT (|> (java/lang/reflect/Method::getGenericExceptionTypes method) - (array.list #.None) + (array.list {.#None}) (monad.each ! (|>> reflection!.type phase.lifted)) (phase\each (monad.each ! (..reflection_type mapping))) phase\conjoint) .let [methodT (<| (type.univ_q (dictionary.size mapping)) (type.function (case method_style - #Static + {#Static} inputsT _ - (list& {#.Primitive (java/lang/Class::getName owner) owner_tvarsT} + (list& {.#Primitive (java/lang/Class::getName owner) owner_tvarsT} inputsT))) outputT)]] (in [methodT @@ -1228,24 +1228,24 @@ (-> (java/lang/reflect/Constructor java/lang/Object) (Operation Method_Signature)) (let [owner (java/lang/reflect/Constructor::getDeclaringClass constructor) owner_tvars (|> (java/lang/Class::getTypeParameters owner) - (array.list #.None) + (array.list {.#None}) (list\each (|>> java/lang/reflect/TypeVariable::getName))) method_tvars (|> (java/lang/reflect/Constructor::getTypeParameters constructor) - (array.list #.None) + (array.list {.#None}) (list\each (|>> java/lang/reflect/TypeVariable::getName))) [owner_tvarsT mapping] (jvm_type_var_mapping owner_tvars method_tvars)] (do [! phase.monad] [inputsT (|> (java/lang/reflect/Constructor::getGenericParameterTypes constructor) - (array.list #.None) + (array.list {.#None}) (monad.each ! (|>> reflection!.type phase.lifted)) (phase\each (monad.each ! (reflection_type mapping))) phase\conjoint) exceptionsT (|> (java/lang/reflect/Constructor::getGenericExceptionTypes constructor) - (array.list #.None) + (array.list {.#None}) (monad.each ! (|>> reflection!.type phase.lifted)) (phase\each (monad.each ! (reflection_type mapping))) phase\conjoint) - .let [objectT {#.Primitive (java/lang/Class::getName owner) owner_tvarsT} + .let [objectT {.#Primitive (java/lang/Class::getName owner) owner_tvarsT} constructorT (<| (type.univ_q (dictionary.size mapping)) (type.function inputsT) objectT)]] @@ -1262,10 +1262,10 @@ [(def: <name> (-> Evaluation (Maybe Method_Signature)) (|>> (case> {<tag> output} - {#.Some output} + {.#Some output} _ - #.None)))] + {.#None})))] [pass! #Pass] [hint! #Hint] @@ -1275,7 +1275,7 @@ [(def: <name> (-> <type> (List (Type Var))) (|>> <method> - (array.list #.None) + (array.list {.#None}) (list\each (|>> java/lang/reflect/TypeVariable::getName jvm.var))))] [class_type_variables (java/lang/Class java/lang/Object) java/lang/Class::getTypeParameters] @@ -1296,7 +1296,7 @@ .let [expected_class_tvars (class_type_variables class)] candidates (|> class java/lang/Class::getDeclaredMethods - (array.list #.None) + (array.list {.#None}) (list.only (|>> java/lang/reflect/Method::getName (text\= method_name))) (monad.each ! (: (-> java/lang/reflect/Method (Operation Evaluation)) (function (_ method) @@ -1306,14 +1306,14 @@ (..aliasing expected_method_tvars actual_method_tvars))] passes? (check_method aliasing class method_name method_style inputsJT method)] (\ ! each (if passes? - (|>> #Pass) - (|>> #Hint)) + (|>> {#Pass}) + (|>> {#Hint})) (method_signature method_style method)))))))] (case (list.all pass! candidates) - {#.Item method #.End} + {.#Item method {.#End}} (in method) - #.End + {.#End} (/////analysis.except ..no_candidates [class_name method_name inputsJT (list.all hint! candidates)]) candidates @@ -1329,7 +1329,7 @@ .let [expected_class_tvars (class_type_variables class)] candidates (|> class java/lang/Class::getConstructors - (array.list #.None) + (array.list {.#None}) (monad.each ! (function (_ constructor) (do ! [.let [expected_method_tvars (constructor_type_variables constructor) @@ -1337,13 +1337,15 @@ (..aliasing expected_method_tvars actual_method_tvars))] passes? (check_constructor aliasing class inputsJT constructor)] (\ ! each - (if passes? (|>> #Pass) (|>> #Hint)) + (if passes? + (|>> {#Pass}) + (|>> {#Hint})) (constructor_signature constructor))))))] (case (list.all pass! candidates) - {#.Item constructor #.End} + {.#Item constructor {.#End}} (in constructor) - #.End + {.#End} (/////analysis.except ..no_candidates [class_name ..constructor_method inputsJT (list.all hint! candidates)]) candidates @@ -1382,12 +1384,12 @@ (do phase.monad [_ (..ensure_fresh_class! class_loader class) .let [argsT (list\each product.left argsTC)] - [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class method_tvars method #Static argsT) + [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class method_tvars method {#Static} argsT) _ (phase.assertion ..deprecated_method [class method methodT] (not deprecated?)) [outputT argsA] (inferenceA.general archive analyse methodT (list\each product.right argsTC)) outputJT (check_return outputT)] - (in {#/////analysis.Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) + (in {/////analysis.#Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) (/////analysis.text method) (/////analysis.text (..signature outputJT)) (decorate_inputs argsT argsA))})))])) @@ -1400,18 +1402,18 @@ (do phase.monad [_ (..ensure_fresh_class! class_loader class) .let [argsT (list\each product.left argsTC)] - [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class method_tvars method #Virtual argsT) + [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class method_tvars method {#Virtual} argsT) _ (phase.assertion ..deprecated_method [class method methodT] (not deprecated?)) [outputT allA] (inferenceA.general archive analyse methodT (list& objectC (list\each product.right argsTC))) .let [[objectA argsA] (case allA - {#.Item objectA argsA} + {.#Item objectA argsA} [objectA argsA] _ (undefined))] outputJT (check_return outputT)] - (in {#/////analysis.Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) + (in {/////analysis.#Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) (/////analysis.text method) (/////analysis.text (..signature outputJT)) objectA @@ -1425,12 +1427,12 @@ (do phase.monad [_ (..ensure_fresh_class! class_loader class) .let [argsT (list\each product.left argsTC)] - [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class method_tvars method #Special argsT) + [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class method_tvars method {#Special} argsT) _ (phase.assertion ..deprecated_method [class method methodT] (not deprecated?)) [outputT argsA] (inferenceA.general archive analyse methodT (list& objectC (list\each product.right argsTC))) outputJT (check_return outputT)] - (in {#/////analysis.Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) + (in {/////analysis.#Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) (/////analysis.text method) (/////analysis.text (..signature outputJT)) (decorate_inputs argsT argsA))})))])) @@ -1446,18 +1448,18 @@ class (phase.lifted (reflection!.load class_loader class_name)) _ (phase.assertion non_interface class_name (java/lang/reflect/Modifier::isInterface (java/lang/Class::getModifiers class))) - [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class_name method_tvars method #Interface argsT) + [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class_name method_tvars method {#Interface} argsT) _ (phase.assertion ..deprecated_method [class_name method methodT] (not deprecated?)) [outputT allA] (inferenceA.general archive analyse methodT (list& objectC (list\each product.right argsTC))) .let [[objectA argsA] (case allA - {#.Item objectA argsA} + {.#Item objectA argsA} [objectA argsA] _ (undefined))] outputJT (check_return outputT)] - (in {#/////analysis.Extension extension_name + (in {/////analysis.#Extension extension_name (list& (/////analysis.text (..signature (jvm.class class_name (list)))) (/////analysis.text method) (/////analysis.text (..signature outputJT)) @@ -1476,7 +1478,7 @@ _ (phase.assertion ..deprecated_method [class ..constructor_method methodT] (not deprecated?)) [outputT argsA] (inferenceA.general archive analyse methodT (list\each product.right argsTC))] - (in {#/////analysis.Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) + (in {/////analysis.#Extension extension_name (list& (/////analysis.text (..signature (jvm.class class (list)))) (decorate_inputs argsT argsA))})))])) (def: (bundle::member class_loader) @@ -1554,23 +1556,23 @@ (-> (java/lang/Class java/lang/Object) (Try (List [Text (Type Method)]))) (|>> java/lang/Class::getDeclaredMethods - (array.list #.None) + (array.list {.#None}) <only> (monad.each try.monad (function (_ method) (do [! try.monad] [.let [type_variables (|> (java/lang/reflect/Method::getTypeParameters method) - (array.list #.None) + (array.list {.#None}) (list\each (|>> java/lang/reflect/TypeVariable::getName jvm.var)))] inputs (|> (java/lang/reflect/Method::getGenericParameterTypes method) - (array.list #.None) + (array.list {.#None}) (monad.each ! reflection!.type)) return (|> method java/lang/reflect/Method::getGenericReturnType reflection!.return) exceptions (|> (java/lang/reflect/Method::getGenericExceptionTypes method) - (array.list #.None) + (array.list {.#None}) (monad.each ! reflection!.class))] (in [(java/lang/reflect/Method::getName method) (jvm.method [type_variables inputs return exceptions])]))))))] @@ -1607,10 +1609,10 @@ (type: .public Visibility (Variant - #Public - #Private - #Protected - #Default)) + {#Public} + {#Private} + {#Protected} + {#Default})) (type: .public Finality Bit) (type: .public Strictness Bit) @@ -1631,10 +1633,10 @@ (def: .public (visibility_analysis visibility) (-> Visibility Analysis) (/////analysis.text (case visibility - #Public ..public_tag - #Private ..private_tag - #Protected ..protected_tag - #Default ..default_tag))) + {#Public} ..public_tag + {#Private} ..private_tag + {#Protected} ..protected_tag + {#Default} ..default_tag))) (type: .public (Constructor a) [Visibility @@ -1693,7 +1695,7 @@ (in [name luxT]))) arguments) [scope bodyA] (|> arguments' - {#.Item [self_name selfT]} + {.#Item [self_name selfT]} list.reversed (list\mix scope.with_local (analyse archive body)) (typeA.with_type .Any) @@ -1707,7 +1709,7 @@ (/////analysis.tuple (list\each ..argument_analysis arguments)) (/////analysis.tuple (list\each class_analysis exceptions)) (/////analysis.tuple (list\each typed_analysis super_arguments)) - {#/////analysis.Function + {/////analysis.#Function (list\each (|>> /////analysis.variable) (scope.environment scope)) (/////analysis.tuple (list bodyA))} @@ -1769,7 +1771,7 @@ (in [name luxT]))) arguments) [scope bodyA] (|> arguments' - {#.Item [self_name selfT]} + {.#Item [self_name selfT]} list.reversed (list\mix scope.with_local (analyse archive body)) (typeA.with_type returnT) @@ -1785,7 +1787,7 @@ (/////analysis.tuple (list\each ..argument_analysis arguments)) (return_analysis return) (/////analysis.tuple (list\each class_analysis exceptions)) - {#/////analysis.Function + {/////analysis.#Function (list\each (|>> /////analysis.variable) (scope.environment scope)) (/////analysis.tuple (list bodyA))} @@ -1857,7 +1859,7 @@ (return_analysis return) (/////analysis.tuple (list\each class_analysis exceptions)) - {#/////analysis.Function + {/////analysis.#Function (list\each (|>> /////analysis.variable) (scope.environment scope)) (/////analysis.tuple (list bodyA))} @@ -1914,10 +1916,10 @@ (case (list.one (function (_ super) (let [[super_name super_parameters] (jvm_parser.read_class super)] (if (text\= parent_name super_name) - {#.Some super_parameters} - #.None))) + {.#Some super_parameters} + {.#None}))) supers) - {#.Some super_parameters} + {.#Some super_parameters} (let [expected_count (list.size parent_parameters) actual_count (list.size super_parameters)] (if (n.= expected_count actual_count) @@ -1931,7 +1933,7 @@ (\ ! each (|>> (list.zipped/2 parent_parameters))))) (phase.lifted (exception.except ..mismatched_super_parameters [parent_name expected_count actual_count])))) - #.None + {.#None} (phase.lifted (exception.except ..unknown_super [parent_name supers]))))) (def: .public (with_fresh_type_vars vars mapping) @@ -1966,23 +1968,23 @@ bodyA 2 - {#/////analysis.Case (/////analysis.unit) - [[#/////analysis.when - {#/////analysis.Bind 2} + {/////analysis.#Case (/////analysis.unit) + [[/////analysis.#when + {/////analysis.#Bind 2} - #/////analysis.then + /////analysis.#then bodyA] (list)]} _ - {#/////analysis.Case (/////analysis.unit) - [[#/////analysis.when - {#/////analysis.Complex - {#/////analysis.Tuple (|> arity + {/////analysis.#Case (/////analysis.unit) + [[/////analysis.#when + {/////analysis.#Complex + {/////analysis.#Tuple (|> arity list.indices - (list\each (|>> (n.+ 2) #/////analysis.Bind)))}} + (list\each (|>> (n.+ 2) {/////analysis.#Bind})))}} - #/////analysis.then + /////analysis.#then bodyA] (list)]}))) @@ -2012,7 +2014,7 @@ arguments) returnT (boxed_reflection_return mapping return) [scope bodyA] (|> arguments' - {#.Item [self_name selfT]} + {.#Item [self_name selfT]} list.reversed (list\mix scope.with_local (analyse archive body)) (typeA.with_type returnT) @@ -2028,7 +2030,7 @@ (return_analysis return) (/////analysis.tuple (list\each class_analysis exceptions)) - {#/////analysis.Function + {/////analysis.#Function (list\each (|>> /////analysis.variable) (scope.environment scope)) (..hide_method_body (list.size arguments) bodyA)} @@ -2074,7 +2076,7 @@ [.let [[name actual_parameters] (jvm_parser.read_class class)] class (phase.lifted (reflection!.load class_loader name)) .let [expected_parameters (|> (java/lang/Class::getTypeParameters class) - (array.list #.None) + (array.list {.#None}) (list\each (|>> java/lang/reflect/TypeVariable::getName)))] _ (phase.assertion ..class_parameter_mismatch [expected_parameters actual_parameters] (n.= (list.size expected_parameters) @@ -2082,10 +2084,10 @@ (in (|> (list.zipped/2 expected_parameters actual_parameters) (list\mix (function (_ [expected actual] mapping) (case (jvm_parser.var? actual) - {#.Some actual} + {.#Some actual} (dictionary.has actual expected mapping) - #.None + {.#None} mapping)) jvm_alias.fresh))))) @@ -2154,7 +2156,7 @@ selfT (///.lifted (do meta.monad [where meta.current_module_name id meta.seed] - (in (inheritance_relationship_type {#.Primitive (..anonymous_class_name where id) (list)} + (in (inheritance_relationship_type {.#Primitive (..anonymous_class_name where id) (list)} super_classT super_interfaceT+)))) _ (typeA.infer selfT) @@ -2165,10 +2167,10 @@ (analyse archive term))] (in [type termA]))) constructor_args) - .let [supers {#.Item super_class super_interfaces}] + .let [supers {.#Item super_class super_interfaces}] _ (..require_complete_method_concretion class_loader supers methods) methodsA (monad.each ! (analyse_overriden_method analyse archive selfT mapping supers) methods)] - (in {#/////analysis.Extension extension_name + (in {/////analysis.#Extension extension_name (list (class_analysis super_class) (/////analysis.tuple (list\each class_analysis super_interfaces)) (/////analysis.tuple (list\each typed_analysis constructor_argsA+)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux index c9c1dfb0b..beb9ac7c4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux @@ -50,7 +50,7 @@ (phase archive lengthC)) [var_id varT] (analysis/type.with_env check.var) _ (analysis/type.infer (type (Array varT)))] - (in {#analysis.Extension extension (list lengthA)})))])) + (in {analysis.#Extension extension (list lengthA)})))])) (def: array::length Handler @@ -62,7 +62,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer Nat)] - (in {#analysis.Extension extension (list arrayA)})))])) + (in {analysis.#Extension extension (list arrayA)})))])) (def: array::read Handler @@ -76,7 +76,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer varT)] - (in {#analysis.Extension extension (list indexA arrayA)})))])) + (in {analysis.#Extension extension (list indexA arrayA)})))])) (def: array::write Handler @@ -92,7 +92,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in {#analysis.Extension extension (list indexA valueA arrayA)})))])) + (in {analysis.#Extension extension (list indexA valueA arrayA)})))])) (def: array::delete Handler @@ -106,7 +106,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in {#analysis.Extension extension (list indexA arrayA)})))])) + (in {analysis.#Extension extension (list indexA arrayA)})))])) (def: bundle::array Bundle @@ -128,7 +128,7 @@ [objectA (analysis/type.with_type ..Object (phase archive objectC)) _ (analysis/type.infer .Any)] - (in {#analysis.Extension extension (list (analysis.text fieldC) + (in {analysis.#Extension extension (list (analysis.text fieldC) objectA)})))])) (def: object::do @@ -141,7 +141,7 @@ (phase archive objectC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] - (in {#analysis.Extension extension (list& (analysis.text methodC) + (in {analysis.#Extension extension (list& (analysis.text methodC) objectA inputsA)})))])) @@ -165,7 +165,7 @@ [inputA (analysis/type.with_type (type <fromT>) (phase archive inputC)) _ (analysis/type.infer (type <toT>))] - (in {#analysis.Extension extension (list inputA)})))]))] + (in {analysis.#Extension extension (list inputA)})))]))] [utf8::encode Text (array.Array (I64 Any))] [utf8::decode (array.Array (I64 Any)) Text] @@ -186,7 +186,7 @@ (function (_ extension phase archive name) (do phase.monad [_ (analysis/type.infer Any)] - (in {#analysis.Extension extension (list (analysis.text name))})))])) + (in {analysis.#Extension extension (list (analysis.text name))})))])) (def: lua::apply Handler @@ -198,7 +198,7 @@ (phase archive abstractionC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] - (in {#analysis.Extension extension (list& abstractionA inputsA)})))])) + (in {analysis.#Extension extension (list& abstractionA inputsA)})))])) (def: lua::power Handler @@ -211,7 +211,7 @@ baseA (analysis/type.with_type Frac (phase archive baseC)) _ (analysis/type.infer Frac)] - (in {#analysis.Extension extension (list powerA baseA)})))])) + (in {analysis.#Extension extension (list powerA baseA)})))])) (def: lua::import Handler @@ -220,7 +220,7 @@ (function (_ extension phase archive name) (do phase.monad [_ (analysis/type.infer ..Object)] - (in {#analysis.Extension extension (list (analysis.text name))})))])) + (in {analysis.#Extension extension (list (analysis.text name))})))])) (def: lua::function Handler @@ -232,7 +232,7 @@ abstractionA (analysis/type.with_type (-> inputT Any) (phase archive abstractionC)) _ (analysis/type.infer ..Function)] - (in {#analysis.Extension extension (list (analysis.nat arity) + (in {analysis.#Extension extension (list (analysis.nat arity) abstractionA)})))])) (def: .public bundle diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux index 0609bee0a..e1c23ed0d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux @@ -41,10 +41,10 @@ Handler)) (function (_ extension_name analyse archive args) (case (<code>.result syntax args) - {#try.Success inputs} + {try.#Success inputs} (handler extension_name analyse archive inputs) - {#try.Failure _} + {try.#Failure _} (////analysis.except ///.invalid_syntax [extension_name %.code args])))) (def: (simple inputsT+ outputT) @@ -60,7 +60,7 @@ (typeA.with_type argT (analyse archive argC))) (list.zipped/2 inputsT+ args))] - (in {#////analysis.Extension extension_name argsA})) + (in {////analysis.#Extension extension_name argsA})) (////analysis.except ///.incorrect_arity [extension_name num_expected num_actual])))))) (def: .public (nullary valueT) @@ -119,7 +119,7 @@ (list (////analysis.tuple (list\each (|>> ////analysis.nat) cases)) branch)))) (list& input else) - {#////analysis.Extension extension_name}))))]))) + {////analysis.#Extension extension_name}))))]))) ... "lux is" represents reference/pointer equality. (def: lux::is @@ -142,7 +142,7 @@ _ (typeA.infer (type (Either Text varT))) opA (typeA.with_type (type (-> .Any varT)) (analyse archive opC))] - (in {#////analysis.Extension extension_name (list opA)})) + (in {////analysis.#Extension extension_name (list opA)})) _ (////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) @@ -151,7 +151,7 @@ Handler (function (_ extension_name analyse archive argsC+) (case argsC+ - (^ (list [_ {#.Text module_name}] exprC)) + (^ (list [_ {.#Text module_name}] exprC)) (////analysis.with_current_module module_name (analyse archive exprC)) @@ -214,15 +214,15 @@ (do ! [input_type (///.lifted (meta.definition (name_of .Macro')))] (case input_type - (^or {#.Definition [exported? def_type def_value]} - {#.Type [exported? def_value labels]}) + (^or {.#Definition [exported? def_type def_value]} + {.#Type [exported? def_value labels]}) (in (:as Type def_value)) - (^or {#.Label _} - {#.Slot _}) + (^or {.#Label _} + {.#Slot _}) (////.failure (exception.error ..not_a_type [(name_of .Macro')])) - {#.Alias real_name} + {.#Alias real_name} (recur real_name))))] (typeA.with_type input_type (phase archive valueC))))])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux index 16717539b..0aa12b4be 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux @@ -38,7 +38,7 @@ (phase archive lengthC)) [var_id varT] (analysis/type.with_env check.var) _ (analysis/type.infer (type (Array varT)))] - (in {#analysis.Extension extension (list lengthA)})))])) + (in {analysis.#Extension extension (list lengthA)})))])) (def: array::length Handler @@ -50,7 +50,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer Nat)] - (in {#analysis.Extension extension (list arrayA)})))])) + (in {analysis.#Extension extension (list arrayA)})))])) (def: array::read Handler @@ -64,7 +64,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer varT)] - (in {#analysis.Extension extension (list indexA arrayA)})))])) + (in {analysis.#Extension extension (list indexA arrayA)})))])) (def: array::write Handler @@ -80,7 +80,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in {#analysis.Extension extension (list indexA valueA arrayA)})))])) + (in {analysis.#Extension extension (list indexA valueA arrayA)})))])) (def: array::delete Handler @@ -94,7 +94,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in {#analysis.Extension extension (list indexA arrayA)})))])) + (in {analysis.#Extension extension (list indexA arrayA)})))])) (def: bundle::array Bundle @@ -127,7 +127,7 @@ (do [! phase.monad] [inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] - (in {#analysis.Extension extension (list& (analysis.text constructor) inputsA)})))])) + (in {analysis.#Extension extension (list& (analysis.text constructor) inputsA)})))])) (def: object::get Handler @@ -138,7 +138,7 @@ [objectA (analysis/type.with_type ..Object (phase archive objectC)) _ (analysis/type.infer .Any)] - (in {#analysis.Extension extension (list (analysis.text fieldC) + (in {analysis.#Extension extension (list (analysis.text fieldC) objectA)})))])) (def: object::do @@ -151,7 +151,7 @@ (phase archive objectC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] - (in {#analysis.Extension extension (list& (analysis.text methodC) + (in {analysis.#Extension extension (list& (analysis.text methodC) objectA inputsA)})))])) @@ -173,7 +173,7 @@ (function (_ extension phase archive name) (do phase.monad [_ (analysis/type.infer Any)] - (in {#analysis.Extension extension (list (analysis.text name))})))])) + (in {analysis.#Extension extension (list (analysis.text name))})))])) (def: php::apply Handler @@ -185,7 +185,7 @@ (phase archive abstractionC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] - (in {#analysis.Extension extension (list& abstractionA inputsA)})))])) + (in {analysis.#Extension extension (list& abstractionA inputsA)})))])) (def: php::pack Handler @@ -198,7 +198,7 @@ dataA (analysis/type.with_type (type (Array (I64 Any))) (phase archive dataC)) _ (analysis/type.infer Text)] - (in {#analysis.Extension extension (list formatA dataA)})))])) + (in {analysis.#Extension extension (list formatA dataA)})))])) (def: .public bundle Bundle diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux index ec21b45bc..385150e03 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux @@ -38,7 +38,7 @@ (phase archive lengthC)) [var_id varT] (analysis/type.with_env check.var) _ (analysis/type.infer (type (Array varT)))] - (in {#analysis.Extension extension (list lengthA)})))])) + (in {analysis.#Extension extension (list lengthA)})))])) (def: array::length Handler @@ -50,7 +50,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer Nat)] - (in {#analysis.Extension extension (list arrayA)})))])) + (in {analysis.#Extension extension (list arrayA)})))])) (def: array::read Handler @@ -64,7 +64,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer varT)] - (in {#analysis.Extension extension (list indexA arrayA)})))])) + (in {analysis.#Extension extension (list indexA arrayA)})))])) (def: array::write Handler @@ -80,7 +80,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in {#analysis.Extension extension (list indexA valueA arrayA)})))])) + (in {analysis.#Extension extension (list indexA valueA arrayA)})))])) (def: array::delete Handler @@ -94,7 +94,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in {#analysis.Extension extension (list indexA arrayA)})))])) + (in {analysis.#Extension extension (list indexA arrayA)})))])) (def: bundle::array Bundle @@ -136,7 +136,7 @@ [objectA (analysis/type.with_type ..Object (phase archive objectC)) _ (analysis/type.infer .Any)] - (in {#analysis.Extension extension (list (analysis.text fieldC) + (in {analysis.#Extension extension (list (analysis.text fieldC) objectA)})))])) (def: object::do @@ -149,7 +149,7 @@ (phase archive objectC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] - (in {#analysis.Extension extension (list& (analysis.text methodC) + (in {analysis.#Extension extension (list& (analysis.text methodC) objectA inputsA)})))])) @@ -170,7 +170,7 @@ (function (_ extension phase archive name) (do phase.monad [_ (analysis/type.infer Any)] - (in {#analysis.Extension extension (list (analysis.text name))})))])) + (in {analysis.#Extension extension (list (analysis.text name))})))])) (def: python::import Handler @@ -179,7 +179,7 @@ (function (_ extension phase archive name) (do phase.monad [_ (analysis/type.infer ..Object)] - (in {#analysis.Extension extension (list (analysis.text name))})))])) + (in {analysis.#Extension extension (list (analysis.text name))})))])) (def: python::apply Handler @@ -191,7 +191,7 @@ (phase archive abstractionC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] - (in {#analysis.Extension extension (list& abstractionA inputsA)})))])) + (in {analysis.#Extension extension (list& abstractionA inputsA)})))])) (def: python::function Handler @@ -203,7 +203,7 @@ abstractionA (analysis/type.with_type (-> inputT Any) (phase archive abstractionC)) _ (analysis/type.infer ..Function)] - (in {#analysis.Extension extension (list (analysis.nat arity) + (in {analysis.#Extension extension (list (analysis.nat arity) abstractionA)})))])) (def: python::exec @@ -217,7 +217,7 @@ globalsA (analysis/type.with_type ..Dict (phase archive globalsC)) _ (analysis/type.infer .Any)] - (in {#analysis.Extension extension (list codeA globalsA)})))])) + (in {analysis.#Extension extension (list codeA globalsA)})))])) (def: .public bundle Bundle diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux index 525458cdd..7a8eda597 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux @@ -38,7 +38,7 @@ (phase archive lengthC)) [var_id varT] (analysis/type.with_env check.var) _ (analysis/type.infer (type (Array varT)))] - (in {#analysis.Extension extension (list lengthA)})))])) + (in {analysis.#Extension extension (list lengthA)})))])) (def: array::length Handler @@ -50,7 +50,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer Nat)] - (in {#analysis.Extension extension (list arrayA)})))])) + (in {analysis.#Extension extension (list arrayA)})))])) (def: array::read Handler @@ -64,7 +64,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer varT)] - (in {#analysis.Extension extension (list indexA arrayA)})))])) + (in {analysis.#Extension extension (list indexA arrayA)})))])) (def: array::write Handler @@ -80,7 +80,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in {#analysis.Extension extension (list indexA valueA arrayA)})))])) + (in {analysis.#Extension extension (list indexA valueA arrayA)})))])) (def: array::delete Handler @@ -94,7 +94,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in {#analysis.Extension extension (list indexA arrayA)})))])) + (in {analysis.#Extension extension (list indexA arrayA)})))])) (def: bundle::array Bundle @@ -128,7 +128,7 @@ [objectA (analysis/type.with_type ..Object (phase archive objectC)) _ (analysis/type.infer .Any)] - (in {#analysis.Extension extension (list (analysis.text fieldC) + (in {analysis.#Extension extension (list (analysis.text fieldC) objectA)})))])) (def: object::do @@ -141,7 +141,7 @@ (phase archive objectC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer .Any)] - (in {#analysis.Extension extension (list& (analysis.text methodC) + (in {analysis.#Extension extension (list& (analysis.text methodC) objectA inputsA)})))])) @@ -162,7 +162,7 @@ (function (_ extension phase archive name) (do phase.monad [_ (analysis/type.infer Any)] - (in {#analysis.Extension extension (list (analysis.text name))})))])) + (in {analysis.#Extension extension (list (analysis.text name))})))])) (def: ruby::apply Handler @@ -174,7 +174,7 @@ (phase archive abstractionC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] - (in {#analysis.Extension extension (list& abstractionA inputsA)})))])) + (in {analysis.#Extension extension (list& abstractionA inputsA)})))])) (def: ruby::import Handler @@ -183,7 +183,7 @@ (function (_ extension phase archive name) (do phase.monad [_ (analysis/type.infer Bit)] - (in {#analysis.Extension extension (list (analysis.text name))})))])) + (in {analysis.#Extension extension (list (analysis.text name))})))])) (def: .public bundle Bundle diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux index a0df81d93..1dd6d0ca0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux @@ -38,7 +38,7 @@ (phase archive lengthC)) [var_id varT] (analysis/type.with_env check.var) _ (analysis/type.infer (type (Array varT)))] - (in {#analysis.Extension extension (list lengthA)})))])) + (in {analysis.#Extension extension (list lengthA)})))])) (def: array::length Handler @@ -50,7 +50,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer Nat)] - (in {#analysis.Extension extension (list arrayA)})))])) + (in {analysis.#Extension extension (list arrayA)})))])) (def: array::read Handler @@ -64,7 +64,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer varT)] - (in {#analysis.Extension extension (list indexA arrayA)})))])) + (in {analysis.#Extension extension (list indexA arrayA)})))])) (def: array::write Handler @@ -80,7 +80,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in {#analysis.Extension extension (list indexA valueA arrayA)})))])) + (in {analysis.#Extension extension (list indexA valueA arrayA)})))])) (def: array::delete Handler @@ -94,7 +94,7 @@ arrayA (analysis/type.with_type (type (Array varT)) (phase archive arrayC)) _ (analysis/type.infer (type (Array varT)))] - (in {#analysis.Extension extension (list indexA arrayA)})))])) + (in {analysis.#Extension extension (list indexA arrayA)})))])) (def: bundle::array Bundle @@ -131,7 +131,7 @@ (function (_ extension phase archive name) (do phase.monad [_ (analysis/type.infer Any)] - (in {#analysis.Extension extension (list (analysis.text name))})))])) + (in {analysis.#Extension extension (list (analysis.text name))})))])) (def: scheme::apply Handler @@ -143,7 +143,7 @@ (phase archive abstractionC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.with_type Any)) inputsC) _ (analysis/type.infer Any)] - (in {#analysis.Extension extension (list& abstractionA inputsA)})))])) + (in {analysis.#Extension extension (list& abstractionA inputsA)})))])) (def: .public bundle Bundle diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux index 76c66e37d..a4c026cb4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux @@ -171,9 +171,9 @@ (def: (constraint name) (-> Text Constraint) - [#type.name name - #type.super_class (type.class "java.lang.Object" (list)) - #type.super_interfaces (list)]) + [type.#name name + type.#super_class (type.class "java.lang.Object" (list)) + type.#super_interfaces (list)]) (def: constant::modifier (Modifier field.Field) @@ -194,15 +194,15 @@ [constant (`` (|> value (~~ (template.spliced <constant>)))) attribute (attribute.constant constant)] (field.field ..constant::modifier name <type> (row.row attribute)))]) - ([#.Bit type.boolean [(case> #0 +0 #1 +1) .i64 i32.i32 constant.integer pool.integer]] - [#.Int type.byte [.i64 i32.i32 constant.integer pool.integer]] - [#.Int type.short [.i64 i32.i32 constant.integer pool.integer]] - [#.Int type.int [.i64 i32.i32 constant.integer pool.integer]] - [#.Int type.long [constant.long pool.long]] - [#.Frac type.float [host.double_to_float constant.float pool.float]] - [#.Frac type.double [constant.double pool.double]] - [#.Nat type.char [.i64 i32.i32 constant.integer pool.integer]] - [#.Text (type.class "java.lang.String" (list)) [pool.string]] + ([.#Bit type.boolean [(case> #0 +0 #1 +1) .i64 i32.i32 constant.integer pool.integer]] + [.#Int type.byte [.i64 i32.i32 constant.integer pool.integer]] + [.#Int type.short [.i64 i32.i32 constant.integer pool.integer]] + [.#Int type.int [.i64 i32.i32 constant.integer pool.integer]] + [.#Int type.long [constant.long pool.long]] + [.#Frac type.float [host.double_to_float constant.float pool.float]] + [.#Frac type.double [constant.double pool.double]] + [.#Nat type.char [.i64 i32.i32 constant.integer pool.integer]] + [.#Text (type.class "java.lang.String" (list)) [pool.string]] ) ... TODO: Tighten this pattern-matching so this catch-all clause isn't necessary. @@ -275,13 +275,13 @@ (monad.each check.monad (|>> ..signature (luxT.check (luxT.class mapping))) super_interfaces))) - .let [selfT (jvm.inheritance_relationship_type {#.Primitive name (list\each product.right parameters)} + .let [selfT (jvm.inheritance_relationship_type {.#Primitive name (list\each product.right parameters)} super_classT super_interfaceT+)] state (extension.lifted phase.get_state) - .let [analyse (value@ [#directive.analysis #directive.phase] state) - synthesize (value@ [#directive.synthesis #directive.phase] state) - generate (value@ [#directive.generation #directive.phase] state)] + .let [analyse (value@ [directive.#analysis directive.#phase] state) + synthesize (value@ [directive.#synthesis directive.#phase] state) + generate (value@ [directive.#generation directive.#phase] state)] methods (monad.each ! (..method_definition [mapping selfT] [analyse synthesize generate]) methods) ... _ (directive.lifted_generation diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux index 95775c22a..fdd576cdc 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux @@ -54,10 +54,10 @@ (Handler anchor expression directive))) (function (_ extension_name phase archive inputs) (case (<code>.result syntax inputs) - {#try.Success inputs} + {try.#Success inputs} (handler extension_name phase archive inputs) - {#try.Failure error} + {try.#Failure error} (phase.except ///.invalid_syntax [extension_name %.code inputs])))) (def: (context [module_id artifact_id]) @@ -87,9 +87,9 @@ (-> Archive Type Code (Operation anchor expression directive [Type expression Any]))) (do phase.monad [state (///.lifted phase.get_state) - .let [analyse (value@ [#/////directive.analysis #/////directive.phase] state) - synthesize (value@ [#/////directive.synthesis #/////directive.phase] state) - generate (value@ [#/////directive.generation #/////directive.phase] state)] + .let [analyse (value@ [/////directive.#analysis /////directive.#phase] state) + synthesize (value@ [/////directive.#synthesis /////directive.#phase] state) + generate (value@ [/////directive.#generation /////directive.#phase] state)] [_ codeA] (/////directive.lifted_analysis (/////analysis.with_scope (typeA.with_fresh_env @@ -113,8 +113,8 @@ [codeG (generate archive codeS) id (/////generation.learn name) module_id (phase.lifted (archive.id module archive)) - [target_name value directive] (/////generation.define! [module_id id] #.None codeG) - _ (/////generation.save! id #.None directive)] + [target_name value directive] (/////generation.define! [module_id id] {.#None} codeG) + _ (/////generation.save! id {.#None} directive)] (in [code//type codeG value])))) (def: (definition archive name expected codeC) @@ -123,14 +123,14 @@ (Operation anchor expression directive [Type expression Any]))) (do [! phase.monad] [state (///.lifted phase.get_state) - .let [analyse (value@ [#/////directive.analysis #/////directive.phase] state) - synthesize (value@ [#/////directive.synthesis #/////directive.phase] state) - generate (value@ [#/////directive.generation #/////directive.phase] state)] + .let [analyse (value@ [/////directive.#analysis /////directive.#phase] state) + synthesize (value@ [/////directive.#synthesis /////directive.#phase] state) + generate (value@ [/////directive.#generation /////directive.#phase] state)] [_ code//type codeA] (/////directive.lifted_analysis (/////analysis.with_scope (typeA.with_fresh_env (case expected - #.None + {.#None} (do ! [[code//type codeA] (typeA.with_inference (analyse archive codeC)) @@ -138,7 +138,7 @@ (check.clean code//type))] (in [code//type codeA])) - {#.Some expected} + {.#Some expected} (do ! [codeA (typeA.with_type expected (analyse archive codeC))] @@ -165,8 +165,8 @@ [codeG (generate archive codeS) module_id (phase.lifted (archive.id current_module archive)) id (<learn> extension) - [target_name value directive] (/////generation.define! [module_id id] #.None codeG) - _ (/////generation.save! id #.None directive)] + [target_name value directive] (/////generation.define! [module_id id] {.#None} codeG) + _ (/////generation.save! id {.#None} directive)] (in [codeG value]))))) (def: .public (<full> archive extension codeT codeC) @@ -175,9 +175,9 @@ (Operation anchor expression directive [expression Any]))) (do phase.monad [state (///.lifted phase.get_state) - .let [analyse (value@ [#/////directive.analysis #/////directive.phase] state) - synthesize (value@ [#/////directive.synthesis #/////directive.phase] state) - generate (value@ [#/////directive.generation #/////directive.phase] state)] + .let [analyse (value@ [/////directive.#analysis /////directive.#phase] state) + synthesize (value@ [/////directive.#synthesis /////directive.#phase] state) + generate (value@ [/////directive.#generation /////directive.#phase] state)] [_ codeA] (/////directive.lifted_analysis (/////analysis.with_scope (typeA.with_fresh_env @@ -199,11 +199,11 @@ (do phase.monad [[bundle state] phase.get_state .let [eval (/////analysis/evaluation.evaluator expander - (value@ [#/////directive.synthesis #/////directive.state] state) - (value@ [#/////directive.generation #/////directive.state] state) - (value@ [#/////directive.generation #/////directive.phase] state))]] + (value@ [/////directive.#synthesis /////directive.#state] state) + (value@ [/////directive.#generation /////directive.#state] state) + (value@ [/////directive.#generation /////directive.#phase] state))]] (phase.set_state [bundle - (revised@ [#/////directive.analysis #/////directive.state] + (revised@ [/////directive.#analysis /////directive.#state] (: (-> /////analysis.State+ /////analysis.State+) (|>> product.right [(///analysis.bundle eval host_analysis)])) @@ -219,15 +219,15 @@ (-> Expander /////analysis.Bundle Handler) (function (_ extension_name phase archive inputsC+) (case inputsC+ - (^ (list [_ {#.Identifier ["" short_name]}] valueC exported?C)) + (^ (list [_ {.#Identifier ["" short_name]}] valueC exported?C)) (do phase.monad [current_module (/////directive.lifted_analysis (///.lifted meta.current_module_name)) .let [full_name [current_module short_name]] - [type valueT value] (..definition archive full_name #.None valueC) + [type valueT value] (..definition archive full_name {.#None} valueC) [_ _ exported?] (evaluate! archive Bit exported?C) _ (/////directive.lifted_analysis - (module.define short_name {#.Definition [(:as Bit exported?) type value]})) + (module.define short_name {.#Definition [(:as Bit exported?) type value]})) _ (..refresh expander host_analysis) _ (..announce_definition! short_name type)] (in /////directive.no_requirements)) @@ -241,7 +241,7 @@ (/////directive.lifted_generation (monad.each phase.monad (function (_ tag) - (/////generation.log! (format "#" tag " : Tag of " (%.type owner)))) + (/////generation.log! (format tag " : Tag of " (%.type owner)))) tags))) (def: (def::type_tagged expander host_analysis) @@ -258,23 +258,23 @@ .let [full_name [current_module short_name]] [_ _ exported?] (evaluate! archive Bit exported?C) .let [exported? (:as Bit exported?)] - [type valueT value] (..definition archive full_name {#.Some .Type} valueC) + [type valueT value] (..definition archive full_name {.#Some .Type} valueC) labels (/////directive.lifted_analysis (do phase.monad [.let [[record? labels] (case labels - {#.Left tags} + {.#Left tags} [false tags] - {#.Right slots} + {.#Right slots} [true slots])] _ (case labels - #.End - (module.define short_name {#.Definition [exported? type value]}) + {.#End} + (module.define short_name {.#Definition [exported? type value]}) - {#.Item labels} - (module.define short_name {#.Type [exported? (:as .Type value) (if record? - {#.Right labels} - {#.Left labels})]})) + {.#Item labels} + (module.define short_name {.#Type [exported? (:as .Type value) (if record? + {.#Right labels} + {.#Left labels})]})) _ (module.declare_tags record? labels exported? (:as .Type value))] (in labels))) _ (..refresh expander host_analysis) @@ -302,8 +302,8 @@ "" (in []) _ (module.alias alias module)))) imports))] - (in [#/////directive.imports imports - #/////directive.referrals (list)])))])) + (in [/////directive.#imports imports + /////directive.#referrals (list)])))])) (exception: .public (cannot_alias_an_alias [local Alias foreign Alias @@ -325,15 +325,15 @@ [current_module (///.lifted meta.current_module_name) constant (///.lifted (meta.definition original))] (case constant - {#.Alias de_aliased} + {.#Alias de_aliased} (phase.except ..cannot_alias_an_alias [[current_module alias] original de_aliased]) - (^or {#.Definition _} - {#.Type _}) - (module.define alias {#.Alias original}) + (^or {.#Definition _} + {.#Type _}) + (module.define alias {.#Alias original}) - (^or {#.Label _} - {#.Slot _}) + (^or {.#Label _} + {.#Slot _}) (phase.except ..cannot_alias_a_label [[current_module alias] original])))) (def: def::alias @@ -343,8 +343,8 @@ (function (_ extension_name phase archive [alias def_name]) (do phase.monad [_ (///.lifted - (phase.sub [(value@ [#/////directive.analysis #/////directive.state]) - (with@ [#/////directive.analysis #/////directive.state])] + (phase.sub [(value@ [/////directive.#analysis /////directive.#state]) + (with@ [/////directive.#analysis /////directive.#state])] (define_alias alias def_name)))] (in /////directive.no_requirements)))])) @@ -428,7 +428,7 @@ (do phase.monad [programG (generate archive programS) artifact_id (/////generation.learn /////program.name)] - (/////generation.save! artifact_id #.None (program [module_id artifact_id] programG)))) + (/////generation.save! artifact_id {.#None} (program [module_id artifact_id] programG)))) (def: (def::program program) (All (_ anchor expression directive) @@ -438,9 +438,9 @@ (^ (list programC)) (do phase.monad [state (///.lifted phase.get_state) - .let [analyse (value@ [#/////directive.analysis #/////directive.phase] state) - synthesize (value@ [#/////directive.synthesis #/////directive.phase] state) - generate (value@ [#/////directive.generation #/////directive.phase] state)] + .let [analyse (value@ [/////directive.#analysis /////directive.#phase] state) + synthesize (value@ [/////directive.#synthesis /////directive.#phase] state) + generate (value@ [/////directive.#generation /////directive.#phase] state)] programS (prepare_program archive analyse synthesize programC) current_module (/////directive.lifted_analysis (///.lifted meta.current_module_name)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux index 8c6df79fd..aec90687b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux @@ -45,10 +45,10 @@ Handler)) (function (_ extension_name phase archive input) (case (<s>.result parser input) - {#try.Success input'} + {try.#Success input'} (handler extension_name phase archive input') - {#try.Failure error} + {try.#Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) (template: (!unary function) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux index 54b345e36..de36c0766 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux @@ -45,10 +45,10 @@ Handler)) (function (_ extension_name phase archive input) (case (<s>.result parser input) - {#try.Success input'} + {try.#Success input'} (handler extension_name phase archive input') - {#try.Failure error} + {try.#Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) ... [Procedures] @@ -101,7 +101,7 @@ Phase! (case synthesis ... TODO: Get rid of this ASAP - {#synthesis.Extension "lux syntax char case!" parameters} + {synthesis.#Extension "lux syntax char case!" parameters} (do /////.monad [body (expression archive synthesis)] (in (:as Statement body))) @@ -121,8 +121,8 @@ (^template [<tag>] [(^ {<tag> value}) (/////\each _.return (expression archive synthesis))]) - ([#synthesis.Reference] - [#synthesis.Extension]) + ([synthesis.#Reference] + [synthesis.#Extension]) (^ (synthesis.branch/case case)) (//case.case! statement expression archive case) @@ -166,13 +166,13 @@ ... (in (_.apply/* (_.closure (list) ... (_.switch (_.the //runtime.i64_low_field inputG) ... conditionals! - ... {#.Some (_.return else!)})) + ... {.#Some (_.return else!)})) ... (list))) (in (<| (:as Expression) (: Statement) (_.switch (_.the //runtime.i64_low_field inputG) conditionals! - {#.Some else!})))))])) + {.#Some else!})))))])) ... [Bundles] (def: lux_procs diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux index f3efd5f47..cb63e2a33 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux @@ -49,10 +49,10 @@ Handler)) (function (_ extension_name phase archive input) (case (<s>.result parser input) - {#try.Success input'} + {try.#Success input'} (handler extension_name phase archive input') - {#try.Failure error} + {try.#Failure error} (/////.except /////extension.invalid_syntax [extension_name //////synthesis.%synthesis input])))) (def: $Boolean (type.class "java.lang.Boolean" (list))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux index b070a0a6b..8784ae034 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux @@ -339,15 +339,15 @@ (do <>.monad [arrayJT (<t>.then parser.array <s>.text)] (case (parser.array? arrayJT) - {#.Some elementJT} + {.#Some elementJT} (case (parser.object? elementJT) - {#.Some elementJT} + {.#Some elementJT} (in elementJT) - #.None + {.#None} (<>.failure (exception.error ..not_an_object_array arrayJT))) - #.None + {.#None} (undefined)))) (def: (primitive_array_length_handler jvm_primitive) @@ -644,10 +644,10 @@ (do //////.monad [.let [$class (type.class class (list))]] (case (dictionary.value unboxed ..primitives) - {#.Some primitive} + {.#Some primitive} (in (_.getstatic $class field primitive)) - #.None + {.#None} (in (_.getstatic $class field (type.class unboxed (list)))))))])) (def: unitG (_.string //////synthesis.unit)) @@ -661,13 +661,13 @@ [valueG (generate archive valueS) .let [$class (type.class class (list))]] (case (dictionary.value unboxed ..primitives) - {#.Some primitive} + {.#Some primitive} (in ($_ _.composite valueG (_.putstatic $class field primitive) ..unitG)) - #.None + {.#None} (in ($_ _.composite valueG (_.checkcast $class) @@ -683,10 +683,10 @@ [objectG (generate archive objectS) .let [$class (type.class class (list)) getG (case (dictionary.value unboxed ..primitives) - {#.Some primitive} + {.#Some primitive} (_.getfield $class field primitive) - #.None + {.#None} (_.getfield $class field (type.class unboxed (list))))]] (in ($_ _.composite objectG @@ -703,10 +703,10 @@ objectG (generate archive objectS) .let [$class (type.class class (list)) putG (case (dictionary.value unboxed ..primitives) - {#.Some primitive} + {.#Some primitive} (_.putfield $class field primitive) - #.None + {.#None} (let [$unboxed (type.class unboxed (list))] ($_ _.composite (_.checkcast $unboxed) @@ -729,10 +729,10 @@ (do //////.monad [valueG (generate archive valueS)] (case (type.primitive? valueT) - {#.Right valueT} + {.#Right valueT} (in [valueT valueG]) - {#.Left valueT} + {.#Left valueT} (in [valueT ($_ _.composite valueG (_.checkcast valueT))])))) @@ -740,10 +740,10 @@ (def: (prepare_output outputT) (-> (Type Return) (Bytecode Any)) (case (type.void? outputT) - {#.Right outputT} + {.#Right outputT} ..unitG - {#.Left outputT} + {.#Left outputT} (\ _.monad in []))) (def: invoke::static @@ -857,15 +857,15 @@ (^template [<tag>] [(^ {<tag> leftP rightP}) {<tag> (recur leftP) (recur rightP)}]) - ([#//////synthesis.Alt] - [#//////synthesis.Seq]) + ([//////synthesis.#Alt] + [//////synthesis.#Seq]) (^template [<tag>] - [(^ {<tag> value}) + [(^ {<tag> _}) path]) - ([#//////synthesis.Pop] - [#//////synthesis.Bind] - [#//////synthesis.Access]) + ([//////synthesis.#Pop] + [//////synthesis.#Bind] + [//////synthesis.#Access]) _ (undefined)))) @@ -877,7 +877,7 @@ (^template [<tag>] [(^ {<tag> value}) body]) - ([#//////synthesis.Primitive] + ([//////synthesis.#Primitive] [//////synthesis.constant]) (^ (//////synthesis.variant [lefts right? sub])) @@ -928,8 +928,8 @@ (^ (//////synthesis.function/apply [functionS inputsS+])) (//////synthesis.function/apply [(recur functionS) (list\each recur inputsS+)]) - {#//////synthesis.Extension [name inputsS+]} - {#//////synthesis.Extension [name (list\each recur inputsS+)]}))) + {//////synthesis.#Extension [name inputsS+]} + {//////synthesis.#Extension [name (list\each recur inputsS+)]}))) (def: $Object (type.class "java.lang.Object" (list))) @@ -952,7 +952,7 @@ (_.putfield class (///reference.foreign_name register) $Object)))))] (method.method method.public "<init>" (anonymous_init_method env) (list) - {#.Some ($_ _.composite + {.#Some ($_ _.composite (_.aload 0) (monad.each _.monad product.right inputsTG) (_.invokespecial super_class "<init>" (type.method [(list\each product.left inputsTG) type.void (list)])) @@ -972,17 +972,17 @@ (def: (returnG returnT) (-> (Type Return) (Bytecode Any)) (case (type.void? returnT) - {#.Right returnT} + {.#Right returnT} _.return - {#.Left returnT} + {.#Left returnT} (case (type.primitive? returnT) - {#.Left returnT} + {.#Left returnT} ($_ _.composite (_.checkcast returnT) _.areturn) - {#.Right returnT} + {.#Right returnT} (cond (or (\ type.equivalence = type.boolean returnT) (\ type.equivalence = type.byte returnT) (\ type.equivalence = type.short returnT) @@ -1027,7 +1027,7 @@ ... Give them names as "foreign" variables. list.enumeration (list\each (function (_ [id capture]) - [capture {#//////variable.Foreign id}])) + [capture {//////variable.#Foreign id}])) (dictionary.from_list //////variable.hash)) normalized_methods (list\each (function (_ [environment [ownerT name @@ -1037,7 +1037,7 @@ (let [local_mapping (|> environment list.enumeration (list\each (function (_ [foreign_id capture]) - [{#//////variable.Foreign foreign_id} + [{//////variable.#Foreign foreign_id} (|> global_mapping (dictionary.value capture) maybe.trusted)])) @@ -1066,7 +1066,7 @@ returnT exceptionsT]) (list) - {#.Some ($_ _.composite + {.#Some ($_ _.composite bodyG (returnG returnT))})))) normalized_methods) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux index 3523c19fa..1de9c4057 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux @@ -48,10 +48,10 @@ Handler)) (function (_ extension_name phase archive input) (case (<s>.result parser input) - {#try.Success input'} + {try.#Success input'} (handler extension_name phase archive input') - {#try.Failure error} + {try.#Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) (template: (!unary function) @@ -61,7 +61,7 @@ Phase! (case synthesis ... TODO: Get rid of this ASAP - {#synthesis.Extension "lux syntax char case!" parameters} + {synthesis.#Extension "lux syntax char case!" parameters} (do /////.monad [body (expression archive synthesis)] (in (:as Statement body))) @@ -81,8 +81,8 @@ (^template [<tag>] [(^ {<tag> value}) (/////\each _.return (expression archive synthesis))]) - ([#synthesis.Reference] - [#synthesis.Extension]) + ([synthesis.#Reference] + [synthesis.#Extension]) (^ (synthesis.branch/case case)) (//case.case! statement expression archive case) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux index 9a06cd980..131f8e57e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux @@ -45,10 +45,10 @@ Handler)) (function (_ extension_name phase archive input) (case (<s>.result parser input) - {#try.Success input'} + {try.#Success input'} (handler extension_name phase archive input') - {#try.Failure error} + {try.#Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) (template: (!unary function) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux index cbb7c557d..d06f428a6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux @@ -47,7 +47,7 @@ Phase! (case synthesis ... TODO: Get rid of this ASAP - {#synthesis.Extension "lux syntax char case!" parameters} + {synthesis.#Extension "lux syntax char case!" parameters} (do /////.monad [body (expression archive synthesis)] (in (:as (Statement Any) body))) @@ -67,8 +67,8 @@ (^template [<tag>] [(^ {<tag> value}) (/////\each _.return (expression archive synthesis))]) - ([#synthesis.Reference] - [#synthesis.Extension]) + ([synthesis.#Reference] + [synthesis.#Extension]) (^ (synthesis.branch/case case)) (//case.case! false statement expression archive case) @@ -92,10 +92,10 @@ Handler)) (function (_ extension_name phase archive input) (case (<synthesis>.result parser input) - {#try.Success input'} + {try.#Success input'} (handler extension_name phase archive input') - {#try.Failure error} + {try.#Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) ... TODO: Get rid of this ASAP @@ -128,7 +128,7 @@ ... .let [dependencies (//case.dependencies (list\mix (function (_ right left) ... (synthesis.path/seq left right)) ... (synthesis.path/then input) - ... {#.Item (synthesis.path/then else) + ... {.#Item (synthesis.path/then else) ... (list\each (|>> product.right ... synthesis.path/then) ... conditionals)})) @@ -141,7 +141,7 @@ ... else! ... conditionals!)))] ... _ (generation.execute! closure) - ... _ (generation.save! (product.right artifact_id) #.None closure) + ... _ (generation.save! (product.right artifact_id) {.#None} closure) ] ... (in (_.apply/* @closure dependencies)) (in (<| (:as (Expression Any)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux index 2e533b5bd..1db4fb268 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux @@ -45,10 +45,10 @@ Handler)) (function (_ extension_name phase archive input) (case (<s>.result parser input) - {#try.Success input'} + {try.#Success input'} (handler extension_name phase archive input') - {#try.Failure error} + {try.#Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) ... (template: (!unary function) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux index 6b6538363..f057e6e10 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux @@ -48,17 +48,17 @@ Handler)) (function (_ extension_name phase archive input) (case (<s>.result parser input) - {#try.Success input'} + {try.#Success input'} (handler extension_name phase archive input') - {#try.Failure error} + {try.#Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) (def: .public (statement expression archive synthesis) Phase! (case synthesis ... TODO: Get rid of this ASAP - {#synthesis.Extension "lux syntax char case!" parameters} + {synthesis.#Extension "lux syntax char case!" parameters} (do /////.monad [body (expression archive synthesis)] (in (:as Statement @@ -79,8 +79,8 @@ (^template [<tag>] [(^ {<tag> value}) (/////\each _.return (expression archive synthesis))]) - ([#synthesis.Reference] - [#synthesis.Extension]) + ([synthesis.#Reference] + [synthesis.#Extension]) (^ (synthesis.branch/case case)) (//case.case! false statement expression archive case) @@ -123,7 +123,7 @@ _.nil)) branch!]))) conditionals)) - ... .let [closure (_.lambda #.None (list @input) + ... .let [closure (_.lambda {.#None} (list @input) ... (list\mix (function (_ [test then] else) ... (_.if test (_.return then) else)) ... (_.return else!) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux index 7161326e1..e786087d1 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux @@ -45,10 +45,10 @@ Handler)) (function (_ extension_name phase archive input) (case (<s>.result parser input) - {#try.Success input'} + {try.#Success input'} (handler extension_name phase archive input') - {#try.Failure error} + {try.#Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) (template: (!unary function) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp.lux index 26a967a45..dca5d6673 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp.lux @@ -34,7 +34,7 @@ [////synthesis.f64 /primitive.f64] [////synthesis.text /primitive.text]) - {#////synthesis.Reference value} + {////synthesis.#Reference value} (//reference.reference /reference.system archive value) (^template [<tag> <generator>] @@ -52,6 +52,6 @@ [////synthesis.loop/recur /loop.recur] [////synthesis.function/abstraction /function.function]) - {#////synthesis.Extension extension} + {////synthesis.#Extension extension} (///extension.apply archive generate extension) )) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux index 5442b7268..ed9bd19a0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux @@ -68,8 +68,8 @@ (^template [<side> <accessor>] [(<side> lefts) (<accessor> (_.int (.int lefts)))]) - ([#.Left //runtime.tuple//left] - [#.Right //runtime.tuple//right]))] + ([.#Left //runtime.tuple//left] + [.#Right //runtime.tuple//right]))] (method source))) valueG pathP)))) @@ -117,10 +117,10 @@ (_.go @fail) (..push! @temp))) (.case next! - {#.Some next!} + {.#Some next!} (list next!) - #.None + {.#None} (list))))))] [left_choice _.nil (<|)] @@ -147,20 +147,20 @@ (_.go @done)))) (expression archive bodyS)) - #/////synthesis.Pop + {/////synthesis.#Pop} (///////phase\in ..pop!) - {#/////synthesis.Bind register} + {/////synthesis.#Bind register} (///////phase\in (_.setq (..register register) ..peek)) - {#/////synthesis.Bit_Fork when thenP elseP} + {/////synthesis.#Bit_Fork when thenP elseP} (do [! ///////phase.monad] [then! (recur [$output @done @fail thenP]) else! (.case elseP - {#.Some elseP} + {.#Some elseP} (recur [$output @done @fail elseP]) - #.None + {.#None} (in (_.go @fail)))] (in (.if when (_.if ..peek @@ -179,23 +179,23 @@ (in [(<=> [(|> match <format>) ..peek]) then!]))) - {#.Item item})] + {.#Item item})] (in (list\mix (function (_ [when then] else) (_.if when then else)) (_.go @fail) clauses)))]) - ([#/////synthesis.I64_Fork //primitive.i64 _.=/2] - [#/////synthesis.F64_Fork //primitive.f64 _.=/2] - [#/////synthesis.Text_Fork //primitive.text _.string=/2]) + ([/////synthesis.#I64_Fork //primitive.i64 _.=/2] + [/////synthesis.#F64_Fork //primitive.f64 _.=/2] + [/////synthesis.#Text_Fork //primitive.text _.string=/2]) (^template [<complex> <simple> <choice>] [(^ (<complex> idx)) - (///////phase\in (<choice> @fail false idx #.None)) + (///////phase\in (<choice> @fail false idx {.#None})) (^ (<simple> idx nextP)) (|> nextP [$output @done @fail] recur - (\ ///////phase.monad each (|>> {#.Some} (<choice> @fail true idx))))]) + (\ ///////phase.monad each (|>> {.#Some} (<choice> @fail true idx))))]) ([/////synthesis.side/left /////synthesis.simple_left_side ..left_choice] [/////synthesis.side/right /////synthesis.simple_right_side ..right_choice]) @@ -248,7 +248,7 @@ pattern_matching! (pattern_matching $output expression archive pathP) .let [storage (|> pathP ////synthesis/case.storage - (value@ #////synthesis/case.bindings) + (value@ ////synthesis/case.#bindings) set.list (list\each (function (_ register) [(..register register) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux index 5f38c7bad..3130f0121 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux @@ -43,7 +43,7 @@ (def: (with_closure inits function_definition) (-> (List (Expression Any)) (Expression Any) (Operation (Expression Any))) (case inits - #.End + {.#End} (\ ///////phase.monad in function_definition) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux index bae37c835..18bbc788e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux @@ -36,7 +36,7 @@ (Generator (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop - #.End + {.#End} (expression archive bodyS) ... true loop diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux index 1c7fd4877..2cee2de25 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux @@ -109,7 +109,7 @@ (let [runtime (code.local_identifier (///reference.artifact [..module_id runtime_id])) runtime_name (` (_.var (~ (code.text (%.code runtime)))))] (case declaration - {#.Left name} + {.#Left name} (let [g!name (code.local_identifier name) code_nameC (code.local_identifier (format "@" name))] (in (list (` (def: .public (~ g!name) @@ -120,7 +120,7 @@ (_.Expression Any) (_.defparameter (~ runtime_name) (~ code))))))) - {#.Right [name inputs]} + {.#Right [name inputs]} (let [g!name (code.local_identifier name) code_nameC (code.local_identifier (format "@" name)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux index 2a5fa7c1c..22ed7a7c6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux @@ -17,10 +17,10 @@ (def: .public (tuple expression archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ - #.End + {.#End} (///////phase\in (//primitive.text /////synthesis.unit)) - {#.Item singletonS #.End} + {.#Item singletonS {.#End}} (expression archive singletonS) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux index 65b06ce16..24db5395a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux @@ -49,7 +49,7 @@ (^ (synthesis.tuple members)) (/structure.tuple expression archive members) - {#synthesis.Reference value} + {synthesis.#Reference value} (//reference.reference /reference.system archive value) (^ (synthesis.branch/case case)) @@ -76,7 +76,7 @@ (^ (synthesis.function/apply application)) (/function.apply expression archive application) - {#synthesis.Extension extension} + {synthesis.#Extension extension} (///extension.apply archive expression extension))) (def: .public generate diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux index 8f98d44ab..246bcb54d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux @@ -82,8 +82,8 @@ (^template [<side> <accessor>] [(<side> lefts) (<accessor> (_.i32 (.int lefts)))]) - ([#.Left //runtime.tuple//left] - [#.Right //runtime.tuple//right]))] + ([.#Left //runtime.tuple//left] + [.#Right //runtime.tuple//right]))] (method source))) valueO (list.reversed pathP))))) @@ -166,12 +166,12 @@ [(^ (<simple> idx nextP)) (|> nextP recur - (\ ///////phase.monad each (|>> (_.then (<choice> true idx)) #.Some)))]) + (\ ///////phase.monad each (|>> (_.then (<choice> true idx)) {.#Some})))]) ([/////synthesis.simple_left_side ..left_choice] [/////synthesis.simple_right_side ..right_choice]) (^ (/////synthesis.member/left 0)) - (///////phase\in {#.Some (push_cursor! (_.at (_.i32 +0) ..peek_cursor))}) + (///////phase\in {.#Some (push_cursor! (_.at (_.i32 +0) ..peek_cursor))}) ... Extra optimization (^ (/////synthesis.path/seq @@ -179,7 +179,7 @@ (/////synthesis.!bind_top register thenP))) (do ///////phase.monad [then! (recur thenP)] - (in {#.Some ($_ _.then + (in {.#Some ($_ _.then (_.define (..register register) (_.at (_.i32 +0) ..peek_cursor)) then!)})) @@ -190,7 +190,7 @@ (/////synthesis.!bind_top register thenP))) (do ///////phase.monad [then! (recur thenP)] - (in {#.Some ($_ _.then + (in {.#Some ($_ _.then (_.define (..register register) (<getter> (_.i32 (.int lefts)) ..peek_cursor)) then!)}))]) ([/////synthesis.member/left //runtime.tuple//left] @@ -199,7 +199,7 @@ (^ (/////synthesis.!bind_top register thenP)) (do ///////phase.monad [then! (recur thenP)] - (in {#.Some ($_ _.then + (in {.#Some ($_ _.then (_.define (..register register) ..peek_and_pop_cursor) then!)})) @@ -207,12 +207,12 @@ (.let [[extra_pops nextP'] (////synthesis/case.count_pops nextP)] (do ///////phase.monad [next! (recur nextP')] - (in {#.Some ($_ _.then + (in {.#Some ($_ _.then (multi_pop_cursor! (n.+ 2 extra_pops)) next!)}))) _ - (///////phase\in #.None))) + (///////phase\in {.#None}))) (def: (pattern_matching' statement expression archive) (-> Phase! Phase Archive @@ -221,28 +221,28 @@ (do ///////phase.monad [outcome (optimized_pattern_matching recur pathP)] (.case outcome - {#.Some outcome} + {.#Some outcome} (in outcome) - #.None + {.#None} (.case pathP - {#/////synthesis.Then bodyS} + {/////synthesis.#Then bodyS} (statement expression archive bodyS) - #/////synthesis.Pop + {/////synthesis.#Pop} (///////phase\in pop_cursor!) - {#/////synthesis.Bind register} + {/////synthesis.#Bind register} (///////phase\in (_.define (..register register) ..peek_cursor)) - {#/////synthesis.Bit_Fork when thenP elseP} + {/////synthesis.#Bit_Fork when thenP elseP} (do [! ///////phase.monad] [then! (recur thenP) else! (.case elseP - {#.Some elseP} + {.#Some elseP} (recur elseP) - #.None + {.#None} (in ..fail_pm!))] (in (.if when (_.if ..peek_cursor @@ -252,7 +252,7 @@ else! then!)))) - {#/////synthesis.I64_Fork item} + {/////synthesis.#I64_Fork item} (do [! ///////phase.monad] [clauses (monad.each ! (function (_ [match then]) (do ! @@ -260,20 +260,20 @@ (in [(//runtime.i64//= (//primitive.i64 (.int match)) ..peek_cursor) then!]))) - {#.Item item})] + {.#Item item})] (in (_.cond clauses ..fail_pm!))) (^template [<tag> <format>] - [(<tag> item) + [{<tag> item} (do [! ///////phase.monad] [cases (monad.each ! (function (_ [match then]) (\ ! each (|>> [(list (<format> match))]) (recur then))) - {#.Item item})] + {.#Item item})] (in (_.switch ..peek_cursor cases - {#.Some ..fail_pm!})))]) - ([#/////synthesis.F64_Fork //primitive.f64] - [#/////synthesis.Text_Fork //primitive.text]) + {.#Some ..fail_pm!})))]) + ([/////synthesis.#F64_Fork //primitive.f64] + [/////synthesis.#Text_Fork //primitive.text]) (^template [<complex> <choice>] [(^ (<complex> idx)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux index f9e8d9c10..57083f023 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux @@ -41,7 +41,7 @@ (def: (with_closure @self inits body!) (-> Var (List Expression) Statement [Statement Expression]) (case inits - #.End + {.#End} [(_.function! @self (list) body!) @self] @@ -119,5 +119,5 @@ @self)))))))) ))] _ (/////generation.execute! definition) - _ (/////generation.save! (product.right function_name) #.None definition)] + _ (/////generation.save! (product.right function_name) {.#None} definition)] (in instantiation))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux index 52600eaeb..cde2c64a7 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux @@ -45,7 +45,7 @@ (Generator! (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop - #.End + {.#End} (statement expression archive bodyS) ... true loop @@ -64,7 +64,7 @@ (-> Phase! (Generator (Scope Synthesis))) (case initsS+ ... function/false/non-independent loop - #.End + {.#End} (expression archive bodyS) ... true loop diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux index f2be9fda5..b83068e2b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux @@ -104,7 +104,7 @@ (macro.with_identifiers [g!_ runtime] (let [runtime_name (` (_.var (~ (code.text (%.code runtime)))))] (case declaration - {#.Left name} + {.#Left name} (let [g!name (code.local_identifier name)] (in (list (` (def: .public (~ g!name) Var @@ -116,7 +116,7 @@ (function ((~ g!_) (~ g!name)) (~ code)))))))) - {#.Right [name inputs]} + {.#Right [name inputs]} (let [g!name (code.local_identifier name) inputsC (list\each code.local_identifier inputs) inputs_typesC (list\each (function.constant (` _.Expression)) inputs)] @@ -775,12 +775,12 @@ (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) - _ (/////generation.save! ..module_id #.None ..runtime)] + _ (/////generation.save! ..module_id {.#None} ..runtime)] (in [(|> artifact.empty artifact.resource product.right) (row.row [..module_id - #.None + {.#None} (|> ..runtime _.code (\ utf8.codec encoded))])]))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux index 88072200f..d5838b04b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux @@ -17,10 +17,10 @@ (def: .public (tuple generate archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ - #.End + {.#End} (///////phase\in //runtime.unit) - {#.Item singletonS #.End} + {.#Item singletonS {.#End}} (generate archive singletonS) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm.lux index 6a1a607cb..738700655 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm.lux @@ -36,12 +36,12 @@ (^ (synthesis.tuple members)) (/structure.tuple generate archive members) - {#synthesis.Reference reference} + {synthesis.#Reference reference} (case reference - {#reference.Variable variable} + {reference.#Variable variable} (/reference.variable archive variable) - {#reference.Constant constant} + {reference.#Constant constant} (/reference.constant archive constant)) (^ (synthesis.branch/case [valueS pathS])) @@ -68,6 +68,6 @@ (^ (synthesis.function/apply application)) (/function.apply generate archive application) - {#synthesis.Extension extension} + {synthesis.#Extension extension} (///extension.apply archive generate extension) )) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux index 2da725141..3493c8140 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux @@ -92,15 +92,15 @@ (def: (path' stack_depth @else @end phase archive path) (-> Nat Label Label (Generator Path)) (.case path - #synthesis.Pop + {synthesis.#Pop} (operation\in ..pop) - {#synthesis.Bind register} + {synthesis.#Bind register} (operation\in ($_ _.composite ..peek (_.astore register))) - {#synthesis.Then bodyS} + {synthesis.#Then bodyS} (do phase.monad [bodyG (phase archive bodyS)] (in ($_ _.composite @@ -171,7 +171,7 @@ ([synthesis.member/left //runtime.left_projection] [synthesis.member/right //runtime.right_projection]) - {#synthesis.Alt leftP rightP} + {synthesis.#Alt leftP rightP} (do phase.monad [@alt_else //runtime.forge_label left! (path' (++ stack_depth) @alt_else @end phase archive leftP) @@ -183,7 +183,7 @@ _.pop right!))) - {#synthesis.Seq leftP rightP} + {synthesis.#Seq leftP rightP} (do phase.monad [left! (path' stack_depth @else @end phase archive leftP) right! (path' stack_depth @else @end phase archive rightP)] @@ -243,10 +243,10 @@ [recordG (phase archive recordS)] (in (list\mix (function (_ step so_far) (.let [next (.case step - {#.Left lefts} + {.#Left lefts} (..left_projection lefts) - {#.Right lefts} + {.#Right lefts} (..right_projection lefts))] (_.composite so_far next))) recordG diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/debug.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/debug.lux index b0833504c..c0ab7b58d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/debug.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/debug.lux @@ -24,8 +24,8 @@ (file.get_file io.monad file.default file_path))] (\ file over_write bytecode))] (in (case outcome - {#try.Success definition} + {try.#Success definition} file_path - {#try.Failure error} + {try.#Failure error} error))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux index 0aa307c72..b046e78b8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux @@ -113,7 +113,7 @@ (row.row))) .let [bytecode (format.result class.writer class)] _ (generation.execute! [function_class bytecode]) - _ (generation.save! function_class #.None [function_class bytecode])] + _ (generation.save! function_class {.#None} [function_class bytecode])] (in instance))) (def: .public (apply generate archive [abstractionS inputsS]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux index 15a73026e..d9f9427a2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux @@ -85,7 +85,7 @@ (method.method //.modifier ////runtime.apply::name (////runtime.apply::type apply_arity) (list) - {#.Some (case num_partials + {.#Some (case num_partials 0 ($_ _.composite ////reference.this (..inputs ..this_offset apply_arity) @@ -97,7 +97,7 @@ @labelsT (|> _.new_label (list.repeated (-- num_partials)) (monad.all _.monad)) - .let [cases (|> (list\composite {#.Item [@labelsH @labelsT]} + .let [cases (|> (list\composite {.#Item [@labelsH @labelsT]} (list @default)) list.enumeration (list\each (function (_ [stage @case]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux index 723ff6ce5..9a77e6a62 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux @@ -31,7 +31,7 @@ (method.method //.modifier name (..type arity) (list) - {#.Some ($_ _.composite + {.#Some ($_ _.composite (_.set_label @begin) body _.areturn diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux index 91df54eca..ecddbaf46 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux @@ -94,7 +94,7 @@ (method.method //.modifier ..name (..type environment arity) (list) - {#.Some ($_ _.composite + {.#Some ($_ _.composite ////reference.this (..super environment_size arity) (store_all environment_size (///foreign.put class) offset_foreign) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux index 79926e5b8..105718c78 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux @@ -69,7 +69,7 @@ (method.method //.modifier //init.name (//init.type environment arity) (list) - {#.Some ($_ _.composite + {.#Some ($_ _.composite ////reference.this (//init.super environment_size arity) (monad.each _.monad (function (_ register) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux index b5bdb1e1d..791bca2f5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux @@ -43,7 +43,7 @@ (method.method //.modifier ..name (..type class) (list) - {#.Some ($_ _.composite + {.#Some ($_ _.composite (if (arity.multiary? arity) (//new.instance' (..current_environment class environment) class environment arity) ////reference.this) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux index 0ffbbceb3..e6db5b72c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux @@ -81,20 +81,20 @@ (def: (class_value class_name class) (-> Text (java/lang/Class java/lang/Object) (Try Any)) (case (java/lang/Class::getField ..value::field class) - {#try.Success field} - (case (java/lang/reflect/Field::get #.None field) - {#try.Success ?value} + {try.#Success field} + (case (java/lang/reflect/Field::get {.#None} field) + {try.#Success ?value} (case ?value - {#.Some value} - {#try.Success value} + {.#Some value} + {try.#Success value} - #.None + {.#None} (exception.except ..invalid_value [class_name])) - {#try.Failure error} + {try.#Failure error} (exception.except ..cannot_load [class_name error])) - {#try.Failure error} + {try.#Failure error} (exception.except ..invalid_field [class_name ..value::field error]))) (def: class_path_separator @@ -110,7 +110,7 @@ (list (field.field ..value::modifier ..value::field ..value::type (row.row))) (list (method.method ..init::modifier "<clinit>" ..init::type (list) - {#.Some + {.#Some ($_ _.composite valueG (_.putstatic (type.class bytecode_name (list)) ..value::field ..value::type) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux index 9ed5eb48e..daf8fa2fc 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux @@ -51,21 +51,21 @@ value (case (signed.s1 value) - {#try.Success value} + {try.#Success value} (do _.monad [_ (_.bipush value) _ _.i2l] ..wrap_i64) - {#try.Failure _} + {try.#Failure _} (case (signed.s2 value) - {#try.Success value} + {try.#Success value} (do _.monad [_ (_.sipush value) _ _.i2l] ..wrap_i64) - {#try.Failure _} + {try.#Failure _} (do _.monad [_ (_.long value)] ..wrap_i64))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux index 4074cf6cc..cb5f99c33 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux @@ -132,7 +132,7 @@ (let [super_class (|> ..^Object type.reflection reflection.reflection name.internal) main (method.method ..main::modifier "main" ..main::type (list) - {#.Some ($_ _.composite + {.#Some ($_ _.composite program ..input_list ..feed_inputs diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux index 778b23005..c61f58336 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux @@ -53,10 +53,10 @@ (def: .public (variable archive variable) (-> Archive Variable (Operation (Bytecode Any))) (case variable - {#variable.Local variable} + {variable.#Local variable} (operation\in (_.aload variable)) - {#variable.Foreign variable} + {variable.#Foreign variable} (..foreign archive variable))) (def: .public (constant archive name) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux index c3c8f518c..eba8c2f00 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux @@ -151,7 +151,7 @@ (method.method ..modifier ..variant::name ..variant::type (list) - {#.Some ($_ _.composite + {.#Some ($_ _.composite new_variant ... A[3] (..set! ..variant_tag $tag) ... A[3] (..set! ..variant_last? $last?) ... A[3] @@ -213,7 +213,7 @@ (method.method ..modifier ..decode_frac::name ..decode_frac::type (list) - {#.Some + {.#Some (..risky ($_ _.composite _.aload_0 @@ -250,7 +250,7 @@ (method.method ..modifier name ..failure::type (list) - {#.Some + {.#Some ($_ _.composite (..illegal_state_exception message) _.athrow)})) @@ -272,7 +272,7 @@ (method.method ..modifier ..push::name ..push::type (list) - {#.Some + {.#Some (let [new_stack_frame! ($_ _.composite _.iconst_2 (_.anewarray //type.value)) @@ -291,7 +291,7 @@ (def: case::method (method.method ..modifier ..case::name ..case::type (list) - {#.Some + {.#Some (do _.monad [@loop _.new_label @perfect_match! _.new_label @@ -395,7 +395,7 @@ left_projection::method (method.method ..modifier ..left_projection::name ..projection_type (list) - {#.Some + {.#Some (do _.monad [@loop _.new_label @recursive _.new_label @@ -413,7 +413,7 @@ right_projection::method (method.method ..modifier ..right_projection::name ..projection_type (list) - {#.Some + {.#Some (do _.monad [@loop _.new_label @not_tail _.new_label @@ -466,7 +466,7 @@ (def: try::method (method.method ..modifier ..try::name ..try::type (list) - {#.Some + {.#Some (do _.monad [@try _.new_label @handler _.new_label @@ -539,7 +539,7 @@ (row.row)))] (do ////.monad [_ (generation.execute! [class bytecode])] - (generation.save! ..artifact_id #.None [class bytecode])))) + (generation.save! ..artifact_id {.#None} [class bytecode])))) (def: generate_function (Operation Any) @@ -549,7 +549,7 @@ (list\each (function (_ arity) (method.method method.public ..apply::name (..apply::type arity) (list) - {#.Some + {.#Some (let [previous_inputs (|> arity list.indices (monad.each _.monad _.aload))] @@ -563,10 +563,10 @@ (list& (method.method (modifier\composite method.public method.abstract) ..apply::name (..apply::type //function/arity.minimum) (list) - #.None))) + {.#None}))) <init>::method (method.method method.public "<init>" //function.init (list) - {#.Some + {.#Some (let [$partials _.iload_1] ($_ _.composite ..this @@ -596,7 +596,7 @@ (row.row)))] (do ////.monad [_ (generation.execute! [class bytecode])] - (generation.save! //function.artifact_id #.None [class bytecode])))) + (generation.save! //function.artifact_id {.#None} [class bytecode])))) (def: .public generate (Operation Any) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux index 6b1a09aea..7455a3d3b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux @@ -29,10 +29,10 @@ (def: .public (tuple generate archive membersS) (Generator (Tuple Synthesis)) (case membersS - #.End + {.#End} (\ phase.monad in //runtime.unit) - {#.Item singletonS #.End} + {.#Item singletonS {.#End}} (generate archive singletonS) _ @@ -64,15 +64,15 @@ 4 _.iconst_4 5 _.iconst_5 tag (case (signed.s1 (.int tag)) - {#try.Success value} + {try.#Success value} (_.bipush value) - {#try.Failure _} + {try.#Failure _} (case (signed.s2 (.int tag)) - {#try.Success value} + {try.#Success value} (_.sipush value) - {#try.Failure _} + {try.#Failure _} (_.int (.i64 tag)))))) (def: .public (flag right?) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux index 66472f114..44b40b6e9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux @@ -49,7 +49,7 @@ (^ (synthesis.tuple members)) (/structure.tuple expression archive members) - {#synthesis.Reference value} + {synthesis.#Reference value} (//reference.reference /reference.system archive value) (^ (synthesis.branch/case case)) @@ -76,7 +76,7 @@ (^ (synthesis.function/apply application)) (/function.apply expression archive application) - {#synthesis.Extension extension} + {synthesis.#Extension extension} (///extension.apply archive expression extension))) (def: .public generate diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux index 7188a282c..90f2f3f3a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux @@ -67,8 +67,8 @@ (^template [<side> <accessor>] [(<side> lefts) (<accessor> (_.int (.int lefts)))]) - ([#.Left //runtime.tuple//left] - [#.Right //runtime.tuple//right]))] + ([.#Left //runtime.tuple//left] + [.#Right //runtime.tuple//right]))] (method source))) valueO (list.reversed pathP))))) @@ -163,23 +163,23 @@ (-> Phase! Phase Archive Path (Operation Statement)) (function (recur pathP) (.case pathP - {#/////synthesis.Then bodyS} + {/////synthesis.#Then bodyS} (statement expression archive bodyS) - #/////synthesis.Pop + {/////synthesis.#Pop} (///////phase\in ..pop!) - {#/////synthesis.Bind register} + {/////synthesis.#Bind register} (///////phase\in (_.local/1 (..register register) ..peek)) - {#/////synthesis.Bit_Fork when thenP elseP} + {/////synthesis.#Bit_Fork when thenP elseP} (do [! ///////phase.monad] [then! (recur thenP) else! (.case elseP - {#.Some elseP} + {.#Some elseP} (recur elseP) - #.None + {.#None} (in ..fail!))] (in (.if when (_.if ..peek @@ -198,11 +198,11 @@ (in [(_.= (|> match <format>) ..peek) then!]))) - {#.Item item})] + {.#Item item})] (in (_.cond clauses ..fail!)))]) - ([#/////synthesis.I64_Fork (<| _.int .int)] - [#/////synthesis.F64_Fork _.float] - [#/////synthesis.Text_Fork _.string]) + ([/////synthesis.#I64_Fork (<| _.int .int)] + [/////synthesis.#F64_Fork _.float] + [/////synthesis.#Text_Fork _.string]) (^template [<complex> <simple> <choice>] [(^ (<complex> idx)) @@ -250,14 +250,14 @@ (def: .public dependencies (-> Path (List Var)) (|>> ////synthesis/case.storage - (value@ #////synthesis/case.dependencies) + (value@ ////synthesis/case.#dependencies) set.list (list\each (function (_ variable) (.case variable - {#///////variable.Local register} + {///////variable.#Local register} (..register register) - {#///////variable.Foreign register} + {///////variable.#Foreign register} (..capture register)))))) (def: .public (case! statement expression archive [valueS pathP]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux index dbae0c91b..e395e1b19 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux @@ -43,7 +43,7 @@ (def: (with_closure inits @self @args body!) (-> (List Expression) Var (List Var) Statement [Statement Expression]) (case inits - #.End + {.#End} [(_.function @self @args body!) @self] @@ -133,5 +133,5 @@ (_.apply/1 @self)))))))) ))] _ (/////generation.execute! definition) - _ (/////generation.save! (product.right function_name) #.None definition)] + _ (/////generation.save! (product.right function_name) {.#None} definition)] (in instantiation))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux index 57b7261ff..bee7ac538 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux @@ -53,7 +53,7 @@ (Operation [(List Expression) Statement])) (case initsS+ ... function/false/non-independent loop - #.End + {.#End} (|> bodyS (statement expression archive) (\ ///////phase.monad each (|>> [(list)]))) @@ -75,7 +75,7 @@ (-> Phase! (Generator (Scope Synthesis))) (case initsS+ ... function/false/non-independent loop - #.End + {.#End} (expression archive bodyS) ... true loop @@ -93,7 +93,7 @@ (set.of_list _.hash) (set.difference (set.of_list _.hash locals)) set.list) - #.End + {.#End} [(_.function @loop locals scope!) @loop] @@ -108,7 +108,7 @@ )) (|> @context (_.apply/* foreigns))])))] _ (/////generation.execute! directive) - _ (/////generation.save! artifact_id #.None directive)] + _ (/////generation.save! artifact_id {.#None} directive)] (in (|> instantiation (_.apply/* initsO+)))))) (def: .public (recur! statement expression archive argsS+) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux index a6e448433..fa0a01ef7 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux @@ -127,7 +127,7 @@ (let [runtime (code.local_identifier (///reference.artifact [..module_id runtime_id])) runtime_name (` (_.var (~ (code.text (%.code runtime)))))] (case declaration - {#.Left name} + {.#Left name} (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name)] (in (list (` (def: .public (~ g!name) @@ -140,7 +140,7 @@ (function ((~ g!_) (~ g!name)) (_.set (~ g!name) (~ code)))))))))) - {#.Right [name inputs]} + {.#Right [name inputs]} (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name) inputsC (list\each code.local_identifier inputs) @@ -422,12 +422,12 @@ (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) - _ (/////generation.save! ..module_id #.None ..runtime)] + _ (/////generation.save! ..module_id {.#None} ..runtime)] (in [(|> artifact.empty artifact.resource product.right) (row.row [..module_id - #.None + {.#None} (|> ..runtime _.code (\ utf8.codec encoded))])]))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux index 29a909d0e..c2bd264e0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux @@ -17,10 +17,10 @@ (def: .public (tuple generate archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ - #.End + {.#End} (///////phase\in (//primitive.text /////synthesis.unit)) - {#.Item singletonS #.End} + {.#Item singletonS {.#End}} (generate archive singletonS) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux index 9c16f64cb..e2fc2ba88 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux @@ -39,10 +39,14 @@ [////synthesis.text] [////synthesis.variant] [////synthesis.tuple] - [#////synthesis.Reference] [////synthesis.branch/get] - [////synthesis.function/apply] - [#////synthesis.Extension]) + [////synthesis.function/apply]) + + (^template [<tag>] + [(^ {<tag> value}) + (//////phase\each _.return (expression archive synthesis))]) + ([////synthesis.#Reference] + [////synthesis.#Extension]) (^ (////synthesis.branch/case case)) (/case.case! statement expression archive case) @@ -72,7 +76,7 @@ [////synthesis.f64 /primitive.f64] [////synthesis.text /primitive.text]) - {#////synthesis.Reference value} + {////synthesis.#Reference value} (//reference.reference /reference.system archive value) (^template [<tag> <generator>] @@ -95,7 +99,7 @@ (^ (////synthesis.loop/recur _)) (//////phase.except ..cannot_recur_as_an_expression []) - {#////synthesis.Extension extension} + {////synthesis.#Extension extension} (///extension.apply archive expression extension))) (def: .public generate diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux index a5532afc3..d6e4ccb15 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux @@ -88,8 +88,8 @@ (^template [<side> <accessor>] [(<side> lefts) (<accessor> (_.int (.int lefts)))]) - ([#.Left //runtime.tuple//left] - [#.Right //runtime.tuple//right]))] + ([.#Left //runtime.tuple//left] + [.#Right //runtime.tuple//right]))] (method source))) valueG (list.reversed pathP))))) @@ -163,23 +163,23 @@ (Generator! Path) (function (recur pathP) (.case pathP - {#/////synthesis.Then bodyS} + {/////synthesis.#Then bodyS} (statement expression archive bodyS) - #/////synthesis.Pop + {/////synthesis.#Pop} (///////phase\in ..pop!) - {#/////synthesis.Bind register} + {/////synthesis.#Bind register} (///////phase\in (_.set! (..register register) ..peek)) - {#/////synthesis.Bit_Fork when thenP elseP} + {/////synthesis.#Bit_Fork when thenP elseP} (do [! ///////phase.monad] [then! (recur thenP) else! (.case elseP - {#.Some elseP} + {.#Some elseP} (recur elseP) - #.None + {.#None} (in ..fail!))] (in (.if when (_.if ..peek @@ -198,11 +198,11 @@ (in [(_.=== (|> match <format>) ..peek) then!]))) - {#.Item item})] + {.#Item item})] (in (_.cond clauses ..fail!)))]) - ([#/////synthesis.I64_Fork //primitive.i64] - [#/////synthesis.F64_Fork //primitive.f64] - [#/////synthesis.Text_Fork //primitive.text]) + ([/////synthesis.#I64_Fork //primitive.i64] + [/////synthesis.#F64_Fork //primitive.f64] + [/////synthesis.#Text_Fork //primitive.text]) (^template [<complex> <simple> <choice>] [(^ (<complex> idx)) @@ -260,14 +260,14 @@ (def: .public dependencies (-> Path (List Var)) (|>> ////synthesis/case.storage - (value@ #////synthesis/case.dependencies) + (value@ ////synthesis/case.#dependencies) set.list (list\each (function (_ variable) (.case variable - {#///////variable.Local register} + {///////variable.#Local register} (..register register) - {#///////variable.Foreign register} + {///////variable.#Foreign register} (..capture register)))))) (def: .public (case! statement expression archive [valueS pathP]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux index f630ec274..83e16e834 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux @@ -50,7 +50,7 @@ (def: (with_closure inits @selfG @selfL body!) (-> (List Expression) Global Var Statement [Statement Expression]) (case inits - #.End + {.#End} [($_ _.then (_.set! @selfL (_.closure (list (_.reference @selfL)) (list) body!)) (_.set! @selfG @selfL)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux index 055e107e0..7ce83fe85 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux @@ -51,7 +51,7 @@ (Generator! (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop - #.End + {.#End} (statement expression archive bodyS) ... true loop @@ -70,7 +70,7 @@ (-> Phase! (Generator (Scope Synthesis))) (case initsS+ ... function/false/non-independent loop - #.End + {.#End} (expression archive bodyS) ... true loop @@ -92,7 +92,7 @@ (list\mix set.union (referenced_variables bodyS)) (set.difference loop_variables) set.list) - #.End + {.#End} [(_.define_function @loop (list) scope!) @loop] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux index d8a418657..81f608c20 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux @@ -95,7 +95,7 @@ (let [runtime (code.local_identifier (///reference.artifact [..module_id runtime_id])) runtime_name (` (_.constant (~ (code.text (%.code runtime)))))] (case declaration - {#.Left name} + {.#Left name} (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name)] (in (list (` (def: .public (~ g!name) @@ -108,7 +108,7 @@ (function ((~ g!_) (~ g!name)) (_.define (~ g!name) (~ code)))))))))) - {#.Right [name inputs]} + {.#Right [name inputs]} (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name) inputsC (list\each code.local_identifier inputs) @@ -317,9 +317,9 @@ (_.set! value (_.apply/1 op [..unit])) (_.return (..right value))) (list (with_vars [error] - [#_.class (_.constant "Exception") - #_.exception error - #_.handler (_.return (..left (_.do "getMessage" (list) error)))]))))) + [_.#class (_.constant "Exception") + _.#exception error + _.#handler (_.return (..left (_.do "getMessage" (list) error)))]))))) (runtime: (lux//program_args inputs) (with_vars [head tail] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux index cb499a364..8e1a366a8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux @@ -20,10 +20,10 @@ (def: .public (tuple expression archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ - #.End + {.#End} (///////phase\in (//primitive.text /////synthesis.unit)) - {#.Item singletonS #.End} + {.#Item singletonS {.#End}} (expression archive singletonS) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux index b691c09d6..deca2222f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux @@ -49,7 +49,7 @@ (^ (////synthesis.tuple members)) (/structure.tuple expression archive members) - {#////synthesis.Reference value} + {////synthesis.#Reference value} (//reference.reference /reference.system archive value) (^ (////synthesis.branch/case case)) @@ -76,7 +76,7 @@ (^ (////synthesis.function/apply application)) (/function.apply expression archive application) - {#////synthesis.Extension extension} + {////synthesis.#Extension extension} (///extension.apply archive expression extension))) (def: .public generate diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux index 6cdabddd0..6b6e2ff74 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux @@ -93,8 +93,8 @@ (^template [<side> <accessor>] [(<side> lefts) (<accessor> (_.int (.int lefts)))]) - ([#.Left //runtime.tuple::left] - [#.Right //runtime.tuple::right]))] + ([.#Left //runtime.tuple::left] + [.#Right //runtime.tuple::right]))] (method source))) valueO (list.reversed pathP))))) @@ -156,14 +156,14 @@ (.if in_closure? (_.while (_.bool true) body! - #.None) + {.#None}) ($_ _.then (_.set (list g!once) (_.bool true)) (_.while g!once ($_ _.then (_.set (list g!once) (_.bool false)) body!) - {#.Some _.continue})))) + {.#Some _.continue})))) (def: (alternation in_closure? g!once pre! post!) (-> Bit SVar (Statement Any) (Statement Any) (Statement Any)) @@ -179,16 +179,16 @@ (-> (-> Path (Operation (Statement Any))) (-> Path (Operation (Maybe (Statement Any))))) (.case pathP - {#/////synthesis.Bit_Fork when thenP elseP} + {/////synthesis.#Bit_Fork when thenP elseP} (do [! ///////phase.monad] [then! (recur thenP) else! (.case elseP - {#.Some elseP} + {.#Some elseP} (recur elseP) - #.None + {.#None} (in ..fail_pm!))] - (in {#.Some (.if when + (in {.#Some (.if when (_.if ..peek then! else!) @@ -204,15 +204,15 @@ (|>> [(_.= (|> match <format>) ..peek)]) (recur then))) - {#.Item item})] - (in {#.Some (_.cond clauses + {.#Item item})] + (in {.#Some (_.cond clauses ..fail_pm!)}))]) - ([#/////synthesis.I64_Fork (<| //primitive.i64 .int)] - [#/////synthesis.F64_Fork (<| //primitive.f64)] - [#/////synthesis.Text_Fork (<| //primitive.text)]) + ([/////synthesis.#I64_Fork (<| //primitive.i64 .int)] + [/////synthesis.#F64_Fork (<| //primitive.f64)] + [/////synthesis.#Text_Fork (<| //primitive.text)]) _ - (\ ///////phase.monad in #.None))) + (\ ///////phase.monad in {.#None}))) (def: (pattern_matching' in_closure? statement expression archive) (-> Bit Phase! Phase Archive Path (Operation (Statement Any))) @@ -220,18 +220,18 @@ (do [! ///////phase.monad] [?output (primitive_pattern_matching recur pathP)] (.case ?output - {#.Some output} + {.#Some output} (in output) - #.None + {.#None} (.case pathP - {#/////synthesis.Then bodyS} + {/////synthesis.#Then bodyS} (statement expression archive bodyS) - #/////synthesis.Pop + {/////synthesis.#Pop} (///////phase\in ..pop!) - {#/////synthesis.Bind register} + {/////synthesis.#Bind register} (///////phase\in (_.set (list (..register register)) ..peek)) (^template [<complex> <simple> <choice>] @@ -298,14 +298,14 @@ (def: .public dependencies (-> Path (List SVar)) (|>> case.storage - (value@ #case.dependencies) + (value@ case.#dependencies) set.list (list\each (function (_ variable) (.case variable - {#///////variable.Local register} + {///////variable.#Local register} (..register register) - {#///////variable.Foreign register} + {///////variable.#Foreign register} (..capture register)))))) (def: .public (case! in_closure? statement expression archive [valueS pathP]) @@ -330,5 +330,5 @@ directive (_.def @case @dependencies+ pattern_matching!)] _ (/////generation.execute! directive) - _ (/////generation.save! case_artifact #.None directive)] + _ (/////generation.save! case_artifact {.#None} directive)] (in (_.apply/* @case @dependencies+)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux index fa9fc1656..bbb9fbd00 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux @@ -45,10 +45,10 @@ (def: (with_closure function_id @function inits function_definition) (-> artifact.ID SVar (List (Expression Any)) (Statement Any) (Operation (Expression Any))) (case inits - #.End + {.#End} (do ///////phase.monad [_ (/////generation.execute! function_definition) - _ (/////generation.save! function_id #.None function_definition)] + _ (/////generation.save! function_id {.#None} function_definition)] (in @function)) _ @@ -60,7 +60,7 @@ function_definition (_.return @function)))] _ (/////generation.execute! directive) - _ (/////generation.save! function_id #.None directive)] + _ (/////generation.save! function_id {.#None} directive)] (in (_.apply/* @function inits))))) (def: input diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux index b84826a26..066149a79 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux @@ -45,13 +45,13 @@ (-> (Statement Any) (Statement Any)) (_.while (_.bool true) body! - #.None)) + {.#None})) (def: .public (scope! statement expression archive [start initsS+ bodyS]) (Generator! (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop - #.End + {.#End} (statement expression archive bodyS) ... true loop @@ -68,7 +68,7 @@ (-> Phase! (Generator (Scope Synthesis))) (case initsS+ ... function/false/non-independent loop - #.End + {.#End} (expression archive bodyS) ... true loop @@ -91,7 +91,7 @@ (set.of_list _.hash) (set.difference (set.of_list _.hash locals)) set.list) - #.End + {.#End} [actual_loop @loop] @@ -103,7 +103,7 @@ )) (_.apply/* @loop foreigns)]))] _ (/////generation.execute! directive) - _ (/////generation.save! loop_artifact #.None directive)] + _ (/////generation.save! loop_artifact {.#None} directive)] (in (_.apply/* instantiation initsO+))))) (def: .public (recur! statement expression archive argsS+) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux index c2055e2cc..e72faad54 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux @@ -126,7 +126,7 @@ (<>.some <code>.local_identifier)))) code <code>.any]) (case declaration - {#.Left name} + {.#Left name} (macro.with_identifiers [g!_] (let [nameC (code.local_identifier name) code_nameC (code.local_identifier (format "@" name)) @@ -138,7 +138,7 @@ (function ((~ g!_) (~ g!_)) (_.set (list (~ g!_)) (~ code)))))))))) - {#.Right [name inputs]} + {.#Right [name inputs]} (macro.with_identifiers [g!_] (let [nameC (code.local_identifier name) code_nameC (code.local_identifier (format "@" name)) @@ -174,7 +174,7 @@ (runtime: (lux::exec code globals) ($_ _.then - (_.exec code {#.Some globals}) + (_.exec code {.#Some globals}) (_.return ..unit))) (def: runtime::lux @@ -220,7 +220,7 @@ (_.return (_.item lefts tuple)) ... Needs recursion <recur>)) - #.None))) + {.#None}))) (runtime: (tuple::right lefts tuple) (with_vars [last_index_right right_index] @@ -234,7 +234,7 @@ ... Needs recursion. <recur>]) (_.return (_.slice_from right_index tuple)))) - #.None)))) + {.#None})))) (runtime: (sum::get sum wantsLast wantedTag) (let [no_match! (_.return _.none) @@ -261,7 +261,7 @@ (_.return (variant' (_.- wantedTag sum_tag) sum_flag sum_value))]) no_match!) - #.None))) + {.#None}))) (def: runtime::adt (Statement Any) @@ -449,12 +449,12 @@ (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) - _ (/////generation.save! ..module_id #.None ..runtime)] + _ (/////generation.save! ..module_id {.#None} ..runtime)] (in [(|> artifact.empty artifact.resource product.right) (row.row [..module_id - #.None + {.#None} (|> ..runtime _.code (\ utf8.codec encoded))])]))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux index 5950a81ff..86c429347 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux @@ -17,10 +17,10 @@ (def: .public (tuple generate archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ - #.End + {.#End} (///////phase\in (//primitive.text /////synthesis.unit)) - {#.Item singletonS #.End} + {.#Item singletonS {.#End}} (generate archive singletonS) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r.lux index 4e3e67097..5438a0266 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r.lux @@ -36,7 +36,7 @@ [////synthesis.f64 /primitive.f64] [////synthesis.text /primitive.text]) - {#////synthesis.Reference value} + {////synthesis.#Reference value} (//reference.reference /reference.system archive value) (^template [<tag> <generator>] @@ -54,6 +54,6 @@ [////synthesis.loop/recur /loop.recur] [////synthesis.function/abstraction /function.function]) - {#////synthesis.Extension extension} + {////synthesis.#Extension extension} (///extension.apply archive generate extension) )) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux index 15e9c75e5..e99973e60 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux @@ -71,8 +71,8 @@ (^template [<side> <accessor>] [(<side> lefts) (<accessor> (_.int (.int lefts)))]) - ([#.Left //runtime.tuple::left] - [#.Right //runtime.tuple::right]))] + ([.#Left //runtime.tuple::left] + [.#Right //runtime.tuple::right]))] (method source))) valueO (list.reversed pathP))))) @@ -135,23 +135,23 @@ (Generator Path) (function (recur pathP) (.case pathP - {#/////synthesis.Then bodyS} + {/////synthesis.#Then bodyS} (expression archive bodyS) - #/////synthesis.Pop + {/////synthesis.#Pop} (///////phase\in ..pop_cursor!) - {#/////synthesis.Bind register} + {/////synthesis.#Bind register} (///////phase\in (_.set! (..register register) ..peek)) - {#/////synthesis.Bit_Fork when thenP elseP} + {/////synthesis.#Bit_Fork when thenP elseP} (do [! ///////phase.monad] [then! (recur thenP) else! (.case elseP - {#.Some elseP} + {.#Some elseP} (recur elseP) - #.None + {.#None} (in ..fail!))] (in (.if when (_.if ..peek @@ -170,14 +170,14 @@ (in [(<=> (|> match <format>) ..peek) then!]))) - {#.Item item})] + {.#Item item})] (in (list\mix (function (_ [when then] else) (_.if when then else)) ..fail! clauses)))]) - ([#/////synthesis.I64_Fork //primitive.i64 //runtime.i64::=] - [#/////synthesis.F64_Fork //primitive.f64 _.=] - [#/////synthesis.Text_Fork //primitive.text _.=]) + ([/////synthesis.#I64_Fork //primitive.i64 //runtime.i64::=] + [/////synthesis.#F64_Fork //primitive.f64 _.=] + [/////synthesis.#Text_Fork //primitive.text _.=]) (^template [<pm> <flag> <prep>] [(^ (<pm> idx)) @@ -213,11 +213,11 @@ (in (_.try ($_ _.then ..save_cursor! leftO) - #.None - {#.Some (..catch ($_ _.then + {.#None} + {.#Some (..catch ($_ _.then ..restore_cursor! rightO))} - #.None))) + {.#None}))) ))) (def: (pattern_matching expression archive pathP) @@ -225,9 +225,9 @@ (do ///////phase.monad [pattern_matching! (pattern_matching' expression archive pathP)] (in (_.try pattern_matching! - #.None - {#.Some (..catch (_.stop (_.string "Invalid expression for pattern-matching.")))} - #.None)))) + {.#None} + {.#Some (..catch (_.stop (_.string "Invalid expression for pattern-matching.")))} + {.#None})))) (def: .public (case expression archive [valueS pathP]) (Generator [Synthesis Path]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux index 87487db01..8d049ba86 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux @@ -42,7 +42,7 @@ (def: (with_closure function_id $function inits function_definition) (-> artifact.ID SVar (List Expression) Expression (Operation Expression)) (case inits - #.End + {.#End} (do ///////phase.monad [_ (/////generation.execute! function_definition) _ (/////generation.save! (%.nat function_id) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux index 02d6712ec..d0cb917a6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux @@ -37,7 +37,7 @@ (Generator (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop - #.End + {.#End} (expression archive bodyS) ... true loop diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux index 9d2c878cf..2c61e52f2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux @@ -126,10 +126,10 @@ (function (_ proc_name) (function (_ translate inputsS) (case (s.result inputsS ($_ p.and s.nat (s.tuple (p.many s.any)) s.any)) - {#e.Success [offset initsS+ bodyS]} + {e.#Success [offset initsS+ bodyS]} (loopT.translate_loop translate offset initsS+ bodyS) - {#e.Error error} + {e.#Error error} (&.throw Wrong_Syntax (wrong_syntax proc_name inputsS))) ))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux index 4975c0aec..54a0c637b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux @@ -25,7 +25,7 @@ ... (def: (lua//global proc translate inputs) ... (-> Text @.Proc) ... (case inputs -... (^ (list [_ {#.Text name}])) +... (^ (list [_ {.#Text name}])) ... (do macro.Monad<Meta> ... [] ... (in name)) @@ -56,7 +56,7 @@ ... (def: (table//call proc translate inputs) ... (-> Text @.Proc) ... (case inputs -... (^ (list& tableS [_ {#.Text field}] argsS+)) +... (^ (list& tableS [_ {.#Text field}] argsS+)) ... (do [@ macro.Monad<Meta>] ... [tableO (translate tableS) ... argsO+ (monad.each @ translate argsS+)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux index 246a010c9..01d69d81b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux @@ -98,7 +98,7 @@ (let [runtime (code.local_identifier (///reference.artifact [..module_id runtime_id])) runtime_name (` (_.var (~ (code.text (%.code runtime)))))] (case declaration - {#.Left name} + {.#Left name} (let [g!name (code.local_identifier name)] (in (list (` (def: .public (~ g!name) _.SVar @@ -108,7 +108,7 @@ _.Expression (_.set! (~ runtime_name) (~ code))))))) - {#.Right [name inputs]} + {.#Right [name inputs]} (let [g!name (code.local_identifier name) inputsC (list\each code.local_identifier inputs) inputs_typesC (list\each (function.constant (` _.Expression)) @@ -523,11 +523,11 @@ (_.try ($_ _.then (_.set! value (_.apply (list ..unit) op)) (..right value)) - #.None - {#.Some (_.function (list error) + {.#None} + {.#Some (_.function (list error) (..left (_.item (_.string "message") error)))} - #.None))) + {.#None}))) (runtime: (lux::program_args program_args) (with_vars [inputs value] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux index 711366595..bafd70383 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux @@ -20,10 +20,10 @@ (def: .public (tuple expression archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ - #.End + {.#End} (///////phase\in (//primitive.text /////synthesis.unit)) - {#.Item singletonS #.End} + {.#Item singletonS {.#End}} (expression archive singletonS) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux index 49389b109..2a456eba4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux @@ -73,18 +73,18 @@ (All (_ expression) (-> (System expression) Variable expression)) (case variable - {#variable.Local register} + {variable.#Local register} (..local system register) - {#variable.Foreign register} + {variable.#Foreign register} (..foreign system register))) (def: .public (reference system archive reference) (All (_ anchor expression directive) (-> (System expression) Archive Reference (////generation.Operation anchor expression directive expression))) (case reference - {#reference.Constant value} + {reference.#Constant value} (..constant system archive value) - {#reference.Variable value} + {reference.#Variable value} (phase\in (..variable system value)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux index b9202972d..d2027e419 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux @@ -65,10 +65,10 @@ (^ (////synthesis.loop/recur _)) (//////phase.except ..cannot_recur_as_an_expression []) - {#////synthesis.Reference value} + {////synthesis.#Reference value} (//reference.reference /reference.system archive value) - {#////synthesis.Extension extension} + {////synthesis.#Extension extension} (///extension.apply archive expression extension))) (def: .public generate diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux index 1e6cb7058..31fd8da27 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux @@ -56,7 +56,7 @@ ... TODO: Find some way to do 'let' without paying the price of the closure. (in (|> bodyO _.return - (_.lambda #.None (list (..register register))) + (_.lambda {.#None} (list (..register register))) (_.apply_lambda/* (list valueO)))))) (def: .public (let! statement expression archive [valueS register bodyS]) @@ -93,10 +93,10 @@ (in (list\mix (function (_ side source) (.let [method (.case side (^template [<side> <accessor>] - [(<side> lefts) + [{<side> lefts} (<accessor> (_.int (.int lefts)))]) - ([#.Left //runtime.tuple//left] - [#.Right //runtime.tuple//right]))] + ([.#Left //runtime.tuple//left] + [.#Right //runtime.tuple//right]))] (method source))) valueO (list.reversed pathP))))) @@ -188,16 +188,16 @@ (-> (-> Path (Operation Statement)) (-> Path (Operation (Maybe Statement)))) (.case pathP - {#/////synthesis.Bit_Fork when thenP elseP} + {/////synthesis.#Bit_Fork when thenP elseP} (do [! ///////phase.monad] [then! (recur thenP) else! (.case elseP - {#.Some elseP} + {.#Some elseP} (recur elseP) - #.None + {.#None} (in ..fail!))] - (in {#.Some (.if when + (in {.#Some (.if when (_.if ..peek then! else!) @@ -213,15 +213,15 @@ (|>> [(_.= (|> match <format>) ..peek)]) (recur then))) - {#.Item item})] - (in {#.Some (_.cond clauses + {.#Item item})] + (in {.#Some (_.cond clauses ..fail!)}))]) - ([#/////synthesis.I64_Fork (<| //primitive.i64 .int)] - [#/////synthesis.F64_Fork (<| //primitive.f64)] - [#/////synthesis.Text_Fork (<| //primitive.text)]) + ([/////synthesis.#I64_Fork (<| //primitive.i64 .int)] + [/////synthesis.#F64_Fork (<| //primitive.f64)] + [/////synthesis.#Text_Fork (<| //primitive.text)]) _ - (\ ///////phase.monad in #.None))) + (\ ///////phase.monad in {.#None}))) (def: (pattern_matching' in_closure? statement expression archive) (-> Bit (Generator! Path)) @@ -229,28 +229,28 @@ (do ///////phase.monad [?output (primitive_pattern_matching recur pathP)] (.case ?output - {#.Some output} + {.#Some output} (in output) - #.None + {.#None} (.case pathP - {#/////synthesis.Then bodyS} + {/////synthesis.#Then bodyS} (statement expression archive bodyS) - #/////synthesis.Pop + {/////synthesis.#Pop} (///////phase\in ..pop!) - {#/////synthesis.Bind register} + {/////synthesis.#Bind register} (///////phase\in (_.set (list (..register register)) ..peek)) - {#/////synthesis.Bit_Fork when thenP elseP} + {/////synthesis.#Bit_Fork when thenP elseP} (do [! ///////phase.monad] [then! (recur thenP) else! (.case elseP - {#.Some elseP} + {.#Some elseP} (recur elseP) - #.None + {.#None} (in ..fail!))] (in (.if when (_.if ..peek @@ -268,12 +268,12 @@ (|>> [(_.= (|> match <format>) ..peek)]) (recur then))) - {#.Item item})] + {.#Item item})] (in (_.cond clauses ..fail!)))]) - ([#/////synthesis.I64_Fork (<| //primitive.i64 .int)] - [#/////synthesis.F64_Fork (<| //primitive.f64)] - [#/////synthesis.Text_Fork (<| //primitive.text)]) + ([/////synthesis.#I64_Fork (<| //primitive.i64 .int)] + [/////synthesis.#F64_Fork (<| //primitive.f64)] + [/////synthesis.#Text_Fork (<| //primitive.text)]) (^template [<complex> <simple> <choice>] [(^ (<complex> idx)) @@ -353,5 +353,5 @@ (|> case (case! true statement expression archive) (\ ///////phase.monad each - (|>> (_.lambda #.None (list)) + (|>> (_.lambda {.#None} (list)) (_.apply_lambda/* (list)))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux index 091d1fd31..b067a3319 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux @@ -45,7 +45,7 @@ (def: (with_closure inits self function_definition) (-> (List Expression) Text Expression [Statement Expression]) (case inits - #.End + {.#End} (let [@self (_.global self)] [(_.set (list @self) function_definition) @self]) @@ -84,7 +84,7 @@ initialize_self! (list.indices arity)) [declaration instatiation] (with_closure closureO+ function_name - (_.lambda {#.Some @self} (list (_.variadic @curried)) + (_.lambda {.#Some @self} (list (_.variadic @curried)) ($_ _.then (_.set (list @num_args) (_.the "length" @curried)) (_.cond (list [(|> @num_args (_.= arityO)) @@ -101,12 +101,12 @@ (_.apply_lambda/* (list output_func_args)))))]) ... (|> @num_args (_.< arityO)) (let [@missing (_.local "missing")] - (_.return (_.lambda #.None (list (_.variadic @missing)) + (_.return (_.lambda {.#None} (list (_.variadic @missing)) (_.return (|> @self (_.apply_lambda/* (list (_.splat (|> (_.array (list)) (_.do "concat" (list @curried)) (_.do "concat" (list @missing)))))))))))) )))] _ (/////generation.execute! declaration) - _ (/////generation.save! function_artifact #.None declaration)] + _ (/////generation.save! function_artifact {.#None} declaration)] (in instatiation))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux index 1aa61c2bc..b6be81745 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux @@ -52,7 +52,7 @@ (Generator! (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop - #.End + {.#End} (statement expression archive bodyS) ... true loop @@ -69,7 +69,7 @@ (-> Phase! (Generator (Scope Synthesis))) (case initsS+ ... function/false/non-independent loop - #.End + {.#End} (expression archive bodyS) ... true loop @@ -77,7 +77,7 @@ (do [! ///////phase.monad] [body! (scope! statement expression archive [start initsS+ bodyS])] (in (|> body! - (_.lambda #.None (list)) + (_.lambda {.#None} (list)) (_.apply_lambda/* (list))))))) (def: .public (recur! statement expression archive argsS+) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux index 643bde0b2..c10550d39 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux @@ -96,7 +96,7 @@ (let [runtime (code.local_identifier (///reference.artifact [..module_id runtime_id])) runtime_name (` (_.local (~ (code.text (%.code runtime)))))] (case declaration - {#.Left name} + {.#Left name} (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name)] (in (list (` (def: .public (~ g!name) LVar (~ runtime_name))) @@ -106,7 +106,7 @@ (function ((~ g!_) (~ g!name)) (_.set (list (~ g!name)) (~ code)))))))))) - {#.Right [name inputs]} + {.#Right [name inputs]} (macro.with_identifiers [g!_] (let [g!name (code.local_identifier name) inputsC (list\each code.local_identifier inputs) @@ -393,12 +393,12 @@ (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) - _ (/////generation.save! ..module_id #.None ..runtime)] + _ (/////generation.save! ..module_id {.#None} ..runtime)] (in [(|> artifact.empty artifact.resource product.right) (row.row [..module_id - #.None + {.#None} (|> ..runtime _.code (\ utf8.codec encoded))])]))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux index 32ec74e4f..e3f1e558a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux @@ -17,10 +17,10 @@ (def: .public (tuple generate archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ - #.End + {.#End} (///////phase\in (//primitive.text /////synthesis.unit)) - {#.Item singletonS #.End} + {.#Item singletonS {.#End}} (generate archive singletonS) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme.lux index 20108a0cd..26c13742e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme.lux @@ -36,7 +36,7 @@ [////synthesis.f64 /primitive.f64] [////synthesis.text /primitive.text]) - {#////synthesis.Reference value} + {////synthesis.#Reference value} (//reference.reference /reference.system archive value) (^template [<tag> <generator>] @@ -54,6 +54,6 @@ [////synthesis.loop/recur /loop.recur] [////synthesis.function/abstraction /function.function]) - {#////synthesis.Extension extension} + {////synthesis.#Extension extension} (///extension.apply archive generate extension) )) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux index bfdb9bf93..e2bdad616 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux @@ -69,8 +69,8 @@ (^template [<side> <accessor>] [(<side> lefts) (<accessor> (_.int (.int lefts)))]) - ([#.Left //runtime.tuple//left] - [#.Right //runtime.tuple//right]))] + ([.#Left //runtime.tuple//left] + [.#Right //runtime.tuple//right]))] (method source))) valueO (list.reversed pathP))))) @@ -122,30 +122,30 @@ (list [(_.and (list (_.string?/1 @alt_error) (_.string=?/2 ..pm_error @alt_error))) on_failure]) - #.None + {.#None} happy_path)) (def: (pattern_matching' expression archive) (Generator Path) (function (recur pathP) (.case pathP - {#/////synthesis.Then bodyS} + {/////synthesis.#Then bodyS} (expression archive bodyS) - #/////synthesis.Pop + {/////synthesis.#Pop} (///////phase\in pop_cursor!) - {#/////synthesis.Bind register} + {/////synthesis.#Bind register} (///////phase\in (_.define_constant (..register register) ..peek)) - {#/////synthesis.Bit_Fork when thenP elseP} + {/////synthesis.#Bit_Fork when thenP elseP} (do [! ///////phase.monad] [then! (recur thenP) else! (.case elseP - {#.Some elseP} + {.#Some elseP} (recur elseP) - #.None + {.#None} (in ..fail!))] (in (.if when (_.if ..peek @@ -164,14 +164,14 @@ (in [(<=> (|> match <format>) ..peek) then!]))) - {#.Item item})] + {.#Item item})] (in (list\mix (function (_ [when then] else) (_.if when then else)) ..fail! clauses)))]) - ([#/////synthesis.I64_Fork //primitive.i64 _.=/2] - [#/////synthesis.F64_Fork //primitive.f64 _.=/2] - [#/////synthesis.Text_Fork //primitive.text _.string=?/2]) + ([/////synthesis.#I64_Fork //primitive.i64 _.=/2] + [/////synthesis.#F64_Fork //primitive.f64 _.=/2] + [/////synthesis.#Text_Fork //primitive.text _.string=?/2]) (^template [<pm> <flag> <prep>] [(^ (<pm> idx)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux index f0d2751f3..f45da0eaa 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux @@ -44,14 +44,14 @@ (-> (List Expression) Computation (Operation Computation)) (///////phase\in (case inits - #.End + {.#End} function_definition _ (|> function_definition (_.lambda [(|> (list.enumeration inits) (list\each (|>> product.left ..capture))) - #.None]) + {.#None}]) (_.apply/* inits))))) (def: @curried (_.var "curried")) @@ -76,13 +76,13 @@ @num_args (_.var "num_args") @self (_.var (///reference.artifact function_name))]] (with_closure closureO+ - (_.letrec (list [@self (_.lambda [(list) {#.Some @curried}] + (_.letrec (list [@self (_.lambda [(list) {.#Some @curried}] (_.let (list [@num_args (_.length/1 @curried)]) (<| (_.if (|> @num_args (_.=/2 arityO)) (<| (_.let (list [(//case.register 0) @self])) (_.let_values (list [[(|> (list.indices arity) (list\each ..input)) - #.None] + {.#None}] (_.apply/2 (_.var "apply") (_.var "values") @curried)])) bodyO)) (_.if (|> @num_args (_.>/2 arityO)) @@ -94,7 +94,7 @@ (apply_poly arity_args) (apply_poly output_func_args)))))) ... (|> @num_args (_.</2 arityO)) - (_.lambda [(list) {#.Some @missing}] + (_.lambda [(list) {.#Some @missing}] (|> @self (apply_poly (_.append/2 @curried @missing))))) ))]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux index c5e6b5e0e..4718eca95 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux @@ -40,7 +40,7 @@ (Generator (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop - #.End + {.#End} (expression archive bodyS) ... true loop @@ -52,7 +52,7 @@ (in (_.letrec (list [@scope (_.lambda [(|> initsS+ list.enumeration (list\each (|>> product.left (n.+ start) //case.register))) - #.None] + {.#None}] bodyO)]) (_.apply/* initsO+ @scope)))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux index 0f8ae8b9a..1d15137f9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux @@ -80,7 +80,7 @@ (let [runtime (code.local_identifier (///reference.artifact [..module_id runtime_id])) runtime_name (` (_.var (~ (code.text (%.code runtime)))))] (case declaration - {#.Left name} + {.#Left name} (let [g!name (code.local_identifier name)] (in (list (` (def: .public (~ g!name) Var @@ -90,7 +90,7 @@ _.Computation (_.define_constant (~ runtime_name) (~ code))))))) - {#.Right [name inputs]} + {.#Right [name inputs]} (let [g!name (code.local_identifier name) inputsC (list\each code.local_identifier inputs) inputs_typesC (list\each (function.constant (` _.Expression)) @@ -102,7 +102,7 @@ (` (def: (~ (code.local_identifier (format "@" name))) _.Computation (..with_vars [(~+ inputsC)] - (_.define_function (~ runtime_name) [(list (~+ inputsC)) #.None] + (_.define_function (~ runtime_name) [(list (~+ inputsC)) {.#None}] (~ code))))))))))))) (def: last_index @@ -214,14 +214,14 @@ (runtime: (lux//try op) (with_vars [error] (_.with_exception_handler - (_.lambda [(list error) #.None] + (_.lambda [(list error) {.#None}] (..left error)) - (_.lambda [(list) #.None] + (_.lambda [(list) {.#None}] (..right (_.apply/* (list ..unit) op)))))) (runtime: (lux//program_args program_args) (with_vars [@loop @input @output] - (_.letrec (list [@loop (_.lambda [(list @input @output) #.None] + (_.letrec (list [@loop (_.lambda [(list @input @output) {.#None}] (_.if (_.null?/1 @input) @output (_.apply/2 @loop (_.cdr/1 @input) (..some (_.vector/* (list (_.car/1 @input) @output))))))]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux index cc84cf77c..d23bf422b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux @@ -20,10 +20,10 @@ (def: .public (tuple expression archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ - #.End + {.#End} (///////phase\in (//primitive.text /////synthesis.unit)) - {#.Item singletonS #.End} + {.#Item singletonS {.#End}} (expression archive singletonS) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux index faa6739cb..f7a4d8078 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux @@ -27,72 +27,72 @@ (def: (primitive analysis) (-> ///analysis.Primitive /.Primitive) (case analysis - #///analysis.Unit - {#/.Text /.unit} + {///analysis.#Unit} + {/.#Text /.unit} (^template [<analysis> <synthesis>] [{<analysis> value} {<synthesis> value}]) - ([#///analysis.Bit #/.Bit] - [#///analysis.Frac #/.F64] - [#///analysis.Text #/.Text]) + ([///analysis.#Bit /.#Bit] + [///analysis.#Frac /.#F64] + [///analysis.#Text /.#Text]) (^template [<analysis> <synthesis>] [{<analysis> value} {<synthesis> (.i64 value)}]) - ([#///analysis.Nat #/.I64] - [#///analysis.Int #/.I64] - [#///analysis.Rev #/.I64]))) + ([///analysis.#Nat /.#I64] + [///analysis.#Int /.#I64] + [///analysis.#Rev /.#I64]))) (def: (optimization archive) Phase (function (optimization' analysis) (case analysis - {#///analysis.Primitive analysis'} - (phase\in {#/.Primitive (..primitive analysis')}) + {///analysis.#Primitive analysis'} + (phase\in {/.#Primitive (..primitive analysis')}) - {#///analysis.Reference reference} - (phase\in {#/.Reference reference}) + {///analysis.#Reference reference} + (phase\in {/.#Reference reference}) - {#///analysis.Structure structure} + {///analysis.#Structure structure} (/.with_currying? false (case structure - {#///analysis.Variant variant} + {///analysis.#Variant variant} (do phase.monad - [valueS (optimization' (value@ #///analysis.value variant))] - (in (/.variant (with@ #///analysis.value valueS variant)))) + [valueS (optimization' (value@ ///analysis.#value variant))] + (in (/.variant (with@ ///analysis.#value valueS variant)))) - {#///analysis.Tuple tuple} + {///analysis.#Tuple tuple} (|> tuple (monad.each phase.monad optimization') (phase\each (|>> /.tuple))))) - {#///analysis.Case inputA branchesAB+} + {///analysis.#Case inputA branchesAB+} (/.with_currying? false (/case.synthesize optimization branchesAB+ archive inputA)) (^ (///analysis.no_op value)) (optimization' value) - {#///analysis.Apply _} + {///analysis.#Apply _} (/.with_currying? false (/function.apply optimization archive analysis)) - {#///analysis.Function environmentA bodyA} + {///analysis.#Function environmentA bodyA} (/function.abstraction optimization environmentA archive bodyA) - {#///analysis.Extension name args} + {///analysis.#Extension name args} (/.with_currying? false (function (_ state) (|> (//extension.apply archive optimization [name args]) (phase.result' state) - (case> {#try.Success output} - {#try.Success output} + (case> {try.#Success output} + {try.#Success output} - {#try.Failure _} + {try.#Failure _} (|> args (monad.each phase.monad optimization') - (phase\each (|>> [name] #/.Extension)) + (phase\each (|>> [name] {/.#Extension})) (phase.result' state)))))) ))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux index 6722a4e4e..a2cb2403a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux @@ -31,19 +31,19 @@ (def: clean_up (-> Path Path) - (|>> {#/.Seq #/.Pop})) + (|>> {/.#Seq {/.#Pop}})) (def: (path' pattern end? thenC) (-> Pattern Bit (Operation Path) (Operation Path)) (case pattern - {#///analysis.Simple simple} + {///analysis.#Simple simple} (case simple - #///analysis.Unit + {///analysis.#Unit} thenC - {#///analysis.Bit when} + {///analysis.#Bit when} (///\each (function (_ then) - {#/.Bit_Fork when then #.None}) + {/.#Bit_Fork when then {.#None}}) thenC) (^template [<from> <to> <conversion>] @@ -51,38 +51,38 @@ (///\each (function (_ then) {<to> [(<conversion> test) then] (list)}) thenC)]) - ([#///analysis.Nat #/.I64_Fork .i64] - [#///analysis.Int #/.I64_Fork .i64] - [#///analysis.Rev #/.I64_Fork .i64] - [#///analysis.Frac #/.F64_Fork |>] - [#///analysis.Text #/.Text_Fork |>])) - - {#///analysis.Bind register} - (<| (\ ///.monad each (|>> {#/.Seq {#/.Bind register}})) + ([///analysis.#Nat /.#I64_Fork .i64] + [///analysis.#Int /.#I64_Fork .i64] + [///analysis.#Rev /.#I64_Fork .i64] + [///analysis.#Frac /.#F64_Fork |>] + [///analysis.#Text /.#Text_Fork |>])) + + {///analysis.#Bind register} + (<| (\ ///.monad each (|>> {/.#Seq {/.#Bind register}})) /.with_new_local thenC) - {#///analysis.Complex {#///analysis.Variant [lefts right? value_pattern]}} - (<| (///\each (|>> {#/.Seq {#/.Access {#/.Side (if right? - {#.Right lefts} - {#.Left lefts})}}})) + {///analysis.#Complex {///analysis.#Variant [lefts right? value_pattern]}} + (<| (///\each (|>> {/.#Seq {/.#Access {/.#Side (if right? + {.#Right lefts} + {.#Left lefts})}}})) (path' value_pattern end?) (when> [(new> (not end?) [])] [(///\each ..clean_up)]) thenC) - {#///analysis.Complex {#///analysis.Tuple tuple}} + {///analysis.#Complex {///analysis.#Tuple tuple}} (let [tuple::last (-- (list.size tuple))] (list\mix (function (_ [tuple::lefts tuple::member] nextC) (.case tuple::member - {#///analysis.Simple #///analysis.Unit} + {///analysis.#Simple {///analysis.#Unit}} nextC _ (let [right? (n.= tuple::last tuple::lefts) end?' (and end? right?)] - (<| (///\each (|>> {#/.Seq {#/.Access {#/.Member (if right? - {#.Right (-- tuple::lefts)} - {#.Left tuple::lefts})}}})) + (<| (///\each (|>> {/.#Seq {/.#Access {/.#Member (if right? + {.#Right (-- tuple::lefts)} + {.#Left tuple::lefts})}}})) (path' tuple::member end?') (when> [(new> (not end?') [])] [(///\each ..clean_up)]) nextC)))) @@ -92,7 +92,7 @@ (def: (path archive synthesize pattern bodyA) (-> Archive Phase Pattern Analysis (Operation Path)) - (path' pattern true (///\each (|>> #/.Then) (synthesize archive bodyA)))) + (path' pattern true (///\each (|>> {/.#Then}) (synthesize archive bodyA)))) (def: (weave_branch weave equivalence [new_test new_then] [[old_test old_then] old_tail]) (All (_ a) (-> (-> Path Path Path) (Equivalence a) [a Path] (/.Fork a Path) @@ -101,86 +101,86 @@ [[old_test (weave new_then old_then)] old_tail] [[old_test old_then] (case old_tail - #.End + {.#End} (list [new_test new_then]) - {#.Item old_item} - {#.Item (weave_branch weave equivalence [new_test new_then] old_item)})])) + {.#Item old_item} + {.#Item (weave_branch weave equivalence [new_test new_then] old_item)})])) (def: (weave_fork weave equivalence new_fork old_fork) (All (_ a) (-> (-> Path Path Path) (Equivalence a) (/.Fork a Path) (/.Fork a Path) (/.Fork a Path))) - (list\mix (..weave_branch weave equivalence) old_fork {#.Item new_fork})) + (list\mix (..weave_branch weave equivalence) old_fork {.#Item new_fork})) (def: (weave new old) (-> Path Path Path) - (with_expansions [<default> (as_is {#/.Alt old new})] + (with_expansions [<default> (as_is {/.#Alt old new})] (case [new old] [_ - {#/.Alt old_left old_right}] - {#/.Alt old_left + {/.#Alt old_left old_right}] + {/.#Alt old_left (weave new old_right)} - [{#/.Seq preN postN} - {#/.Seq preO postO}] + [{/.#Seq preN postN} + {/.#Seq preO postO}] (case (weave preN preO) - {#/.Alt _} + {/.#Alt _} <default> woven - {#/.Seq woven (weave postN postO)}) + {/.#Seq woven (weave postN postO)}) - [#/.Pop #/.Pop] + [{/.#Pop} {/.#Pop}] old - [{#/.Bit_Fork new_when new_then new_else} - {#/.Bit_Fork old_when old_then old_else}] + [{/.#Bit_Fork new_when new_then new_else} + {/.#Bit_Fork old_when old_then old_else}] (if (bit\= new_when old_when) - {#/.Bit_Fork old_when + {/.#Bit_Fork old_when (weave new_then old_then) (case [new_else old_else] - [#.None #.None] - #.None + [{.#None} {.#None}] + {.#None} - (^or [{#.Some woven_then} #.None] - [#.None {#.Some woven_then}]) - {#.Some woven_then} + (^or [{.#Some woven_then} {.#None}] + [{.#None} {.#Some woven_then}]) + {.#Some woven_then} - [{#.Some new_else} {#.Some old_else}] - {#.Some (weave new_else old_else)})} - {#/.Bit_Fork old_when + [{.#Some new_else} {.#Some old_else}] + {.#Some (weave new_else old_else)})} + {/.#Bit_Fork old_when (case new_else - #.None + {.#None} old_then - {#.Some new_else} + {.#Some new_else} (weave new_else old_then)) - {#.Some (case old_else - #.None + {.#Some (case old_else + {.#None} new_then - {#.Some old_else} + {.#Some old_else} (weave new_then old_else))}}) (^template [<tag> <equivalence>] [[{<tag> new_fork} {<tag> old_fork}] {<tag> (..weave_fork weave <equivalence> new_fork old_fork)}]) - ([#/.I64_Fork i64.equivalence] - [#/.F64_Fork frac.equivalence] - [#/.Text_Fork text.equivalence]) + ([/.#I64_Fork i64.equivalence] + [/.#F64_Fork frac.equivalence] + [/.#Text_Fork text.equivalence]) (^template [<access> <side>] - [[{#/.Access {<access> {<side> newL}}} - {#/.Access {<access> {<side> oldL}}}] + [[{/.#Access {<access> {<side> newL}}} + {/.#Access {<access> {<side> oldL}}}] (if (n.= newL oldL) old <default>)]) - ([#/.Side #.Left] - [#/.Side #.Right] - [#/.Member #.Left] - [#/.Member #.Right]) + ([/.#Side .#Left] + [/.#Side .#Right] + [/.#Member .#Left] + [/.#Member .#Right]) - [{#/.Bind newR} {#/.Bind oldR}] + [{/.#Bind newR} {/.#Bind oldR}] (if (n.= newR oldR) old <default>) @@ -196,25 +196,25 @@ <continue> (as_is (recur (++ lefts) tail)) <member> (as_is (if (list.empty? tail) - {#.Right (-- lefts)} - {#.Left lefts}))] + {.#Right (-- lefts)} + {.#Left lefts}))] (case patterns - #.End + {.#End} <failure> - {#.Item head tail} + {.#Item head tail} (case head - {#///analysis.Simple #///analysis.Unit} + {///analysis.#Simple {///analysis.#Unit}} <continue> - {#///analysis.Bind register} + {///analysis.#Bind register} (if (n.= @selection register) (list <member>) <continue>) - {#///analysis.Complex {#///analysis.Tuple sub_patterns}} + {///analysis.#Complex {///analysis.#Tuple sub_patterns}} (case (get sub_patterns @selection) - #.End + {.#End} <continue> sub_members @@ -231,8 +231,8 @@ (in (/.branch/case [input (list\mix weave headSP tailSP+)])))) (template: (!masking <variable> <output>) - [[[{#///analysis.Bind <variable>} - {#///analysis.Reference (///reference.local <output>)}] + [[[{///analysis.#Bind <variable>} + {///analysis.#Reference (///reference.local <output>)}] (list)]]) (def: .public (synthesize_let synthesize archive input @variable body) @@ -246,7 +246,7 @@ (-> Phase Archive Synthesis Register Register (Operation Synthesis)) (if (n.= @variable @output) (///\in input) - (..synthesize_let synthesize archive input @variable {#///analysis.Reference (///reference.local @output)}))) + (..synthesize_let synthesize archive input @variable {///analysis.#Reference (///reference.local @output)}))) (def: .public (synthesize_if synthesize archive test then else) (-> Phase Archive Synthesis Analysis Analysis (Operation Synthesis)) @@ -257,13 +257,13 @@ (template: (!get <patterns> <output>) [[[(///analysis.pattern/tuple <patterns>) - {#///analysis.Reference (///reference.local <output>)}] + {///analysis.#Reference (///reference.local <output>)}] (.list)]]) (def: .public (synthesize_get synthesize archive input patterns @member) (-> Phase Archive Synthesis (///analysis.Tuple ///analysis.Pattern) Register (Operation Synthesis)) (case (..get patterns @member) - #.End + {.#End} (..synthesize_case synthesize archive input (!get patterns @member)) path @@ -282,8 +282,8 @@ (^ (!masking @variable @output)) (..synthesize_masking synthesize^ archive inputS @variable @output) - [[{#///analysis.Bind @variable} body] - #.End] + [[{///analysis.#Bind @variable} body] + {.#End}] (..synthesize_let synthesize^ archive inputS @variable body) (^or (^ [[(///analysis.pattern/bit #1) then] @@ -306,7 +306,7 @@ (def: .public (count_pops path) (-> Path [Nat Path]) (case path - (^ (/.path/seq #/.Pop path')) + (^ (/.path/seq {/.#Pop} path')) (let [[pops post_pops] (count_pops path')] [(++ pops) post_pops]) @@ -338,26 +338,27 @@ [path path path_storage ..empty] (case path - (^or #/.Pop {#/.Access Access}) + (^or {/.#Pop} + {/.#Access Access}) path_storage (^ (/.path/bind register)) (revised@ #bindings (set.has register) path_storage) - {#/.Bit_Fork _ default otherwise} + {/.#Bit_Fork _ default otherwise} (|> (case otherwise - #.None + {.#None} path_storage - {#.Some otherwise} + {.#Some otherwise} (for_path otherwise path_storage)) (for_path default)) - (^or {#/.I64_Fork forks} - {#/.F64_Fork forks} - {#/.Text_Fork forks}) - (|> {#.Item forks} + (^or {/.#I64_Fork forks} + {/.#F64_Fork forks} + {/.#Text_Fork forks}) + (|> {.#Item forks} (list\each product.right) (list\mix for_path path_storage)) @@ -376,16 +377,16 @@ (^ (/.tuple members)) (list\mix for_synthesis synthesis_storage members) - {#/.Reference {#///reference.Variable {#///reference/variable.Local register}}} + {/.#Reference {///reference.#Variable {///reference/variable.#Local register}}} (if (set.member? (value@ #bindings synthesis_storage) register) synthesis_storage - (revised@ #dependencies (set.has {#///reference/variable.Local register}) synthesis_storage)) + (revised@ #dependencies (set.has {///reference/variable.#Local register}) synthesis_storage)) - {#/.Reference {#///reference.Variable var}} + {/.#Reference {///reference.#Variable var}} (revised@ #dependencies (set.has var) synthesis_storage) (^ (/.function/apply [functionS argsS])) - (list\mix for_synthesis synthesis_storage {#.Item functionS argsS}) + (list\mix for_synthesis synthesis_storage {.#Item functionS argsS}) (^ (/.function/abstraction [environment arity bodyS])) (list\mix for_synthesis synthesis_storage environment) @@ -423,7 +424,7 @@ (^ (/.loop/recur replacementsS+)) (list\mix for_synthesis synthesis_storage replacementsS+) - {#/.Extension [extension argsS]} + {/.#Extension [extension argsS]} (list\mix for_synthesis synthesis_storage argsS) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux index 278b6343e..09725f153 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux @@ -56,7 +56,7 @@ (with_expansions [<apply> (as_is (/.function/apply [funcS argsS]))] (case funcS (^ (/.function/abstraction functionS)) - (if (n.= (value@ #/.arity functionS) + (if (n.= (value@ /.#arity functionS) (list.size argsS)) (do ! [locals /.locals] @@ -85,17 +85,17 @@ (def: (find_foreign environment register) (-> (Environment Synthesis) Register (Operation Synthesis)) (case (list.item register environment) - {#.Some aliased} + {.#Some aliased} (phase\in aliased) - #.None + {.#None} (phase.except ..cannot_find_foreign_variable_in_environment [register environment]))) (def: (grow_path grow path) (-> (-> Synthesis (Operation Synthesis)) Path (Operation Path)) (case path - {#/.Bind register} - (phase\in {#/.Bind (++ register)}) + {/.#Bind register} + (phase\in {/.#Bind (++ register)}) (^template [<tag>] [{<tag> left right} @@ -103,18 +103,18 @@ [left' (grow_path grow left) right' (grow_path grow right)] (in {<tag> left' right'}))]) - ([#/.Alt] [#/.Seq]) + ([/.#Alt] [/.#Seq]) - {#/.Bit_Fork when then else} + {/.#Bit_Fork when then else} (do [! phase.monad] [then (grow_path grow then) else (case else - {#.Some else} - (\ ! each (|>> {#.Some}) (grow_path grow else)) + {.#Some else} + (\ ! each (|>> {.#Some}) (grow_path grow else)) - #.None - (in #.None))] - (in {#/.Bit_Fork when then else})) + {.#None} + (in {.#None}))] + (in {/.#Bit_Fork when then else})) (^template [<tag>] [{<tag> [[test then] elses]} @@ -126,14 +126,14 @@ (in [else_test else_then]))) elses)] (in {<tag> [[test then] elses]}))]) - ([#/.I64_Fork] - [#/.F64_Fork] - [#/.Text_Fork]) + ([/.#I64_Fork] + [/.#F64_Fork] + [/.#Text_Fork]) - {#/.Then thenS} + {/.#Then thenS} (|> thenS grow - (phase\each (|>> {#/.Then}))) + (phase\each (|>> {/.#Then}))) _ (phase\in path))) @@ -141,14 +141,14 @@ (def: (grow environment expression) (-> (Environment Synthesis) Synthesis (Operation Synthesis)) (case expression - {#/.Structure structure} + {/.#Structure structure} (case structure - {#////analysis.Variant [lefts right? subS]} + {////analysis.#Variant [lefts right? subS]} (|> subS (grow environment) (phase\each (|>> [lefts right?] /.variant))) - {#////analysis.Tuple membersS+} + {////analysis.#Tuple membersS+} (|> membersS+ (monad.each phase.monad (grow environment)) (phase\each (|>> /.tuple)))) @@ -156,66 +156,66 @@ (^ (..self_reference)) (phase\in (/.function/apply [expression (list (/.variable/local 1))])) - {#/.Reference reference} + {/.#Reference reference} (case reference - {#////reference.Variable variable} + {////reference.#Variable variable} (case variable - {#////reference/variable.Local register} + {////reference/variable.#Local register} (phase\in (/.variable/local (++ register))) - {#////reference/variable.Foreign register} + {////reference/variable.#Foreign register} (..find_foreign environment register)) - {#////reference.Constant constant} + {////reference.#Constant constant} (phase\in expression)) - {#/.Control control} + {/.#Control control} (case control - {#/.Branch branch} + {/.#Branch branch} (case branch - {#/.Let [inputS register bodyS]} + {/.#Let [inputS register bodyS]} (do phase.monad [inputS' (grow environment inputS) bodyS' (grow environment bodyS)] (in (/.branch/let [inputS' (++ register) bodyS']))) - {#/.If [testS thenS elseS]} + {/.#If [testS thenS elseS]} (do phase.monad [testS' (grow environment testS) thenS' (grow environment thenS) elseS' (grow environment elseS)] (in (/.branch/if [testS' thenS' elseS']))) - {#/.Get members inputS} + {/.#Get members inputS} (do phase.monad [inputS' (grow environment inputS)] (in (/.branch/get [members inputS']))) - {#/.Case [inputS pathS]} + {/.#Case [inputS pathS]} (do phase.monad [inputS' (grow environment inputS) pathS' (grow_path (grow environment) pathS)] (in (/.branch/case [inputS' pathS'])))) - {#/.Loop loop} + {/.#Loop loop} (case loop - {#/.Scope [start initsS+ iterationS]} + {/.#Scope [start initsS+ iterationS]} (do [! phase.monad] [initsS+' (monad.each ! (grow environment) initsS+) iterationS' (grow environment iterationS)] (in (/.loop/scope [(++ start) initsS+' iterationS']))) - {#/.Recur argumentsS+} + {/.#Recur argumentsS+} (|> argumentsS+ (monad.each phase.monad (grow environment)) (phase\each (|>> /.loop/recur)))) - {#/.Function function} + {/.#Function function} (case function - {#/.Abstraction [_env _arity _body]} + {/.#Abstraction [_env _arity _body]} (do [! phase.monad] [_env' (monad.each ! - (|>> (case> {#/.Reference {#////reference.Variable {#////reference/variable.Foreign register}}} + (|>> (case> {/.#Reference {////reference.#Variable {////reference/variable.#Foreign register}}} (..find_foreign environment register) captured @@ -223,7 +223,7 @@ _env)] (in (/.function/abstraction [_env' _arity _body]))) - {#/.Apply funcS argsS+} + {/.#Apply funcS argsS+} (do [! phase.monad] [funcS (grow environment funcS) argsS+ (monad.each ! (grow environment) argsS+)] @@ -236,12 +236,12 @@ [funcS argsS+])))))) - {#/.Extension name argumentsS+} + {/.#Extension name argumentsS+} (|> argumentsS+ (monad.each phase.monad (grow environment)) - (phase\each (|>> {#/.Extension name}))) + (phase\each (|>> {/.#Extension name}))) - {#/.Primitive _} + {/.#Primitive _} (phase\in expression))) (def: .public (abstraction phase environment archive bodyA) @@ -258,21 +258,21 @@ (|> bodyS' (grow env') (\ ! each (function (_ body) - [#/.environment environment - #/.arity (++ down_arity') - #/.body body]))) + [/.#environment environment + /.#arity (++ down_arity') + /.#body body]))) _ - (in [#/.environment environment - #/.arity 1 - #/.body bodyS])))] + (in [/.#environment environment + /.#arity 1 + /.#body bodyS])))] (in (if currying? (/.function/abstraction abstraction) (case (//loop.optimization false 1 (list) abstraction) - {#.Some [startL initsL bodyL]} - (/.function/abstraction [#/.environment environment - #/.arity (value@ #/.arity abstraction) - #/.body (/.loop/scope [startL initsL bodyL])]) + {.#Some [startL initsL bodyL]} + (/.function/abstraction [/.#environment environment + /.#arity (value@ /.#arity abstraction) + /.#body (/.loop/scope [startL initsL bodyL])]) - #.None + {.#None} (/.function/abstraction abstraction)))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux index c65c261e8..b994bd92e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux @@ -30,8 +30,8 @@ (-> (Transform Synthesis) Register (Transform Path)) (function (recur path) (case path - {#/.Bind register} - {#.Some {#/.Bind (register_optimization offset register)}} + {/.#Bind register} + {.#Some {/.#Bind (register_optimization offset register)}} (^template [<tag>] [{<tag> left right} @@ -39,18 +39,18 @@ [left' (recur left) right' (recur right)] (in {<tag> left' right'}))]) - ([#/.Alt] [#/.Seq]) + ([/.#Alt] [/.#Seq]) - {#/.Bit_Fork when then else} + {/.#Bit_Fork when then else} (do [! maybe.monad] [then (recur then) else (case else - {#.Some else} - (\ ! each (|>> #.Some) (recur else)) + {.#Some else} + (\ ! each (|>> {.#Some}) (recur else)) - #.None - (in #.None))] - (in {#/.Bit_Fork when then else})) + {.#None} + (in {.#None}))] + (in {/.#Bit_Fork when then else})) (^template [<tag>] [{<tag> [[test then] elses]} @@ -62,57 +62,57 @@ (in [else_test else_then]))) elses)] (in {<tag> [[test then] elses]}))]) - ([#/.I64_Fork] - [#/.F64_Fork] - [#/.Text_Fork]) + ([/.#I64_Fork] + [/.#F64_Fork] + [/.#Text_Fork]) - {#/.Then body} + {/.#Then body} (|> body body_optimization - (maybe\each (|>> {#/.Then}))) + (maybe\each (|>> {/.#Then}))) _ - {#.Some path}))) + {.#Some path}))) (def: (body_optimization true_loop? offset scope_environment arity expr) (-> Bit Register (Environment Synthesis) Arity (Transform Synthesis)) (loop [return? true expr expr] (case expr - {#/.Primitive _} - {#.Some expr} + {/.#Primitive _} + {.#Some expr} - {#/.Structure structure} + {/.#Structure structure} (case structure - {#analysis.Variant variant} + {analysis.#Variant variant} (do maybe.monad - [value' (|> variant (value@ #analysis.value) (recur false))] + [value' (|> variant (value@ analysis.#value) (recur false))] (in (|> variant - (with@ #analysis.value value') + (with@ analysis.#value value') /.variant))) - {#analysis.Tuple tuple} + {analysis.#Tuple tuple} (|> tuple (monad.each maybe.monad (recur false)) (maybe\each (|>> /.tuple)))) - {#/.Reference reference} + {/.#Reference reference} (case reference - (^ {#reference.Variable (variable.self)}) + (^ {reference.#Variable (variable.self)}) (if true_loop? - #.None - {#.Some expr}) + {.#None} + {.#Some expr}) (^ (reference.constant constant)) - {#.Some expr} + {.#Some expr} (^ (reference.local register)) - {#.Some {#/.Reference (reference.local (register_optimization offset register))}} + {.#Some {/.#Reference (reference.local (register_optimization offset register))}} (^ (reference.foreign register)) (if true_loop? (list.item register scope_environment) - {#.Some expr})) + {.#Some expr})) (^ (/.branch/case [input path])) (do maybe.monad @@ -141,12 +141,12 @@ (^ (/.loop/scope scope)) (do [! maybe.monad] [inits' (|> scope - (value@ #/.inits) + (value@ /.#inits) (monad.each ! (recur false))) - iteration' (recur return? (value@ #/.iteration scope))] - (in (/.loop/scope [#/.start (|> scope (value@ #/.start) (register_optimization offset)) - #/.inits inits' - #/.iteration iteration']))) + iteration' (recur return? (value@ /.#iteration scope))] + (in (/.loop/scope [/.#start (|> scope (value@ /.#start) (register_optimization offset)) + /.#inits inits' + /.#iteration iteration']))) (^ (/.loop/recur args)) (|> args @@ -165,45 +165,45 @@ [abstraction' (recur false abstraction)] (in (/.function/apply [abstraction' arguments']))))] (case abstraction - (^ {#/.Reference {#reference.Variable (variable.self)}}) + (^ {/.#Reference {reference.#Variable (variable.self)}}) (if (and return? (n.= arity (list.size arguments))) (in (/.loop/recur arguments')) (if true_loop? - #.None + {.#None} <application>)) _ <application>))) ... TODO: Stop relying on this custom code. - (^ {#/.Extension ["lux syntax char case!" (list& input else matches)]}) + (^ {/.#Extension ["lux syntax char case!" (list& input else matches)]}) (if return? (do [! maybe.monad] [input (recur false input) matches (monad.each ! (function (_ match) (case match - (^ {#/.Structure {#analysis.Tuple (list when then)}}) + (^ {/.#Structure {analysis.#Tuple (list when then)}}) (do ! [when (recur false when) then (recur return? then)] - (in {#/.Structure {#analysis.Tuple (list when then)}})) + (in {/.#Structure {analysis.#Tuple (list when then)}})) _ (recur false match))) matches) else (recur return? else)] - (in {#/.Extension ["lux syntax char case!" (list& input else matches)]})) - #.None) + (in {/.#Extension ["lux syntax char case!" (list& input else matches)]})) + {.#None}) - {#/.Extension [name args]} + {/.#Extension [name args]} (|> args (monad.each maybe.monad (recur false)) - (maybe\each (|>> [name] {#/.Extension})))))) + (maybe\each (|>> [name] {/.#Extension})))))) (def: .public (optimization true_loop? offset inits functionS) (-> Bit Register (List Synthesis) Abstraction (Maybe [Register (List Synthesis) Synthesis])) - (|> (value@ #/.body functionS) - (body_optimization true_loop? offset (value@ #/.environment functionS) (value@ #/.arity functionS)) + (|> (value@ /.#body functionS) + (body_optimization true_loop? offset (value@ /.#environment functionS) (value@ /.#arity functionS)) (maybe\each (|>> [offset inits])))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux index 17399b478..75647203b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux @@ -39,27 +39,27 @@ (-> (Remover Synthesis) (Remover Path)) (function (recur path) (case path - {#/.Seq {#/.Bind register} + {/.#Seq {/.#Bind register} post} (if (n.= redundant register) (recur post) - {#/.Seq {#/.Bind (if (n.> redundant register) + {/.#Seq {/.#Bind (if (n.> redundant register) (-- register) register)} (recur post)}) - (^or {#/.Seq {#/.Access {#/.Member member}} - {#/.Seq {#/.Bind register} + (^or {/.#Seq {/.#Access {/.#Member member}} + {/.#Seq {/.#Bind register} post}} ... This alternative form should never occur in practice. ... Yet, it is "technically" possible to construct it. - {#/.Seq {#/.Seq {#/.Access {#/.Member member}} - {#/.Bind register}} + {/.#Seq {/.#Seq {/.#Access {/.#Member member}} + {/.#Bind register}} post}) (if (n.= redundant register) (recur post) - {#/.Seq {#/.Access {#/.Member member}} - {#/.Seq {#/.Bind (if (n.> redundant register) + {/.#Seq {/.#Access {/.#Member member}} + {/.#Seq {/.#Bind (if (n.> redundant register) (-- register) register)} (recur post)}}) @@ -67,11 +67,11 @@ (^template [<tag>] [{<tag> left right} {<tag> (recur left) (recur right)}]) - ([#/.Seq] - [#/.Alt]) + ([/.#Seq] + [/.#Alt]) - {#/.Bit_Fork when then else} - {#/.Bit_Fork when (recur then) (maybe\each recur else)} + {/.#Bit_Fork when then else} + {/.#Bit_Fork when (recur then) (maybe\each recur else)} (^template [<tag>] [{<tag> [[test then] tail]} @@ -79,93 +79,93 @@ (list\each (function (_ [test' then']) [test' (recur then')]) tail)]}]) - ([#/.I64_Fork] - [#/.F64_Fork] - [#/.Text_Fork]) + ([/.#I64_Fork] + [/.#F64_Fork] + [/.#Text_Fork]) - (^or #/.Pop - {#/.Access _}) + (^or {/.#Pop} + {/.#Access _}) path - {#/.Bind register} + {/.#Bind register} (undefined) - {#/.Then then} - {#/.Then (remove_local redundant then)} + {/.#Then then} + {/.#Then (remove_local redundant then)} ))) (def: (remove_local_from_variable redundant variable) (Remover Variable) (case variable - {#variable.Local register} - {#variable.Local (..prune redundant register)} + {variable.#Local register} + {variable.#Local (..prune redundant register)} - {#variable.Foreign register} + {variable.#Foreign register} variable)) (def: (remove_local redundant) (Remover Synthesis) (function (recur synthesis) (case synthesis - {#/.Primitive _} + {/.#Primitive _} synthesis - {#/.Structure structure} - {#/.Structure (case structure - {#analysis.Variant [lefts right value]} - {#analysis.Variant [lefts right (recur value)]} + {/.#Structure structure} + {/.#Structure (case structure + {analysis.#Variant [lefts right value]} + {analysis.#Variant [lefts right (recur value)]} - {#analysis.Tuple tuple} - {#analysis.Tuple (list\each recur tuple)})} + {analysis.#Tuple tuple} + {analysis.#Tuple (list\each recur tuple)})} - {#/.Reference reference} + {/.#Reference reference} (case reference - {#reference.Variable variable} + {reference.#Variable variable} (/.variable (..remove_local_from_variable redundant variable)) - {#reference.Constant constant} + {reference.#Constant constant} synthesis) - {#/.Control control} - {#/.Control (case control - {#/.Branch branch} - {#/.Branch (case branch - {#/.Let input register output} - {#/.Let (recur input) + {/.#Control control} + {/.#Control (case control + {/.#Branch branch} + {/.#Branch (case branch + {/.#Let input register output} + {/.#Let (recur input) (..prune redundant register) (recur output)} - {#/.If test then else} - {#/.If (recur test) (recur then) (recur else)} + {/.#If test then else} + {/.#If (recur test) (recur then) (recur else)} - {#/.Get path record} - {#/.Get path (recur record)} + {/.#Get path record} + {/.#Get path (recur record)} - {#/.Case input path} - {#/.Case (recur input) (remove_local_from_path remove_local redundant path)})} + {/.#Case input path} + {/.#Case (recur input) (remove_local_from_path remove_local redundant path)})} - {#/.Loop loop} - {#/.Loop (case loop - {#/.Scope [start inits iteration]} - {#/.Scope [(..prune redundant start) + {/.#Loop loop} + {/.#Loop (case loop + {/.#Scope [start inits iteration]} + {/.#Scope [(..prune redundant start) (list\each recur inits) (recur iteration)]} - {#/.Recur resets} - {#/.Recur (list\each recur resets)})} + {/.#Recur resets} + {/.#Recur (list\each recur resets)})} - {#/.Function function} - {#/.Function (case function - {#/.Abstraction [environment arity body]} - {#/.Abstraction [(list\each recur environment) + {/.#Function function} + {/.#Function (case function + {/.#Abstraction [environment arity body]} + {/.#Abstraction [(list\each recur environment) arity body]} - {#/.Apply abstraction inputs} - {#/.Apply (recur abstraction) (list\each recur inputs)})})} + {/.#Apply abstraction inputs} + {/.#Apply (recur abstraction) (list\each recur inputs)})})} - {#/.Extension name inputs} - {#/.Extension name (list\each recur inputs)}))) + {/.#Extension name inputs} + {/.#Extension name (list\each recur inputs)}))) (type: Redundancy (Dictionary Register Bit)) @@ -197,16 +197,16 @@ (All (_ a) (-> (Optimization a) (Optimization (List a)))) (function (recur [redundancy values]) (case values - #.End - {#try.Success [redundancy + {.#End} + {try.#Success [redundancy values]} - {#.Item head tail} + {.#Item head tail} (do try.monad [[redundancy head] (optimization [redundancy head]) [redundancy tail] (recur [redundancy tail])] (in [redundancy - {#.Item head tail}]))))) + {.#Item head tail}]))))) (template [<name>] [(exception: .public (<name> [register Register]) @@ -220,20 +220,20 @@ (def: (declare register redundancy) (-> Register Redundancy (Try Redundancy)) (case (dictionary.value register redundancy) - #.None - {#try.Success (dictionary.has register ..redundant! redundancy)} + {.#None} + {try.#Success (dictionary.has register ..redundant! redundancy)} - {#.Some _} + {.#Some _} (exception.except ..redundant_declaration [register]))) (def: (observe register redundancy) (-> Register Redundancy (Try Redundancy)) (case (dictionary.value register redundancy) - #.None + {.#None} (exception.except ..unknown_register [register]) - {#.Some _} - {#try.Success (dictionary.has register ..necessary! redundancy)})) + {.#Some _} + {try.#Success (dictionary.has register ..necessary! redundancy)})) (def: (format redundancy) (%.Format Redundancy) @@ -247,24 +247,24 @@ (-> (Optimization Synthesis) (Optimization Path)) (function (recur [redundancy path]) (case path - (^or #/.Pop - {#/.Access _}) - {#try.Success [redundancy + (^or {/.#Pop} + {/.#Access _}) + {try.#Success [redundancy path]} - {#/.Bit_Fork when then else} + {/.#Bit_Fork when then else} (do [! try.monad] [[redundancy then] (recur [redundancy then]) [redundancy else] (case else - {#.Some else} + {.#Some else} (\ ! each (function (_ [redundancy else]) - [redundancy {#.Some else}]) + [redundancy {.#Some else}]) (recur [redundancy else])) - #.None - (in [redundancy #.None]))] - (in [redundancy {#/.Bit_Fork when then else}])) + {.#None} + (in [redundancy {.#None}]))] + (in [redundancy {/.#Bit_Fork when then else}])) (^template [<tag> <type>] [{<tag> [[test then] elses]} @@ -277,23 +277,23 @@ (in [redundancy [else_test else_then]])))) [redundancy elses])] (in [redundancy {<tag> [[test then] elses]}]))]) - ([#/.I64_Fork (I64 Any)] - [#/.F64_Fork Frac] - [#/.Text_Fork Text]) + ([/.#I64_Fork (I64 Any)] + [/.#F64_Fork Frac] + [/.#Text_Fork Text]) - {#/.Bind register} + {/.#Bind register} (do try.monad [redundancy (..declare register redundancy)] (in [redundancy path])) - {#/.Alt left right} + {/.#Alt left right} (do try.monad [[redundancy left] (recur [redundancy left]) [redundancy right] (recur [redundancy right])] - (in [redundancy {#/.Alt left right}])) + (in [redundancy {/.#Alt left right}])) - {#/.Seq pre post} + {/.#Seq pre post} (do try.monad [.let [baseline (|> redundancy dictionary.keys @@ -313,56 +313,56 @@ (in [(list\mix dictionary.lacks redundancy (set.list bindings)) (|> redundants (list.sorted n.>) - (list\mix (..remove_local_from_path ..remove_local) {#/.Seq pre post}))])) + (list\mix (..remove_local_from_path ..remove_local) {/.#Seq pre post}))])) - {#/.Then then} + {/.#Then then} (do try.monad [[redundancy then] (optimization [redundancy then])] - (in [redundancy {#/.Then then}])) + (in [redundancy {/.#Then then}])) ))) (def: (optimization' [redundancy synthesis]) (Optimization Synthesis) - (with_expansions [<no_op> (as_is {#try.Success [redundancy + (with_expansions [<no_op> (as_is {try.#Success [redundancy synthesis]})] (case synthesis - {#/.Primitive _} + {/.#Primitive _} <no_op> - {#/.Structure structure} + {/.#Structure structure} (case structure - {#analysis.Variant [lefts right value]} + {analysis.#Variant [lefts right value]} (do try.monad [[redundancy value] (optimization' [redundancy value])] (in [redundancy - {#/.Structure {#analysis.Variant [lefts right value]}}])) + {/.#Structure {analysis.#Variant [lefts right value]}}])) - {#analysis.Tuple tuple} + {analysis.#Tuple tuple} (do try.monad [[redundancy tuple] (..list_optimization optimization' [redundancy tuple])] (in [redundancy - {#/.Structure {#analysis.Tuple tuple}}]))) + {/.#Structure {analysis.#Tuple tuple}}]))) - {#/.Reference reference} + {/.#Reference reference} (case reference - {#reference.Variable variable} + {reference.#Variable variable} (case variable - {#variable.Local register} + {variable.#Local register} (do try.monad [redundancy (..observe register redundancy)] <no_op>) - {#variable.Foreign register} + {variable.#Foreign register} <no_op>) - {#reference.Constant constant} + {reference.#Constant constant} <no_op>) - {#/.Control control} + {/.#Control control} (case control - {#/.Branch branch} + {/.#Branch branch} (case branch - {#/.Let input register output} + {/.#Let input register output} (do try.monad [[redundancy input] (optimization' [redundancy input]) redundancy (..declare register redundancy) @@ -371,70 +371,70 @@ (dictionary.value register) (maybe.else ..necessary!))]] (in [(dictionary.lacks register redundancy) - {#/.Control (if redundant? - {#/.Branch {#/.Case input - {#/.Seq #/.Pop - {#/.Then (..remove_local register output)}}}} - {#/.Branch {#/.Let input register output}})}])) + {/.#Control (if redundant? + {/.#Branch {/.#Case input + {/.#Seq {/.#Pop} + {/.#Then (..remove_local register output)}}}} + {/.#Branch {/.#Let input register output}})}])) - {#/.If test then else} + {/.#If test then else} (do try.monad [[redundancy test] (optimization' [redundancy test]) [redundancy then] (optimization' [redundancy then]) [redundancy else] (optimization' [redundancy else])] (in [redundancy - {#/.Control {#/.Branch {#/.If test then else}}}])) + {/.#Control {/.#Branch {/.#If test then else}}}])) - {#/.Get path record} + {/.#Get path record} (do try.monad [[redundancy record] (optimization' [redundancy record])] (in [redundancy - {#/.Control {#/.Branch {#/.Get path record}}}])) + {/.#Control {/.#Branch {/.#Get path record}}}])) - {#/.Case input path} + {/.#Case input path} (do try.monad [[redundancy input] (optimization' [redundancy input]) [redundancy path] (..path_optimization optimization' [redundancy path])] (in [redundancy - {#/.Control {#/.Branch {#/.Case input path}}}]))) + {/.#Control {/.#Branch {/.#Case input path}}}]))) - {#/.Loop loop} + {/.#Loop loop} (case loop - {#/.Scope [start inits iteration]} + {/.#Scope [start inits iteration]} (do try.monad [[redundancy inits] (..list_optimization optimization' [redundancy inits]) .let [[extension redundancy] (..extended start (list.size inits) redundancy)] [redundancy iteration] (optimization' [redundancy iteration])] (in [(list\mix dictionary.lacks redundancy extension) - {#/.Control {#/.Loop {#/.Scope [start inits iteration]}}}])) + {/.#Control {/.#Loop {/.#Scope [start inits iteration]}}}])) - {#/.Recur resets} + {/.#Recur resets} (do try.monad [[redundancy resets] (..list_optimization optimization' [redundancy resets])] (in [redundancy - {#/.Control {#/.Loop {#/.Recur resets}}}]))) + {/.#Control {/.#Loop {/.#Recur resets}}}]))) - {#/.Function function} + {/.#Function function} (case function - {#/.Abstraction [environment arity body]} + {/.#Abstraction [environment arity body]} (do [! try.monad] [[redundancy environment] (..list_optimization optimization' [redundancy environment]) [_ body] (optimization' [(..default arity) body])] (in [redundancy - {#/.Control {#/.Function {#/.Abstraction [environment arity body]}}}])) + {/.#Control {/.#Function {/.#Abstraction [environment arity body]}}}])) - {#/.Apply abstraction inputs} + {/.#Apply abstraction inputs} (do try.monad [[redundancy abstraction] (optimization' [redundancy abstraction]) [redundancy inputs] (..list_optimization optimization' [redundancy inputs])] (in [redundancy - {#/.Control {#/.Function {#/.Apply abstraction inputs}}}])))) + {/.#Control {/.#Function {/.#Apply abstraction inputs}}}])))) - {#/.Extension name inputs} + {/.#Extension name inputs} (do try.monad [[redundancy inputs] (..list_optimization optimization' [redundancy inputs])] (in [redundancy - {#/.Extension name inputs}]))))) + {/.#Extension name inputs}]))))) (def: .public optimization (-> Synthesis (Try Synthesis)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/program.lux b/stdlib/source/library/lux/tool/compiler/language/lux/program.lux index 6b9fbfd09..cd3bb3f30 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/program.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/program.lux @@ -42,16 +42,16 @@ (do ! [id (archive.id module archive) [descriptor document] (archive.find module archive)] - (in [[module id] (value@ #descriptor.registry descriptor)])))))] + (in [[module id] (value@ descriptor.#registry descriptor)])))))] (case (list.one (function (_ [[module module_id] registry]) (do maybe.monad [program_id (artifact.remember ..name registry)] (in [module_id program_id]))) registries) - {#.Some program_context} + {.#Some program_context} (in program_context) - #.None + {.#None} (|> registries (list\each (|>> product.left product.left)) (exception.except ..cannot_find_program))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux index b855ced2f..68df640bf 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux @@ -171,11 +171,11 @@ ["Text" (%.text text)])) (template: (!failure parser where offset source_code) - [{#.Left [[where offset source_code] + [{.#Left [[where offset source_code] (exception.error ..unrecognized_input [where (%.name (name_of parser)) source_code offset])]}]) (template: (!end_of_file where offset source_code current_module) - [{#.Left [[where offset source_code] + [{.#Left [[where offset source_code] (exception.error ..end_of_file current_module)]}]) (type: (Parser a) @@ -193,15 +193,15 @@ (template: (!letE <binding> <computation> <body>) [(case <computation> - {#.Right <binding>} + {.#Right <binding>} <body> - ... {#.Left error} + ... {.#Left error} <<otherwise>> (:expected <<otherwise>>))]) (template: (!horizontal where offset source_code) - [[(revised@ #.column ++ where) + [[(revised@ .#column ++ where) (!++ offset) source_code]]) @@ -225,62 +225,62 @@ (-> (Parser Code) Location Offset Text (Either [Source Text] [Source Code])) (loop [source (: Source [(!forward 1 where) offset source_code]) - stack (: (List Code) #.End)] + stack (: (List Code) {.#End})] (case (parse source) - {#.Right [source' top]} - (recur source' {#.Item top stack}) + {.#Right [source' top]} + (recur source' {.#Item top stack}) - {#.Left [source' error]} + {.#Left [source' error]} (if (same? <close> error) - {#.Right [source' + {.#Right [source' [where {<tag> (list.reversed stack)}]]} - {#.Left [source' error]}))))] + {.#Left [source' error]}))))] ... Form and tuple syntax is mostly the same, differing only in the ... delimiters involved. ... They may have an arbitrary number of arbitrary Code nodes as elements. - [form_parser ..close_form #.Form] - [variant_parser ..close_variant #.Variant] - [tuple_parser ..close_tuple #.Tuple] + [form_parser ..close_form .#Form] + [variant_parser ..close_variant .#Variant] + [tuple_parser ..close_tuple .#Tuple] ) (inline: (record_parser parse where offset source_code) (-> (Parser Code) Location Offset Text (Either [Source Text] [Source Code])) (loop [source (: Source [(!forward 1 where) offset source_code]) - stack (: (List [Code Code]) #.End)] + stack (: (List [Code Code]) {.#End})] (case (parse source) - {#.Right [sourceF field]} + {.#Right [sourceF field]} (!letE [sourceFV value] (parse sourceF) - (recur sourceFV {#.Item [field value] stack})) + (recur sourceFV {.#Item [field value] stack})) - {#.Left [source' error]} + {.#Left [source' error]} (if (same? ..close_variant error) - {#.Right [source' - [where {#.Record (list.reversed stack)}]]} - {#.Left [source' error]})))) + {.#Right [source' + [where {.#Record (list.reversed stack)}]]} + {.#Left [source' error]})))) (template: (!guarantee_no_new_lines where offset source_code content body) [(case ("lux text index" 0 (static text.new_line) content) - #.None + {.#None} body g!_ - {#.Left [[where offset source_code] + {.#Left [[where offset source_code] (exception.error ..text_cannot_contain_new_lines content)]})]) (def: (text_parser where offset source_code) (-> Location Offset Text (Either [Source Text] [Source Code])) (case ("lux text index" offset (static ..text_delimiter) source_code) - {#.Some g!end} + {.#Some g!end} (<| (let [g!content (!clip offset g!end source_code)]) (!guarantee_no_new_lines where offset source_code g!content) - {#.Right [[(let [size (!n/- offset g!end)] - (revised@ #.column (|>> (!n/+ size) (!n/+ 2)) where)) + {.#Right [[(let [size (!n/- offset g!end)] + (revised@ .#column (|>> (!n/+ size) (!n/+ 2)) where)) (!++ g!end) source_code] [where - {#.Text g!content}]]}) + {.#Text g!content}]]}) _ (!failure ..text_parser where offset source_code))) @@ -295,8 +295,7 @@ [..open_form] [..close_form] [..open_variant] [..close_variant] [..open_tuple] [..close_tuple] - [..text_delimiter] - [..sigil]) + [..text_delimiter]) <digit_separator> (static ..digit_separator)] (template: (!if_digit? @char @then @else) [("lux syntax char case!" @char @@ -338,23 +337,23 @@ (!clip <start> <end>) (text.replaced ..digit_separator "") (\ <codec> decoded)) - {#.Right output} - {#.Right [[(let [[where::file where::line where::column] where] + {.#Right output} + {.#Right [[(let [[where::file where::line where::column] where] [where::file where::line (!n/+ (!n/- <start> <end>) where::column)]) <end> <source_code>] [where {<tag> output}]]} - {#.Left error} - {#.Left [[where <start> <source_code>] + {.#Left error} + {.#Left [[where <start> <source_code>] error]})]) (def: no_exponent Offset 0) -(with_expansions [<int_output> (as_is (!number_output source_code start end int.decimal #.Int)) - <frac_output> (as_is (!number_output source_code start end frac.decimal #.Frac)) +(with_expansions [<int_output> (as_is (!number_output source_code start end int.decimal .#Int)) + <frac_output> (as_is (!number_output source_code start end frac.decimal .#Frac)) <failure> (!failure ..frac_parser where offset source_code) <frac_separator> (static ..frac_separator) <signs> (template [<sign>] @@ -412,8 +411,8 @@ [] (!number_output source_code start g!end <codec> <tag>)))))] - [nat_parser n.decimal #.Nat] - [rev_parser rev.decimal #.Rev] + [nat_parser n.decimal .#Nat] + [rev_parser rev.decimal .#Rev] ) (template: (!signed_parser source_code//size offset where source_code @aliases @end) @@ -421,9 +420,9 @@ (!with_char+ source_code//size source_code g!offset/1 g!char/1 @end) (!if_digit? g!char/1 (signed_parser source_code//size offset where (!++/2 offset) source_code) - (!full_name_parser offset [where (!++ offset) source_code] where @aliases #.Identifier)))]) + (!full_name_parser offset [where (!++ offset) source_code] where @aliases .#Identifier)))]) -(with_expansions [<output> {#.Right [[(revised@ #.column (|>> (!n/+ (!n/- start end))) where) +(with_expansions [<output> {.#Right [[(revised@ .#column (|>> (!n/+ (!n/- start end))) where) end source_code] (!clip start end source_code)]}] @@ -440,7 +439,7 @@ (template: (!half_name_parser @offset @char @module) [(!if_name_char?|head @char (!letE [source' name] (..name_part_parser @offset (!forward 1 where) (!++ @offset) source_code) - {#.Right [source' [@module name]]}) + {.#Right [source' [@module name]]}) (!failure ..!half_name_parser where @offset source_code))]) (`` (def: (short_name_parser source_code//size current_module [where offset/0 source_code]) @@ -456,9 +455,9 @@ (template: (!short_name_parser source_code//size @current_module @source @where @tag) [(!letE [source' name] (..short_name_parser source_code//size @current_module @source) - {#.Right [source' [@where {@tag name}]]})]) + {.#Right [source' [@where {@tag name}]]})]) -(with_expansions [<simple> (as_is {#.Right [source' ["" simple]]})] +(with_expansions [<simple> (as_is {.#Right [source' ["" simple]]})] (`` (def: (full_name_parser aliases start source) (-> Aliases Offset (Parser Name)) (<| (!letE [source' simple] (let [[where offset source_code] source] @@ -471,7 +470,7 @@ (if ("lux text =" "" complex) (let [[where offset source_code] source] (!failure ..full_name_parser where offset source_code)) - {#.Right [source'' [(|> aliases + {.#Right [source'' [(|> aliases (dictionary.value simple) (maybe.else simple)) complex]]})) @@ -479,7 +478,7 @@ (template: (!full_name_parser @offset @source @where @aliases @tag) [(!letE [source' full_name] (..full_name_parser @aliases @offset @source) - {#.Right [source' [@where {@tag full_name}]]})]) + {.#Right [source' [@where {@tag full_name}]]})]) ... TODO: Grammar macro for specifying syntax. ... (grammar: lux_grammar @@ -492,14 +491,14 @@ <recur> (as_is (parse current_module aliases source_code//size))] (template: (!close closer) - [{#.Left [<move_1> closer]}]) + [{.#Left [<move_1> closer]}]) (def: (bit_syntax value [where offset/0 source_code]) (-> Bit (Parser Code)) - {#.Right [[(revised@ #.column (|>> !++/2) where) + {.#Right [[(revised@ .#column (|>> !++/2) where) (!++/2 offset/0) source_code] - [where {#.Bit value}]]}) + [where {.#Bit value}]]}) (def: .public (parse current_module aliases source_code//size) (-> Text Aliases Nat (Parser Code)) @@ -536,37 +535,15 @@ [(~~ (static ..text_delimiter))] (text_parser where (!++ offset/0) source_code) - ... Special code - [(~~ (static ..sigil))] - (<| (let [offset/1 (!++ offset/0)]) - (!with_char+ source_code//size source_code offset/1 char/1 - (!end_of_file where offset/1 source_code current_module)) - ("lux syntax char case!" char/1 - [[(~~ (static ..name_separator))] - (!short_name_parser source_code//size current_module <move_2> where #.Tag) - - (~~ (template [<char> <bit>] - [[<char>] - (..bit_syntax <bit> [where offset/0 source_code])] - - ["0" #0] - ["1" #1]))] - - ... else - (!if_name_char?|head char/1 - ... Tag - (!full_name_parser offset/1 <move_2> where aliases #.Tag) - (!failure ..parse where offset/0 source_code)))) - ... Coincidentally (= ..name_separator ..frac_separator) [(~~ (static ..name_separator)) ... (~~ (static ..frac_separator)) ] ... It's either a Rev, an identifier, or a comment. (with_expansions [<rev_parser> (rev_parser source_code//size offset/0 where (!++ offset/1) source_code) - <short_name_parser> (!short_name_parser source_code//size current_module [where offset/1 source_code] where #.Identifier) + <short_name_parser> (!short_name_parser source_code//size current_module [where offset/1 source_code] where .#Identifier) <comment_parser> (case ("lux text index" (!++ offset/1) (static text.new_line) source_code) - {#.Some end} + {.#Some end} (recur (!vertical where end source_code)) _ @@ -596,14 +573,29 @@ [(~~ (static ..positive_sign)) (~~ (static ..negative_sign))] (!signed_parser source_code//size offset/0 where source_code aliases - (!end_of_file where offset/0 source_code current_module))] + (!end_of_file where offset/0 source_code current_module)) + + [(~~ (static ..sigil))] + (<| (let [offset/1 (!++ offset/0)]) + (!with_char+ source_code//size source_code offset/1 char/1 + (!end_of_file where offset/1 source_code current_module)) + ("lux syntax char case!" char/1 + [(~~ (template [<char> <bit>] + [[<char>] + (..bit_syntax <bit> [where offset/0 source_code])] + + ["0" #0] + ["1" #1]))] + + ... else + (!full_name_parser offset/0 [<consume_1>] where aliases .#Identifier)))] ... else (!if_digit? char/0 ... Natural number (nat_parser source_code//size offset/0 where (!++ offset/0) source_code) ... Identifier - (!full_name_parser offset/0 [<consume_1>] where aliases #.Identifier)) + (!full_name_parser offset/0 [<consume_1>] where aliases .#Identifier)) ))) ))) )) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux index e718a2469..ad940f809 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux @@ -75,7 +75,7 @@ (type: .public (Path' s) (Variant - #Pop + {#Pop} {#Access Access} {#Bind Register} {#Bit_Fork Bit (Path' s) (Maybe (Path' s))} @@ -151,45 +151,45 @@ (def: .public path/pop Path - #Pop) + {#Pop}) (template [<name> <kind>] [(template: .public (<name> content) - [(.<| #..Access - <kind> + [(.<| {..#Access} + {<kind>} content)])] - [path/side #..Side] - [path/member #..Member] + [path/side ..#Side] + [path/member ..#Member] ) (template [<name> <kind> <side>] [(template: .public (<name> content) - [(.<| {#..Access} + [(.<| {..#Access} {<kind>} {<side>} content)])] - [side/left #..Side #.Left] - [side/right #..Side #.Right] - [member/left #..Member #.Left] - [member/right #..Member #.Right] + [side/left ..#Side .#Left] + [side/right ..#Side .#Right] + [member/left ..#Member .#Left] + [member/right ..#Member .#Right] ) (template [<name> <tag>] [(template: .public (<name> content) [{<tag> content}])] - [path/bind #..Bind] - [path/then #..Then] + [path/bind ..#Bind] + [path/then ..#Then] ) (template [<name> <tag>] [(template: .public (<name> left right) [{<tag> left right}])] - [path/alt #..Alt] - [path/seq #..Seq] + [path/alt ..#Alt] + [path/seq ..#Seq] ) (type: .public Abstraction @@ -223,27 +223,27 @@ (template [<name> <tag>] [(template: .public (<name> content) - [{#..Primitive {<tag> content}}])] + [{..#Primitive {<tag> content}}])] - [bit #..Bit] - [i64 #..I64] - [f64 #..F64] - [text #..Text] + [bit ..#Bit] + [i64 ..#I64] + [f64 ..#F64] + [text ..#Text] ) (template [<name> <tag>] [(template: .public (<name> content) - [(<| {#..Structure} + [(<| {..#Structure} {<tag>} content)])] - [variant #analysis.Variant] - [tuple #analysis.Tuple] + [variant analysis.#Variant] + [tuple analysis.#Tuple] ) (template [<name> <tag>] [(template: .public (<name> content) - [(.<| {#..Reference} + [(.<| {..#Reference} <tag> content)])] @@ -255,43 +255,43 @@ (template [<name> <family> <tag>] [(template: .public (<name> content) - [(.<| {#..Control} + [(.<| {..#Control} {<family>} {<tag>} content)])] - [branch/case #..Branch #..Case] - [branch/let #..Branch #..Let] - [branch/if #..Branch #..If] - [branch/get #..Branch #..Get] + [branch/case ..#Branch ..#Case] + [branch/let ..#Branch ..#Let] + [branch/if ..#Branch ..#If] + [branch/get ..#Branch ..#Get] - [loop/recur #..Loop #..Recur] - [loop/scope #..Loop #..Scope] + [loop/recur ..#Loop ..#Recur] + [loop/scope ..#Loop ..#Scope] - [function/abstraction #..Function #..Abstraction] - [function/apply #..Function #..Apply] + [function/abstraction ..#Function ..#Abstraction] + [function/apply ..#Function ..#Apply] ) (def: .public (%path' %then value) (All (_ a) (-> (Format a) (Format (Path' a)))) (case value - #Pop + {#Pop} "_" {#Bit_Fork when then else} (format "(?" " " (%.bit when) " " (%path' %then then) (case else - {#.Some else} + {.#Some else} (format " " (%.bit (not when)) " " (%path' %then else)) - #.None + {.#None} "") ")") (^template [<tag> <format>] [{<tag> item} - (|> {#.Item item} + (|> {.#Item item} (list\each (function (_ [test then]) (format (<format> test) " " (%path' %then then)))) (text.interposed " ") @@ -304,18 +304,18 @@ (case access {#Side side} (case side - {#.Left lefts} + {.#Left lefts} (format "(" (%.nat lefts) " #0" ")") - {#.Right lefts} + {.#Right lefts} (format "(" (%.nat lefts) " #1" ")")) {#Member member} (case member - {#.Left lefts} + {.#Left lefts} (format "[" (%.nat lefts) " #0" "]") - {#.Right lefts} + {.#Right lefts} (format "[" (%.nat lefts) " #1" "]"))) {#Bind register} @@ -348,12 +348,12 @@ {#Structure structure} (case structure - {#analysis.Variant [lefts right? content]} + {analysis.#Variant [lefts right? content]} (|> (%synthesis content) (format (%.nat lefts) " " (%.bit right?) " ") (text.enclosed ["{" "}"])) - {#analysis.Tuple members} + {analysis.#Tuple members} (|> members (list\each %synthesis) (text.interposed " ") @@ -393,7 +393,7 @@ {#Get members record} (|> (format (%.list (%path' %synthesis) - (list\each (|>> #Member #Access) members)) + (list\each (|>> {#Member} {#Access}) members)) " " (%synthesis record)) (text.enclosed ["{#get " "}"])) @@ -505,7 +505,7 @@ (def: (= reference sample) (case [reference sample] - [#Pop #Pop] + [{#Pop} {#Pop}] true [{#Bit_Fork reference_when reference_then reference_else} @@ -518,8 +518,8 @@ [[{<tag> reference_item} {<tag> sample_item}] (\ (list.equivalence (product.equivalence <equivalence> =)) = - {#.Item reference_item} - {#.Item sample_item})]) + {.#Item reference_item} + {.#Item sample_item})]) ([#I64_Fork i64.equivalence] [#F64_Fork f.equivalence] [#Text_Fork text.equivalence]) @@ -551,7 +551,7 @@ (def: (hash value) (case value - #Pop + {#Pop} 2 {#Access access} @@ -795,14 +795,14 @@ (template: .public (!bind_top register thenP) [($_ ..path/seq - {#..Bind register} - {#..Pop} + {..#Bind register} + {..#Pop} thenP)]) (template: .public (!multi_pop nextP) [($_ ..path/seq - {#..Pop} - {#..Pop} + {..#Pop} + {..#Pop} nextP)]) ... TODO: There are sister patterns to the simple side checks for tuples. @@ -816,7 +816,7 @@ [(template: .public (<name> idx nextP) [($_ ..path/seq (<side> idx) - #..Pop + ..#Pop nextP)])] [simple_left_side ..side/left] diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/archive.lux index 0f1f5ef2c..2c5b688a2 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive.lux @@ -90,70 +90,70 @@ (def: .public (id module archive) (-> Module Archive (Try ID)) - (let [(^slots [#..resolver]) (:representation archive)] - (case (dictionary.value module resolver) - {#.Some [id _]} - {#try.Success id} + (let [(^slots [..#resolver]) (:representation archive)] + (case (dictionary.value module #resolver) + {.#Some [id _]} + {try.#Success id} - #.None + {.#None} (exception.except ..unknown_document [module - (dictionary.keys resolver)])))) + (dictionary.keys #resolver)])))) (def: .public (reserve module archive) (-> Module Archive (Try [ID Archive])) - (let [(^slots [#..next #..resolver]) (:representation archive)] - (case (dictionary.value module resolver) - {#.Some _} + (let [(^open "_[0]") (:representation archive)] + (case (dictionary.value module _#resolver) + {.#Some _} (exception.except ..module_has_already_been_reserved [module]) - #.None - {#try.Success [next + {.#None} + {try.#Success [_#next (|> archive :representation - (revised@ #..resolver (dictionary.has module [next #.None])) - (revised@ #..next ++) + (revised@ #resolver (dictionary.has module [_#next {.#None}])) + (revised@ #next ++) :abstraction)]}))) (def: .public (has module [descriptor document output] archive) (-> Module [Descriptor (Document Any) Output] Archive (Try Archive)) - (let [(^slots [#..resolver]) (:representation archive)] - (case (dictionary.value module resolver) - {#.Some [id #.None]} - {#try.Success (|> archive + (let [(^slots [..#resolver]) (:representation archive)] + (case (dictionary.value module #resolver) + {.#Some [id {.#None}]} + {try.#Success (|> archive :representation - (revised@ #..resolver (dictionary.has module [id {#.Some [descriptor document output]}])) + (revised@ ..#resolver (dictionary.has module [id {.#Some [descriptor document output]}])) :abstraction)} - {#.Some [id {#.Some [existing_descriptor existing_document existing_output]}]} + {.#Some [id {.#Some [existing_descriptor existing_document existing_output]}]} (if (same? document existing_document) ... TODO: Find out why this code allows for the same module to be added more than once. It looks fishy... - {#try.Success archive} + {try.#Success archive} (exception.except ..cannot_replace_document [module existing_document document])) - #.None + {.#None} (exception.except ..module_must_be_reserved_before_it_can_be_added [module])))) (def: .public (find module archive) (-> Module Archive (Try [Descriptor (Document Any) Output])) - (let [(^slots [#..resolver]) (:representation archive)] - (case (dictionary.value module resolver) - {#.Some [id {#.Some entry}]} - {#try.Success entry} + (let [(^slots [..#resolver]) (:representation archive)] + (case (dictionary.value module #resolver) + {.#Some [id {.#Some entry}]} + {try.#Success entry} - {#.Some [id #.None]} + {.#Some [id {.#None}]} (exception.except ..module_is_only_reserved [module]) - #.None + {.#None} (exception.except ..unknown_document [module - (dictionary.keys resolver)])))) + (dictionary.keys #resolver)])))) (def: .public (archived? archive module) (-> Archive Module Bit) (case (..find module archive) - {#try.Success _} + {try.#Success _} bit.yes - {#try.Failure _} + {try.#Failure _} bit.no)) (def: .public archived @@ -163,17 +163,17 @@ dictionary.entries (list.all (function (_ [module [id descriptor+document]]) (case descriptor+document - {#.Some _} {#.Some module} - #.None #.None))))) + {.#Some _} {.#Some module} + {.#None} {.#None}))))) (def: .public (reserved? archive module) (-> Archive Module Bit) - (let [(^slots [#..resolver]) (:representation archive)] - (case (dictionary.value module resolver) - {#.Some [id _]} + (let [(^slots [..#resolver]) (:representation archive)] + (case (dictionary.value module #resolver) + {.#Some [id _]} bit.yes - #.None + {.#None} bit.no))) (def: .public reserved @@ -199,10 +199,10 @@ (revised@ #resolver (function (_ resolver) (list\mix (function (_ [module [id entry]] resolver) (case entry - {#.Some _} + {.#Some _} (dictionary.has module [id entry] resolver) - #.None + {.#None} resolver)) resolver (dictionary.entries +resolver)))) @@ -230,14 +230,14 @@ (def: .public (export version archive) (-> Version Archive Binary) - (let [(^slots [#..next #..resolver]) (:representation archive)] - (|> resolver + (let [(^slots [..#next ..#resolver]) (:representation archive)] + (|> #resolver dictionary.entries (list.all (function (_ [module [id descriptor+document]]) (case descriptor+document - {#.Some _} {#.Some [module id]} - #.None #.None))) - [version next] + {.#Some _} {.#Some [module id]} + {.#None} {.#None}))) + [version #next] (binary.result ..writer)))) (exception: .public (version_mismatch [expected Version @@ -280,7 +280,7 @@ (in (:abstraction [#next next #resolver (list\mix (function (_ [module id] archive) - (dictionary.has module [id #.None] archive)) + (dictionary.has module [id {.#None}] archive)) (value@ #resolver (:representation ..empty)) reservations)])))) ) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux index 75753c473..9681197b8 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux @@ -26,7 +26,7 @@ (type: .public Category (Variant - #Anonymous + {#Anonymous} {#Definition Text} {#Analyser Text} {#Synthesizer Text} @@ -64,7 +64,7 @@ (|> registry :representation (revised@ #artifacts (row.suffix [#id id - #category #Anonymous])) + #category {#Anonymous}])) :abstraction)])) (template [<tag> <create> <fetch>] @@ -86,8 +86,8 @@ (value@ #artifacts) row.list (list.all (|>> (value@ #category) - (case> {<tag> name} {#.Some name} - _ #.None)))))] + (case> {<tag> name} {.#Some name} + _ {.#None})))))] [#Definition definition definitions] [#Analyser analyser analysers] @@ -109,7 +109,8 @@ (function (_ value) (case value (^template [<nat> <tag> <writer>] - [{<tag> value} ((binary.and binary.nat <writer>) [<nat> value])]) + [{<tag> value} + ((binary.and binary.nat <writer>) [<nat> value])]) ([0 #Anonymous binary.any] [1 #Definition binary.text] [2 #Analyser binary.text] @@ -135,7 +136,8 @@ [tag <binary>.nat] (case tag (^template [<nat> <tag> <parser>] - [<nat> (\ ! each (|>> {<tag>}) <parser>)]) + [<nat> + (\ ! each (|>> {<tag>}) <parser>)]) ([0 #Anonymous <binary>.any] [1 #Definition <binary>.text] [2 #Analyser <binary>.text] @@ -149,7 +151,7 @@ (\ <>.monad each (row\mix (function (_ artifact registry) (product.right (case artifact - #Anonymous + {#Anonymous} (..resource registry) (^template [<tag> <create>] diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/descriptor.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/descriptor.lux index e45c69fa2..f1f68d434 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/descriptor.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/descriptor.lux @@ -44,7 +44,7 @@ <b>.text <b>.text <b>.nat - (\ <>.monad in #.Cached) + (\ <>.monad in {.#Cached}) (<b>.set text.hash <b>.text) artifact.parser )) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux index d007967f2..3207e7b8f 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux @@ -37,7 +37,7 @@ (if (\ signature.equivalence = (key.signature key) document//signature) - {#try.Success (:sharing [e] + {try.#Success (:sharing [e] (Key e) key diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux index f586c398a..a7acc969b 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux @@ -57,10 +57,10 @@ (function (_ recur module) (do [! state.monad] [.let [parents (case (archive.find module archive) - {#try.Success [descriptor document]} - (value@ #descriptor.references descriptor) + {try.#Success [descriptor document]} + (value@ descriptor.#references descriptor) - {#try.Failure error} + {try.#Failure error} ..fresh)] ancestors (monad.each ! recur (set.list parents))] (in (list\mix set.union parents ancestors))))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux index fe1e8d223..a41580fd6 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux @@ -61,9 +61,9 @@ (def: (archive fs static) (All (_ !) (-> (file.System !) Static file.Path)) - (format (value@ #static.target static) + (format (value@ static.#target static) (\ fs separator) - (value@ #static.host static))) + (value@ static.#host static))) (def: (unversioned_lux_archive fs static) (All (_ !) (-> (file.System !) Static file.Path)) @@ -88,14 +88,14 @@ (format (..module fs static module_id) (\ fs separator) (%.nat artifact_id) - (value@ #static.artifact_extension static))) + (value@ static.#artifact_extension static))) (def: (ensure_directory fs path) (-> (file.System Async) file.Path (Async (Try Any))) (do async.monad [? (\ fs directory? path)] (if ? - (in {#try.Success []}) + (in {try.#Success []}) (\ fs make_directory path)))) (def: .public (prepare fs static module_id) @@ -104,16 +104,16 @@ [.let [module (..module fs static module_id)] module_exists? (\ fs directory? module)] (if module_exists? - (in {#try.Success []}) + (in {try.#Success []}) (do (try.with !) [_ (ensure_directory fs (..unversioned_lux_archive fs static)) _ (ensure_directory fs (..versioned_lux_archive fs static))] (|> module (\ fs make_directory) - (\ ! each (|>> (case> {#try.Success output} - {#try.Success []} + (\ ! each (|>> (case> {try.#Success output} + {try.#Success []} - {#try.Failure error} + {try.#Failure error} (exception.except ..cannot_prepare [(..archive fs static) module_id error]))))))))) @@ -125,7 +125,7 @@ (def: .public (enable fs static) (-> (file.System Async) Static (Async (Try Any))) (do (try.with async.monad) - [_ (..ensure_directory fs (value@ #static.target static))] + [_ (..ensure_directory fs (value@ static.#target static))] (..ensure_directory fs (..archive fs static)))) (def: (general_descriptor fs static) @@ -174,7 +174,7 @@ content (document.read $.key document)] (in [module content]))) (archive.archived archive)))] - (in (with@ #.modules modules (fresh_analysis_state host))))) + (in (with@ .#modules modules (fresh_analysis_state host))))) (def: (cached_artifacts fs static module_id) (-> (file.System Async) Static archive.ID (Async (Try (Dictionary Text Binary)))) @@ -223,16 +223,16 @@ output (: Output row.empty)] (let [[analysers synthesizers generators directives] bundles] (case input - {#.Item [[artifact_id artifact_category] input']} + {.#Item [[artifact_id artifact_category] input']} (case (do ! [data (try.of_maybe (dictionary.value (format (%.nat artifact_id) extension) actual)) .let [context [module_id artifact_id] directive (\ host ingest context data)]] (case artifact_category - #artifact.Anonymous + {artifact.#Anonymous} (do ! - [.let [output (row.suffix [artifact_id #.None data] output)] - _ (\ host re_learn context #.None directive)] + [.let [output (row.suffix [artifact_id .#None data] output)] + _ (\ host re_learn context {.#None} directive)] (in [definitions [analysers synthesizers @@ -240,8 +240,8 @@ directives] output])) - {#artifact.Definition name} - (let [output (row.suffix [artifact_id #.None data] output)] + {artifact.#Definition name} + (let [output (row.suffix [artifact_id {.#None} data] output)] (if (text\= $/program.name name) (in [definitions [analysers @@ -250,7 +250,7 @@ directives] output]) (do ! - [value (\ host re_load context #.None directive)] + [value (\ host re_load context {.#None} directive)] (in [(dictionary.has name value definitions) [analysers synthesizers @@ -258,10 +258,10 @@ directives] output])))) - {#artifact.Analyser extension} + {artifact.#Analyser extension} (do ! - [.let [output (row.suffix [artifact_id #.None data] output)] - value (\ host re_load context #.None directive)] + [.let [output (row.suffix [artifact_id {.#None} data] output)] + value (\ host re_load context {.#None} directive)] (in [definitions [(dictionary.has extension (:as analysis.Handler value) analysers) synthesizers @@ -269,10 +269,10 @@ directives] output])) - {#artifact.Synthesizer extension} + {artifact.#Synthesizer extension} (do ! - [.let [output (row.suffix [artifact_id #.None data] output)] - value (\ host re_load context #.None directive)] + [.let [output (row.suffix [artifact_id {.#None} data] output)] + value (\ host re_load context {.#None} directive)] (in [definitions [analysers (dictionary.has extension (:as synthesis.Handler value) synthesizers) @@ -280,10 +280,10 @@ directives] output])) - {#artifact.Generator extension} + {artifact.#Generator extension} (do ! - [.let [output (row.suffix [artifact_id #.None data] output)] - value (\ host re_load context #.None directive)] + [.let [output (row.suffix [artifact_id {.#None} data] output)] + value (\ host re_load context {.#None} directive)] (in [definitions [analysers synthesizers @@ -291,10 +291,10 @@ directives] output])) - {#artifact.Directive extension} + {artifact.#Directive extension} (do ! - [.let [output (row.suffix [artifact_id #.None data] output)] - value (\ host re_load context #.None directive)] + [.let [output (row.suffix [artifact_id {.#None} data] output)] + value (\ host re_load context {.#None} directive)] (in [definitions [analysers synthesizers @@ -302,50 +302,50 @@ (dictionary.has extension (:as directive.Handler value) directives)] output])) - {#artifact.Custom name} + {artifact.#Custom name} (do ! - [.let [output (row.suffix [artifact_id {#.Some name} data] output)] - _ (\ host re_learn context {#.Some name} directive)] + [.let [output (row.suffix [artifact_id {.#Some name} data] output)] + _ (\ host re_learn context {.#Some name} directive)] (in [definitions [analysers synthesizers generators directives] output])))) - {#try.Success [definitions' bundles' output']} + {try.#Success [definitions' bundles' output']} (recur input' definitions' bundles' output') failure failure) - #.End - {#try.Success [definitions bundles output]})))) + {.#End} + {try.#Success [definitions bundles output]})))) content (document.read $.key document) definitions (monad.each ! (function (_ [def_name def_global]) (case def_global (^template [<tag>] [{<tag> payload} (in [def_name {<tag> payload}])]) - ([#.Alias] - [#.Label] - [#.Slot]) + ([.#Alias] + [.#Label] + [.#Slot]) - {#.Definition [exported? type _]} + {.#Definition [exported? type _]} (|> definitions (dictionary.value def_name) try.of_maybe (\ ! each (|>> [exported? type] - {#.Definition} + {.#Definition} [def_name]))) - {#.Type [exported? _ labels]} + {.#Type [exported? _ labels]} (|> definitions (dictionary.value def_name) try.of_maybe (\ ! each (function (_ def_value) - [def_name {#.Type [exported? (:as .Type def_value) labels]}]))))) - (value@ #.definitions content))] - (in [(document.write $.key (with@ #.definitions definitions content)) + [def_name {.#Type [exported? (:as .Type def_value) labels]}]))))) + (value@ .#definitions content))] + (in [(document.write $.key (with@ .#definitions definitions content)) bundles]))) (def: (load_definitions fs static module_id host_environment descriptor document) @@ -356,8 +356,8 @@ Bundles])))) (do (try.with async.monad) [actual (cached_artifacts fs static module_id) - .let [expected (|> descriptor (value@ #descriptor.registry) artifact.artifacts)] - [document bundles output] (async\in (loaded_document (value@ #static.artifact_extension static) host_environment module_id expected actual document))] + .let [expected (|> descriptor (value@ descriptor.#registry) artifact.artifacts)] + [document bundles output] (async\in (loaded_document (value@ static.#artifact_extension static) host_environment module_id expected actual document))] (in [[descriptor document output] bundles]))) (def: (purge! fs static [module_name module_id]) @@ -372,12 +372,12 @@ (def: (valid_cache? expected actual) (-> Descriptor Input Bit) - (and (text\= (value@ #descriptor.name expected) - (value@ #////.module actual)) - (text\= (value@ #descriptor.file expected) - (value@ #////.file actual)) - (n.= (value@ #descriptor.hash expected) - (value@ #////.hash actual)))) + (and (text\= (value@ descriptor.#name expected) + (value@ ////.#module actual)) + (text\= (value@ descriptor.#file expected) + (value@ ////.#file actual)) + (n.= (value@ descriptor.#hash expected) + (value@ ////.#hash actual)))) (type: Purge (Dictionary Module archive.ID)) @@ -387,8 +387,8 @@ Purge) (|>> (list.all (function (_ [valid_cache? [module_name [module_id _]]]) (if valid_cache? - #.None - {#.Some [module_name module_id]}))) + {.#None} + {.#Some [module_name module_id]}))) (dictionary.of_list text.hash))) (def: (full_purge caches load_order) @@ -401,7 +401,7 @@ (if (purged? module_name) purge (if (|> descriptor - (value@ #descriptor.references) + (value@ descriptor.#references) set.list (list.any? purged?)) (dictionary.has module_name module_id purge) @@ -428,7 +428,7 @@ (in [true [module_name [module_id [descriptor document]]]]) (do ! - [input (//context.read fs ..pseudo_module import contexts (value@ #static.host_module_extension static) module_name)] + [input (//context.read fs ..pseudo_module import contexts (value@ static.#host_module_extension static) module_name)] (in [(..valid_cache? descriptor input) [module_name [module_id [descriptor document]]]]))))))) load_order (|> pre_loaded_caches @@ -458,7 +458,7 @@ (archive.has module descriptor,document,output archive)) archive loaded_caches) - analysis_state (..analysis_state (value@ #static.host static) archive)] + analysis_state (..analysis_state (value@ static.#host static) archive)] (in [archive analysis_state (list\mix (function (_ [_ [+analysers +synthesizers +generators +directives]] @@ -477,12 +477,12 @@ (do async.monad [binary (\ fs read (..general_descriptor fs static))] (case binary - {#try.Success binary} + {try.#Success binary} (do (try.with async.monad) [archive (async\in (archive.import ///.version binary))] (..load_every_reserved_module host_environment fs static import contexts archive)) - {#try.Failure error} - (in {#try.Success [archive.empty - (fresh_analysis_state (value@ #static.host static)) + {try.#Failure error} + (in {try.#Success [archive.empty + (fresh_analysis_state (value@ static.#host static)) ..empty_bundles]})))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux index 69a0858e6..59d06a9fd 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux @@ -58,15 +58,15 @@ (-> (file.System Async) Module (List Context) Module Extension (Async (Try file.Path))) (case contexts - #.End + {.#End} (async\in (exception.except ..cannot_find_module [importer module])) - {#.Item context contexts'} + {.#Item context contexts'} (let [path (format (..path fs context module) extension)] (do async.monad [? (\ fs file? path)] (if ? - (in {#try.Success path}) + (in {try.#Success path}) (find_source_file fs importer contexts' module extension)))))) (def: (full_host_extension partial_host_extension) @@ -81,12 +81,12 @@ (do [! async.monad] [outcome (..find_source_file fs importer contexts module (..full_host_extension partial_host_extension))] (case outcome - {#try.Success path} + {try.#Success path} (|> path (\ fs read) (\ (try.with !) each (|>> [path]))) - {#try.Failure _} + {try.#Failure _} (do [! (try.with !)] [path (..find_source_file fs importer contexts module ..lux_extension)] (|> path @@ -97,16 +97,16 @@ (-> Module Import Extension Module (Try [file.Path Binary])) (let [path (format module (..full_host_extension partial_host_extension))] (case (dictionary.value path import) - {#.Some data} - {#try.Success [path data]} + {.#Some data} + {try.#Success [path data]} - #.None + {.#None} (let [path (format module ..lux_extension)] (case (dictionary.value path import) - {#.Some data} - {#try.Success [path data]} + {.#Some data} + {try.#Success [path data]} - #.None + {.#None} (exception.except ..cannot_find_module [importer module])))))) (def: (find_any_source_file fs importer import contexts partial_host_extension module) @@ -117,10 +117,10 @@ (do [! async.monad] [outcome (find_local_source_file fs importer import contexts partial_host_extension module)] (case outcome - {#try.Success [path data]} + {try.#Success [path data]} (in outcome) - {#try.Failure _} + {try.#Failure _} (in (..find_library_source_file importer import partial_host_extension module))))) (def: .public (read fs importer import contexts partial_host_extension module) @@ -129,13 +129,13 @@ (do (try.with async.monad) [[path binary] (..find_any_source_file fs importer import contexts partial_host_extension module)] (case (\ utf8.codec decoded binary) - {#try.Success code} - (in [#////.module module - #////.file path - #////.hash (text\hash code) - #////.code code]) + {try.#Success code} + (in [////.#module module + ////.#file path + ////.#hash (text\hash code) + ////.#code code]) - {#try.Failure _} + {try.#Failure _} (async\in (exception.except ..cannot_read_module [module]))))) (type: .public Enumeration diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager.lux b/stdlib/source/library/lux/tool/compiler/meta/packager.lux index e9224a8d0..73d919175 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager.lux @@ -35,8 +35,8 @@ (-> dependency.Order Order) (list\each (function (_ [module [module_id [descriptor document]]]) (|> descriptor - (value@ #descriptor.registry) + (value@ descriptor.#registry) artifact.artifacts row.list - (list\each (|>> (value@ #artifact.id))) + (list\each (|>> (value@ artifact.#id))) [module_id])))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux index 75eca1c30..9faeb3b47 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux @@ -143,7 +143,7 @@ (let [class_path (|> custom (maybe\each (|>> name.internal name.read)) (maybe.else (runtime.class_name [module artifact])) - (text.suffix (value@ #static.artifact_extension static)))] + (text.suffix (value@ static.#artifact_extension static)))] (do try.monad [_ (java/util/jar/JarOutputStream::putNextEntry (java/util/jar/JarEntry::new class_path) sink)] (in (do_to sink @@ -208,29 +208,29 @@ duplicates duplicates sink sink] (case (java/util/jar/JarInputStream::getNextJarEntry input) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success ?entry} + {try.#Success ?entry} (case ?entry - #.None + {.#None} (exec (java/io/Closeable::close input) - {#try.Success [entries duplicates sink]}) + {try.#Success [entries duplicates sink]}) - {#.Some entry} + {.#Some entry} (let [entry_path (java/util/zip/ZipEntry::getName entry) entry_size (java/util/zip/ZipEntry::getSize entry)] (if (not (or (java/util/zip/ZipEntry::isDirectory entry) (text.starts_with? "META-INF/maven/" entry_path) (text.starts_with? "META-INF/leiningen/" entry_path))) (case (java/util/jar/JarOutputStream::putNextEntry (java/util/jar/JarEntry::new entry_path) sink) - {#try.Failure error} + {try.#Failure error} (recur entries (set.has entry_path duplicates) sink) - {#try.Success _} + {try.#Success _} (let [[entry_size entry_data] (read_jar_entry entry input)] (recur (set.has entry_path entries) duplicates diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux index c78d07b6f..b5d364a3d 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux @@ -88,12 +88,12 @@ (def: owner tar.Owner - [#tar.name tar.anonymous - #tar.id tar.no_id]) + [tar.#name tar.anonymous + tar.#id tar.no_id]) (def: ownership - [#tar.user ..owner - #tar.group ..owner]) + [tar.#user ..owner + tar.#group ..owner]) (def: (write_module now mapping [module [module_id [descriptor document output]]]) (-> Instant (Dictionary Module archive.ID) @@ -104,7 +104,7 @@ (..bundle_module output)) entry_content (: (Try tar.Content) (|> descriptor - (value@ #descriptor.references) + (value@ descriptor.#references) set.list (list.all (function (_ module) (dictionary.value module mapping))) (list\each (|>> ..module_file _.string _.load_relative/1)) @@ -114,7 +114,7 @@ (\ encoding.utf8 encoded) tar.content)) module_file (tar.path (..module_file module_id))] - (in {#tar.Normal [module_file now ..mode ..ownership entry_content]}))) + (in {tar.#Normal [module_file now ..mode ..ownership entry_content]}))) (def: .public (package now) (-> Instant Packager) diff --git a/stdlib/source/library/lux/tool/compiler/phase.lux b/stdlib/source/library/lux/tool/compiler/phase.lux index 4809e8ed9..a54785eed 100644 --- a/stdlib/source/library/lux/tool/compiler/phase.lux +++ b/stdlib/source/library/lux/tool/compiler/phase.lux @@ -53,13 +53,13 @@ (All (_ s o) (Operation s s)) (function (_ state) - {#try.Success [state state]})) + {try.#Success [state state]})) (def: .public (set_state state) (All (_ s o) (-> s (Operation s Any))) (function (_ _) - {#try.Success [state []]})) + {try.#Success [state []]})) (def: .public (sub [get set] operation) (All (_ s s' o) @@ -73,7 +73,7 @@ (def: .public failure (-> Text Operation) - (|>> #try.Failure (state.lifted try.monad))) + (|>> {try.#Failure} (state.lifted try.monad))) (def: .public (except exception parameters) (All (_ e) (-> (Exception e) e Operation)) @@ -94,7 +94,7 @@ (def: .public identity (All (_ s a) (Phase s a a)) (function (_ archive input state) - {#try.Success [state input]})) + {try.#Success [state input]})) (def: .public (composite pre post) (All (_ s0 s1 i t o) diff --git a/stdlib/source/library/lux/tool/compiler/reference.lux b/stdlib/source/library/lux/tool/compiler/reference.lux index 0f345a12f..e61fc7b99 100644 --- a/stdlib/source/library/lux/tool/compiler/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/reference.lux @@ -48,20 +48,21 @@ (case value (^template [<factor> <tag> <hash>] [{<tag> value} - ($_ n.* <factor> - (\ <hash> hash value))]) + (|> value + (\ <hash> hash) + (n.* <factor>))]) ([2 #Variable /variable.hash] [3 #Constant name.hash]) ))) (template [<name> <family> <tag>] [(template: .public (<name> content) - [(<| <family> + [(<| {<family>} {<tag>} content)])] - [local #..Variable #/variable.Local] - [foreign #..Variable #/variable.Foreign] + [local ..#Variable /variable.#Local] + [foreign ..#Variable /variable.#Foreign] ) (template [<name> <tag>] @@ -69,8 +70,8 @@ [(<| {<tag>} content)])] - [variable #..Variable] - [constant #..Constant] + [variable ..#Variable] + [constant ..#Constant] ) (def: .public self diff --git a/stdlib/source/library/lux/tool/compiler/reference/variable.lux b/stdlib/source/library/lux/tool/compiler/reference/variable.lux index bde1de15b..e3c5ce5c2 100644 --- a/stdlib/source/library/lux/tool/compiler/reference/variable.lux +++ b/stdlib/source/library/lux/tool/compiler/reference/variable.lux @@ -44,13 +44,14 @@ (def: hash (|>> (case> (^template [<factor> <tag>] [{<tag> register} - ($_ n.* <factor> - (\ n.hash hash register))]) + (|> register + (\ n.hash hash) + (n.* <factor>))]) ([2 #Local] [3 #Foreign]))))) (template: .public (self) - [{#..Local 0}]) + [{..#Local 0}]) (def: .public self? (-> Variable Bit) diff --git a/stdlib/source/library/lux/tool/interpreter.lux b/stdlib/source/library/lux/tool/interpreter.lux index 85020815f..323aa7ff4 100644 --- a/stdlib/source/library/lux/tool/interpreter.lux +++ b/stdlib/source/library/lux/tool/interpreter.lux @@ -75,14 +75,14 @@ (do Monad<!> [state (platform.initialize platform generation_bundle) state (platform.compile platform - (with@ #cli.module syntax.prelude configuration) - (with@ [#extension.state - #directive.analysis #directive.state - #extension.state - #.info #.mode] - #.Interpreter + (with@ cli.#module syntax.prelude configuration) + (with@ [extension.#state + directive.#analysis directive.#state + extension.#state + .#info .#mode] + {.#Interpreter} state)) - [state _] (\ (value@ #platform.file_system platform) + [state _] (\ (value@ platform.#file_system platform) lift (phase.result' state enter_module)) _ (\ Console<!> write ..welcome_message)] (in state))) @@ -102,9 +102,9 @@ (-> Code <Interpretation>)) (do [! phase.monad] [state (extension.lifted phase.get_state) - .let [analyse (value@ [#directive.analysis #directive.phase] state) - synthesize (value@ [#directive.synthesis #directive.phase] state) - generate (value@ [#directive.generation #directive.phase] state)] + .let [analyse (value@ [directive.#analysis directive.#phase] state) + synthesize (value@ [directive.#synthesis directive.#phase] state) + generate (value@ [directive.#generation directive.#phase] state)] [_ codeT codeA] (directive.lifted_analysis (analysis.with_scope (type.with_fresh_env @@ -135,10 +135,10 @@ <Interpretation> (interpret_directive code))) - {#try.Success [state' output]} - {#try.Success [state' output]} + {try.#Success [state' output]} + {try.#Success [state' output]} - {#try.Failure error} + {try.#Failure error} (if (ex.match? total.not_a_directive error) (<| (phase.result' state) (:sharing [anchor expression directive] @@ -147,7 +147,7 @@ <Interpretation> (interpret_expression code))) - {#try.Failure error})))) + {try.#Failure error})))) ) (def: (execute configuration code) @@ -156,9 +156,9 @@ (do phase.monad [[codeT codeV] (interpret configuration code) state phase.get_state] - (in (/type.represent (value@ [#extension.state - #directive.analysis #directive.state - #extension.state] + (in (/type.represent (value@ [extension.#state + directive.#analysis directive.#state + extension.#state] state) codeT codeV)))) @@ -218,12 +218,12 @@ (text\= ..exit_command line)) (\ Console<!> write ..farewell_message) (case (read_eval_print (revised@ #source (add_line line) context)) - {#try.Success [context' representation]} + {try.#Success [context' representation]} (do ! [_ (\ Console<!> write representation)] (recur context' #0)) - {#try.Failure error} + {try.#Failure error} (if (ex.match? syntax.end_of_file error) (recur context #1) (exec (log! (ex.error ..error error)) diff --git a/stdlib/source/library/lux/type.lux b/stdlib/source/library/lux/type.lux index d01e2948b..fb91a6a2b 100644 --- a/stdlib/source/library/lux/type.lux +++ b/stdlib/source/library/lux/type.lux @@ -39,14 +39,14 @@ _ [num_args type])))] - [flat_univ_q #.UnivQ] - [flat_ex_q #.ExQ] + [flat_univ_q .#UnivQ] + [flat_ex_q .#ExQ] ) (def: .public (flat_function type) (-> Type [(List Type) Type]) (case type - {#.Function in out'} + {.#Function in out'} (let [[ins out] (flat_function out')] [(list& in ins) out]) @@ -56,7 +56,7 @@ (def: .public (flat_application type) (-> Type [Type (List Type)]) (case type - {#.Apply arg func'} + {.#Apply arg func'} (let [[func args] (flat_application func')] [func (list\composite args (list arg))]) @@ -73,14 +73,14 @@ _ (list type)))] - [flat_variant #.Sum] - [flat_tuple #.Product] + [flat_variant .#Sum] + [flat_tuple .#Product] ) (def: .public (format type) (-> Type Text) (case type - {#.Primitive name params} + {.#Primitive name params} ($_ text\composite "(primitive " (text.enclosed' text.double_quote name) @@ -98,10 +98,10 @@ (list.interposed " ") (list\mix text\composite "")) <close>)]) - ([#.Sum "(Or " ")" flat_variant] - [#.Product "[" "]" flat_tuple]) + ([.#Sum "(Or " ")" flat_variant] + [.#Product "[" "]" flat_tuple]) - {#.Function input output} + {.#Function input output} (let [[ins out] (flat_function type)] ($_ text\composite "(-> " (|> ins @@ -111,26 +111,26 @@ (list\mix text\composite "")) " " (format out) ")")) - {#.Parameter idx} + {.#Parameter idx} (n\encoded idx) - {#.Var id} + {.#Var id} ($_ text\composite "⌈v:" (n\encoded id) "⌋") - {#.Ex id} + {.#Ex id} ($_ text\composite "⟨e:" (n\encoded id) "⟩") - {#.Apply param fun} + {.#Apply param fun} (let [[type_func type_args] (flat_application type)] ($_ text\composite "(" (format type_func) " " (|> type_args (list\each format) list.reversed (list.interposed " ") (list\mix text\composite "")) ")")) (^template [<tag> <desc>] [{<tag> env body} ($_ text\composite "(" <desc> " {" (|> env (list\each format) (text.interposed " ")) "} " (format body) ")")]) - ([#.UnivQ "All"] - [#.ExQ "Ex"]) + ([.#UnivQ "All"] + [.#ExQ "Ex"]) - {#.Named [module name] type} + {.#Named [module name] type} ($_ text\composite module "." name) )) @@ -138,27 +138,27 @@ (def: (reduced env type) (-> (List Type) Type Type) (case type - {#.Primitive name params} - {#.Primitive name (list\each (reduced env) params)} + {.#Primitive name params} + {.#Primitive name (list\each (reduced env) params)} (^template [<tag>] [{<tag> left right} {<tag> (reduced env left) (reduced env right)}]) - ([#.Sum] [#.Product] - [#.Function] [#.Apply]) + ([.#Sum] [.#Product] + [.#Function] [.#Apply]) (^template [<tag>] [{<tag> old_env def} (case old_env - #.End + {.#End} {<tag> env def} _ {<tag> (list\each (reduced env) old_env) def})]) - ([#.UnivQ] - [#.ExQ]) + ([.#UnivQ] + [.#ExQ]) - {#.Parameter idx} + {.#Parameter idx} (maybe.else (panic! ($_ text\composite "Unknown type parameter" text.new_line " Index: " (n\encoded idx) text.new_line @@ -183,7 +183,7 @@ @.php false] (same? x y)) (case [x y] - [{#.Primitive xname xparams} {#.Primitive yname yparams}] + [{.#Primitive xname xparams} {.#Primitive yname yparams}] (and (text\= xname yname) (n.= (list.size yparams) (list.size xparams)) (list\mix (.function (_ [x y] prev) (and prev (= x y))) @@ -193,24 +193,24 @@ (^template [<tag>] [[{<tag> xid} {<tag> yid}] (n.= yid xid)]) - ([#.Var] [#.Ex] [#.Parameter]) + ([.#Var] [.#Ex] [.#Parameter]) - (^or [{#.Function xleft xright} {#.Function yleft yright}] - [{#.Apply xleft xright} {#.Apply yleft yright}]) + (^or [{.#Function xleft xright} {.#Function yleft yright}] + [{.#Apply xleft xright} {.#Apply yleft yright}]) (and (= xleft yleft) (= xright yright)) - [{#.Named xname xtype} {#.Named yname ytype}] + [{.#Named xname xtype} {.#Named yname ytype}] (and (name\= xname yname) (= xtype ytype)) (^template [<tag>] [[{<tag> xL xR} {<tag> yL yR}] (and (= xL yL) (= xR yR))]) - ([#.Sum] [#.Product]) + ([.#Sum] [.#Product]) - (^or [{#.UnivQ xenv xbody} {#.UnivQ yenv ybody}] - [{#.ExQ xenv xbody} {#.ExQ yenv ybody}]) + (^or [{.#UnivQ xenv xbody} {.#UnivQ yenv ybody}] + [{.#ExQ xenv xbody} {.#ExQ yenv ybody}]) (and (n.= (list.size yenv) (list.size xenv)) (= xbody ybody) (list\mix (.function (_ [x y] prev) (and prev (= x y))) @@ -224,60 +224,60 @@ (def: .public (applied params func) (-> (List Type) Type (Maybe Type)) (case params - #.End - {#.Some func} + {.#End} + {.#Some func} - {#.Item param params'} + {.#Item param params'} (case func (^template [<tag>] [{<tag> env body} (|> body (reduced (list& func param env)) (applied params'))]) - ([#.UnivQ] [#.ExQ]) + ([.#UnivQ] [.#ExQ]) - {#.Apply A F} + {.#Apply A F} (applied (list& A params) F) - {#.Named name unnamed} + {.#Named name unnamed} (applied params unnamed) _ - #.None))) + {.#None}))) (def: .public (code type) (-> Type Code) (case type - {#.Primitive name params} - (` {#.Primitive (~ (code.text name)) + {.#Primitive name params} + (` {.#Primitive (~ (code.text name)) (.list (~+ (list\each code params)))}) (^template [<tag>] [{<tag> idx} (` {<tag> (~ (code.nat idx))})]) - ([#.Var] [#.Ex] [#.Parameter]) + ([.#Var] [.#Ex] [.#Parameter]) (^template [<tag>] [{<tag> left right} (` {<tag> (~ (code left)) (~ (code right))})]) - ([#.Sum] [#.Product] [#.Function] [#.Apply]) + ([.#Sum] [.#Product] [.#Function] [.#Apply]) - {#.Named name sub_type} + {.#Named name sub_type} (code.identifier name) (^template [<tag>] [{<tag> env body} (` {<tag> (.list (~+ (list\each code env))) (~ (code body))})]) - ([#.UnivQ] [#.ExQ]) + ([.#UnivQ] [.#ExQ]) )) (def: .public (de_aliased type) (-> Type Type) (case type - {#.Named _ {#.Named name type'}} - (de_aliased {#.Named name type'}) + {.#Named _ {.#Named name type'}} + (de_aliased {.#Named name type'}) _ type)) @@ -285,7 +285,7 @@ (def: .public (anonymous type) (-> Type Type) (case type - {#.Named name type'} + {.#Named name type'} (anonymous type') _ @@ -295,36 +295,36 @@ [(def: .public (<name> types) (-> (List Type) Type) (case types - #.End + {.#End} <base> - {#.Item type #.End} + {.#Item type {.#End}} type - {#.Item type types'} + {.#Item type types'} {<ctor> type (<name> types')}))] - [variant Nothing #.Sum] - [tuple Any #.Product] + [variant Nothing .#Sum] + [tuple Any .#Product] ) (def: .public (function inputs output) (-> (List Type) Type Type) (case inputs - #.End + {.#End} output - {#.Item input inputs'} - {#.Function input (function inputs' output)})) + {.#Item input inputs'} + {.#Function input (function inputs' output)})) (def: .public (application params quant) (-> (List Type) Type Type) (case params - #.End + {.#End} quant - {#.Item param params'} - (application params' {#.Apply param quant}))) + {.#Item param params'} + (application params' {.#Apply param quant}))) (template [<name> <tag>] [(def: .public (<name> size body) @@ -333,22 +333,22 @@ 0 body _ (|> body (<name> (-- size)) {<tag> (list)})))] - [univ_q #.UnivQ] - [ex_q #.ExQ] + [univ_q .#UnivQ] + [ex_q .#ExQ] ) (def: .public (quantified? type) (-> Type Bit) (case type - {#.Named [module name] _type} + {.#Named [module name] _type} (quantified? _type) - {#.Apply A F} + {.#Apply A F} (|> (..applied (list A) F) (\ maybe.monad each quantified?) (maybe.else #0)) - (^or {#.UnivQ _} {#.ExQ _}) + (^or {.#UnivQ _} {.#ExQ _}) #1 _ @@ -361,12 +361,12 @@ _ (|> element_type (array (-- depth)) (list) - {#.Primitive array.type_name}))) + {.#Primitive array.type_name}))) (def: .public (flat_array type) (-> Type [Nat Type]) (case type - (^multi (^ {#.Primitive name (list element_type)}) + (^multi (^ {.#Primitive name (list element_type)}) (text\= array.type_name name)) (let [[depth element_type] (flat_array element_type)] [(++ depth) element_type]) @@ -391,7 +391,7 @@ (<>.maybe (<>.after (<code>.identifier! ..secret_marker) <code>.any))) <code>.any)]) (case input - {#.Left [valueN valueC]} + {.#Left [valueN valueC]} (do meta.monad [location meta.location valueT (meta.type valueN) @@ -399,16 +399,16 @@ ($_ text\composite (name\encoded (name_of ..:log!)) " " (location.format location) text.new_line "Expression: " (case valueC - {#.Some valueC} + {.#Some valueC} (code.format valueC) - #.None + {.#None} (name\encoded valueN)) text.new_line " Type: " (..format valueT)))]] (in (list (code.identifier valueN)))) - {#.Right valueC} + {.#Right valueC} (macro.with_identifiers [g!value] (in (list (` (.let [(~ g!value) (~ valueC)] (..:log! (~ valueC) (~ (code.identifier ..secret_marker)) (~ g!value))))))))) @@ -426,10 +426,10 @@ (-> (~ input) (~ output))) (|>> :expected)))] (case value - #.None + {.#None} (in (list casterC)) - {#.Some value} + {.#Some value} (in (list (` ((~ casterC) (~ value))))))))) (type: Typed diff --git a/stdlib/source/library/lux/type/abstract.lux b/stdlib/source/library/lux/type/abstract.lux index 51216b293..9ce2ce24d 100644 --- a/stdlib/source/library/lux/type/abstract.lux +++ b/stdlib/source/library/lux/type/abstract.lux @@ -28,7 +28,7 @@ (def: (push value stack) (All (_ a) (-> a (Stack a) (Stack a))) - {#.Item value stack}) + {.#Item value stack}) (def: pop (All (_ a) (-> (Stack a) (Maybe (Stack a)))) @@ -43,36 +43,36 @@ (def: frames (Stack Frame) - #.End) + {.#End}) (template: (!peek <source> <reference> <then>) [(loop [entries <source>] (case entries - {#.Item [head_name head] tail} + {.#Item [head_name head] tail} (if (text\= <reference> head_name) <then> (recur tail)) - #.End + {.#End} (undefined)))]) (def: (peek_frames_definition reference source) (-> Text (List [Text Global]) (Stack Frame)) (!peek source reference (case head - {#.Definition [exported? frame_type frame_value]} + {.#Definition [exported? frame_type frame_value]} (:as (Stack Frame) frame_value) - (^or {#.Type _} - {#.Alias _} - {#.Label _} - {#.Slot _}) + (^or {.#Type _} + {.#Alias _} + {.#Label _} + {.#Slot _}) (undefined)))) (def: (peek_frames reference definition_reference source) (-> Text Text (List [Text Module]) (Stack Frame)) (!peek source reference - (peek_frames_definition definition_reference (value@ #.definitions head)))) + (peek_frames_definition definition_reference (value@ .#definitions head)))) (exception: .public no_active_frames) @@ -80,66 +80,66 @@ (-> (Maybe Text) (Meta Frame)) (function (_ compiler) (let [[reference definition_reference] (name_of ..frames) - current_frames (peek_frames reference definition_reference (value@ #.modules compiler))] + current_frames (peek_frames reference definition_reference (value@ .#modules compiler))] (case (case frame - {#.Some frame} + {.#Some frame} (list.example (function (_ [actual _]) (text\= frame actual)) current_frames) - #.None + {.#None} (..peek current_frames)) - {#.Some frame} - {#.Right [compiler frame]} + {.#Some frame} + {.#Right [compiler frame]} - #.None + {.#None} (exception.except ..no_active_frames []))))) (def: .public current (Meta Frame) - (..peek! #.None)) + (..peek! {.#None})) (def: .public (specific name) (-> Text (Meta Frame)) - (..peek! {#.Some name})) + (..peek! {.#Some name})) (template: (!push <source> <reference> <then>) [(loop [entries <source>] (case entries - {#.Item [head_name head] tail} + {.#Item [head_name head] tail} (if (text\= <reference> head_name) - {#.Item [head_name <then>] + {.#Item [head_name <then>] tail} - {#.Item [head_name head] + {.#Item [head_name head] (recur tail)}) - #.End + {.#End} (undefined)))]) (def: (push_frame_definition reference frame source) (-> Text Frame (List [Text Global]) (List [Text Global])) (!push source reference (case head - {#.Definition [exported? frames_type frames_value]} - {#.Definition [exported? + {.#Definition [exported? frames_type frames_value]} + {.#Definition [exported? frames_type (..push frame (:as (Stack Frame) frames_value))]} - (^or {#.Type _} - {#.Alias _} - {#.Label _} - {#.Slot _}) + (^or {.#Type _} + {.#Alias _} + {.#Label _} + {.#Slot _}) (undefined)))) (def: (push_frame [module_reference definition_reference] frame source) (-> Name Frame (List [Text Module]) (List [Text Module])) (!push source module_reference - (revised@ #.definitions (push_frame_definition definition_reference frame) head))) + (revised@ .#definitions (push_frame_definition definition_reference frame) head))) (def: (push! frame) (-> Frame (Meta Any)) (function (_ compiler) - {#.Right [(revised@ #.modules + {.#Right [(revised@ .#modules (..push_frame (name_of ..frames) frame) compiler) []]})) @@ -148,31 +148,31 @@ (-> Text (List [Text Global]) (List [Text Global])) (!push source reference (case head - {#.Definition [exported? frames_type frames_value]} - {#.Definition [exported? + {.#Definition [exported? frames_type frames_value]} + {.#Definition [exported? frames_type (let [current_frames (:as (Stack Frame) frames_value)] (case (..pop current_frames) - {#.Some current_frames'} + {.#Some current_frames'} current_frames' - #.None + {.#None} current_frames))]} - (^or {#.Type _} - {#.Alias _} - {#.Label _} - {#.Slot _}) + (^or {.#Type _} + {.#Alias _} + {.#Label _} + {.#Slot _}) (undefined)))) (def: (pop_frame [module_reference definition_reference] source) (-> Name (List [Text Module]) (List [Text Module])) (!push source module_reference - (|> head (revised@ #.definitions (pop_frame_definition definition_reference))))) + (|> head (revised@ .#definitions (pop_frame_definition definition_reference))))) (syntax: (pop! []) (function (_ compiler) - {#.Right [(revised@ #.modules + {.#Right [(revised@ .#modules (..pop_frame (name_of ..frames)) compiler) (list)]})) @@ -180,7 +180,7 @@ (def: cast (Parser [(Maybe Text) Code]) (<>.either (<>.and (<>.maybe <code>.local_identifier) <code>.any) - (<>.and (<>\in #.None) <code>.any))) + (<>.and (<>\in {.#None}) <code>.any))) (template [<name> <from> <to>] [(syntax: .public (<name> [[frame value] ..cast]) @@ -200,7 +200,7 @@ (def: representation_definition_name (-> Text Text) (|>> ($_ text\composite - (name\encoded (name_of #..Representation)) + (name\encoded (name_of ..#Representation)) " "))) (def: declaration diff --git a/stdlib/source/library/lux/type/check.lux b/stdlib/source/library/lux/type/check.lux index b0ea2a745..2fd8affb1 100644 --- a/stdlib/source/library/lux/type/check.lux +++ b/stdlib/source/library/lux/type/check.lux @@ -76,11 +76,11 @@ (def: (each f fa) (function (_ context) (case (fa context) - {#try.Success [context' output]} - {#try.Success [context' (f output)]} + {try.#Success [context' output]} + {try.#Success [context' (f output)]} - {#try.Failure error} - {#try.Failure error})))) + {try.#Failure error} + {try.#Failure error})))) (implementation: .public apply (Apply Check) @@ -90,16 +90,16 @@ (def: (on fa ff) (function (_ context) (case (ff context) - {#try.Success [context' f]} + {try.#Success [context' f]} (case (fa context') - {#try.Success [context'' a]} - {#try.Success [context'' (f a)]} + {try.#Success [context'' a]} + {try.#Success [context'' (f a)]} - {#try.Failure error} - {#try.Failure error}) + {try.#Failure error} + {try.#Failure error}) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} ))) ) @@ -110,21 +110,21 @@ (def: (in x) (function (_ context) - {#try.Success [context x]})) + {try.#Success [context x]})) (def: (conjoint ffa) (function (_ context) (case (ffa context) - {#try.Success [context' fa]} + {try.#Success [context' fa]} (case (fa context') - {#try.Success [context'' a]} - {#try.Success [context'' a]} + {try.#Success [context'' a]} + {try.#Success [context'' a]} - {#try.Failure error} - {#try.Failure error}) + {try.#Failure error} + {try.#Failure error}) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} ))) ) @@ -132,54 +132,54 @@ (def: (var::new id plist) (-> Var Type_Vars Type_Vars) - {#.Item [id #.None] plist}) + {.#Item [id {.#None}] plist}) (def: (var::get id plist) (-> Var Type_Vars (Maybe (Maybe Type))) (case plist - {#.Item [var_id var_type] + {.#Item [var_id var_type] plist'} (if (!n\= id var_id) - {#.Some var_type} + {.#Some var_type} (var::get id plist')) - #.End - #.None)) + {.#End} + {.#None})) (def: (var::put id value plist) (-> Var (Maybe Type) Type_Vars Type_Vars) (case plist - #.End + {.#End} (list [id value]) - {#.Item [var_id var_type] + {.#Item [var_id var_type] plist'} (if (!n\= id var_id) - {#.Item [var_id value] + {.#Item [var_id value] plist'} - {#.Item [var_id var_type] + {.#Item [var_id var_type] (var::put id value plist')}))) (def: .public (result context proc) (All (_ a) (-> Type_Context (Check a) (Try a))) (case (proc context) - {#try.Success [context' output]} - {#try.Success output} + {try.#Success [context' output]} + {try.#Success output} - {#try.Failure error} - {#try.Failure error})) + {try.#Failure error} + {try.#Failure error})) (def: .public (failure message) (All (_ a) (-> Text (Check a))) (function (_ context) - {#try.Failure message})) + {try.#Failure message})) (def: .public (assertion message test) (-> Text Bit (Check Any)) (function (_ context) (if test - {#try.Success [context []]} - {#try.Failure message}))) + {try.#Success [context []]} + {try.#Failure message}))) (def: .public (except exception message) (All (_ e a) (-> (Exception e) e (Check a))) @@ -188,27 +188,27 @@ (def: .public existential (Check [Nat Type]) (function (_ context) - (let [id (value@ #.ex_counter context)] - {#try.Success [(revised@ #.ex_counter ++ context) - [id {#.Ex id}]]}))) + (let [id (value@ .#ex_counter context)] + {try.#Success [(revised@ .#ex_counter ++ context) + [id {.#Ex id}]]}))) (template [<name> <outputT> <fail> <succeed>] [(def: .public (<name> id) (-> Var (Check <outputT>)) (function (_ context) - (case (|> context (value@ #.var_bindings) (var::get id)) - (^or {#.Some {#.Some {#.Var _}}} - {#.Some #.None}) - {#try.Success [context <fail>]} + (case (|> context (value@ .#var_bindings) (var::get id)) + (^or {.#Some {.#Some {.#Var _}}} + {.#Some {.#None}}) + {try.#Success [context <fail>]} - {#.Some {#.Some bound}} - {#try.Success [context <succeed>]} + {.#Some {.#Some bound}} + {try.#Success [context <succeed>]} - #.None + {.#None} (exception.except ..unknown_type_var id))))] - [bound? Bit false true] - [peek (Maybe Type) #.None {#.Some bound}] + [bound? Bit false true] + [peek (Maybe Type) {.#None} {.#Some bound}] ) (def: .public (read id) @@ -216,20 +216,20 @@ (do ..monad [?type (peek id)] (case ?type - {#.Some type} + {.#Some type} (in type) - #.None + {.#None} (..except ..unbound_type_var id)))) (def: (bound id) (-> Var (Check Type)) (function (_ context) - (case (|> context (value@ #.var_bindings) (var::get id)) - {#.Some {#.Some bound}} - {#try.Success [context bound]} + (case (|> context (value@ .#var_bindings) (var::get id)) + {.#Some {.#Some bound}} + {try.#Success [context bound]} - {#.Some _} + {.#Some _} (exception.except ..unbound_type_var id) _ @@ -238,12 +238,12 @@ (def: .public (bind type id) (-> Type Var (Check Any)) (function (_ context) - (case (|> context (value@ #.var_bindings) (var::get id)) - {#.Some #.None} - {#try.Success [(revised@ #.var_bindings (var::put id {#.Some type}) context) + (case (|> context (value@ .#var_bindings) (var::get id)) + {.#Some {.#None}} + {try.#Success [(revised@ .#var_bindings (var::put id {.#Some type}) context) []]} - {#.Some {#.Some bound}} + {.#Some {.#Some bound}} (exception.except ..cannot_rebind_var [id type bound]) _ @@ -252,9 +252,9 @@ (def: (re_bind type id) (-> Type Var (Check Any)) (function (_ context) - (case (|> context (value@ #.var_bindings) (var::get id)) - {#.Some _} - {#try.Success [(revised@ #.var_bindings (var::put id {#.Some type}) context) + (case (|> context (value@ .#var_bindings) (var::get id)) + {.#Some _} + {try.#Success [(revised@ .#var_bindings (var::put id {.#Some type}) context) []]} _ @@ -263,33 +263,33 @@ (def: .public var (Check [Var Type]) (function (_ context) - (let [id (value@ #.var_counter context)] - {#try.Success [(|> context - (revised@ #.var_counter ++) - (revised@ #.var_bindings (var::new id))) - [id {#.Var id}]]}))) + (let [id (value@ .#var_counter context)] + {try.#Success [(|> context + (revised@ .#var_counter ++) + (revised@ .#var_bindings (var::new id))) + [id {.#Var id}]]}))) (def: (on argT funcT) (-> Type Type (Check Type)) (case funcT - {#.Var func_id} + {.#Var func_id} (do ..monad [?funcT' (peek func_id)] (case ?funcT' - {#.Some funcT'} + {.#Some funcT'} (on argT funcT') _ (except ..invalid_type_application [funcT argT]))) - {#.Apply argT' funcT'} + {.#Apply argT' funcT'} (do ..monad [funcT'' (on argT' funcT')] (on argT funcT'')) _ (case (//.applied (list argT) funcT) - {#.Some output} + {.#Some output} (check\in output) _ @@ -308,44 +308,44 @@ (function (_ context) (loop [current start output (set.has start empty_ring)] - (case (|> context (value@ #.var_bindings) (var::get current)) - {#.Some {#.Some type}} + (case (|> context (value@ .#var_bindings) (var::get current)) + {.#Some {.#Some type}} (case type - {#.Var post} + {.#Var post} (if (!n\= start post) - {#try.Success [context output]} + {try.#Success [context output]} (recur post (set.has post output))) _ - {#try.Success [context empty_ring]}) + {try.#Success [context empty_ring]}) - {#.Some #.None} - {#try.Success [context output]} + {.#Some {.#None}} + {try.#Success [context output]} - #.None + {.#None} (exception.except ..unknown_type_var current))))) (def: .public fresh_context Type_Context - [#.var_counter 0 - #.ex_counter 0 - #.var_bindings (list)]) + [.#var_counter 0 + .#ex_counter 0 + .#var_bindings (list)]) (def: (attempt op) (All (_ a) (-> (Check a) (Check (Maybe a)))) (function (_ context) (case (op context) - {#try.Success [context' output]} - {#try.Success [context' {#.Some output}]} + {try.#Success [context' output]} + {try.#Success [context' {.#Some output}]} - {#try.Failure _} - {#try.Success [context #.None]}))) + {try.#Failure _} + {try.#Success [context {.#None}]}))) (def: (either left right) (All (_ a) (-> (Check a) (Check a) (Check a))) (function (_ context) (case (left context) - {#try.Failure _} + {try.#Failure _} (right context) output @@ -374,21 +374,21 @@ then) (do ..monad [?bound (peek id)] - (else (maybe.else {#.Var id} ?bound))))) + (else (maybe.else {.#Var id} ?bound))))) ... TODO: "link/2" can be optimized... (def: (link/2 left right) (-> Var Var (Check Any)) (do ..monad - [_ (..bind {#.Var right} left)] - (..bind {#.Var left} right))) + [_ (..bind {.#Var right} left)] + (..bind {.#Var left} right))) ... TODO: "link/3" can be optimized... (def: (link/3 interpose to from) (-> Var Var Var (Check Any)) (do ..monad - [_ (re_bind {#.Var interpose} from)] - (re_bind {#.Var to} interpose))) + [_ (re_bind {.#Var interpose} from)] + (re_bind {.#Var to} interpose))) ... TODO: "check_vars" can be optimized... (def: (check_vars check' assumptions idE idA) @@ -400,36 +400,36 @@ abound (attempt (..bound idA))] (case [ebound abound] ... Link the 2 variables circularly - [#.None #.None] + [{.#None} {.#None}] (do ! [_ (link/2 idE idA)] (in assumptions)) ... Interpose new variable between 2 existing links - [{#.Some etype} #.None] + [{.#Some etype} {.#None}] (case etype - {#.Var targetE} + {.#Var targetE} (do ! [_ (link/3 idA targetE idE)] (in assumptions)) _ - (check' assumptions etype {#.Var idA})) + (check' assumptions etype {.#Var idA})) ... Interpose new variable between 2 existing links - [#.None {#.Some atype}] + [{.#None} {.#Some atype}] (case atype - {#.Var targetA} + {.#Var targetA} (do ! [_ (link/3 idE targetA idA)] (in assumptions)) _ - (check' assumptions {#.Var idE} atype)) + (check' assumptions {.#Var idE} atype)) - [{#.Some etype} {#.Some atype}] + [{.#Some etype} {.#Some atype}] (case [etype atype] - [{#.Var targetE} {#.Var targetA}] + [{.#Var targetE} {.#Var targetA}] (do ! [ringE (..ring idE) ringA (..ring idA)] @@ -451,8 +451,8 @@ [ring (..ring <id>) _ (monad.each ! (re_bind <type>) (set.list ring))] (in assumptions))]) - ([[{#.Var _} _] idE atype] - [[_ {#.Var _}] idA etype]) + ([[{.#Var _} _] idE atype] + [[_ {.#Var _}] idA etype]) _ (check' assumptions etype atype)))))) @@ -467,54 +467,54 @@ (let [[expected_input expected_function] expected [actual_input actual_function] actual] (case [expected_function actual_function] - [{#.Ex exE} {#.Ex exA}] + [{.#Ex exE} {.#Ex exA}] (if (!n\= exE exA) (check' assumptions expected_input actual_input) ..silent_failure!) - [{#.UnivQ _ _} {#.Ex _}] + [{.#UnivQ _ _} {.#Ex _}] (do ..monad [expected' (..on expected_input expected_function)] - (check' assumptions expected' {#.Apply actual})) + (check' assumptions expected' {.#Apply actual})) - [{#.Ex _} {#.UnivQ _ _}] + [{.#Ex _} {.#UnivQ _ _}] (do ..monad [actual' (..on actual_input actual_function)] - (check' assumptions {#.Apply expected} actual')) + (check' assumptions {.#Apply expected} actual')) - [{#.Apply [expected_input' expected_function']} {#.Ex _}] + [{.#Apply [expected_input' expected_function']} {.#Ex _}] (do ..monad [expected_function'' (..on expected_input' expected_function')] - (check' assumptions {#.Apply [expected_input expected_function'']} {#.Apply actual})) + (check' assumptions {.#Apply [expected_input expected_function'']} {.#Apply actual})) - [{#.Ex _} {#.Apply [actual_input' actual_function']}] + [{.#Ex _} {.#Apply [actual_input' actual_function']}] (do ..monad [actual_function'' (..on actual_input' actual_function')] - (check' assumptions {#.Apply expected} {#.Apply [actual_input actual_function'']})) + (check' assumptions {.#Apply expected} {.#Apply [actual_input actual_function'']})) - (^or [{#.Ex _} _] [_ {#.Ex _}]) + (^or [{.#Ex _} _] [_ {.#Ex _}]) (do ..monad [assumptions (check' assumptions expected_function actual_function)] (check' assumptions expected_input actual_input)) - [{#.Var id} _] + [{.#Var id} _] (function (_ context) (case ((do ..monad [expected_function' (..read id)] - (check' assumptions {#.Apply expected_input expected_function'} {#.Apply actual})) + (check' assumptions {.#Apply expected_input expected_function'} {.#Apply actual})) context) - {#try.Success output} - {#try.Success output} + {try.#Success output} + {try.#Success output} - {#try.Failure _} + {try.#Failure _} (case actual_function - {#.UnivQ _ _} + {.#UnivQ _ _} ((do ..monad [actual' (..on actual_input actual_function)] - (check' assumptions {#.Apply expected} actual')) + (check' assumptions {.#Apply expected} actual')) context) - {#.Ex exA} + {.#Ex exA} ((do ..monad [assumptions (check' assumptions expected_function actual_function)] (check' assumptions expected_input actual_input)) @@ -528,14 +528,14 @@ (check' assumptions expected' actual')) context)))) - [_ {#.Var id}] + [_ {.#Var id}] (function (_ context) (case ((do ..monad [actual_function' (read id)] - (check' assumptions {#.Apply expected} {#.Apply actual_input actual_function'})) + (check' assumptions {.#Apply expected} {.#Apply actual_input actual_function'})) context) - {#try.Success output} - {#try.Success output} + {try.#Success output} + {try.#Success output} _ ((do ..monad @@ -563,38 +563,38 @@ (check\in assumptions) (with ..type_check_failed [expected actual] (case [expected actual] - [{#.Var idE} {#.Var idA}] + [{.#Var idE} {.#Var idA}] (check_vars check' assumptions idE idA) - [{#.Var id} _] + [{.#Var id} _] (if_can_bind id actual (check\in assumptions) (function (_ bound) (check' assumptions bound actual))) - [_ {#.Var id}] + [_ {.#Var id}] (if_can_bind id expected (check\in assumptions) (function (_ bound) (check' assumptions expected bound))) (^template [<fE> <fA>] - [[{#.Apply aE <fE>} {#.Apply aA <fA>}] + [[{.#Apply aE <fE>} {.#Apply aA <fA>}] (check_apply check' assumptions [aE <fE>] [aA <fA>])]) - ([F1 {#.Ex ex}] - [{#.Ex exE} fA] - [fE {#.Var idA}] - [{#.Var idE} fA]) + ([F1 {.#Ex ex}] + [{.#Ex exE} fA] + [fE {.#Var idA}] + [{.#Var idE} fA]) - [{#.Apply A F} _] + [{.#Apply A F} _] (let [new_assumption [expected actual]] (if (assumed? new_assumption assumptions) (check\in assumptions) (do ..monad [expected' (..on A F)] - (check' {#.Item new_assumption assumptions} expected' actual)))) + (check' {.#Item new_assumption assumptions} expected' actual)))) - [_ {#.Apply A F}] + [_ {.#Apply A F}] (do ..monad [actual' (..on A F)] (check' assumptions expected actual')) @@ -606,8 +606,8 @@ [[_ paramT] <instancer> expected' (..on paramT expected)] (check' assumptions expected' actual))]) - ([#.UnivQ ..existential] - [#.ExQ ..var]) + ([.#UnivQ ..existential] + [.#ExQ ..var]) ... TODO: Refactor-away as cold-code (^template [<tag> <instancer>] @@ -616,19 +616,19 @@ [[_ paramT] <instancer> actual' (..on paramT actual)] (check' assumptions expected actual'))]) - ([#.UnivQ ..var] - [#.ExQ ..existential]) + ([.#UnivQ ..var] + [.#ExQ ..existential]) - [{#.Primitive e_name e_params} {#.Primitive a_name a_params}] + [{.#Primitive e_name e_params} {.#Primitive a_name a_params}] (if (!text\= e_name a_name) (loop [assumptions assumptions e_params e_params a_params a_params] (case [e_params a_params] - [#.End #.End] + [{.#End} {.#End}] (check\in assumptions) - [{#.Item e_head e_tail} {#.Item a_head a_tail}] + [{.#Item e_head e_tail} {.#Item a_head a_tail}] (do ..monad [assumptions' (check' assumptions e_head a_head)] (recur assumptions' e_tail a_tail)) @@ -642,23 +642,23 @@ (do ..monad [assumptions (check' assumptions eL aL)] (check' assumptions eR aR))]) - ([#.Sum] - [#.Product]) + ([.#Sum] + [.#Product]) - [{#.Function eI eO} {#.Function aI aO}] + [{.#Function eI eO} {.#Function aI aO}] (do ..monad [assumptions (check' assumptions aI eI)] (check' assumptions eO aO)) - [{#.Ex e!id} {#.Ex a!id}] + [{.#Ex e!id} {.#Ex a!id}] (if (!n\= e!id a!id) (check\in assumptions) ..silent_failure!) - [{#.Named _ ?etype} _] + [{.#Named _ ?etype} _] (check' assumptions ?etype actual) - [_ {#.Named _ ?atype}] + [_ {.#Named _ ?atype}] (check' assumptions expected ?atype) _ @@ -672,26 +672,26 @@ (-> Type Type Bit) (case (..result ..fresh_context (..check expected actual)) - {#try.Failure _} + {try.#Failure _} false - {#try.Success _} + {try.#Success _} true)) (def: .public context (Check Type_Context) (function (_ context) - {#try.Success [context context]})) + {try.#Success [context context]})) (def: .public (clean inputT) (-> Type (Check Type)) (case inputT - {#.Primitive name paramsT+} + {.#Primitive name paramsT+} (|> paramsT+ (monad.each ..monad clean) - (check\each (|>> {#.Primitive name}))) + (check\each (|>> {.#Primitive name}))) - (^or {#.Parameter _} {#.Ex _} {#.Named _}) + (^or {.#Parameter _} {.#Ex _} {.#Named _}) (check\in inputT) (^template [<tag>] @@ -700,13 +700,13 @@ [leftT' (clean leftT)] (|> (clean rightT) (check\each (|>> {<tag> leftT'}))))]) - ([#.Sum] [#.Product] [#.Function] [#.Apply]) + ([.#Sum] [.#Product] [.#Function] [.#Apply]) - {#.Var id} + {.#Var id} (do ..monad [?actualT (peek id)] (case ?actualT - {#.Some actualT} + {.#Some actualT} (clean actualT) _ @@ -717,5 +717,5 @@ (do [! ..monad] [envT+' (monad.each ! clean envT+)] (in {<tag> envT+' unquantifiedT}))]) - ([#.UnivQ] [#.ExQ]) + ([.#UnivQ] [.#ExQ]) )) diff --git a/stdlib/source/library/lux/type/dynamic.lux b/stdlib/source/library/lux/type/dynamic.lux index 412f811ec..48fb68378 100644 --- a/stdlib/source/library/lux/type/dynamic.lux +++ b/stdlib/source/library/lux/type/dynamic.lux @@ -44,7 +44,7 @@ (: ((~! try.Try) (~ type)) (if (\ (~! type.equivalence) (~' =) (.type (~ type)) (~ g!type)) - {#try.Success (:as (~ type) (~ g!value))} + {try.#Success (:as (~ type) (~ g!value))} ((~! exception.except) ..wrong_type [(.type (~ type)) (~ g!type)]))))))))) (def: .public (format value) diff --git a/stdlib/source/library/lux/type/implicit.lux b/stdlib/source/library/lux/type/implicit.lux index 03379a14e..1d32fd57c 100644 --- a/stdlib/source/library/lux/type/implicit.lux +++ b/stdlib/source/library/lux/type/implicit.lux @@ -29,19 +29,19 @@ (def: (type_var id env) (-> Nat Type_Context (Meta Type)) (case (list.example (|>> product.left (n.= id)) - (value@ #.var_bindings env)) - {#.Some [_ {#.Some type}]} + (value@ .#var_bindings env)) + {.#Some [_ {.#Some type}]} (case type - {#.Var id'} + {.#Var id'} (type_var id' env) _ (\ meta.monad in type)) - {#.Some [_ #.None]} + {.#Some [_ {.#None}]} (meta.failure (format "Unbound type-var " (%.nat id))) - #.None + {.#None} (meta.failure (format "Unknown type-var " (%.nat id))) )) @@ -51,8 +51,8 @@ [raw_type (meta.type var_name) compiler meta.compiler_state] (case raw_type - {#.Var id} - (type_var id (value@ #.type_context compiler)) + {.#Var id} + (type_var id (value@ .#type_context compiler)) _ (in raw_type)))) @@ -60,18 +60,18 @@ (def: (member_type idx sig_type) (-> Nat Type (Check Type)) (case sig_type - {#.Named _ sig_type'} + {.#Named _ sig_type'} (member_type idx sig_type') - {#.Apply arg func} + {.#Apply arg func} (case (type.applied (list arg) func) - #.None + {.#None} (check.failure (format "Cannot apply type " (%.type func) " to type " (%.type arg))) - {#.Some sig_type'} + {.#Some sig_type'} (member_type idx sig_type')) - {#.Product left right} + {.#Product left right} (if (n.= 0 idx) (\ check.monad in left) (member_type (-- idx) right)) @@ -97,10 +97,10 @@ candidates (list.only (|>> product.right (text\= simple_name)) tag_lists)]] (case candidates - #.End + {.#End} (meta.failure (format "Unknown tag: " (%.name member))) - {#.Item winner #.End} + {.#Item winner {.#End}} (in winner) _ @@ -139,7 +139,7 @@ (if (and (or (text\= target_module source_module) exported?) (compatible_type? sig_type def_type)) - {#.Item [[source_module name] def_type] aggregate} + {.#Item [[source_module name] def_type] aggregate} aggregate)) aggregate constants)) @@ -157,15 +157,15 @@ dictionary.entries (list.all (function (_ [name type]) (if (compatible_type? sig_type type) - {#.Some [["" name] type]} - #.None))))))) + {.#Some [["" name] type]} + {.#None}))))))) (def: (local_structs sig_type) (-> Type (Meta (List [Name Type]))) (do [! meta.monad] [this_module_name meta.current_module_name definitions (meta.definitions this_module_name)] - (in (available_definitions sig_type this_module_name this_module_name definitions #.End)))) + (in (available_definitions sig_type this_module_name this_module_name definitions {.#End})))) (def: (imported_structs sig_type) (-> Type (Meta (List [Name Type]))) @@ -175,16 +175,16 @@ accessible_definitions (monad.each ! meta.definitions imported_modules)] (in (list\mix (function (_ [imported_module definitions] tail) (available_definitions sig_type imported_module this_module_name definitions tail)) - #.End + {.#End} (list.zipped/2 imported_modules accessible_definitions))))) (def: (on_argument arg func) (-> Type Type (Check Type)) (case func - {#.Named _ func'} + {.#Named _ func'} (on_argument arg func') - {#.UnivQ _} + {.#UnivQ _} (do check.monad [[id var] check.var] (|> func @@ -192,7 +192,7 @@ maybe.trusted (on_argument arg))) - {#.Function input output} + {.#Function input output} (do check.monad [_ (check.check input arg)] (in output)) @@ -203,11 +203,11 @@ (def: (concrete_type type) (-> Type (Check [(List Nat) Type])) (case type - {#.UnivQ _} + {.#UnivQ _} (do check.monad [[id var] check.var [ids final_output] (concrete_type (maybe.trusted (type.applied (list var) type)))] - (in [{#.Item id ids} + (in [{.#Item id ids} final_output])) _ @@ -241,13 +241,13 @@ context' check.context =deps (monad.each ! (provision compiler context') deps)] (in =deps))) - {#.Left error} + {.#Left error} (list) - {#.Right =deps} + {.#Right =deps} (list [alt_name =deps])))) list\conjoint) - #.End + {.#End} (meta.failure (format "No candidates for provisioning: " (%.type dep))) found @@ -260,15 +260,15 @@ (do meta.monad [alts (..local_env sig_type)] (..candidate_provision (provision sig_type) context dep alts)) (do meta.monad [alts (..local_structs sig_type)] (..candidate_provision (provision sig_type) context dep alts)) (do meta.monad [alts (..imported_structs sig_type)] (..candidate_provision (provision sig_type) context dep alts)))) - {#.Left error} + {.#Left error} (check.failure error) - {#.Right candidates} + {.#Right candidates} (case candidates - #.End + {.#End} (check.failure (format "No candidates for provisioning: " (%.type dep))) - {#.Item winner #.End} + {.#Item winner {.#End}} (\ check.monad in winner) _ @@ -292,13 +292,13 @@ context' check.context =deps (monad.each ! (provision sig_type compiler context') deps)] (in =deps))) - {#.Left error} + {.#Left error} (list) - {#.Right =deps} + {.#Right =deps} (list [alt_name =deps])))) list\conjoint) - #.End + {.#End} (meta.failure (format "No alternatives for " (%.type (type.function input_types output_type)))) found @@ -315,7 +315,7 @@ (def: (var? input) (-> Code Bit) (case input - [_ {#.Identifier _}] + [_ {.#Identifier _}] #1 _ @@ -328,7 +328,7 @@ (def: (instance$ [constructor dependencies]) (-> Instance Code) (case dependencies - #.End + {.#End} (code.identifier constructor) _ @@ -338,17 +338,17 @@ args (<>.or (<>.and (<>.some <code>.identifier) <code>.end!) (<>.and (<>.some <code>.any) <code>.end!))]) (case args - {#.Left [args _]} + {.#Left [args _]} (do [! meta.monad] [[member_idx sig_type] (..implicit_member member) input_types (monad.each ! ..implicit_type args) output_type meta.expected_type chosen_ones (alternatives sig_type member_idx input_types output_type)] (case chosen_ones - #.End + {.#End} (meta.failure (format "No implementation could be found for member: " (%.name member))) - {#.Item chosen #.End} + {.#Item chosen {.#End}} (in (list (` (\ (~ (instance$ chosen)) (~ (code.local_identifier (product.right member))) (~+ (list\each code.identifier args)))))) @@ -360,7 +360,7 @@ (text.interposed ", ")) " --- for type: " (%.type sig_type))))) - {#.Right [args _]} + {.#Right [args _]} (do [! meta.monad] [labels (|> (macro.identifier "") (list.repeated (list.size args)) (monad.all !))] (in (list (` (let [(~+ (|> args (list.zipped/2 labels) (list\each ..pair_list) list\conjoint))] diff --git a/stdlib/source/library/lux/type/poly.lux b/stdlib/source/library/lux/type/poly.lux index 1656e88ca..705c72ecc 100644 --- a/stdlib/source/library/lux/type/poly.lux +++ b/stdlib/source/library/lux/type/poly.lux @@ -42,32 +42,32 @@ (function ((~ g!_) (~ g!name)) (~ body))) (.:as .Type (~ g!type)))) - {#.Left (~ g!output)} + {.#Left (~ g!output)} ((~! meta.failure) (~ g!output)) - {#.Right (~ g!output)} + {.#Right (~ g!output)} ((~' in) (.list (~ g!output)))))))))))) (def: .public (code env type) (-> Env Type Code) (`` (case type - {#.Primitive name params} - (` {#.Primitive (~ (code.text name)) + {.#Primitive name params} + (` {.#Primitive (~ (code.text name)) (.list (~+ (list\each (code env) params)))}) (^template [<tag>] [{<tag> idx} (` {<tag> (~ (code.nat idx))})]) - ([#.Var] [#.Ex]) + ([.#Var] [.#Ex]) - {#.Parameter idx} + {.#Parameter idx} (let [idx (<type>.adjusted_idx env idx)] (if (n.= 0 idx) (|> (dictionary.value idx env) maybe.trusted product.left (code env)) (` (.$ (~ (code.nat (-- idx))))))) - {#.Apply {#.Primitive "" #.End} - {#.Parameter idx}} + {.#Apply {.#Primitive "" {.#End}} + {.#Parameter idx}} (case (<type>.adjusted_idx env idx) 0 (|> env (dictionary.value 0) maybe.trusted product.left (code env)) idx (undefined)) @@ -76,20 +76,20 @@ [{<tag> left right} (` {<tag> (~ (code env left)) (~ (code env right))})]) - ([#.Function] [#.Apply]) + ([.#Function] [.#Apply]) (^template [<macro> <tag> <flattener>] [{<tag> left right} (` (<macro> (~+ (list\each (code env) (<flattener> type)))))]) - ([.Union #.Sum type.flat_variant] - [.Tuple #.Product type.flat_tuple]) + ([.Union .#Sum type.flat_variant] + [.Tuple .#Product type.flat_tuple]) - {#.Named name sub_type} + {.#Named name sub_type} (code.identifier name) (^template [<tag>] [{<tag> scope body} (` {<tag> (.list (~+ (list\each (code env) scope))) (~ (code env body))})]) - ([#.UnivQ] [#.ExQ]) + ([.#UnivQ] [.#ExQ]) ))) diff --git a/stdlib/source/library/lux/type/refinement.lux b/stdlib/source/library/lux/type/refinement.lux index 2de171779..8e4f23952 100644 --- a/stdlib/source/library/lux/type/refinement.lux +++ b/stdlib/source/library/lux/type/refinement.lux @@ -25,9 +25,9 @@ (-> (Predicate t) (Refiner t %)))) (function (_ value) (if (predicate value) - {#.Some (:abstraction [#value value + {.#Some (:abstraction [#value value #predicate predicate])} - #.None))) + {.#None}))) (template [<name> <output> <slot>] [(def: .public <name> @@ -44,45 +44,45 @@ (-> (Refined t %) (Maybe (Refined t %))))) (function (_ refined) (let [(^slots [#value #predicate]) (:representation refined) - value' (transform value)] - (if (predicate value') - {#.Some (:abstraction [#value value' - #predicate predicate])} - #.None)))) + value' (transform #value)] + (if (#predicate value') + {.#Some (:abstraction [..#value value' + ..#predicate #predicate])} + {.#None})))) ) (def: .public (only refiner values) (All (_ t %) (-> (Refiner t %) (List t) (List (Refined t %)))) (case values - #.End - #.End + {.#End} + {.#End} - {#.Item head tail} + {.#Item head tail} (case (refiner head) - {#.Some refined} - {#.Item refined (only refiner tail)} + {.#Some refined} + {.#Item refined (only refiner tail)} - #.None + {.#None} (only refiner tail)))) (def: .public (partition refiner values) (All (_ t %) (-> (Refiner t %) (List t) [(List (Refined t %)) (List t)])) (case values - #.End - [#.End #.End] + {.#End} + [{.#End} {.#End}] - {#.Item head tail} + {.#Item head tail} (let [[yes no] (partition refiner tail)] (case (refiner head) - {#.Some refined} - [{#.Item refined yes} + {.#Some refined} + [{.#Item refined yes} no] - #.None + {.#None} [yes - {#.Item head no}])))) + {.#Item head no}])))) (syntax: .public (type [refiner <code>.any]) (macro.with_identifiers [g!t g!%] diff --git a/stdlib/source/library/lux/type/resource.lux b/stdlib/source/library/lux/type/resource.lux index 5c2618263..23d504446 100644 --- a/stdlib/source/library/lux/type/resource.lux +++ b/stdlib/source/library/lux/type/resource.lux @@ -129,10 +129,10 @@ (syntax: .public (exchange [swaps ..indices]) (macro.with_identifiers [g!_ g!context g!!] (case swaps - #.End + {.#End} (in (list (` (~! no_op)))) - {#.Item head tail} + {.#Item head tail} (do [! meta.monad] [.let [max_idx (list\mix n.max head tail)] g!inputs (<| (monad.all !) (list.repeated (++ max_idx)) (macro.identifier "input")) diff --git a/stdlib/source/library/lux/type/unit.lux b/stdlib/source/library/lux/type/unit.lux index 7b60ba1f5..4a47eaf50 100644 --- a/stdlib/source/library/lux/type/unit.lux +++ b/stdlib/source/library/lux/type/unit.lux @@ -29,11 +29,11 @@ (abstract: .public (Qty unit) Int - (def: in + (def: in' (All (_ unit) (-> Int (Qty unit))) (|>> :abstraction)) - (def: out + (def: out' (All (_ unit) (-> (Qty unit) Int)) (|>> :representation)) @@ -79,11 +79,11 @@ (def: .public pure (-> Int Pure) - ..in) + ..in') (def: .public number (-> Pure Int) - ..out) + ..out') (syntax: .public (unit: [[export_policy type_name unit_name] (|export|.parser @@ -99,11 +99,11 @@ (` (implementation: (~ export_policy) (~ (code.local_identifier unit_name)) (..Unit (~ g!type)) - (def: (~' in) (~! ..in)) - (def: (~' out) (~! ..out)))) + (def: (~' in) (~! ..in')) + (def: (~' out) (~! ..out')))) )))) -(def: scale +(def: scaleP (Parser Ratio) (<code>.tuple (do <>.monad [numerator <code>.nat @@ -119,9 +119,9 @@ ($_ <>.and <code>.local_identifier <code>.local_identifier - ..scale))]) + ..scaleP))]) (do meta.monad - [.let [(^slots [#ratio.numerator #ratio.denominator]) ratio] + [.let [(^slots [ratio.#numerator ratio.#denominator]) ratio] @ meta.current_module_name .let [g!scale (code.local_identifier type_name)]] (in (list (` (type: (~ export_policy) ((~ g!scale) (~' u)) @@ -131,17 +131,17 @@ (..Scale (~ g!scale)) (def: (~' scale) - (|>> ((~! ..out)) - (i.* (~ (code.int (.int numerator)))) - (i./ (~ (code.int (.int denominator)))) - ((~! ..in)))) + (|>> ((~! ..out')) + (i.* (~ (code.int (.int #numerator)))) + (i./ (~ (code.int (.int #denominator)))) + ((~! ..in')))) (def: (~' de_scale) - (|>> ((~! ..out)) - (i.* (~ (code.int (.int denominator)))) - (i./ (~ (code.int (.int numerator)))) - ((~! ..in)))) + (|>> ((~! ..out')) + (i.* (~ (code.int (.int #denominator)))) + (i./ (~ (code.int (.int #numerator)))) + ((~! ..in')))) (def: (~' ratio) - [(~ (code.nat numerator)) (~ (code.nat denominator))]))) + [(~ (code.nat #numerator)) (~ (code.nat #denominator))]))) )))) (def: .public (re_scaled from to quantity) @@ -149,10 +149,10 @@ (let [[numerator denominator] (ratio./ (\ from ratio) (\ to ratio))] (|> quantity - out + out' (i.* (.int numerator)) (i./ (.int denominator)) - in))) + in'))) (syntax: (implementation_name [type_name <code>.local_identifier]) (in (list (code.local_identifier (text.lower_cased type_name))))) @@ -185,7 +185,7 @@ (All (_ unit) (Equivalence (Qty unit))) (def: (= reference sample) - (i.= (..out reference) (..out sample)))) + (i.= (..out' reference) (..out' sample)))) (implementation: .public order (All (_ unit) (Order (Qty unit))) @@ -193,11 +193,11 @@ (def: &equivalence ..equivalence) (def: (< reference sample) - (i.< (..out reference) (..out sample)))) + (i.< (..out' reference) (..out' sample)))) (implementation: .public enum (All (_ unit) (Enum (Qty unit))) (def: &order ..order) - (def: succ (|>> ..out ++ ..in)) - (def: pred (|>> ..out -- ..in))) + (def: succ (|>> ..out' ++ ..in')) + (def: pred (|>> ..out' -- ..in'))) diff --git a/stdlib/source/library/lux/world/console.lux b/stdlib/source/library/lux/world/console.lux index 7c974630f..276fd51de 100644 --- a/stdlib/source/library/lux/world/console.lux +++ b/stdlib/source/library/lux/world/console.lux @@ -71,14 +71,14 @@ (do io.monad [?jvm_console (java/lang/System::console)] (case ?jvm_console - #.None + {.#None} (in (exception.except ..cannot_open [])) - {#.Some jvm_console} + {.#Some jvm_console} (let [jvm_input (java/lang/System::in) jvm_output (java/lang/System::out)] (<| in - #try.Success + {try.#Success} (: (Console IO)) ... TODO: Remove ASAP (implementation (def: (read _) @@ -122,13 +122,13 @@ (do [! io.monad] [|state| (atom.read! state)] (case (\ mock <mock> |state|) - {#try.Success [|state| output]} + {try.#Success [|state| output]} (do ! [_ (atom.write! |state| state)] - (in {#try.Success output})) + (in {try.#Success output})) - {#try.Failure error} - (in {#try.Failure error}))))] + {try.#Failure error} + (in {try.#Failure error}))))] [read on_read] [read_line on_read_line] @@ -138,23 +138,23 @@ (do [! io.monad] [|state| (atom.read! state)] (case (\ mock on_write input |state|) - {#try.Success |state|} + {try.#Success |state|} (do ! [_ (atom.write! |state| state)] - (in {#try.Success []})) + (in {try.#Success []})) - {#try.Failure error} - (in {#try.Failure error})))) + {try.#Failure error} + (in {try.#Failure error})))) (def: (close _) (do [! io.monad] [|state| (atom.read! state)] (case (\ mock on_close |state|) - {#try.Success |state|} + {try.#Success |state|} (do ! [_ (atom.write! |state| state)] - (in {#try.Success []})) + (in {try.#Success []})) - {#try.Failure error} - (in {#try.Failure error})))) + {try.#Failure error} + (in {try.#Failure error})))) )))) diff --git a/stdlib/source/library/lux/world/db/jdbc/input.lux b/stdlib/source/library/lux/world/db/jdbc/input.lux index aa8a168af..117edaab3 100644 --- a/stdlib/source/library/lux/world/db/jdbc/input.lux +++ b/stdlib/source/library/lux/world/db/jdbc/input.lux @@ -64,12 +64,12 @@ (def: .public (fail error) (All (_ a) (-> Text (Input a))) (function (_ value [idx context]) - {#try.Failure error})) + {try.#Failure error})) (def: .public empty (Input Any) (function (_ value context) - {#try.Success context})) + {try.#Success context})) (template [<function> <type> <setter>] [(def: .public <function> diff --git a/stdlib/source/library/lux/world/db/jdbc/output.lux b/stdlib/source/library/lux/world/db/jdbc/output.lux index 3772ff0e1..0ec397faf 100644 --- a/stdlib/source/library/lux/world/db/jdbc/output.lux +++ b/stdlib/source/library/lux/world/db/jdbc/output.lux @@ -56,11 +56,11 @@ (def: (each f fa) (function (_ idx+rs) (case (fa idx+rs) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success [idx' value]} - {#try.Success [idx' (f value)]})))) + {try.#Success [idx' value]} + {try.#Success [idx' (f value)]})))) (implementation: .public apply (Apply Output) @@ -70,16 +70,16 @@ (def: (apply ff fa) (function (_ [idx rs]) (case (ff [idx rs]) - {#try.Success [idx' f]} + {try.#Success [idx' f]} (case (fa [idx' rs]) - {#try.Success [idx'' a]} - {#try.Success [idx'' (f a)]} + {try.#Success [idx'' a]} + {try.#Success [idx'' (f a)]} - {#try.Failure msg} - {#try.Failure msg}) + {try.#Failure msg} + {try.#Failure msg}) - {#try.Failure msg} - {#try.Failure msg})))) + {try.#Failure msg} + {try.#Failure msg})))) (implementation: .public monad (Monad Output) @@ -88,21 +88,21 @@ (def: (in a) (function (_ [idx rs]) - {#.Some [idx a]})) + {.#Some [idx a]})) (def: (conjoint mma) (function (_ [idx rs]) (case (mma [idx rs]) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success [idx' ma]} + {try.#Success [idx' ma]} (ma [idx' rs]))))) (def: .public (fail error) (All (_ a) (-> Text (Output a))) (function (_ [idx result_set]) - {#try.Failure error})) + {try.#Failure error})) (def: .public (and left right) (All (_ a b) @@ -117,11 +117,11 @@ (Output <type>) (function (_ [idx result_set]) (case (<method_name> [(.int idx)] result_set) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success value} - {#try.Success [(++ idx) value]})))] + {try.#Success value} + {try.#Success [(++ idx) value]})))] [boolean java/sql/ResultSet::getBoolean Bit] @@ -142,11 +142,11 @@ (Output Instant) (function (_ [idx result_set]) (case (<method_name> [(.int idx)] result_set) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success value} - {#try.Success [(++ idx) + {try.#Success value} + {try.#Success [(++ idx) (instant.from_millis (java/util/Date::getTime value))]})))] [date java/sql/ResultSet::getDate] @@ -157,24 +157,24 @@ (def: .public (rows output results) (All (_ a) (-> (Output a) java/sql/ResultSet (IO (Try (List a))))) (case (java/sql/ResultSet::next results) - {#try.Success has_next?} + {try.#Success has_next?} (if has_next? (case (output [1 results]) - {#.Some [_ head]} + {.#Some [_ head]} (do io.monad [?tail (rows output results)] (case ?tail - {#try.Success tail} - (in {#try.Success {#.Item head tail}}) + {try.#Success tail} + (in {try.#Success {.#Item head tail}}) - {#try.Failure error} + {try.#Failure error} (do io.monad [temp (java/sql/ResultSet::close results)] (in (do try.monad [_ temp] (try.failure error)))))) - {#try.Failure error} + {try.#Failure error} (do io.monad [temp (java/sql/ResultSet::close results)] (in (do try.monad @@ -186,7 +186,7 @@ [_ temp] (in (list)))))) - {#try.Failure error} + {try.#Failure error} (do io.monad [temp (java/sql/ResultSet::close results)] (in (do try.monad diff --git a/stdlib/source/library/lux/world/db/sql.lux b/stdlib/source/library/lux/world/db/sql.lux index 60abb4484..dd0a2dd7e 100644 --- a/stdlib/source/library/lux/world/db/sql.lux +++ b/stdlib/source/library/lux/world/db/sql.lux @@ -214,7 +214,7 @@ (format <op> " " (case columns - #.End + {.#End} "*" _ @@ -292,7 +292,7 @@ (Query where having No_Order group limit offset) (Query where having With_Order group limit offset))) (case pairs - #.End + {.#End} (|> query :representation :abstraction) _ @@ -310,7 +310,7 @@ (Query where having order No_Group limit offset) (Query where having order With_Group limit offset))) (case pairs - #.End + {.#End} (|> query :representation :abstraction) _ @@ -335,7 +335,7 @@ (-> Table (List [Column Value]) (Command No_Where No_Having)) (:abstraction (format "UPDATE " (:representation table) (case pairs - #.End + {.#End} "" _ diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux index 82796463c..5a8c23c48 100644 --- a/stdlib/source/library/lux/world/file.lux +++ b/stdlib/source/library/lux/world/file.lux @@ -81,10 +81,10 @@ (All (_ !) (-> (System !) Path (Maybe [Path Text]))) (let [/ (\ fs separator)] (case (text.last_index / path) - #.None - #.None + {.#None} + {.#None} - {#.Some last_separator} + {.#Some last_separator} (do maybe.monad [[parent temp] (text.split_at last_separator path) [_ child] (text.split_at (text.size /) temp)] @@ -230,14 +230,14 @@ (do [! (try.with io.monad)] [?children (java/io/File::listFiles (java/io/File::new path))] (case ?children - {#.Some children} + {.#Some children} (|> children - (array.list #.None) + (array.list {.#None}) (monad.only ! (|>> <method>)) (\ ! each (monad.each ! (|>> java/io/File::getAbsolutePath))) (\ ! conjoint)) - #.None + {.#None} (\ io.monad in (exception.except ..cannot_find_directory [path])))))] [directory_files java/io/File::isFile] @@ -354,8 +354,8 @@ io.run! write! (if (ffi.null? error) - {#try.Success []} - {#try.Failure (Error::toString [] (:as Error error))}))) + {try.#Success []} + {try.#Failure (Error::toString [] (:as Error error))}))) (def: (value_callback write!) (All (_ a) (-> (async.Resolver (Try a)) ffi.Function)) @@ -363,8 +363,8 @@ io.run! write! (if (ffi.null? error) - {#try.Success (:expected datum)} - {#try.Failure (Error::toString [] (:as Error error))}))) + {try.#Success (:expected datum)} + {try.#Failure (Error::toString [] (:as Error error))}))) (ffi.import: JsPath ["[1]::[0]" @@ -383,9 +383,9 @@ (def: (require _) (-> [] (-> ffi.String Any)) (case [(normal_require []) (global_require []) (process_load [])] - (^or [{#.Some require} _ _] - [_ {#.Some require} _] - [_ _ {#.Some require}]) + (^or [{.#Some require} _ _] + [_ {.#Some require} _] + [_ _ {.#Some require}]) require _ @@ -418,10 +418,10 @@ (Fs::stat [path (..value_callback write!)] (..node_fs [])))] (in (case ?stats - {#try.Success stats} + {try.#Success stats} (<method> [] stats) - {#try.Failure _} + {try.#Failure _} false))))] [file? Stats::isFile] @@ -437,10 +437,10 @@ (..any_callback write!)] node_fs))] (case outcome - {#try.Success _} + {try.#Success _} (in (exception.except ..cannot_make_directory [path])) - {#try.Failure _} + {try.#Failure _} (with_async write! (Try Any) (Fs::mkdir [path (..any_callback write!)] node_fs))))) @@ -451,7 +451,7 @@ subs (with_async write! (Try (Array ffi.String)) (Fs::readdir [path (..value_callback write!)] node_fs))] (|> subs - (array.list #.None) + (array.list {.#None}) (list\each (|>> (format path ..js_separator))) (monad.each ! (function (_ sub) (\ ! each (|>> (<method> []) [sub]) @@ -487,12 +487,12 @@ (def: (can_execute? path) (let [node_fs (..node_fs [])] (\ async.monad each - (|>> (case> {#try.Success _} + (|>> (case> {try.#Success _} true - {#try.Failure _} + {try.#Failure _} false) - #try.Success) + {try.#Success}) (with_async write! (Try Any) (Fs::access [path (|> node_fs Fs::constants FsConstants::X_OK) @@ -598,7 +598,7 @@ (let [! (try.with io.monad)] (|> path os::listdir - (\ ! each (|>> (array.list #.None) + (\ ! each (|>> (array.list {.#None}) (list\each (|>> (format path ..python_separator))) (monad.each ! (function (_ sub) (\ ! each (|>> [sub]) (<method> [sub])))) @@ -725,19 +725,19 @@ [self (RubyDir::open [path]) children (RubyDir::children [] self) output (loop [input (|> children - (array.list #.None) + (array.list {.#None}) (list\each (|>> (format path ..ruby_separator)))) output (: (List ..Path) (list))] (case input - #.End + {.#End} (in output) - {#.Item head tail} + {.#Item head tail} (do ! [verdict (<test> head)] (recur tail (if verdict - {#.Item head output} + {.#Item head output} output))))) _ (RubyDir::close [] self)] (in output)))] @@ -918,21 +918,21 @@ ... (do [! (try.with io.monad)] ... [children (..scandir [path])] ... (loop [input (|> children - ... (array.list #.None) + ... (array.list {.#None}) ... (list.only (function (_ child) ... (not (or (text\= "." child) ... (text\= ".." child)))))) ... output (: (List (<capability> IO)) ... (list))] ... (case input - ... #.End + ... {.#End} ... (in output) - ... {#.Item head tail} + ... {.#Item head tail} ... (do ! ... [verdict (<test> head)] ... (if verdict - ... (recur tail {#.Item (<constructor> head) output}) + ... (recur tail {.#Item (<constructor> head) output}) ... (recur tail output)))))))] ... [files ..is_file ..file File] @@ -956,7 +956,7 @@ ... [verdict (<test> path)] ... (\ io.monad in ... (if verdict - ... {#try.Success (<constructor> path)} + ... {try.#Success (<constructor> path)} ... (exception.except <exception> [path])))))] ... [file ..is_file ..file ..cannot_find_file] @@ -968,7 +968,7 @@ ... [verdict (..touch [path (|> instant.now io.run! instant.relative duration.millis (i./ +1,000))])] ... (\ io.monad in ... (if verdict - ... {#try.Success (..file path)} + ... {try.#Success (..file path)} ... (exception.except ..cannot_make_file [path]))))) ... (def: (make_directory path) @@ -976,7 +976,7 @@ ... [verdict (..mkdir path)] ... (\ io.monad in ... (if verdict - ... {#try.Success (..directory path)} + ... {try.#Success (..directory path)} ... (exception.except ..cannot_make_directory [path]))))) ... (def: separator @@ -1013,23 +1013,23 @@ (loop [directory mock trail (text.all_split_by separator path)] (case trail - {#.Item head tail} + {.#Item head tail} (case (dictionary.value head directory) - #.None + {.#None} (exception.except ..cannot_find_file [path]) - {#.Some node} + {.#Some node} (case [node tail] - [{#.Left file} #.End] - {#try.Success [head file]} + [{.#Left file} {.#End}] + {try.#Success [head file]} - [{#.Right sub_directory} {#.Item _}] + [{.#Right sub_directory} {.#Item _}] (recur sub_directory tail) _ (exception.except ..cannot_find_file [path]))) - #.End + {.#End} (exception.except ..cannot_find_file [path])))) (def: (update_mock_file! / path now content mock) @@ -1037,38 +1037,38 @@ (loop [directory mock trail (text.all_split_by / path)] (case trail - {#.Item head tail} + {.#Item head tail} (case (dictionary.value head directory) - #.None + {.#None} (case tail - #.End - {#try.Success (dictionary.has head - {#.Left [#mock_last_modified now + {.#End} + {try.#Success (dictionary.has head + {.#Left [#mock_last_modified now #mock_can_execute false #mock_content content]} directory)} - {#.Item _} + {.#Item _} (exception.except ..cannot_find_file [path])) - {#.Some node} + {.#Some node} (case [node tail] - [{#.Left file} #.End] - {#try.Success (dictionary.has head - {#.Left (|> file + [{.#Left file} {.#End}] + {try.#Success (dictionary.has head + {.#Left (|> file (with@ #mock_last_modified now) (with@ #mock_content content))} directory)} - [{#.Right sub_directory} {#.Item _}] + [{.#Right sub_directory} {.#Item _}] (do try.monad [sub_directory (recur sub_directory tail)] - (in (dictionary.has head {#.Right sub_directory} directory))) + (in (dictionary.has head {.#Right sub_directory} directory))) _ (exception.except ..cannot_find_file [path]))) - #.End + {.#End} (exception.except ..cannot_find_file [path])))) (def: (delete_mock_node! / path mock) @@ -1076,34 +1076,34 @@ (loop [directory mock trail (text.all_split_by / path)] (case trail - {#.Item head tail} + {.#Item head tail} (case (dictionary.value head directory) - #.None + {.#None} (exception.except ..cannot_delete [path]) - {#.Some node} + {.#Some node} (case tail - #.End + {.#End} (case node - {#.Left file} - {#try.Success (dictionary.lacks head directory)} + {.#Left file} + {try.#Success (dictionary.lacks head directory)} - {#.Right sub_directory} + {.#Right sub_directory} (if (dictionary.empty? sub_directory) - {#try.Success (dictionary.lacks head directory)} + {try.#Success (dictionary.lacks head directory)} (exception.except ..cannot_delete [path]))) - {#.Item _} + {.#Item _} (case node - {#.Left file} + {.#Left file} (exception.except ..cannot_delete [path]) - {#.Right sub_directory} + {.#Right sub_directory} (do try.monad [sub_directory' (recur sub_directory tail)] - (in (dictionary.has head {#.Right sub_directory'} directory)))))) + (in (dictionary.has head {.#Right sub_directory'} directory)))))) - #.End + {.#End} (exception.except ..cannot_delete [path])))) (def: (attempt! transform var) @@ -1111,40 +1111,40 @@ (do [! stm.monad] [|var| (stm.read var)] (case (transform |var|) - {#try.Success |var|} + {try.#Success |var|} (do ! [_ (stm.write |var| var)] - (in {#try.Success []})) + (in {try.#Success []})) - {#try.Failure error} - (in {#try.Failure error})))) + {try.#Failure error} + (in {try.#Failure error})))) (def: (make_mock_directory! / path mock) (-> Text Path Mock (Try Mock)) (loop [directory mock trail (text.all_split_by / path)] (case trail - {#.Item head tail} + {.#Item head tail} (case (dictionary.value head directory) - #.None + {.#None} (case tail - #.End - {#try.Success (dictionary.has head {#.Right ..empty_mock} directory)} + {.#End} + {try.#Success (dictionary.has head {.#Right ..empty_mock} directory)} - {#.Item _} + {.#Item _} (exception.except ..cannot_make_directory [path])) - {#.Some node} + {.#Some node} (case [node tail] - [{#.Right sub_directory} {#.Item _}] + [{.#Right sub_directory} {.#Item _}] (do try.monad [sub_directory (recur sub_directory tail)] - (in (dictionary.has head {#.Right sub_directory} directory))) + (in (dictionary.has head {.#Right sub_directory} directory))) _ (exception.except ..cannot_make_directory [path]))) - #.End + {.#End} (exception.except ..cannot_make_directory [path])))) (def: (retrieve_mock_directory! / path mock) @@ -1152,25 +1152,25 @@ (loop [directory mock trail (text.all_split_by / path)] (case trail - #.End - {#try.Success directory} + {.#End} + {try.#Success directory} - {#.Item head tail} + {.#Item head tail} (case (dictionary.value head directory) - #.None + {.#None} (exception.except ..cannot_find_directory [path]) - {#.Some node} + {.#Some node} (case node - {#.Left _} + {.#Left _} (exception.except ..cannot_find_directory [path]) - {#.Right sub_directory} + {.#Right sub_directory} (case tail - #.End - {#try.Success sub_directory} + {.#End} + {try.#Success sub_directory} - {#.Item _} + {.#Item _} (recur sub_directory tail))))))) (def: .public (mock separator) @@ -1198,13 +1198,13 @@ (do [! stm.monad] [|store| (stm.read store)] (case (..make_mock_directory! separator path |store|) - {#try.Success |store|} + {try.#Success |store|} (do ! [_ (stm.write |store| store)] - (in {#try.Success []})) + (in {try.#Success []})) - {#try.Failure error} - (in {#try.Failure error}))))) + {try.#Failure error} + (in {try.#Failure error}))))) (~~ (template [<method> <tag>] [(def: (<method> path) @@ -1218,13 +1218,13 @@ (list.all (function (_ [node_name node]) (case node {<tag> _} - {#.Some (format path separator node_name)} + {.#Some (format path separator node_name)} _ - #.None))))))))))] + {.#None}))))))))))] - [directory_files #.Left] - [sub_directories #.Right] + [directory_files .#Left] + [sub_directories .#Right] )) (def: (file_size path) @@ -1304,13 +1304,13 @@ [[name file] (..retrieve_mock_file! separator origin |store|) |store| (..delete_mock_node! separator origin |store|)] (..update_mock_file! separator destination (value@ #mock_last_modified file) (value@ #mock_content file) |store|)) - {#try.Success |store|} + {try.#Success |store|} (do ! [_ (stm.write |store| store)] - (in {#try.Success []})) + (in {try.#Success []})) - {#try.Failure error} - (in {#try.Failure error}))))) + {try.#Failure error} + (in {try.#Failure error}))))) )))) (def: (check_or_make_directory monad fs path) @@ -1318,7 +1318,7 @@ (do monad [? (\ fs directory? path)] (if ? - (in {#try.Success []}) + (in {try.#Success []}) (\ fs make_directory path)))) (def: .public (make_directories monad fs path) @@ -1328,10 +1328,10 @@ (case (if rooted? (list.after 1 segments) segments) - #.End + {.#End} (\ monad in (exception.except ..cannot_make_directory [path])) - {#.Item head tail} + {.#Item head tail} (case head "" (\ monad in (exception.except ..cannot_make_directory [path])) _ (loop [current (if rooted? @@ -1341,17 +1341,17 @@ (do monad [? (..check_or_make_directory monad fs current)] (case ? - {#try.Success _} + {try.#Success _} (case next - #.End - (in {#try.Success []}) + {.#End} + (in {try.#Success []}) - {#.Item head tail} + {.#Item head tail} (recur (format current (\ fs separator) head) tail)) - {#try.Failure error} - (in {#try.Failure error})))))))) + {try.#Failure error} + (in {try.#Failure error})))))))) (def: .public (make_file monad fs content path) (All (_ !) (-> (Monad !) (System !) Binary Path (! (Try Any)))) diff --git a/stdlib/source/library/lux/world/file/watch.lux b/stdlib/source/library/lux/world/file/watch.lux index 51ac92a90..86620bd7b 100644 --- a/stdlib/source/library/lux/world/file/watch.lux +++ b/stdlib/source/library/lux/world/file/watch.lux @@ -112,12 +112,12 @@ (do [! stm.monad] [@tracker (stm.read tracker)] (case (dictionary.value path @tracker) - {#.Some [old_concern last_modified]} + {.#Some [old_concern last_modified]} (do ! [_ (stm.update (dictionary.has path [new_concern last_modified]) tracker)] (in true)) - #.None + {.#None} (in false)))) (def: (file_tracker fs directory) @@ -143,7 +143,7 @@ (\ ! each (|>> [file])))) files))) -(def: (available_directory_changes fs [directory [concern file_tracker]]) +(def: (available_directory_changes fs [directory [the_concern file_tracker]]) (-> (//.System Async) [//.Path [Concern File_Tracker]] (Async (Try [[//.Path [Concern File_Tracker]] [(List [//.Path Instant]) @@ -151,14 +151,14 @@ (List //.Path)]]))) (do [! (try.with async.monad)] [current_files (..available_files fs directory) - .let [creations (if (..creation? concern) + .let [creations (if (..creation? the_concern) (list.only (|>> product.left (dictionary.key? file_tracker) not) current_files) (list)) available (|> current_files (list\each product.left) (set.of_list text.hash)) - deletions (if (..deletion? concern) + deletions (if (..deletion? the_concern) (|> (dictionary.entries file_tracker) (list\each product.left) (list.only (|>> (set.member? available) not))) @@ -169,7 +169,7 @@ (in [path previous_modification current_modification]))) current_files)]] (in [[directory - [concern + [the_concern (let [with_deletions (list\mix dictionary.lacks file_tracker deletions) with_creations (list\mix (function (_ [path last_modified] tracker) (dictionary.has path last_modified tracker)) @@ -196,34 +196,34 @@ (do ! [updated? (stm.commit! (..update_watch! new_concern path tracker))] (if updated? - (in {#try.Success []}) + (in {try.#Success []}) (do (try.with !) [file_tracker (..file_tracker fs path)] (do ! [_ (stm.commit! (stm.update (dictionary.has path [new_concern file_tracker]) tracker))] - (in {#try.Success []}))))) + (in {try.#Success []}))))) (in (exception.except ..cannot_poll_a_non_existent_directory [path]))))) (def: (concern path) (stm.commit! (do stm.monad [@tracker (stm.read tracker)] (in (case (dictionary.value path @tracker) - {#.Some [concern file_tracker]} - {#try.Success concern} + {.#Some [it file_tracker]} + {try.#Success it} - #.None + {.#None} (exception.except ..not_being_watched [path])))))) (def: (stop path) (stm.commit! (do [! stm.monad] [@tracker (stm.read tracker)] (case (dictionary.value path @tracker) - {#.Some [concern file_tracker]} + {.#Some [the_concern file_tracker]} (do ! [_ (stm.update (dictionary.lacks path) tracker)] - (in {#try.Success concern})) + (in {try.#Success the_concern})) - #.None + {.#None} (in (exception.except ..not_being_watched [path])))))) (def: (poll _) (do async.monad @@ -237,7 +237,7 @@ (list\each product.left) (dictionary.of_list text.hash)) tracker))] - (in {#try.Success []})) + (in {try.#Success []})) .let [[creations modifications deletions] (list\mix (function (_ [_ [creations modifications deletions]] [all_creations all_modifications all_deletions]) @@ -275,10 +275,10 @@ (All (_ a) (-> (java/util/List a) (List a))) (let [size (.nat (java/util/List::size list))] (loop [idx 0 - output #.End] + output {.#End}] (if (n.< size idx) (recur (++ idx) - {#.Item (java/util/List::get (.int idx) list) + {.#Item (java/util/List::get (.int idx) list) output}) output)))) @@ -375,7 +375,7 @@ (do (try.with io.monad) [?key (java/nio/file/WatchService::poll watcher)] (case ?key - {#.Some key} + {.#Some key} (do [! io.monad] [valid? (java/nio/file/WatchKey::reset key)] (if valid? @@ -385,12 +385,12 @@ (:as java/nio/file/Path) java/nio/file/Path::toString (:as //.Path))] - concern (..default_key_concern key)] - (recur {#.Item [concern path] + the_concern (..default_key_concern key)] + (recur {.#Item [the_concern path] output})) (recur output))) - #.None + {.#None} (in output))))) (def: (watch_events concern) @@ -420,36 +420,36 @@ (do [! async.monad] [@tracker (stm.commit! (stm.read tracker))] (case (dictionary.value path @tracker) - {#.Some [concern key]} + {.#Some [the_concern key]} (do ! [_ (async.future (java/nio/file/WatchKey::cancel key)) _ (stm.commit! (stm.update (dictionary.lacks path) tracker))] - (in {#try.Success concern})) + (in {try.#Success the_concern})) - #.None + {.#None} (in (exception.except ..not_being_watched [path]))))))]] (in (: (Watcher Async) (implementation - (def: (start concern path) + (def: (start the_concern path) (do async.monad [?concern (stop path)] (do (try.with async.monad) [key (..default_start (..watch_events (..also (try.else ..none ?concern) - concern)) + the_concern)) watcher path)] (do async.monad - [_ (stm.commit! (stm.update (dictionary.has path [concern key]) tracker))] - (in {#try.Success []}))))) + [_ (stm.commit! (stm.update (dictionary.has path [the_concern key]) tracker))] + (in {try.#Success []}))))) (def: (concern path) (do async.monad [@tracker (stm.commit! (stm.read tracker))] (case (dictionary.value path @tracker) - {#.Some [concern key]} - (in {#try.Success concern}) + {.#Some [it key]} + (in {try.#Success it}) - #.None + {.#None} (in (exception.except ..not_being_watched [path]))))) (def: stop stop) (def: (poll _) diff --git a/stdlib/source/library/lux/world/net/http.lux b/stdlib/source/library/lux/world/net/http.lux index 8afbd105b..8e61f33a0 100644 --- a/stdlib/source/library/lux/world/net/http.lux +++ b/stdlib/source/library/lux/world/net/http.lux @@ -17,15 +17,15 @@ (type: .public Method (Variant - #Post - #Get - #Put - #Patch - #Delete - #Head - #Connect - #Options - #Trace)) + {#Post} + {#Get} + {#Put} + {#Patch} + {#Delete} + {#Head} + {#Connect} + {#Options} + {#Trace})) (type: .public Port Nat) @@ -48,8 +48,8 @@ (type: .public Scheme (Variant - #HTTP - #HTTPS)) + {#HTTP} + {#HTTPS})) (type: .public Address (Record diff --git a/stdlib/source/library/lux/world/net/http/client.lux b/stdlib/source/library/lux/world/net/http/client.lux index 472c49a52..7fed7739e 100644 --- a/stdlib/source/library/lux/world/net/http/client.lux +++ b/stdlib/source/library/lux/world/net/http/client.lux @@ -36,8 +36,8 @@ (! (Try (//.Response !)))) request))) -(syntax: (method_function [[_ name] <code>.tag]) - (in (list (code.local_identifier (text.lower_cased name))))) +(syntax: (method_function [[_ name] <code>.identifier]) + (in (list (code.local_identifier (text.replaced "#" "" (text.lower_cased name)))))) (template [<method>] [(with_expansions [<name> (method_function <method>)] @@ -45,17 +45,17 @@ (All (_ !) (-> URL //.Headers (Maybe Binary) (Client !) (! (Try (//.Response !))))) - (\ client request <method> url headers data)))] - - [#//.Post] - [#//.Get] - [#//.Put] - [#//.Patch] - [#//.Delete] - [#//.Head] - [#//.Connect] - [#//.Options] - [#//.Trace] + (\ client request {<method>} url headers data)))] + + [//.#Post] + [//.#Get] + [//.#Put] + [//.#Patch] + [//.#Delete] + [//.#Head] + [//.#Connect] + [//.#Options] + [//.#Trace] ) (def: default_buffer_size @@ -108,15 +108,15 @@ (def: jvm_method (-> //.Method Text) - (|>> (case> #//.Post "POST" - #//.Get "GET" - #//.Put "PUT" - #//.Patch "PATCH" - #//.Delete "DELETE" - #//.Head "HEAD" - #//.Connect "CONNECT" - #//.Options "OPTIONS" - #//.Trace "TRACE"))) + (|>> (case> {//.#Post} "POST" + {//.#Get} "GET" + {//.#Put} "PUT" + {//.#Patch} "PATCH" + {//.#Delete} "DELETE" + {//.#Head} "HEAD" + {//.#Connect} "CONNECT" + {//.#Options} "OPTIONS" + {//.#Trace} "TRACE"))) (def: (default_body input) (-> java/io/BufferedInputStream (//.Body IO)) @@ -172,13 +172,13 @@ (do [! (try.with io.monad)] [?name (java/net/URLConnection::getHeaderFieldKey index connection)] (case ?name - {#.Some name} + {.#Some name} (do ! [?value (java/net/URLConnection::getHeaderField index connection)] (recur (++ index) (dictionary.has name (maybe.else "" ?value) headers))) - #.None + {.#None} (in headers))))) (implementation: .public default @@ -194,7 +194,7 @@ (java/net/URLConnection::setRequestProperty name value connection)) (dictionary.entries headers)) _ (case data - {#.Some data} + {.#Some data} (do ! [_ (java/net/URLConnection::setDoOutput true connection) stream (java/net/URLConnection::getOutputStream connection) @@ -203,7 +203,7 @@ _ (java/lang/AutoCloseable::close stream)] (in [])) - #.None + {.#None} (in [])) status (java/net/HttpURLConnection::getResponseCode connection) headers (..default_headers connection) @@ -211,8 +211,8 @@ java/net/URLConnection::getInputStream (\ ! each (|>> java/io/BufferedInputStream::new)))] (in [(.nat status) - [#//.headers headers - #//.body (..default_body input)]]))))))] + [//.#headers headers + //.#body (..default_body input)]]))))))] (for [@.old (as_is <jvm>) @.jvm (as_is <jvm>)] (as_is))) @@ -224,14 +224,14 @@ (|> (\ client request method url headers data) async.future (\ async.monad each - (|>> (case> {#try.Success [status message]} - {#try.Success [status (revised@ #//.body (: (-> (//.Body IO) (//.Body Async)) + (|>> (case> {try.#Success [status message]} + {try.#Success [status (revised@ //.#body (: (-> (//.Body IO) (//.Body Async)) (function (_ body) (|>> body async.future))) message)]} - {#try.Failure error} - {#try.Failure error})))))) + {try.#Failure error} + {try.#Failure error})))))) (def: .public headers (-> (List [Text Text]) //.Headers) diff --git a/stdlib/source/library/lux/world/net/http/cookie.lux b/stdlib/source/library/lux/world/net/http/cookie.lux index b1a829f9a..a7e2d1644 100644 --- a/stdlib/source/library/lux/world/net/http/cookie.lux +++ b/stdlib/source/library/lux/world/net/http/cookie.lux @@ -59,14 +59,14 @@ (type: .public CSRF_Policy (Variant - #Strict - #Lax)) + {#Strict} + {#Lax})) (def: .public (same_site policy) (-> CSRF_Policy Directive) (..directive (format "SameSite=" (case policy - #Strict "Strict" - #Lax "Lax")))) + {#Strict} "Strict" + {#Lax} "Lax")))) (def: (cookie context) (-> Context (Parser Context)) diff --git a/stdlib/source/library/lux/world/net/http/request.lux b/stdlib/source/library/lux/world/net/http/request.lux index c6185bc09..12287083d 100644 --- a/stdlib/source/library/lux/world/net/http/request.lux +++ b/stdlib/source/library/lux/world/net/http/request.lux @@ -56,73 +56,73 @@ (All (_ a) (-> (<json>.Reader a) (-> a Server) Server)) (function (_ (^@ request [identification protocol resource message])) (do async.monad - [?raw (read_text_body (value@ #//.body message))] + [?raw (read_text_body (value@ //.#body message))] (case (do try.monad [raw ?raw content (\ json.codec decoded raw)] (json.result content reader)) - {#try.Success input} + {try.#Success input} (server input request) - {#try.Failure error} + {try.#Failure error} (async.resolved ..failure))))) (def: .public (text server) (-> (-> Text Server) Server) (function (_ (^@ request [identification protocol resource message])) (do async.monad - [?raw (read_text_body (value@ #//.body message))] + [?raw (read_text_body (value@ //.#body message))] (case ?raw - {#try.Success content} + {try.#Success content} (server content request) - {#try.Failure error} + {try.#Failure error} (async.resolved ..failure))))) (def: .public (query property server) (All (_ a) (-> (Property a) (-> a Server) Server)) (function (_ [identification protocol resource message]) - (let [full (value@ #//.uri resource) + (let [full (value@ //.#uri resource) [uri query] (|> full (text.split_by "?") (maybe.else [full ""]))] (case (do try.monad [query (//query.parameters query) input (context.result query property)] - (in [[identification protocol (with@ #//.uri uri resource) message] + (in [[identification protocol (with@ //.#uri uri resource) message] input])) - {#try.Success [request input]} + {try.#Success [request input]} (server input request) - {#try.Failure error} + {try.#Failure error} (async.resolved ..failure))))) (def: .public (form property server) (All (_ a) (-> (Property a) (-> a Server) Server)) (function (_ (^@ request [identification protocol resource message])) (do async.monad - [?body (read_text_body (value@ #//.body message))] + [?body (read_text_body (value@ //.#body message))] (case (do try.monad [body ?body form (//query.parameters body)] (context.result form property)) - {#try.Success input} + {try.#Success input} (server input request) - {#try.Failure error} + {try.#Failure error} (async.resolved ..failure))))) (def: .public (cookies property server) (All (_ a) (-> (Property a) (-> a Server) Server)) (function (_ (^@ request [identification protocol resource message])) (case (do try.monad - [cookies (|> (value@ #//.headers message) + [cookies (|> (value@ //.#headers message) (dictionary.value "Cookie") (maybe.else "") //cookie.get)] (context.result cookies property)) - {#try.Success input} + {try.#Success input} (server input request) - {#try.Failure error} + {try.#Failure error} (async.resolved ..failure)))) diff --git a/stdlib/source/library/lux/world/net/http/response.lux b/stdlib/source/library/lux/world/net/http/response.lux index 0a03f9f31..272e906b5 100644 --- a/stdlib/source/library/lux/world/net/http/response.lux +++ b/stdlib/source/library/lux/world/net/http/response.lux @@ -32,15 +32,15 @@ (let [body (frp\in (\ encoding.utf8 encoded ""))] (function (_ status) [status - [#//.headers (|> context.empty + [//.#headers (|> context.empty (header.content_length 0) (header.content_type mime.utf_8)) - #//.body body]]))) + //.#body body]]))) (def: .public (temporary_redirect to) (-> URL Response) (let [[status message] (..empty status.temporary_redirect)] - [status (revised@ #//.headers (header.location to) message)])) + [status (revised@ //.#headers (header.location to) message)])) (def: .public not_found Response @@ -49,10 +49,10 @@ (def: .public (content status type data) (-> Status MIME Binary Response) [status - [#//.headers (|> context.empty + [//.#headers (|> context.empty (header.content_length (binary.size data)) (header.content_type type)) - #//.body (frp\in data)]]) + //.#body (frp\in data)]]) (def: .public bad_request (-> Text Response) diff --git a/stdlib/source/library/lux/world/net/http/route.lux b/stdlib/source/library/lux/world/net/http/route.lux index 4232f4481..92b522254 100644 --- a/stdlib/source/library/lux/world/net/http/route.lux +++ b/stdlib/source/library/lux/world/net/http/route.lux @@ -18,46 +18,46 @@ [(def: .public (<name> server) (-> Server Server) (function (_ (^@ request [identification protocol resource message])) - (case (value@ #//.scheme protocol) - <scheme> + (case (value@ //.#scheme protocol) + {<scheme>} (server request) _ (async.resolved //response.not_found))))] - [#//.HTTP http] - [#//.HTTPS https] + [//.#HTTP http] + [//.#HTTPS https] ) (template [<method> <name>] [(def: .public (<name> server) (-> Server Server) (function (_ (^@ request [identification protocol resource message])) - (case (value@ #//.method resource) - <method> + (case (value@ //.#method resource) + {<method>} (server request) _ (async.resolved //response.not_found))))] - [#//.Get get] - [#//.Post post] - [#//.Put put] - [#//.Patch patch] - [#//.Delete delete] - [#//.Head head] - [#//.Connect connect] - [#//.Options options] - [#//.Trace trace] + [//.#Get get] + [//.#Post post] + [//.#Put put] + [//.#Patch patch] + [//.#Delete delete] + [//.#Head head] + [//.#Connect connect] + [//.#Options options] + [//.#Trace trace] ) (def: .public (uri path server) (-> URI Server Server) (function (_ [identification protocol resource message]) - (if (text.starts_with? path (value@ #//.uri resource)) + (if (text.starts_with? path (value@ //.#uri resource)) (server [identification protocol - (revised@ #//.uri + (revised@ //.#uri (|>> (text.clip_since (text.size path)) maybe.trusted) resource) message]) diff --git a/stdlib/source/library/lux/world/program.lux b/stdlib/source/library/lux/world/program.lux index 5d5604777..3a4b1417a 100644 --- a/stdlib/source/library/lux/world/program.lux +++ b/stdlib/source/library/lux/world/program.lux @@ -62,11 +62,11 @@ (in (|> entries (list.all (function (_ [name value]) (case value - {#try.Success value} - {#.Some [name value]} + {try.#Success value} + {.#Some [name value]} - {#try.Failure _} - #.None))) + {try.#Failure _} + {.#None}))) (dictionary.of_list text.hash))))) (`` (implementation: .public (async program) @@ -97,10 +97,10 @@ (function.constant (io.io (dictionary.keys environment)))) (def: (variable name) (io.io (case (dictionary.value name environment) - {#.Some value} - {#try.Success value} + {.#Some value} + {try.#Success value} - #.None + {.#None} (exception.except ..unknown_environment_variable [name])))) (def: home home) @@ -137,9 +137,9 @@ (def: (jvm\\consume iterator) (All (_ a) (-> (java/util/Iterator a) (List a))) (if (java/util/Iterator::hasNext iterator) - {#.Item (java/util/Iterator::next iterator) + {.#Item (java/util/Iterator::next iterator) (jvm\\consume iterator)} - #.End)) + {.#End})) )] (for [@.old (as_is <jvm>) @.jvm (as_is <jvm>) @@ -155,10 +155,10 @@ (def: (exit_node_js! code) (-> Exit (IO Nothing)) (case (ffi.constant ..NodeJs_Process [process]) - {#.Some process} + {.#Some process} (NodeJs_Process::exit (i.frac code) process) - #.None + {.#None} (..default_exit! code))) (import: Browser_Window @@ -173,23 +173,23 @@ (-> Exit (IO Nothing)) (case [(ffi.constant ..Browser_Window [window]) (ffi.constant ..Browser_Location [location])] - [{#.Some window} {#.Some location}] + [{.#Some window} {.#Some location}] (exec (Browser_Window::close [] window) (Browser_Location::reload [] location) (..default_exit! code)) - [{#.Some window} #.None] + [{.#Some window} {.#None}] (exec (Browser_Window::close [] window) (..default_exit! code)) - [#.None {#.Some location}] + [{.#None} {.#Some location}] (exec (Browser_Location::reload [] location) (..default_exit! code)) - [#.None #.None] + [{.#None} {.#None}] (..default_exit! code))) (import: Object @@ -213,9 +213,9 @@ (def: (require _) (-> [] (-> ffi.String Any)) (case [(normal_require []) (global_require []) (process_load [])] - (^or [{#.Some require} _ _] - [_ {#.Some require} _] - [_ _ {#.Some require}]) + (^or [{.#Some require} _ _] + [_ {.#Some require} _] + [_ _ {.#Some require}]) require _ @@ -247,18 +247,18 @@ (do [! io.monad] [outcome (io/popen [command])] (case outcome - {#try.Success outcome} + {try.#Success outcome} (case outcome - {#.Some file} + {.#Some file} (do ! [?output (LuaFile::read ["*l"] file) _ (LuaFile::close [] file)] (in (maybe.else default ?output))) - #.None + {.#None} (in default)) - {#try.Failure _} + {try.#Failure _} (in default))))) @.ruby (as_is (ffi.import: Env "as" RubyEnv ["[1]::[0]" @@ -314,25 +314,25 @@ @.jvm <jvm> @.js (io.io (if ffi.on_node_js? (case (ffi.constant Object [process env]) - {#.Some process/env} + {.#Some process/env} (|> (Object::entries [process/env]) - (array.list #.None) + (array.list {.#None}) (list\each (|>> (array.read! 0) maybe.trusted))) - #.None + {.#None} (list)) (list))) - @.python (\ io.monad each (array.list #.None) (os/environ::keys [])) + @.python (\ io.monad each (array.list {.#None}) (os/environ::keys [])) ... Lua offers no way to get all the environment variables available. @.lua (io.io (list)) @.ruby (|> (RubyEnv::keys []) - (array.list #.None) + (array.list {.#None}) io.io) ... @.php (do io.monad ... [environment (..getenv/0 [])] ... (in (|> environment ... ..array_keys - ... (array.list #.None) + ... (array.list {.#None}) ... (list\each (function (_ variable) ... [variable ("php array read" (:as Nat variable) environment)])) ... (dictionary.of_list text.hash)))) @@ -352,10 +352,10 @@ [(do io.monad [value (<method> name)] (in (case value - {#.Some value} - {#try.Success value} + {.#Some value} + {try.#Success value} - #.None + {.#None} (exception.except ..unknown_environment_variable [name]))))]] (with_expansions [<jvm> (!fetch java/lang/System::resolveEnv)] (for [@.old <jvm> @@ -365,10 +365,10 @@ [process/env (ffi.constant Object [process env])] (array.read! (:as Nat name) (:as (Array Text) process/env))) - {#.Some value} - {#try.Success value} + {.#Some value} + {try.#Success value} - #.None + {.#None} (exception.except ..unknown_environment_variable [name])) (exception.except ..unknown_environment_variable [name]))) @.python (!fetch os/environ::get) @@ -407,10 +407,10 @@ @.jvm <jvm> @.js (if ffi.on_node_js? (case (ffi.constant ..NodeJs_Process [process]) - {#.Some process} + {.#Some process} (NodeJs_Process::cwd [] process) - #.None + {.#None} (io.io <default>)) (io.io <default>)) @.python (os::getcwd []) diff --git a/stdlib/source/library/lux/world/shell.lux b/stdlib/source/library/lux/world/shell.lux index 3fd76261b..29ff3ab2e 100644 --- a/stdlib/source/library/lux/world/shell.lux +++ b/stdlib/source/library/lux/world/shell.lux @@ -50,7 +50,7 @@ (: (-> [] (! (Try Text))) read) (: (-> [] (! (Try Text))) - error) + fail) (: (-> Text (! (Try Any))) write) (: (-> [] (! (Try Any))) @@ -67,7 +67,7 @@ async.future))] [read] - [error] + [fail] [write] [destroy] [await] @@ -140,11 +140,11 @@ (Ex (_ ?) (-> (Sanitizer Command) (Sanitizer Argument) (Policy ?))) (?.with_policy (: (Context Safety Policy) - (function (_ (^open "?\[0]")) + (function (_ (^open "?[0]")) (implementation - (def: command (|>> safe_command ?\can_upgrade)) - (def: argument (|>> safe_argument ?\can_upgrade)) - (def: value ?\can_downgrade)))))) + (def: command (|>> safe_command ?#can_upgrade)) + (def: argument (|>> safe_argument ?#can_upgrade)) + (def: value ?#can_downgrade)))))) (def: unix_policy (let [replacer (: Replacer @@ -249,14 +249,14 @@ (do ! [output (java/io/BufferedReader::readLine <stream>)] (case output - {#.Some output} + {.#Some output} (in output) - #.None + {.#None} (\ io.monad in (exception.except ..no_more_output [])))))] [read jvm_input] - [error jvm_error] + [fail jvm_error] )) (def: (write message) (java/io/OutputStream::write (\ utf8.codec encoded message) jvm_output)) @@ -315,7 +315,7 @@ (: (-> s (Try [s Text])) on_read) (: (-> s (Try [s Text])) - on_error) + on_fail) (: (-> Text s (Try s)) on_write) (: (-> s (Try s)) @@ -331,40 +331,40 @@ (do [! io.monad] [|state| (atom.read! state)] (case (\ mock <mock> |state|) - {#try.Success [|state| output]} + {try.#Success [|state| output]} (do ! [_ (atom.write! |state| state)] - (in {#try.Success output})) + (in {try.#Success output})) - {#try.Failure error} - (in {#try.Failure error}))))] + {try.#Failure error} + (in {try.#Failure error}))))] [read on_read] - [error on_error] + [fail on_fail] [await on_await] )) (def: (write message) (do [! io.monad] [|state| (atom.read! state)] (case (\ mock on_write message |state|) - {#try.Success |state|} + {try.#Success |state|} (do ! [_ (atom.write! |state| state)] - (in {#try.Success []})) + (in {try.#Success []})) - {#try.Failure error} - (in {#try.Failure error})))) + {try.#Failure error} + (in {try.#Failure error})))) (def: (destroy _) (do [! io.monad] [|state| (atom.read! state)] (case (\ mock on_destroy |state|) - {#try.Success |state|} + {try.#Success |state|} (do ! [_ (atom.write! |state| state)] - (in {#try.Success []})) + (in {try.#Success []})) - {#try.Failure error} - (in {#try.Failure error})))))) + {try.#Failure error} + (in {try.#Failure error})))))) (implementation: .public (mock mock init) (All (_ s) |