diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/library/lux.lux | 627 |
1 files changed, 92 insertions, 535 deletions
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index 823132f6c..4b1204bc7 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -1,21 +1,17 @@ ("lux def" dummy_location ["" 0 0] - [["" 0 0] (9 #1 (0 #0))] #0) ("lux def" double_quote ("lux i64 char" +34) - [dummy_location (9 #1 (0 #0))] #0) ("lux def" \n ("lux i64 char" +10) - [dummy_location (9 #1 (0 #0))] #0) ("lux def" prelude_module "library/lux" - [dummy_location (9 #1 (0 #0))] #1) ... (type: .public Any @@ -24,8 +20,6 @@ ("lux type check type" (9 #1 ["library/lux" "Any"] (8 #0 (0 #0) (4 #0 1)))) - [dummy_location - (9 #1 (0 #0))] #1) ... (type: .public Nothing @@ -34,8 +28,6 @@ ("lux type check type" (9 #1 ["library/lux" "Nothing"] (7 #0 (0 #0) (4 #0 1)))) - [dummy_location - (9 #1 (0 #0))] #1) ... (type: .public (List a) @@ -49,8 +41,6 @@ ... "lux.Item" (2 #0 (4 #0 1) (9 #0 (4 #0 1) (4 #0 0)))))) - [dummy_location - (9 #1 (0 #0))] ("End" "Item") #1) @@ -58,8 +48,6 @@ ("lux type check type" (9 #1 ["library/lux" "Bit"] (0 #0 "#Bit" #End))) - [dummy_location - (9 #1 #End)] #1) ("lux def" I64 @@ -67,56 +55,42 @@ (9 #1 ["library/lux" "I64"] (7 #0 (0 #0) (0 #0 "#I64" (#Item (4 #0 1) #End))))) - [dummy_location - (9 #1 #End)] #1) ("lux def" Nat ("lux type check type" (9 #1 ["library/lux" "Nat"] (0 #0 "#I64" (#Item (0 #0 "#Nat" #End) #End)))) - [dummy_location - (9 #1 #End)] #1) ("lux def" Int ("lux type check type" (9 #1 ["library/lux" "Int"] (0 #0 "#I64" (#Item (0 #0 "#Int" #End) #End)))) - [dummy_location - (9 #1 #End)] #1) ("lux def" Rev ("lux type check type" (9 #1 ["library/lux" "Rev"] (0 #0 "#I64" (#Item (0 #0 "#Rev" #End) #End)))) - [dummy_location - (9 #1 #End)] #1) ("lux def" Frac ("lux type check type" (9 #1 ["library/lux" "Frac"] (0 #0 "#Frac" #End))) - [dummy_location - (9 #1 #End)] #1) ("lux def" Text ("lux type check type" (9 #1 ["library/lux" "Text"] (0 #0 "#Text" #End))) - [dummy_location - (9 #1 #End)] #1) ("lux def" Name ("lux type check type" (9 #1 ["library/lux" "Name"] (2 #0 Text Text))) - [dummy_location - (9 #1 #End)] #1) ... (type: .public (Maybe a) @@ -129,8 +103,6 @@ Any ... "lux.Some" (4 #0 1)))) - [dummy_location - (9 #1 #End)] ("None" "Some") #1) @@ -190,8 +162,6 @@ ("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))))) - [dummy_location - (9 #1 #End)] ("Primitive" "Sum" "Product" "Function" "Parameter" "Var" "Ex" "UnivQ" "ExQ" "Apply" "Named") #1) @@ -203,8 +173,6 @@ ("lux def type tagged" Location (#Named ["library/lux" "Location"] (#Product Text (#Product Nat Nat))) - [dummy_location - (9 #1 #End)] ["module" "line" "column"] #1) @@ -218,8 +186,6 @@ (#UnivQ #End (#Product (#Parameter 3) (#Parameter 1))))) - [dummy_location - (9 #1 #End)] ["meta" "datum"] #1) @@ -268,8 +234,6 @@ ("lux type check type" (#Apply (#Apply (#Parameter 1) (#Parameter 0)) (#Parameter 1))))) - [dummy_location - (9 #1 #End)] ("Bit" "Nat" "Int" "Rev" "Frac" "Text" "Identifier" "Tag" "Form" "Tuple" "Record") #1) @@ -281,32 +245,22 @@ ({w (#Apply (#Apply w Code') w)} ("lux type check type" (#Apply Location Ann))))) - [dummy_location - (#Record #End)] #1) ("lux def" private #0 - [dummy_location - (#Record #End)] #1) ("lux def" public #1 - [dummy_location - (#Record #End)] #1) ("lux def" local #0 - [dummy_location - (#Record #End)] #1) ("lux def" global #1 - [dummy_location - (#Record #End)] #1) ("lux def" _ann @@ -316,94 +270,79 @@ Code) ([_ data] [dummy_location data])) - [dummy_location (#Record #End)] #0) ("lux def" bit$ ("lux type check" (#Function Bit Code) ([_ value] (_ann (#Bit value)))) - [dummy_location (#Record #End)] #0) ("lux def" nat$ ("lux type check" (#Function Nat Code) ([_ value] (_ann (#Nat value)))) - [dummy_location (#Record #End)] #0) ("lux def" int$ ("lux type check" (#Function Int Code) ([_ value] (_ann (#Int value)))) - [dummy_location (#Record #End)] #0) ("lux def" rev$ ("lux type check" (#Function Rev Code) ([_ value] (_ann (#Rev value)))) - [dummy_location (#Record #End)] #0) ("lux def" frac$ ("lux type check" (#Function Frac Code) ([_ value] (_ann (#Frac value)))) - [dummy_location (#Record #End)] #0) ("lux def" text$ ("lux type check" (#Function Text Code) ([_ text] (_ann (#Text text)))) - [dummy_location (#Record #End)] #0) ("lux def" identifier$ ("lux type check" (#Function Name Code) ([_ name] (_ann (#Identifier name)))) - [dummy_location (#Record #End)] #0) ("lux def" local_identifier$ ("lux type check" (#Function Text Code) ([_ name] (_ann (#Identifier ["" name])))) - [dummy_location (#Record #End)] #0) ("lux def" tag$ ("lux type check" (#Function Name Code) ([_ name] (_ann (#Tag name)))) - [dummy_location (#Record #End)] #0) ("lux def" local_tag$ ("lux type check" (#Function Text Code) ([_ name] (_ann (#Tag ["" name])))) - [dummy_location (#Record #End)] #0) ("lux def" form$ ("lux type check" (#Function (#Apply Code List) Code) ([_ tokens] (_ann (#Form tokens)))) - [dummy_location (#Record #End)] #0) ("lux def" tuple$ ("lux type check" (#Function (#Apply Code List) Code) ([_ tokens] (_ann (#Tuple tokens)))) - [dummy_location (#Record #End)] #0) ("lux def" record$ ("lux type check" (#Function (#Apply (#Product Code Code) List) Code) ([_ tokens] (_ann (#Record tokens)))) - [dummy_location (#Record #End)] #0) ... (type: .public Definition -... [Bit Type Code Any]) +... [Bit Type Any]) ("lux def" Definition ("lux type check type" (#Named ["library/lux" "Definition"] - (#Product Bit (#Product Type (#Product Code Any))))) - (record$ #End) + (#Product Bit (#Product Type Any)))) .public) ... (type: .public Alias @@ -412,7 +351,6 @@ ("lux type check type" (#Named ["library/lux" "Alias"] Name)) - (record$ #End) .public) ... (type: .public Label @@ -421,7 +359,6 @@ ("lux type check type" (#Named ["library/lux" "Label"] (#Product Bit (#Product Type (#Product (#Apply Text List) Nat))))) - (record$ #End) .public) ... (type: .public Global @@ -440,7 +377,6 @@ (#Sum Label (#Sum Label Alias))))) - (record$ #End) ("Definition" "Type" "Label" "Slot" "Alias") .public) @@ -458,7 +394,6 @@ (#Apply (#Product (#Parameter 3) (#Parameter 1)) List))))) - (record$ #End) ["counter" "mappings"] .public) @@ -471,7 +406,6 @@ Nat ... Captured Nat)) - (record$ #End) ("Local" "Captured") .public) @@ -491,14 +425,12 @@ (#Apply (#Product Type Nat) (#Apply Text Bindings)) ... captured (#Apply (#Product Type Ref) (#Apply Text Bindings)))))) - (record$ #End) ["name" "inner" "locals" "captured"] .public) ("lux def" Code_List ("lux type check type" (#Apply Code List)) - (record$ #End) #0) ... (type: .public (Either l r) @@ -512,7 +444,6 @@ (#Parameter 3) ... "lux.Right" (#Parameter 1))))) - (record$ #End) ("Left" "Right") .public) @@ -522,7 +453,6 @@ ("lux type check type" (#Named ["library/lux" "Source"] (#Product Location (#Product Nat Text)))) - (record$ #End) .public) ... (type: .public Module_State @@ -539,7 +469,6 @@ Any ... #Cached Any))) - (record$ #End) ("Active" "Compiled" "Cached") .public) @@ -567,7 +496,6 @@ ... module_state Module_State ))))) - (record$ #End) ["module_hash" "module_aliases" "definitions" "imports" "module_state"] .public) @@ -585,7 +513,6 @@ ... var_bindings (#Apply (#Product Nat (#Apply Type Maybe)) List)))) - (record$ #End) ["ex_counter" "var_counter" "var_bindings"] .public) @@ -601,7 +528,6 @@ Any ... Interpreter Any))) - (record$ #End) ("Build" "Eval" "Interpreter") .public) @@ -620,7 +546,6 @@ Text ... mode Mode))) - (record$ #End) ["target" "version" "mode"] .public) @@ -686,7 +611,6 @@ ... host Any))))))))))))))} (#Apply (0 #0 ["" #End]) (#Parameter 0)))) - (record$ #End) ["info" "source" "location" "current_module" "modules" "scopes" "type_context" "expected" "seed" "scope_type_vars" "extensions" "eval" "host"] .public) @@ -699,7 +623,6 @@ (#Function Lux (#Apply (#Product Lux (#Parameter 1)) (#Apply Text Either)))))) - (record$ #End) .public) ... (type: .public Macro' @@ -708,7 +631,6 @@ ("lux type check type" (#Named ["library/lux" "Macro'"] (#Function Code_List (#Apply Code_List Meta)))) - (record$ #End) .public) ... (type: .public Macro @@ -717,7 +639,6 @@ ("lux type check type" (#Named ["library/lux" "Macro"] (#Primitive "#Macro" #End))) - (record$ #End) .public) ... Base functions & macros @@ -732,7 +653,6 @@ ([_ val] ([_ state] (#Right state val)))) - (record$ #End) #0) ("lux def" failure @@ -746,7 +666,6 @@ ([_ msg] ([_ state] (#Left msg)))) - (record$ #End) #0) ("lux def" let'' @@ -759,7 +678,6 @@ _ (failure "Wrong syntax for let''")} tokens))) - (record$ #End) #0) ("lux def" function'' @@ -796,13 +714,11 @@ _ (failure "Wrong syntax for function''")} tokens))) - (record$ #End) #0) ("lux def" location_code ("lux type check" Code (tuple$ (#Item (text$ "") (#Item (nat$ 0) (#Item (nat$ 0) #End))))) - (record$ #End) #0) ("lux def" meta_code @@ -812,7 +728,6 @@ (tuple$ (#Item location_code (#Item (form$ (#Item (tag$ tag) (#Item value #End))) #End)))))) - (record$ #End) #0) ("lux def" flag_meta @@ -821,21 +736,18 @@ (tuple$ (#Item [(meta_code ["library/lux" "Tag"] (tuple$ (#Item (text$ "library/lux") (#Item (text$ tag) #End)))) (#Item [(meta_code ["library/lux" "Bit"] (bit$ #1)) #End])])))) - (record$ #End) #0) ("lux def" as_def - ("lux type check" (#Function Code (#Function Code (#Function Code (#Function Code Code)))) - (function'' [name value annotations export_policy] - (form$ (#Item (text$ "lux def") (#Item name (#Item value (#Item annotations (#Item export_policy #End)))))))) - (record$ #End) + ("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)))))) - (record$ #End) #0) ("lux def" as_function @@ -845,7 +757,6 @@ (#Item self (#Item (tuple$ inputs) (#Item output #End))))))) - (record$ #End) #0) ("lux def" as_macro @@ -854,7 +765,6 @@ (form$ (#Item (text$ "lux macro") (#Item expression #End))))) - (record$ #End) #0) ("lux def" def:'' @@ -862,26 +772,20 @@ (function'' [tokens] ({(#Item [export_policy (#Item [[_ (#Form (#Item [name args]))] - (#Item [meta (#Item [type (#Item [body #End])])])])]) - (in_meta (#Item [(as_def name (as_checked type (as_function name args body)) - (form$ (#Item (identifier$ ["library/lux" "record$"]) - (#Item meta - #End))) + (#Item [type (#Item [body #End])])])]) + (in_meta (#Item [(as_def name + (as_checked type (as_function name args body)) export_policy) #End])) - (#Item [export_policy (#Item [name (#Item [meta (#Item [type (#Item [body #End])])])])]) + (#Item [export_policy (#Item [name (#Item [type (#Item [body #End])])])]) (in_meta (#Item [(as_def name (as_checked type body) - (form$ (#Item (identifier$ ["library/lux" "record$"]) - (#Item meta - #End))) export_policy) #End])) _ (failure "Wrong syntax for def''")} tokens))) - (record$ #End) #0) ("lux def" macro:' @@ -889,28 +793,20 @@ (function'' [tokens] ({(#Item export_policy (#Item [_ (#Form (#Item name args))] (#Item body #End))) (in_meta (#Item (as_def name (as_macro (as_function name args body)) - (form$ (#Item (identifier$ ["library/lux" "record$"]) - (#Item (tag$ ["library/lux" "End"]) - #End))) export_policy) #End)) - (#Item export_policy (#Item [_ (#Form (#Item name args))] (#Item meta_data (#Item body #End)))) + (#Item export_policy (#Item [_ (#Form (#Item name args))] (#Item body #End))) (in_meta (#Item (as_def name (as_macro (as_function name args body)) - (form$ (#Item (identifier$ ["library/lux" "record$"]) - (#Item meta_data - #End))) export_policy) #End)) _ (failure "Wrong syntax for macro:'")} tokens))) - (record$ #End) #0) (macro:' .public (comment tokens) - #End (in_meta #End)) (macro:' .private ($' tokens) @@ -929,7 +825,6 @@ tokens)) (def:'' .private (list\each f xs) - #End (#UnivQ #End (#UnivQ #End (#Function (#Function (#Parameter 3) (#Parameter 1)) @@ -943,12 +838,10 @@ xs)) (def:'' .private Replacement_Environment - #End Type ($' List (#Product Text Code))) (def:'' .private (replacement_environment xs ys) - #End (#Function ($' List Text) (#Function ($' List Code) Replacement_Environment)) ({[(#Item x xs') (#Item y ys')] (#Item [x y] (replacement_environment xs' ys')) @@ -958,12 +851,10 @@ [xs ys])) (def:'' .private (text\= reference sample) - #End (#Function Text (#Function Text Bit)) ("lux text =" reference sample)) (def:'' .private (replacement for environment) - #End (#Function Text (#Function Replacement_Environment ($' Maybe Code))) ({#End #None @@ -978,7 +869,6 @@ environment)) (def:'' .private (with_replacements reps syntax) - #End (#Function Replacement_Environment (#Function Code Code)) ({[_ (#Identifier "" name)] ({(#Some replacement) @@ -1007,7 +897,6 @@ syntax)) (def:'' .private (n/* param subject) - #End (#Function Nat (#Function Nat Nat)) ("lux type as" Nat ("lux i64 *" @@ -1015,7 +904,6 @@ ("lux type as" Int subject)))) (def:'' .private (list\mix f init xs) - #End ... (All (_ a b) (-> (-> b a a) a (List b) a)) (#UnivQ #End (#UnivQ #End (#Function (#Function (#Parameter 1) (#Function (#Parameter 3) @@ -1031,41 +919,34 @@ xs)) (def:'' .private (list\size list) - #End (#UnivQ #End (#Function ($' List (#Parameter 1)) Nat)) (list\mix (function'' [_ acc] ("lux i64 +" 1 acc)) 0 list)) (def:'' .private (let$ binding value body) - #End (#Function Code (#Function Code (#Function Code Code))) (form$ (#Item (record$ (#Item [binding body] #End)) (#Item value #End)))) (def:'' .private (UnivQ$ body) - #End (#Function Code Code) (form$ (#Item (tag$ ["library/lux" "UnivQ"]) (#Item (tag$ ["library/lux" "End"]) (#Item body #End))))) (def:'' .private (ExQ$ body) - #End (#Function Code Code) (form$ (#Item (tag$ ["library/lux" "ExQ"]) (#Item (tag$ ["library/lux" "End"]) (#Item body #End))))) (def:'' .private quantification_level - #End Text ("lux text concat" double_quote ("lux text concat" "quantification_level" double_quote))) (def:'' .private quantified - #End (#Function Code Code) (let$ (local_identifier$ ..quantification_level) (nat$ 0))) (def:'' .private (quantified_type_parameter idx) - #End (#Function Nat Code) (form$ (#Item (tag$ ["library/lux" "Parameter"]) (#Item (form$ (#Item (text$ "lux i64 +") @@ -1075,12 +956,10 @@ #End)))) (def:'' .private (next_level depth) - #End (#Function Nat Nat) ("lux i64 +" 2 depth)) (def:'' .private (self_id? id) - #End (#Function Nat Bit) ("lux i64 =" id ("lux type as" Nat ("lux i64 *" +2 @@ -1089,7 +968,6 @@ id)))))) (def:'' .public (__adjusted_quantified_type__ permission depth type) - #End (#Function Nat (#Function Nat (#Function Type Type))) ({0 ({... Jackpot! @@ -1140,7 +1018,6 @@ permission)) (def:'' .private (with_correct_quantification body) - #End (#Function Code Code) (form$ (#Item (identifier$ [prelude_module "__adjusted_quantified_type__"]) (#Item (local_identifier$ ..quantification_level) @@ -1149,7 +1026,6 @@ #End)))))) (def:'' .private (with_quantification depth body) - #End (#Function Nat (#Function Code Code)) ({g!level (let$ g!level @@ -1164,7 +1040,6 @@ (local_identifier$ ..quantification_level))) (def:'' .private (initialized_quantification? lux) - #End (#Function Lux Bit) ({[#info _ #source _ #current_module _ #modules _ #scopes scopes #type_context _ #host _ @@ -1190,7 +1065,6 @@ lux)) (macro:' .public (All tokens lux) - #End ({(#Item [_ (#Form (#Item self_name args))] (#Item body #End)) (#Right [lux @@ -1223,7 +1097,6 @@ tokens)) (macro:' .public (Ex tokens lux) - #End ({(#Item [_ (#Form (#Item self_name args))] (#Item body #End)) (#Right [lux @@ -1256,7 +1129,6 @@ tokens)) (def:'' .private (list\reversed list) - #End (All (_ a) (#Function ($' List a) ($' List a))) (list\mix ("lux type check" (All (_ a) @@ -1266,7 +1138,6 @@ list)) (macro:' .public (-> tokens) - #End ({(#Item output inputs) (in_meta (#Item (list\mix ("lux type check" (#Function Code (#Function Code Code)) (function'' [i o] (form$ (#Item (tag$ ["library/lux" "Function"]) (#Item i (#Item o #End)))))) @@ -1279,7 +1150,6 @@ (list\reversed tokens))) (macro:' .public (list xs) - #End (in_meta (#Item (list\mix (function'' [head tail] (form$ (#Item (tag$ ["library/lux" "Item"]) (#Item (tuple$ (#Item [head (#Item [tail #End])])) @@ -1289,7 +1159,6 @@ #End))) (macro:' .public (list& xs) - #End ({(#Item last init) (in_meta (list (list\mix (function'' [head tail] (form$ (list (tag$ ["library/lux" "Item"]) @@ -1302,7 +1171,6 @@ (list\reversed xs))) (macro:' .public (Union tokens) - #End ({#End (in_meta (list (identifier$ ["library/lux" "Nothing"]))) @@ -1313,7 +1181,6 @@ (list\reversed tokens))) (macro:' .public (Tuple tokens) - #End ({#End (in_meta (list (identifier$ ["library/lux" "Any"]))) @@ -1352,7 +1219,7 @@ (macro:' .private (def:''' tokens) ({(#Item [export_policy (#Item [[_ (#Form (#Item [name args]))] - (#Item [meta (#Item [type (#Item [body #End])])])])]) + (#Item [type (#Item [body #End])])])]) (in_meta (list (form$ (list (text$ "lux def") name (form$ (list (text$ "lux type check") @@ -1361,20 +1228,14 @@ name (tuple$ args) body)))) - (form$ (#Item (identifier$ ["library/lux" "record$"]) - (#Item meta - #End))) export_policy)))) - (#Item [export_policy (#Item [name (#Item [meta (#Item [type (#Item [body #End])])])])]) + (#Item [export_policy (#Item [name (#Item [type (#Item [body #End])])])]) (in_meta (list (form$ (list (text$ "lux def") name (form$ (list (text$ "lux type check") type body)) - (form$ (#Item (identifier$ ["library/lux" "record$"]) - (#Item meta - #End))) export_policy)))) _ @@ -1382,17 +1243,14 @@ tokens)) (def:''' .public Or - #End Macro ..Union) (def:''' .public And - #End Macro ..Tuple) (def:''' .private (pairs xs) - #End (All (_ a) (-> ($' List a) ($' List (Tuple a a)))) ({(#Item x (#Item y xs')) (#Item [x y] (pairs xs')) @@ -1417,7 +1275,6 @@ tokens)) (def:''' .private (any? p xs) - #End (All (_ a) (-> (-> a Bit) ($' List a) Bit)) ({#End @@ -1430,13 +1287,11 @@ xs)) (def:''' .private (with_location content) - #End (-> Code Code) (tuple$ (list (tuple$ (list (text$ "") (nat$ 0) (nat$ 0))) content))) (def:''' .private (untemplated_list tokens) - #End (-> ($' List Code) Code) ({#End (_ann (#Tag ["library/lux" "End"])) @@ -1446,7 +1301,6 @@ tokens)) (def:''' .private (list\composite xs ys) - #End (All (_ a) (-> ($' List a) ($' List a) ($' List a))) ({(#Item x xs') (#Item x (list\composite xs' ys)) @@ -1456,7 +1310,6 @@ xs)) (def:''' .private (right_associativity op a1 a2) - #End (-> Code Code Code Code) ({[_ (#Form parts)] (form$ (list\composite parts (list a1 a2))) @@ -1466,14 +1319,12 @@ op)) (def:''' .private (function\flipped func) - #End (All (_ a b c) (-> (-> a b c) (-> b a c))) (function' [right left] (func left right))) (macro:' .public (_$ tokens) - #End ({(#Item op tokens') ({(#Item first nexts) (in_meta (list (list\mix (function\flipped (right_associativity op)) first nexts))) @@ -1487,7 +1338,6 @@ tokens)) (macro:' .public ($_ tokens) - #End ({(#Item op tokens') ({(#Item last prevs) (in_meta (list (list\mix (right_associativity op) last prevs))) @@ -1515,12 +1365,10 @@ (-> (-> a ($' ! b)) ($' ! a) ($' ! b)))))) - (record$ (list)) ["in" "then"] #0) (def:''' .private maybe_monad - #End ($' Monad Maybe) [#in (function' [x] (#Some x)) @@ -1532,7 +1380,6 @@ ma))]) (def:''' .private meta_monad - #End ($' Monad Meta) [#in (function' [x] @@ -1584,7 +1431,6 @@ tokens)) (def:''' .private (monad\each m f xs) - #End (All (_ m a b) (-> ($' Monad m) (-> a ($' m b)) @@ -1602,7 +1448,6 @@ xs))) (def:''' .private (monad\mix m f y xs) - #End (All (_ m a b) (-> ($' Monad m) (-> a b ($' m b)) @@ -1620,7 +1465,6 @@ xs))) (macro:' .public (if tokens) - (list) ({(#Item test (#Item then (#Item else #End))) (in_meta (list (form$ (list (record$ (list [(bit$ #1) then] [(bit$ #0) else])) @@ -1631,12 +1475,10 @@ tokens)) (def:''' .private PList - #End Type (All (_ a) ($' List (Tuple Text a)))) (def:''' .private (plist\value k plist) - #End (All (_ a) (-> Text ($' PList a) ($' Maybe a))) ({(#Item [[k' v] plist']) @@ -1649,12 +1491,10 @@ plist)) (def:''' .private (text\composite x y) - #End (-> Text Text Text) ("lux text concat" x y)) (def:''' .private (name\encoded full_name) - #End (-> Name Text) (let' [[module name] full_name] ({"" name @@ -1662,7 +1502,6 @@ module))) (def:''' .private (global_identifier full_name state) - #End (-> Name ($' Meta Name)) (let' [[module name] full_name [#info info #source source #current_module _ #modules modules @@ -1674,7 +1513,7 @@ ({(#Alias real_name) (#Right [state real_name]) - (#Definition [exported? def_type def_meta def_value]) + (#Definition [exported? def_type def_value]) (#Right [state full_name]) (#Type [exported? type labels]) @@ -1696,7 +1535,6 @@ (plist\value module modules)))) (def:''' .private (code_list expression) - #End (-> Code Code) (let' [type (form$ (list (tag$ ["library/lux" "Apply"]) (identifier$ ["library/lux" "Code"]) @@ -1704,7 +1542,6 @@ (form$ (list (text$ "lux type check") type expression)))) (def:''' .private (spliced replace? untemplated elems) - #End (-> Bit (-> Code ($' Meta Code)) ($' List Code) ($' Meta Code)) ({#1 ({#End @@ -1744,12 +1581,10 @@ replace?)) (def:''' .private (untemplated_text value) - #End (-> Text Code) (with_location (form$ (list (tag$ ["library/lux" "Text"]) (text$ value))))) (def:''' .private (untemplated replace? subst token) - #End (-> Bit Text Code ($' Meta Code)) ({[_ [_ (#Bit value)]] (in_meta (with_location (form$ (list (tag$ ["library/lux" "Bit"]) (bit$ value))))) @@ -1840,7 +1675,6 @@ [replace? token])) (macro:' .public (primitive tokens) - (list) ({(#Item [_ (#Text class_name)] #End) (in_meta (list (form$ (list (tag$ ["library/lux" "Primitive"]) (text$ class_name) (tag$ ["library/lux" "End"]))))) @@ -1852,7 +1686,6 @@ tokens)) (def:'' .private (current_module_name state) - #End ($' Meta Text) ({[#info info #source source #current_module current_module #modules modules #scopes scopes #type_context types #host host @@ -1867,7 +1700,6 @@ state)) (macro:' .public (` tokens) - (list) ({(#Item template #End) (do meta_monad [current_module current_module_name @@ -1881,7 +1713,6 @@ tokens)) (macro:' .public (`' tokens) - (list) ({(#Item template #End) (do meta_monad [=template (untemplated #1 "" template)] @@ -1892,7 +1723,6 @@ tokens)) (macro:' .public (' tokens) - (list) ({(#Item template #End) (do meta_monad [=template (untemplated #0 "" template)] @@ -1903,7 +1733,6 @@ tokens)) (macro:' .public (|> tokens) - (list) ({(#Item [init apps]) (in_meta (list (list\mix ("lux type check" (-> Code Code Code) (function' [app acc] @@ -1924,7 +1753,6 @@ tokens)) (macro:' .public (<| tokens) - (list) ({(#Item [init apps]) (in_meta (list (list\mix ("lux type check" (-> Code Code Code) (function' [app acc] @@ -1945,14 +1773,11 @@ (list\reversed tokens))) (def:''' .private (function\composite f g) - (list [(tag$ ["library/lux" "doc"]) - (text$ "Function composition.")]) (All (_ a b c) (-> (-> b c) (-> a b) (-> a c))) (function' [x] (f (g x)))) (def:''' .private (identifier_name x) - #End (-> Code ($' Maybe Name)) ({[_ (#Identifier sname)] (#Some sname) @@ -1962,7 +1787,6 @@ x)) (def:''' .private (tag_name x) - #End (-> Code ($' Maybe Name)) ({[_ (#Tag sname)] (#Some sname) @@ -1972,7 +1796,6 @@ x)) (def:''' .private (identifier_short x) - #End (-> Code ($' Maybe Text)) ({[_ (#Identifier "" sname)] (#Some sname) @@ -1982,7 +1805,6 @@ x)) (def:''' .private (tuple_list tuple) - #End (-> Code ($' Maybe ($' List Code))) ({[_ (#Tuple members)] (#Some members) @@ -1992,7 +1814,6 @@ tuple)) (def:''' .private (realized_template env template) - #End (-> Replacement_Environment Code Code) ({[_ (#Identifier "" sname)] ({(#Some subst) @@ -2020,28 +1841,23 @@ template)) (def:''' .private (every? p xs) - #End (All (_ a) (-> (-> a Bit) ($' List a) Bit)) (list\mix (function' [_2 _1] (if _1 (p _2) #0)) #1 xs)) (def:''' .private (high_bits value) - (list) (-> ($' I64 Any) I64) ("lux i64 right-shift" 32 value)) (def:''' .private low_mask - (list) I64 (|> 1 ("lux i64 left-shift" 32) ("lux i64 -" 1))) (def:''' .private (low_bits value) - (list) (-> ($' I64 Any) I64) ("lux i64 and" low_mask value)) (def:''' .private (n/< reference sample) - (list) (-> Nat Nat Bit) (let' [referenceH (high_bits reference) sampleH (high_bits sample)] @@ -2054,13 +1870,11 @@ #0)))) (def:''' .private (list\conjoint xs) - #End (All (_ a) (-> ($' List ($' List a)) ($' List a))) (list\mix list\composite #End (list\reversed xs))) (macro:' .public (template tokens) - (list) ({(#Item [[_ (#Tuple bindings)] (#Item [[_ (#Tuple templates)] data])]) ({[(#Some bindings') (#Some data')] (let' [apply ("lux type check" (-> Replacement_Environment ($' List Code)) @@ -2084,7 +1898,6 @@ tokens)) (def:''' .private (n// param subject) - (list) (-> Nat Nat Nat) (if ("lux i64 <" +0 ("lux type as" Int param)) (if (n/< param subject) @@ -2103,7 +1916,6 @@ ("lux i64 +" 1 quotient))))) (def:''' .private (n/% param subject) - (list) (-> Nat Nat Nat) (let' [flat ("lux i64 *" ("lux type as" Int param) @@ -2111,19 +1923,16 @@ ("lux i64 -" flat subject))) (def:''' .private (n/min left right) - (list) (-> Nat Nat Nat) (if (n/< right left) left right)) (def:''' .private (bit\encoded x) - #End (-> Bit Text) (if x "#1" "#0")) (def:''' .private (digit::format digit) - #End (-> Nat Text) ({0 "0" 1 "1" 2 "2" 3 "3" @@ -2133,7 +1942,6 @@ digit)) (def:''' .private (nat\encoded value) - #End (-> Nat Text) ({0 "0" @@ -2150,14 +1958,12 @@ value)) (def:''' .private (int\abs value) - #End (-> Int Int) (if ("lux i64 <" +0 value) ("lux i64 *" -1 value) value)) (def:''' .private (int\encoded value) - #End (-> Int Text) (if ("lux i64 =" +0 value) "+0" @@ -2175,22 +1981,18 @@ (|> value ("lux i64 %" +10) int\abs ("lux type as" Nat) digit::format))))) (def:''' .private (frac\encoded x) - #End (-> Frac Text) ("lux f64 encode" x)) (def:''' .private (multiple? div n) - #End (-> Nat Nat Bit) (|> n (n/% div) ("lux i64 =" 0))) (def:''' .public (not x) - (list) (-> Bit Bit) (if x #0 #1)) (def:''' .private (macro_type? type) - (list) (-> Type Bit) ({(#Named ["library/lux" "Macro"] (#Primitive "#Macro" #End)) #1 @@ -2200,7 +2002,6 @@ type)) (def:''' .private (macro'' modules current_module module name) - #End (-> ($' List (Tuple Text Module)) Text Text Text ($' Maybe Macro)) @@ -2211,7 +2012,7 @@ ({(#Alias [r_module r_name]) (macro'' modules current_module r_module r_name) - (#Definition [exported? def_type def_meta def_value]) + (#Definition [exported? def_type def_value]) (if (macro_type? def_type) (if exported? (#Some ("lux type as" Macro def_value)) @@ -2231,7 +2032,6 @@ ("lux type check" Global gdef)))) (def:''' .private (normal name) - #End (-> Name ($' Meta Name)) ({["" name] (do meta_monad @@ -2243,7 +2043,6 @@ name)) (def:''' .private (macro' full_name) - #End (-> Name ($' Meta ($' Maybe Macro))) (do meta_monad [current_module current_module_name] @@ -2258,7 +2057,6 @@ state))))) (def:''' .private (macro? name) - #End (-> Name ($' Meta Bit)) (do meta_monad [name (normal name) @@ -2268,7 +2066,6 @@ output)))) (def:''' .private (list\interposed sep xs) - #End (All (_ a) (-> a ($' List a) ($' List a))) ({#End @@ -2282,7 +2079,6 @@ xs)) (def:''' .private (single_expansion token) - #End (-> Code ($' Meta ($' List Code))) ({[_ (#Form (#Item [_ (#Identifier name)] args))] (do meta_monad @@ -2292,7 +2088,7 @@ (("lux type as" Macro' macro) args) #None - (in_meta (list token))} + (in (list token))} ?macro)) _ @@ -2300,7 +2096,6 @@ token)) (def:''' .private (expansion token) - #End (-> Code ($' Meta ($' List Code))) ({[_ (#Form (#Item [_ (#Identifier name)] args))] (do meta_monad @@ -2313,7 +2108,7 @@ (in (list\conjoint recursive_expansion))) #None - (in_meta (list token))} + (in (list token))} ?macro)) _ @@ -2321,7 +2116,6 @@ token)) (def:''' .private (full_expansion syntax) - #End (-> Code ($' Meta ($' List Code))) ({[_ (#Form (#Item [_ (#Identifier name)] args))] (do meta_monad @@ -2370,12 +2164,10 @@ syntax)) (def:''' .private (text\encoded original) - #End (-> Text Text) ($_ text\composite ..double_quote original ..double_quote)) (def:''' .private (code\encoded code) - #End (-> Code Text) ({[_ (#Bit value)] (bit\encoded value) @@ -2429,7 +2221,6 @@ code)) (def:''' .private (normal_type type) - #End (-> Code Code) ({[_ (#Form (#Item [_ (#Tag tag)] parts))] (form$ (#Item (tag$ tag) (list\each normal_type parts))) @@ -2475,7 +2266,6 @@ type)) (macro:' .public (type tokens) - (list) ({(#Item type #End) (do meta_monad [initialized_quantification? (function' [lux] (#Right [lux (initialized_quantification? lux)]))] @@ -2495,7 +2285,6 @@ tokens)) (macro:' .public (: tokens) - (list) ({(#Item type (#Item value #End)) (in_meta (list (` ("lux type check" (..type (~ type)) @@ -2506,7 +2295,6 @@ tokens)) (macro:' .public (:as tokens) - (list) ({(#Item type (#Item value #End)) (in_meta (list (` ("lux type as" (..type (~ type)) @@ -2517,7 +2305,6 @@ tokens)) (def:''' .private (empty? xs) - #End (All (_ a) (-> ($' List a) Bit)) ({#End #1 @@ -2526,7 +2313,6 @@ (template [<name> <type> <value>] [(def:''' .private (<name> xy) - #End (All (_ a b) (-> (Tuple a b) <type>)) (let' [[x y] xy] @@ -2536,7 +2322,6 @@ [product\right b y]) (def:''' .private (identifier prefix state) - #End (-> Text ($' Meta Code)) ({[#info info #source source #current_module _ #modules modules #scopes scopes #type_context types #host host @@ -2552,7 +2337,6 @@ state)) (macro:' .public (exec tokens) - (list) ({(#Item value actions) (let' [dummy (local_identifier$ "")] (in_meta (list (list\mix ("lux type check" (-> Code Code Code) @@ -2597,8 +2381,6 @@ ?type)] (in_meta (list (` ("lux def" (~ name) (~ body'') - [(~ location_code) - (#.Record #.End)] (~ export_policy)))))) #None @@ -2639,7 +2421,6 @@ branches)) (macro:' .public (case tokens) - (list) ({(#Item value branches) (do meta_monad [expansion (expander branches)] @@ -2650,7 +2431,6 @@ tokens)) (macro:' .public (^ tokens) - (list) (case tokens (#Item [_ (#Form (#Item pattern #End))] (#Item body branches)) (do meta_monad @@ -2666,7 +2446,6 @@ (failure "Wrong syntax for ^ macro"))) (macro:' .public (^or tokens) - (list) (case tokens (^ (list& [_ (#Form patterns)] body branches)) (case patterns @@ -2691,7 +2470,6 @@ #0)) (macro:' .public (let tokens) - (list) (case tokens (^ (list [_ (#Tuple bindings)] body)) (if (multiple? 2 (list\size bindings)) @@ -2711,7 +2489,6 @@ (failure "Wrong syntax for let"))) (macro:' .public (function tokens) - (list) (case (: (Maybe [Text Code (List Code) Code]) (case tokens (^ (list [_ (#Form (list& [_ (#Identifier ["" name])] head tail))] body)) @@ -2734,57 +2511,6 @@ #None (failure "Wrong syntax for function"))) -(def:' .private (definition_annotation_value code) - (-> Code Code) - (case code - [_ (#Bit value)] - (meta_code ["library/lux" "Bit"] (bit$ value)) - - [_ (#Nat value)] - (meta_code ["library/lux" "Nat"] (nat$ value)) - - [_ (#Int value)] - (meta_code ["library/lux" "Int"] (int$ value)) - - [_ (#Rev value)] - (meta_code ["library/lux" "Rev"] (rev$ value)) - - [_ (#Frac value)] - (meta_code ["library/lux" "Frac"] (frac$ value)) - - [_ (#Text value)] - (meta_code ["library/lux" "Text"] (text$ value)) - - [_ (#Tag [module name])] - (meta_code ["library/lux" "Tag"] (` [(~ (text$ module)) (~ (text$ name))])) - - (^or [_ (#Form _)] [_ (#Identifier _)]) - code - - [_ (#Tuple xs)] - (|> xs - (list\each definition_annotation_value) - untemplated_list - (meta_code ["library/lux" "Tuple"])) - - [_ (#Record kvs)] - (|> kvs - (list\each (: (-> [Code Code] Code) - (function (_ [k v]) - (` [(~ (definition_annotation_value k)) - (~ (definition_annotation_value v))])))) - untemplated_list - (meta_code ["library/lux" "Record"])) - )) - -(def:' .private (definition_annotations kvs) - (-> (List [Code Code]) Code) - (untemplated_list (list\each (: (-> [Code Code] Code) - (function (_ [k v]) - (` [(~ (definition_annotation_value k)) - (~ (definition_annotation_value v))]))) - kvs))) - (def:' .private (endP tokens) (-> (List Code) (Maybe Any)) (case tokens @@ -2851,12 +2577,31 @@ [enhanced_local_declarationP Code enhanced_parametersP] ) +(def:' .private (export_policyP tokens) + (-> (List Code) [(List Code) Code]) + (case tokens + (^ (list& candidate tokens')) + (case candidate + [_ (#Bit it)] + [tokens' candidate] + + [_ (#Identifier ["" _])] + [tokens (` .private)] + + [_ (#Identifier it)] + [tokens' candidate] + + _ + [tokens (` .private)]) + + _ + [tokens (` .private)])) + (template [<parser> <parameter_type> <local>] [(def:' .private (<parser> tokens) (-> (List Code) (Maybe [(List Code) [Code Text (List <parameter_type>)]])) (do maybe_monad - [% (anyP tokens) - .let' [[tokens export_policy] %] + [.let' [[tokens export_policy] (export_policyP tokens)] % (<local> tokens) .let' [[tokens [name parameters]] %]] (in [tokens [export_policy name parameters]])))] @@ -2865,15 +2610,6 @@ [enhanced_declarationP Code enhanced_local_declarationP] ) -(def:' .private (annotationsP tokens) - (-> (List Code) (Maybe [(List Code) (List [Code Code])])) - (case tokens - (^ (list& [_ (#Record annotations)] tokens')) - (#Some [tokens' annotations]) - - tokens' - #None)) - (def:' .private (bodyP tokens) (-> (List Code) (Maybe [(List Code) [(Maybe Code) Code]])) (case tokens @@ -2888,71 +2624,19 @@ _ #None)) -(macro:' .private (maybe\else' tokens) - (case tokens - (^ (list else then)) - (do meta_monad - [g!_ (..identifier "g!_")] - (in (list (` (..case (~ then) - (#..Some (~ g!_)) - (#..Some (~ g!_)) - - #..None - (~ else)))))) - - _ - (failure "Wrong syntax for maybe\else'"))) - (def:' .private (definitionP tokens) - (-> (List Code) (Maybe [Code Text (List Code) (List [Code Code]) (Maybe Code) Code])) - (|> (do maybe_monad - [% (anyP tokens) - .let' [[tokens export_policy] %] - % (enhanced_local_declarationP tokens) - .let' [[tokens [name parameters]] %] - % (annotationsP tokens) - .let' [[tokens annotations] %] - % (bodyP tokens) - .let' [[tokens [?type body]] %] - _ (endP tokens)] - (in [export_policy name parameters annotations ?type body])) - ... (^ (list _export_policy _declaration _annotations _type _body)) - ... (^ (list _export_policy _declaration _annotations _body)) - (maybe\else' (do maybe_monad - [% (enhanced_local_declarationP tokens) - .let' [[tokens [name parameters]] %] - % (bodyP tokens) - .let' [[tokens [?type body]] %] - _ (endP tokens)] - (in [(` ..private) name parameters #End ?type body]))) - ... (^ (list _declaration _type _body)) - ... (^ (list _declaration _body)) - (maybe\else' (do maybe_monad - [% (enhanced_local_declarationP tokens) - .let' [[tokens [name parameters]] %] - % (annotationsP tokens) - .let' [[tokens annotations] %] - % (bodyP tokens) - .let' [[tokens [?type body]] %] - _ (endP tokens)] - (in [(` ..private) name parameters annotations ?type body]))) - ... (^ (list _declaration _annotations _type _body)) - ... (^ (list _declaration _annotations _body)) - (maybe\else' (do maybe_monad - [% (enhanced_declarationP tokens) - .let' [[tokens [export_policy name parameters]] %] - % (bodyP tokens) - .let' [[tokens [?type body]] %] - _ (endP tokens)] - (in [export_policy name parameters #End ?type body]))) - ... (^ (list _export_policy _declaration _type _body)) - ... (^ (list _export_policy _declaration _body)) - )) + (-> (List Code) (Maybe [Code Text (List Code) (Maybe Code) Code])) + (do maybe_monad + [% (enhanced_declarationP tokens) + .let' [[tokens [export_policy name parameters]] %] + % (bodyP tokens) + .let' [[tokens [?type body]] %] + _ (endP tokens)] + (in [export_policy name parameters ?type body]))) (macro:' .public (def: tokens) - (list) (case (definitionP tokens) - (#Some [export_policy name parameters annotations ?type body]) + (#Some [export_policy name parameters ?type body]) (let [body (case parameters #End body @@ -2966,63 +2650,27 @@ (~ body))) #None - body) - =annotations (definition_annotations annotations)] + body)] (in_meta (list (` ("lux def" (~ (..local_identifier$ name)) (~ body) - [(~ location_code) - (#.Record (~ =annotations))] (~ export_policy)))))) #None (failure "Wrong syntax for def:"))) (def:' .private (macroP tokens) - (-> (List Code) (Maybe [Code Text (List Text) (List [Code Code]) Code])) - (|> (do maybe_monad - [% (anyP tokens) - .let' [[tokens export_policy] %] - % (local_declarationP tokens) - .let' [[tokens [name parameters]] %] - % (annotationsP tokens) - .let' [[tokens annotations] %] - % (anyP tokens) - .let' [[tokens body] %] - _ (endP tokens)] - (in [export_policy name parameters annotations body])) - ... (^ (list _export_policy _declaration _annotations _body)) - (maybe\else' (do maybe_monad - [% (local_declarationP tokens) - .let' [[tokens [name parameters]] %] - % (anyP tokens) - .let' [[tokens body] %] - _ (endP tokens)] - (in [(` ..private) name parameters #End body]))) - ... (^ (list _declaration _body)) - (maybe\else' (do maybe_monad - [% (local_declarationP tokens) - .let' [[tokens [name parameters]] %] - % (annotationsP tokens) - .let' [[tokens annotations] %] - % (anyP tokens) - .let' [[tokens body] %] - _ (endP tokens)] - (in [(` ..private) name parameters annotations body]))) - ... (^ (list _declaration _annotations _body)) - (maybe\else' (do maybe_monad - [% (declarationP tokens) - .let' [[tokens [export_policy name parameters]] %] - % (anyP tokens) - .let' [[tokens body] %] - _ (endP tokens)] - (in [export_policy name parameters #End body]))) - ... (^ (list _export_policy _declaration _body)) - )) + (-> (List Code) (Maybe [Code Text (List Text) Code])) + (do maybe_monad + [% (declarationP tokens) + .let' [[tokens [export_policy name parameters]] %] + % (anyP tokens) + .let' [[tokens body] %] + _ (endP tokens)] + (in [export_policy name parameters body]))) (macro:' .public (macro: tokens) - (list) (case (macroP tokens) - (#Some [export_policy name args annotations body]) + (#Some [export_policy name args body]) (let [name (local_identifier$ name) body (case args #End @@ -3030,12 +2678,9 @@ _ (` ("lux macro" - (function ((~ name) (~+ (list\each local_identifier$ args))) (~ body))))) - =annotations (definition_annotations annotations)] + (function ((~ name) (~+ (list\each local_identifier$ args))) (~ body)))))] (in_meta (list (` ("lux def" (~ name) (~ body) - [(~ location_code) - (#Record (~ =annotations))] (~ export_policy)))))) #None @@ -3384,7 +3029,7 @@ (: (-> Code (Meta (List Code))) (function (_ token) (case token - (^ [_ (#Form (list [_ (#Text "lux def")] [_ (#Identifier "" tag_name)] value meta export_policy))]) + (^ [_ (#Form (list [_ (#Text "lux def")] [_ (#Identifier ["" tag_name])] value export_policy))]) (case (plist\value tag_name tag_mappings) (#Some tag) (in (list tag value)) @@ -3419,41 +3064,18 @@ (#Item tokens))) (def: (implementationP tokens) - (-> (List Code) (Maybe [Code Text (List Code) (List [Code Code]) Code (List Code)])) - (|> (do maybe_monad - [% (enhanced_declarationP tokens) - .let' [[tokens [export_policy name parameters]] %] - % (annotationsP tokens) - .let' [[tokens annotations] %] - % (anyP tokens) - .let' [[tokens type] %] - tokens (remainderP tokens)] - (in [export_policy name parameters annotations type tokens])) - ... (^ (list _export_policy _declaration _annotations _type _body)) - ... (^ (list _declaration _annotations _type _body)) - (maybe\else' (do maybe_monad - [% (enhanced_local_declarationP tokens) - .let' [[tokens [name parameters]] %] - % (anyP tokens) - .let' [[tokens type] %] - tokens (remainderP tokens)] - (in [(` ..private) name parameters #End type tokens]))) - ... (^ (list _declaration _type _body)) - (maybe\else' (do maybe_monad - [% (anyP tokens) - .let' [[tokens export_policy] %] - % (enhanced_local_declarationP tokens) - .let' [[tokens [name parameters]] %] - % (anyP tokens) - .let' [[tokens type] %] - tokens (remainderP tokens)] - (in [export_policy name parameters #End type tokens]))) - ... (^ (list _export_policy _declaration _type _body)) - )) + (-> (List Code) (Maybe [Code Text (List Code) Code (List Code)])) + (do maybe_monad + [% (enhanced_declarationP tokens) + .let' [[tokens [export_policy name parameters]] %] + % (anyP tokens) + .let' [[tokens type] %] + tokens (remainderP tokens)] + (in [export_policy name parameters type tokens]))) (macro: .public (implementation: tokens) (case (implementationP tokens) - (#Some [export_policy name args annotations type definitions]) + (#Some [export_policy name args type definitions]) (let [usage (case args #End (local_identifier$ name) @@ -3461,9 +3083,9 @@ _ (` ((~ (local_identifier$ name)) (~+ args))))] (in_meta (list (` (..def: (~ export_policy) (~ usage) - (~ (record$ annotations)) (~ type) - (implementation (~+ definitions))))))) + (implementation + (~+ definitions))))))) #None (failure "Wrong syntax for implementation:"))) @@ -3542,48 +3164,14 @@ (failure "Wrong syntax for Record"))) (def: (typeP tokens) - (-> (List Code) (Maybe [Code Text (List Text) (List [Code Code]) Code])) - (|> (do maybe_monad - [% (anyP tokens) - .let' [[tokens export_policy] %] - % (local_declarationP tokens) - .let' [[tokens [name parameters]] %] - % (annotationsP tokens) - .let' [[tokens annotations] %] - % (anyP tokens) - .let' [[tokens definition] %] - _ (endP tokens)] - (in [export_policy name parameters annotations definition])) - ... (^ (list _export_policy _declaration _annotations _body)) - (maybe\else' (do maybe_monad - [% (local_declarationP tokens) - .let' [[tokens [name parameters]] %] - % (annotationsP tokens) - .let' [[tokens annotations] %] - % (anyP tokens) - .let' [[tokens definition] %] - _ (endP tokens)] - (in [(` ..private) name parameters annotations definition]))) - ... (^ (list _declaration _annotations _body)) - (maybe\else' (do maybe_monad - [% (local_declarationP tokens) - .let' [[tokens [name parameters]] %] - % (anyP tokens) - .let' [[tokens definition] %] - _ (endP tokens)] - (in [(` ..private) name parameters #End definition]))) - ... (^ (list _declaration _body)) - (maybe\else' (do maybe_monad - [% (anyP tokens) - .let' [[tokens export_policy] %] - % (local_declarationP tokens) - .let' [[tokens [name parameters]] %] - % (anyP tokens) - .let' [[tokens definition] %] - _ (endP tokens)] - (in [export_policy name parameters #End definition]))) - ... (^ (list _export_policy _declaration _body)) - )) + (-> (List Code) (Maybe [Code Text (List Text) Code])) + (do maybe_monad + [% (declarationP tokens) + .let' [[tokens [export_policy name parameters]] %] + % (anyP tokens) + .let' [[tokens definition] %] + _ (endP tokens)] + (in [export_policy name parameters definition]))) (def: (textP tokens) (-> (List Code) (Maybe [(List Code) Text])) @@ -3628,7 +3216,7 @@ (macro: .public (type: tokens) (case (typeP tokens) - (#Some [export_policy name args meta type_codes]) + (#Some [export_policy name args type_codes]) (do meta_monad [type+labels?? (..type_declaration type_codes) module_name current_module_name @@ -3641,10 +3229,7 @@ _ (#Some (` (.All ((~ type_name) (~+ (list\each local_identifier$ args))) - (~ type)))))) - total_meta (let [meta (definition_annotations meta)] - (` [(~ location_code) - (#.Record (~ meta))]))]] + (~ type))))))]] (case type' (#Some type'') (let [typeC (` (#.Named [(~ (text$ module_name)) @@ -3656,14 +3241,12 @@ (#Left tags) (` ("lux def type tagged" (~ type_name) (~ typeC) - (~ total_meta) ((~+ (list\each text$ tags))) (~ export_policy))) (#Right slots) (` ("lux def type tagged" (~ type_name) (~ typeC) - (~ total_meta) [(~+ (list\each text$ slots))] (~ export_policy)))) @@ -3671,7 +3254,6 @@ (` ("lux def" (~ type_name) ("lux type check type" (~ typeC)) - (~ total_meta) (~ export_policy))))))) #None @@ -3983,7 +3565,7 @@ (#Alias _) (list) - (#Definition [exported? def_type def_meta def_value]) + (#Definition [exported? def_type def_value]) (if exported? (list name) (list)) @@ -4090,7 +3672,7 @@ (#Alias real_name) (definition_type real_name state) - (#Definition [exported? def_type def_meta def_value]) + (#Definition [exported? def_type def_value]) (#Some def_type) (#Type [exported? type labels]) @@ -4123,7 +3705,7 @@ (#Alias real_name) (definition_value real_name state) - (#Definition [exported? def_type def_meta def_value]) + (#Definition [exported? def_type def_value]) (#Right [state [def_type def_value]]) (#Type [exported? type labels]) @@ -4346,7 +3928,6 @@ _ (in_meta (list (` ("lux def" (~ (local_identifier$ (..module_alias (list short) alias))) (~ source+) - [(~ location_code) (#.Record #.End)] #0))))))) (macro: .public (open: tokens) @@ -4373,9 +3954,7 @@ _ (do meta_monad [g!struct (..identifier "struct")] - (in_meta (list (` ("lux def" (~ g!struct) (~ struct) - [(~ location_code) (#.Record #.End)] - #0)) + (in_meta (list (` ("lux def" (~ g!struct) (~ struct) #0)) (` (..open: (~ (text$ alias)) (~ g!struct))))))) _ @@ -5195,39 +4774,18 @@ #None)) (def: (templateP tokens) - (-> (List Code) (Maybe [Code Text (List Text) (List [Code Code]) (List Code)])) - (|> (do maybe_monad - [% (declarationP tokens) - .let' [[tokens [export_policy name parameters]] %] - % (annotationsP tokens) - .let' [[tokens annotations] %] - % (tupleP tokens) - .let' [[tokens templates] %] - _ (endP tokens)] - (in [export_policy name parameters annotations templates])) - ... (^ (list _export_policy _declaration _annotations _body)) - ... (^ (list _declaration _annotations _body)) - (maybe\else' (do maybe_monad - [% (declarationP tokens) - .let' [[tokens [export_policy name parameters]] %] - % (tupleP tokens) - .let' [[tokens templates] %] - _ (endP tokens)] - (in [export_policy name parameters #End templates]))) - ... (^ (list _export_policy _declaration _body)) - (maybe\else' (do maybe_monad - [% (local_declarationP tokens) - .let' [[tokens [name parameters]] %] - % (tupleP tokens) - .let' [[tokens templates] %] - _ (endP tokens)] - (in [(` ..private) name parameters #End templates]))) - ... (^ (list _declaration _body)) - )) + (-> (List Code) (Maybe [Code Text (List Text) (List Code)])) + (do maybe_monad + [% (declarationP tokens) + .let' [[tokens [export_policy name parameters]] %] + % (tupleP tokens) + .let' [[tokens templates] %] + _ (endP tokens)] + (in [export_policy name parameters templates]))) (macro: .public (template: tokens) (case (templateP tokens) - (#Some [export_policy name args anns input_templates]) + (#Some [export_policy name args input_templates]) (do meta_monad [g!tokens (..identifier "tokens") g!compiler (..identifier "compiler") @@ -5238,7 +4796,6 @@ this_module current_module_name] (in (list (` (macro: (~ export_policy) ((~ (local_identifier$ name)) (~ g!tokens) (~ g!compiler)) - (~ (record$ anns)) (case (~ g!tokens) (^ (list (~+ (list\each local_identifier$ args)))) (#.Right [(~ g!compiler) |