diff options
Diffstat (limited to '')
15 files changed, 1194 insertions, 1131 deletions
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index e1092f696..94735a065 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -1,175 +1,175 @@ -("lux def" dummy_location - ["" 0 0] - #0) +(.def# dummy_location + ["" 0 0] + #0) -("lux def" double_quote - ("lux i64 char" +34) - #0) +(.def# double_quote + ("lux i64 char" +34) + #0) -("lux def" \n - ("lux i64 char" +10) - #0) +(.def# \n + ("lux i64 char" +10) + #0) -("lux def" prelude - "library/lux" - #1) +(.def# prelude + "library/lux" + #1) ... (type .public Any ... (Ex (_ a) a)) -("lux def" Any - ("lux type check type" - {9 #1 - [..prelude "Any"] - {8 #0 - {0 #0} - {4 #0 1}}}) - #1) +(.def# Any + ("lux type check type" + {9 #1 + [..prelude "Any"] + {8 #0 + {0 #0} + {4 #0 1}}}) + #1) ... (type .public Nothing ... (All (_ a) a)) -("lux def" Nothing - ("lux type check type" - {9 #1 - [..prelude "Nothing"] - {7 #0 - {0 #0} - {4 #0 1}}}) - #1) - -("lux def" Bit - ("lux type check type" - {9 #1 - [..prelude "Bit"] - {0 #0 "#Bit" {0 #0}}}) - #1) - -("lux def" I64 - ("lux type check type" - {9 #1 - [..prelude "I64"] - {7 #0 - {0 #0} - {0 #0 "#I64" {0 #1 {4 #0 1} {0 #0}}}}}) - #1) - -("lux def" Nat - ("lux type check type" - {9 #1 - [..prelude "Nat"] - {0 #0 "#I64" {0 #1 {0 #0 "#Nat" {0 #0}} {0 #0}}}}) - #1) - -("lux def" Int - ("lux type check type" - {9 #1 - [..prelude "Int"] - {0 #0 "#I64" {0 #1 {0 #0 "#Int" {0 #0}} {0 #0}}}}) - #1) - -("lux def" Rev - ("lux type check type" - {9 #1 - [..prelude "Rev"] - {0 #0 "#I64" {0 #1 {0 #0 "#Rev" {0 #0}} {0 #0}}}}) - #1) - -("lux def" Frac - ("lux type check type" - {9 #1 - [..prelude "Frac"] - {0 #0 "#Frac" {0 #0}}}) - #1) - -("lux def" Text - ("lux type check type" - {9 #1 - [..prelude "Text"] - {0 #0 "#Text" {0 #0}}}) - #1) - -("lux def" Symbol - ("lux type check type" - {9 #1 - [..prelude "Symbol"] - {2 #0 Text Text}}) - #1) +(.def# Nothing + ("lux type check type" + {9 #1 + [..prelude "Nothing"] + {7 #0 + {0 #0} + {4 #0 1}}}) + #1) + +(.def# Bit + ("lux type check type" + {9 #1 + [..prelude "Bit"] + {0 #0 "#Bit" {0 #0}}}) + #1) + +(.def# I64 + ("lux type check type" + {9 #1 + [..prelude "I64"] + {7 #0 + {0 #0} + {0 #0 "#I64" {0 #1 {4 #0 1} {0 #0}}}}}) + #1) + +(.def# Nat + ("lux type check type" + {9 #1 + [..prelude "Nat"] + {0 #0 "#I64" {0 #1 {0 #0 "#Nat" {0 #0}} {0 #0}}}}) + #1) + +(.def# Int + ("lux type check type" + {9 #1 + [..prelude "Int"] + {0 #0 "#I64" {0 #1 {0 #0 "#Int" {0 #0}} {0 #0}}}}) + #1) + +(.def# Rev + ("lux type check type" + {9 #1 + [..prelude "Rev"] + {0 #0 "#I64" {0 #1 {0 #0 "#Rev" {0 #0}} {0 #0}}}}) + #1) + +(.def# Frac + ("lux type check type" + {9 #1 + [..prelude "Frac"] + {0 #0 "#Frac" {0 #0}}}) + #1) + +(.def# Text + ("lux type check type" + {9 #1 + [..prelude "Text"] + {0 #0 "#Text" {0 #0}}}) + #1) + +(.def# Symbol + ("lux type check type" + {9 #1 + [..prelude "Symbol"] + {2 #0 Text Text}}) + #1) ... (type .public (List a) ... (Variant ... {#End} ... {#Item a (List a)})) -("lux def" List - ("lux type check type" - {9 #1 - [..prelude "List"] - {7 #0 - {0 #0} - {1 #0 - ... End - Any - ... Item - {2 #0 - {4 #0 1} - {9 #0 - {4 #0 1} - {4 #0 0}}}}}}) - #1) +(.def# List + ("lux type check type" + {9 #1 + [..prelude "List"] + {7 #0 + {0 #0} + {1 #0 + ... End + Any + ... Item + {2 #0 + {4 #0 1} + {9 #0 + {4 #0 1} + {4 #0 0}}}}}}) + #1) ... (type .public Tag ... (Primitive "#Tag")) -("lux def" Tag - ("lux type check type" - {9 #1 [..prelude "Tag"] - {0 #0 "#Tag" {0 #0}}}) - #1) +(.def# Tag + ("lux type check type" + {9 #1 [..prelude "Tag"] + {0 #0 "#Tag" {0 #0}}}) + #1) ... (type .public Slot ... (Primitive "#Slot")) -("lux def" Slot - ("lux type check type" - {9 #1 [..prelude "Slot"] - {0 #0 "#Slot" {0 #0}}}) - #1) - -("lux def" Label' - ("lux type check type" - {1 #0 [Any {2 #0 [Nat {2 #0 [Bit {9 #0 Symbol List}]}]}]}) - #0) - -("lux def" list_tags - ("lux type check" - {9 #0 Symbol List} - {0 #1 [[..prelude "#End"] - {0 #1 [[..prelude "#Item"] - {0 #0}]}]}) - #0) -("lux def" #End ("lux type as" Tag [("lux type check" Label' {0 #1 [0 #0 ..list_tags]}) List]) #1) -("lux def" #Item ("lux type as" Tag [("lux type check" Label' {0 #1 [0 #1 ..list_tags]}) List]) #1) +(.def# Slot + ("lux type check type" + {9 #1 [..prelude "Slot"] + {0 #0 "#Slot" {0 #0}}}) + #1) + +(.def# Label' + ("lux type check 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}]}]}) + #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) ... (type .public (Maybe a) ... {#None} ... {#Some a}) -("lux def" Maybe - ("lux type check type" - {9 #1 - [..prelude "Maybe"] - {7 #0 - {#End} - {1 #0 - ... None - Any - ... Some - {4 #0 1}}}}) - #1) -("lux def" maybe_tags - ("lux type check" - {9 #0 Symbol List} - {0 #1 [[..prelude "#None"] - {0 #1 [[..prelude "#Some"] - {0 #0}]}]}) - #0) -("lux def" #None ("lux type as" Tag [("lux type check" Label' {0 #1 [0 #0 ..maybe_tags]}) Maybe]) #1) -("lux def" #Some ("lux type as" Tag [("lux type check" Label' {0 #1 [0 #1 ..maybe_tags]}) Maybe]) #1) +(.def# Maybe + ("lux type check type" + {9 #1 + [..prelude "Maybe"] + {7 #0 + {#End} + {1 #0 + ... None + Any + ... Some + {4 #0 1}}}}) + #1) +(.def# maybe_tags + ("lux type check" + {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) ... (type .public Type ... (Rec Type @@ -185,149 +185,149 @@ ... {#ExQ (List Type) Type} ... {#Apply Type Type} ... {#Named Symbol Type}))) -("lux def" Type - ("lux type check type" - {9 #1 [..prelude "Type"] - ({Type - ({Type_List - ({Type_Pair - {9 #0 - {0 #0 ["" {#End}]} - {7 #0 - {#End} - {1 #0 - ... Primitive - {2 #0 Text Type_List} - {1 #0 - ... Sum - Type_Pair +(.def# Type + ("lux type check type" + {9 #1 [..prelude "Type"] + ({Type + ({Type_List + ({Type_Pair + {9 #0 + {0 #0 ["" {#End}]} + {7 #0 + {#End} {1 #0 - ... Product - Type_Pair + ... Primitive + {2 #0 Text Type_List} {1 #0 - ... Function + ... Sum Type_Pair {1 #0 - ... Parameter - Nat + ... Product + Type_Pair {1 #0 - ... Var - Nat + ... Function + Type_Pair {1 #0 - ... Ex + ... Parameter Nat {1 #0 - ... UnivQ - {2 #0 Type_List Type} + ... Var + Nat {1 #0 - ... ExQ - {2 #0 Type_List Type} + ... Ex + Nat {1 #0 - ... Apply - 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}}))}) - #1) - -("lux 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}]}]}]}]}]}]}]}]}]}]}]}) - #0) -("lux def" #Primitive ("lux type as" Tag [("lux type check" Label' {#Some [0 #0 ..type_tags]}) Type]) #1) -("lux def" #Sum ("lux type as" Tag [("lux type check" Label' {#Some [1 #0 ..type_tags]}) Type]) #1) -("lux def" #Product ("lux type as" Tag [("lux type check" Label' {#Some [2 #0 ..type_tags]}) Type]) #1) -("lux def" #Function ("lux type as" Tag [("lux type check" Label' {#Some [3 #0 ..type_tags]}) Type]) #1) -("lux def" #Parameter ("lux type as" Tag [("lux type check" Label' {#Some [4 #0 ..type_tags]}) Type]) #1) -("lux def" #Var ("lux type as" Tag [("lux type check" Label' {#Some [5 #0 ..type_tags]}) Type]) #1) -("lux def" #Ex ("lux type as" Tag [("lux type check" Label' {#Some [6 #0 ..type_tags]}) Type]) #1) -("lux def" #UnivQ ("lux type as" Tag [("lux type check" Label' {#Some [7 #0 ..type_tags]}) Type]) #1) -("lux def" #ExQ ("lux type as" Tag [("lux type check" Label' {#Some [8 #0 ..type_tags]}) Type]) #1) -("lux def" #Apply ("lux type as" Tag [("lux type check" Label' {#Some [9 #0 ..type_tags]}) Type]) #1) -("lux def" #Named ("lux type as" Tag [("lux type check" Label' {#Some [9 #1 ..type_tags]}) Type]) #1) + ... UnivQ + {2 #0 Type_List Type} + {1 #0 + ... ExQ + {2 #0 Type_List Type} + {1 #0 + ... Apply + 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}}))}) + #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}]}]}]}]}]}]}]}]}]}]}]}) + #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) ... (type .public Label ... [(Maybe [Nat Bit (List Symbol)]) Type]) -("lux def" Label - ("lux type check" - Type - {#Named [..prelude "Label"] - {#Product {#Apply {#Product Nat {#Product Bit {#Apply Symbol List}}} Maybe} - Type}}) - #1) - -("lux def" tag - ("lux type check" - {#Function Label Tag} - ([_ it] ("lux type as" Tag it))) - #0) - -("lux def" slot - ("lux type check" - {#Function Label Slot} - ([_ it] ("lux type as" Slot it))) - #0) +(.def# Label + ("lux type check" + 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))) + #0) + +(.def# slot + ("lux type check" + {#Function Label Slot} + ([_ it] ("lux type as" Slot it))) + #0) ... (type .public Location ... (Record ... [#module Text ... #line Nat ... #column Nat])) -("lux def" Location - ("lux type check" - Type - {#Named [..prelude "Location"] - {#Product Text {#Product Nat Nat}}}) - #1) -("lux def" location_slots - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#module"] - {#Item [..prelude "#line"] - {#Item [..prelude "#column"] - {#End}}}}) - #0) -("lux def" #module (slot [{#Some [0 #0 ..location_slots]} Location]) #1) -("lux def" #line (slot [{#Some [1 #0 ..location_slots]} Location]) #1) -("lux def" #column (slot [{#Some [1 #1 ..location_slots]} Location]) #1) +(.def# Location + ("lux type check" + 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}}}}) + #0) +(.def# #module (slot [{#Some [0 #0 ..location_slots]} Location]) #1) +(.def# #line (slot [{#Some [1 #0 ..location_slots]} Location]) #1) +(.def# #column (slot [{#Some [1 #1 ..location_slots]} Location]) #1) ... (type .public (Ann m v) ... (Record ... [#meta m ... #datum v])) -("lux def" Ann - ("lux type check" - Type - {#Named [..prelude "Ann"] - {#UnivQ {#End} - {#UnivQ {#End} - {#Product - {#Parameter 3} - {#Parameter 1}}}}}) - #1) -("lux def" ann_slots - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#meta"] - {#Item [..prelude "#datum"] - {#End}}}) - #0) -("lux def" #meta (slot [{#Some [0 #0 ..ann_slots]} Ann]) #1) -("lux def" #datum (slot [{#Some [0 #1 ..ann_slots]} Ann]) #1) +(.def# Ann + ("lux type check" + 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}}}) + #0) +(.def# #meta (slot [{#Some [0 #0 ..ann_slots]} Ann]) #1) +(.def# #datum (slot [{#Some [0 #1 ..ann_slots]} Ann]) #1) ... (type .public (Code' w) ... (Variant @@ -341,285 +341,285 @@ ... {#Form (List (w (Code' w)))} ... {#Variant (List (w (Code' w)))} ... {#Tuple (List (w (Code' w)))})) -("lux 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 - {#Sum - ... Text - Text +(.def# Code' + ("lux type check" + Type + {#Named [..prelude "Code'"] + ({Code + ({Code_List + {#UnivQ {#End} {#Sum - ... Symbol - Symbol + ... Bit + Bit {#Sum - ... Form - Code_List + ... Nat + Nat {#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}}))}) - #1) -("lux 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}}}}}}}}}}}) - #0) -("lux def" #Bit (tag [{#Some [0 #0 ..code'_tags]} Code']) #1) -("lux def" #Nat (tag [{#Some [1 #0 ..code'_tags]} Code']) #1) -("lux def" #Int (tag [{#Some [2 #0 ..code'_tags]} Code']) #1) -("lux def" #Rev (tag [{#Some [3 #0 ..code'_tags]} Code']) #1) -("lux def" #Frac (tag [{#Some [4 #0 ..code'_tags]} Code']) #1) -("lux def" #Text (tag [{#Some [5 #0 ..code'_tags]} Code']) #1) -("lux def" #Symbol (tag [{#Some [6 #0 ..code'_tags]} Code']) #1) -("lux def" #Form (tag [{#Some [7 #0 ..code'_tags]} Code']) #1) -("lux def" #Variant (tag [{#Some [8 #0 ..code'_tags]} Code']) #1) -("lux def" #Tuple (tag [{#Some [8 #1 ..code'_tags]} Code']) #1) + ... Int + Int + {#Sum + ... Rev + Rev + {#Sum + ... Frac + Frac + {#Sum + ... Text + Text + {#Sum + ... Symbol + Symbol + {#Sum + ... Form + Code_List + {#Sum + ... Variant + Code_List + ... Tuple + Code_List + }}}}}}}}} + }} + ("lux type check" + Type + {#Apply Code List}))} + ("lux type check" + Type + {#Apply {#Apply {#Parameter 1} + {#Parameter 0}} + {#Parameter 1}}))}) + #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}}}}}}}}}}}) + #0) +(.def# #Bit (tag [{#Some [0 #0 ..code'_tags]} Code']) #1) +(.def# #Nat (tag [{#Some [1 #0 ..code'_tags]} Code']) #1) +(.def# #Int (tag [{#Some [2 #0 ..code'_tags]} Code']) #1) +(.def# #Rev (tag [{#Some [3 #0 ..code'_tags]} Code']) #1) +(.def# #Frac (tag [{#Some [4 #0 ..code'_tags]} Code']) #1) +(.def# #Text (tag [{#Some [5 #0 ..code'_tags]} Code']) #1) +(.def# #Symbol (tag [{#Some [6 #0 ..code'_tags]} Code']) #1) +(.def# #Form (tag [{#Some [7 #0 ..code'_tags]} Code']) #1) +(.def# #Variant (tag [{#Some [8 #0 ..code'_tags]} Code']) #1) +(.def# #Tuple (tag [{#Some [8 #1 ..code'_tags]} Code']) #1) ... (type .public Code ... (Ann Location (Code' (Ann Location)))) -("lux def" Code - ("lux type check" - Type - {#Named [..prelude "Code"] - ({w - {#Apply {#Apply w Code'} w}} - ("lux type check" Type {#Apply Location Ann}))}) - #1) - -("lux def" private - #0 - #1) - -("lux def" public - #1 - #1) - -("lux def" local - #0 - #1) - -("lux def" global - #1 - #1) - -("lux def" _ann - ("lux type check" - {#Function {#Apply {#Apply Location Ann} Code'} - Code} - ([_ data] - [dummy_location data])) - #0) - -("lux def" bit$ - ("lux type check" - {#Function Bit Code} - ([_ value] (_ann {#Bit value}))) - #0) - -("lux def" nat$ - ("lux type check" - {#Function Nat Code} - ([_ value] (_ann {#Nat value}))) - #0) - -("lux def" int$ - ("lux type check" - {#Function Int Code} - ([_ value] (_ann {#Int value}))) - #0) - -("lux def" rev$ - ("lux type check" - {#Function Rev Code} - ([_ value] (_ann {#Rev value}))) - #0) - -("lux def" frac$ - ("lux type check" - {#Function Frac Code} - ([_ value] (_ann {#Frac value}))) - #0) - -("lux def" text$ - ("lux type check" - {#Function Text Code} - ([_ text] (_ann {#Text text}))) - #0) - -("lux def" symbol$ - ("lux type check" - {#Function Symbol Code} - ([_ name] (_ann {#Symbol name}))) - #0) - -("lux def" local$ - ("lux type check" - {#Function Text Code} - ([_ name] (_ann {#Symbol ["" name]}))) - #0) - -("lux def" form$ - ("lux type check" - {#Function {#Apply Code List} Code} - ([_ tokens] (_ann {#Form tokens}))) - #0) - -("lux def" variant$ - ("lux type check" - {#Function {#Apply Code List} Code} - ([_ tokens] (_ann {#Variant tokens}))) - #0) - -("lux def" tuple$ - ("lux type check" - {#Function {#Apply Code List} Code} - ([_ tokens] (_ann {#Tuple tokens}))) - #0) +(.def# Code + ("lux type check" + Type + {#Named [..prelude "Code"] + ({w + {#Apply {#Apply w Code'} w}} + ("lux type check" Type {#Apply Location Ann}))}) + #1) + +(.def# private + #0 + #1) + +(.def# public + #1 + #1) + +(.def# local + #0 + #1) + +(.def# global + #1 + #1) + +(.def# _ann + ("lux type check" + {#Function {#Apply {#Apply Location Ann} Code'} + Code} + ([_ data] + [dummy_location data])) + #0) + +(.def# bit$ + ("lux type check" + {#Function Bit Code} + ([_ value] (_ann {#Bit value}))) + #0) + +(.def# nat$ + ("lux type check" + {#Function Nat Code} + ([_ value] (_ann {#Nat value}))) + #0) + +(.def# int$ + ("lux type check" + {#Function Int Code} + ([_ value] (_ann {#Int value}))) + #0) + +(.def# rev$ + ("lux type check" + {#Function Rev Code} + ([_ value] (_ann {#Rev value}))) + #0) + +(.def# frac$ + ("lux type check" + {#Function Frac Code} + ([_ value] (_ann {#Frac value}))) + #0) + +(.def# text$ + ("lux type check" + {#Function Text Code} + ([_ text] (_ann {#Text text}))) + #0) + +(.def# symbol$ + ("lux type check" + {#Function Symbol Code} + ([_ name] (_ann {#Symbol name}))) + #0) + +(.def# local$ + ("lux type check" + {#Function Text Code} + ([_ name] (_ann {#Symbol ["" name]}))) + #0) + +(.def# form$ + ("lux type check" + {#Function {#Apply Code List} Code} + ([_ tokens] (_ann {#Form tokens}))) + #0) + +(.def# variant$ + ("lux type check" + {#Function {#Apply Code List} Code} + ([_ tokens] (_ann {#Variant tokens}))) + #0) + +(.def# tuple$ + ("lux type check" + {#Function {#Apply Code List} Code} + ([_ tokens] (_ann {#Tuple tokens}))) + #0) ... (type .public Definition ... [Bit Type Any]) -("lux def" Definition - ("lux type check" - Type - {#Named [..prelude "Definition"] - {#Product Bit {#Product Type Any}}}) - .public) +(.def# Definition + ("lux type check" + Type + {#Named [..prelude "Definition"] + {#Product Bit {#Product Type Any}}}) + .public) ... (type .public Default ... Definition) -("lux def" Default - ("lux type check" - Type - {#Named [..prelude "Default"] - Definition}) - .public) +(.def# Default + ("lux type check" + Type + {#Named [..prelude "Default"] + Definition}) + .public) ... (type .public Alias ... Symbol) -("lux def" Alias - ("lux type check" - Type - {#Named [..prelude "Alias"] - Symbol}) - .public) +(.def# Alias + ("lux type check" + Type + {#Named [..prelude "Alias"] + Symbol}) + .public) ... (type .public Global ... (Variant ... {#Definition Definition} ... {#Alias Alias} ... {#Default Default})) -("lux def" Global - ("lux type check" - Type - {#Named [..prelude "Global"] - {#Sum Definition - {#Sum Alias - Default}}}) - .public) - -("lux def" global_tags - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#Definition"] - {#Item [..prelude "#Alias"] - {#Item [..prelude "#Default"] - {#End}}}}) - #0) -("lux def" #Definition (tag [{#Some [0 #0 ..global_tags]} Global]) .public) -("lux def" #Alias (tag [{#Some [1 #0 ..global_tags]} Global]) .public) -("lux def" #Default (tag [{#Some [1 #1 ..global_tags]} Global]) .public) +(.def# Global + ("lux type check" + 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}}}}) + #0) +(.def# #Definition (tag [{#Some [0 #0 ..global_tags]} Global]) .public) +(.def# #Alias (tag [{#Some [1 #0 ..global_tags]} Global]) .public) +(.def# #Default (tag [{#Some [1 #1 ..global_tags]} Global]) .public) ... (type .public (Bindings k v) ... (Record ... [#counter Nat ... #mappings (List [k v])])) -("lux def" Bindings - ("lux type check" - Type - {#Named [..prelude "Bindings"] - {#UnivQ {#End} - {#UnivQ {#End} - {#Product - ... counter - Nat - ... mappings - {#Apply {#Product {#Parameter 3} - {#Parameter 1}} - List}}}}}) - .public) - -("lux def" bindings_slots - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#counter"] - {#Item [..prelude "#mappings"] - {#End}}}) - #0) -("lux def" #counter (slot [{#Some [0 #0 ..bindings_slots]} Bindings]) .public) -("lux def" #mappings (slot [{#Some [0 #1 ..bindings_slots]} Bindings]) .public) +(.def# Bindings + ("lux type check" + 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}}}) + #0) +(.def# #counter (slot [{#Some [0 #0 ..bindings_slots]} Bindings]) .public) +(.def# #mappings (slot [{#Some [0 #1 ..bindings_slots]} Bindings]) .public) ... (type .public Ref ... {#Local Nat} ... {#Captured Nat}) -("lux def" Ref - ("lux type check" - Type - {#Named [..prelude "Ref"] - {#Sum - ... Local - Nat - ... Captured - Nat}}) - .public) - -("lux def" ref_tags - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#Local"] - {#Item [..prelude "#Captured"] - {#End}}}) - #0) -("lux def" #Local (tag [{#Some [0 #0 ..ref_tags]} Ref]) .public) -("lux def" #Captured (tag [{#Some [0 #1 ..ref_tags]} Ref]) .public) +(.def# Ref + ("lux type check" + 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}}}) + #0) +(.def# #Local (tag [{#Some [0 #0 ..ref_tags]} Ref]) .public) +(.def# #Captured (tag [{#Some [0 #1 ..ref_tags]} Ref]) .public) ... TODO: Get rid of both #scope_name & #inner_scopes ... (type .public Scope @@ -628,109 +628,109 @@ ... #inner_scopes Nat ... #locals (Bindings Text [Type Nat]) ... #captured (Bindings Text [Type Ref])])) -("lux 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}}}}}}) - .public) - -("lux def" scope_slots - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#scope_name"] - {#Item [..prelude "#inner_scopes"] - {#Item [..prelude "#locals"] - {#Item [..prelude "#captured"] - {#End}}}}}) - #0) -("lux def" #scope_name (slot [{#Some [0 #0 ..scope_slots]} Scope]) .public) -("lux def" #inner_scopes (slot [{#Some [1 #0 ..scope_slots]} Scope]) .public) -("lux def" #locals (slot [{#Some [2 #0 ..scope_slots]} Scope]) .public) -("lux def" #captured (slot [{#Some [2 #1 ..scope_slots]} Scope]) .public) - -("lux def" Code_List - ("lux type check" - Type - {#Apply Code List}) - #0) +(.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}}}}}}) + .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}}}}}) + #0) +(.def# #scope_name (slot [{#Some [0 #0 ..scope_slots]} Scope]) .public) +(.def# #inner_scopes (slot [{#Some [1 #0 ..scope_slots]} Scope]) .public) +(.def# #locals (slot [{#Some [2 #0 ..scope_slots]} Scope]) .public) +(.def# #captured (slot [{#Some [2 #1 ..scope_slots]} Scope]) .public) + +(.def# Code_List + ("lux type check" + Type + {#Apply Code List}) + #0) ... (type .public (Either l r) ... (Variant ... {#Left l} ... {#Right r})) -("lux def" Either - ("lux type check" - Type - {#Named [..prelude "Either"] - {#UnivQ {#End} - {#UnivQ {#End} - {#Sum - ... Left - {#Parameter 3} - ... Right - {#Parameter 1}}}}}) - .public) - -("lux def" either_tags - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#Left"] - {#Item [..prelude "#Right"] - {#End}}}) - #0) -("lux def" #Left (tag [{#Some [0 #0 ..either_tags]} Either]) .public) -("lux def" #Right (tag [{#Some [0 #1 ..either_tags]} Either]) .public) +(.def# Either + ("lux type check" + 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}}}) + #0) +(.def# #Left (tag [{#Some [0 #0 ..either_tags]} Either]) .public) +(.def# #Right (tag [{#Some [0 #1 ..either_tags]} Either]) .public) ... (type .public Source ... [Location Nat Text]) -("lux def" Source - ("lux type check" - Type - {#Named [..prelude "Source"] - {#Product Location {#Product Nat Text}}}) - .public) +(.def# Source + ("lux type check" + Type + {#Named [..prelude "Source"] + {#Product Location {#Product Nat Text}}}) + .public) ... (type .public Module_State ... (Variant ... #Active ... #Compiled ... #Cached)) -("lux def" Module_State - ("lux type check" - Type - {#Named [..prelude "Module_State"] - {#Sum - ... #Active - Any - {#Sum - ... #Compiled - Any - ... #Cached - Any}}}) - .public) - -("lux def" module_state_tags - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#Active"] - {#Item [..prelude "#Compiled"] - {#Item [..prelude "#Cached"] - {#End}}}}) - #0) -("lux def" #Active (tag [{#Some [0 #0 ..module_state_tags]} Module_State]) .public) -("lux def" #Compiled (tag [{#Some [1 #0 ..module_state_tags]} Module_State]) .public) -("lux def" #Cached (tag [{#Some [1 #1 ..module_state_tags]} Module_State]) .public) +(.def# Module_State + ("lux type check" + 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}}}}) + #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) +(.def# #Cached (tag [{#Some [1 #1 ..module_state_tags]} Module_State]) .public) ... (type .public Module ... (Record @@ -739,103 +739,103 @@ ... #definitions (List [Text Global]) ... #imports (List Text) ... #module_state Module_State])) -("lux 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 - }}}}}) - .public) - -("lux 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}}}}}}) - #0) -("lux def" #module_hash (slot [{#Some [0 #0 ..module_slots]} Module]) .public) -("lux def" #module_aliases (slot [{#Some [1 #0 ..module_slots]} Module]) .public) -("lux def" #definitions (slot [{#Some [2 #0 ..module_slots]} Module]) .public) -("lux def" #imports (slot [{#Some [3 #0 ..module_slots]} Module]) .public) -("lux def" #module_state (slot [{#Some [3 #1 ..module_slots]} Module]) .public) +(.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 + }}}}}) + .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}}}}}}) + #0) +(.def# #module_hash (slot [{#Some [0 #0 ..module_slots]} Module]) .public) +(.def# #module_aliases (slot [{#Some [1 #0 ..module_slots]} Module]) .public) +(.def# #definitions (slot [{#Some [2 #0 ..module_slots]} Module]) .public) +(.def# #imports (slot [{#Some [3 #0 ..module_slots]} Module]) .public) +(.def# #module_state (slot [{#Some [3 #1 ..module_slots]} Module]) .public) ... (type .public Type_Context ... (Record ... [#ex_counter Nat ... #var_counter Nat ... #var_bindings (List [Nat (Maybe Type)])])) -("lux 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}}}}) - .public) - -("lux def" type_context_slots - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#ex_counter"] - {#Item [..prelude "#var_counter"] - {#Item [..prelude "#var_bindings"] - {#End}}}}) - #0) -("lux def" #ex_counter (slot [{#Some [0 #0 ..type_context_slots]} Type_Context]) .public) -("lux def" #var_counter (slot [{#Some [1 #0 ..type_context_slots]} Type_Context]) .public) -("lux def" #var_bindings (slot [{#Some [1 #1 ..type_context_slots]} Type_Context]) .public) +(.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}}}}) + .public) + +(.def# type_context_slots + ("lux type check" + {#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) +(.def# #var_bindings (slot [{#Some [1 #1 ..type_context_slots]} Type_Context]) .public) ... (type .public Mode ... (Variant ... {#Build} ... {#Eval} ... {#Interpreter})) -("lux def" Mode - ("lux type check" - Type - {#Named [..prelude "Mode"] - {#Sum - ... Build - Any - {#Sum - ... Eval - Any - ... Interpreter - Any}}}) - .public) - -("lux def" mode_tags - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#Build"] - {#Item [..prelude "#Eval"] - {#Item [..prelude "#Interpreter"] - {#End}}}}) - #0) -("lux def" #Build (tag [{#Some [0 #0 ..mode_tags]} Mode]) .public) -("lux def" #Eval (tag [{#Some [1 #0 ..mode_tags]} Mode]) .public) -("lux def" #Interpreter (tag [{#Some [1 #1 ..mode_tags]} Mode]) .public) +(.def# Mode + ("lux type check" + 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}}}}) + #0) +(.def# #Build (tag [{#Some [0 #0 ..mode_tags]} Mode]) .public) +(.def# #Eval (tag [{#Some [1 #0 ..mode_tags]} Mode]) .public) +(.def# #Interpreter (tag [{#Some [1 #1 ..mode_tags]} Mode]) .public) ... (type .public Info ... (Record @@ -843,36 +843,36 @@ ... #version Text ... #mode Mode ... #configuration (List [Text Text])])) -("lux def" Info - ("lux type check" - Type - {#Named [..prelude "Info"] - {#Product - ... target - Text - {#Product - ... version - Text - {#Product - ... mode - Mode - ... configuration - {#Apply {#Product Text Text} List}}}}}) - .public) - -("lux def" info_slots - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#target"] - {#Item [..prelude "#version"] - {#Item [..prelude "#mode"] - {#Item [..prelude "#configuration"] - {#End}}}}}) - #0) -("lux def" #target (slot [{#Some [0 #0 ..info_slots]} Info]) .public) -("lux def" #version (slot [{#Some [1 #0 ..info_slots]} Info]) .public) -("lux def" #mode (slot [{#Some [2 #0 ..info_slots]} Info]) .public) -("lux def" #configuration (slot [{#Some [2 #1 ..info_slots]} Info]) .public) +(.def# Info + ("lux type check" + 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}}}}}) + #0) +(.def# #target (slot [{#Some [0 #0 ..info_slots]} Info]) .public) +(.def# #version (slot [{#Some [1 #0 ..info_slots]} Info]) .public) +(.def# #mode (slot [{#Some [2 #0 ..info_slots]} Info]) .public) +(.def# #configuration (slot [{#Some [2 #1 ..info_slots]} Info]) .public) ... (type .public Lux ... (Rec Lux @@ -890,297 +890,297 @@ ... #extensions Any ... #eval (-> Type Code (-> Lux (Either Text [Lux Any]))) ... #host Any]))) -("lux 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} - {#Product - ... scopes - {#Apply Scope List} +(.def# Lux + ("lux type check" + Type + {#Named [..prelude "Lux"] + ({Lux + {#Apply {0 #0 ["" {#End}]} + {#UnivQ {#End} {#Product - ... type_context - Type_Context + ... info + Info {#Product - ... expected - {#Apply Type Maybe} + ... source + Source {#Product - ... seed - Nat + ... location + Location {#Product - ... scope_type_vars - {#Apply Nat List} + ... current_module + {#Apply Text Maybe} {#Product - ... extensions - Any + ... modules + {#Apply {#Product Text Module} List} {#Product - ... eval - {#Function Type - {#Function Code - {#Function Lux - {#Sum Text {#Product Lux Any}}}}} - ... host - Any}}}}}}}}}}}}}}} - {#Apply {0 #0 ["" {#End}]} {#Parameter 0}})}) - .public) - -("lux 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}}}}}}}}}}}}}}) - #0) -("lux def" #info (slot [{#Some [0 #0 ..lux_slots]} Lux]) .public) -("lux def" #source (slot [{#Some [1 #0 ..lux_slots]} Lux]) .public) -("lux def" #location (slot [{#Some [2 #0 ..lux_slots]} Lux]) .public) -("lux def" #current_module (slot [{#Some [3 #0 ..lux_slots]} Lux]) .public) -("lux def" #modules (slot [{#Some [4 #0 ..lux_slots]} Lux]) .public) -("lux def" #scopes (slot [{#Some [5 #0 ..lux_slots]} Lux]) .public) -("lux def" #type_context (slot [{#Some [6 #0 ..lux_slots]} Lux]) .public) -("lux def" #expected (slot [{#Some [7 #0 ..lux_slots]} Lux]) .public) -("lux def" #seed (slot [{#Some [8 #0 ..lux_slots]} Lux]) .public) -("lux def" #scope_type_vars (slot [{#Some [9 #0 ..lux_slots]} Lux]) .public) -("lux def" #extensions (slot [{#Some [10 #0 ..lux_slots]} Lux]) .public) -("lux def" #eval (slot [{#Some [11 #0 ..lux_slots]} Lux]) .public) -("lux def" #host (slot [{#Some [11 #1 ..lux_slots]} Lux]) .public) + ... scopes + {#Apply Scope List} + {#Product + ... 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}}}}}}}}}}}}}}) + #0) +(.def# #info (slot [{#Some [0 #0 ..lux_slots]} Lux]) .public) +(.def# #source (slot [{#Some [1 #0 ..lux_slots]} Lux]) .public) +(.def# #location (slot [{#Some [2 #0 ..lux_slots]} Lux]) .public) +(.def# #current_module (slot [{#Some [3 #0 ..lux_slots]} Lux]) .public) +(.def# #modules (slot [{#Some [4 #0 ..lux_slots]} Lux]) .public) +(.def# #scopes (slot [{#Some [5 #0 ..lux_slots]} Lux]) .public) +(.def# #type_context (slot [{#Some [6 #0 ..lux_slots]} Lux]) .public) +(.def# #expected (slot [{#Some [7 #0 ..lux_slots]} Lux]) .public) +(.def# #seed (slot [{#Some [8 #0 ..lux_slots]} Lux]) .public) +(.def# #scope_type_vars (slot [{#Some [9 #0 ..lux_slots]} Lux]) .public) +(.def# #extensions (slot [{#Some [10 #0 ..lux_slots]} Lux]) .public) +(.def# #eval (slot [{#Some [11 #0 ..lux_slots]} Lux]) .public) +(.def# #host (slot [{#Some [11 #1 ..lux_slots]} Lux]) .public) ... (type .public (Meta a) ... (-> Lux (Either Text [Lux a]))) -("lux def" Meta - ("lux type check" - Type - {#Named [..prelude "Meta"] - {#UnivQ {#End} - {#Function Lux - {#Apply {#Product Lux {#Parameter 1}} - {#Apply Text Either}}}}}) - .public) +(.def# Meta + ("lux type check" + 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)))) -("lux def" Macro' - ("lux type check" - Type - {#Named [..prelude "Macro'"] - {#Function Code_List {#Apply Code_List Meta}}}) - .public) +(.def# Macro' + ("lux type check" + Type + {#Named [..prelude "Macro'"] + {#Function Code_List {#Apply Code_List Meta}}}) + .public) ... (type .public Macro ... (Primitive "#Macro")) -("lux def" Macro - ("lux type check" - Type - {#Named [..prelude "Macro"] - {#Primitive "#Macro" {#End}}}) - .public) +(.def# Macro + ("lux type check" + Type + {#Named [..prelude "Macro"] + {#Primitive "#Macro" {#End}}}) + .public) ... Base functions & macros -("lux def" meta#in - ("lux type check" - {#UnivQ {#End} {#Function {#Parameter 1} {#Apply {#Parameter 1} Meta}}} - ([_ val] - ([_ state] - {#Right [state val]}))) - #0) - -("lux def" failure - ("lux type check" - {#UnivQ {#End} {#Function Text {#Apply {#Parameter 1} Meta}}} - ([_ msg] - ([_ state] - {#Left msg}))) - #0) - -("lux def" text#composite - ("lux type check" - {#Function Text {#Function Text Text}} - ([_ x] - ([_ y] - ("lux text concat" x y)))) - #0) - -("lux def" symbol_separator - ("lux type check" - Text - ".") - #0) - -("lux 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))) - #0) +(.def# meta#in + ("lux type check" + {#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}))) + #0) + +(.def# text#composite + ("lux type check" + {#Function Text {#Function Text Text}} + ([_ x] + ([_ y] + ("lux text concat" x y)))) + #0) + +(.def# symbol_separator + ("lux type check" + 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))) + #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. -("lux def" wrong_syntax_error - ("lux type check" - {#Function Symbol Text} - ([_ it] - (text#composite "Wrong syntax for " (symbol#encoded it)))) - #0) - -("lux 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}}) +(.def# wrong_syntax_error + ("lux type check" + {#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)))) - #0) - -("lux 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 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 - _ - (failure "Wrong syntax for function''")} - tokens)))) - #0) - -("lux def" as_def - ("lux type check" - {#Function Code {#Function Code {#Function Code Code}}} - (function'' [name value export_policy] - (form$ {#Item (text$ "lux def") {#Item name {#Item value {#Item export_policy {#End}}}}}))) - #0) - -("lux def" as_checked - ("lux type check" - {#Function Code {#Function Code Code}} - (function'' [type value] - (form$ {#Item (text$ "lux type check") {#Item type {#Item value {#End}}}}))) - #0) - -("lux 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))) - #0) - -("lux 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}}}}))) - #0) - -("lux 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}]}) + _ + (_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 - _ - (failure "Wrong syntax for def'")} - tokens)))) - #0) - -("lux 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}}) + _ + (_ann {#Form {#Item (_ann {#Symbol [..prelude "function''"]}) + {#Item (_ann {#Tuple args'}) + {#Item body {#End}}}}})} + args') + {#End}}}}) + {#End}}) - _ - (failure (wrong_syntax_error [..prelude "macro"]))} - tokens)))) - #1) + _ + (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}}}}}))) + #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}}}}))) + #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))) + #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}}}}))) + #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)))) + #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)))) + #1) (def' .public comment Macro @@ -1739,27 +1739,27 @@ ... #in) ... (is (All (_ a b) (-> (-> a (m b)) (m a) (m b))) ... #then))) -("lux def" Monad - ("lux type check" - Type - {#Named [..prelude "Monad"] - (All (_ !) - (Tuple (All (_ a) - (-> a ($ ! a))) - (All (_ a b) - (-> (-> a ($ ! b)) - (-> ($ ! a) ($ ! b))))))}) - #0) - -("lux def" monad_slots - ("lux type check" - {#Apply Symbol List} - {#Item [..prelude "#in"] - {#Item [..prelude "#then"] - {#End}}}) - #0) -("lux def" #in (slot [{#Some [0 #0 ..monad_slots]} Monad]) .private) -("lux def" #then (slot [{#Some [0 #1 ..monad_slots]} Monad]) .private) +(.def# Monad + ("lux type check" + 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}}}) + #0) +(.def# #in (slot [{#Some [0 #0 ..monad_slots]} Monad]) .private) +(.def# #then (slot [{#Some [0 #1 ..monad_slots]} Monad]) .private) (def' .private maybe#monad ($ Monad Maybe) @@ -1948,7 +1948,8 @@ (def' .public UnQuote Type - {#Primitive "#Macro/UnQuote" {#End}}) + {#Named [..prelude "UnQuote"] + {#Primitive "#Macro/UnQuote" {#End}}}) (def' .public (unquote it) (-> Macro UnQuote) @@ -1960,7 +1961,8 @@ (def' .public Spliced_UnQuote Type - {#Primitive "#Macro/Spliced_UnQuote" {#End}}) + {#Named [..prelude "Spliced_UnQuote"] + {#Primitive "#Macro/Spliced_UnQuote" {#End}}}) (def' .public (spliced_unquote it) (-> Macro Spliced_UnQuote) @@ -3340,7 +3342,8 @@ (def' .public Pattern Type - {#Primitive "#Macro/Pattern" {#End}}) + {#Named [..prelude "Pattern"] + {#Primitive "#Macro/Pattern" {#End}}}) (def' .public (pattern it) (-> Macro Pattern) @@ -3784,9 +3787,9 @@ {#None} body)] - (meta#in (list (` ("lux def" (, (..local$ name)) - (, body) - (, export_policy)))))) + (meta#in (list (` (.def# (, (..local$ name)) + (, body) + (, export_policy)))))) {#None} (failure (..wrong_syntax_error (symbol ..def)))))) @@ -4097,7 +4100,7 @@ (is (-> Code (Meta (List Code))) (function (_ token) (when token - [_ {#Form (list [_ {#Text "lux def"}] [_ {#Symbol ["" slot_name]}] value export_policy)}] + [_ {#Form (list [_ {#Symbol [..prelude "def#"]}] [_ {#Symbol ["" slot_name]}] value export_policy)}] (when (property#value slot_name tag_mappings) {#Some tag} (in (list tag value)) @@ -4624,7 +4627,7 @@ (def (alias_definition imported_module def) (-> Text Text Code) - (` ("lux def alias" (, (local$ def)) (, (symbol$ [imported_module def]))))) + (` (.alias# (, (local$ def)) (, (symbol$ [imported_module def]))))) (def .public only (macro (_ tokens) @@ -5014,9 +5017,9 @@ (in (list#conjoint decls'))) _ - (in (list (` ("lux def" (, (local$ (..module_alias (list short imported_module) alias))) - (, source+) - #0))))))) + (in (list (` (.def# (, (local$ (..module_alias (list short imported_module) alias))) + (, source+) + #0))))))) (def (implementation_declarations imported_module alias implementation) (-> Text Text Symbol (Meta (List Code))) @@ -5087,7 +5090,7 @@ _ (do meta#monad [g!implementation (..generated_symbol "implementation")] - (in [{#Item (` ("lux def" (, g!implementation) (, it) #0)) pre_defs} + (in [{#Item (` (.def# (, g!implementation) (, it) #0)) pre_defs} {#Item g!implementation implementations}])))) [(list) (list)] implementations)) @@ -5740,7 +5743,7 @@ (function (_ [module_name m_alias =refer]) (refer_code module_name (..maybe#else "" m_alias) =refer))) imports) - =module (` ("lux def module" (, =imports)))] + =module (` (.module# (, =imports)))] g!_ (..generated_symbol "")] (in {#Item =module (for "Python" @@ -5749,7 +5752,7 @@ ... {library/lux/tool/compiler/language/lux/generation.no_buffer_for_saving_code} ... Artifact ID: 0 ... Which only ever happens for the Python compiler. - (list#partial (` ("lux def" (, g!_) [] #0)) + (list#partial (` (.def# (, g!_) [] #0)) =refers) =refers)}))))) @@ -5910,7 +5913,8 @@ [(def .public <type> Type (let [[_ short] (symbol <type>)] - {.#Primitive (text#composite "#" short) (list)}))] + {#Named [..prelude short] + {.#Primitive (text#composite "#Extension/" short) (list)}}))] [Analysis] [Synthesis] diff --git a/stdlib/source/library/lux/ffi/export.js.lux b/stdlib/source/library/lux/ffi/export.js.lux index 2f9e4e99d..6b0732c7a 100644 --- a/stdlib/source/library/lux/ffi/export.js.lux +++ b/stdlib/source/library/lux/ffi/export.js.lux @@ -40,14 +40,14 @@ (-> Code (Meta [Text Code])) (|>> (list) (<code>.result (<| <code>.form - (<>.after (<code>.this_text "lux def")) + (<>.after (<code>.this_symbol (symbol .def#))) (<>.before <code>.any) (all <>.and <code>.local <code>.any))) meta.lifted)) -(with_expansions [<extension> (static.random (|>> %.nat (%.format "lua export ") code.text) +(with_expansions [<extension> (static.random (|>> %.nat (%.format "js export ") code.text) random.nat)] (declaration (<extension> self phase archive [name <code>.text term <code>.any]) diff --git a/stdlib/source/library/lux/ffi/export.lua.lux b/stdlib/source/library/lux/ffi/export.lua.lux index c00493f77..ce6949ea7 100644 --- a/stdlib/source/library/lux/ffi/export.lua.lux +++ b/stdlib/source/library/lux/ffi/export.lua.lux @@ -40,7 +40,7 @@ (-> Code (Meta [Text Code])) (|>> (list) (<code>.result (<| <code>.form - (<>.after (<code>.this_text "lux def")) + (<>.after (<code>.this_symbol (symbol .def#))) (<>.before <code>.any) (all <>.and <code>.local diff --git a/stdlib/source/library/lux/ffi/export.py.lux b/stdlib/source/library/lux/ffi/export.py.lux index 7633ed73a..d67b9539c 100644 --- a/stdlib/source/library/lux/ffi/export.py.lux +++ b/stdlib/source/library/lux/ffi/export.py.lux @@ -40,7 +40,7 @@ (-> Code (Meta [Text Code])) (|>> (list) (<code>.result (<| <code>.form - (<>.after (<code>.this_text "lux def")) + (<>.after (<code>.this_symbol (symbol .def#))) (<>.before <code>.any) (all <>.and <code>.local diff --git a/stdlib/source/library/lux/ffi/export.rb.lux b/stdlib/source/library/lux/ffi/export.rb.lux index 614cd7b45..9798cdb96 100644 --- a/stdlib/source/library/lux/ffi/export.rb.lux +++ b/stdlib/source/library/lux/ffi/export.rb.lux @@ -78,7 +78,7 @@ (-> Code (Meta [Name Code])) (|>> (list) (<code>.result (<| <code>.form - (<>.after (<code>.this_text "lux def")) + (<>.after (<code>.this_symbol (symbol .def#))) (<>.before <code>.any) (all <>.and (<text>.then ..name <code>.local) diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux index 69211a03c..c126d7c70 100644 --- a/stdlib/source/library/lux/meta.lux +++ b/stdlib/source/library/lux/meta.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except try macro type) + [lux (.except try macro type local) [abstract [functor (.only Functor)] [apply (.only Apply)] @@ -412,6 +412,54 @@ (in it) (failure (all text#composite "Default is not an export: " (symbol#encoded name)))))))))) +(with_template [<name> <slot> <type>] + [(def .public <name> + (Meta <type>) + (function (_ lux) + {try.#Success [lux (the <slot> lux)]}))] + + [compiler_state [] Lux] + + [type_context .#type_context Type_Context] + + [target [.#info .#target] Text] + [version [.#info .#version] Text] + [configuration [.#info .#configuration] (List [Text Text])] + ) + +(def .public (local name) + (-> Symbol (Meta Global)) + (do ..monad + [name (..normal name) + current_module_name ..current_module_name + lux ..compiler_state] + (loop (again [[normal_module normal_short] name]) + (when (is (Maybe Global) + (do maybe.monad + [(open "/[0]") (|> lux + (the .#modules) + (property.value normal_module))] + (property.value normal_short /#definitions))) + {.#Some it} + (when it + {.#Definition [exported? type value]} + (if (or exported? + (text#= current_module_name normal_module)) + (in it) + (failure (all text#composite "Global is not an export: " (symbol#encoded name)))) + + {.#Default [exported? type value]} + (if (or exported? + (text#= current_module_name normal_module)) + (in it) + (failure (all text#composite "Global is not an export: " (symbol#encoded name)))) + + {.#Alias de_aliased} + (again de_aliased)) + + {.#None it} + (failure (all text#composite "Unknown global: " (symbol#encoded name))))))) + (def .public (definition_type name) (-> Symbol (Meta Type)) (do ..monad @@ -662,21 +710,6 @@ {try.#Failure error} (..failure error))) -(with_template [<name> <slot> <type>] - [(def .public <name> - (Meta <type>) - (function (_ lux) - {try.#Success [lux (the <slot> lux)]}))] - - [compiler_state [] Lux] - - [type_context .#type_context Type_Context] - - [target [.#info .#target] Text] - [version [.#info .#version] Text] - [configuration [.#info .#configuration] (List [Text Text])] - ) - (def .public (eval type code) (-> Type Code (Meta Any)) (do [! ..monad] diff --git a/stdlib/source/library/lux/meta/compiler/default/init.lux b/stdlib/source/library/lux/meta/compiler/default/init.lux index b30769ba6..07cfaf968 100644 --- a/stdlib/source/library/lux/meta/compiler/default/init.lux +++ b/stdlib/source/library/lux/meta/compiler/default/init.lux @@ -83,16 +83,14 @@ ///declaration.#generation [///declaration.#state generation_state ///declaration.#phase (generate extender)]]])) -(def .public (with_default_declarations host_analysis program extender) +(def .public (with_default_declarations host_analysis) (All (_ anchor expression declaration) (-> ///analysis.Bundle - (Program expression declaration) - (Extender anchor expression declaration) (-> (///declaration.State+ anchor expression declaration) (///declaration.State+ anchor expression declaration)))) (function (_ [declaration_extensions sub_state]) [(dictionary.composite declaration_extensions - (luxD.bundle host_analysis program extender)) + (luxD.bundle host_analysis)) sub_state])) (type Reader @@ -126,9 +124,21 @@ [(///generation.Buffer declaration) Registry]) -(def (with_generation_defaults module) - (-> Text - (Operation Any)) +(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_generation_defaults + (Operation Any) (do [! ///phase.monad] [state ///phase.state _ (|> state @@ -146,8 +156,8 @@ (when module .prelude (do ///phase.monad - [] - (with_generation_defaults module)) + [_ with_generation_defaults] + with_declaration_defaults) _ (with ///phase.monad diff --git a/stdlib/source/library/lux/meta/compiler/default/platform.lux b/stdlib/source/library/lux/meta/compiler/default/platform.lux index eecc1ed00..aa0f1d2eb 100644 --- a/stdlib/source/library/lux/meta/compiler/default/platform.lux +++ b/stdlib/source/library/lux/meta/compiler/default/platform.lux @@ -276,7 +276,7 @@ (initialize_state extender (as_expected (..complete_extensions host_declaration_bundle (as_expected bundles))) analysis_state) - (try#each (//init.with_default_declarations host_analysis program extender)) + (try#each (//init.with_default_declarations host_analysis)) async#in)))]] (if (archive.archived? archive descriptor.runtime) (do ! diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/reference.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/reference.lux index 6d74996cc..668ee5376 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/reference.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/reference.lux @@ -35,10 +35,10 @@ (exception.report (list ["Definition" (%.symbol definition)]))) -(exception.def .public (labels_are_not_definitions definition) +(exception.def .public (defaults_are_not_definitions global) (Exception Symbol) (exception.report - (list ["Label" (%.symbol definition)]))) + (list ["Default" (%.symbol global)]))) (def (definition quoted_module def_name) (-> Text Symbol (Operation Analysis)) @@ -63,7 +63,10 @@ (text#= quoted_module ::module)) <return> (/.except ..foreign_module_has_not_been_imported [current ::module quoted_module def_name]))) - (/.except ..definition_has_not_been_exported def_name)))))))) + (/.except ..definition_has_not_been_exported [def_name])))) + + {.#Default _} + (/.except ..defaults_are_not_definitions [def_name]))))) (def (variable var_name) (-> Text (Operation (Maybe Analysis))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/declaration.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/declaration.lux index 363c97fe5..88ce8f82b 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/declaration.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/declaration.lux @@ -12,13 +12,13 @@ [collection ["[0]" list (.use "[1]#[0]" mix monoid)]]] ["[0]" meta (.only) - [type + [type (.only sharing) ["[0]" check]]]]] ["[0]" // ["[1][0]" extension] ["[1][0]" analysis] ["/[1]" // - ["/" declaration (.only Operation Phase Extender)] + ["/" declaration (.only Operation Phase Handler Extender)] ["[1][0]" analysis (.only) ["[0]" evaluation] ["[1]/[0]" macro (.only Expander)] @@ -40,11 +40,6 @@ (exception.report (list ["Code" (%.code code)]))) -(exception.def .public (macro_was_not_found name) - (Exception Symbol) - (exception.report - (list ["Name" (%.symbol name)]))) - (type Eval (-> Type Code (Meta Any))) @@ -86,6 +81,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_declaration name) + (-> Symbol (Meta Value)) + (do meta.monad + [[type value] (global_value name)] + (if (check.subsumes? .Declaration type) + (in value) + (meta.failure (exception.error ..not_an_extension [name .Declaration type]))))) + (def (extension_application extender phase archive name parameters) @@ -95,19 +117,27 @@ Symbol (List Code) (Operation anchor expression declaration /.Requirements))) (do //.monad - [[exported? type value] (<| /.lifted_analysis - //extension.lifted - (meta.export name))] - (if (check.subsumes? .Declaration type) - ((extender value) "" phase archive parameters) - (//.except ..not_an_extension [name .Declaration type])))) + [value (<| /.lifted_analysis + //extension.lifted + (global_declaration name))] + (when value + {#Normal definition} + ((extender definition) "" phase archive parameters) + + {#Special default} + (let [default (sharing [anchor expression declaration] + (is (Extender anchor expression declaration) + extender) + (is (Handler anchor expression declaration) + (as_expected default)))] + (default "" phase archive parameters))))) (type Outcome (Variant {#More (List Code)} {#Done /.Requirements})) -(with_expansions [<lux_def_module> (these [|form_location| {.#Form (list.partial [|text_location| {.#Text "lux def module"}] annotations)}])] +(with_expansions [<lux_def_module> (these [|form_location| {.#Form (list.partial [|text_location| {.#Symbol [..prelude "module#"]}] annotations)}])] (def .public (phase wrapper extender expander) (All (_ anchor expression declaration) (-> //.Wrapper (Extender anchor expression declaration) Expander (Phase anchor expression declaration))) @@ -128,37 +158,34 @@ [_ {.#Form (list.partial [_ {.#Text name}] inputs)}] (//extension.apply archive again [name inputs]) - [_ {.#Form (list.partial macro|extension inputs)}] + [_ {.#Form (list.partial [_ {.#Symbol macro|extension}] inputs)}] (do ! [expansion|requirements (do ! - [[def_type def_analysis] (<| /.lifted_analysis - ///analysis/type.inferring - (analysis archive macro|extension))] - (when def_analysis - (///analysis.constant def_name) + [[def_type def_value] (<| /.lifted_analysis + //extension.lifted + (global_value macro|extension))] + (when def_value + {#Normal def_value} (cond (check.subsumes? Macro def_type) (/.lifted_analysis (do ! - [?macro (//extension.lifted (meta.macro def_name)) - macro (when ?macro - {.#Some macro} - (in macro) - - {.#None} - (//.except ..macro_was_not_found def_name)) - expansion (//extension.lifted (///analysis/macro.expansion expander def_name macro inputs))] + [expansion (//extension.lifted (///analysis/macro.expansion expander macro|extension (as Macro def_value) inputs))] (in {#More expansion}))) (check.subsumes? .Declaration def_type) (do ! - [requirements (extension_application extender again archive def_name inputs)] + [requirements (extension_application extender again archive macro|extension inputs)] (in {#Done requirements})) ... else (//.except ..invalid_macro_call [code])) - - _ - (//.except ..invalid_macro_call [code])))] + + {#Special def_value} + (if (check.subsumes? .Declaration def_type) + (do ! + [requirements (extension_application extender again archive macro|extension inputs)] + (in {#Done requirements})) + (//.except ..invalid_macro_call [code]))))] (when expansion|requirements {.#Left expansion} (when expansion 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 caddd4c81..22317eaea 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 @@ -364,25 +364,11 @@ {.#Named name anonymous} {.#Named name (again anonymous)})))) -(def (bundle::def host_analysis program extender) +(def .public (bundle host_analysis) (All (_ anchor expression declaration) (-> /////analysis.Bundle - (Program expression declaration) - (Extender anchor expression declaration) (Bundle anchor expression declaration))) - (<| (///bundle.prefix "def") - (|> ///bundle.empty - (dictionary.has "module" def_module) - (dictionary.has "alias" def_alias) - ))) - -(def .public (bundle host_analysis program extender) - (All (_ anchor expression declaration) - (-> /////analysis.Bundle - (Program expression declaration) - (Extender anchor expression declaration) - (Bundle anchor expression declaration))) - (<| (///bundle.prefix "lux") - (|> ///bundle.empty - (dictionary.has "def" (lux::def host_analysis)) - (dictionary.composite (..bundle::def host_analysis program extender))))) + (|> ///bundle.empty + (dictionary.has "def#" (lux::def host_analysis)) + (dictionary.has "module#" def_module) + (dictionary.has "alias#" def_alias))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm.lux index b31d36e9b..8c55204b3 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm.lux @@ -61,15 +61,15 @@ [definition (meta.try (meta.export name))] (when definition {try.#Success [exported? type definition]} - (in [exported? type {.#Left definition}]) + (in [type {.#Left definition}]) {try.#Failure error} (do ! [[exported? type default] (meta.default name)] - (in [exported? type {.#Right default}])))) - (is (Meta [Bit Type (Either Any Any)])) + (in [type {.#Right default}])))) + (is (Meta [Type (Either Any Any)])) (meta.result lux)) - {try.#Success [exported? type value]} + {try.#Success [type value]} (if (check.subsumes? .Generation type) (when value {.#Left definition} diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis.lux index 539c17856..49f847b4d 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis.lux @@ -75,15 +75,15 @@ [definition (meta.try (meta.export name))] (when definition {try.#Success [exported? type definition]} - (in [exported? type {.#Left definition}]) + (in [type {.#Left definition}]) {try.#Failure error} (do ! [[exported? type default] (meta.default name)] - (in [exported? type {.#Right default}])))) - (is (Meta [Bit Type (Either Any Any)])) + (in [type {.#Right default}])))) + (is (Meta [Type (Either Any Any)])) (meta.result lux)) - {try.#Success [exported? type value]} + {try.#Success [type value]} (if (check.subsumes? .Synthesis type) (when value {.#Left definition} diff --git a/stdlib/source/library/lux/meta/macro/syntax/definition.lux b/stdlib/source/library/lux/meta/macro/syntax/definition.lux index 0db62599f..6c58ff992 100644 --- a/stdlib/source/library/lux/meta/macro/syntax/definition.lux +++ b/stdlib/source/library/lux/meta/macro/syntax/definition.lux @@ -43,7 +43,7 @@ )) (def extension - "lux def") + (symbol .def#)) (def dummy Code @@ -53,7 +53,7 @@ (def .public (format (open "_[0]")) (-> Definition Code) - (` ((, (code.text ..extension)) + (` ((, (code.symbol ..extension)) (, (code.local _#name)) (, (when _#value {.#Left check} @@ -73,7 +73,7 @@ <>.lifted)] (<| (<code>.locally me_raw) <code>.form - (<>.after (<code>.this_text ..extension)) + (<>.after (<code>.this_symbol ..extension)) (all <>.and <code>.local (<>.or //check.parser diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index 67a23e73b..dbd4166fa 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -463,7 +463,7 @@ ... ... TODO: Remove this hack once Jython is no longer being used as the Python interpreter. ... (`` (for @.python (when (' [<input>']) ... (^.` [<module> - ... ("lux def" (, [_ {.#Symbol ["" _]}]) [] #0) + ... (.def# (, [_ {.#Symbol ["" _]}]) [] #0) ... (,, (template.spliced <referrals>))]) ... true @@ -478,52 +478,52 @@ ... (scenario [])))] ... [(.require [<module/0>']) - ... ("lux def module" []) + ... (.module# []) ... []] ... [(.require [<alias> <module/0>' (.except)]) - ... ("lux def module" [[<module/0> <alias>]]) + ... (.module# [[<module/0> <alias>]]) ... [(<referral> <module/0> (.except))]] ... [(.require [<alias> <module/0>' (.only <definition>)]) - ... ("lux def module" [[<module/0> <alias>]]) + ... (.module# [[<module/0> <alias>]]) ... [(<referral> <module/0> (.only <definition>))]] ... [(.require [<alias> <module/0>' (.except <definition>)]) - ... ("lux def module" [[<module/0> <alias>]]) + ... (.module# [[<module/0> <alias>]]) ... [(<referral> <module/0> (.except <definition>))]] ... [(.require [<alias> <module/0>']) - ... ("lux def module" []) + ... (.module# []) ... []] ... [(.require [<module/0>' ... [<alias> <module/1>']]) - ... ("lux def module" [[<m0/1> <alias>]]) + ... (.module# [[<m0/1> <alias>]]) ... [(<referral> <m0/1>)]] ... [(.require ["[0]" <module/0>' ... ["[0]" <module/1>']]) - ... ("lux def module" [[<module/0> <module/0>] + ... (.module# [[<module/0> <module/0>] ... [<m0/1> <module/1>]]) ... [(<referral> <module/0>) ... (<referral> <m0/1>)]] ... [(.require ["[0]" <module/0>' ... ["[1]" <module/1>']]) - ... ("lux def module" [[<m0/1> <module/0>]]) + ... (.module# [[<m0/1> <module/0>]]) ... [(<referral> <m0/1>)]] ... [(.require ["[0]" <module/0>' ... ["[1]" <module/1>' ... ["[2]" <module/2>']]]) - ... ("lux def module" [[<m0/1/2> <module/0>]]) + ... (.module# [[<m0/1/2> <module/0>]]) ... [(<referral> <m0/1/2>)]] ... [(.require [<module/0>' ... ["[0]" <module/1>' ... ["[0]" <//>']]]) - ... ("lux def module" [[<m0/1> <module/1>] + ... (.module# [[<m0/1> <module/1>] ... [<m0/2> <//>]]) ... [(<referral> <m0/1>) ... (<referral> <m0/2>)]] @@ -531,13 +531,13 @@ ... [(.require ["[0]" <module/0>' ... [<module/1>' ... ["[0]" <\\>']]]) - ... ("lux def module" [[<module/0> <module/0>] + ... (.module# [[<module/0> <module/0>] ... [<m2/1> <\\>]]) ... [(<referral> <module/0>) ... (<referral> <m2/1>)]] ... [(.require ["[0]" <module/0>' (.use "[1]#[0]" <definition>)]) - ... ("lux def module" [[<module/0> <module/0>]]) + ... (.module# [[<module/0> <module/0>]]) ... [(<referral> <module/0> (<open/0> <definition>))]] ... )))))) )))))) |