From 820ffc0a87d7960e62508fc451d9df7a94a6afa7 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 19 Oct 2022 19:34:33 -0400 Subject: Migrating default extensions to the new format [Part 2] --- stdlib/source/library/lux.lux | 1637 +++++++++----------- stdlib/source/library/lux/abstract/comonad.lux | 2 +- stdlib/source/library/lux/abstract/monad.lux | 4 +- .../library/lux/control/concurrency/thread.lux | 2 +- stdlib/source/library/lux/control/exception.lux | 6 +- .../source/library/lux/control/function/inline.lux | 2 +- .../lux/control/function/polymorphism/context.lux | 2 +- .../control/function/polymorphism/predicate.lux | 2 +- stdlib/source/library/lux/control/try.lux | 10 +- stdlib/source/library/lux/data/collection/bits.lux | 7 +- stdlib/source/library/lux/data/collection/list.lux | 8 +- stdlib/source/library/lux/data/product.lux | 5 +- stdlib/source/library/lux/data/sum.lux | 4 +- stdlib/source/library/lux/data/text.lux | 44 +- stdlib/source/library/lux/data/text/escape.lux | 30 +- stdlib/source/library/lux/debug.lux | 8 +- stdlib/source/library/lux/documentation.lux | 2 +- stdlib/source/library/lux/ffi.php.lux | 10 - stdlib/source/library/lux/ffi.scm.lux | 10 - stdlib/source/library/lux/math.lux | 44 +- stdlib/source/library/lux/math/number.lux | 2 +- stdlib/source/library/lux/math/number/frac.lux | 190 ++- stdlib/source/library/lux/math/number/i64.lux | 16 +- stdlib/source/library/lux/math/number/int.lux | 40 +- stdlib/source/library/lux/math/number/nat.lux | 90 +- stdlib/source/library/lux/math/number/rev.lux | 75 +- stdlib/source/library/lux/math/random.lux | 6 +- stdlib/source/library/lux/meta.lux | 6 +- .../library/lux/meta/compiler/default/init.lux | 24 +- .../compiler/language/lux/analysis/evaluation.lux | 15 +- .../meta/compiler/language/lux/analysis/module.lux | 22 +- .../meta/compiler/language/lux/phase/analysis.lux | 118 +- .../language/lux/phase/extension/analysis/jvm.lux | 115 +- .../language/lux/phase/extension/analysis/lux.lux | 149 +- .../lux/phase/extension/declaration/lux.lux | 29 +- .../lux/phase/extension/generation/js/common.lux | 2 +- .../lux/phase/extension/generation/jvm/common.lux | 121 +- .../lux/phase/extension/generation/jvm/host.lux | 268 ++-- .../lux/phase/extension/generation/lua/common.lux | 2 +- .../phase/extension/generation/python/common.lux | 2 +- .../lux/phase/extension/generation/ruby/common.lux | 2 +- .../compiler/language/lux/phase/synthesis/loop.lux | 4 +- .../lux/meta/compiler/language/lux/syntax.lux | 248 +-- stdlib/source/library/lux/meta/compiler/phase.lux | 14 +- stdlib/source/library/lux/meta/location.lux | 20 +- stdlib/source/library/lux/meta/macro/expansion.lux | 12 +- stdlib/source/library/lux/meta/macro/pattern.lux | 24 +- stdlib/source/library/lux/meta/type.lux | 23 +- stdlib/source/library/lux/meta/type/check.lux | 4 +- stdlib/source/library/lux/test/property.lux | 3 +- stdlib/source/library/lux/world/time/day.lux | 2 +- stdlib/source/library/lux/world/time/instant.lux | 6 +- stdlib/source/library/lux/world/time/month.lux | 2 +- 53 files changed, 1751 insertions(+), 1744 deletions(-) (limited to 'stdlib/source/library') 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))) (|>> ( 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 (_ ) [(if - {..#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 (_ ) - [((`` ("lux in-module" (,, (static .prelude)) .wrong_syntax_error)) + [((`` (.in_module# (,, (static .prelude)) .wrong_syntax_error)) (symbol ))])) (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 [ ] [(def .public (..of_char )) @@ -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 [ ] [ (let [[previous' current' limit'] (ascii_escaped 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 [ ] [ (let [[previous' current' limit'] (..ascii_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 .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 .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 .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.+] [Complex (type.expecting Complex (phase archive (` ))) 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.-] [Complex (type.expecting Complex (phase archive (` ))) 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.*] [Complex (type.expecting Complex (phase archive (` ))) 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./] [Complex (type.expecting Complex (phase archive (` ))) 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 [ ] @@ -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 [ ] @@ -243,7 +243,7 @@ (-> Frac Frac) (|> ("ruby object do" 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 [ ] @@ -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 [ ] [(def .public ( it) (-> Frac Frac) - (|> (..exp it) ( (..exp ("lux f64 *" -1.0 it))) ("lux f64 /" +2.0))) + (|> (..exp it) ( (..exp (.f64_*# -1.0 it))) (.f64_/# +2.0))) (def .public ( it) (-> Frac Frac) - (|> +2.0 ("lux f64 /" (|> (..exp it) ( (..exp ("lux f64 *" -1.0 it)))))))] + (|> +2.0 (.f64_/# (|> (..exp it) ( (..exp (.f64_*# -1.0 it)))))))] - [sinh "lux f64 -" csch] - [cosh "lux f64 +" sech] + [sinh .f64_-# csch] + [cosh .f64_+# sech] ) (with_template [ ] [(def .public ( it) (-> Frac Frac) (let [e+ (exp it) - e- (exp ("lux f64 *" -1.0 it)) - sinh' (|> e+ ("lux f64 -" e-)) - cosh' (|> e+ ("lux f64 +" e-))] - (|> ("lux f64 /" ))))] + e- (exp (.f64_*# -1.0 it)) + sinh' (|> e+ (.f64_-# e-)) + cosh' (|> e+ (.f64_+# e-))] + (|> (.f64_/# ))))] [tanh sinh' cosh'] [coth cosh' sinh'] @@ -404,18 +402,18 @@ (with_template [ ] [(def .public ( it) (-> Frac Frac) - (|> it (pow +2.0) ( +1.0) (pow +0.5) ("lux f64 +" it) log))] + (|> it (pow +2.0) ( +1.0) (pow +0.5) (.f64_+# it) log))] - [asinh "lux f64 +"] - [acosh "lux f64 -"] + [asinh .f64_+#] + [acosh .f64_-#] ) (with_template [ ] [(def .public ( it) (-> Frac Frac) - (let [it+ (|> ("lux f64 +" )) - it- (|> ("lux f64 -" ))] - (|> it+ ("lux f64 /" it-) log ("lux f64 /" +2.0))))] + (let [it+ (|> (.f64_+# )) + it- (|> (.f64_-# ))] + (|> it+ (.f64_/# it-) log (.f64_/# +2.0))))] [atanh +1.0 it] [acoth it +1.0] @@ -425,10 +423,10 @@ [(def .public ( it) (-> Frac Frac) (let [it^2 (|> it (pow +2.0))] - (|> +1.0 ( it^2) (pow +0.5) ("lux f64 +" +1.0) ("lux f64 /" it) log)))] + (|> +1.0 ( it^2) (pow +0.5) (.f64_+# +1.0) (.f64_/# it) log)))] - [asech "lux f64 -"] - [acsch "lux f64 +"] + [asech .f64_-#] + [acsch .f64_+#] ) (with_template [ ] @@ -436,23 +434,23 @@ (-> Frac Frac Bit) ( 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 [ ] [(def .public @@ -469,11 +467,11 @@ (-> Frac Frac Frac) ( 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 [ ] [(def .public @@ -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 [ ] [ (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.* (.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 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 decoded))] - (in [("lux text clip" 0 split_index mantissa) + (in [(.text_clip# 0 split_index mantissa) decimal])) {.#None} - {try.#Failure ("lux text concat" representation)}) - .let [whole ("lux text clip" 1 (-- ("lux text size" whole)) whole)] + {try.#Failure (.text_composite# representation)}) + .let [whole (.text_clip# 1 (-- (.text_size# whole)) whole)] mantissa (at decoded (when decimal 0 whole - _ ("lux text concat" whole (at encoded decimal)))) + _ (.text_composite# whole (at 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" representation)})))))] + {try.#Failure (.text_composite# 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) (-> (I64 s) (I64 s))) ( 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) ( 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 [ ] [(def .public @@ -71,11 +71,11 @@ (-> Int Int Int) ( 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 encoded) ("lux text concat" ..-sign)) - (|> value .nat (at encoded) ("lux text concat" ..+sign)))) + (|> value ++ ..opposite .nat ++ (at encoded) (.text_composite# ..-sign)) + (|> value .nat (at 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 decoded) (at try.functor each (|>> .int))) ..-sign (|> repr - ("lux text clip" 1 (-- input_size)) + (.text_clip# 1 (-- input_size)) (at 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 ) ( 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 [ ] [(def .public ( 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" ) --)] + (let [mask (|> 1 (.i64_left# ) --)] (function (_ value) (loop (again [input value output ""]) - (let [output' ("lux text concat" - ( ("lux i64 and" mask input)) + (let [output' (.text_composite# + ( (.i64_and# mask input)) output)] - (when (is Nat ("lux i64 right-shift" input)) + (when (is Nat (.i64_right# 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 ( ("lux text char" idx repr)) + (when ( (.text_char# idx repr)) {.#Some digit_value} (again (++ idx) (|> output - ("lux i64 left-shift" ) - ("lux i64 or" digit_value))) + (.i64_left# ) + (.i64_or# digit_value))) _ - {try.#Failure ("lux text concat" repr)}) + {try.#Failure (.text_composite# repr)}) {try.#Success output})) - {try.#Failure ("lux text concat" repr)})))))] + {try.#Failure (.text_composite# 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 [ {try.#Failure ("lux text concat" "Invalid decimal syntax for Nat: " repr)}] + (let [input_size (.text_size# repr)] + (with_expansions [ {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} 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 [ ] [(def .public ( left right) @@ -81,18 +81,18 @@ (-> Rev Rev Rev) ( 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 [ 1] (def .public (reciprocal numerator) (-> Nat Rev) - (.rev (when (is Nat ("lux i64 and" numerator)) + (.rev (when (is Nat (.i64_and# 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" param)) + (let [reciprocal (when (is Nat (.i64_and# 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 [ ] - [(with_expansions [ (these {try.#Failure ("lux text concat" repr)})] + [(with_expansions [ (these {try.#Failure (.text_composite# repr)})] (def .public (Codec Text Rev) (implementation @@ -233,22 +232,22 @@ (when (//nat.% //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 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 [ ] [(def .public @@ -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 [ ] [(def ( [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 "" ..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 [ ] @@ -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 [ ] @@ -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 "" - true (anonymous_init_method env inputsTG) - (list) - {.#Some (all _.composite - (_.aload 0) - inputs! - (_.invokespecial super_class "" (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 "" (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 @@ ))) ... 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 []))))])) -... 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 -... 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) [( 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 [ ] [(def (template (_ reference subject) [( reference subject)]))] - [!n/= "lux i64 ="] - [!i/< "lux i64 <"] + [!n/= .i64_=#] + [!i/< .int_<#] ) (with_template [ ] @@ -112,8 +112,8 @@ (template (_ param subject) [( 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 (_ ) @@ -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 @@ (static ..digit_separator)] (def !if_digit? (template (_ @char @then @else) - [("lux syntax char case!" @char - [[] - @then] + [(.when_char# @char + [[] + @then] - ... else - @else)])) + ... else + @else)])) (def !if_digit?+ (template (_ @char @then @else_options @else) - [(`` ("lux syntax char case!" @char - [[ ] - @then + [(`` (.when_char# @char + [[ ] + @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 - [[] - @else] + [(.when_char# @char + [[] + @else] - ... else - @then)]))) + ... else + @then)]))) (`` (def !if_symbol_char?|head (template (_ @char @then @else) - [("lux syntax char case!" @char - [[ ] - @else] + [(.when_char# @char + [[ ] + @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 ) - (`` ("lux syntax char case!" char/1 - [[] - (<| (!with_char+ source_code//size source_code (!n/+ 2 end) char/2 ) - (!if_digit?+ char/2 - (again (!n/+ 3 end) char/0) - [] - ))] - ... else - ))) + (`` (.when_char# char/1 + [[] + (<| (!with_char+ source_code//size source_code (!n/+ 2 end) char/2 ) + (!if_digit?+ char/2 + (again (!n/+ 3 end) char/0) + [] + ))] + ... else + ))) )] )))) @@ -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 ) (!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)) - - - - ... 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 source_code//size offset/0 where (!++ offset/1) source_code) - (!short_symbol_parser source_code//size current_module [where offset/1 source_code] where .#Symbol) - (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. - - ... 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. - ] - ... It's a symbol. - ))] - ... It's a symbol. - )))) - - [(,, (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 [ ] - [[] - (..bit_syntax [where offset/0 source_code])] - - ["0" #0] - ["1" #1]))] - - ... else - (!full_symbol_parser offset/0 [] 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 [] 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)) + + + + ... 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 source_code//size offset/0 where (!++ offset/1) source_code) + (!short_symbol_parser source_code//size current_module [where offset/1 source_code] where .#Symbol) + (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. + + ... 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. + ] + ... It's a symbol. + ))] + ... It's a symbol. + )))) + + [(,, (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 [ ] + [[] + (..bit_syntax [where offset/0 source_code])] + + ["0" #0] + ["1" #1]))] + + ... else + (!full_symbol_parser offset/0 [] 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 [] 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 ( 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)))] (<| (.locally type_check) .form - (<>.after (.this (` "lux type check"))) + (<>.after (.this (` .is#))) (<>.and .any .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 [] [(exception.def .public ( 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})))]))) -- cgit v1.2.3