diff options
author | Eduardo Julian | 2022-10-19 19:34:33 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-10-19 19:34:33 -0400 |
commit | 820ffc0a87d7960e62508fc451d9df7a94a6afa7 (patch) | |
tree | 33ff1ac227942820f92b43c0a8b872d4e080f974 /stdlib/source | |
parent | d9a1d70ec04fd5796276aeb46038654ade4484f9 (diff) |
Migrating default extensions to the new format [Part 2]
Diffstat (limited to '')
67 files changed, 1978 insertions, 1988 deletions
diff --git a/stdlib/source/format/lux/data/binary.lux b/stdlib/source/format/lux/data/binary.lux index 034d4edd7..2eede5dfb 100644 --- a/stdlib/source/format/lux/data/binary.lux +++ b/stdlib/source/format/lux/data/binary.lux @@ -38,9 +38,9 @@ (template (<name> <parameter> <subject>) [(<post> (<extension> (.int <parameter>) (.int <subject>)))]))] - [n#= "lux i64 =" .|>] - [n#+ "lux i64 +" .nat] - [n#* "lux i64 *" .nat] + [n#= .i64_=# .|>] + [n#+ .i64_+# .nat] + [n#* .int_*# .nat] ) (def mask diff --git a/stdlib/source/format/lux/data/text.lux b/stdlib/source/format/lux/data/text.lux index 7d237bea2..0b475e609 100644 --- a/stdlib/source/format/lux/data/text.lux +++ b/stdlib/source/format/lux/data/text.lux @@ -51,7 +51,7 @@ (def .public format (syntax (_ [fragments (<>.many <code>.any)]) - (in (.list (` (all "lux text concat" (,* fragments))))))) + (in (.list (` (all .text_composite# (,* fragments))))))) (with_template [<name> <type> <formatter>] [(def .public <name> diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index 94735a065..af8942f2e 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -3,11 +3,11 @@ #0) (.def# double_quote - ("lux i64 char" +34) + (.int_char# +34) #0) (.def# \n - ("lux i64 char" +10) + (.int_char# +10) #0) (.def# prelude @@ -17,7 +17,7 @@ ... (type .public Any ... (Ex (_ a) a)) (.def# Any - ("lux type check type" + (.is_type# {9 #1 [..prelude "Any"] {8 #0 @@ -28,7 +28,7 @@ ... (type .public Nothing ... (All (_ a) a)) (.def# Nothing - ("lux type check type" + (.is_type# {9 #1 [..prelude "Nothing"] {7 #0 @@ -37,14 +37,14 @@ #1) (.def# Bit - ("lux type check type" + (.is_type# {9 #1 [..prelude "Bit"] {0 #0 "#Bit" {0 #0}}}) #1) (.def# I64 - ("lux type check type" + (.is_type# {9 #1 [..prelude "I64"] {7 #0 @@ -53,42 +53,42 @@ #1) (.def# Nat - ("lux type check type" + (.is_type# {9 #1 [..prelude "Nat"] {0 #0 "#I64" {0 #1 {0 #0 "#Nat" {0 #0}} {0 #0}}}}) #1) (.def# Int - ("lux type check type" + (.is_type# {9 #1 [..prelude "Int"] {0 #0 "#I64" {0 #1 {0 #0 "#Int" {0 #0}} {0 #0}}}}) #1) (.def# Rev - ("lux type check type" + (.is_type# {9 #1 [..prelude "Rev"] {0 #0 "#I64" {0 #1 {0 #0 "#Rev" {0 #0}} {0 #0}}}}) #1) (.def# Frac - ("lux type check type" + (.is_type# {9 #1 [..prelude "Frac"] {0 #0 "#Frac" {0 #0}}}) #1) (.def# Text - ("lux type check type" + (.is_type# {9 #1 [..prelude "Text"] {0 #0 "#Text" {0 #0}}}) #1) (.def# Symbol - ("lux type check type" + (.is_type# {9 #1 [..prelude "Symbol"] {2 #0 Text Text}}) @@ -99,7 +99,7 @@ ... {#End} ... {#Item a (List a)})) (.def# List - ("lux type check type" + (.is_type# {9 #1 [..prelude "List"] {7 #0 @@ -118,7 +118,7 @@ ... (type .public Tag ... (Primitive "#Tag")) (.def# Tag - ("lux type check type" + (.is_type# {9 #1 [..prelude "Tag"] {0 #0 "#Tag" {0 #0}}}) #1) @@ -126,31 +126,30 @@ ... (type .public Slot ... (Primitive "#Slot")) (.def# Slot - ("lux type check type" + (.is_type# {9 #1 [..prelude "Slot"] {0 #0 "#Slot" {0 #0}}}) #1) (.def# Label' - ("lux type check type" + (.is_type# {1 #0 [Any {2 #0 [Nat {2 #0 [Bit {9 #0 Symbol List}]}]}]}) #0) (.def# list_tags - ("lux type check" - {9 #0 Symbol List} - {0 #1 [[..prelude "#End"] - {0 #1 [[..prelude "#Item"] - {0 #0}]}]}) + (.is# {9 #0 Symbol List} + {0 #1 [[..prelude "#End"] + {0 #1 [[..prelude "#Item"] + {0 #0}]}]}) #0) -(.def# #End ("lux type as" Tag [("lux type check" Label' {0 #1 [0 #0 ..list_tags]}) List]) #1) -(.def# #Item ("lux type as" Tag [("lux type check" Label' {0 #1 [0 #1 ..list_tags]}) List]) #1) +(.def# #End (.as# Tag [(.is# Label' {0 #1 [0 #0 ..list_tags]}) List]) #1) +(.def# #Item (.as# Tag [(.is# Label' {0 #1 [0 #1 ..list_tags]}) List]) #1) ... (type .public (Maybe a) ... {#None} ... {#Some a}) (.def# Maybe - ("lux type check type" + (.is_type# {9 #1 [..prelude "Maybe"] {7 #0 @@ -162,14 +161,13 @@ {4 #0 1}}}}) #1) (.def# maybe_tags - ("lux type check" - {9 #0 Symbol List} - {0 #1 [[..prelude "#None"] - {0 #1 [[..prelude "#Some"] - {0 #0}]}]}) + (.is# {9 #0 Symbol List} + {0 #1 [[..prelude "#None"] + {0 #1 [[..prelude "#Some"] + {0 #0}]}]}) #0) -(.def# #None ("lux type as" Tag [("lux type check" Label' {0 #1 [0 #0 ..maybe_tags]}) Maybe]) #1) -(.def# #Some ("lux type as" Tag [("lux type check" Label' {0 #1 [0 #1 ..maybe_tags]}) Maybe]) #1) +(.def# #None (.as# Tag [(.is# Label' {0 #1 [0 #0 ..maybe_tags]}) Maybe]) #1) +(.def# #Some (.as# Tag [(.is# Label' {0 #1 [0 #1 ..maybe_tags]}) Maybe]) #1) ... (type .public Type ... (Rec Type @@ -186,7 +184,7 @@ ... {#Apply Type Type} ... {#Named Symbol Type}))) (.def# Type - ("lux type check type" + (.is_type# {9 #1 [..prelude "Type"] ({Type ({Type_List @@ -227,59 +225,55 @@ Type_Pair ... Named {2 #0 Symbol 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}}))}) + (.is_type# {2 #0 Type Type}))} + (.is_type# {9 #0 Type List}))} + (.is_type# {9 #0 {0 #0 ["" {#End}]} {4 #0 0}}))}) #1) (.def# type_tags - ("lux type check" - {9 #0 Symbol List} - {0 #1 [[..prelude "#Primitive"] - {0 #1 [[..prelude "#Sum"] - {0 #1 [[..prelude "#Product"] - {0 #1 [[..prelude "#Function"] - {0 #1 [[..prelude "#Parameter"] - {0 #1 [[..prelude "#Var"] - {0 #1 [[..prelude "#Ex"] - {0 #1 [[..prelude "#UnivQ"] - {0 #1 [[..prelude "#ExQ"] - {0 #1 [[..prelude "#Apply"] - {0 #1 [[..prelude "#Named"] - {0 #0}]}]}]}]}]}]}]}]}]}]}]}) + (.is# {9 #0 Symbol List} + {0 #1 [[..prelude "#Primitive"] + {0 #1 [[..prelude "#Sum"] + {0 #1 [[..prelude "#Product"] + {0 #1 [[..prelude "#Function"] + {0 #1 [[..prelude "#Parameter"] + {0 #1 [[..prelude "#Var"] + {0 #1 [[..prelude "#Ex"] + {0 #1 [[..prelude "#UnivQ"] + {0 #1 [[..prelude "#ExQ"] + {0 #1 [[..prelude "#Apply"] + {0 #1 [[..prelude "#Named"] + {0 #0}]}]}]}]}]}]}]}]}]}]}]}) #0) -(.def# #Primitive ("lux type as" Tag [("lux type check" Label' {#Some [0 #0 ..type_tags]}) Type]) #1) -(.def# #Sum ("lux type as" Tag [("lux type check" Label' {#Some [1 #0 ..type_tags]}) Type]) #1) -(.def# #Product ("lux type as" Tag [("lux type check" Label' {#Some [2 #0 ..type_tags]}) Type]) #1) -(.def# #Function ("lux type as" Tag [("lux type check" Label' {#Some [3 #0 ..type_tags]}) Type]) #1) -(.def# #Parameter ("lux type as" Tag [("lux type check" Label' {#Some [4 #0 ..type_tags]}) Type]) #1) -(.def# #Var ("lux type as" Tag [("lux type check" Label' {#Some [5 #0 ..type_tags]}) Type]) #1) -(.def# #Ex ("lux type as" Tag [("lux type check" Label' {#Some [6 #0 ..type_tags]}) Type]) #1) -(.def# #UnivQ ("lux type as" Tag [("lux type check" Label' {#Some [7 #0 ..type_tags]}) Type]) #1) -(.def# #ExQ ("lux type as" Tag [("lux type check" Label' {#Some [8 #0 ..type_tags]}) Type]) #1) -(.def# #Apply ("lux type as" Tag [("lux type check" Label' {#Some [9 #0 ..type_tags]}) Type]) #1) -(.def# #Named ("lux type as" Tag [("lux type check" Label' {#Some [9 #1 ..type_tags]}) Type]) #1) +(.def# #Primitive (.as# Tag [(.is# Label' {#Some [0 #0 ..type_tags]}) Type]) #1) +(.def# #Sum (.as# Tag [(.is# Label' {#Some [1 #0 ..type_tags]}) Type]) #1) +(.def# #Product (.as# Tag [(.is# Label' {#Some [2 #0 ..type_tags]}) Type]) #1) +(.def# #Function (.as# Tag [(.is# Label' {#Some [3 #0 ..type_tags]}) Type]) #1) +(.def# #Parameter (.as# Tag [(.is# Label' {#Some [4 #0 ..type_tags]}) Type]) #1) +(.def# #Var (.as# Tag [(.is# Label' {#Some [5 #0 ..type_tags]}) Type]) #1) +(.def# #Ex (.as# Tag [(.is# Label' {#Some [6 #0 ..type_tags]}) Type]) #1) +(.def# #UnivQ (.as# Tag [(.is# Label' {#Some [7 #0 ..type_tags]}) Type]) #1) +(.def# #ExQ (.as# Tag [(.is# Label' {#Some [8 #0 ..type_tags]}) Type]) #1) +(.def# #Apply (.as# Tag [(.is# Label' {#Some [9 #0 ..type_tags]}) Type]) #1) +(.def# #Named (.as# Tag [(.is# Label' {#Some [9 #1 ..type_tags]}) Type]) #1) ... (type .public Label ... [(Maybe [Nat Bit (List Symbol)]) Type]) (.def# Label - ("lux type check" - Type - {#Named [..prelude "Label"] - {#Product {#Apply {#Product Nat {#Product Bit {#Apply Symbol List}}} Maybe} - Type}}) + (.is# Type + {#Named [..prelude "Label"] + {#Product {#Apply {#Product Nat {#Product Bit {#Apply Symbol List}}} Maybe} + Type}}) #1) (.def# tag - ("lux type check" - {#Function Label Tag} - ([_ it] ("lux type as" Tag it))) + (.is# {#Function Label Tag} + ([_ it] (.as# Tag it))) #0) (.def# slot - ("lux type check" - {#Function Label Slot} - ([_ it] ("lux type as" Slot it))) + (.is# {#Function Label Slot} + ([_ it] (.as# Slot it))) #0) ... (type .public Location @@ -288,18 +282,16 @@ ... #line Nat ... #column Nat])) (.def# Location - ("lux type check" - Type - {#Named [..prelude "Location"] - {#Product Text {#Product Nat Nat}}}) + (.is# Type + {#Named [..prelude "Location"] + {#Product Text {#Product Nat Nat}}}) #1) (.def# location_slots - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#module"] - {#Item [..prelude "#line"] - {#Item [..prelude "#column"] - {#End}}}}) + (.is# {#Apply Symbol List} + {#Item [..prelude "#module"] + {#Item [..prelude "#line"] + {#Item [..prelude "#column"] + {#End}}}}) #0) (.def# #module (slot [{#Some [0 #0 ..location_slots]} Location]) #1) (.def# #line (slot [{#Some [1 #0 ..location_slots]} Location]) #1) @@ -310,21 +302,19 @@ ... [#meta m ... #datum v])) (.def# Ann - ("lux type check" - Type - {#Named [..prelude "Ann"] - {#UnivQ {#End} - {#UnivQ {#End} - {#Product - {#Parameter 3} - {#Parameter 1}}}}}) + (.is# Type + {#Named [..prelude "Ann"] + {#UnivQ {#End} + {#UnivQ {#End} + {#Product + {#Parameter 3} + {#Parameter 1}}}}}) #1) (.def# ann_slots - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#meta"] - {#Item [..prelude "#datum"] - {#End}}}) + (.is# {#Apply Symbol List} + {#Item [..prelude "#meta"] + {#Item [..prelude "#datum"] + {#End}}}) #0) (.def# #meta (slot [{#Some [0 #0 ..ann_slots]} Ann]) #1) (.def# #datum (slot [{#Some [0 #1 ..ann_slots]} Ann]) #1) @@ -342,66 +332,62 @@ ... {#Variant (List (w (Code' w)))} ... {#Tuple (List (w (Code' w)))})) (.def# Code' - ("lux type check" - Type - {#Named [..prelude "Code'"] - ({Code - ({Code_List - {#UnivQ {#End} - {#Sum - ... Bit - Bit - {#Sum - ... Nat - Nat - {#Sum - ... Int - Int - {#Sum - ... Rev - Rev - {#Sum - ... Frac - Frac + (.is# Type + {#Named [..prelude "Code'"] + ({Code + ({Code_List + {#UnivQ {#End} {#Sum - ... Text - Text + ... Bit + Bit {#Sum - ... Symbol - Symbol + ... Nat + Nat {#Sum - ... Form - Code_List + ... Int + Int {#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}}))}) + ... Rev + Rev + {#Sum + ... Frac + Frac + {#Sum + ... Text + Text + {#Sum + ... Symbol + Symbol + {#Sum + ... Form + Code_List + {#Sum + ... Variant + Code_List + ... Tuple + Code_List + }}}}}}}}} + }} + (.is# Type + {#Apply Code List}))} + (.is# Type + {#Apply {#Apply {#Parameter 1} + {#Parameter 0}} + {#Parameter 1}}))}) #1) (.def# code'_tags - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#Bit"] - {#Item [..prelude "#Nat"] - {#Item [..prelude "#Int"] - {#Item [..prelude "#Rev"] - {#Item [..prelude "#Frac"] - {#Item [..prelude "#Text"] - {#Item [..prelude "#Symbol"] - {#Item [..prelude "#Form"] - {#Item [..prelude "#Variant"] - {#Item [..prelude "#Tuple"] - {#End}}}}}}}}}}}) + (.is# {#Apply Symbol List} + {#Item [..prelude "#Bit"] + {#Item [..prelude "#Nat"] + {#Item [..prelude "#Int"] + {#Item [..prelude "#Rev"] + {#Item [..prelude "#Frac"] + {#Item [..prelude "#Text"] + {#Item [..prelude "#Symbol"] + {#Item [..prelude "#Form"] + {#Item [..prelude "#Variant"] + {#Item [..prelude "#Tuple"] + {#End}}}}}}}}}}}) #0) (.def# #Bit (tag [{#Some [0 #0 ..code'_tags]} Code']) #1) (.def# #Nat (tag [{#Some [1 #0 ..code'_tags]} Code']) #1) @@ -417,12 +403,11 @@ ... (type .public Code ... (Ann Location (Code' (Ann Location)))) (.def# Code - ("lux type check" - Type - {#Named [..prelude "Code"] - ({w - {#Apply {#Apply w Code'} w}} - ("lux type check" Type {#Apply Location Ann}))}) + (.is# Type + {#Named [..prelude "Code"] + ({w + {#Apply {#Apply w Code'} w}} + (.is# Type {#Apply Location Ann}))}) #1) (.def# private @@ -442,104 +427,89 @@ #1) (.def# _ann - ("lux type check" - {#Function {#Apply {#Apply Location Ann} Code'} - Code} - ([_ data] - [dummy_location data])) + (.is# {#Function {#Apply {#Apply Location Ann} Code'} + Code} + ([_ data] + [dummy_location data])) #0) (.def# bit$ - ("lux type check" - {#Function Bit Code} - ([_ value] (_ann {#Bit value}))) + (.is# {#Function Bit Code} + ([_ value] (_ann {#Bit value}))) #0) (.def# nat$ - ("lux type check" - {#Function Nat Code} - ([_ value] (_ann {#Nat value}))) + (.is# {#Function Nat Code} + ([_ value] (_ann {#Nat value}))) #0) (.def# int$ - ("lux type check" - {#Function Int Code} - ([_ value] (_ann {#Int value}))) + (.is# {#Function Int Code} + ([_ value] (_ann {#Int value}))) #0) (.def# rev$ - ("lux type check" - {#Function Rev Code} - ([_ value] (_ann {#Rev value}))) + (.is# {#Function Rev Code} + ([_ value] (_ann {#Rev value}))) #0) (.def# frac$ - ("lux type check" - {#Function Frac Code} - ([_ value] (_ann {#Frac value}))) + (.is# {#Function Frac Code} + ([_ value] (_ann {#Frac value}))) #0) (.def# text$ - ("lux type check" - {#Function Text Code} - ([_ text] (_ann {#Text text}))) + (.is# {#Function Text Code} + ([_ text] (_ann {#Text text}))) #0) (.def# symbol$ - ("lux type check" - {#Function Symbol Code} - ([_ name] (_ann {#Symbol name}))) + (.is# {#Function Symbol Code} + ([_ name] (_ann {#Symbol name}))) #0) (.def# local$ - ("lux type check" - {#Function Text Code} - ([_ name] (_ann {#Symbol ["" name]}))) + (.is# {#Function Text Code} + ([_ name] (_ann {#Symbol ["" name]}))) #0) (.def# form$ - ("lux type check" - {#Function {#Apply Code List} Code} - ([_ tokens] (_ann {#Form tokens}))) + (.is# {#Function {#Apply Code List} Code} + ([_ tokens] (_ann {#Form tokens}))) #0) (.def# variant$ - ("lux type check" - {#Function {#Apply Code List} Code} - ([_ tokens] (_ann {#Variant tokens}))) + (.is# {#Function {#Apply Code List} Code} + ([_ tokens] (_ann {#Variant tokens}))) #0) (.def# tuple$ - ("lux type check" - {#Function {#Apply Code List} Code} - ([_ tokens] (_ann {#Tuple tokens}))) + (.is# {#Function {#Apply Code List} Code} + ([_ tokens] (_ann {#Tuple tokens}))) #0) ... (type .public Definition ... [Bit Type Any]) (.def# Definition - ("lux type check" - Type - {#Named [..prelude "Definition"] - {#Product Bit {#Product Type Any}}}) + (.is# Type + {#Named [..prelude "Definition"] + {#Product Bit {#Product Type Any}}}) .public) ... (type .public Default ... Definition) (.def# Default - ("lux type check" - Type - {#Named [..prelude "Default"] - Definition}) + (.is# Type + {#Named [..prelude "Default"] + Definition}) .public) ... (type .public Alias ... Symbol) (.def# Alias - ("lux type check" - Type - {#Named [..prelude "Alias"] - Symbol}) + (.is# Type + {#Named [..prelude "Alias"] + Symbol}) .public) ... (type .public Global @@ -548,21 +518,19 @@ ... {#Alias Alias} ... {#Default Default})) (.def# Global - ("lux type check" - Type - {#Named [..prelude "Global"] - {#Sum Definition - {#Sum Alias - Default}}}) + (.is# Type + {#Named [..prelude "Global"] + {#Sum Definition + {#Sum Alias + Default}}}) .public) (.def# global_tags - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#Definition"] - {#Item [..prelude "#Alias"] - {#Item [..prelude "#Default"] - {#End}}}}) + (.is# {#Apply Symbol List} + {#Item [..prelude "#Definition"] + {#Item [..prelude "#Alias"] + {#Item [..prelude "#Default"] + {#End}}}}) #0) (.def# #Definition (tag [{#Some [0 #0 ..global_tags]} Global]) .public) (.def# #Alias (tag [{#Some [1 #0 ..global_tags]} Global]) .public) @@ -573,26 +541,24 @@ ... [#counter Nat ... #mappings (List [k v])])) (.def# Bindings - ("lux type check" - Type - {#Named [..prelude "Bindings"] - {#UnivQ {#End} - {#UnivQ {#End} - {#Product - ... counter - Nat - ... mappings - {#Apply {#Product {#Parameter 3} - {#Parameter 1}} - List}}}}}) + (.is# Type + {#Named [..prelude "Bindings"] + {#UnivQ {#End} + {#UnivQ {#End} + {#Product + ... counter + Nat + ... mappings + {#Apply {#Product {#Parameter 3} + {#Parameter 1}} + List}}}}}) .public) (.def# bindings_slots - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#counter"] - {#Item [..prelude "#mappings"] - {#End}}}) + (.is# {#Apply Symbol List} + {#Item [..prelude "#counter"] + {#Item [..prelude "#mappings"] + {#End}}}) #0) (.def# #counter (slot [{#Some [0 #0 ..bindings_slots]} Bindings]) .public) (.def# #mappings (slot [{#Some [0 #1 ..bindings_slots]} Bindings]) .public) @@ -601,22 +567,20 @@ ... {#Local Nat} ... {#Captured Nat}) (.def# Ref - ("lux type check" - Type - {#Named [..prelude "Ref"] - {#Sum - ... Local - Nat - ... Captured - Nat}}) + (.is# Type + {#Named [..prelude "Ref"] + {#Sum + ... Local + Nat + ... Captured + Nat}}) .public) (.def# ref_tags - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#Local"] - {#Item [..prelude "#Captured"] - {#End}}}) + (.is# {#Apply Symbol List} + {#Item [..prelude "#Local"] + {#Item [..prelude "#Captured"] + {#End}}}) #0) (.def# #Local (tag [{#Some [0 #0 ..ref_tags]} Ref]) .public) (.def# #Captured (tag [{#Some [0 #1 ..ref_tags]} Ref]) .public) @@ -629,30 +593,28 @@ ... #locals (Bindings Text [Type Nat]) ... #captured (Bindings Text [Type Ref])])) (.def# Scope - ("lux type check" - Type - {#Named [..prelude "Scope"] - {#Product - ... name - {#Apply Text List} - {#Product - ... inner - Nat - {#Product - ... locals - {#Apply {#Product Type Nat} {#Apply Text Bindings}} - ... captured - {#Apply {#Product Type Ref} {#Apply Text Bindings}}}}}}) + (.is# Type + {#Named [..prelude "Scope"] + {#Product + ... name + {#Apply Text List} + {#Product + ... inner + Nat + {#Product + ... locals + {#Apply {#Product Type Nat} {#Apply Text Bindings}} + ... captured + {#Apply {#Product Type Ref} {#Apply Text Bindings}}}}}}) .public) (.def# scope_slots - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#scope_name"] - {#Item [..prelude "#inner_scopes"] - {#Item [..prelude "#locals"] - {#Item [..prelude "#captured"] - {#End}}}}}) + (.is# {#Apply Symbol List} + {#Item [..prelude "#scope_name"] + {#Item [..prelude "#inner_scopes"] + {#Item [..prelude "#locals"] + {#Item [..prelude "#captured"] + {#End}}}}}) #0) (.def# #scope_name (slot [{#Some [0 #0 ..scope_slots]} Scope]) .public) (.def# #inner_scopes (slot [{#Some [1 #0 ..scope_slots]} Scope]) .public) @@ -660,9 +622,8 @@ (.def# #captured (slot [{#Some [2 #1 ..scope_slots]} Scope]) .public) (.def# Code_List - ("lux type check" - Type - {#Apply Code List}) + (.is# Type + {#Apply Code List}) #0) ... (type .public (Either l r) @@ -670,24 +631,22 @@ ... {#Left l} ... {#Right r})) (.def# Either - ("lux type check" - Type - {#Named [..prelude "Either"] - {#UnivQ {#End} - {#UnivQ {#End} - {#Sum - ... Left - {#Parameter 3} - ... Right - {#Parameter 1}}}}}) + (.is# Type + {#Named [..prelude "Either"] + {#UnivQ {#End} + {#UnivQ {#End} + {#Sum + ... Left + {#Parameter 3} + ... Right + {#Parameter 1}}}}}) .public) (.def# either_tags - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#Left"] - {#Item [..prelude "#Right"] - {#End}}}) + (.is# {#Apply Symbol List} + {#Item [..prelude "#Left"] + {#Item [..prelude "#Right"] + {#End}}}) #0) (.def# #Left (tag [{#Some [0 #0 ..either_tags]} Either]) .public) (.def# #Right (tag [{#Some [0 #1 ..either_tags]} Either]) .public) @@ -695,10 +654,9 @@ ... (type .public Source ... [Location Nat Text]) (.def# Source - ("lux type check" - Type - {#Named [..prelude "Source"] - {#Product Location {#Product Nat Text}}}) + (.is# Type + {#Named [..prelude "Source"] + {#Product Location {#Product Nat Text}}}) .public) ... (type .public Module_State @@ -707,26 +665,24 @@ ... #Compiled ... #Cached)) (.def# Module_State - ("lux type check" - Type - {#Named [..prelude "Module_State"] - {#Sum - ... #Active - Any - {#Sum - ... #Compiled - Any - ... #Cached - Any}}}) + (.is# Type + {#Named [..prelude "Module_State"] + {#Sum + ... #Active + Any + {#Sum + ... #Compiled + Any + ... #Cached + Any}}}) .public) (.def# module_state_tags - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#Active"] - {#Item [..prelude "#Compiled"] - {#Item [..prelude "#Cached"] - {#End}}}}) + (.is# {#Apply Symbol List} + {#Item [..prelude "#Active"] + {#Item [..prelude "#Compiled"] + {#Item [..prelude "#Cached"] + {#End}}}}) #0) (.def# #Active (tag [{#Some [0 #0 ..module_state_tags]} Module_State]) .public) (.def# #Compiled (tag [{#Some [1 #0 ..module_state_tags]} Module_State]) .public) @@ -740,35 +696,33 @@ ... #imports (List Text) ... #module_state Module_State])) (.def# Module - ("lux type check" - Type - {#Named [..prelude "Module"] - {#Product - ... module_hash - Nat - {#Product - ... module_aliases - {#Apply {#Product Text Text} List} - {#Product - ... definitions - {#Apply {#Product Text Global} List} - {#Product - ... imports - {#Apply Text List} - ... module_state - Module_State - }}}}}) + (.is# Type + {#Named [..prelude "Module"] + {#Product + ... module_hash + Nat + {#Product + ... module_aliases + {#Apply {#Product Text Text} List} + {#Product + ... definitions + {#Apply {#Product Text Global} List} + {#Product + ... imports + {#Apply Text List} + ... module_state + Module_State + }}}}}) .public) (.def# module_slots - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#module_hash"] - {#Item [..prelude "#module_aliases"] - {#Item [..prelude "#definitions"] - {#Item [..prelude "#imports"] - {#Item [..prelude "#module_state"] - {#End}}}}}}) + (.is# {#Apply Symbol List} + {#Item [..prelude "#module_hash"] + {#Item [..prelude "#module_aliases"] + {#Item [..prelude "#definitions"] + {#Item [..prelude "#imports"] + {#Item [..prelude "#module_state"] + {#End}}}}}}) #0) (.def# #module_hash (slot [{#Some [0 #0 ..module_slots]} Module]) .public) (.def# #module_aliases (slot [{#Some [1 #0 ..module_slots]} Module]) .public) @@ -782,25 +736,23 @@ ... #var_counter Nat ... #var_bindings (List [Nat (Maybe Type)])])) (.def# Type_Context - ("lux type check" - Type - {#Named [..prelude "Type_Context"] - {#Product ... ex_counter - Nat - {#Product ... var_counter - Nat - ... var_bindings - {#Apply {#Product Nat {#Apply Type Maybe}} - List}}}}) + (.is# Type + {#Named [..prelude "Type_Context"] + {#Product ... ex_counter + Nat + {#Product ... var_counter + Nat + ... var_bindings + {#Apply {#Product Nat {#Apply Type Maybe}} + List}}}}) .public) (.def# type_context_slots - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#ex_counter"] - {#Item [..prelude "#var_counter"] - {#Item [..prelude "#var_bindings"] - {#End}}}}) + (.is# {#Apply Symbol List} + {#Item [..prelude "#ex_counter"] + {#Item [..prelude "#var_counter"] + {#Item [..prelude "#var_bindings"] + {#End}}}}) #0) (.def# #ex_counter (slot [{#Some [0 #0 ..type_context_slots]} Type_Context]) .public) (.def# #var_counter (slot [{#Some [1 #0 ..type_context_slots]} Type_Context]) .public) @@ -812,26 +764,24 @@ ... {#Eval} ... {#Interpreter})) (.def# Mode - ("lux type check" - Type - {#Named [..prelude "Mode"] - {#Sum - ... Build - Any - {#Sum - ... Eval - Any - ... Interpreter - Any}}}) + (.is# Type + {#Named [..prelude "Mode"] + {#Sum + ... Build + Any + {#Sum + ... Eval + Any + ... Interpreter + Any}}}) .public) (.def# mode_tags - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#Build"] - {#Item [..prelude "#Eval"] - {#Item [..prelude "#Interpreter"] - {#End}}}}) + (.is# {#Apply Symbol List} + {#Item [..prelude "#Build"] + {#Item [..prelude "#Eval"] + {#Item [..prelude "#Interpreter"] + {#End}}}}) #0) (.def# #Build (tag [{#Some [0 #0 ..mode_tags]} Mode]) .public) (.def# #Eval (tag [{#Some [1 #0 ..mode_tags]} Mode]) .public) @@ -844,30 +794,28 @@ ... #mode Mode ... #configuration (List [Text Text])])) (.def# Info - ("lux type check" - Type - {#Named [..prelude "Info"] - {#Product - ... target - Text - {#Product - ... version - Text - {#Product - ... mode - Mode - ... configuration - {#Apply {#Product Text Text} List}}}}}) + (.is# Type + {#Named [..prelude "Info"] + {#Product + ... target + Text + {#Product + ... version + Text + {#Product + ... mode + Mode + ... configuration + {#Apply {#Product Text Text} List}}}}}) .public) (.def# info_slots - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#target"] - {#Item [..prelude "#version"] - {#Item [..prelude "#mode"] - {#Item [..prelude "#configuration"] - {#End}}}}}) + (.is# {#Apply Symbol List} + {#Item [..prelude "#target"] + {#Item [..prelude "#version"] + {#Item [..prelude "#mode"] + {#Item [..prelude "#configuration"] + {#End}}}}}) #0) (.def# #target (slot [{#Some [0 #0 ..info_slots]} Info]) .public) (.def# #version (slot [{#Some [1 #0 ..info_slots]} Info]) .public) @@ -891,73 +839,71 @@ ... #eval (-> Type Code (-> Lux (Either Text [Lux Any]))) ... #host Any]))) (.def# Lux - ("lux type check" - Type - {#Named [..prelude "Lux"] - ({Lux - {#Apply {0 #0 ["" {#End}]} - {#UnivQ {#End} - {#Product - ... info - Info - {#Product - ... source - Source - {#Product - ... location - Location - {#Product - ... current_module - {#Apply Text Maybe} - {#Product - ... modules - {#Apply {#Product Text Module} List} + (.is# Type + {#Named [..prelude "Lux"] + ({Lux + {#Apply {0 #0 ["" {#End}]} + {#UnivQ {#End} {#Product - ... scopes - {#Apply Scope List} + ... info + Info {#Product - ... type_context - Type_Context + ... source + Source {#Product - ... expected - {#Apply Type Maybe} + ... location + Location {#Product - ... seed - Nat + ... current_module + {#Apply Text Maybe} {#Product - ... scope_type_vars - {#Apply Nat List} + ... modules + {#Apply {#Product Text Module} List} {#Product - ... extensions - Any + ... scopes + {#Apply Scope List} {#Product - ... eval - {#Function Type - {#Function Code - {#Function Lux - {#Sum Text {#Product Lux Any}}}}} - ... host - Any}}}}}}}}}}}}}}} - {#Apply {0 #0 ["" {#End}]} {#Parameter 0}})}) + ... type_context + Type_Context + {#Product + ... expected + {#Apply Type Maybe} + {#Product + ... seed + Nat + {#Product + ... scope_type_vars + {#Apply Nat List} + {#Product + ... extensions + Any + {#Product + ... eval + {#Function Type + {#Function Code + {#Function Lux + {#Sum Text {#Product Lux Any}}}}} + ... host + Any}}}}}}}}}}}}}}} + {#Apply {0 #0 ["" {#End}]} {#Parameter 0}})}) .public) (.def# lux_slots - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#info"] - {#Item [..prelude "#source"] - {#Item [..prelude "#location"] - {#Item [..prelude "#current_module"] - {#Item [..prelude "#modules"] - {#Item [..prelude "#scopes"] - {#Item [..prelude "#type_context"] - {#Item [..prelude "#expected"] - {#Item [..prelude "#seed"] - {#Item [..prelude "#scope_type_vars"] - {#Item [..prelude "#extensions"] - {#Item [..prelude "#eval"] - {#Item [..prelude "#host"] - {#End}}}}}}}}}}}}}}) + (.is# {#Apply Symbol List} + {#Item [..prelude "#info"] + {#Item [..prelude "#source"] + {#Item [..prelude "#location"] + {#Item [..prelude "#current_module"] + {#Item [..prelude "#modules"] + {#Item [..prelude "#scopes"] + {#Item [..prelude "#type_context"] + {#Item [..prelude "#expected"] + {#Item [..prelude "#seed"] + {#Item [..prelude "#scope_type_vars"] + {#Item [..prelude "#extensions"] + {#Item [..prelude "#eval"] + {#Item [..prelude "#host"] + {#End}}}}}}}}}}}}}}) #0) (.def# #info (slot [{#Some [0 #0 ..lux_slots]} Lux]) .public) (.def# #source (slot [{#Some [1 #0 ..lux_slots]} Lux]) .public) @@ -976,210 +922,197 @@ ... (type .public (Meta a) ... (-> Lux (Either Text [Lux a]))) (.def# Meta - ("lux type check" - Type - {#Named [..prelude "Meta"] - {#UnivQ {#End} - {#Function Lux - {#Apply {#Product Lux {#Parameter 1}} - {#Apply Text Either}}}}}) + (.is# Type + {#Named [..prelude "Meta"] + {#UnivQ {#End} + {#Function Lux + {#Apply {#Product Lux {#Parameter 1}} + {#Apply Text Either}}}}}) .public) ... (type .public Macro' ... (-> (List Code) (Meta (List Code)))) (.def# Macro' - ("lux type check" - Type - {#Named [..prelude "Macro'"] - {#Function Code_List {#Apply Code_List Meta}}}) + (.is# Type + {#Named [..prelude "Macro'"] + {#Function Code_List {#Apply Code_List Meta}}}) .public) ... (type .public Macro ... (Primitive "#Macro")) (.def# Macro - ("lux type check" - Type - {#Named [..prelude "Macro"] - {#Primitive "#Macro" {#End}}}) + (.is# Type + {#Named [..prelude "Macro"] + {#Primitive "#Macro" {#End}}}) .public) ... Base functions & macros (.def# meta#in - ("lux type check" - {#UnivQ {#End} {#Function {#Parameter 1} {#Apply {#Parameter 1} Meta}}} - ([_ val] - ([_ state] - {#Right [state val]}))) + (.is# {#UnivQ {#End} {#Function {#Parameter 1} {#Apply {#Parameter 1} Meta}}} + ([_ val] + ([_ state] + {#Right [state val]}))) #0) (.def# failure - ("lux type check" - {#UnivQ {#End} {#Function Text {#Apply {#Parameter 1} Meta}}} - ([_ msg] - ([_ state] - {#Left msg}))) + (.is# {#UnivQ {#End} {#Function Text {#Apply {#Parameter 1} Meta}}} + ([_ msg] + ([_ state] + {#Left msg}))) #0) (.def# text#composite - ("lux type check" - {#Function Text {#Function Text Text}} - ([_ x] - ([_ y] - ("lux text concat" x y)))) + (.is# {#Function Text {#Function Text Text}} + ([_ x] + ([_ y] + (.text_composite# x y)))) #0) (.def# symbol_separator - ("lux type check" - Text - ".") + (.is# Text + ".") #0) (.def# symbol#encoded - ("lux type check" - {#Function Symbol Text} - ([_ full_name] - ({[module name] - ({"" name - _ (text#composite module (text#composite ..symbol_separator name))} - module)} - full_name))) + (.is# {#Function Symbol Text} + ([_ full_name] + ({[module name] + ({"" name + _ (text#composite module (text#composite ..symbol_separator name))} + module)} + full_name))) #0) ... TODO: Allow asking the compiler for the name of the definition ... currently being defined. That name can then be fed into ... 'wrong_syntax_error' for easier maintenance of the error_messages. (.def# wrong_syntax_error - ("lux type check" - {#Function Symbol Text} - ([_ it] - (text#composite "Wrong syntax for " (symbol#encoded it)))) + (.is# {#Function Symbol Text} + ([_ it] + (text#composite "Wrong syntax for " (symbol#encoded it)))) #0) (.def# let'' - ("lux type as" Macro - ("lux type check" Macro' - ([_ tokens] - ({{#Item lhs {#Item rhs {#Item body {#End}}}} - (meta#in {#Item (form$ {#Item (variant$ {#Item lhs {#Item body {#End}}}) - {#Item rhs {#End}}}) - {#End}}) - - _ - (failure "Wrong syntax for let''")} - tokens)))) + (.as# Macro + (.is# Macro' + ([_ tokens] + ({{#Item lhs {#Item rhs {#Item body {#End}}}} + (meta#in {#Item (form$ {#Item (variant$ {#Item lhs {#Item body {#End}}}) + {#Item rhs {#End}}}) + {#End}}) + + _ + (failure "Wrong syntax for let''")} + tokens)))) #0) (.def# function'' - ("lux type as" Macro - ("lux type check" Macro' - ([_ tokens] - ({{#Item [_ {#Tuple {#Item arg args'}}] {#Item body {#End}}} - (meta#in {#Item (_ann {#Form {#Item (_ann {#Tuple {#Item (_ann {#Symbol ["" ""]}) - {#Item arg {#End}}}}) - {#Item ({{#End} - body - - _ - (_ann {#Form {#Item (_ann {#Symbol [..prelude "function''"]}) - {#Item (_ann {#Tuple args'}) - {#Item body {#End}}}}})} - args') - {#End}}}}) - {#End}}) - - {#Item [_ {#Symbol ["" self]}] {#Item [_ {#Tuple {#Item arg args'}}] {#Item body {#End}}}} - (meta#in {#Item (_ann {#Form {#Item (_ann {#Tuple {#Item (_ann {#Symbol ["" self]}) - {#Item arg {#End}}}}) - {#Item ({{#End} - body - - _ - (_ann {#Form {#Item (_ann {#Symbol [..prelude "function''"]}) - {#Item (_ann {#Tuple args'}) - {#Item body {#End}}}}})} - args') - {#End}}}}) - {#End}}) - - _ - (failure "Wrong syntax for function''")} - tokens)))) + (.as# Macro + (.is# Macro' + ([_ tokens] + ({{#Item [_ {#Tuple {#Item arg args'}}] {#Item body {#End}}} + (meta#in {#Item (_ann {#Form {#Item (_ann {#Tuple {#Item (_ann {#Symbol ["" ""]}) + {#Item arg {#End}}}}) + {#Item ({{#End} + body + + _ + (_ann {#Form {#Item (_ann {#Symbol [..prelude "function''"]}) + {#Item (_ann {#Tuple args'}) + {#Item body {#End}}}}})} + args') + {#End}}}}) + {#End}}) + + {#Item [_ {#Symbol ["" self]}] {#Item [_ {#Tuple {#Item arg args'}}] {#Item body {#End}}}} + (meta#in {#Item (_ann {#Form {#Item (_ann {#Tuple {#Item (_ann {#Symbol ["" self]}) + {#Item arg {#End}}}}) + {#Item ({{#End} + body + + _ + (_ann {#Form {#Item (_ann {#Symbol [..prelude "function''"]}) + {#Item (_ann {#Tuple args'}) + {#Item body {#End}}}}})} + args') + {#End}}}}) + {#End}}) + + _ + (failure "Wrong syntax for function''")} + tokens)))) #0) (.def# as_def - ("lux type check" - {#Function Code {#Function Code {#Function Code Code}}} - (function'' [name value export_policy] - (form$ {#Item (symbol$ [..prelude "def#"]) {#Item name {#Item value {#Item export_policy {#End}}}}}))) + (.is# {#Function Code {#Function Code {#Function Code Code}}} + (function'' [name value export_policy] + (form$ {#Item (symbol$ [..prelude "def#"]) {#Item name {#Item value {#Item export_policy {#End}}}}}))) #0) (.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}}}}))) + (.is# {#Function Code {#Function Code Code}} + (function'' [type value] + (form$ {#Item (symbol$ [..prelude "is#"]) {#Item type {#Item value {#End}}}}))) #0) (.def# as_function - ("lux type check" - {#Function Code {#Function {#Apply Code List} {#Function Code Code}}} - (function'' as_function [self inputs output] - ({{#End} - output - - {#Item head tail} - (_ann {#Form {#Item (_ann {#Tuple {#Item self {#Item head {#End}}}}) - {#Item (as_function (_ann {#Symbol ["" ""]}) tail output) - {#End}}}})} - inputs))) + (.is# {#Function Code {#Function {#Apply Code List} {#Function Code Code}}} + (function'' as_function [self inputs output] + ({{#End} + output + + {#Item head tail} + (_ann {#Form {#Item (_ann {#Tuple {#Item self {#Item head {#End}}}}) + {#Item (as_function (_ann {#Symbol ["" ""]}) tail output) + {#End}}}})} + inputs))) #0) (.def# as_macro - ("lux type check" - {#Function Code Code} - (function'' [expression] - (form$ {#Item (text$ "lux type as") - {#Item (symbol$ [..prelude "Macro"]) - {#Item (form$ {#Item (text$ "lux type check") - {#Item (symbol$ [..prelude "Macro'"]) - {#Item expression - {#End}}}}) - {#End}}}}))) + (.is# {#Function Code Code} + (function'' [expression] + (form$ {#Item (symbol$ [..prelude "as#"]) + {#Item (symbol$ [..prelude "Macro"]) + {#Item (form$ {#Item (symbol$ [..prelude "is#"]) + {#Item (symbol$ [..prelude "Macro'"]) + {#Item expression + {#End}}}}) + {#End}}}}))) #0) (.def# def' - ("lux type as" Macro - ("lux type check" Macro' - (function'' [tokens] - ({{#Item [export_policy - {#Item [[_ {#Form {#Item [name args]}}] - {#Item [type {#Item [body {#End}]}]}]}]} - (meta#in {#Item [(as_def name - (as_checked type (as_function name args body)) - export_policy) - {#End}]}) - - {#Item [export_policy {#Item [name {#Item [type {#Item [body {#End}]}]}]}]} - (meta#in {#Item [(as_def name (as_checked type body) - export_policy) - {#End}]}) - - _ - (failure "Wrong syntax for def'")} - tokens)))) + (.as# Macro + (.is# Macro' + (function'' [tokens] + ({{#Item [export_policy + {#Item [[_ {#Form {#Item [name args]}}] + {#Item [type {#Item [body {#End}]}]}]}]} + (meta#in {#Item [(as_def name + (as_checked type (as_function name args body)) + export_policy) + {#End}]}) + + {#Item [export_policy {#Item [name {#Item [type {#Item [body {#End}]}]}]}]} + (meta#in {#Item [(as_def name (as_checked type body) + export_policy) + {#End}]}) + + _ + (failure "Wrong syntax for def'")} + tokens)))) #0) (.def# macro - ("lux type as" Macro - ("lux type check" Macro' - (function'' [tokens] - ({{#Item [_ {#Form {#Item name {#Item head tail}}}] {#Item body {#End}}} - (meta#in {#Item (as_macro (as_function name {#Item head tail} body)) - {#End}}) - - _ - (failure (wrong_syntax_error [..prelude "macro"]))} - tokens)))) + (.as# Macro + (.is# Macro' + (function'' [tokens] + ({{#Item [_ {#Form {#Item name {#Item head tail}}}] {#Item body {#End}}} + (meta#in {#Item (as_macro (as_function name {#Item head tail} body)) + {#End}}) + + _ + (failure (wrong_syntax_error [..prelude "macro"]))} + tokens)))) #1) (def' .public comment @@ -1222,10 +1155,9 @@ (def' .private (list#reversed list) {#UnivQ {#End} {#Function ($ List {#Parameter 1}) ($ List {#Parameter 1})}} - (list#mix ("lux type check" - {#UnivQ {#End} - {#Function {#Parameter 1} {#Function ($ List {#Parameter 1}) ($ List {#Parameter 1})}}} - (function'' [head tail] {#Item head tail})) + (list#mix (.is# {#UnivQ {#End} + {#Function {#Parameter 1} {#Function ($ List {#Parameter 1}) ($ List {#Parameter 1})}}} + (function'' [head tail] {#Item head tail})) {#End} list)) @@ -1254,7 +1186,7 @@ (def' .private (text#= reference sample) {#Function Text {#Function Text Bit}} - ("lux text =" reference sample)) + (.text_=# reference sample)) (def' .private (replacement for environment) {#Function Text {#Function Replacement_Environment ($ Maybe Code)}} @@ -1292,15 +1224,14 @@ (def' .private (n/* param subject) {#Function Nat {#Function Nat Nat}} - ("lux type as" Nat - ("lux i64 *" - ("lux type as" Int param) - ("lux type as" Int subject)))) + (.as# Nat + (.int_*# (.as# Int param) + (.as# Int subject)))) (def' .private (list#size list) {#UnivQ {#End} {#Function ($ List {#Parameter 1}) Nat}} - (list#mix (function'' [_ acc] ("lux i64 +" 1 acc)) 0 list)) + (list#mix (function'' [_ acc] (.i64_+# 1 acc)) 0 list)) (def' .private (let$ binding value body) {#Function Code {#Function Code {#Function Code Code}}} @@ -1328,9 +1259,9 @@ (def' .private quantification_level Text - ("lux text concat" double_quote - ("lux text concat" "quantification_level" - double_quote))) + (.text_composite# double_quote + (.text_composite# "quantification_level" + double_quote))) (def' .private quantified {#Function Code Code} @@ -1339,7 +1270,7 @@ (def' .private (quantified_type_parameter idx) {#Function Nat Code} (variant$ {#Item (symbol$ [..prelude "#Parameter"]) - {#Item (form$ {#Item (text$ "lux i64 +") + {#Item (form$ {#Item (symbol$ [..prelude "i64_+#"]) {#Item (local$ ..quantification_level) {#Item (nat$ idx) {#End}}}}) @@ -1347,15 +1278,15 @@ (def' .private (next_level depth) {#Function Nat Nat} - ("lux i64 +" 2 depth)) + (.i64_+# 2 depth)) (def' .private (self_id? id) {#Function Nat Bit} - ("lux i64 =" id ("lux type as" Nat - ("lux i64 *" +2 - ("lux i64 /" +2 - ("lux type as" Int - id)))))) + (.i64_=# id (.as# Nat + (.int_*# +2 + (.int_/# +2 + (.as# Int + id)))))) (def' .public (__adjusted_quantified_type__ permission depth type) {#Function Nat {#Function Nat {#Function Type Type}}} @@ -1364,9 +1295,9 @@ {#Parameter id} ({id' ({[#0] {#Parameter id'} - [#1] {#Parameter ("lux i64 -" 2 id')}} + [#1] {#Parameter (.i64_-# 2 id')}} (self_id? id))} - ("lux i64 -" ("lux i64 -" depth id) 0)) + (.i64_-# (.i64_-# depth id) 0)) ... Recur {#Primitive name parameters} @@ -1419,12 +1350,12 @@ {#Function Nat {#Function Code Code}} ({g!level (let$ g!level - (form$ {#Item (text$ "lux i64 +") + (form$ {#Item (symbol$ [..prelude "i64_+#"]) {#Item g!level - {#Item (nat$ ("lux type as" Nat - ("lux i64 *" +2 - ("lux type as" Int - depth)))) + {#Item (nat$ (.as# Nat + (.int_*# +2 + (.as# Int + depth)))) {#End}}}}) body)} (local$ ..quantification_level))) @@ -1443,7 +1374,7 @@ (list#mix (function'' [local verdict] ({[local _] ({[#1] #1 - _ ("lux text =" ..quantification_level local)} + _ (.text_=# ..quantification_level local)} verdict)} local)) #0 @@ -1474,8 +1405,8 @@ raw} (list#mix (function'' [parameter offset,body'] ({[offset body'] - [("lux i64 +" 2 offset) - (let$ parameter (quantified_type_parameter ("lux i64 +" offset 1)) + [(.i64_+# 2 offset) + (let$ parameter (quantified_type_parameter (.i64_+# offset 1)) (UnivQ$ body'))]} offset,body')) [0 (with_quantification (list#size args) @@ -1508,8 +1439,8 @@ raw} (list#mix (function'' [parameter offset,body'] ({[offset body'] - [("lux i64 +" 2 offset) - (let$ parameter (quantified_type_parameter ("lux i64 +" offset 1)) + [(.i64_+# 2 offset) + (let$ parameter (quantified_type_parameter (.i64_+# offset 1)) (ExQ$ body'))]} offset,body')) [0 (with_quantification (list#size args) @@ -1526,9 +1457,8 @@ Macro (macro (_ tokens) ({{#Item output inputs} - (meta#in {#Item (list#mix ("lux type check" - {#Function Code {#Function Code Code}} - (function'' [i o] (variant$ {#Item (symbol$ [..prelude "#Function"]) {#Item i {#Item o {#End}}}}))) + (meta#in {#Item (list#mix (.is# {#Function Code {#Function Code Code}} + (function'' [i o] (variant$ {#Item (symbol$ [..prelude "#Function"]) {#Item i {#Item o {#End}}}}))) output inputs) {#End}}) @@ -1635,13 +1565,12 @@ (macro (_ tokens) ({{#Item [_ {#Tuple bindings}] {#Item body {#End}}} ({{#Some bindings} - (meta#in (list (list#mix ("lux type check" - (-> (Tuple Code Code) Code - Code) - (function' [binding body] - ({[label value] - (form$ (list (variant$ (list label body)) value))} - binding))) + (meta#in (list (list#mix (.is# (-> (Tuple Code Code) Code + Code) + (function' [binding body] + ({[label value] + (form$ (list (variant$ (list label body)) value))} + binding))) body (list#reversed bindings)))) @@ -1740,23 +1669,21 @@ ... (is (All (_ a b) (-> (-> a (m b)) (m a) (m b))) ... #then))) (.def# Monad - ("lux type check" - Type - {#Named [..prelude "Monad"] - (All (_ !) - (Tuple (All (_ a) - (-> a ($ ! a))) - (All (_ a b) - (-> (-> a ($ ! b)) - (-> ($ ! a) ($ ! b))))))}) + (.is# Type + {#Named [..prelude "Monad"] + (All (_ !) + (Tuple (All (_ a) + (-> a ($ ! a))) + (All (_ a b) + (-> (-> a ($ ! b)) + (-> ($ ! a) ($ ! b))))))}) #0) (.def# monad_slots - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#in"] - {#Item [..prelude "#then"] - {#End}}}) + (.is# {#Apply Symbol List} + {#Item [..prelude "#in"] + {#Item [..prelude "#then"] + {#End}}}) #0) (.def# #in (slot [{#Some [0 #0 ..monad_slots]} Monad]) .private) (.def# #then (slot [{#Some [0 #1 ..monad_slots]} Monad]) .private) @@ -1799,26 +1726,25 @@ ({{#Some bindings} (let' [g!in (local$ "in") g!then (local$ " then ") - body' (list#mix ("lux type check" - (-> (Tuple Code Code) Code Code) - (function' [binding body'] - (let' [[var value] binding] - ({[_ {#Symbol [module short]}] - ({"" - (form$ (list g!then - (form$ (list (tuple$ (list (local$ "") var)) body')) - value)) - - _ - (form$ (list var value body'))} - module) - - - _ - (form$ (list g!then - (form$ (list (tuple$ (list (local$ "") var)) body')) - value))} - var)))) + body' (list#mix (.is# (-> (Tuple Code Code) Code Code) + (function' [binding body'] + (let' [[var value] binding] + ({[_ {#Symbol [module short]}] + ({"" + (form$ (list g!then + (form$ (list (tuple$ (list (local$ "") var)) body')) + value)) + + _ + (form$ (list var value body'))} + module) + + + _ + (form$ (list g!then + (form$ (list (tuple$ (list (local$ "") var)) body')) + value))} + var)))) body (list#reversed bindings))] (meta#in (list (form$ (list (variant$ (list (tuple$ (list g!in g!then)) @@ -1939,7 +1865,7 @@ (let' [type (variant$ (list (symbol$ [..prelude "#Apply"]) (symbol$ [..prelude "Code"]) (symbol$ [..prelude "List"])))] - (form$ (list (text$ "lux type check") type expression)))) + (form$ (list (symbol$ [..prelude "is#"]) type expression)))) (def' .private (untemplated_text value) (-> Text Code) @@ -1953,11 +1879,11 @@ (def' .public (unquote it) (-> Macro UnQuote) - ("lux type as" UnQuote it)) + (.as# UnQuote it)) (def' .public (unquote_macro it) (-> UnQuote Macro') - ("lux type as" Macro' it)) + (.as# Macro' it)) (def' .public Spliced_UnQuote Type @@ -1966,11 +1892,11 @@ (def' .public (spliced_unquote it) (-> Macro Spliced_UnQuote) - ("lux type as" Spliced_UnQuote it)) + (.as# Spliced_UnQuote it)) (def' .public (spliced_unquote_macro it) (-> Spliced_UnQuote Macro') - ("lux type as" Macro' it)) + (.as# Macro' it)) (def' .private (list#one f xs) (All (_ a b) @@ -1993,21 +1919,19 @@ ..#scopes scopes ..#type_context types ..#host host ..#seed seed ..#expected expected ..#location location ..#extensions extensions ..#scope_type_vars scope_type_vars ..#eval _eval] state] - (list#one ("lux type check" - (-> Scope ($ Maybe Type)) - (function' [env] - (let' [[..#scope_name _ - ..#inner_scopes _ - ..#locals [..#counter _ ..#mappings locals] - ..#captured _] env] - (list#one ("lux type check" - (-> (Tuple Text (Tuple Type Any)) ($ Maybe Type)) - (function' [it] - (let' [[bname [type _]] it] - (if (text#= name bname) - {#Some type} - {#None})))) - locals)))) + (list#one (.is# (-> Scope ($ Maybe Type)) + (function' [env] + (let' [[..#scope_name _ + ..#inner_scopes _ + ..#locals [..#counter _ ..#mappings locals] + ..#captured _] env] + (list#one (.is# (-> (Tuple Text (Tuple Type Any)) ($ Maybe Type)) + (function' [it] + (let' [[bname [type _]] it] + (if (text#= name bname) + {#Some type} + {#None})))) + locals)))) scopes))) (def' .private (available? expected_module current_module exported?) @@ -2121,7 +2045,7 @@ ({[{#Primitive nameL parametersL} {#Primitive nameR parametersR}] (all and' (text#= nameL nameR) - ("lux i64 =" (list#size parametersL) (list#size parametersR)) + (.i64_=# (list#size parametersL) (list#size parametersR)) (every? (function' [l,r] (let' [[itL itR] l,r] (type#= itL itR))) (zipped_2 parametersL parametersR))) @@ -2146,24 +2070,24 @@ (type#= rightL rightR)) [{#Parameter idL} {#Parameter idR}] - ("lux i64 =" idL idR) + (.i64_=# idL idR) [{#Var idL} {#Var idR}] - ("lux i64 =" idL idR) + (.i64_=# idL idR) [{#Ex idL} {#Ex idR}] - ("lux i64 =" idL idR) + (.i64_=# idL idR) [{#UnivQ envL bodyL} {#UnivQ envR bodyR}] (all and' - ("lux i64 =" (list#size envL) (list#size envR)) + (.i64_=# (list#size envL) (list#size envR)) (every? (function' [l,r] (let' [[itL itR] l,r] (type#= itL itR))) (zipped_2 envL envR)) (type#= bodyL bodyR)) [{#ExQ envL bodyL} {#ExQ envR bodyR}] (all and' - ("lux i64 =" (list#size envL) (list#size envR)) + (.i64_=# (list#size envL) (list#size envR)) (every? (function' [l,r] (let' [[itL itR] l,r] (type#= itL itR))) (zipped_2 envL envR)) (type#= bodyL bodyR)) @@ -2217,12 +2141,11 @@ (-> Text Location (-> Bit Text Code ($ Meta Code)) Bit Text ($ List Code) ($ Meta Code)) (do meta#monad - [.let' [cons ("lux type check" - (-> Code Code ($ Meta Code)) - (function' [head tail] - (do meta#monad - [head (untemplated replace? subst head)] - (in (|#Item| head tail)))))] + [.let' [cons (.is# (-> Code Code ($ Meta Code)) + (function' [head tail] + (do meta#monad + [head (untemplated replace? subst head)] + (in (|#Item| head tail)))))] output (if replace? (monad#mix meta#monad (function' [head tail] @@ -2233,7 +2156,7 @@ ({{#Some [type value]} (if (type#= Spliced_UnQuote type) (do meta#monad - [.let' [it (spliced_unquote_macro ("lux type as" Spliced_UnQuote value))] + [.let' [it (spliced_unquote_macro (.as# Spliced_UnQuote value))] output (one_expansion (it {#Item tail parameters})) .let' [[_ output] output]] (in [@composite output])) @@ -2320,7 +2243,7 @@ ({{#Some [type value]} (if (type#= UnQuote type) (do meta#monad - [.let' [it (unquote_macro ("lux type as" UnQuote value))] + [.let' [it (unquote_macro (.as# UnQuote value))] output (one_expansion (it parameters)) .let' [[_ output] output]] (in [@composite output])) @@ -2360,7 +2283,7 @@ (do meta#monad [current_module current_module_name =template (untemplated #1 current_module template)] - (in (list (form$ (list (text$ "lux type check") + (in (list (form$ (list (symbol$ [..prelude "is#"]) (symbol$ [..prelude "Code"]) =template))))) @@ -2376,7 +2299,7 @@ ({{#Item template {#End}} (do meta#monad [=template (untemplated #1 "" template)] - (in (list (form$ (list (text$ "lux type check") (symbol$ [..prelude "Code"]) =template))))) + (in (list (form$ (list (symbol$ [..prelude "is#"]) (symbol$ [..prelude "Code"]) =template))))) _ (failure (wrong_syntax_error [..prelude "`'"]))} @@ -2390,7 +2313,7 @@ ({{#Item template {#End}} (do meta#monad [=template (untemplated #0 "" template)] - (in (list (form$ (list (text$ "lux type check") (symbol$ [..prelude "Code"]) =template))))) + (in (list (form$ (list (symbol$ [..prelude "is#"]) (symbol$ [..prelude "Code"]) =template))))) _ (failure (wrong_syntax_error [..prelude "'"]))} @@ -2403,7 +2326,7 @@ (..unquote (macro (_ tokens) ({{#Item it {#End}} - (meta#in (list (form$ (list (text$ "lux type check") + (meta#in (list (form$ (list (symbol$ [..prelude "is#"]) (symbol$ [..prelude "Code"]) it)))) @@ -2431,7 +2354,7 @@ (def' .public ,* Spliced_UnQuote - (let' [g!list#composite (form$ (list (text$ "lux in-module") + (let' [g!list#composite (form$ (list (symbol$ [..prelude "in_module#"]) (text$ ..prelude) (symbol$ [..prelude "list#composite"])))] (..spliced_unquote @@ -2449,21 +2372,20 @@ Macro (macro (_ tokens) ({{#Item [init apps]} - (meta#in (list (list#mix ("lux type check" - (-> Code Code Code) - (function' [app acc] - ({[_ {#Variant parts}] - (variant$ (list#composite parts (list acc))) + (meta#in (list (list#mix (.is# (-> Code Code Code) + (function' [app acc] + ({[_ {#Variant parts}] + (variant$ (list#composite parts (list acc))) - [_ {#Tuple parts}] - (tuple$ (list#composite parts (list acc))) + [_ {#Tuple parts}] + (tuple$ (list#composite parts (list acc))) - [_ {#Form parts}] - (form$ (list#composite parts (list acc))) + [_ {#Form parts}] + (form$ (list#composite parts (list acc))) - _ - (` ((, app) (, acc)))} - app))) + _ + (` ((, app) (, acc)))} + app))) init apps))) @@ -2475,21 +2397,20 @@ Macro (macro (_ tokens) ({{#Item [init apps]} - (meta#in (list (list#mix ("lux type check" - (-> Code Code Code) - (function' [app acc] - ({[_ {#Variant parts}] - (variant$ (list#composite parts (list acc))) + (meta#in (list (list#mix (.is# (-> Code Code Code) + (function' [app acc] + ({[_ {#Variant parts}] + (variant$ (list#composite parts (list acc))) - [_ {#Tuple parts}] - (tuple$ (list#composite parts (list acc))) + [_ {#Tuple parts}] + (tuple$ (list#composite parts (list acc))) - [_ {#Form parts}] - (form$ (list#composite parts (list acc))) + [_ {#Form parts}] + (form$ (list#composite parts (list acc))) - _ - (` ((, app) (, acc)))} - app))) + _ + (` ((, app) (, acc)))} + app))) init apps))) @@ -2554,26 +2475,25 @@ (def' .private (high_bits value) (-> ($ I64 Any) I64) - ("lux i64 right-shift" 32 value)) + (.i64_right# 32 value)) (def' .private low_mask I64 - (|> 1 ("lux i64 left-shift" 32) ("lux i64 -" 1))) + (|> 1 (.i64_left# 32) (.i64_-# 1))) (def' .private (low_bits value) (-> ($ I64 Any) I64) - ("lux i64 and" low_mask value)) + (.i64_and# low_mask value)) (def' .private (n/< reference sample) (-> Nat Nat Bit) (let' [referenceH (high_bits reference) sampleH (high_bits sample)] - (if ("lux i64 <" referenceH sampleH) + (if (.int_<# referenceH sampleH) #1 - (if ("lux i64 =" referenceH sampleH) - ("lux i64 <" - (low_bits reference) - (low_bits sample)) + (if (.i64_=# referenceH sampleH) + (.int_<# (low_bits reference) + (low_bits sample)) #0)))) (def' .private (list#conjoint xs) @@ -2596,11 +2516,10 @@ (macro (_ tokens) ({{#Item [[_ {#Tuple bindings}] {#Item [[_ {#Tuple templates}] data]}]} ({[{#Some bindings'} {#Some data'}] - (let' [apply ("lux type check" - (-> Replacement_Environment ($ List Code)) - (function' [env] (list#each (realized_template env) templates))) + (let' [apply (.is# (-> Replacement_Environment ($ List Code)) + (function' [env] (list#each (realized_template env) templates))) num_bindings (list#size bindings')] - (if (every? (function' [size] ("lux i64 =" num_bindings size)) + (if (every? (function' [size] (.i64_=# num_bindings size)) (list#each list#size data')) (|> data' (list#each (function#composite apply (replacement_environment bindings'))) @@ -2619,28 +2538,26 @@ (def' .private (n// param subject) (-> Nat Nat Nat) - (if ("lux i64 <" +0 ("lux type as" Int param)) + (if (.int_<# +0 (.as# Int param)) (if (n/< param subject) 0 1) (let' [quotient (|> subject - ("lux i64 right-shift" 1) - ("lux i64 /" ("lux type as" Int param)) - ("lux i64 left-shift" 1)) - flat ("lux i64 *" - ("lux type as" Int param) - ("lux type as" Int quotient)) - remainder ("lux i64 -" flat subject)] + (.i64_right# 1) + (.int_/# (.as# Int param)) + (.i64_left# 1)) + flat (.int_*# (.as# Int param) + (.as# Int quotient)) + remainder (.i64_-# flat subject)] (if (n/< param remainder) quotient - ("lux i64 +" 1 quotient))))) + (.i64_+# 1 quotient))))) (def' .private (n/% param subject) (-> Nat Nat Nat) - (let' [flat ("lux i64 *" - ("lux type as" Int param) - ("lux type as" Int (n// param subject)))] - ("lux i64 -" flat subject))) + (let' [flat (.int_*# (.as# Int param) + (.as# Int (n// param subject)))] + (.i64_-# flat subject))) (def' .private (n/min left right) (-> Nat Nat Nat) @@ -2658,50 +2575,48 @@ [1] "1" [2] "2" [3] "3" [4] "4" [5] "5" [6] "6" [7] "7" [8] "8" [9] "9" - _ ("lux io error" "@digit::format Undefined behavior.")} + _ (.error# "@digit::format Undefined behavior.")} digit)) (def' .private (nat#encoded value) (-> Nat Text) ({[0] "0" - _ (let' [loop ("lux type check" - (-> Nat Text Text) - (function' again [input output] - (if ("lux i64 =" 0 input) - output - (again (n// 10 input) - (text#composite (|> input (n/% 10) digit::format) - output)))))] + _ (let' [loop (.is# (-> Nat Text Text) + (function' again [input output] + (if (.i64_=# 0 input) + output + (again (n// 10 input) + (text#composite (|> input (n/% 10) digit::format) + output)))))] (loop value ""))} value)) (def' .private (int#abs value) (-> Int Int) - (if ("lux i64 <" +0 value) - ("lux i64 *" -1 value) + (if (.int_<# +0 value) + (.int_*# -1 value) value)) (def' .private (int#encoded value) (-> Int Text) - (if ("lux i64 =" +0 value) + (if (.i64_=# +0 value) "+0" - (let' [sign (if ("lux i64 <" value +0) + (let' [sign (if (.int_<# value +0) "+" "-")] - (("lux type check" - (-> Int Text Text) - (function' again [input output] - (if ("lux i64 =" +0 input) - (text#composite sign output) - (again ("lux i64 /" +10 input) - (text#composite (|> input ("lux i64 %" +10) ("lux type as" Nat) digit::format) - output))))) - (|> value ("lux i64 /" +10) int#abs) - (|> value ("lux i64 %" +10) int#abs ("lux type as" Nat) digit::format))))) + ((.is# (-> Int Text Text) + (function' again [input output] + (if (.i64_=# +0 input) + (text#composite sign output) + (again (.int_/# +10 input) + (text#composite (|> input (.int_%# +10) (.as# Nat) digit::format) + output))))) + (|> value (.int_/# +10) int#abs) + (|> value (.int_%# +10) int#abs (.as# Nat) digit::format))))) (def' .private (frac#encoded x) (-> Frac Text) - ("lux f64 encode" x)) + (.f64_encoded# x)) (def' .public (not x) (-> Bit Bit) @@ -2722,7 +2637,7 @@ ($ Maybe Macro)) (do maybe#monad [$module (property#value module modules) - gdef (let' [[..#module_hash _ ..#module_aliases _ ..#definitions bindings ..#imports _ ..#module_state _] ("lux type check" Module $module)] + gdef (let' [[..#module_hash _ ..#module_aliases _ ..#definitions bindings ..#imports _ ..#module_state _] (.is# Module $module)] (property#value name bindings))] ({{#Alias [r_module r_name]} (named_macro' modules current_module r_module r_name) @@ -2730,15 +2645,15 @@ {#Definition [exported? def_type def_value]} (if (macro_type? def_type) (if exported? - {#Some ("lux type as" Macro def_value)} + {#Some (.as# Macro def_value)} (if (text#= module current_module) - {#Some ("lux type as" Macro def_value)} + {#Some (.as# Macro def_value)} {#None})) {#None}) {#Default _} {#None}} - ("lux type check" Global gdef)))) + (.is# Global gdef)))) (def' .private (named_macro full_name) (-> Symbol ($ Meta ($ Maybe Macro))) @@ -2783,7 +2698,7 @@ [name' (normal name) ?macro (named_macro name')] ({{#Some macro} - (("lux type as" Macro' macro) args) + ((.as# Macro' macro) args) {#None} (in (list token))} @@ -2801,7 +2716,7 @@ ?macro (named_macro name')] ({{#Some macro} (do meta#monad - [top_level_expansion (("lux type as" Macro' macro) args) + [top_level_expansion ((.as# Macro' macro) args) recursive_expansion (monad#each meta#monad complete_expansion top_level_expansion)] (in (list#conjoint recursive_expansion))) @@ -2820,7 +2735,7 @@ ?macro (named_macro name')] ({{#Some macro} (do meta#monad - [expansion (("lux type as" Macro' macro) args) + [expansion ((.as# Macro' macro) args) expansion' (monad#each meta#monad total_expansion expansion)] (in (list#conjoint expansion'))) @@ -2911,7 +2826,7 @@ (int#encoded value) [_ {#Rev value}] - ("lux io error" "@code#encoded Undefined behavior.") + (.error# "@code#encoded Undefined behavior.") [_ {#Frac value}] (frac#encoded value) @@ -2956,13 +2871,13 @@ [members (monad#each meta#monad normal_type members)] (in (` (Tuple (,* members))))) - [_ {#Form {#Item [_ {#Text "lux in-module"}] + [_ {#Form {#Item [_ {#Symbol ["library/lux" "in_module#"]}] {#Item [_ {#Text module}] {#Item type' {#End}}}}}] (do meta#monad [type' (normal_type type')] - (in (` ("lux in-module" (, (text$ module)) (, type'))))) + (in (` (.in_module# (, (text$ module)) (, type'))))) [_ {#Form {#Item [_ {#Symbol ["" ","]}] {#Item expression {#End}}}}] (meta#in expression) @@ -2993,9 +2908,8 @@ (do meta#monad [type_fn (normal_type type_fn) args (monad#each meta#monad normal_type args)] - (in (list#mix ("lux type check" - (-> Code Code Code) - (function' [arg type_fn] (` {.#Apply (, arg) (, type_fn)}))) + (in (list#mix (.is# (-> Code Code Code) + (function' [arg type_fn] (` {.#Apply (, arg) (, type_fn)}))) type_fn args))) @@ -3056,7 +2970,7 @@ ..#scopes (list#partial [#scope_name (list) #inner_scopes 0 #locals [#counter 0 - #mappings (list [..quantification_level [.Nat ("lux type as" Nat -1)]])] + #mappings (list [..quantification_level [.Nat (.as# Nat -1)]])] #captured [#counter 0 #mappings (list)]] scopes/pre) @@ -3100,9 +3014,8 @@ Macro (macro (_ tokens) ({{#Item type {#Item value {#End}}} - (meta#in (list (` ("lux type check" - (..type_literal (, type)) - (, value))))) + (meta#in (list (` (.is# (..type_literal (, type)) + (, value))))) _ (failure (..wrong_syntax_error (symbol ..is)))} @@ -3112,9 +3025,8 @@ Macro (macro (_ tokens) ({{#Item type {#Item value {#End}}} - (meta#in (list (` ("lux type as" - (..type_literal (, type)) - (, value))))) + (meta#in (list (` (.as# (..type_literal (, type)) + (, value))))) _ (failure (..wrong_syntax_error (symbol ..as)))} @@ -3146,7 +3058,7 @@ ..#scope_type_vars scope_type_vars ..#eval _eval] {#Right [..#info info ..#source source ..#current_module _ ..#modules modules ..#scopes scopes ..#type_context types ..#host host - ..#seed ("lux i64 +" 1 seed) ..#expected expected + ..#seed (.i64_+# 1 seed) ..#expected expected ..#location location ..#extensions extensions ..#scope_type_vars scope_type_vars ..#eval _eval] (local$ (all text#composite "__gensym__" prefix (nat#encoded seed)))}} @@ -3157,9 +3069,8 @@ (macro (_ tokens) ({{#Item value actions} (let' [dummy (local$ "")] - (meta#in (list (list#mix ("lux type check" - (-> Code Code Code) - (function' [pre post] (` ({(, dummy) (, post)} (, pre))))) + (meta#in (list (list#mix (.is# (-> Code Code Code) + (function' [pre post] (` ({(, dummy) (, post)} (, pre))))) value actions)))) @@ -3347,11 +3258,11 @@ (def' .public (pattern it) (-> Macro Pattern) - ("lux type as" Pattern it)) + (.as# Pattern it)) (def' .public (pattern_macro it) (-> Pattern Macro') - ("lux type as" Macro' it)) + (.as# Macro' it)) (def' .private (when_expansion#macro when_expansion pattern body branches) (type_literal (-> (-> (List Code) (Meta (List Code))) @@ -3374,7 +3285,7 @@ ({{#Some [type value]} (if (type#= Pattern type) (do meta#monad - [branches'' ((pattern_macro ("lux type as" Pattern value)) + [branches'' ((pattern_macro (.as# Pattern value)) (list#partial (form$ parameters) body branches'))] (when_expansion branches'')) (when_expansion#macro when_expansion [@composite {#Form {#Item [@symbol {#Symbol global}] parameters}}] body branches')) @@ -3813,11 +3724,11 @@ (def (index part text) (-> Text Text (Maybe Nat)) - ("lux text index" 0 part text)) + (.text_index# 0 part text)) (def .public (panic! message) (-> Text Nothing) - ("lux io error" message)) + (.error# message)) (def maybe#else (macro (_ tokens state) @@ -3842,13 +3753,12 @@ (list input) {#Some idx} - (list#partial ("lux text clip" 0 idx input) + (list#partial (.text_clip# 0 idx input) (text#all_split_by splitter - (let [after_offset ("lux i64 +" 1 idx) - after_length ("lux i64 -" - after_offset - ("lux text size" input))] - ("lux text clip" after_offset after_length input)))))) + (let [after_offset (.i64_+# 1 idx) + after_length (.i64_-# after_offset + (.text_size# input))] + (.text_clip# after_offset after_length input)))))) (def (item idx xs) (All (_ a) @@ -3858,9 +3768,9 @@ {#None} {#Item x xs'} - (if ("lux i64 =" 0 idx) + (if (.i64_=# 0 idx) {#Some x} - (item ("lux i64 -" 1 idx) xs')))) + (item (.i64_-# 1 idx) xs')))) ... https://en.wikipedia.org/wiki/Lambda_calculus#%CE%B2-reduction (def (reduced env type) @@ -4256,7 +4166,7 @@ (-> Nat (List a) (List [Nat a]))) (when xs {#Item x xs'} - {#Item [idx x] (enumeration' ("lux i64 +" 1 idx) xs')} + {#Item [idx x] (enumeration' (.i64_+# 1 idx) xs')} {#End} {#End})) @@ -4285,7 +4195,7 @@ (` (def (, export_policy) (, (local$ right)) (<| (as (, label_type)) (is Label) - [{#Some [(, (nat$ ("lux i64 -" 1 (list#size lefts)))) #1 (, family)]} (, associated_type)]))) + [{#Some [(, (nat$ (.i64_-# 1 (list#size lefts)))) #1 (, family)]} (, associated_type)]))) (list#each (function (_ [lefts it]) (` (def (, export_policy) (, (local$ it)) (<| (as (, label_type)) @@ -4367,15 +4277,15 @@ (def (text#split_at' at x) (-> Nat Text [Text Text]) - [("lux text clip" 0 at x) - ("lux text clip" at (|> x "lux text size" ("lux i64 -" at)) x)]) + [(.text_clip# 0 at x) + (.text_clip# at (|> x .text_size# (.i64_-# at)) x)]) (def (text#split_by token sample) (-> Text Text (Maybe [Text Text])) (do ..maybe#monad [index (..index token sample) .let [[pre post'] (text#split_at' index sample) - [_ post] (text#split_at' ("lux text size" token) post')]] + [_ post] (text#split_at' (.text_size# token) post')]] (in [pre post]))) (def (replaced pattern replacement template) @@ -4384,21 +4294,21 @@ (function (again left right) (when (..text#split_by pattern right) {#Some [pre post]} - (again (all "lux text concat" left pre replacement) post) + (again (all .text_composite# left pre replacement) post) {#None} - ("lux text concat" left right)))) + (.text_composite# left right)))) "" template)) (def (alias_stand_in index) (-> Nat Text) - (all "lux text concat" "[" (nat#encoded index) "]")) + (all .text_composite# "[" (nat#encoded index) "]")) (def (module_alias context aliased) (-> (List Text) Text Text) (product#right (list#mix (function (_ replacement [index aliased]) - [("lux i64 +" 1 index) + [(.i64_+# 1 index) (replaced (alias_stand_in index) replacement aliased)]) [0 aliased] context))) @@ -4433,13 +4343,13 @@ (def (relative_ups relatives input) (-> Nat Text Nat) - (when ("lux text index" relatives ..module_separator input) + (when (.text_index# relatives ..module_separator input) {#None} relatives {#Some found} - (if ("lux i64 =" relatives found) - (relative_ups ("lux i64 +" 1 relatives) input) + (if (.i64_=# relatives found) + (relative_ups (.i64_+# 1 relatives) input) relatives))) (def (list#after amount list) @@ -4450,31 +4360,31 @@ list [_ {#Item _ tail}] - (list#after ("lux i64 -" 1 amount) tail))) + (list#after (.i64_-# 1 amount) tail))) (def (absolute_module_name nested? relative_root module) (-> Bit Text Text (Meta Text)) (when (relative_ups 0 module) 0 (meta#in (if nested? - (all "lux text concat" relative_root ..module_separator module) + (all .text_composite# relative_root ..module_separator module) module)) relatives (let [parts (text#all_split_by ..module_separator relative_root) - jumps ("lux i64 -" 1 relatives)] + jumps (.i64_-# 1 relatives)] (if (n/< (list#size parts) jumps) (let [prefix (|> parts list#reversed (list#after jumps) list#reversed (text#interposed ..module_separator)) - clean ("lux text clip" relatives (|> module "lux text size" ("lux i64 -" relatives)) module) - output (when ("lux text size" clean) + clean (.text_clip# relatives (|> module .text_size# (.i64_-# relatives)) module) + output (when (.text_size# clean) 0 prefix _ (all text#composite prefix ..module_separator clean))] (meta#in output)) - (failure (all "lux text concat" + (failure (all .text_composite# "Cannot climb the module hierarchy..." \n "Importing module: " module \n " Relative Root: " relative_root \n)))))) @@ -4717,7 +4627,7 @@ {#End} {#Item [var bound] bindings'} - (if ("lux i64 =" idx var) + (if (.i64_=# idx var) bound (type_variable idx bindings')))) @@ -4932,11 +4842,11 @@ (function (again index input output) (when input (list#partial head tail) - (if ("lux i64 =" index (if right? - ("lux i64 +" 1 lefts) - lefts)) + (if (.i64_=# index (if right? + (.i64_+# 1 lefts) + lefts)) (list#reversed (list#partial g!output output)) - (again ("lux i64 +" 1 index) tail (list#partial g!_ output))) + (again (.i64_+# 1 index) tail (list#partial g!_ output))) (list) (list)))) @@ -4964,13 +4874,13 @@ [g!_ (..generated_symbol "_") g!output (..generated_symbol "") .let [idx (if right? - (is Nat ("lux i64 +" 1 lefts)) + (is Nat (.i64_+# 1 lefts)) lefts) pattern (|> (enumeration family) (list#each (is (-> [Nat Symbol] (List Code)) (function (_ [r_idx slot]) (list (symbol$ slot) - (if ("lux i64 =" idx r_idx) + (if (.i64_=# idx r_idx) g!output g!_))))) list#conjoint)]] @@ -5001,7 +4911,7 @@ pattern (|> tags enumeration (list#each (function (_ [tag_idx tag]) - (if ("lux i64 =" my_tag_index tag_idx) + (if (.i64_=# my_tag_index tag_idx) g!output g!_))) tuple$) @@ -5208,13 +5118,13 @@ r_var)))) list#conjoint) idx (if right? - (is Nat ("lux i64 +" 1 lefts)) + (is Nat (.i64_+# 1 lefts)) lefts) output (|> pattern' (list#each (is (-> [Symbol Nat Code] (List Code)) (function (_ [r_slot_name r_idx r_var]) (list (symbol$ r_slot_name) - (if ("lux i64 =" idx r_idx) + (if (.i64_=# idx r_idx) value r_var))))) list#conjoint)]] @@ -5293,13 +5203,13 @@ r_var)))) list#conjoint) idx (if right? - (is Nat ("lux i64 +" 1 lefts)) + (is Nat (.i64_+# 1 lefts)) lefts) output (|> pattern' (list#each (is (-> [Symbol Nat Code] (List Code)) (function (_ [r_slot_name r_idx r_var]) (list (symbol$ r_slot_name) - (if ("lux i64 =" idx r_idx) + (if (.i64_=# idx r_idx) (` ((, fun) (, r_var))) r_var))))) list#conjoint)]] @@ -5349,7 +5259,7 @@ [bindings' (monad#each maybe#monad symbol_short bindings) data' (monad#each maybe#monad tuple_list data)] (let [num_bindings (list#size bindings')] - (if (every? (|>> ("lux i64 =" num_bindings)) + (if (every? (|>> (.i64_=# num_bindings)) (list#each list#size data')) (let [apply (is (-> Replacement_Environment (List Code)) (function (_ env) (list#each (realized_template env) templates)))] @@ -5373,8 +5283,8 @@ (-> (I64 s) (I64 s))) (|>> (<extension> 1)))] - [++ "lux i64 +"] - [-- "lux i64 -"] + [++ .i64_+#] + [-- .i64_-#] ) (def (interleaved xs ys) @@ -5445,11 +5355,10 @@ {#None} (failure (..wrong_syntax_error (symbol ..loop))))) init_types (monad#each meta#monad type_definition inits') expected ..expected_type] - (meta#in (list (` (("lux type check" - (-> (,* (list#each type_code init_types)) - (, (type_code expected))) - (function ((, name) (,* vars)) - (, body))) + (meta#in (list (` ((.is# (-> (,* (list#each type_code init_types)) + (, (type_code expected))) + (function ((, name) (,* vars)) + (, body))) (,* inits)))))) (do meta#monad [aliases (monad#each meta#monad @@ -5525,7 +5434,7 @@ (def .public (same? reference sample) (All (_ a) (-> a a Bit)) - ("lux is" reference sample)) + (.is?# reference sample)) (def .public as_expected (macro (_ tokens) @@ -5533,7 +5442,8 @@ (list expr) (do meta#monad [type ..expected_type] - (in (list (` ("lux type as" (, (type_code type)) (, expr)))))) + (in (list (` (.as# (, (type_code type)) + (, expr)))))) _ (failure (..wrong_syntax_error (symbol ..as_expected)))))) @@ -5548,8 +5458,8 @@ (do meta#monad [location location .let [[module line column] location - location (all "lux text concat" (text#encoded module) "," (nat#encoded line) "," (nat#encoded column)) - message (all "lux text concat" "Undefined behavior @ " location)]] + location (all .text_composite# (text#encoded module) "," (nat#encoded line) "," (nat#encoded column)) + message (all .text_composite# "Undefined behavior @ " location)]] (in (list (` (..panic! (, (text$ message))))))) _ @@ -5629,8 +5539,8 @@ (macro (_ tokens compiler) (when tokens (list [_ {#Text input}]) - (if (|> input "lux text size" ("lux i64 =" 1)) - (|> input ("lux text char" 0) + (if (|> input .text_size# (.i64_=# 1)) + (|> input (.text_char# 0) nat$ list [compiler] {#Right}) {#Left (..wrong_syntax_error (symbol ..char))}) @@ -5851,9 +5761,8 @@ (list expression) (do meta#monad [g!_ (..generated_symbol "g!_")] - (in (list (` ("lux try" - (.function ((, g!_) (, g!_)) - (, expression))))))) + (in (list (` (.try# (.function ((, g!_) (, g!_)) + (, expression))))))) _ (..failure (..wrong_syntax_error (symbol ..try)))))) @@ -5861,7 +5770,7 @@ (def (methodP tokens) (-> (List Code) (Maybe [(List Code) [Text Code]])) (when tokens - (list#partial [_ {#Form (list [_ {#Text "lux type check"}] + (list#partial [_ {#Form (list [_ {#Symbol [..prelude "is#"]}] type [_ {#Symbol ["" name]}])}] tokens') diff --git a/stdlib/source/library/lux/abstract/comonad.lux b/stdlib/source/library/lux/abstract/comonad.lux index 5cf0679df..c62c42674 100644 --- a/stdlib/source/library/lux/abstract/comonad.lux +++ b/stdlib/source/library/lux/abstract/comonad.lux @@ -40,7 +40,7 @@ {.#Some bindings} (let [[module short] (symbol ..be) symbol (is (-> Text Code) - (|>> (all "lux text concat" module " " short " ") [""] {.#Symbol} [location.dummy])) + (|>> (all .text_composite# module " " short " ") [""] {.#Symbol} [location.dummy])) g!_ (symbol "_") g!each (symbol "each") g!disjoint (symbol "disjoint") diff --git a/stdlib/source/library/lux/abstract/monad.lux b/stdlib/source/library/lux/abstract/monad.lux index f2455e3f8..6667d75fa 100644 --- a/stdlib/source/library/lux/abstract/monad.lux +++ b/stdlib/source/library/lux/abstract/monad.lux @@ -67,10 +67,10 @@ _ {.#None})) {.#Some [?name monad bindings body]} - (if (|> bindings list#size .int ("lux i64 %" +2) ("lux i64 =" +0)) + (if (|> bindings list#size .int (.int_%# +2) (.i64_=# +0)) (let [[module short] (symbol ..do) symbol (is (-> Text Code) - (|>> (.all "lux text concat" module " " short " ") [""] {.#Symbol} [location.dummy])) + (|>> (.all .text_composite# module " " short " ") [""] {.#Symbol} [location.dummy])) g!_ (symbol "_") g!each (symbol "each") g!conjoint (symbol "conjoint") diff --git a/stdlib/source/library/lux/control/concurrency/thread.lux b/stdlib/source/library/lux/control/concurrency/thread.lux index 5b260b4ea..1b752dea7 100644 --- a/stdlib/source/library/lux/control/concurrency/thread.lux +++ b/stdlib/source/library/lux/control/concurrency/thread.lux @@ -108,7 +108,7 @@ (when (try (io.run! action)) {try.#Failure error} (exec - (debug.log! (all "lux text concat" + (debug.log! (all .text_composite# "ERROR DURING THREAD EXECUTION:" text.new_line error)) []) diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux index 474ca07d3..fabba5ad5 100644 --- a/stdlib/source/library/lux/control/exception.lux +++ b/stdlib/source/library/lux/control/exception.lux @@ -147,16 +147,16 @@ ..report)) (.def separator - (let [gap (all "lux text concat" text.new_line text.new_line) + (let [gap (all .text_composite# text.new_line text.new_line) horizontal_line (|> "-" (list.repeated 64) text.together)] - (all "lux text concat" + (all .text_composite# gap horizontal_line gap))) (.def (decorated prelude error) (-> Text Text Text) - (all "lux text concat" + (all .text_composite# prelude ..separator error)) diff --git a/stdlib/source/library/lux/control/function/inline.lux b/stdlib/source/library/lux/control/function/inline.lux index bbdbdd434..a75f7688e 100644 --- a/stdlib/source/library/lux/control/function/inline.lux +++ b/stdlib/source/library/lux/control/function/inline.lux @@ -37,7 +37,7 @@ g!parameters (|> (macro.symbol "parameter") (list.repeated (list.size parameters)) (monad.all !)) - .let [inlined (` (("lux in-module" + .let [inlined (` ((.in_module# (, (code.text @)) (.is (, type) (.function ((, (code.local name)) (,* parameters)) diff --git a/stdlib/source/library/lux/control/function/polymorphism/context.lux b/stdlib/source/library/lux/control/function/polymorphism/context.lux index ee47ece31..ce9d5a149 100644 --- a/stdlib/source/library/lux/control/function/polymorphism/context.lux +++ b/stdlib/source/library/lux/control/function/polymorphism/context.lux @@ -143,7 +143,7 @@ [[(, g!_) (, g!_) (, g!_) (, g!_) (, g!_) (, g!_) (, g!_) (, g!scenarios)] (context.search' (|>> product.left (at text.equivalence (,' =) (, (code.text (the #name signature))))) - [("lux in-module" (, (code.text @)) ..stack) + [(.in_module# (, (code.text @)) ..stack) (symbol ..stack)])] (at meta.monad (,' in) (list (` (.def (, export_policy) (, name) diff --git a/stdlib/source/library/lux/control/function/polymorphism/predicate.lux b/stdlib/source/library/lux/control/function/polymorphism/predicate.lux index ed0d4097f..d87917fe0 100644 --- a/stdlib/source/library/lux/control/function/polymorphism/predicate.lux +++ b/stdlib/source/library/lux/control/function/polymorphism/predicate.lux @@ -83,7 +83,7 @@ [[(, g!_) (, g!_) (, g!_) (, g!_) (, g!_) (, g!_) (, g!scenarios)] (context.search' (|>> product.left (at text.equivalence (,' =) (, (code.text (the #name signature))))) - [("lux in-module" (, (code.text @)) ..stack) + [(.in_module# (, (code.text @)) ..stack) (symbol ..stack)])] (at meta.monad (,' in) (list (` (.def (, export_policy) (, name) diff --git a/stdlib/source/library/lux/control/try.lux b/stdlib/source/library/lux/control/try.lux index 419f3525d..1a1fae856 100644 --- a/stdlib/source/library/lux/control/try.lux +++ b/stdlib/source/library/lux/control/try.lux @@ -100,7 +100,7 @@ (_#= reference sample) [{#Failure reference} {#Failure sample}] - ("lux text =" reference sample) + (.text_=# reference sample) _ false @@ -135,13 +135,13 @@ {#Success value} {.#None} - {#Failure (`` (("lux in-module" (,, (static .prelude)) .symbol#encoded) (symbol ..of_maybe)))})) + {#Failure (`` ((.in_module# (,, (static .prelude)) .symbol#encoded) (symbol ..of_maybe)))})) (def generated_symbol (macro (_ tokens compiler) (.when tokens (list [_ {.#Text prefix}]) - (let [generated_symbol (`` ("lux in-module" (,, (static .prelude)) .generated_symbol))] + (let [generated_symbol (`` (.in_module# (,, (static .prelude)) .generated_symbol))] (.when (generated_symbol prefix compiler) {#Success [compiler g!_]} {#Success [compiler (list g!_)]} @@ -168,7 +168,7 @@ (template (_ <test> <then>) [(if <test> <then> - {..#Failure (let [symbol#encoded (`` ("lux in-module" (,, (static .prelude)) .symbol#encoded))] - (all "lux text concat" + {..#Failure (let [symbol#encoded (`` (.in_module# (,, (static .prelude)) .symbol#encoded))] + (all .text_composite# "[" (symbol#encoded (symbol ..when)) "]" " " "Invalid condition!"))})])) diff --git a/stdlib/source/library/lux/data/collection/bits.lux b/stdlib/source/library/lux/data/collection/bits.lux index 1e84ee9c4..e54f99e21 100644 --- a/stdlib/source/library/lux/data/collection/bits.lux +++ b/stdlib/source/library/lux/data/collection/bits.lux @@ -102,7 +102,7 @@ (if (n.< chunks idx) (.or (|> (..chunk idx sample) (i64.and (..chunk idx reference)) - ("lux i64 =" empty_chunk) + (.i64_=# empty_chunk) .not) (again (++ idx))) false)))) @@ -170,8 +170,7 @@ (array.size sample))] (loop (again [idx 0]) (if (n.< size idx) - (.and ("lux i64 =" - (..chunk idx reference) - (..chunk idx sample)) + (.and (.i64_=# (..chunk idx reference) + (..chunk idx sample)) (again (++ idx))) true)))))) diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux index f6850e380..c0b4c4e87 100644 --- a/stdlib/source/library/lux/data/collection/list.lux +++ b/stdlib/source/library/lux/data/collection/list.lux @@ -80,7 +80,7 @@ (def wrong_syntax_error (template (_ <it>) - [((`` ("lux in-module" (,, (static .prelude)) .wrong_syntax_error)) + [((`` (.in_module# (,, (static .prelude)) .wrong_syntax_error)) (symbol <it>))])) (def .public partial @@ -468,7 +468,7 @@ 8 "8" 9 "9" _ (undefined)) - output' ("lux text concat" digit output) + output' (.text_composite# digit output) input' (n./ 10 input)] (.when input' 0 output' @@ -491,7 +491,7 @@ (each (function (_ idx) (let [base (nat#encoded idx)] [(symbol$ base) - (symbol$ ("lux text concat" base "'"))])))) + (symbol$ (.text_composite# base "'"))])))) pattern (` [(,* (each (function (_ [v vs]) (` {.#Item (, v) (, vs)})) vars+lists))]) g!step (symbol$ "0step0") @@ -535,7 +535,7 @@ (each (function (_ idx) (let [base (nat#encoded idx)] [(symbol$ base) - (symbol$ ("lux text concat" base "'"))])))) + (symbol$ (.text_composite# base "'"))])))) pattern (` [(,* (each (function (_ [v vs]) (` {.#Item (, v) (, vs)})) vars+lists))]) g!step (symbol$ "0step0") diff --git a/stdlib/source/library/lux/data/product.lux b/stdlib/source/library/lux/data/product.lux index 6c1143dc2..50ab886e2 100644 --- a/stdlib/source/library/lux/data/product.lux +++ b/stdlib/source/library/lux/data/product.lux @@ -63,6 +63,5 @@ (..equivalence (at left equivalence) (at right equivalence))) (def (hash [leftV rightV]) - ("lux i64 +" - (at left hash leftV) - (at right hash rightV))))) + (.i64_+# (at left hash leftV) + (at right hash rightV))))) diff --git a/stdlib/source/library/lux/data/sum.lux b/stdlib/source/library/lux/data/sum.lux index 72d5d52df..9dc3e6f7b 100644 --- a/stdlib/source/library/lux/data/sum.lux +++ b/stdlib/source/library/lux/data/sum.lux @@ -88,7 +88,7 @@ (def (hash value) (.nat (when value {.#Left value} - ("lux i64 *" +2 (.int (at left hash value))) + (.int_*# +2 (.int (at left hash value))) {.#Right value} - ("lux i64 *" +3 (.int (at right hash value)))))))) + (.int_*# +3 (.int (at right hash value)))))))) diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux index 8502d1d76..e1ac2856b 100644 --- a/stdlib/source/library/lux/data/text.lux +++ b/stdlib/source/library/lux/data/text.lux @@ -27,7 +27,7 @@ ... (The JVM specifies chars as 16-bit unsigned integers) (def .public of_char (-> Char Text) - (|>> .int "lux i64 char")) + (|>> .int .int_char#)) (with_template [<code> <short> <long>] [(def .public <long> (..of_char <code>)) @@ -49,17 +49,17 @@ (def .public size (-> Text Nat) - (|>> "lux text size")) + (|>> .text_size#)) (def .public (char index input) (-> Nat Text (Maybe Char)) - (if (n.< ("lux text size" input) index) - {.#Some ("lux text char" index input)} + (if (n.< (.text_size# input) index) + {.#Some (.text_char# index input)} {.#None})) (def .public (index_since offset pattern input) (-> Nat Text Text (Maybe Nat)) - ("lux text index" offset pattern input)) + (.text_index# offset pattern input)) (def .public (index pattern input) (-> Text Text (Maybe Nat)) @@ -70,7 +70,7 @@ (loop (again [offset 0 output (is (Maybe Nat) {.#None})]) - (let [output' ("lux text index" offset part text)] + (let [output' (.text_index# offset part text)] (when output' {.#None} output @@ -104,7 +104,7 @@ (def .public (contains? sub text) (-> Text Text Bit) - (when ("lux text index" 0 sub text) + (when (.text_index# 0 sub text) {.#Some _} true @@ -113,15 +113,15 @@ (def .public (prefix param subject) (-> Text Text Text) - ("lux text concat" param subject)) + (.text_composite# param subject)) (def .public (suffix param subject) (-> Text Text Text) - ("lux text concat" subject param)) + (.text_composite# subject param)) (def .public (enclosed [left right] content) (-> [Text Text] Text Text) - (all "lux text concat" left content right)) + (all .text_composite# left content right)) (def .public (enclosed' boundary content) (-> Text Text Text) @@ -133,16 +133,16 @@ (def .public (clip offset size input) (-> Nat Nat Text (Maybe Text)) - (if (|> size (n.+ offset) (n.> ("lux text size" input))) + (if (|> size (n.+ offset) (n.> (.text_size# input))) {.#None} - {.#Some ("lux text clip" offset size input)})) + {.#Some (.text_clip# offset size input)})) (def .public (clip_since offset input) (-> Nat Text (Maybe Text)) - (let [size ("lux text size" input)] + (let [size (.text_size# input)] (if (n.> size offset) {.#None} - {.#Some ("lux text clip" offset (n.- offset size) input)}))) + {.#Some (.text_clip# offset (n.- offset size) input)}))) (def .public (split_at at x) (-> Nat Text (Maybe [Text Text])) @@ -181,7 +181,7 @@ (<| (maybe.else template) (do maybe.monad [[pre post] (..split_by pattern template)] - (in (all "lux text concat" pre replacement post))))) + (in (all .text_composite# pre replacement post))))) (for @.js (these (def defined? (macro (_ tokens lux) @@ -217,10 +217,10 @@ right template]) (when (..split_by pattern right) {.#Some [pre post]} - (again (all "lux text concat" left pre replacement) post) + (again (all .text_composite# left pre replacement) post) {.#None} - ("lux text concat" left right)))] + (.text_composite# left right)))] (for @.old (as Text ("jvm invokevirtual:java.lang.String:replace:java.lang.CharSequence,java.lang.CharSequence" @@ -261,7 +261,7 @@ (Equivalence Text) (implementation (def (= reference sample) - ("lux text =" reference sample)))) + (.text_=# reference sample)))) (def .public order (Order Text) @@ -269,7 +269,7 @@ (def equivalence ..equivalence) (def (< reference sample) - ("lux text <" reference sample)))) + (.text_<# reference sample)))) (def .public monoid (Monoid Text) @@ -277,7 +277,7 @@ (def identity "") (def (composite left right) - ("lux text concat" left right)))) + (.text_composite# left right)))) (def .public hash (Hash Text) @@ -301,7 +301,7 @@ (is (Primitive "java.lang.Long")) (as Nat)) ... Platform-independent default. - (let [length ("lux text size" input)] + (let [length (.text_size# input)] (loop (again [index 0 hash 0]) (if (n.< length index) @@ -309,7 +309,7 @@ (|> hash (i64.left_shifted 5) (n.- hash) - (n.+ ("lux text char" index input)))) + (n.+ (.text_char# index input)))) hash))))))) (def .public together diff --git a/stdlib/source/library/lux/data/text/escape.lux b/stdlib/source/library/lux/data/text/escape.lux index b09ae72c7..46e2ca8e2 100644 --- a/stdlib/source/library/lux/data/text/escape.lux +++ b/stdlib/source/library/lux/data/text/escape.lux @@ -88,16 +88,16 @@ (let [post_offset (++ pre_offset) post_limit (n.- post_offset pre_limit)] [(format previous - ("lux text clip" 0 pre_offset current) + (.text_clip# 0 pre_offset current) replacement) - ("lux text clip" post_offset post_limit current) + (.text_clip# post_offset post_limit current) post_limit])) (def (unicode_escaped char pre_offset pre_limit previous current) (-> Char Nat Nat Text Text [Text Text Nat]) (let [code (at n.hex encoded char) replacement (format ..sigil "u" - (when ("lux text size" code) + (when (.text_size# code) 1 (format "000" code) 2 (format "00" code) 3 (format "0" code) @@ -105,9 +105,9 @@ post_offset (++ pre_offset) post_limit (n.- post_offset pre_limit)] [(format previous - ("lux text clip" 0 pre_offset current) + (.text_clip# 0 pre_offset current) replacement) - ("lux text clip" post_offset post_limit current) + (.text_clip# post_offset post_limit current) post_limit])) (def .public (escaped text) @@ -115,9 +115,9 @@ (loop (again [offset 0 previous "" current text - limit ("lux text size" text)]) + limit (.text_size# text)]) (if (n.< limit offset) - (when ("lux text char" offset current) + (when (.text_char# offset current) (^.with_template [<char> <replacement>] [<char> (let [[previous' current' limit'] (ascii_escaped <replacement> offset limit previous current)] @@ -173,22 +173,22 @@ (-> Text Nat Text Text Nat [Text Text Nat]) (let [limit' (|> limit (n.- offset) (n.- ..ascii_escape_offset))] [(format previous - ("lux text clip" 0 offset current) + (.text_clip# 0 offset current) replacement) - ("lux text clip" (n.+ ..ascii_escape_offset offset) limit' current) + (.text_clip# (n.+ ..ascii_escape_offset offset) limit' current) limit'])) (def (unicode_un_escaped offset previous current limit) (-> Nat Text Text Nat (Try [Text Text Nat])) (when (|> current - ("lux text clip" (n.+ ..ascii_escape_offset offset) ..code_size) + (.text_clip# (n.+ ..ascii_escape_offset offset) ..code_size) (at n.hex decoded)) {try.#Success char} (let [limit' (|> limit (n.- offset) (n.- ..unicode_escape_offset))] {try.#Success [(format previous - ("lux text clip" 0 offset current) + (.text_clip# 0 offset current) (//.of_char char)) - ("lux text clip" (n.+ ..unicode_escape_offset offset) limit' current) + (.text_clip# (n.+ ..unicode_escape_offset offset) limit' current) limit']}) {try.#Failure error} @@ -199,13 +199,13 @@ (loop (again [offset 0 previous "" current text - limit ("lux text size" text)]) + limit (.text_size# text)]) (if (n.< limit offset) - (when ("lux text char" offset current) + (when (.text_char# offset current) ..sigil_char (let [@sigil (++ offset)] (if (n.< limit @sigil) - (when ("lux text char" @sigil current) + (when (.text_char# @sigil current) (^.with_template [<sigil> <un_escaped>] [<sigil> (let [[previous' current' limit'] (..ascii_un_escaped <un_escaped> offset previous current limit)] diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index c5f95dae2..09d379e8c 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -527,13 +527,13 @@ (def .public private (syntax (_ [definition <code>.symbol]) (let [[module _] definition] - (in (list (` ("lux in-module" + (in (list (` (.in_module# (, (code.text module)) (, (code.symbol definition))))))))) -(def .public (log! message) +(def .public log! (-> Text Any) - ("lux io log" message)) + (|>> .log#)) (exception.def .public (type_hole [location type]) (Exception [Location Type]) @@ -591,7 +591,7 @@ (in [name format]) (function.constant (exception.except ..unknown_local_binding [name])))) targets)))] - (in (list (` (..log! ("lux text concat" + (in (list (` (..log! (.text_composite# (, (code.text (%.format (%.location location) text.new_line))) (exception.report (.list (,* (|> targets diff --git a/stdlib/source/library/lux/documentation.lux b/stdlib/source/library/lux/documentation.lux index 38ef6aa3f..2d71738d0 100644 --- a/stdlib/source/library/lux/documentation.lux +++ b/stdlib/source/library/lux/documentation.lux @@ -506,7 +506,7 @@ _ (` ((, g!name) (,* (list#each code.local parameters)))))))))) ... Type - (let [(, g!type) ("lux in-module" + (let [(, g!type) (.in_module# (, g!module) (.type_of (, (code.symbol name))))] (md.code "clojure" diff --git a/stdlib/source/library/lux/ffi.php.lux b/stdlib/source/library/lux/ffi.php.lux index 1eea0f3a0..796e8d887 100644 --- a/stdlib/source/library/lux/ffi.php.lux +++ b/stdlib/source/library/lux/ffi.php.lux @@ -186,16 +186,6 @@ ..constant )) -(def .public try - (syntax (_ [expression <code>.any]) - ... {.#doc (example (when (try (risky_computation input)) - ... {.#Right success} - ... (do_something success) - - ... {.#Left error} - ... (recover_from_failure error)))} - (in (list (` ("lux try" (io.io (, expression)))))))) - (def (with_io with? without) (-> Bit Code Code) (if with? diff --git a/stdlib/source/library/lux/ffi.scm.lux b/stdlib/source/library/lux/ffi.scm.lux index 434926adc..4c57af516 100644 --- a/stdlib/source/library/lux/ffi.scm.lux +++ b/stdlib/source/library/lux/ffi.scm.lux @@ -151,16 +151,6 @@ ..constant )) -(def .public try - (syntax (_ [expression <code>.any]) - ... {.#doc (example (when (try (risky_computation input)) - ... {.#Right success} - ... (do_something success) - - ... {.#Left error} - ... (recover_from_failure error)))} - (in (list (` ("lux try" (io.io (, expression)))))))) - (def (with_io with? without) (-> Bit Code Code) (if with? diff --git a/stdlib/source/library/lux/math.lux b/stdlib/source/library/lux/math.lux index 6e864d421..f5b4ec12a 100644 --- a/stdlib/source/library/lux/math.lux +++ b/stdlib/source/library/lux/math.lux @@ -46,9 +46,9 @@ (def (composite phase archive <+> last prevs) (-> Phase Archive Code Analysis (List Analysis) (Operation Analysis)) (when <+> - [_ {.#Text $}] + [_ {.#Symbol [.prelude $]}] (phase#in (list#mix (function (_ left right) - {analysis.#Extension ["" $] (list left right)}) + {analysis.#Extension [.prelude $] (list left right)}) last prevs)) @@ -108,28 +108,28 @@ ... else (phase.except ..no_arithmetic_for [:it:]))))))))))] - [+ [[.Nat (in (analysis.nat 0)) "lux i64 +"] - [.Int (in (analysis.int +0)) "lux i64 +"] - [.Rev (in (analysis.rev .0)) "lux i64 +"] - [.Frac (in (analysis.frac +0.0)) "lux f64 +"] + [+ [[.Nat (in (analysis.nat 0)) .i64_+#|generation] + [.Int (in (analysis.int +0)) .i64_+#|generation] + [.Rev (in (analysis.rev .0)) .i64_+#|generation] + [.Frac (in (analysis.frac +0.0)) .f64_+#|generation] [Ratio (type.expecting Ratio (phase archive (` <ratio/0>))) ratio.+] [Complex (type.expecting Complex (phase archive (` <complex/0>))) complex.+]]] - [- [[.Nat (in (analysis.nat 0)) "lux i64 -"] - [.Int (in (analysis.int -0)) "lux i64 -"] - [.Rev (in (analysis.rev .0)) "lux i64 -"] - [.Frac (in (analysis.frac -0.0)) "lux f64 -"] + [- [[.Nat (in (analysis.nat 0)) .i64_-#|generation] + [.Int (in (analysis.int -0)) .i64_-#|generation] + [.Rev (in (analysis.rev .0)) .i64_-#|generation] + [.Frac (in (analysis.frac -0.0)) .f64_-#|generation] [Ratio (type.expecting Ratio (phase archive (` <ratio/0>))) ratio.-] [Complex (type.expecting Complex (phase archive (` <complex/0>))) complex.-]]] [* [[.Nat (in (analysis.nat 1)) nat.*] - [.Int (in (analysis.int +1)) "lux i64 *"] + [.Int (in (analysis.int +1)) .int_*#|generation] [.Rev (in (analysis.rev rev./1)) rev.*] - [.Frac (in (analysis.frac +1.0)) "lux f64 *"] + [.Frac (in (analysis.frac +1.0)) .f64_*#|generation] [Ratio (type.expecting Ratio (phase archive (` <ratio/1>))) ratio.*] [Complex (type.expecting Complex (phase archive (` <complex/1>))) complex.*]]] [/ [[.Nat (in (analysis.nat 1)) nat./] - [.Int (in (analysis.int +1)) "lux i64 /"] + [.Int (in (analysis.int +1)) .int_/#|generation] [.Rev (in (analysis.rev rev./1)) rev./] - [.Frac (in (analysis.frac +1.0)) "lux f64 /"] + [.Frac (in (analysis.frac +1.0)) .f64_/#|generation] [Ratio (type.expecting Ratio (phase archive (` <ratio/1>))) ratio./] [Complex (type.expecting Complex (phase archive (` <complex/1>))) complex./]]] ) @@ -158,16 +158,16 @@ ... else (phase.except ..no_arithmetic_for [:it:])))))))))] - [= [[.Nat "lux i64 ="] - [.Int "lux i64 ="] - [.Rev "lux i64 ="] - [.Frac "lux f64 ="] + [= [[.Nat .i64_=#|generation] + [.Int .i64_=#|generation] + [.Rev .i64_=#|generation] + [.Frac .f64_=#|generation] [Ratio ratio.=] [Complex complex.=]]] [< [[.Nat nat.<] - [.Int "lux i64 <"] + [.Int .int_<#|generation] [.Rev rev.<] - [.Frac "lux f64 <"] + [.Frac .f64_<#|generation] [Ratio ratio.<]]] [> [[.Nat nat.>] [.Int int.>] @@ -211,9 +211,9 @@ (phase.except ..no_arithmetic_for [:it:])))))))))] [% [[.Nat nat.%] - [.Int "lux i64 %"] + [.Int .int_%#|generation] [.Rev rev.%] - [.Frac "lux f64 %"] + [.Frac .f64_%#|generation] [Ratio ratio.%] [Complex complex.%]]] ) diff --git a/stdlib/source/library/lux/math/number.lux b/stdlib/source/library/lux/math/number.lux index b31167dc9..d145556c8 100644 --- a/stdlib/source/library/lux/math/number.lux +++ b/stdlib/source/library/lux/math/number.lux @@ -21,7 +21,7 @@ (def (separator_prefixed? number) (-> Text Bit) - (when ("lux text index" 0 ..separator number) + (when (.text_index# 0 ..separator number) {.#Some 0} true diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux index 1cbe2d535..80eacae5d 100644 --- a/stdlib/source/library/lux/math/number/frac.lux +++ b/stdlib/source/library/lux/math/number/frac.lux @@ -168,13 +168,13 @@ (def .public (root_3 it) (-> Frac Frac) - (if ("lux f64 <" +0.0 it) + (if (.f64_<# +0.0 it) (|> it - ("lux f64 *" -1.0) - (..pow ("lux f64 /" +3.0 +1.0)) - ("lux f64 *" -1.0)) + (.f64_*# -1.0) + (..pow (.f64_/# +3.0 +1.0)) + (.f64_*# -1.0)) (|> it - (..pow ("lux f64 /" +3.0 +1.0)))))) + (..pow (.f64_/# +3.0 +1.0)))))) @.lua (these (with_template [<name> <method>] @@ -207,13 +207,13 @@ (def .public (root_3 it) (-> Frac Frac) - (if ("lux f64 <" +0.0 it) + (if (.f64_<# +0.0 it) (|> it - ("lux f64 *" -1.0) - (..pow ("lux f64 /" +3.0 +1.0)) - ("lux f64 *" -1.0)) + (.f64_*# -1.0) + (..pow (.f64_/# +3.0 +1.0)) + (.f64_*# -1.0)) (|> it - (..pow ("lux f64 /" +3.0 +1.0)))))) + (..pow (.f64_/# +3.0 +1.0)))))) @.ruby (these (with_template [<name> <method>] @@ -243,7 +243,7 @@ (-> Frac Frac) (|> ("ruby object do" <method> it []) (as Int) - ("lux i64 f64")))] + (.int_f64#)))] [ceil "ceil"] [floor "floor"] @@ -283,7 +283,7 @@ (def .public root_3 (-> Frac Frac) - (..pow ("lux f64 /" +3.0 +1.0)))) + (..pow (.f64_/# +3.0 +1.0)))) @.scheme (these (with_template [<name> <method>] @@ -315,48 +315,47 @@ (def .public root_3 (-> Frac Frac) - (..pow ("lux f64 /" +3.0 +1.0)))) + (..pow (.f64_/# +3.0 +1.0)))) ) (def .public (round it) (-> Frac Frac) (let [floored (floor it) - diff ("lux f64 -" floored it)] - (cond ("lux f64 <" diff +0.5) - ("lux f64 +" +1.0 floored) + diff (.f64_-# floored it)] + (cond (.f64_<# diff +0.5) + (.f64_+# +1.0 floored) - ("lux f64 <" -0.5 diff) - ("lux f64 +" -1.0 floored) + (.f64_<# -0.5 diff) + (.f64_+# -1.0 floored) ... else floored))) (def .public (atan_2 x y) (-> Frac Frac Frac) - (cond ("lux f64 <" x +0.0) - (..atan ("lux f64 /" x y)) - - ("lux f64 <" +0.0 x) - (if (or ("lux f64 <" y +0.0) - ("lux f64 =" +0.0 y)) - (|> y ("lux f64 /" x) atan ("lux f64 +" pi)) - (|> y ("lux f64 /" x) atan ("lux f64 -" pi))) - - ... ("lux f64 =" +0.0 x) - (cond ("lux f64 <" y +0.0) - (|> pi ("lux f64 /" +2.0)) + (cond (.f64_<# x +0.0) + (..atan (.f64_/# x y)) + + (.f64_<# +0.0 x) + (if (or (.f64_<# y +0.0) + (.f64_=# +0.0 y)) + (|> y (.f64_/# x) atan (.f64_+# pi)) + (|> y (.f64_/# x) atan (.f64_-# pi))) + + ... (.f64_=# +0.0 x) + (cond (.f64_<# y +0.0) + (|> pi (.f64_/# +2.0)) - ("lux f64 <" +0.0 y) - (|> pi ("lux f64 /" -2.0)) + (.f64_<# +0.0 y) + (|> pi (.f64_/# -2.0)) - ... ("lux f64 =" +0.0 y) - ("lux f64 /" +0.0 +0.0)))) + ... (.f64_=# +0.0 y) + (.f64_/# +0.0 +0.0)))) (def .public (log_by base it) (-> Frac Frac Frac) - ("lux f64 /" - (..log base) - (..log it))) + (.f64_/# (..log base) + (..log it))) (def .public (factorial it) (-> Nat Nat) @@ -368,33 +367,32 @@ (def .public (hypotenuse catA catB) (-> Frac Frac Frac) - (..pow +0.5 ("lux f64 +" - (..pow +2.0 catA) - (..pow +2.0 catB)))) + (..pow +0.5 (.f64_+# (..pow +2.0 catA) + (..pow +2.0 catB)))) ... Hyperbolic functions ... https://en.wikipedia.org/wiki/Hyperbolic_function#Definitions (with_template [<name> <comp> <inverse>] [(def .public (<name> it) (-> Frac Frac) - (|> (..exp it) (<comp> (..exp ("lux f64 *" -1.0 it))) ("lux f64 /" +2.0))) + (|> (..exp it) (<comp> (..exp (.f64_*# -1.0 it))) (.f64_/# +2.0))) (def .public (<inverse> it) (-> Frac Frac) - (|> +2.0 ("lux f64 /" (|> (..exp it) (<comp> (..exp ("lux f64 *" -1.0 it)))))))] + (|> +2.0 (.f64_/# (|> (..exp it) (<comp> (..exp (.f64_*# -1.0 it)))))))] - [sinh "lux f64 -" csch] - [cosh "lux f64 +" sech] + [sinh .f64_-# csch] + [cosh .f64_+# sech] ) (with_template [<name> <top> <bottom>] [(def .public (<name> it) (-> Frac Frac) (let [e+ (exp it) - e- (exp ("lux f64 *" -1.0 it)) - sinh' (|> e+ ("lux f64 -" e-)) - cosh' (|> e+ ("lux f64 +" e-))] - (|> <top> ("lux f64 /" <bottom>))))] + e- (exp (.f64_*# -1.0 it)) + sinh' (|> e+ (.f64_-# e-)) + cosh' (|> e+ (.f64_+# e-))] + (|> <top> (.f64_/# <bottom>))))] [tanh sinh' cosh'] [coth cosh' sinh'] @@ -404,18 +402,18 @@ (with_template [<name> <comp>] [(def .public (<name> it) (-> Frac Frac) - (|> it (pow +2.0) (<comp> +1.0) (pow +0.5) ("lux f64 +" it) log))] + (|> it (pow +2.0) (<comp> +1.0) (pow +0.5) (.f64_+# it) log))] - [asinh "lux f64 +"] - [acosh "lux f64 -"] + [asinh .f64_+#] + [acosh .f64_-#] ) (with_template [<name> <base> <diff>] [(def .public (<name> it) (-> Frac Frac) - (let [it+ (|> <base> ("lux f64 +" <diff>)) - it- (|> <base> ("lux f64 -" <diff>))] - (|> it+ ("lux f64 /" it-) log ("lux f64 /" +2.0))))] + (let [it+ (|> <base> (.f64_+# <diff>)) + it- (|> <base> (.f64_-# <diff>))] + (|> it+ (.f64_/# it-) log (.f64_/# +2.0))))] [atanh +1.0 it] [acoth it +1.0] @@ -425,10 +423,10 @@ [(def .public (<name> it) (-> Frac Frac) (let [it^2 (|> it (pow +2.0))] - (|> +1.0 (<op> it^2) (pow +0.5) ("lux f64 +" +1.0) ("lux f64 /" it) log)))] + (|> +1.0 (<op> it^2) (pow +0.5) (.f64_+# +1.0) (.f64_/# it) log)))] - [asech "lux f64 -"] - [acsch "lux f64 +"] + [asech .f64_-#] + [acsch .f64_+#] ) (with_template [<name> <op>] @@ -436,23 +434,23 @@ (-> Frac Frac Bit) (<op> param subject))] - [= "lux f64 ="] - [< "lux f64 <"] + [= .f64_=#] + [< .f64_<#] ) (def .public (<= reference sample) (-> Frac Frac Bit) - (or ("lux f64 <" reference sample) - ("lux f64 =" reference sample))) + (or (.f64_<# reference sample) + (.f64_=# reference sample))) (def .public (> reference sample) (-> Frac Frac Bit) - ("lux f64 <" sample reference)) + (.f64_<# sample reference)) (def .public (>= reference sample) (-> Frac Frac Bit) - (or ("lux f64 <" sample reference) - ("lux f64 =" sample reference))) + (or (.f64_<# sample reference) + (.f64_=# sample reference))) (with_template [<comparison> <name>] [(def .public <name> @@ -469,11 +467,11 @@ (-> Frac Frac Frac) (<op> param subject))] - [+ "lux f64 +"] - [- "lux f64 -"] - [* "lux f64 *"] - [/ "lux f64 /"] - [% "lux f64 %"] + [+ .f64_+#] + [- .f64_-#] + [* .f64_*#] + [/ .f64_/#] + [% .f64_%#] ) (def .public (/% param subject) @@ -514,27 +512,27 @@ (def .public nat (-> Frac Nat) - (|>> "lux f64 i64" .nat)) + (|>> .f64_int# .nat)) (def .public int (-> Frac Int) - (|>> "lux f64 i64")) + (|>> .f64_int#)) (def mantissa_size Nat 52) (def exponent_size Nat 11) (def frac_denominator (|> -1 - ("lux i64 right-shift" ..exponent_size) - "lux i64 f64")) + (.i64_right# ..exponent_size) + .int_f64#)) (def .public rev (-> Frac Rev) (|>> ..abs (..% +1.0) (..* ..frac_denominator) - "lux f64 i64" - ("lux i64 left-shift" ..exponent_size))) + .f64_int# + (.i64_left# ..exponent_size))) (with_template [<name> <numerator>] [(def .public <name> @@ -604,16 +602,16 @@ (implementation (def (encoded x) (when x - -0.0 (let [output ("lux f64 encode" x)] + -0.0 (let [output (.f64_encoded# x)] (if (text.starts_with? "-" output) output - ("lux text concat" "+" output))) + (.text_composite# "+" output))) _ (if (..< +0.0 x) - ("lux f64 encode" x) - ("lux text concat" "+" ("lux f64 encode" x))))) + (.f64_encoded# x) + (.text_composite# "+" (.f64_encoded# x))))) (def (decoded input) - (when ("lux f64 decode" input) + (when (.f64_decoded# input) {.#Some value} {try.#Success value} @@ -754,19 +752,19 @@ (`` (def (representation_exponent codec representation) (-> (Codec Text Nat) Text (Try [Text Int])) - (when [("lux text index" 0 "e+" representation) - ("lux text index" 0 "E+" representation) - ("lux text index" 0 "e-" representation) - ("lux text index" 0 "E-" representation)] + (when [(.text_index# 0 "e+" representation) + (.text_index# 0 "E+" representation) + (.text_index# 0 "e-" representation) + (.text_index# 0 "E-" representation)] (,, (with_template [<factor> <pattern>] [<pattern> (do try.monad [.let [after_offset (//nat.+ 2 split_index) - after_length (//nat.- after_offset ("lux text size" representation))] + after_length (//nat.- after_offset (.text_size# representation))] exponent (|> representation - ("lux text clip" after_offset after_length) + (.text_clip# after_offset after_length) (at codec decoded))] - (in [("lux text clip" 0 split_index representation) + (in [(.text_clip# 0 split_index representation) (//int.* <factor> (.int exponent))]))] [+1 [{.#Some split_index} {.#None} {.#None} {.#None}]] @@ -787,7 +785,7 @@ mantissa (..mantissa bits) exponent (//int.- (.int ..double_bias) (..exponent bits)) sign (..sign bits)] - (all "lux text concat" + (all .text_composite# (when (.nat sign) 1 "-" 0 "+" @@ -802,30 +800,30 @@ (if (or negative? positive?) (do [! try.monad] [[mantissa exponent] (..representation_exponent <nat> representation) - [whole decimal] (when ("lux text index" 0 "." mantissa) + [whole decimal] (when (.text_index# 0 "." mantissa) {.#Some split_index} (do ! [.let [after_offset (++ split_index) - after_length (//nat.- after_offset ("lux text size" mantissa))] + after_length (//nat.- after_offset (.text_size# mantissa))] decimal (|> mantissa - ("lux text clip" after_offset after_length) + (.text_clip# after_offset after_length) (at <nat> decoded))] - (in [("lux text clip" 0 split_index mantissa) + (in [(.text_clip# 0 split_index mantissa) decimal])) {.#None} - {try.#Failure ("lux text concat" <error> representation)}) - .let [whole ("lux text clip" 1 (-- ("lux text size" whole)) whole)] + {try.#Failure (.text_composite# <error> representation)}) + .let [whole (.text_clip# 1 (-- (.text_size# whole)) whole)] mantissa (at <nat> decoded (when decimal 0 whole - _ ("lux text concat" whole (at <nat> encoded decimal)))) + _ (.text_composite# whole (at <nat> encoded decimal)))) .let [sign (if negative? 1 0)]] (in (..of_bits (all //i64.or (//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 (.text_composite# <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/i64.lux b/stdlib/source/library/lux/math/number/i64.lux index 9a1077f88..8baa67ee5 100644 --- a/stdlib/source/library/lux/math/number/i64.lux +++ b/stdlib/source/library/lux/math/number/i64.lux @@ -26,12 +26,12 @@ (All (_ s) (-> <parameter_type> (I64 s) (I64 s))) (<op> parameter subject))] - [(I64 Any) or "lux i64 or"] - [(I64 Any) xor "lux i64 xor"] - [(I64 Any) and "lux i64 and"] + [(I64 Any) or .i64_or#] + [(I64 Any) xor .i64_xor#] + [(I64 Any) and .i64_and#] - [Nat left_shifted "lux i64 left-shift"] - [Nat right_shifted "lux i64 right-shift"] + [Nat left_shifted .i64_left#] + [Nat right_shifted .i64_right#] ) ... https://en.wikipedia.org/wiki/Mask_(computing) @@ -121,7 +121,7 @@ (All (_ a) (Equivalence (I64 a))) (implementation (def (= reference sample) - ("lux i64 =" reference sample)))) + (.i64_=# reference sample)))) (def .public hash (All (_ a) (Hash (I64 a))) @@ -152,10 +152,10 @@ output char]) (if (n.< times iterations) (again (++ iterations) - ("lux text concat" char output)) + (.text_composite# char output)) output)))) pattern (repetitions (n./ (n.+ size size) ..width) - ("lux text concat" + (.text_composite# (repetitions size "1") (repetitions size "0"))) diff --git a/stdlib/source/library/lux/math/number/int.lux b/stdlib/source/library/lux/math/number/int.lux index c51ed91bd..711e36c8f 100644 --- a/stdlib/source/library/lux/math/number/int.lux +++ b/stdlib/source/library/lux/math/number/int.lux @@ -25,25 +25,25 @@ (-> Int Int Bit) (<op> param subject))] - [= "lux i64 ="] - [< "lux i64 <"] + [= .i64_=#] + [< .int_<#] ) (def .public (<= reference sample) (-> Int Int Bit) - (if ("lux i64 <" reference sample) + (if (.int_<# reference sample) true - ("lux i64 =" reference sample))) + (.i64_=# reference sample))) (def .public (> reference sample) (-> Int Int Bit) - ("lux i64 <" sample reference)) + (.int_<# sample reference)) (def .public (>= reference sample) (-> Int Int Bit) - (if ("lux i64 <" sample reference) + (if (.int_<# sample reference) true - ("lux i64 =" reference sample))) + (.i64_=# reference sample))) (with_template [<comparison> <name>] [(def .public <name> @@ -71,11 +71,11 @@ (-> Int Int Int) (<op> param subject))] - [+ "lux i64 +"] - [- "lux i64 -"] - [* "lux i64 *"] - [/ "lux i64 /"] - [% "lux i64 %"] + [+ .i64_+#] + [- .i64_-#] + [* .int_*#] + [/ .int_/#] + [% .int_%#] ) (def .public (/% param subject) @@ -113,7 +113,7 @@ (def .public even? (-> Int Bit) - (|>> (..% +2) ("lux i64 =" +0))) + (|>> (..% +2) (.i64_=# +0))) (def .public odd? (-> Int Bit) @@ -159,7 +159,7 @@ (def .public frac (-> Int Frac) - (|>> "lux i64 f64")) + (|>> .int_f64#)) (def .public equivalence (Equivalence Int) @@ -215,22 +215,22 @@ (implementation (def (encoded value) (if (..< +0 value) - (|> value ++ ..opposite .nat ++ (at <codec> encoded) ("lux text concat" ..-sign)) - (|> value .nat (at <codec> encoded) ("lux text concat" ..+sign)))) + (|> value ++ ..opposite .nat ++ (at <codec> encoded) (.text_composite# ..-sign)) + (|> value .nat (at <codec> encoded) (.text_composite# ..+sign)))) (def (decoded repr) - (let [input_size ("lux text size" repr)] + (let [input_size (.text_size# repr)] (if (//nat.> 1 input_size) - (when ("lux text clip" 0 1 repr) + (when (.text_clip# 0 1 repr) ..+sign (|> repr - ("lux text clip" 1 (-- input_size)) + (.text_clip# 1 (-- input_size)) (at <codec> decoded) (at try.functor each (|>> .int))) ..-sign (|> repr - ("lux text clip" 1 (-- input_size)) + (.text_clip# 1 (-- input_size)) (at <codec> decoded) (at try.functor each (|>> -- .int ..opposite --))) diff --git a/stdlib/source/library/lux/math/number/nat.lux b/stdlib/source/library/lux/math/number/nat.lux index f5fd924d5..4b8366218 100644 --- a/stdlib/source/library/lux/math/number/nat.lux +++ b/stdlib/source/library/lux/math/number/nat.lux @@ -19,28 +19,28 @@ (-> Nat Nat <output>) (<extension> parameter subject))] - ["lux i64 =" Bit =] - ["lux i64 +" Nat +] - ["lux i64 -" Nat -] + [.i64_=# Bit =] + [.i64_+# Nat +] + [.i64_-# Nat -] ) (def high (-> (I64 Any) I64) - (|>> ("lux i64 right-shift" 32))) + (|>> (.i64_right# 32))) (def low (-> (I64 Any) I64) - (let [mask (|> 1 ("lux i64 left-shift" 32) ("lux i64 -" 1))] - (|>> ("lux i64 and" mask)))) + (let [mask (|> 1 (.i64_left# 32) (.i64_-# 1))] + (|>> (.i64_and# mask)))) (def .public (< reference sample) (-> Nat Nat Bit) (let [referenceH (..high reference) sampleH (..high sample)] - (if ("lux i64 <" referenceH sampleH) + (if (.int_<# referenceH sampleH) true - (if ("lux i64 =" referenceH sampleH) - ("lux i64 <" + (if (.i64_=# referenceH sampleH) + (.int_<# (..low reference) (..low sample)) false)))) @@ -48,7 +48,7 @@ (def .public (<= reference sample) (-> Nat Nat Bit) (or (..< reference sample) - ("lux i64 =" reference sample))) + (.i64_=# reference sample))) (def .public (> reference sample) (-> Nat Nat Bit) @@ -57,7 +57,7 @@ (def .public (>= reference sample) (-> Nat Nat Bit) (or (..< sample reference) - ("lux i64 =" reference sample))) + (.i64_=# reference sample))) (with_template [<name> <test>] [(def .public (<name> left right) @@ -72,42 +72,38 @@ (def .public (* parameter subject) (-> Nat Nat Nat) - (.nat ("lux i64 *" - (.int parameter) - (.int subject)))) + (.nat (.int_*# (.int parameter) + (.int subject)))) (def .public (/ parameter subject) (-> Nat Nat Nat) - (if ("lux i64 <" +0 (.int parameter)) + (if (.int_<# +0 (.int parameter)) (if (..< parameter subject) 0 1) (let [quotient (|> subject - ("lux i64 right-shift" 1) - ("lux i64 /" (.int parameter)) - ("lux i64 left-shift" 1)) - flat ("lux i64 *" - (.int parameter) - (.int quotient)) - remainder ("lux i64 -" flat subject)] + (.i64_right# 1) + (.int_/# (.int parameter)) + (.i64_left# 1)) + flat (.int_*# (.int parameter) + (.int quotient)) + remainder (.i64_-# flat subject)] (if (..< parameter remainder) quotient - ("lux i64 +" 1 quotient))))) + (.i64_+# 1 quotient))))) (def .public (/% parameter subject) (-> Nat Nat [Nat Nat]) (let [quotient (../ parameter subject) - flat ("lux i64 *" - (.int parameter) - (.int quotient))] - [quotient ("lux i64 -" flat subject)])) + flat (.int_*# (.int parameter) + (.int quotient))] + [quotient (.i64_-# flat subject)])) (def .public (% parameter subject) (-> Nat Nat Nat) - (let [flat ("lux i64 *" - (.int parameter) - (.int (../ parameter subject)))] - ("lux i64 -" flat subject))) + (let [flat (.int_*# (.int parameter) + (.int (../ parameter subject)))] + (.i64_-# flat subject))) (def .public (gcd a b) (-> Nat Nat Nat) @@ -134,7 +130,7 @@ (def .public even? (-> Nat Bit) - (|>> (..% 2) ("lux i64 =" 0))) + (|>> (..% 2) (.i64_=# 0))) (def .public odd? (-> Nat Bit) @@ -142,7 +138,7 @@ (def .public frac (-> Nat Frac) - (|>> .int "lux i64 f64")) + (|>> .int .int_f64#)) (def .public equivalence (Equivalence Nat) @@ -301,14 +297,14 @@ (Codec Text Nat) (implementation (def encoded - (let [mask (|> 1 ("lux i64 left-shift" <shift>) --)] + (let [mask (|> 1 (.i64_left# <shift>) --)] (function (_ value) (loop (again [input value output ""]) - (let [output' ("lux text concat" - (<to_character> ("lux i64 and" mask input)) + (let [output' (.text_composite# + (<to_character> (.i64_and# mask input)) output)] - (when (is Nat ("lux i64 right-shift" <shift> input)) + (when (is Nat (.i64_right# <shift> input)) 0 output' @@ -316,22 +312,22 @@ (again input' output'))))))) (def (decoded repr) - (let [input_size ("lux text size" repr)] + (let [input_size (.text_size# repr)] (if (..> 0 input_size) (loop (again [idx 0 output 0]) (if (..< input_size idx) - (when (<to_value> ("lux text char" idx repr)) + (when (<to_value> (.text_char# idx repr)) {.#Some digit_value} (again (++ idx) (|> output - ("lux i64 left-shift" <shift>) - ("lux i64 or" digit_value))) + (.i64_left# <shift>) + (.i64_or# digit_value))) _ - {try.#Failure ("lux text concat" <error> repr)}) + {try.#Failure (.text_composite# <error> repr)}) {try.#Success output})) - {try.#Failure ("lux text concat" <error> repr)})))))] + {try.#Failure (.text_composite# <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,7 +341,7 @@ (loop (again [input value output ""]) (let [digit (decimal_character (..% 10 input)) - output' ("lux text concat" digit output)] + output' (.text_composite# digit output)] (when (../ 10 input) 0 output' @@ -354,13 +350,13 @@ (again input' output'))))) (def (decoded repr) - (let [input_size ("lux text size" repr)] - (with_expansions [<failure> {try.#Failure ("lux text concat" "Invalid decimal syntax for Nat: " repr)}] + (let [input_size (.text_size# repr)] + (with_expansions [<failure> {try.#Failure (.text_composite# "Invalid decimal syntax for Nat: " repr)}] (if (..> 0 input_size) (loop (again [idx 0 output 0]) (if (..< input_size idx) - (when (decimal_value ("lux text char" idx repr)) + (when (decimal_value (.text_char# idx repr)) {.#None} <failure> diff --git a/stdlib/source/library/lux/math/number/rev.lux b/stdlib/source/library/lux/math/number/rev.lux index a1b8e14ed..4704d7c8a 100644 --- a/stdlib/source/library/lux/math/number/rev.lux +++ b/stdlib/source/library/lux/math/number/rev.lux @@ -45,7 +45,7 @@ (def .public (= reference sample) (-> Rev Rev Bit) - ("lux i64 =" reference sample)) + (.i64_=# reference sample)) (def .public (< reference sample) (-> Rev Rev Bit) @@ -54,7 +54,7 @@ (def .public (<= reference sample) (-> Rev Rev Bit) (or (//nat.< (.nat reference) (.nat sample)) - ("lux i64 =" reference sample))) + (.i64_=# reference sample))) (def .public (> reference sample) (-> Rev Rev Bit) @@ -63,7 +63,7 @@ (def .public (>= reference sample) (-> Rev Rev Bit) (or (..< sample reference) - ("lux i64 =" reference sample))) + (.i64_=# reference sample))) (with_template [<name> <test>] [(def .public (<name> left right) @@ -81,18 +81,18 @@ (-> Rev Rev Rev) (<op> param subject))] - [+ "lux i64 +"] - [- "lux i64 -"] + [+ .i64_+#] + [- .i64_-#] ) (def high (-> (I64 Any) I64) - (|>> ("lux i64 right-shift" 32))) + (|>> (.i64_right# 32))) (def low (-> (I64 Any) I64) - (let [mask (|> 1 ("lux i64 left-shift" 32) ("lux i64 -" 1))] - (|>> ("lux i64 and" mask)))) + (let [mask (|> 1 (.i64_left# 32) (.i64_-# 1))] + (|>> (.i64_and# mask)))) (def .public (* param subject) (-> Rev Rev Rev) @@ -101,16 +101,15 @@ paramH (..high param) paramL (..low param) bottom (|> subjectL - ("lux i64 *" paramL) - ("lux i64 right-shift" 32)) - middle ("lux i64 +" - ("lux i64 *" paramL subjectH) - ("lux i64 *" paramH subjectL)) - top ("lux i64 *" subjectH paramH)] + (.int_*# paramL) + (.i64_right# 32)) + middle (.i64_+# (.int_*# paramL subjectH) + (.int_*# paramH subjectL)) + top (.int_*# subjectH paramH)] (|> bottom - ("lux i64 +" middle) + (.i64_+# middle) ..high - ("lux i64 +" top)))) + (.i64_+# top)))) (def even_one (//i64.right_rotated 1 1)) (def odd_one (-- 0)) @@ -127,15 +126,15 @@ (with_expansions [<least_significant_bit> 1] (def .public (reciprocal numerator) (-> Nat Rev) - (.rev (when (is Nat ("lux i64 and" <least_significant_bit> numerator)) + (.rev (when (is Nat (.i64_and# <least_significant_bit> numerator)) 0 (..even_reciprocal numerator) _ (..odd_reciprocal numerator)))) (def .public (/ param subject) (-> Rev Rev Rev) - (if ("lux i64 =" +0 param) + (if (.i64_=# +0 param) (panic! "Cannot divide Rev by zero!") - (let [reciprocal (when (is Nat ("lux i64 and" <least_significant_bit> param)) + (let [reciprocal (when (is Nat (.i64_and# <least_significant_bit> param)) 0 (..even_reciprocal (.nat param)) _ (..odd_reciprocal (.nat param)))] (.rev (//nat.* reciprocal (.nat subject))))))) @@ -165,15 +164,15 @@ (def mantissa (-> (I64 Any) Frac) - (|>> ("lux i64 right-shift" 11) - "lux i64 f64")) + (|>> (.i64_right# 11) + .int_f64#)) (def frac_denominator (..mantissa -1)) (def .public frac (-> Rev Frac) - (|>> ..mantissa ("lux f64 /" ..frac_denominator))) + (|>> ..mantissa (.f64_/# ..frac_denominator))) (def .public equivalence (Equivalence Rev) @@ -220,10 +219,10 @@ (def (decimals input) (-> Text Text) - ("lux text clip" 1 (-- ("lux text size" input)) input)) + (.text_clip# 1 (-- (.text_size# input)) input)) (with_template [<struct> <codec> <char_bit_size> <error>] - [(with_expansions [<failure> (these {try.#Failure ("lux text concat" <error> repr)})] + [(with_expansions [<failure> (these {try.#Failure (.text_composite# <error> repr)})] (def .public <struct> (Codec Text Rev) (implementation @@ -233,22 +232,22 @@ (when (//nat.% <char_bit_size> //i64.width) 0 0 _ 1)) - raw_size ("lux text size" raw_output) + raw_size (.text_size# raw_output) zero_padding (is Text (loop (again [zeroes_left (is Nat (//nat.- raw_size max_num_chars)) output (is Text "")]) (if (//nat.= 0 zeroes_left) output (again (-- zeroes_left) - ("lux text concat" "0" output)))))] + (.text_composite# "0" output)))))] (|> raw_output - ("lux text concat" zero_padding) - ("lux text concat" ".")))) + (.text_composite# zero_padding) + (.text_composite# ".")))) (def (decoded repr) - (let [repr_size ("lux text size" repr)] + (let [repr_size (.text_size# repr)] (if (//nat.> 1 repr_size) - (when ("lux text char" 0 repr) + (when (.text_char# 0 repr) (char ".") (when (at <codec> decoded (..decimals repr)) {try.#Success output} @@ -332,7 +331,7 @@ (again (-- idx) true output) (again (-- idx) false - ("lux text concat" + (.text_composite# (at //nat.decimal encoded digit) output))))))) @@ -353,13 +352,13 @@ (def (text_digits input) (-> Text (Maybe Digits)) - (let [length ("lux text size" input)] + (let [length (.text_size# input)] (if (//nat.> //i64.width length) {.#None} (loop (again [idx 0 output (..digits [])]) (if (//nat.< length idx) - (when ("lux text index" 0 ("lux text clip" idx 1 input) "0123456789") + (when (.text_index# 0 (.text_clip# idx 1 input) "0123456789") {.#None} {.#None} @@ -412,7 +411,7 @@ (loop (again [idx last_idx digits (..digits [])]) (if (//int.< +0 (.int idx)) - ("lux text concat" "." (..format digits)) + (.text_composite# "." (..format digits)) (if (//i64.one? idx input) (let [digits' (digits#+! (power_digits (//nat.- idx last_idx)) digits)] @@ -422,14 +421,14 @@ digits))))))) (def (decoded input) - (let [dotted? (when ("lux text index" 0 "." input) + (let [dotted? (when (.text_index# 0 "." input) {.#Some 0} true _ false) within_limits? (|> input - "lux text size" + .text_size# (//nat.<= (++ //i64.width)))] (if (and dotted? within_limits?) (when (|> input ..decimals ..text_digits) @@ -448,6 +447,6 @@ {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)})) + {try.#Failure (.text_composite# "Wrong syntax for Rev: " input)}) + {try.#Failure (.text_composite# "Wrong syntax for Rev: " input)})) ))) diff --git a/stdlib/source/library/lux/math/random.lux b/stdlib/source/library/lux/math/random.lux index 3d7b33581..7f08ef23a 100644 --- a/stdlib/source/library/lux/math/random.lux +++ b/stdlib/source/library/lux/math/random.lux @@ -123,7 +123,7 @@ [prng right] (prng [])] [prng (|> left (i64.left_shifted 32) - ("lux i64 +" right))]))) + (.i64_+# right))]))) (with_template [<name> <type> <cast>] [(def .public <name> @@ -353,7 +353,7 @@ (-> [(I64 Any) (I64 Any)] PRNG) (let [magic 6364136223846793005] (function (_ _) - [(|> seed .nat (n.* magic) ("lux i64 +" increase) [increase] pcg_32) + [(|> seed .nat (n.* magic) (.i64_+# increase) [increase] pcg_32) (let [rot (|> seed .nat (i64.right_shifted 59))] (|> seed (i64.right_shifted 18) @@ -371,7 +371,7 @@ (i64.xor s01) (i64.xor (i64.left_shifted 14 s01))) (i64.left_rotated 36 s01)])) - ("lux i64 +" s0 s1)])) + (.i64_+# s0 s1)])) ... https://en.wikipedia.org/wiki/Xorshift#Initialization ... http://xorshift.di.unimi.it/splitmix64.c diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux index c126d7c70..f1dcddff0 100644 --- a/stdlib/source/library/lux/meta.lux +++ b/stdlib/source/library/lux/meta.lux @@ -495,7 +495,7 @@ (type_definition de_aliased) {.#Definition [exported? def_type def_value]} - (let [type_code (`` ("lux in-module" (,, (static .prelude)) .type_code))] + (let [type_code (`` (.in_module# (,, (static .prelude)) .type_code))] (if (or (same? .Type def_type) (at code.equivalence = (type_code .Type) @@ -550,10 +550,10 @@ {try.#Success}))) (def type#= - (`` ("lux in-module" (,, (static .prelude)) .type#=))) + (`` (.in_module# (,, (static .prelude)) .type#=))) (def type#encoded - (`` ("lux in-module" (,, (static .prelude)) .type#encoded))) + (`` (.in_module# (,, (static .prelude)) .type#encoded))) (def .public (tags_of type_name) (-> Symbol (Meta (Maybe (List Symbol)))) diff --git a/stdlib/source/library/lux/meta/compiler/default/init.lux b/stdlib/source/library/lux/meta/compiler/default/init.lux index 07cfaf968..bebc4619d 100644 --- a/stdlib/source/library/lux/meta/compiler/default/init.lux +++ b/stdlib/source/library/lux/meta/compiler/default/init.lux @@ -100,7 +100,7 @@ (-> descriptor.Module Aliases Source (///analysis.Operation Reader)) (function (_ [bundle state]) {try.#Success [[bundle state] - (///syntax.parse current_module aliases ("lux text size" source_code))]})) + (///syntax.parse current_module aliases (text.size source_code))]})) (def (read source reader) (-> Source Reader (///analysis.Operation [Source Code])) @@ -124,17 +124,17 @@ [(///generation.Buffer declaration) Registry]) -(def with_declaration_defaults +(def with_analysis_defaults (Operation Any) (do [! ///phase.monad] [state ///phase.state _ (|> state - (the extension.#bundle) + (the [extension.#state ///declaration.#analysis ///declaration.#state extension.#bundle]) dictionary.entries (monad.each ! (function (_ [name handler]) (///declaration.lifted_analysis - (moduleA.define name {.#Default [true .Declaration handler]})))))] + (moduleA.define name {.#Default [true .Analysis handler]})))))] (in []))) (def with_generation_defaults @@ -150,13 +150,27 @@ (moduleA.define name {.#Default [true .Generation handler]})))))] (in []))) +(def with_declaration_defaults + (Operation Any) + (do [! ///phase.monad] + [state ///phase.state + _ (|> state + (the extension.#bundle) + dictionary.entries + (monad.each ! + (function (_ [name handler]) + (///declaration.lifted_analysis + (moduleA.define name {.#Default [true .Declaration handler]})))))] + (in []))) + (def (with_defaults module) (-> Text (Operation Any)) (when module .prelude (do ///phase.monad - [_ with_generation_defaults] + [_ with_analysis_defaults + _ with_generation_defaults] with_declaration_defaults) _ diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/evaluation.lux b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/evaluation.lux index 5327bb81a..03543aa35 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/evaluation.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/evaluation.lux @@ -14,7 +14,8 @@ ["[0]" dictionary (.only Dictionary)]]] [math [number - ["n" nat]]] + ["n" nat] + ["[0]" i64]]] ["[0]" meta (.only) [type (.only sharing)]]]] ["[0]" // (.only Operation) @@ -22,8 +23,8 @@ ["[1][0]" scope] [// [phase - ["[0]P" extension] ["[0]P" analysis] + ["[0]" extension] [// ["[0]" synthesis] ["[0]" generation] @@ -55,9 +56,9 @@ [exprA (<| (//type.expecting type) //scope.reset (analysis archive exprC)) - module (extensionP.lifted + module (extension.lifted meta.current_module_name) - lux (extensionP.lifted + lux (extension.lifted meta.compiler_state)] (<| phase.lifted (do try.monad @@ -74,8 +75,8 @@ .let [[evals _] (io.run! (atom.update! (dictionary.revised' @module 0 ++) ..evals)) @eval (maybe.else 0 (dictionary.value @module evals))] exprO (<| (generation.with_registry_shift (|> @module - ("lux i64 left-shift" 16) - ("lux i64 or" @eval) - ("lux i64 left-shift" 32))) + (i64.left_shifted 16) + (i64.or @eval) + (i64.left_shifted 32))) (generation lux archive exprS))] (generation.evaluate! [@module @eval] [{.#None} exprO])))))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/module.lux b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/module.lux index 98df6e6ad..8c4dc9032 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/module.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/module.lux @@ -31,11 +31,14 @@ (exception.report (list ["Definition" (%.symbol name)] ["Original" (when already_existing - {.#Alias alias} - (format "alias " (%.symbol alias)) + {.#Alias it} + (format "alias " (%.symbol it)) - {.#Definition definition} - (format "definition " (%.symbol name)))]))) + {.#Definition it} + (format "definition " (%.symbol name)) + + {.#Default it} + (format "default " (%.symbol name)))]))) (exception.def .public (can_only_change_state_of_active_module [module state]) (Exception [Text Module_State]) @@ -119,6 +122,17 @@ ((///extension.up (/.except ..cannot_define_more_than_once [[self_name name] already_existing])) state)))))) +(def .public (override_definition [module short] definition) + (-> Symbol Global (Operation Any)) + (///extension.lifted + (function (_ state) + {try.#Success [(revised .#modules + (property.revised module + (revised .#definitions + (property.has short definition))) + state) + []]}))) + (def .public (create hash name) (-> Nat Text (Operation Any)) (///extension.lifted diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis.lux index 711ffdba3..f4056c535 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis.lux @@ -7,7 +7,7 @@ ["[0]" try] ["[0]" exception (.only Exception)]] [data - [text + ["[0]" text (.only) ["%" \\format (.only format)]] [collection ["[0]" list]]] @@ -15,6 +15,7 @@ [number ["n" nat]]] ["[0]" meta (.only) + ["[0]" symbol (.use "[1]#[0]" equivalence)] ["[0]" location] ["[0]" code] [macro @@ -30,7 +31,7 @@ ["/[1]" // ["[1][0]" extension] ["/[1]" // - ["/" analysis (.only Analysis Operation Phase Extender) + ["/" analysis (.only Analysis Operation Phase Handler Extender) ["[1][0]" macro (.only Expander)] ["[1][0]" type]] [/// @@ -84,6 +85,33 @@ ["Expected" (%.type expected)] ["Actual" (%.type actual)]))) +(type Value + (Variant + {#Normal Any} + {#Special Any})) + +(def (global_value name) + (-> Symbol (Meta [Type Value])) + (do meta.monad + [global (meta.local name)] + (when global + {.#Definition [exported? type value]} + (in [type {#Normal value}]) + + {.#Default [exported? type value]} + (in [type {#Special value}]) + + {.#Alias _} + (undefined)))) + +(def (global_analysis name) + (-> Symbol (Meta Value)) + (do meta.monad + [[type value] (global_value name)] + (if (check.subsumes? .Analysis type) + (in value) + (meta.failure (exception.error ..not_an_extension [name .Analysis type]))))) + (def (extension_application extender phase archive name parameters) @@ -92,35 +120,73 @@ Symbol (List Code) (Operation Analysis)) (do //.monad - [[exported? type value] (//extension.lifted (meta.export name))] - (if (check.subsumes? .Analysis type) - ((extender value) "" phase archive parameters) - (//.except ..not_an_extension [name .Analysis type])))) + [value (//extension.lifted (global_analysis name)) + .let [[module short] name]] + (when value + {#Normal definition} + ((extender definition) short phase archive parameters) + + {#Special default} + ((as Handler default) short phase archive parameters)))) + +... TODO: Replace with an inline function. +(exception.def .public (not_a_macro name) + (Exception Symbol) + (exception.report + (list ["Name" (%.symbol name)]))) + +(def (macro_application extender expander analysis archive def_name argsC+) + (-> Extender Expander Phase Archive Symbol (List Code) (Operation Analysis)) + (do [! //.monad] + [?macro (//extension.lifted (meta.macro def_name))] + (when ?macro + {.#Some macro} + (do ! + [expansion (//extension.lifted (/macro.single_expansion expander def_name macro argsC+))] + (analysis archive expansion)) + + _ + (//.except ..not_a_macro [def_name])))) + +... TODO: Replace with an inline function. +(def (global_application extender expander analysis archive function_type function_analysis def_name functionC argsC+) + (-> Extender Expander Phase Archive Type Analysis Symbol Code (List Code) (Operation Analysis)) + (<| (if (check.subsumes? .Analysis function_type) + (extension_application extender analysis archive def_name argsC+)) + (if (check.subsumes? .Macro function_type) + (macro_application extender expander analysis archive def_name argsC+)) + (/function.apply analysis argsC+ function_type function_analysis archive functionC))) + +... TODO: Replace with an inline function. +(def (term_application extender expander analysis archive functionC argsC+) + (-> Extender Expander Phase Archive Code (List Code) (Operation Analysis)) + (do //.monad + [[function_type function_analysis] (/type.inferring + (analysis archive functionC))] + (when function_analysis + (/.constant def_name) + (global_application extender expander analysis archive function_type function_analysis def_name functionC argsC+) + + _ + (/function.apply analysis argsC+ function_type function_analysis archive functionC)))) ... TODO: Replace with an inline function. (def apply_analysis (template (_ extender expander analysis archive functionC argsC+) ... (-> Extender Expander Phase Archive Code (List Code) (Operation Analysis)) - [(do [! //.monad] - [[function_type function_analysis] (/type.inferring - (analysis archive functionC))] - (when function_analysis - (/.constant def_name) - (if (check.subsumes? .Analysis function_type) - (extension_application extender analysis archive def_name argsC+) - (do ! - [?macro (//extension.lifted (meta.macro def_name))] - (when ?macro - {.#Some macro} - (do ! - [expansion (//extension.lifted (/macro.single_expansion expander def_name macro argsC+))] - (analysis archive expansion)) - - _ - (/function.apply analysis argsC+ function_type function_analysis archive functionC)))) - - _ - (/function.apply analysis argsC+ function_type function_analysis archive functionC)))])) + [(when functionC + [_ {.#Symbol global}] + (do //.monad + [it (//.try (extension_application extender analysis archive global argsC+))] + (when it + {try.#Success it} + (in it) + + {try.#Failure error} + (term_application extender expander analysis archive functionC argsC+))) + + _ + (term_application extender expander analysis archive functionC argsC+))])) (def .public (phase extender expander) (-> Extender Expander Phase) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/jvm.lux index f59e344ac..d9c81c517 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/jvm.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/jvm.lux @@ -465,7 +465,8 @@ ..reflection) (list)}) (analyse archive arrayC))] - (in {/////analysis.#Extension [.prelude extension_name] (list arrayA)})) + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] + (list arrayA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) @@ -486,8 +487,9 @@ :read: (typeA.check (check.clean (list) :read:)) :write: (typeA.check (check.clean (list) :write:)) arrayJT (jvm_array_type (.type_literal (array.Array' :read: :write:)))] - (in {/////analysis.#Extension [.prelude extension_name] (list (/////analysis.text (..signature arrayJT)) - arrayA)}))) + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] + (list (/////analysis.text (..signature arrayJT)) + arrayA)}))) _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) @@ -502,7 +504,8 @@ (analyse archive lengthC)) _ (typeA.inference {.#Primitive (|> (jvm.array primitive_type) ..reflection) (list)})] - (in {/////analysis.#Extension [.prelude extension_name] (list lengthA)})) + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] + (list lengthA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) @@ -523,8 +526,9 @@ {.#None} (/////analysis.except ..non_array expectedT))] - (in {/////analysis.#Extension [.prelude extension_name] (list (/////analysis.text (..signature elementJT)) - lengthA)})) + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] + (list (/////analysis.text (..signature elementJT)) + lengthA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) @@ -703,7 +707,8 @@ arrayA (<| (typeA.expecting {.#Primitive (|> (jvm.array jvm_type) ..reflection) (list)}) (analyse archive arrayC))] - (in {/////analysis.#Extension [.prelude extension_name] (list idxA arrayA)})) + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] + (list idxA arrayA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) @@ -726,9 +731,10 @@ :read: (typeA.check (check.clean (list) :read:)) :write: (typeA.check (check.clean (list) :write:)) arrayJT (jvm_array_type (.type_literal (array.Array' :read: :write:)))] - (in {/////analysis.#Extension [.prelude extension_name] (list (/////analysis.text (..signature arrayJT)) - idxA - arrayA)}))) + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] + (list (/////analysis.text (..signature arrayJT)) + idxA + arrayA)}))) _ (/////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) @@ -748,9 +754,10 @@ (analyse archive valueC)) arrayA (<| (typeA.expecting array_type) (analyse archive arrayC))] - (in {/////analysis.#Extension [.prelude extension_name] (list idxA - valueA - arrayA)})) + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] + (list idxA + valueA + arrayA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 3 (list.size args)]))))) @@ -775,10 +782,11 @@ :read: (typeA.check (check.clean (list) :read:)) :write: (typeA.check (check.clean (list) :write:)) arrayJT (jvm_array_type (.type_literal (array.Array' :read: :write:)))] - (in {/////analysis.#Extension [.prelude extension_name] (list (/////analysis.text (..signature arrayJT)) - idxA - valueA - arrayA)}))) + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] + (list (/////analysis.text (..signature arrayJT)) + idxA + valueA + arrayA)}))) _ (/////analysis.except ///.incorrect_arity [extension_name 3 (list.size args)])))) @@ -842,7 +850,8 @@ [expectedT (///.lifted meta.expected_type) [_ :object:] (check_object expectedT) _ (typeA.inference :object:)] - (in {/////analysis.#Extension [.prelude extension_name] (list)})) + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] + (list)})) _ (/////analysis.except ///.incorrect_arity [extension_name 0 (list.size args)])))) @@ -857,7 +866,8 @@ [objectT objectA] (typeA.inferring (analyse archive objectC)) _ (check_object objectT)] - (in {/////analysis.#Extension [.prelude extension_name] (list objectA)})) + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] + (list objectA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) @@ -872,7 +882,8 @@ (analyse archive monitorC)) _ (check_object monitorT) exprA (analyse archive exprC)] - (in {/////analysis.#Extension [.prelude extension_name] (list monitorA exprA)})) + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] + (list monitorA exprA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) @@ -892,7 +903,8 @@ (if ? (in []) (/////analysis.except non_throwable exception_class)))] - (in {/////analysis.#Extension [.prelude extension_name] (list exceptionA)})) + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] + (list exceptionA)})) _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) @@ -908,7 +920,8 @@ [_ (..ensure_fresh_class! class_loader class) _ (typeA.inference {.#Primitive "java.lang.Class" (list {.#Primitive class (list)})}) _ (phase.lifted (reflection!.load class_loader class))] - (in {/////analysis.#Extension [.prelude extension_name] (list (/////analysis.text class))})) + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] + (list (/////analysis.text class))})) _ (/////analysis.except ///.invalid_syntax [extension_name %.code args])) @@ -929,7 +942,8 @@ [object_class _] (check_object objectT) ? (phase.lifted (reflection!.sub? class_loader object_class sub_class))] (if ? - (in {/////analysis.#Extension [.prelude extension_name] (list (/////analysis.text sub_class) objectA)}) + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] + (list (/////analysis.text sub_class) objectA)}) (/////analysis.except cannot_possibly_be_an_instance (format sub_class " !<= " object_class)))))])) (def (class_candidate_parents class_loader from_name fromT to_name to_class) @@ -1018,9 +1032,10 @@ _ false)))))))] (if can_cast? - (in {/////analysis.#Extension [.prelude extension_name] (list (/////analysis.text from_name) - (/////analysis.text to_name) - fromA)}) + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] + (list (/////analysis.text from_name) + (/////analysis.text to_name) + fromA)}) (/////analysis.except ..cannot_cast [fromJT toJT fromC]))) _ @@ -1054,7 +1069,7 @@ (not deprecated?)) fieldT (reflection_type luxT.fresh fieldJT) _ (typeA.inference fieldT)] - (in (<| {/////analysis.#Extension [.prelude extension_name]} + (in (<| {/////analysis.#Extension [.prelude (%.format extension_name "|generation")]} (list (/////analysis.text class) (/////analysis.text field) (/////analysis.text (..signature fieldJT)))))))])) @@ -1078,7 +1093,7 @@ fieldT (reflection_type luxT.fresh fieldJT) valueA (<| (typeA.expecting fieldT) (analyse archive valueC))] - (in (<| {/////analysis.#Extension [.prelude extension_name]} + (in (<| {/////analysis.#Extension [.prelude (%.format extension_name "|generation")]} (list (/////analysis.text class) (/////analysis.text field) (/////analysis.text (..signature fieldJT)) @@ -1103,7 +1118,7 @@ (not deprecated?)) fieldT (reflection_type mapping fieldJT) _ (typeA.inference fieldT)] - (in (<| {/////analysis.#Extension [.prelude extension_name]} + (in (<| {/////analysis.#Extension [.prelude (%.format extension_name "|generation")]} (list (/////analysis.text class) (/////analysis.text field) (/////analysis.text (..signature fieldJT)) @@ -1132,7 +1147,7 @@ fieldT (reflection_type mapping fieldJT) valueA (<| (typeA.expecting fieldT) (analyse archive valueC))] - (in (<| {/////analysis.#Extension [.prelude extension_name]} + (in (<| {/////analysis.#Extension [.prelude (%.format extension_name "|generation")]} (list (/////analysis.text class) (/////analysis.text field) (/////analysis.text (..signature fieldJT)) @@ -1518,10 +1533,11 @@ (not deprecated?)) [outputT argsA] (inference.general archive analyse methodT (list#each product.right argsTC)) outputJT (check_return outputT)] - (in {/////analysis.#Extension [.prelude extension_name] (list.partial (/////analysis.text (..signature (jvm.class class (list)))) - (/////analysis.text method) - (/////analysis.text (..signature outputJT)) - (decorate_inputs argsT argsA))})))])) + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] + (list.partial (/////analysis.text (..signature (jvm.class class (list)))) + (/////analysis.text method) + (/////analysis.text (..signature outputJT)) + (decorate_inputs argsT argsA))})))])) (def (invoke::virtual class_loader) (-> java/lang/ClassLoader Handler) @@ -1542,11 +1558,12 @@ _ (undefined))] outputJT (check_return outputT)] - (in {/////analysis.#Extension [.prelude extension_name] (list.partial (/////analysis.text (..signature (jvm.class class (list)))) - (/////analysis.text method) - (/////analysis.text (..signature outputJT)) - objectA - (decorate_inputs argsT argsA))})))])) + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] + (list.partial (/////analysis.text (..signature (jvm.class class (list)))) + (/////analysis.text method) + (/////analysis.text (..signature outputJT)) + objectA + (decorate_inputs argsT argsA))})))])) (def (invoke::special class_loader) (-> java/lang/ClassLoader Handler) @@ -1567,11 +1584,12 @@ _ (undefined))] outputJT (check_return outputT)] - (in {/////analysis.#Extension [.prelude extension_name] (list.partial (/////analysis.text (..signature (jvm.class class (list)))) - (/////analysis.text method) - (/////analysis.text (..signature outputJT)) - objectA - (decorate_inputs argsT argsA))})))])) + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] + (list.partial (/////analysis.text (..signature (jvm.class class (list)))) + (/////analysis.text method) + (/////analysis.text (..signature outputJT)) + objectA + (decorate_inputs argsT argsA))})))])) (def (invoke::interface class_loader) (-> java/lang/ClassLoader Handler) @@ -1595,7 +1613,7 @@ _ (undefined))] outputJT (check_return outputT)] - (in {/////analysis.#Extension [.prelude extension_name] + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] (list.partial (/////analysis.text (..signature (jvm.class class_name (list)))) (/////analysis.text method) (/////analysis.text (..signature outputJT)) @@ -1614,8 +1632,9 @@ _ (phase.assertion ..deprecated_method [class ..constructor_method methodT] (not deprecated?)) [outputT argsA] (inference.general archive analyse methodT (list#each product.right argsTC))] - (in {/////analysis.#Extension [.prelude extension_name] (list.partial (/////analysis.text (..signature (jvm.class class (list)))) - (decorate_inputs argsT argsA))})))])) + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] + (list.partial (/////analysis.text (..signature (jvm.class class (list)))) + (decorate_inputs argsT argsA))})))])) (def (bundle::member class_loader) (-> java/lang/ClassLoader Bundle) @@ -2709,7 +2728,7 @@ .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 [.prelude extension_name] + (in {/////analysis.#Extension [.prelude (%.format extension_name "|generation")] (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/meta/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux index f311c48ec..238711a4f 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux @@ -65,7 +65,7 @@ (<| (typeA.expecting argT) (analyse archive argC))) (list.zipped_2 inputsT+ args))] - (in {analysis.#Extension [.prelude extension_name] argsA})) + (in {analysis.#Extension [.prelude (format extension_name "|generation")] argsA})) (analysis.except ///.incorrect_arity [extension_name num_expected num_actual])))))) (def .public (nullary valueT) @@ -125,10 +125,10 @@ (list (analysis.tuple (list#each (|>> analysis.nat) cases)) branch)))) (list.partial input else) - {analysis.#Extension [.prelude extension_name]}))))]))) + {analysis.#Extension [.prelude (format extension_name "|generation")]}))))]))) -... "lux is" represents reference/pointer equality. -(def lux::is +... .is?# represents reference/pointer equality. +(def lux::is? Handler (function (_ extension_name analyse archive args) (<| typeA.with_var @@ -136,7 +136,7 @@ ((binary :var: :var: Bit extension_name) analyse archive args)))) -... "lux try" provides a simple way to interact with the host platform's +... .try# provides a simple way to interact with the host platform's ... error_handling facilities. (def lux::try Handler @@ -150,7 +150,7 @@ (|> opC (analyse archive) (typeA.expecting (type_literal (-> .Any :var:))) - (at ! each (|>> list {analysis.#Extension [.prelude extension_name]}))))) + (at ! each (|>> list {analysis.#Extension [.prelude (format extension_name "|generation")]}))))) _ (analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) @@ -166,7 +166,7 @@ _ (analysis.except ///.invalid_syntax [extension_name %.code argsC+])))) -(def (lux::type::check eval) +(def (lux::is eval) (-> Eval Handler) (function (_ extension_name analyse archive args) (when args @@ -181,7 +181,7 @@ _ (analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) -(def (lux::type::as eval) +(def (lux::as eval) (-> Eval Handler) (function (_ extension_name analyse archive args) (when args @@ -207,82 +207,77 @@ (<| (typeA.expecting input) (phase archive valueC))))])) -(def (bundle::lux eval) - (-> Eval Bundle) - (|> ///bundle.empty - (///bundle.install "syntax char case!" lux::syntax_char_case!) - (///bundle.install "is" lux::is) - (///bundle.install "try" lux::try) - (///bundle.install "type check" (lux::type::check eval)) - (///bundle.install "type as" (lux::type::as eval)) - (///bundle.install "type check type" (..caster .Type .Type)) - (///bundle.install "in-module" lux::in_module))) +(def (with_basic_extensions eval) + (-> Eval (-> Bundle Bundle)) + (|>> (///bundle.install "is#" (lux::is eval)) + (///bundle.install "as#" (lux::as eval)) + (///bundle.install "is_type#" (..caster .Type .Type)) + (///bundle.install "is?#" lux::is?) + (///bundle.install "try#" lux::try) + (///bundle.install "in_module#" lux::in_module) + (///bundle.install "when_char#" lux::syntax_char_case!))) -(def bundle::io - Bundle - (<| (///bundle.prefix "io") - (|> ///bundle.empty - (///bundle.install "log" (unary Text Any)) - (///bundle.install "error" (unary Text Nothing)) - (///bundle.install "exit" (unary Int Nothing))))) +(def with_io_extensions + (-> Bundle Bundle) + (|>> (///bundle.install "log#" (unary Text Any)) + (///bundle.install "error#" (unary Text Nothing)))) (def I64* (type_literal (I64 Any))) -(def bundle::i64 - Bundle - (<| (///bundle.prefix "i64") - (|> ///bundle.empty - (///bundle.install "and" (binary I64* I64* I64)) - (///bundle.install "or" (binary I64* I64* I64)) - (///bundle.install "xor" (binary I64* I64* I64)) - (///bundle.install "left-shift" (binary Nat I64* I64)) - (///bundle.install "right-shift" (binary Nat I64* I64)) - (///bundle.install "=" (binary I64* I64* Bit)) - (///bundle.install "<" (binary Int Int Bit)) - (///bundle.install "+" (binary I64* I64* I64)) - (///bundle.install "-" (binary I64* I64* I64)) - (///bundle.install "*" (binary Int Int Int)) - (///bundle.install "/" (binary Int Int Int)) - (///bundle.install "%" (binary Int Int Int)) - (///bundle.install "f64" (unary Int Frac)) - (///bundle.install "char" (unary Int Text))))) +(def with_i64_extensions + (-> Bundle Bundle) + (|>> (///bundle.install "i64_and#" (binary I64* I64* I64)) + (///bundle.install "i64_or#" (binary I64* I64* I64)) + (///bundle.install "i64_xor#" (binary I64* I64* I64)) + (///bundle.install "i64_left#" (binary Nat I64* I64)) + (///bundle.install "i64_right#" (binary Nat I64* I64)) + + (///bundle.install "i64_=#" (binary I64* I64* Bit)) + (///bundle.install "i64_+#" (binary I64* I64* I64)) + (///bundle.install "i64_-#" (binary I64* I64* I64)))) -(def bundle::f64 - Bundle - (<| (///bundle.prefix "f64") - (|> ///bundle.empty - (///bundle.install "+" (binary Frac Frac Frac)) - (///bundle.install "-" (binary Frac Frac Frac)) - (///bundle.install "*" (binary Frac Frac Frac)) - (///bundle.install "/" (binary Frac Frac Frac)) - (///bundle.install "%" (binary Frac Frac Frac)) - (///bundle.install "=" (binary Frac Frac Bit)) - (///bundle.install "<" (binary Frac Frac Bit)) - (///bundle.install "i64" (unary Frac Int)) - (///bundle.install "encode" (unary Frac Text)) - (///bundle.install "decode" (unary Text (type_literal (Maybe Frac))))))) +(def with_int_extensions + (-> Bundle Bundle) + (|>> (///bundle.install "int_<#" (binary Int Int Bit)) + (///bundle.install "int_*#" (binary Int Int Int)) + (///bundle.install "int_/#" (binary Int Int Int)) + (///bundle.install "int_%#" (binary Int Int Int)) + + (///bundle.install "int_f64#" (unary Int Frac)) + (///bundle.install "int_char#" (unary Int Text)))) -(def bundle::text - Bundle - (<| (///bundle.prefix "text") - (|> ///bundle.empty - (///bundle.install "=" (binary Text Text Bit)) - (///bundle.install "<" (binary Text Text Bit)) - (///bundle.install "concat" (binary Text Text Text)) - (///bundle.install "index" (trinary Nat Text Text (type_literal (Maybe Nat)))) - (///bundle.install "size" (unary Text Nat)) - (///bundle.install "char" (binary Nat Text Nat)) - (///bundle.install "clip" (trinary Nat Nat Text Text)) - ))) +(def with_frac_extensions + (-> Bundle Bundle) + (|>> (///bundle.install "f64_+#" (binary Frac Frac Frac)) + (///bundle.install "f64_-#" (binary Frac Frac Frac)) + (///bundle.install "f64_*#" (binary Frac Frac Frac)) + (///bundle.install "f64_/#" (binary Frac Frac Frac)) + (///bundle.install "f64_%#" (binary Frac Frac Frac)) + (///bundle.install "f64_=#" (binary Frac Frac Bit)) + (///bundle.install "f64_<#" (binary Frac Frac Bit)) + + (///bundle.install "f64_int#" (unary Frac Int)) + (///bundle.install "f64_encoded#" (unary Frac Text)) + (///bundle.install "f64_decoded#" (unary Text (type_literal (Maybe Frac)))))) + +(def with_text_extensions + (-> Bundle Bundle) + (|>> (///bundle.install "text_=#" (binary Text Text Bit)) + (///bundle.install "text_<#" (binary Text Text Bit)) + (///bundle.install "text_composite#" (binary Text Text Text)) + (///bundle.install "text_index#" (trinary Nat Text Text (type_literal (Maybe Nat)))) + (///bundle.install "text_size#" (unary Text Nat)) + (///bundle.install "text_char#" (binary Nat Text Nat)) + (///bundle.install "text_clip#" (trinary Nat Nat Text Text)) + )) (def .public (bundle eval) (-> Eval Bundle) - (<| (///bundle.prefix "lux") - (|> ///bundle.empty - (dictionary.composite (bundle::lux eval)) - (dictionary.composite bundle::i64) - (dictionary.composite bundle::f64) - (dictionary.composite bundle::text) - (dictionary.composite bundle::io) - ))) + (|> ///bundle.empty + (with_basic_extensions eval) + with_io_extensions + with_text_extensions + with_i64_extensions + with_int_extensions + with_frac_extensions)) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux index 22317eaea..72c337e78 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux @@ -224,21 +224,32 @@ (def (refresh host_analysis) (All (_ anchor expression declaration) (-> /////analysis.Bundle (Operation anchor expression declaration Any))) - (do phase.monad + (do [! phase.monad] [[bundle state] phase.state .let [eval (/////analysis/evaluation.evaluator (the [/////declaration.#analysis /////declaration.#phase] state) [(the [/////declaration.#synthesis /////declaration.#state] state) (the [/////declaration.#synthesis /////declaration.#phase] state)] [(the [/////declaration.#generation /////declaration.#state] state) (the [/////declaration.#generation /////declaration.#phase] state)]) - previous_analysis_extensions (the [/////declaration.#analysis /////declaration.#state ///.#bundle] state)]] - (phase.with [bundle - (revised [/////declaration.#analysis /////declaration.#state] - (is (-> /////analysis.State+ /////analysis.State+) - (|>> product.right - [(|> previous_analysis_extensions - (dictionary.composite (///analysis.bundle eval host_analysis)))])) - state)]))) + previous_analysis_extensions (the [/////declaration.#analysis /////declaration.#state ///.#bundle] state) + + new_analysis_extensions (///analysis.bundle eval host_analysis) + new_is# (|> new_analysis_extensions (dictionary.value "is#") maybe.trusted) + new_as# (|> new_analysis_extensions (dictionary.value "as#") maybe.trusted)] + _ (phase.with [bundle + (revised [/////declaration.#analysis /////declaration.#state] + (is (-> /////analysis.State+ /////analysis.State+) + (|>> product.right + [(|> previous_analysis_extensions + (dictionary.composite new_analysis_extensions))])) + state)]) + current_module (/////declaration.lifted_analysis + (///.lifted meta.current_module_name)) + _ (/////declaration.lifted_analysis + (do ! + [_ (moduleA.override_definition [.prelude "is#"] {.#Default [true .Analysis new_is#]})] + (moduleA.override_definition [.prelude "as#"] {.#Default [true .Analysis new_as#]})))] + (in []))) (def (announce_definition! short type) (All (_ anchor expression declaration) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/js/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/js/common.lux index d6db61d49..e4920339b 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/js/common.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/js/common.lux @@ -103,7 +103,7 @@ Phase! (when synthesis ... TODO: Get rid of this ASAP - {synthesis.#Extension "lux syntax char case!" parameters} + {synthesis.#Extension [.prelude "when_char#|generation"] parameters} (do /////.monad [body (expression archive synthesis)] (in (as Statement body))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/jvm/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/jvm/common.lux index 10b7d920b..e9980d164 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/jvm/common.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/jvm/common.lux @@ -152,12 +152,11 @@ (_.checkcast ///function.class) ///runtime.try)) -(def bundle::lux - Bundle - (|> (is Bundle /////bundle.empty) - (/////bundle.install "syntax char case!" ..lux::syntax_char_case!) - (/////bundle.install "is" (binary ..lux::is)) - (/////bundle.install "try" (unary ..lux::try)))) +(def with_basic_extensions + (-> Bundle Bundle) + (|>> (/////bundle.install "when_char#|generation" ..lux::syntax_char_case!) + (/////bundle.install "is?#|generation" (binary ..lux::is)) + (/////bundle.install "try#|generation" (unary ..lux::try)))) (with_template [<name> <op>] [(def (<name> [maskG inputG]) @@ -263,39 +262,40 @@ ///runtime.decode_frac] ) -(def bundle::i64 - Bundle - (<| (/////bundle.prefix "i64") - (|> (is Bundle /////bundle.empty) - (/////bundle.install "and" (binary ..i64::and)) - (/////bundle.install "or" (binary ..i64::or)) - (/////bundle.install "xor" (binary ..i64::xor)) - (/////bundle.install "left-shift" (binary ..i64::left_shifted)) - (/////bundle.install "right-shift" (binary ..i64::right_shifted)) - (/////bundle.install "=" (binary ..i64::=)) - (/////bundle.install "<" (binary ..i64::<)) - (/////bundle.install "+" (binary ..i64::+)) - (/////bundle.install "-" (binary ..i64::-)) - (/////bundle.install "*" (binary ..i64::*)) - (/////bundle.install "/" (binary ..i64::/)) - (/////bundle.install "%" (binary ..i64::%)) - (/////bundle.install "f64" (unary ..i64::f64)) - (/////bundle.install "char" (unary ..i64::char))))) - -(def bundle::f64 - Bundle - (<| (/////bundle.prefix "f64") - (|> (is Bundle /////bundle.empty) - (/////bundle.install "+" (binary ..f64::+)) - (/////bundle.install "-" (binary ..f64::-)) - (/////bundle.install "*" (binary ..f64::*)) - (/////bundle.install "/" (binary ..f64::/)) - (/////bundle.install "%" (binary ..f64::%)) - (/////bundle.install "=" (binary ..f64::=)) - (/////bundle.install "<" (binary ..f64::<)) - (/////bundle.install "i64" (unary ..f64::i64)) - (/////bundle.install "encode" (unary ..f64::encode)) - (/////bundle.install "decode" (unary ..f64::decode))))) +(def with_i64_extensions + (-> Bundle Bundle) + (|>> (/////bundle.install "i64_and#|generation" (binary ..i64::and)) + (/////bundle.install "i64_or#|generation" (binary ..i64::or)) + (/////bundle.install "i64_xor#|generation" (binary ..i64::xor)) + (/////bundle.install "i64_left#|generation" (binary ..i64::left_shifted)) + (/////bundle.install "i64_right#|generation" (binary ..i64::right_shifted)) + + (/////bundle.install "i64_=#|generation" (binary ..i64::=)) + (/////bundle.install "i64_+#|generation" (binary ..i64::+)) + (/////bundle.install "i64_-#|generation" (binary ..i64::-)))) + +(def with_int_extensions + (-> Bundle Bundle) + (|>> (/////bundle.install "int_<#|generation" (binary ..i64::<)) + (/////bundle.install "int_*#|generation" (binary ..i64::*)) + (/////bundle.install "int_/#|generation" (binary ..i64::/)) + (/////bundle.install "int_%#|generation" (binary ..i64::%)) + + (/////bundle.install "int_f64#|generation" (unary ..i64::f64)) + (/////bundle.install "int_char#|generation" (unary ..i64::char)))) + +(def with_frac_extensions + (-> Bundle Bundle) + (|>> (/////bundle.install "f64_+#|generation" (binary ..f64::+)) + (/////bundle.install "f64_-#|generation" (binary ..f64::-)) + (/////bundle.install "f64_*#|generation" (binary ..f64::*)) + (/////bundle.install "f64_/#|generation" (binary ..f64::/)) + (/////bundle.install "f64_%#|generation" (binary ..f64::%)) + (/////bundle.install "f64_=#|generation" (binary ..f64::=)) + (/////bundle.install "f64_<#|generation" (binary ..f64::<)) + (/////bundle.install "f64_int#|generation" (unary ..f64::i64)) + (/////bundle.install "f64_encoded#|generation" (unary ..f64::encode)) + (/////bundle.install "f64_decoded#|generation" (unary ..f64::decode)))) (def (text::size inputG) (Unary (Bytecode Any)) @@ -365,17 +365,15 @@ ///runtime.none_injection (_.set_label @end)))) -(def bundle::text - Bundle - (<| (/////bundle.prefix "text") - (|> (is Bundle /////bundle.empty) - (/////bundle.install "=" (binary ..text::=)) - (/////bundle.install "<" (binary ..text::<)) - (/////bundle.install "concat" (binary ..text::concat)) - (/////bundle.install "index" (trinary ..text::index)) - (/////bundle.install "size" (unary ..text::size)) - (/////bundle.install "char" (binary ..text::char)) - (/////bundle.install "clip" (trinary ..text::clip))))) +(def with_text_extensions + (-> Bundle Bundle) + (|>> (/////bundle.install "text_=#|generation" (binary ..text::=)) + (/////bundle.install "text_<#|generation" (binary ..text::<)) + (/////bundle.install "text_composite#|generation" (binary ..text::concat)) + (/////bundle.install "text_index#|generation" (trinary ..text::index)) + (/////bundle.install "text_size#|generation" (unary ..text::size)) + (/////bundle.install "text_char#|generation" (binary ..text::char)) + (/////bundle.install "text_clip#|generation" (trinary ..text::clip)))) (def string_method (type.method [(list) (list ..$String) type.void (list)])) (def (io::log messageG) @@ -397,18 +395,17 @@ (_.invokespecial ..$Error "<init>" ..string_method) _.athrow)) -(def bundle::io - Bundle - (<| (/////bundle.prefix "io") - (|> (is Bundle /////bundle.empty) - (/////bundle.install "log" (unary ..io::log)) - (/////bundle.install "error" (unary ..io::error))))) +(def with_io_extensions + (-> Bundle Bundle) + (|>> (/////bundle.install "log#|generation" (unary ..io::log)) + (/////bundle.install "error#|generation" (unary ..io::error)))) (def .public bundle Bundle - (<| (/////bundle.prefix "lux") - (|> bundle::lux - (dictionary.composite ..bundle::i64) - (dictionary.composite ..bundle::f64) - (dictionary.composite ..bundle::text) - (dictionary.composite ..bundle::io)))) + (|> /////bundle.empty + with_basic_extensions + with_io_extensions + with_text_extensions + with_i64_extensions + with_int_extensions + with_frac_extensions)) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/jvm/host.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/jvm/host.lux index eeb793ab2..f74e4c823 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/jvm/host.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/jvm/host.lux @@ -138,36 +138,36 @@ Bundle (<| (/////bundle.prefix "conversion") (|> (is Bundle /////bundle.empty) - (/////bundle.install "double-to-float" (unary conversion::double_to_float)) - (/////bundle.install "double-to-int" (unary conversion::double_to_int)) - (/////bundle.install "double-to-long" (unary conversion::double_to_long)) + (/////bundle.install "double-to-float|generation" (unary conversion::double_to_float)) + (/////bundle.install "double-to-int|generation" (unary conversion::double_to_int)) + (/////bundle.install "double-to-long|generation" (unary conversion::double_to_long)) - (/////bundle.install "float-to-double" (unary conversion::float_to_double)) - (/////bundle.install "float-to-int" (unary conversion::float_to_int)) - (/////bundle.install "float-to-long" (unary conversion::float_to_long)) + (/////bundle.install "float-to-double|generation" (unary conversion::float_to_double)) + (/////bundle.install "float-to-int|generation" (unary conversion::float_to_int)) + (/////bundle.install "float-to-long|generation" (unary conversion::float_to_long)) - (/////bundle.install "int-to-byte" (unary conversion::int_to_byte)) - (/////bundle.install "int-to-char" (unary conversion::int_to_char)) - (/////bundle.install "int-to-double" (unary conversion::int_to_double)) - (/////bundle.install "int-to-float" (unary conversion::int_to_float)) - (/////bundle.install "int-to-long" (unary conversion::int_to_long)) - (/////bundle.install "int-to-short" (unary conversion::int_to_short)) + (/////bundle.install "int-to-byte|generation" (unary conversion::int_to_byte)) + (/////bundle.install "int-to-char|generation" (unary conversion::int_to_char)) + (/////bundle.install "int-to-double|generation" (unary conversion::int_to_double)) + (/////bundle.install "int-to-float|generation" (unary conversion::int_to_float)) + (/////bundle.install "int-to-long|generation" (unary conversion::int_to_long)) + (/////bundle.install "int-to-short|generation" (unary conversion::int_to_short)) - (/////bundle.install "long-to-double" (unary conversion::long_to_double)) - (/////bundle.install "long-to-float" (unary conversion::long_to_float)) - (/////bundle.install "long-to-int" (unary conversion::long_to_int)) - (/////bundle.install "long-to-short" (unary conversion::long_to_short)) - (/////bundle.install "long-to-byte" (unary conversion::long_to_byte)) - (/////bundle.install "long-to-char" (unary conversion::long_to_char)) + (/////bundle.install "long-to-double|generation" (unary conversion::long_to_double)) + (/////bundle.install "long-to-float|generation" (unary conversion::long_to_float)) + (/////bundle.install "long-to-int|generation" (unary conversion::long_to_int)) + (/////bundle.install "long-to-short|generation" (unary conversion::long_to_short)) + (/////bundle.install "long-to-byte|generation" (unary conversion::long_to_byte)) + (/////bundle.install "long-to-char|generation" (unary conversion::long_to_char)) - (/////bundle.install "char-to-byte" (unary conversion::char_to_byte)) - (/////bundle.install "char-to-short" (unary conversion::char_to_short)) - (/////bundle.install "char-to-int" (unary conversion::char_to_int)) - (/////bundle.install "char-to-long" (unary conversion::char_to_long)) + (/////bundle.install "char-to-byte|generation" (unary conversion::char_to_byte)) + (/////bundle.install "char-to-short|generation" (unary conversion::char_to_short)) + (/////bundle.install "char-to-int|generation" (unary conversion::char_to_int)) + (/////bundle.install "char-to-long|generation" (unary conversion::char_to_long)) - (/////bundle.install "byte-to-long" (unary conversion::byte_to_long)) + (/////bundle.install "byte-to-long|generation" (unary conversion::byte_to_long)) - (/////bundle.install "short-to-long" (unary conversion::short_to_long)) + (/////bundle.install "short-to-long|generation" (unary conversion::short_to_long)) ))) (with_template [<name> <op>] @@ -274,72 +274,72 @@ Bundle (<| (/////bundle.prefix (reflection.reflection reflection.int)) (|> (is Bundle /////bundle.empty) - (/////bundle.install "+" (binary int::+)) - (/////bundle.install "-" (binary int::-)) - (/////bundle.install "*" (binary int::*)) - (/////bundle.install "/" (binary int::/)) - (/////bundle.install "%" (binary int::%)) - (/////bundle.install "=" (binary int::=)) - (/////bundle.install "<" (binary int::<)) - (/////bundle.install "and" (binary int::and)) - (/////bundle.install "or" (binary int::or)) - (/////bundle.install "xor" (binary int::xor)) - (/////bundle.install "shl" (binary int::shl)) - (/////bundle.install "shr" (binary int::shr)) - (/////bundle.install "ushr" (binary int::ushr)) + (/////bundle.install "+|generation" (binary int::+)) + (/////bundle.install "-|generation" (binary int::-)) + (/////bundle.install "*|generation" (binary int::*)) + (/////bundle.install "/|generation" (binary int::/)) + (/////bundle.install "%|generation" (binary int::%)) + (/////bundle.install "=|generation" (binary int::=)) + (/////bundle.install "<|generation" (binary int::<)) + (/////bundle.install "and|generation" (binary int::and)) + (/////bundle.install "or|generation" (binary int::or)) + (/////bundle.install "xor|generation" (binary int::xor)) + (/////bundle.install "shl|generation" (binary int::shl)) + (/////bundle.install "shr|generation" (binary int::shr)) + (/////bundle.install "ushr|generation" (binary int::ushr)) ))) (def bundle::long Bundle (<| (/////bundle.prefix (reflection.reflection reflection.long)) (|> (is Bundle /////bundle.empty) - (/////bundle.install "+" (binary long::+)) - (/////bundle.install "-" (binary long::-)) - (/////bundle.install "*" (binary long::*)) - (/////bundle.install "/" (binary long::/)) - (/////bundle.install "%" (binary long::%)) - (/////bundle.install "=" (binary long::=)) - (/////bundle.install "<" (binary long::<)) - (/////bundle.install "and" (binary long::and)) - (/////bundle.install "or" (binary long::or)) - (/////bundle.install "xor" (binary long::xor)) - (/////bundle.install "shl" (binary long::shl)) - (/////bundle.install "shr" (binary long::shr)) - (/////bundle.install "ushr" (binary long::ushr)) + (/////bundle.install "+|generation" (binary long::+)) + (/////bundle.install "-|generation" (binary long::-)) + (/////bundle.install "*|generation" (binary long::*)) + (/////bundle.install "/|generation" (binary long::/)) + (/////bundle.install "%|generation" (binary long::%)) + (/////bundle.install "=|generation" (binary long::=)) + (/////bundle.install "<|generation" (binary long::<)) + (/////bundle.install "and|generation" (binary long::and)) + (/////bundle.install "or|generation" (binary long::or)) + (/////bundle.install "xor|generation" (binary long::xor)) + (/////bundle.install "shl|generation" (binary long::shl)) + (/////bundle.install "shr|generation" (binary long::shr)) + (/////bundle.install "ushr|generation" (binary long::ushr)) ))) (def bundle::float Bundle (<| (/////bundle.prefix (reflection.reflection reflection.float)) (|> (is Bundle /////bundle.empty) - (/////bundle.install "+" (binary float::+)) - (/////bundle.install "-" (binary float::-)) - (/////bundle.install "*" (binary float::*)) - (/////bundle.install "/" (binary float::/)) - (/////bundle.install "%" (binary float::%)) - (/////bundle.install "=" (binary float::=)) - (/////bundle.install "<" (binary float::<)) + (/////bundle.install "+|generation" (binary float::+)) + (/////bundle.install "-|generation" (binary float::-)) + (/////bundle.install "*|generation" (binary float::*)) + (/////bundle.install "/|generation" (binary float::/)) + (/////bundle.install "%|generation" (binary float::%)) + (/////bundle.install "=|generation" (binary float::=)) + (/////bundle.install "<|generation" (binary float::<)) ))) (def bundle::double Bundle (<| (/////bundle.prefix (reflection.reflection reflection.double)) (|> (is Bundle /////bundle.empty) - (/////bundle.install "+" (binary double::+)) - (/////bundle.install "-" (binary double::-)) - (/////bundle.install "*" (binary double::*)) - (/////bundle.install "/" (binary double::/)) - (/////bundle.install "%" (binary double::%)) - (/////bundle.install "=" (binary double::=)) - (/////bundle.install "<" (binary double::<)) + (/////bundle.install "+|generation" (binary double::+)) + (/////bundle.install "-|generation" (binary double::-)) + (/////bundle.install "*|generation" (binary double::*)) + (/////bundle.install "/|generation" (binary double::/)) + (/////bundle.install "%|generation" (binary double::%)) + (/////bundle.install "=|generation" (binary double::=)) + (/////bundle.install "<|generation" (binary double::<)) ))) (def bundle::char Bundle (<| (/////bundle.prefix (reflection.reflection reflection.char)) (|> (is Bundle /////bundle.empty) - (/////bundle.install "=" (binary char::=)) - (/////bundle.install "<" (binary char::<)) + (/////bundle.install "=|generation" (binary char::=)) + (/////bundle.install "<|generation" (binary char::<)) ))) (with_template [<name> <category> <parser>] @@ -499,48 +499,48 @@ (|> /////bundle.empty (dictionary.composite (<| (/////bundle.prefix "length") (|> /////bundle.empty - (/////bundle.install (reflection.reflection reflection.boolean) (primitive_array_length_handler type.boolean)) - (/////bundle.install (reflection.reflection reflection.byte) (primitive_array_length_handler type.byte)) - (/////bundle.install (reflection.reflection reflection.short) (primitive_array_length_handler type.short)) - (/////bundle.install (reflection.reflection reflection.int) (primitive_array_length_handler type.int)) - (/////bundle.install (reflection.reflection reflection.long) (primitive_array_length_handler type.long)) - (/////bundle.install (reflection.reflection reflection.float) (primitive_array_length_handler type.float)) - (/////bundle.install (reflection.reflection reflection.double) (primitive_array_length_handler type.double)) - (/////bundle.install (reflection.reflection reflection.char) (primitive_array_length_handler type.char)) - (/////bundle.install "object" array::length::object)))) + (/////bundle.install (%.format (reflection.reflection reflection.boolean) "|generation") (primitive_array_length_handler type.boolean)) + (/////bundle.install (%.format (reflection.reflection reflection.byte) "|generation") (primitive_array_length_handler type.byte)) + (/////bundle.install (%.format (reflection.reflection reflection.short) "|generation") (primitive_array_length_handler type.short)) + (/////bundle.install (%.format (reflection.reflection reflection.int) "|generation") (primitive_array_length_handler type.int)) + (/////bundle.install (%.format (reflection.reflection reflection.long) "|generation") (primitive_array_length_handler type.long)) + (/////bundle.install (%.format (reflection.reflection reflection.float) "|generation") (primitive_array_length_handler type.float)) + (/////bundle.install (%.format (reflection.reflection reflection.double) "|generation") (primitive_array_length_handler type.double)) + (/////bundle.install (%.format (reflection.reflection reflection.char) "|generation") (primitive_array_length_handler type.char)) + (/////bundle.install (%.format "object" "|generation") array::length::object)))) (dictionary.composite (<| (/////bundle.prefix "new") (|> /////bundle.empty - (/////bundle.install (reflection.reflection reflection.boolean) (new_primitive_array_handler __.t_boolean)) - (/////bundle.install (reflection.reflection reflection.byte) (new_primitive_array_handler __.t_byte)) - (/////bundle.install (reflection.reflection reflection.short) (new_primitive_array_handler __.t_short)) - (/////bundle.install (reflection.reflection reflection.int) (new_primitive_array_handler __.t_int)) - (/////bundle.install (reflection.reflection reflection.long) (new_primitive_array_handler __.t_long)) - (/////bundle.install (reflection.reflection reflection.float) (new_primitive_array_handler __.t_float)) - (/////bundle.install (reflection.reflection reflection.double) (new_primitive_array_handler __.t_double)) - (/////bundle.install (reflection.reflection reflection.char) (new_primitive_array_handler __.t_char)) - (/////bundle.install "object" array::new::object)))) + (/////bundle.install (%.format (reflection.reflection reflection.boolean) "|generation") (new_primitive_array_handler __.t_boolean)) + (/////bundle.install (%.format (reflection.reflection reflection.byte) "|generation") (new_primitive_array_handler __.t_byte)) + (/////bundle.install (%.format (reflection.reflection reflection.short) "|generation") (new_primitive_array_handler __.t_short)) + (/////bundle.install (%.format (reflection.reflection reflection.int) "|generation") (new_primitive_array_handler __.t_int)) + (/////bundle.install (%.format (reflection.reflection reflection.long) "|generation") (new_primitive_array_handler __.t_long)) + (/////bundle.install (%.format (reflection.reflection reflection.float) "|generation") (new_primitive_array_handler __.t_float)) + (/////bundle.install (%.format (reflection.reflection reflection.double) "|generation") (new_primitive_array_handler __.t_double)) + (/////bundle.install (%.format (reflection.reflection reflection.char) "|generation") (new_primitive_array_handler __.t_char)) + (/////bundle.install (%.format "object" "|generation") array::new::object)))) (dictionary.composite (<| (/////bundle.prefix "read") (|> /////bundle.empty - (/////bundle.install (reflection.reflection reflection.boolean) (read_primitive_array_handler type.boolean _.baload)) - (/////bundle.install (reflection.reflection reflection.byte) (read_primitive_array_handler type.byte _.baload)) - (/////bundle.install (reflection.reflection reflection.short) (read_primitive_array_handler type.short _.saload)) - (/////bundle.install (reflection.reflection reflection.int) (read_primitive_array_handler type.int _.iaload)) - (/////bundle.install (reflection.reflection reflection.long) (read_primitive_array_handler type.long _.laload)) - (/////bundle.install (reflection.reflection reflection.float) (read_primitive_array_handler type.float _.faload)) - (/////bundle.install (reflection.reflection reflection.double) (read_primitive_array_handler type.double _.daload)) - (/////bundle.install (reflection.reflection reflection.char) (read_primitive_array_handler type.char _.caload)) - (/////bundle.install "object" array::read::object)))) + (/////bundle.install (%.format (reflection.reflection reflection.boolean) "|generation") (read_primitive_array_handler type.boolean _.baload)) + (/////bundle.install (%.format (reflection.reflection reflection.byte) "|generation") (read_primitive_array_handler type.byte _.baload)) + (/////bundle.install (%.format (reflection.reflection reflection.short) "|generation") (read_primitive_array_handler type.short _.saload)) + (/////bundle.install (%.format (reflection.reflection reflection.int) "|generation") (read_primitive_array_handler type.int _.iaload)) + (/////bundle.install (%.format (reflection.reflection reflection.long) "|generation") (read_primitive_array_handler type.long _.laload)) + (/////bundle.install (%.format (reflection.reflection reflection.float) "|generation") (read_primitive_array_handler type.float _.faload)) + (/////bundle.install (%.format (reflection.reflection reflection.double) "|generation") (read_primitive_array_handler type.double _.daload)) + (/////bundle.install (%.format (reflection.reflection reflection.char) "|generation") (read_primitive_array_handler type.char _.caload)) + (/////bundle.install (%.format "object" "|generation") array::read::object)))) (dictionary.composite (<| (/////bundle.prefix "write") (|> /////bundle.empty - (/////bundle.install (reflection.reflection reflection.boolean) (write_primitive_array_handler type.boolean _.bastore)) - (/////bundle.install (reflection.reflection reflection.byte) (write_primitive_array_handler type.byte _.bastore)) - (/////bundle.install (reflection.reflection reflection.short) (write_primitive_array_handler type.short _.sastore)) - (/////bundle.install (reflection.reflection reflection.int) (write_primitive_array_handler type.int _.iastore)) - (/////bundle.install (reflection.reflection reflection.long) (write_primitive_array_handler type.long _.lastore)) - (/////bundle.install (reflection.reflection reflection.float) (write_primitive_array_handler type.float _.fastore)) - (/////bundle.install (reflection.reflection reflection.double) (write_primitive_array_handler type.double _.dastore)) - (/////bundle.install (reflection.reflection reflection.char) (write_primitive_array_handler type.char _.castore)) - (/////bundle.install "object" array::write::object)))) + (/////bundle.install (%.format (reflection.reflection reflection.boolean) "|generation") (write_primitive_array_handler type.boolean _.bastore)) + (/////bundle.install (%.format (reflection.reflection reflection.byte) "|generation") (write_primitive_array_handler type.byte _.bastore)) + (/////bundle.install (%.format (reflection.reflection reflection.short) "|generation") (write_primitive_array_handler type.short _.sastore)) + (/////bundle.install (%.format (reflection.reflection reflection.int) "|generation") (write_primitive_array_handler type.int _.iastore)) + (/////bundle.install (%.format (reflection.reflection reflection.long) "|generation") (write_primitive_array_handler type.long _.lastore)) + (/////bundle.install (%.format (reflection.reflection reflection.float) "|generation") (write_primitive_array_handler type.float _.fastore)) + (/////bundle.install (%.format (reflection.reflection reflection.double) "|generation") (write_primitive_array_handler type.double _.dastore)) + (/////bundle.install (%.format (reflection.reflection reflection.char) "|generation") (write_primitive_array_handler type.char _.castore)) + (/////bundle.install (%.format "object" "|generation") array::write::object)))) ))) (def (object::null _) @@ -643,13 +643,13 @@ Bundle (<| (/////bundle.prefix "object") (|> (is Bundle /////bundle.empty) - (/////bundle.install "null" (nullary object::null)) - (/////bundle.install "null?" (unary object::null?)) - (/////bundle.install "synchronized" (binary object::synchronized)) - (/////bundle.install "throw" (unary object::throw)) - (/////bundle.install "class" object::class) - (/////bundle.install "instance?" object::instance?) - (/////bundle.install "cast" object::cast) + (/////bundle.install (%.format "null" "|generation") (nullary object::null)) + (/////bundle.install (%.format "null?" "|generation") (unary object::null?)) + (/////bundle.install (%.format "synchronized" "|generation") (binary object::synchronized)) + (/////bundle.install (%.format "throw" "|generation") (unary object::throw)) + (/////bundle.install (%.format "class" "|generation") object::class) + (/////bundle.install (%.format "instance?" "|generation") object::instance?) + (/////bundle.install (%.format "cast" "|generation") object::cast) ))) (def get::static @@ -798,19 +798,19 @@ (|> (is Bundle /////bundle.empty) (dictionary.composite (<| (/////bundle.prefix "get") (|> (is Bundle /////bundle.empty) - (/////bundle.install "static" get::static) - (/////bundle.install "virtual" get::virtual)))) + (/////bundle.install (%.format "static" "|generation") get::static) + (/////bundle.install (%.format "virtual" "|generation") get::virtual)))) (dictionary.composite (<| (/////bundle.prefix "put") (|> (is Bundle /////bundle.empty) - (/////bundle.install "static" put::static) - (/////bundle.install "virtual" put::virtual)))) + (/////bundle.install (%.format "static" "|generation") put::static) + (/////bundle.install (%.format "virtual" "|generation") put::virtual)))) (dictionary.composite (<| (/////bundle.prefix "invoke") (|> (is Bundle /////bundle.empty) - (/////bundle.install "static" invoke::static) - (/////bundle.install "virtual" invoke::virtual) - (/////bundle.install "special" invoke::special) - (/////bundle.install "interface" invoke::interface) - (/////bundle.install "constructor" invoke::constructor)))) + (/////bundle.install (%.format "static" "|generation") invoke::static) + (/////bundle.install (%.format "virtual" "|generation") invoke::virtual) + (/////bundle.install (%.format "special" "|generation") invoke::special) + (/////bundle.install (%.format "interface" "|generation") invoke::interface) + (/////bundle.install (%.format "constructor" "|generation") invoke::constructor)))) ))) (def annotation_parameter @@ -1139,14 +1139,14 @@ (_.aload (n.+ inputs_offset (++ register))) (_.putfield class (///reference.foreign_name register) $Object)))))] (method.method method.public "<init>" - true (anonymous_init_method env inputsTG) - (list) - {.#Some (all _.composite - (_.aload 0) - inputs! - (_.invokespecial super_class "<init>" (type.method [(list) (list#each product.left inputsTG) type.void (list)])) - store_captured! - _.return)}))) + true (anonymous_init_method env inputsTG) + (list) + {.#Some (all _.composite + (_.aload 0) + inputs! + (_.invokespecial super_class "<init>" (type.method [(list) (list#each product.left inputsTG) type.void (list)])) + store_captured! + _.return)}))) (def (anonymous_instance generate archive class env inputsTI) (-> Phase Archive (Type category.Class) (Environment Synthesis) (List (Typed (Bytecode Any))) (Operation (Bytecode Any))) @@ -1322,13 +1322,13 @@ (if strict_fp? method.strict modifier#identity)) - name - true methodT - (list) - {.#Some (all _.composite - (prepare_arguments 1 argumentsT) - bodyG - (returnG returnT))}))))) + name + true methodT + (list) + {.#Some (all _.composite + (prepare_arguments 1 argumentsT) + bodyG + (returnG returnT))}))))) (def class::anonymous Handler @@ -1374,7 +1374,7 @@ Bundle (<| (/////bundle.prefix "class") (|> (is Bundle /////bundle.empty) - (/////bundle.install "anonymous" class::anonymous) + (/////bundle.install (%.format "anonymous" "|generation") class::anonymous) ))) (def .public bundle diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/lua/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/lua/common.lux index 80882cbbd..b71adedaa 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/lua/common.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/lua/common.lux @@ -65,7 +65,7 @@ Phase! (when synthesis ... TODO: Get rid of this ASAP - {synthesis.#Extension "lux syntax char case!" parameters} + {synthesis.#Extension [.prelude "when_char#|generation"] parameters} (do /////.monad [body (expression archive synthesis)] (in (as Statement body))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/python/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/python/common.lux index 5bb154a47..f68373416 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/python/common.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/python/common.lux @@ -50,7 +50,7 @@ Phase! (when synthesis ... TODO: Get rid of this ASAP - {synthesis.#Extension "lux syntax char case!" parameters} + {synthesis.#Extension [.prelude "when_char#|generation"] parameters} (do /////.monad [body (expression archive synthesis)] (in (as (Statement Any) body))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/ruby/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/ruby/common.lux index 9c136ef38..be7b33267 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/ruby/common.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/generation/ruby/common.lux @@ -61,7 +61,7 @@ Phase! (when synthesis ... TODO: Get rid of this ASAP - {synthesis.#Extension "lux syntax char case!" parameters} + {synthesis.#Extension [.prelude "when_char#|generation"] parameters} (do /////.monad [body (expression archive synthesis)] (in (as Statement diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/loop.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/loop.lux index 4b78390ac..0c73a8683 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/loop.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/loop.lux @@ -187,7 +187,7 @@ <application>))) ... TODO: Stop relying on this custom code. - {/.#Extension [["" "lux syntax char case!"] (list.partial input else matches)]} + {/.#Extension [[.prelude "when_char#|generation"] (list.partial input else matches)]} (if return? (do [! maybe.monad] [input (again false input) @@ -204,7 +204,7 @@ (again false match))) matches) else (again return? else)] - (in {/.#Extension [["" "lux syntax char case!"] (list.partial input else matches)]})) + (in {/.#Extension [[.prelude "when_char#|generation"] (list.partial input else matches)]})) {.#None}) {/.#Extension [name args]} diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/syntax.lux b/stdlib/source/library/lux/meta/compiler/language/lux/syntax.lux index c74188b26..1793cf9a5 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/syntax.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/syntax.lux @@ -68,12 +68,12 @@ (template <declaration> [<body>]))))])) -... TODO: Implement "lux syntax char case!" as a custom extension. +... TODO: Implement .when_char# as a custom extension. ... That way, it should be possible to obtain the char without wrapping ... it into a java.lang.Long, thereby improving performance. ... TODO: Make an extension to take advantage of java/lang/String::indexOf<int,int> -... to get better performance than the current "lux text index" extension. +... to get better performance than the current .text_index# extension. ... TODO: Instead of always keeping a "where" location variable, keep the ... individual components (i.e. file, line and column) separate, so @@ -89,22 +89,22 @@ (template (_ value) [(<extension> <diff> value)]))] - ["lux i64 +" 1 !++] - ["lux i64 +" 2 !++/2] - ["lux i64 -" 1 !--] + [.i64_+# 1 !++] + [.i64_+# 2 !++/2] + [.i64_-# 1 !--] ) (def !clip (template (_ from to text) - [("lux text clip" from (n.- from to) text)])) + [(.text_clip# from (n.- from to) text)])) (with_template [<name> <extension>] [(def <name> (template (_ reference subject) [(<extension> reference subject)]))] - [!n/= "lux i64 ="] - [!i/< "lux i64 <"] + [!n/= .i64_=#] + [!i/< .int_<#] ) (with_template [<name> <extension>] @@ -112,8 +112,8 @@ (template (_ param subject) [(<extension> param subject)]))] - [!n/+ "lux i64 +"] - [!n/- "lux i64 -"] + [!n/+ .i64_+#] + [!n/- .i64_-#] ) (type .public Aliases @@ -171,7 +171,7 @@ (inlined (input_at start input) (-> Offset Text Text) - (let [end (|> start (!n/+ amount_of_input_shown) (n.min ("lux text size" input)))] + (let [end (|> start (!n/+ amount_of_input_shown) (n.min (.text_size# input)))] (!clip start end input))) (exception.def .public (unrecognized_input [[file line column] context input offset]) @@ -205,13 +205,13 @@ (template (_ @source_code_size @source_code @offset @char @else @body) [(if (!i/< (as Int @source_code_size) (as Int @offset)) - (let [@char ("lux text char" @offset @source_code)] + (let [@char (.text_char# @offset @source_code)] @body) @else)])) (def !with_char (template (_ @source_code @offset @char @else @body) - [(!with_char+ ("lux text size" @source_code) @source_code @offset @char @else @body)])) + [(!with_char+ (.text_size# @source_code) @source_code @offset @char @else @body)])) (def !letE (template (_ <binding> <computation> <body>) @@ -271,7 +271,7 @@ (def !guarantee_no_new_lines (template (_ where offset source_code content body) - [(when ("lux text index" 0 (static text.new_line) content) + [(when (.text_index# 0 (static text.new_line) content) {.#None} body @@ -281,7 +281,7 @@ (def (text_parser where offset source_code) (-> Location Offset Text (Either [Source Text] [Source Code])) - (when ("lux text index" offset (static ..text_delimiter) source_code) + (when (.text_index# offset (static ..text_delimiter) source_code) {.#Some g!end} (<| (let [g!content (!clip offset g!end source_code)]) (!guarantee_no_new_lines where offset source_code g!content) @@ -309,41 +309,41 @@ <digit_separator> (static ..digit_separator)] (def !if_digit? (template (_ @char @then @else) - [("lux syntax char case!" @char - [[<digits>] - @then] + [(.when_char# @char + [[<digits>] + @then] - ... else - @else)])) + ... else + @else)])) (def !if_digit?+ (template (_ @char @then @else_options @else) - [(`` ("lux syntax char case!" @char - [[<digits> <digit_separator>] - @then + [(`` (.when_char# @char + [[<digits> <digit_separator>] + @then - (,, (template.spliced @else_options))] + (,, (template.spliced @else_options))] - ... else - @else))])) + ... else + @else))])) (`` (def !if_symbol_char?|tail (template (_ @char @then @else) - [("lux syntax char case!" @char - [[<non_symbol_chars>] - @else] + [(.when_char# @char + [[<non_symbol_chars>] + @else] - ... else - @then)]))) + ... else + @then)]))) (`` (def !if_symbol_char?|head (template (_ @char @then @else) - [("lux syntax char case!" @char - [[<non_symbol_chars> <digits>] - @else] + [(.when_char# @char + [[<non_symbol_chars> <digits>] + @else] - ... else - @then)]))) + ... else + @then)]))) ) (def !number_output @@ -388,15 +388,15 @@ [["e" "E"] (if (same? (static ..no_exponent) exponent) (<| (!with_char+ source_code//size source_code (!++ end) char/1 <failure>) - (`` ("lux syntax char case!" char/1 - [[<signs>] - (<| (!with_char+ source_code//size source_code (!n/+ 2 end) char/2 <failure>) - (!if_digit?+ char/2 - (again (!n/+ 3 end) char/0) - [] - <failure>))] - ... else - <failure>))) + (`` (.when_char# char/1 + [[<signs>] + (<| (!with_char+ source_code//size source_code (!n/+ 2 end) char/2 <failure>) + (!if_digit?+ char/2 + (again (!n/+ 3 end) char/0) + [] + <failure>))] + ... else + <failure>))) <frac_output>)] <frac_output>)))) @@ -445,7 +445,7 @@ (inlined (symbol_part_parser start where offset source_code) (-> Nat Location Offset Text (Either [Source Text] [Source Text])) - (let [source_code//size ("lux text size" source_code)] + (let [source_code//size (.text_size# source_code)] (loop (again [end offset]) (<| (!with_char+ source_code//size source_code end char <output>) (!if_symbol_char?|tail char @@ -485,7 +485,7 @@ (if (!n/= (char (,, (static ..symbol_separator))) char/separator) (<| (let [offset'' (!++ offset')]) (!letE [source'' complex] (..symbol_part_parser offset'' (!forward 1 where') offset'' source_code')) - (if ("lux text =" "" complex) + (if (.text_=# "" complex) (let [[where offset source_code] source] (!failure ..full_symbol_parser where offset source_code)) {.#Right [source'' [(|> aliases @@ -540,82 +540,82 @@ [..open_variant ..close_variant variant_parser] [..open_tuple ..close_tuple tuple_parser] )] - (`` ("lux syntax char case!" char/0 - [[(,, (static text.space)) - (,, (static text.carriage_return))] - (again (!horizontal where offset/0 source_code)) - - ... New line - [(,, (static text.new_line))] - (again (!vertical where offset/0 source_code)) - - <composites> - - ... Text - [(,, (static ..text_delimiter))] - (text_parser where (!++ offset/0) source_code) - - ... Coincidentally (= ..symbol_separator ..frac_separator) - [(,, (static ..symbol_separator)) - ... (,, (static ..frac_separator)) - ] - ... It's either a Rev, a symbol, or a comment. - (with_expansions [<rev_parser> (rev_parser source_code//size offset/0 where (!++ offset/1) source_code) - <short_symbol_parser> (!short_symbol_parser source_code//size current_module [where offset/1 source_code] where .#Symbol) - <comment_parser> (when ("lux text index" (!++ offset/1) (static text.new_line) source_code) - {.#Some end} - (again (!vertical where end source_code)) - - _ - (!end_of_file where offset/1 source_code current_module))] - (<| (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)) - (!if_digit? char/1 - ... It's a Rev. - <rev_parser> - ... It's either a symbol, or a comment. - ("lux syntax char case!" char/1 - [[(,, (static ..symbol_separator))] - ... It's either a symbol, or a comment. - (<| (let [offset/2 (!++ offset/1)]) - (!with_char+ source_code//size source_code offset/2 char/2 - (!end_of_file where offset/2 source_code current_module)) - ("lux syntax char case!" char/2 - [[(,, (static ..symbol_separator))] - ... It's a comment. - <comment_parser>] - ... It's a symbol. - <short_symbol_parser>))] - ... It's a symbol. - <short_symbol_parser>)))) - - [(,, (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)) - - [(,, (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 - [(,, (with_template [<char> <bit>] - [[<char>] - (..bit_syntax <bit> [where offset/0 source_code])] - - ["0" #0] - ["1" #1]))] - - ... else - (!full_symbol_parser offset/0 [<consume_1>] where aliases .#Symbol)))] - - ... else - (!if_digit? char/0 - ... Natural number - (nat_parser source_code//size offset/0 where (!++ offset/0) source_code) - ... Symbol - (!full_symbol_parser offset/0 [<consume_1>] where aliases .#Symbol)) - ))) + (`` (.when_char# char/0 + [[(,, (static text.space)) + (,, (static text.carriage_return))] + (again (!horizontal where offset/0 source_code)) + + ... New line + [(,, (static text.new_line))] + (again (!vertical where offset/0 source_code)) + + <composites> + + ... Text + [(,, (static ..text_delimiter))] + (text_parser where (!++ offset/0) source_code) + + ... Coincidentally (= ..symbol_separator ..frac_separator) + [(,, (static ..symbol_separator)) + ... (,, (static ..frac_separator)) + ] + ... It's either a Rev, a symbol, or a comment. + (with_expansions [<rev_parser> (rev_parser source_code//size offset/0 where (!++ offset/1) source_code) + <short_symbol_parser> (!short_symbol_parser source_code//size current_module [where offset/1 source_code] where .#Symbol) + <comment_parser> (when (.text_index# (!++ offset/1) (static text.new_line) source_code) + {.#Some end} + (again (!vertical where end source_code)) + + _ + (!end_of_file where offset/1 source_code current_module))] + (<| (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)) + (!if_digit? char/1 + ... It's a Rev. + <rev_parser> + ... It's either a symbol, or a comment. + (.when_char# char/1 + [[(,, (static ..symbol_separator))] + ... It's either a symbol, or a comment. + (<| (let [offset/2 (!++ offset/1)]) + (!with_char+ source_code//size source_code offset/2 char/2 + (!end_of_file where offset/2 source_code current_module)) + (.when_char# char/2 + [[(,, (static ..symbol_separator))] + ... It's a comment. + <comment_parser>] + ... It's a symbol. + <short_symbol_parser>))] + ... It's a symbol. + <short_symbol_parser>)))) + + [(,, (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)) + + [(,, (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)) + (.when_char# char/1 + [(,, (with_template [<char> <bit>] + [[<char>] + (..bit_syntax <bit> [where offset/0 source_code])] + + ["0" #0] + ["1" #1]))] + + ... else + (!full_symbol_parser offset/0 [<consume_1>] where aliases .#Symbol)))] + + ... else + (!if_digit? char/0 + ... Natural number + (nat_parser source_code//size offset/0 where (!++ offset/0) source_code) + ... Symbol + (!full_symbol_parser offset/0 [<consume_1>] where aliases .#Symbol)) + ))) )))) ) diff --git a/stdlib/source/library/lux/meta/compiler/phase.lux b/stdlib/source/library/lux/meta/compiler/phase.lux index 77574a4aa..dd87d5866 100644 --- a/stdlib/source/library/lux/meta/compiler/phase.lux +++ b/stdlib/source/library/lux/meta/compiler/phase.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except except with) + [lux (.except except with try) [abstract [functor (.only Functor)] [monad (.only Monad do)]] @@ -113,6 +113,18 @@ (at ..monad in []) (..except exception message))])) +(def .public (try it) + (All (_ state value) + (-> (Operation state value) + (Operation state (Try value)))) + (function (_ state) + (when (it state) + {try.#Success [state' it']} + {try.#Success [state' {try.#Success it'}]} + + {try.#Failure error} + {try.#Success [state {try.#Failure error}]}))) + (def .public identity (All (_ s a) (Phase s a a)) (function (_ archive input state) diff --git a/stdlib/source/library/lux/meta/location.lux b/stdlib/source/library/lux/meta/location.lux index 2c4fc0eb1..56eafe44b 100644 --- a/stdlib/source/library/lux/meta/location.lux +++ b/stdlib/source/library/lux/meta/location.lux @@ -8,9 +8,9 @@ (Equivalence Location) (implementation (def (= reference subject) - (and ("lux text =" (the .#module reference) (the .#module subject)) - ("lux i64 =" (the .#line reference) (the .#line subject)) - ("lux i64 =" (the .#column reference) (the .#column subject)))))) + (and (.text_=# (the .#module reference) (the .#module subject)) + (.i64_=# (the .#line reference) (the .#line subject)) + (.i64_=# (the .#column reference) (the .#column subject)))))) (def .public dummy Location @@ -30,22 +30,22 @@ .#column (, [..dummy {.#Nat (the .#column location)}])])))]}) _ - {.#Left (`` (("lux in-module" (,, (static .prelude)) wrong_syntax_error) (symbol ..here)))}))) + {.#Left (`` ((.in_module# (,, (static .prelude)) wrong_syntax_error) (symbol ..here)))}))) (def .public (format it) (-> Location Text) (let [separator "," [file line column] it] - (all "lux text concat" + (all .text_composite# "@" - (`` (("lux in-module" (,, (static .prelude)) .text#encoded) file)) separator - (`` (("lux in-module" (,, (static .prelude)) .nat#encoded) line)) separator - (`` (("lux in-module" (,, (static .prelude)) .nat#encoded) column))))) + (`` ((.in_module# (,, (static .prelude)) .text#encoded) file)) separator + (`` ((.in_module# (,, (static .prelude)) .nat#encoded) line)) separator + (`` ((.in_module# (,, (static .prelude)) .nat#encoded) column))))) (def \n - ("lux i64 char" +10)) + (.int_char# +10)) (def .public (with location error) (-> Location Text Text) - (all "lux text concat" (..format location) \n + (all .text_composite# (..format location) \n error)) diff --git a/stdlib/source/library/lux/meta/macro/expansion.lux b/stdlib/source/library/lux/meta/macro/expansion.lux index 37bc6bf4c..bbdbe267d 100644 --- a/stdlib/source/library/lux/meta/macro/expansion.lux +++ b/stdlib/source/library/lux/meta/macro/expansion.lux @@ -123,12 +123,12 @@ (do ///.monad [location ///.location output (<func> token) - .let [_ ("lux io log" (all text#composite - (symbol#encoded macro_name) " " (location.format location) - (|> output - (list#each (|>> code.format (all text#composite text.\n text.\t))) - text.together) - text.\n))]] + .let [_ (.log# (all text#composite + (symbol#encoded macro_name) " " (location.format location) + (|> output + (list#each (|>> code.format (all text#composite text.\n text.\t))) + text.together) + text.\n))]] (in (if omit? (list) output))) diff --git a/stdlib/source/library/lux/meta/macro/pattern.lux b/stdlib/source/library/lux/meta/macro/pattern.lux index f4f352efc..e642b1cd3 100644 --- a/stdlib/source/library/lux/meta/macro/pattern.lux +++ b/stdlib/source/library/lux/meta/macro/pattern.lux @@ -21,8 +21,8 @@ (.let [[prelude _] (symbol ._)] (when tokens (list [@ {.#Symbol ["" name]}]) - {.#Right [lux (list (.` ("lux in-module" (., [@ {.#Text prelude}]) - (., [@ {.#Symbol [prelude name]}]))))]} + {.#Right [lux (list (.` (.in_module# (., [@ {.#Text prelude}]) + (., [@ {.#Symbol [prelude name]}]))))]} _ {.#Left ""})))) @@ -95,7 +95,7 @@ [bindings' (monad.each maybe.monad symbol_short bindings) data' (monad.each maybe.monad tuple_list data)] (.let [num_bindings (list.size bindings')] - (if (list.every? (|>> ("lux i64 =" num_bindings)) + (if (list.every? (|>> (.i64_=# num_bindings)) (list#each list.size data')) (.let [apply (is (-> Replacement_Environment (List Code)) (function (_ env) (list#each (realized_template env) templates)))] @@ -175,19 +175,19 @@ false)] expected ..expected_type] (in (list g!temp - (.` ({{.#Some (., g!temp)} + (.` (.when (.is# {.#Apply (., (type_code expected)) Maybe} + (.when (., g!temp) + (.,* (multiG g!temp [mlc body])) + + (.,* (if initial_bind? + (list) + (list g!temp (.` {.#None})))))) + {.#Some (., g!temp)} (., g!temp) {.#None} (.when (., g!temp) - (.,* next_branches))} - ("lux type check" {.#Apply (., (type_code expected)) Maybe} - (.when (., g!temp) - (.,* (multiG g!temp [mlc body])) - - (.,* (if initial_bind? - (list) - (list g!temp (.` {.#None})))))))))))) + (.,* next_branches)))))))) _ (///.failure (..wrong_syntax_error (symbol ..multi))))))) diff --git a/stdlib/source/library/lux/meta/type.lux b/stdlib/source/library/lux/meta/type.lux index a2bec39bf..badf98388 100644 --- a/stdlib/source/library/lux/meta/type.lux +++ b/stdlib/source/library/lux/meta/type.lux @@ -428,17 +428,16 @@ (do meta.monad [location meta.location valueT (meta.type valueN) - .let [_ ("lux io log" - (all text#composite - (symbol#encoded (symbol ..log!)) " " (location.format location) text.new_line - "Expression: " (when valueC - {.#Some valueC} - (code.format valueC) - - {.#None} - (symbol#encoded valueN)) - text.new_line - " Type: " (..format valueT)))]] + .let [_ (.log# (all text#composite + (symbol#encoded (symbol ..log!)) " " (location.format location) text.new_line + "Expression: " (when valueC + {.#Some valueC} + (code.format valueC) + + {.#None} + (symbol#encoded valueN)) + text.new_line + " Type: " (..format valueT)))]] (in (list (code.symbol valueN)))) {.#Right valueC} @@ -478,7 +477,7 @@ type_check (<>.lifted (meta.result lux (expansion.complete it)))] (<| (<code>.locally type_check) <code>.form - (<>.after (<code>.this (` "lux type check"))) + (<>.after (<code>.this (` .is#))) (<>.and <code>.any <code>.any)))) ... TODO: Make sure the generated code always gets optimized away. diff --git a/stdlib/source/library/lux/meta/type/check.lux b/stdlib/source/library/lux/meta/type/check.lux index b36b2b112..bcd8fcadb 100644 --- a/stdlib/source/library/lux/meta/type/check.lux +++ b/stdlib/source/library/lux/meta/type/check.lux @@ -26,11 +26,11 @@ (def !n#= (template (_ reference subject) - [("lux i64 =" reference subject)])) + [(.i64_=# reference subject)])) (def !text#= (template (_ reference subject) - [("lux text =" reference subject)])) + [(.text_=# reference subject)])) (with_template [<name>] [(exception.def .public (<name> id) diff --git a/stdlib/source/library/lux/test/property.lux b/stdlib/source/library/lux/test/property.lux index 2e1739797..732be561f 100644 --- a/stdlib/source/library/lux/test/property.lux +++ b/stdlib/source/library/lux/test/property.lux @@ -248,8 +248,7 @@ run! (is (-> Test //.Test) (|>> (random.result prng) product.right - (function (_ _)) - "lux try" + try (pipe.when {try.#Success output} output diff --git a/stdlib/source/library/lux/world/time/day.lux b/stdlib/source/library/lux/world/time/day.lux index 67a7600d3..60c30a816 100644 --- a/stdlib/source/library/lux/world/time/day.lux +++ b/stdlib/source/library/lux/world/time/day.lux @@ -158,7 +158,7 @@ (Exception Nat) (exception.report (list ["Number" (at n.decimal encoded number)] - ["Valid range" (all "lux text concat" + ["Valid range" (all .text_composite# (at n.decimal encoded (..number {#Sunday})) " ~ " (at n.decimal encoded (..number {#Saturday})))]))) diff --git a/stdlib/source/library/lux/world/time/instant.lux b/stdlib/source/library/lux/world/time/instant.lux index b07bd9652..a9fbc61e2 100644 --- a/stdlib/source/library/lux/world/time/instant.lux +++ b/stdlib/source/library/lux/world/time/instant.lux @@ -166,12 +166,12 @@ @.js (let [date ("js object new" ("js constant" "Date") [])] (|> ("js object do" "getTime" date []) (as Frac) - "lux f64 i64")) + .f64_int#)) @.python (let [time ("python import" "time")] (|> ("python object do" "time" time []) (as Frac) (f.* +1,000.0) - "lux f64 i64")) + .f64_int#)) @.lua (|> ("lua apply" ("lua constant" "os.time") []) (as Int) (i.* +1,000)) @@ -180,7 +180,7 @@ (|> ("ruby object do" "to_f" % []) (as Frac) (f.* +1,000.0) - "lux f64 i64")) + .f64_int#)) @.php (|> ("php constant" "time") "php apply" (as Int) diff --git a/stdlib/source/library/lux/world/time/month.lux b/stdlib/source/library/lux/world/time/month.lux index 814eb32c9..93625a2c2 100644 --- a/stdlib/source/library/lux/world/time/month.lux +++ b/stdlib/source/library/lux/world/time/month.lux @@ -83,7 +83,7 @@ (Exception Nat) (exception.report (list ["Number" (at n.decimal encoded number)] - ["Valid range" (all "lux text concat" + ["Valid range" (all .text_composite# (at n.decimal encoded (..number {#January})) " ~ " (at n.decimal encoded (..number {#December})))]))) diff --git a/stdlib/source/parser/lux/data/binary.lux b/stdlib/source/parser/lux/data/binary.lux index 2a1bf3304..3130b607a 100644 --- a/stdlib/source/parser/lux/data/binary.lux +++ b/stdlib/source/parser/lux/data/binary.lux @@ -49,9 +49,9 @@ (template (<name> <parameter> <subject>) [(<extension> <parameter> <subject>)]))] - [n#= "lux i64 ="] - [n#+ "lux i64 +"] - [n#- "lux i64 -"] + [n#= .i64_=#] + [n#+ .i64_+#] + [n#- .i64_-#] ) (def .public (result parser input) diff --git a/stdlib/source/parser/lux/data/text.lux b/stdlib/source/parser/lux/data/text.lux index 50bb41cb3..dc2507cff 100644 --- a/stdlib/source/parser/lux/data/text.lux +++ b/stdlib/source/parser/lux/data/text.lux @@ -92,7 +92,7 @@ slices parser] (in (list#mix (function (_ [slice::basis slice::distance] [total::basis total::distance]) - [total::basis ("lux i64 +" slice::distance total::distance)]) + [total::basis (.i64_+# slice::distance total::distance)]) [#basis offset #distance 0] slices)))) @@ -102,7 +102,7 @@ (function (_ [offset tape]) (when (/.char offset tape) {.#Some output} - {try.#Success [[("lux i64 +" 1 offset) tape] (/.of_char output)]} + {try.#Success [[(.i64_+# 1 offset) tape] (/.of_char output)]} _ (exception.except ..cannot_parse [])))) @@ -112,7 +112,7 @@ (function (_ [offset tape]) (when (/.char offset tape) {.#Some _} - {try.#Success [[("lux i64 +" 1 offset) tape] + {try.#Success [[(.i64_+# 1 offset) tape] [#basis offset #distance 1]]} @@ -145,7 +145,7 @@ (when (/.index_since offset reference tape) {.#Some where} (if (n.= offset where) - {try.#Success [[("lux i64 +" (/.size reference) offset) tape] + {try.#Success [[(.i64_+# (/.size reference) offset) tape] []]} (exception.except ..cannot_match [reference])) @@ -249,7 +249,7 @@ {.#Some output} (let [output' (/.of_char output)] (if (<modifier> (/.contains? output' options)) - {try.#Success [[("lux i64 +" 1 offset) tape] output']} + {try.#Success [[(.i64_+# 1 offset) tape] output']} (exception.except <exception> [options output]))) _ @@ -267,7 +267,7 @@ {.#Some output} (let [output' (/.of_char output)] (if (<modifier> (/.contains? output' options)) - {try.#Success [[("lux i64 +" 1 offset) tape] + {try.#Success [[(.i64_+# 1 offset) tape] [#basis offset #distance 1]]} (exception.except <exception> [options output]))) @@ -290,7 +290,7 @@ (when (/.char offset tape) {.#Some output} (if (parser output) - {try.#Success [[("lux i64 +" 1 offset) tape] (/.of_char output)]} + {try.#Success [[(.i64_+# 1 offset) tape] (/.of_char output)]} (exception.except ..character_does_not_satisfy_predicate [output])) _ @@ -302,7 +302,7 @@ (when (/.char offset tape) {.#Some output} (if (parser output) - {try.#Success [[("lux i64 +" 1 offset) tape] + {try.#Success [[(.i64_+# 1 offset) tape] [#basis offset #distance 1]]} (exception.except ..character_does_not_satisfy_predicate [output])) @@ -329,7 +329,7 @@ (do //.monad [(open "left[0]") left (open "right[0]") right] - (in [left#basis ("lux i64 +" left#distance right#distance)]))) + (in [left#basis (.i64_+# left#distance right#distance)]))) (with_template [<name> <base> <doc_modifier>] [(def .public (<name> parser) diff --git a/stdlib/source/specification/compositor/generation/common.lux b/stdlib/source/specification/compositor/generation/common.lux index b0f1c2390..099e556e1 100644 --- a/stdlib/source/specification/compositor/generation/common.lux +++ b/stdlib/source/specification/compositor/generation/common.lux @@ -43,8 +43,8 @@ subject r.i64] (with_expansions [<binary> (with_template [<extension> <reference> <param_expr>] [(_.test <extension> - (|> {synthesis.#Extension <extension> (list (synthesis.i64 param) - (synthesis.i64 subject))} + (|> {synthesis.#Extension (symbol <extension>) (list (synthesis.i64 param) + (synthesis.i64 subject))} (run (..safe <extension>)) (pipe.when {try.#Success valueT} @@ -54,10 +54,10 @@ false) (let [param <param_expr>])))] - ["lux i64 and" i64.and param] - ["lux i64 or" i64.or param] - ["lux i64 xor" i64.xor param] - ["lux i64 left-shift" i64.left_shifted (n.% 64 param)] + [.i64_and# i64.and param] + [.i64_or# i64.or param] + [.i64_xor# i64.xor param] + [.i64_left# i64.left_shifted (n.% 64 param)] ["lux i64 logical-right-shift" i64.logic_right_shifted (n.% 64 param)] )] (all _.and @@ -69,9 +69,8 @@ (run (..safe "lux i64 arithmetic-right-shift")) (pipe.when {try.#Success valueT} - ("lux i64 =" - (i64.arithmetic_right_shifted param subject) - (as I64 valueT)) + (.i64_=# (i64.arithmetic_right_shifted param subject) + (as I64 valueT)) {try.#Failure _} false) @@ -81,12 +80,12 @@ (def (i64 run) (-> Runner Test) (do r.monad - [param (|> r.i64 (r.only (|>> ("lux i64 =" 0) not))) + [param (|> r.i64 (r.only (|>> (.i64_=# 0) not))) subject r.i64] (`` (all _.and (,, (with_template [<extension> <type> <prepare> <comp> <subject_expr>] [(_.test <extension> - (|> {synthesis.#Extension <extension> (list (synthesis.i64 subject))} + (|> {synthesis.#Extension (symbol <extension>) (list (synthesis.i64 subject))} (run (..safe <extension>)) (pipe.when {try.#Success valueT} @@ -96,16 +95,16 @@ false) (let [subject <subject_expr>])))] - ["lux i64 f64" Frac i.frac f.= subject] - ["lux i64 char" Text (|>> (as Nat) text.from_code) text#= (|> subject - (as Nat) - (n.% (i64.left_shifted 8 1)) - (as Int))] + [.int_f64# Frac i.frac f.= subject] + [.int_char# Text (|>> (as Nat) text.from_code) text#= (|> subject + (as Nat) + (n.% (i64.left_shifted 8 1)) + (as Int))] )) (,, (with_template [<extension> <reference> <outputT> <comp>] [(_.test <extension> - (|> {synthesis.#Extension <extension> (list (synthesis.i64 param) - (synthesis.i64 subject))} + (|> {synthesis.#Extension (symbol <extension>) (list (synthesis.i64 param) + (synthesis.i64 subject))} (run (..safe <extension>)) (pipe.when {try.#Success valueT} @@ -114,13 +113,14 @@ {try.#Failure _} false)))] - ["lux i64 +" i.+ Int i.=] - ["lux i64 -" i.- Int i.=] - ["lux i64 *" i.* Int i.=] - ["lux i64 /" i./ Int i.=] - ["lux i64 %" i.% Int i.=] - ["lux i64 =" i.= Bit bit#=] - ["lux i64 <" i.< Bit bit#=] + [.i64_+# i.+ Int i.=] + [.i64_-# i.- Int i.=] + [.i64_=# i.= Bit bit#=] + + [.int_<# i.< Bit bit#=] + [.int_*# i.* Int i.=] + [.int_/# i./ Int i.=] + [.int_%# i.% Int i.=] )) )))) @@ -136,21 +136,21 @@ (`` (all _.and (,, (with_template [<extension> <reference> <comp>] [(_.test <extension> - (|> {synthesis.#Extension <extension> (list (synthesis.f64 param) - (synthesis.f64 subject))} + (|> {synthesis.#Extension (symbol <extension>) (list (synthesis.f64 param) + (synthesis.f64 subject))} (run (..safe <extension>)) (//when.verify (<reference> param subject))))] - ["lux f64 +" f.+ f.=] - ["lux f64 -" f.- f.=] - ["lux f64 *" f.* f.=] - ["lux f64 /" f./ f.=] - ["lux f64 %" f.% f.=] + [.f64_+# f.+ f.=] + [.f64_-# f.- f.=] + [.f64_*# f.* f.=] + [.f64_/# f./ f.=] + [.f64_%# f.% f.=] )) (,, (with_template [<extension> <text>] [(_.test <extension> - (|> {synthesis.#Extension <extension> (list (synthesis.f64 param) - (synthesis.f64 subject))} + (|> {synthesis.#Extension (symbol <extension>) (list (synthesis.f64 param) + (synthesis.f64 subject))} (run (..safe <extension>)) (pipe.when {try.#Success valueV} @@ -160,24 +160,14 @@ _ false)))] - ["lux f64 =" f.=] - ["lux f64 <" f.<] + [.f64_=# f.=] + [.f64_<# f.<] )) - (,, (with_template [<extension> <reference>] - [(_.test <extension> - (|> {synthesis.#Extension <extension> (list)} - (run (..safe <extension>)) - (//when.verify <reference>)))] - - ["lux f64 min" ("lux f64 min")] - ["lux f64 max" ("lux f64 max")] - ["lux f64 smallest" ("lux f64 smallest")] - )) - (_.test "'lux f64 i64 && 'lux i64 f64'" - (|> (run (..safe "lux f64 i64") + (_.test ".f64_int# && .int_f64#" + (|> (run (..safe .f64_int#) (|> subject synthesis.f64 - (list) {synthesis.#Extension "lux f64 i64"} - (list) {synthesis.#Extension "lux i64 f64"})) + (list) {synthesis.#Extension (symbol .f64_int#)} + (list) {synthesis.#Extension (symbol .int_f64#)})) (//when.verify subject))) )))) @@ -193,23 +183,23 @@ .let [sample_lowerS (synthesis.text sample_lower) sample_upperS (synthesis.text sample_upper) sample_alphaS (synthesis.text sample_alpha) - concatenatedS {synthesis.#Extension "lux text concat" (list sample_lowerS sample_upperS)} + concatenatedS {synthesis.#Extension (symbol .text_composite#) (list sample_lowerS sample_upperS)} pre_rep_once (format sample_lower sample_upper) post_rep_once (format sample_lower sample_alpha) pre_rep_all (|> sample_lower (list.repeated sample_size) (text.interposed sample_upper)) post_rep_all (|> sample_lower (list.repeated sample_size) (text.interposed sample_alpha))]] (all _.and (_.test "Can compare texts for equality." - (and (|> {synthesis.#Extension "lux text =" (list sample_lowerS sample_lowerS)} - (run (..safe "lux text =")) + (and (|> {synthesis.#Extension (symbol .text_=#) (list sample_lowerS sample_lowerS)} + (run (..safe .text_=#)) (pipe.when {try.#Success valueV} (as Bit valueV) _ false)) - (|> {synthesis.#Extension "lux text =" (list sample_upperS sample_lowerS)} - (run (..safe "lux text =")) + (|> {synthesis.#Extension (symbol .text_=#) (list sample_upperS sample_lowerS)} + (run (..safe .text_=#)) (pipe.when {try.#Success valueV} (not (as Bit valueV)) @@ -217,8 +207,8 @@ _ false)))) (_.test "Can compare texts for order." - (|> {synthesis.#Extension "lux text <" (list sample_lowerS sample_upperS)} - (run (..safe "lux text <")) + (|> {synthesis.#Extension (symbol .text_<#) (list sample_lowerS sample_upperS)} + (run (..safe .text_<#)) (pipe.when {try.#Success valueV} (as Bit valueV) @@ -226,8 +216,8 @@ {try.#Failure _} false))) (_.test "Can get length of text." - (|> {synthesis.#Extension "lux text size" (list sample_lowerS)} - (run (..safe "lux text size")) + (|> {synthesis.#Extension (symbol .text_size#) (list sample_lowerS)} + (run (..safe .text_size#)) (pipe.when {try.#Success valueV} (n.= sample_size (as Nat valueV)) @@ -235,8 +225,8 @@ _ false))) (_.test "Can concatenate text." - (|> {synthesis.#Extension "lux text size" (list concatenatedS)} - (run (..safe "lux text size")) + (|> {synthesis.#Extension (symbol .text_size#) (list concatenatedS)} + (run (..safe .text_size#)) (pipe.when {try.#Success valueV} (n.= (n.* 2 sample_size) (as Nat valueV)) @@ -244,10 +234,10 @@ _ false))) (_.test "Can find index of sub-text." - (and (|> {synthesis.#Extension "lux text index" + (and (|> {synthesis.#Extension (symbol .text_index#) (list concatenatedS sample_lowerS (synthesis.i64 +0))} - (run (..safe "lux text index")) + (run (..safe .text_index#)) (pipe.when (^.multi {try.#Success valueV} [(as (Maybe Nat) valueV) @@ -256,10 +246,10 @@ _ false)) - (|> {synthesis.#Extension "lux text index" + (|> {synthesis.#Extension (symbol .text_index#) (list concatenatedS sample_upperS (synthesis.i64 +0))} - (run (..safe "lux text index")) + (run (..safe .text_index#)) (pipe.when (^.multi {try.#Success valueV} [(as (Maybe Nat) valueV) @@ -270,11 +260,11 @@ false)))) (let [test_clip (is (-> (I64 Any) (I64 Any) Text Bit) (function (_ offset length expected) - (|> {synthesis.#Extension "lux text clip" + (|> {synthesis.#Extension (symbol .text_clip#) (list concatenatedS (synthesis.i64 offset) (synthesis.i64 length))} - (run (..safe "lux text clip")) + (run (..safe .text_clip#)) (pipe.when (^.multi {try.#Success valueV} [(as (Maybe Text) valueV) @@ -287,15 +277,15 @@ (and (test_clip 0 sample_size sample_lower) (test_clip sample_size sample_size sample_upper)))) (_.test "Can extract individual characters from text." - (|> {synthesis.#Extension "lux text char" + (|> {synthesis.#Extension (symbol .text_char#) (list sample_lowerS (synthesis.i64 char_idx))} - (run (..safe "lux text char")) + (run (..safe .text_char#)) (pipe.when (^.multi {try.#Success valueV} [(as (Maybe Int) valueV) {.#Some valueV}]) - (text.contains? ("lux i64 char" valueV) + (text.contains? (.int_char# valueV) sample_lower) _ @@ -308,9 +298,9 @@ [message (r.alphabetic 5)] (all _.and (_.test "Can log messages." - (|> {synthesis.#Extension "lux io log" + (|> {synthesis.#Extension .log# (list (synthesis.text (format "LOG: " message)))} - (run (..safe "lux io log")) + (run (..safe .log#)) (pipe.when {try.#Success valueV} true @@ -318,13 +308,13 @@ {try.#Failure _} false))) (_.test "Can throw runtime errors." - (and (|> {synthesis.#Extension "lux try" + (and (|> {synthesis.#Extension .try# (list (synthesis.function/abstraction [synthesis.#environment (list) synthesis.#arity 1 - synthesis.#body {synthesis.#Extension "lux io error" + synthesis.#body {synthesis.#Extension (symbol .error#) (list (synthesis.text message))}]))} - (run (..safe "lux try")) + (run (..safe .try#)) (pipe.when (^.multi {try.#Success valueV} [(as (Try Text) valueV) @@ -333,12 +323,12 @@ _ false)) - (|> {synthesis.#Extension "lux try" + (|> {synthesis.#Extension .try# (list (synthesis.function/abstraction [synthesis.#environment (list) synthesis.#arity 1 synthesis.#body (synthesis.text message)]))} - (run (..safe "lux try")) + (run (..safe .try#)) (pipe.when (^.multi {try.#Success valueV} [(as (Try Text) valueV) diff --git a/stdlib/source/specification/compositor/generation/primitive.lux b/stdlib/source/specification/compositor/generation/primitive.lux index b9aebc000..167f219e8 100644 --- a/stdlib/source/specification/compositor/generation/primitive.lux +++ b/stdlib/source/specification/compositor/generation/primitive.lux @@ -43,9 +43,9 @@ {try.#Failure _} false))))] - ["bit" synthesis.bit r.bit bit#=] - ["i64" synthesis.i64 r.i64 "lux i64 ="] - ["f64" synthesis.f64 r.frac f.='] + ["bit" synthesis.bit r.bit bit#=] + ["i64" synthesis.i64 r.i64 .i64_=#] + ["f64" synthesis.f64 r.frac f.='] ["text" synthesis.text (r.ascii 5) text#=] )) ))) diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index dbd4166fa..8a5383eea 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -438,7 +438,7 @@ (_.coverage [/.Source] (..found_crosshair?)))) ... (_.coverage [/.require] - ... (`` (with_expansions [<referral> ("lux in-module" "library/lux" library/lux.refer) + ... (`` (with_expansions [<referral> (.in_module# "library/lux" library/lux.refer) ... <alias> (static.random code.text (random.lower_case 1)) ... <definition> (static.random code.local (random.lower_case 1)) ... <module/0> (static.random code.text (random.lower_case 2)) diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux index 97fe18d59..8d560a409 100644 --- a/stdlib/source/test/lux/data/text.lux +++ b/stdlib/source/test/lux/data/text.lux @@ -165,7 +165,7 @@ right (random.unicode 5)] (_.coverage [\\format.format] (/#= (\\format.format left mid right) - (all "lux text concat" left mid right)))) + (all .text_composite# left mid right)))) ..codec (,, (with_template [<format> <alias> <random>] [(do random.monad diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/analysis/inference.lux b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/inference.lux index 9fa7c48ba..511285350 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/analysis/inference.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/analysis/inference.lux @@ -182,7 +182,7 @@ (try.else false)) (|> (/.general archive.empty ..analysis (type_literal (Ex (_ a) (-> a a))) - (list (` ("lux io error" "")))) + (list (` (.error# "")))) //type.inferring (//module.with 0 (product.left name)) (/phase#each (|>> product.right product.left (check.clean (list)) //type.check)) @@ -275,7 +275,7 @@ [(bit#= <verdict> (variant? variantT arity arbitrary_right? <term>))] [#0 term/0] - [#1 (` ("lux io error" ""))])))) + [#1 (` (.error# ""))])))) can_handle_universal_quantification! (and (variant?' (type_literal (All (_ a) (Maybe a))) @@ -298,7 +298,7 @@ [(bit#= <verdict> (variant?' (type_literal (Ex (_ a) (Maybe a))) {.#None} 0 #1 <term>))] [#0 term/0] - [#1 (` ("lux io error" ""))]))))] + [#1 (` (.error# ""))]))))] (and can_match_case! names_do_not_matter! @@ -377,13 +377,13 @@ 2 (list term/0 term/1))) (record? (Ex (_ a) (Tuple type/0 a)) {.#None} - 2 (list term/0 (` ("lux io error" "")))) + 2 (list term/0 (` (.error# "")))) (not (record? (Ex (_ a) (Tuple a type/0)) {.#Some (Tuple type/1 type/0)} 2 (list term/1 term/0))) (record? (Ex (_ a) (Tuple a type/0)) {.#None} - 2 (list (` ("lux io error" "")) term/0)))] + 2 (list (` (.error# "")) term/0)))] (and can_infer_record! names_do_not_matter! can_handle_universal_quantification! diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis.lux index 06fc6be98..f459b1735 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis.lux @@ -639,12 +639,12 @@ (let [state [extension.#bundle (extension/analysis.bundle ..eval) extension.#state lux]] (|> (do phase.monad - [[:it: it] (|> (` ("lux text concat" (, (code.text text/0)) (, (code.text text/0)))) + [[:it: it] (|> (` (.text_composite# (, (code.text text/0)) (, (code.text text/0)))) (/.phase ..expander archive.empty) //type.inferring)] (in (and (type#= .Text :it:) (when it - {//.#Extension "lux text concat" (list (//.text left) (//.text right))} + {//.#Extension (symbol .text_composite#) (list (//.text left) (//.text right))} (and (same? text/0 left) (same? text/0 right)) diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/function.lux index 48a85af95..bfc7e48a8 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/function.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/analysis/function.lux @@ -175,7 +175,7 @@ ... (inferring? (All (_ a) (-> a a)) $argument/0) ... (inferring? (All (_ @0) (-> @0 @0 (And .Bit @0))) ... (` ([(, $function/1) (, $argument/1)] - ... [("lux is" (, $argument/0) (, $argument/1)) + ... [(.is?# (, $argument/0) (, $argument/1)) ... (, $argument/1)])))))) (_.coverage [/.cannot_analyse] (|> (do //phase.monad @@ -233,7 +233,7 @@ ... (reification? (All (_ a) (-> a a a)) (list term/0) (-> input/0 input/0)) ... (reification? (All (_ a) (-> input/0 a)) (list term/0) .Nothing) ... (reification? (All (_ a b) (-> a b a)) (list term/0) (All (_ b) (-> b input/0))) - ... (reification? (Ex (_ a) (-> a input/0)) (list (` ("lux io error" ""))) input/0) + ... (reification? (Ex (_ a) (-> a input/0)) (list (` (.error# ""))) input/0) ... (reification? (Ex (_ a) (-> input/0 a)) (list term/0) .Any)))) (_.coverage [/.cannot_apply] (|> (do //phase.monad diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux index f100c1e07..38cf80869 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux @@ -64,12 +64,12 @@ (r.only (|>> product.left (type#= primT) not)))] (all _.and (_.test "Can test for reference equality." - (check_success+ "lux is" (list primC primC) Bit)) + (check_success+ (` .is?#) (list primC primC) Bit)) (_.test "Reference equality must be done with elements of the same type." - (check_failure+ "lux is" (list primC antiC) Bit)) + (check_failure+ (` .is?#) (list primC antiC) Bit)) (_.test "Can 'try' risky IO computations." - (check_success+ "lux try" - (list (` ("lux io error" "YOLO"))) + (check_success+ (` .try#) + (list (` (.error# "YOLO"))) (type_literal (Either Text primT)))) ))) @@ -81,23 +81,23 @@ paramC (|> r.nat (at ! each code.nat))] (all _.and (_.test "i64 'and'." - (check_success+ "lux i64 and" (list paramC subjectC) Nat)) + (check_success+ (symbol .i64_and#) (list paramC subjectC) Nat)) (_.test "i64 'or'." - (check_success+ "lux i64 or" (list paramC subjectC) Nat)) + (check_success+ (symbol .i64_or#) (list paramC subjectC) Nat)) (_.test "i64 'xor'." - (check_success+ "lux i64 xor" (list paramC subjectC) Nat)) + (check_success+ (symbol .i64_xor#) (list paramC subjectC) Nat)) (_.test "i64 left-shift." - (check_success+ "lux i64 left-shift" (list paramC subjectC) Nat)) + (check_success+ (symbol .i64_left#) (list paramC subjectC) Nat)) (_.test "i64 logical-right-shift." (check_success+ "lux i64 logical-right-shift" (list paramC subjectC) Nat)) (_.test "i64 arithmetic-right-shift." (check_success+ "lux i64 arithmetic-right-shift" (list paramC signedC) Int)) (_.test "i64 equivalence." - (check_success+ "lux i64 =" (list paramC subjectC) Bit)) + (check_success+ (symbol .i64_=#) (list paramC subjectC) Bit)) (_.test "i64 addition." - (check_success+ "lux i64 +" (list paramC subjectC) Int)) + (check_success+ (symbol .i64_+#) (list paramC subjectC) Int)) (_.test "i64 subtraction." - (check_success+ "lux i64 -" (list paramC subjectC) Int)) + (check_success+ (symbol .i64_-#) (list paramC subjectC) Int)) ))) (def int @@ -107,17 +107,17 @@ paramC (|> r.int (at ! each code.int))] (all _.and (_.test "Can multiply integers." - (check_success+ "lux i64 *" (list paramC subjectC) Int)) + (check_success+ (symbol .int_*#) (list paramC subjectC) Int)) (_.test "Can divide integers." - (check_success+ "lux i64 /" (list paramC subjectC) Int)) + (check_success+ (symbol .int_/#) (list paramC subjectC) Int)) (_.test "Can calculate remainder of integers." - (check_success+ "lux i64 %" (list paramC subjectC) Int)) + (check_success+ (symbol .int_%#) (list paramC subjectC) Int)) (_.test "Can compare integers." - (check_success+ "lux i64 <" (list paramC subjectC) Bit)) + (check_success+ (symbol .int_<#) (list paramC subjectC) Bit)) (_.test "Can convert integer to text." - (check_success+ "lux i64 char" (list subjectC) Text)) + (check_success+ (symbol .int_char#) (list subjectC) Text)) (_.test "Can convert integer to fraction." - (check_success+ "lux i64 f64" (list subjectC) Frac)) + (check_success+ (symbol .int_f64#) (list subjectC) Frac)) ))) (def frac @@ -128,31 +128,25 @@ encodedC (|> r.safe_frac (at ! each (|>> %.frac code.text)))] (all _.and (_.test "Can add frac numbers." - (check_success+ "lux f64 +" (list paramC subjectC) Frac)) + (check_success+ (symbol .f64_+#) (list paramC subjectC) Frac)) (_.test "Can subtract frac numbers." - (check_success+ "lux f64 -" (list paramC subjectC) Frac)) + (check_success+ (symbol .f64_-#) (list paramC subjectC) Frac)) (_.test "Can multiply frac numbers." - (check_success+ "lux f64 *" (list paramC subjectC) Frac)) + (check_success+ (symbol .f64_*#) (list paramC subjectC) Frac)) (_.test "Can divide frac numbers." - (check_success+ "lux f64 /" (list paramC subjectC) Frac)) + (check_success+ (symbol .f64_/#) (list paramC subjectC) Frac)) (_.test "Can calculate remainder of frac numbers." - (check_success+ "lux f64 %" (list paramC subjectC) Frac)) + (check_success+ (symbol .f64_%#) (list paramC subjectC) Frac)) (_.test "Can test equivalence of frac numbers." - (check_success+ "lux f64 =" (list paramC subjectC) Bit)) + (check_success+ (symbol .f64_=#) (list paramC subjectC) Bit)) (_.test "Can compare frac numbers." - (check_success+ "lux f64 <" (list paramC subjectC) Bit)) - (_.test "Can obtain minimum frac number." - (check_success+ "lux f64 min" (list) Frac)) - (_.test "Can obtain maximum frac number." - (check_success+ "lux f64 max" (list) Frac)) - (_.test "Can obtain smallest frac number." - (check_success+ "lux f64 smallest" (list) Frac)) + (check_success+ (symbol .f64_<#) (list paramC subjectC) Bit)) (_.test "Can convert frac number to integer." - (check_success+ "lux f64 i64" (list subjectC) Int)) + (check_success+ (symbol .f64_int#) (list subjectC) Int)) (_.test "Can convert frac number to text." - (check_success+ "lux f64 encode" (list subjectC) Text)) + (check_success+ (symbol .f64_encoded#) (list subjectC) Text)) (_.test "Can convert text to frac number." - (check_success+ "lux f64 decode" (list encodedC) (type_literal (Maybe Frac)))) + (check_success+ (symbol .f64_decoded#) (list encodedC) (type_literal (Maybe Frac)))) ))) (def text @@ -165,19 +159,19 @@ toC (|> r.nat (at ! each code.nat))] (all _.and (_.test "Can test text equivalence." - (check_success+ "lux text =" (list paramC subjectC) Bit)) + (check_success+ (symbol .text_=#) (list paramC subjectC) Bit)) (_.test "Compare texts in lexicographical order." - (check_success+ "lux text <" (list paramC subjectC) Bit)) + (check_success+ (symbol .text_<#) (list paramC subjectC) Bit)) (_.test "Can concatenate one text to another." - (check_success+ "lux text concat" (list subjectC paramC) Text)) + (check_success+ (symbol .text_composite#) (list subjectC paramC) Text)) (_.test "Can find the index of a piece of text inside a larger one that (may) contain it." - (check_success+ "lux text index" (list fromC paramC subjectC) (type_literal (Maybe Nat)))) + (check_success+ (symbol .text_index#) (list fromC paramC subjectC) (type_literal (Maybe Nat)))) (_.test "Can query the size/length of a text." - (check_success+ "lux text size" (list subjectC) Nat)) + (check_success+ (symbol .text_size#) (list subjectC) Nat)) (_.test "Can obtain the character code of a text at a given index." - (check_success+ "lux text char" (list fromC subjectC) Nat)) + (check_success+ (symbol .text_char#) (list fromC subjectC) Nat)) (_.test "Can clip a piece of text between 2 indices." - (check_success+ "lux text clip" (list fromC toC subjectC) Text)) + (check_success+ (symbol .text_clip#) (list fromC toC subjectC) Text)) ))) (def io @@ -187,9 +181,9 @@ exitC (|> r.int (at ! each code.int))] (all _.and (_.test "Can log messages to standard output." - (check_success+ "lux io log" (list logC) Any)) + (check_success+ (symbol .log#) (list logC) Any)) (_.test "Can throw a run-time error." - (check_success+ "lux io error" (list logC) Nothing)) + (check_success+ (symbol .error#) (list logC) Nothing)) ))) (def .public test diff --git a/stdlib/source/unsafe/lux/data/binary.lux b/stdlib/source/unsafe/lux/data/binary.lux index d3b824dfb..1e79c9480 100644 --- a/stdlib/source/unsafe/lux/data/binary.lux +++ b/stdlib/source/unsafe/lux/data/binary.lux @@ -70,7 +70,7 @@ (,, (.static @.js)) (.|> <size> .int - "lux i64 f64" + .int_f64# [] ("js object new" ("js constant" "ArrayBuffer")) [] @@ -101,7 +101,7 @@ (.|> <it> ("js object get" "length") (.as .Frac) - "lux f64 i64" + .f64_int# .nat) (,, (.static @.python)) @@ -126,7 +126,7 @@ <jvm> (ffi.byte_to_long <jvm>) <jvm> (.|> <jvm> (.as .I64) - ("lux i64 and" <byte_mask>))] + (.i64_and# <byte_mask>))] (def .public bits_8 (template (bits_8 index it) [(.<| (.as .I64) @@ -139,7 +139,7 @@ (.as (array.Array .Frac)) ("js array read" <index>) (.as .Frac) - "lux f64 i64" + .f64_int# .i64) (,, (.static @.python)) @@ -161,9 +161,9 @@ it (.is ..Binary it')]) (.as .I64) (.is (.I64 .Any)) - (.all "lux i64 or" - ("lux i64 left-shift" 8 (..bits_8 index it)) - (..bits_8 ("lux i64 +" 1 index) it)))])) + (.all .i64_or# + (.i64_left# 08 (..bits_8 index it)) + (..bits_8 (.i64_+# 1 index) it)))])) (def .public bits_32 (template (bits_32 index' it') @@ -171,11 +171,11 @@ it (.is ..Binary it')]) (.as .I64) (.is (.I64 .Any)) - (.all "lux i64 or" - ("lux i64 left-shift" 24 (..bits_8 index it)) - ("lux i64 left-shift" 16 (..bits_8 ("lux i64 +" 1 index) it)) - ("lux i64 left-shift" 8 (..bits_8 ("lux i64 +" 2 index) it)) - (..bits_8 ("lux i64 +" 3 index) it)))])) + (.all .i64_or# + (.i64_left# 24 (..bits_8 index it)) + (.i64_left# 16 (..bits_8 (.i64_+# 1 index) it)) + (.i64_left# 08 (..bits_8 (.i64_+# 2 index) it)) + (..bits_8 (.i64_+# 3 index) it)))])) (def .public bits_64 (template (bits_64 index' it') @@ -183,15 +183,15 @@ it (.is ..Binary it')]) (.as .I64) (.is (.I64 .Any)) - (.all "lux i64 or" - ("lux i64 left-shift" 56 (..bits_8 index it)) - ("lux i64 left-shift" 48 (..bits_8 ("lux i64 +" 1 index) it)) - ("lux i64 left-shift" 40 (..bits_8 ("lux i64 +" 2 index) it)) - ("lux i64 left-shift" 32 (..bits_8 ("lux i64 +" 3 index) it)) - ("lux i64 left-shift" 24 (..bits_8 ("lux i64 +" 4 index) it)) - ("lux i64 left-shift" 16 (..bits_8 ("lux i64 +" 5 index) it)) - ("lux i64 left-shift" 8 (..bits_8 ("lux i64 +" 6 index) it)) - (..bits_8 ("lux i64 +" 7 index) it)))])) + (.all .i64_or# + (.i64_left# 56 (..bits_8 index it)) + (.i64_left# 48 (..bits_8 (.i64_+# 1 index) it)) + (.i64_left# 40 (..bits_8 (.i64_+# 2 index) it)) + (.i64_left# 32 (..bits_8 (.i64_+# 3 index) it)) + (.i64_left# 24 (..bits_8 (.i64_+# 4 index) it)) + (.i64_left# 16 (..bits_8 (.i64_+# 5 index) it)) + (.i64_left# 08 (..bits_8 (.i64_+# 6 index) it)) + (..bits_8 (.i64_+# 7 index) it)))])) (with_expansions [<byte> (hex "FF") <it> (.is ..Binary it) @@ -219,8 +219,8 @@ ("js array write" <index> (.|> <value> .int - ("lux i64 and" (.int <byte>)) - "lux i64 f64" + (.i64_and# (.int <byte>)) + .int_f64# .as_expected)) (.as ..Binary)) @@ -228,7 +228,7 @@ (.|> <it> (.is ..Binary) (.as (array.Array (.I64 .Any))) - ("python array write" <index> (.|> <value> ("lux i64 and" <byte>) (.is (.I64 .Any)))) + ("python array write" <index> (.|> <value> (.i64_and# <byte>) (.is (.I64 .Any)))) (.as ..Binary)) (,, (.static @.scheme)) @@ -238,52 +238,52 @@ it')) ... Default - (array.has! <index> (.|> <value> .int ("lux i64 and" (.int <byte>))) <it>)))])))) + (array.has! <index> (.|> <value> .int (.i64_and# (.int <byte>))) <it>)))])))) (def .public has_16! (template (has_16! index' value' it) [(.let [index (.is .Nat index') value (.is (.I64 .Any) value')] (.|> it - (..has_8! index ("lux i64 right-shift" 8 value)) - (..has_8! ("lux i64 +" 1 index) value)))])) + (..has_8! index (.i64_right# 08 value)) + (..has_8! (.i64_+# 1 index) value)))])) (def .public has_32! (template (has_32! index' value' it) [(.let [index (.is .Nat index') value (.is (.I64 .Any) value')] (.|> it - (..has_8! index ("lux i64 right-shift" 24 value)) - (..has_8! ("lux i64 +" 1 index) ("lux i64 right-shift" 16 value)) - (..has_8! ("lux i64 +" 2 index) ("lux i64 right-shift" 8 value)) - (..has_8! ("lux i64 +" 3 index) value)))])) + (..has_8! index (.i64_right# 24 value)) + (..has_8! (.i64_+# 1 index) (.i64_right# 16 value)) + (..has_8! (.i64_+# 2 index) (.i64_right# 08 value)) + (..has_8! (.i64_+# 3 index) value)))])) (`` (def .public has_64! (template (has_64! index' value' it) [(.let [index (.is .Nat index') value (.is (.I64 .Any) value')] (.for (,, (.static @.scheme)) (.let [write_high (.is (.-> ..Binary ..Binary) - (.|>> (..has_8! index ("lux i64 right-shift" 56 value)) - (..has_8! ("lux i64 +" 1 index) ("lux i64 right-shift" 48 value)) - (..has_8! ("lux i64 +" 2 index) ("lux i64 right-shift" 40 value)) - (..has_8! ("lux i64 +" 3 index) ("lux i64 right-shift" 32 value)))) + (.|>> (..has_8! index (.i64_right# 56 value)) + (..has_8! (.i64_+# 1 index) (.i64_right# 48 value)) + (..has_8! (.i64_+# 2 index) (.i64_right# 40 value)) + (..has_8! (.i64_+# 3 index) (.i64_right# 32 value)))) write_low (.is (.-> ..Binary ..Binary) - (.|>> (..has_8! ("lux i64 +" 4 index) ("lux i64 right-shift" 24 value)) - (..has_8! ("lux i64 +" 5 index) ("lux i64 right-shift" 16 value)) - (..has_8! ("lux i64 +" 6 index) ("lux i64 right-shift" 8 value)) - (..has_8! ("lux i64 +" 7 index) value)))] + (.|>> (..has_8! (.i64_+# 4 index) (.i64_right# 24 value)) + (..has_8! (.i64_+# 5 index) (.i64_right# 16 value)) + (..has_8! (.i64_+# 6 index) (.i64_right# 08 value)) + (..has_8! (.i64_+# 7 index) value)))] (.|> it write_high write_low)) (.|> it - (..has_8! index ("lux i64 right-shift" 56 value)) - (..has_8! ("lux i64 +" 1 index) ("lux i64 right-shift" 48 value)) - (..has_8! ("lux i64 +" 2 index) ("lux i64 right-shift" 40 value)) - (..has_8! ("lux i64 +" 3 index) ("lux i64 right-shift" 32 value)) - (..has_8! ("lux i64 +" 4 index) ("lux i64 right-shift" 24 value)) - (..has_8! ("lux i64 +" 5 index) ("lux i64 right-shift" 16 value)) - (..has_8! ("lux i64 +" 6 index) ("lux i64 right-shift" 8 value)) - (..has_8! ("lux i64 +" 7 index) value))))]))) + (..has_8! index (.i64_right# 56 value)) + (..has_8! (.i64_+# 1 index) (.i64_right# 48 value)) + (..has_8! (.i64_+# 2 index) (.i64_right# 40 value)) + (..has_8! (.i64_+# 3 index) (.i64_right# 32 value)) + (..has_8! (.i64_+# 4 index) (.i64_right# 24 value)) + (..has_8! (.i64_+# 5 index) (.i64_right# 16 value)) + (..has_8! (.i64_+# 6 index) (.i64_right# 08 value)) + (..has_8! (.i64_+# 7 index) value))))]))) (with_expansions [<reference> (.is ..Binary reference') <sample> (.is ..Binary sample') @@ -296,14 +296,13 @@ (.let [reference <reference> sample <sample> limit (..size reference)] - (.and ("lux i64 =" limit (..size sample)) + (.and (.i64_=# limit (..size sample)) (.loop (again [index 0]) - (.if ("lux i64 =" limit index) + (.if (.i64_=# limit index) .true - (.and ("lux i64 =" - (..bits_8 index reference) - (..bits_8 index sample)) - (again ("lux i64 +" 1 index))))))))])))) + (.and (.i64_=# (..bits_8 index reference) + (..bits_8 index sample)) + (again (.i64_+# 1 index))))))))])))) ... TODO: Turn into a template ASAP. (`` (def .public copy! @@ -320,19 +319,19 @@ ... Default (.loop (again [index 0]) - (.if ("lux i64 <" (.int bytes) (.int index)) + (.if (.int_<# (.int bytes) (.int index)) (.exec - (..has_8! ("lux i64 +" target_offset index) - (..bits_8 ("lux i64 +" source_offset index) source) + (..has_8! (.i64_+# target_offset index) + (..bits_8 (.i64_+# source_offset index) source) target) - (again ("lux i64 +" 1 index))) + (again (.i64_+# 1 index))) target))))))) ... TODO: Turn into a template ASAP. (`` (with_expansions [<jvm> (java/util/Arrays::copyOfRange binary (ffi.as_int (.int offset)) (ffi.as_int (.int limit))) - <jvm> (.let [limit ("lux i64 +" size offset)] + <jvm> (.let [limit (.i64_+# size offset)] <jvm>)] (def .public slice (inlined (_ offset size binary) diff --git a/stdlib/source/unsafe/lux/data/collection/array.lux b/stdlib/source/unsafe/lux/data/collection/array.lux index 870e9eb4b..6f85f60bb 100644 --- a/stdlib/source/unsafe/lux/data/collection/array.lux +++ b/stdlib/source/unsafe/lux/data/collection/array.lux @@ -86,7 +86,7 @@ (.-> .Nat (..Array' r w) .Bit)) (.function (lacks? index array) (.let [size (..size array)] - (.if ("lux i64 <" (.int size) (.int index)) + (.if (.int_<# (.int size) (.int index)) (.for (,, (.static @.old)) ("jvm object null?" ("jvm aaload" array index)) @@ -155,7 +155,7 @@ (.-> .Nat (..Array' r w) (..Array' r w))) (.function (lacks! index array) (.let [size (..size array)] - (.if ("lux i64 <" (.int size) (.int index)) + (.if (.int_<# (.int size) (.int index)) (.for (,, (.static @.old)) (..has! index (.as_expected ("jvm object null")) array) @@ -201,14 +201,14 @@ (..Array' r w))) (.function (copy! length src_start src_array dest_start dest_array) (.loop (again [offset 0]) - (.if ("lux i64 <" (.int length) (.int offset)) + (.if (.int_<# (.int length) (.int offset)) (.exec - (.if (..lacks? ("lux i64 +" offset src_start) src_array) - (..lacks! ("lux i64 +" offset dest_start) dest_array) - (..has! ("lux i64 +" offset dest_start) - (..item ("lux i64 +" offset src_start) src_array) + (.if (..lacks? (.i64_+# offset src_start) src_array) + (..lacks! (.i64_+# offset dest_start) dest_array) + (..has! (.i64_+# offset dest_start) + (..item (.i64_+# offset src_start) src_array) dest_array)) - (again ("lux i64 +" 1 offset))) + (again (.i64_+# 1 offset))) dest_array)))) <length> <src_start> <src_array> <dest_start> <dest_array>)])) @@ -220,15 +220,15 @@ (.let [size (..size array)] (.loop (again [index 0 it 0]) - (.if ("lux i64 <" (.int size) (.int index)) + (.if (.int_<# (.int size) (.int index)) (.if (..lacks? index array) - (again ("lux i64 +" 1 index) <when_lacks>) - (again ("lux i64 +" 1 index) <when_has>)) + (again (.i64_+# 1 index) <when_lacks>) + (again (.i64_+# 1 index) <when_has>)) it))))) <array>)]))] - [occupancy it ("lux i64 +" 1 it)] - [vacancy ("lux i64 +" 1 it) it] + [occupancy it (.i64_+# 1 it)] + [vacancy (.i64_+# 1 it) it] ) (def .public only! @@ -238,14 +238,14 @@ (.function (only! ? it) (.let [size (..size it)] (.loop (again [index 0]) - (.if ("lux i64 <" (.int size) (.int index)) + (.if (.int_<# (.int size) (.int index)) (.exec (.if (..lacks? index it) it (.if (? (..item index it)) it (..lacks! index it))) - (again ("lux i64 +" 1 index))) + (again (.i64_+# 1 index))) it))))) <?> <it>)])) @@ -257,13 +257,13 @@ (.function (<name> ? it) (.let [size (..size it)] (.loop (again [index 0]) - (.if ("lux i64 <" (.int size) (.int index)) + (.if (.int_<# (.int size) (.int index)) (.if (..lacks? index it) - (again ("lux i64 +" 1 index)) + (again (.i64_+# 1 index)) (.let [it (..item index it)] (.if <test> {.#Some <term>} - (again ("lux i64 +" 1 index))))) + (again (.i64_+# 1 index))))) {.#None}))))) <?> <it>)]))] @@ -294,7 +294,7 @@ {.#Item head tail} (.exec (..has! index head output) - (again ("lux i64 +" 1 index) tail))))))) + (again (.i64_+# 1 index) tail))))))) <input>)])) (def underflow @@ -305,11 +305,11 @@ (template (list|-default <empty> <array>) [((.is (.All (_ r w) (.-> (.List r) (..Array' r w) (.List r))) (.function (list|-default empty array) - (.loop (again [index ("lux i64 -" 1 (..size array)) + (.loop (again [index (.i64_-# 1 (..size array)) output empty]) - (.if ("lux i64 =" (,, (.static ..underflow)) index) + (.if (.i64_=# (,, (.static ..underflow)) index) output - (again ("lux i64 -" 1 index) + (again (.i64_-# 1 index) (.if (..lacks? index array) output {.#Item (..item index array) output})))))) @@ -319,12 +319,12 @@ (template (list|+default <default> <array>) [((.is (.All (_ r w) (.-> r (..Array' r w) (.List r))) (.function (list|+default default array) - (.loop (again [index ("lux i64 -" 1 (..size array)) + (.loop (again [index (.i64_-# 1 (..size array)) output (`` (.is (.List (,, (.these (,, (.type_of default))))) {.#End}))]) - (.if ("lux i64 =" (,, (.static ..underflow)) index) + (.if (.i64_=# (,, (.static ..underflow)) index) output - (again ("lux i64 -" 1 index) + (again (.i64_-# 1 index) {.#Item (.if (..lacks? index array) default (..item index array)) @@ -348,16 +348,16 @@ [((.is (.All (_ r w0 w1) (.-> (.-> r r .Bit) (..Array' r w0) (..Array' r w1) .Bit)) (.function (= //#= left/* right/*) (.let [size (..size left/*)] - (.and ("lux i64 =" (..size right/*) size) + (.and (.i64_=# (..size right/*) size) (.loop (again [index 0]) - (.if ("lux i64 <" (.int size) (.int index)) + (.if (.int_<# (.int size) (.int index)) (.if (..lacks? index left/*) (..lacks? index right/*) (.if (..lacks? index right/*) .false (.and (//#= (..item index left/*) (..item index right/*)) - (again ("lux i64 +" 1 index))))) + (again (.i64_+# 1 index))))) true)))))) <//#=> <left/*> <right/*>)])) @@ -367,7 +367,7 @@ (.function (composite left/* right/*) (.let [|left| (..size left/*) |right| (..size right/*)] - (.|> (..empty ("lux i64 +" |left| |right|)) + (.|> (..empty (.i64_+# |left| |right|)) (..copy! |left| 0 left/* 0) (..copy! |right| 0 right/* |left|))))) <left/*> <right/*>)])) @@ -380,10 +380,10 @@ (.let [size (..size it)] (.loop (again [index 0 so_far init]) - (.if ("lux i64 <" (.int size) (.int index)) + (.if (.int_<# (.int size) (.int index)) (.if (..lacks? index it) - (again ("lux i64 +" 1 index) so_far) - (again ("lux i64 +" 1 index) ($ index (..item index it) so_far))) + (again (.i64_+# 1 index) so_far) + (again (.i64_+# 1 index) ($ index (..item index it) so_far))) so_far))))) <$> <init> <it>)])) @@ -406,11 +406,11 @@ (.function (<name> ? it) (.let [size (..size it)] (.loop (again [index 0]) - (.if ("lux i64 <" (.int size) (.int index)) + (.if (.int_<# (.int size) (.int index)) (.if (..lacks? index it) - (again ("lux i64 +" 1 index)) + (again (.i64_+# 1 index)) (<op> (? (..item index it)) - (again ("lux i64 +" 1 index)))) + (again (.i64_+# 1 index)))) <init>))))) <?> <it>)]))] @@ -425,8 +425,8 @@ (.function (one ? it) (.let [size (..size it)] (.loop (again [index 0]) - (.if ("lux i64 <" (.int size) (.int index)) - (with_expansions [<again> (again ("lux i64 +" 1 index))] + (.if (.int_<# (.int size) (.int index)) + (with_expansions [<again> (again (.i64_+# 1 index))] (.if (..lacks? index it) <again> (.when (? (..item index it)) |