From dda05bca0956af5e5b3875c4cc36e61aa04772e4 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 12 Sep 2021 00:07:08 -0400 Subject: Made the "#" character great again! --- stdlib/source/library/lux.lux | 969 +++++++++++++++++++----------------------- 1 file changed, 447 insertions(+), 522 deletions(-) (limited to 'stdlib/source/library/lux.lux') 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 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 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 (|#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 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 [ ] @@ -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 [ ] [(def:' .private ( tokens) (-> (List Code) (Maybe (List ))) (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 [ ] [(def: ( 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 [ ] @@ -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 [] [{ left right} (` { (~ (type_code left)) (~ (type_code right))})]) - ([#.Sum] [#.Product] - [#.Function] - [#.Apply]) + ([.#Sum] [.#Product] + [.#Function] + [.#Apply]) (^template [] [{ id} (` { (~ (nat$ id))})]) - ([#.Parameter] [#.Var] [#.Ex]) + ([.#Parameter] [.#Var] [.#Ex]) (^template [] [{ env type} (let [env' (untemplated_list (list\each type_code env))] (` { (~ 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 [] - [(^ (list [_ { [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 [ ] [(def: ( 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) { (~ (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 [ ] [[_ { value}] (in (` [(~ g!meta) { (~ ( 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 [ ] @@ -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 "")))) -- cgit v1.2.3