From 5fdf2b62f1f97026f76c0336a225f8b510762b46 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 16 Sep 2021 20:16:22 -0400 Subject: Adapted Lua, Python and Ruby compilers to the new variant format. --- stdlib/source/library/lux.lux | 88 ++++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 39 deletions(-) (limited to 'stdlib/source/library/lux.lux') diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index a474ac1a4..3cf71545b 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -823,18 +823,52 @@ (failure "Wrong syntax for $'")} tokens)) +... (def:'' .private (list#each f xs) +... {#UnivQ {#End} +... {#UnivQ {#End} +... {#Function {#Function {#Parameter 3} {#Parameter 1}} +... {#Function ($' List {#Parameter 3}) +... ($' List {#Parameter 1})}}}} +... ({{#End} +... {#End} + +... {#Item x xs'} +... {#Item (f x) (list#each f xs')}} +... xs)) + +(def:'' .private (list#mix f init xs) + ... (All (_ a b) (-> (-> b a a) a (List b) a)) + {#UnivQ {#End} {#UnivQ {#End} {#Function {#Function {#Parameter 1} + {#Function {#Parameter 3} + {#Parameter 3}}} + {#Function {#Parameter 3} + {#Function ($' List {#Parameter 1}) + {#Parameter 3}}}}}} + ({{#End} + init + + {#Item x xs'} + (list#mix f (f x init) xs')} + xs)) + +(def:'' .private (list#reversed list) + {#UnivQ {#End} + {#Function ($' List {#Parameter 1}) ($' List {#Parameter 1})}} + (list#mix ("lux type check" {#UnivQ {#End} + {#Function {#Parameter 1} {#Function ($' List {#Parameter 1}) ($' List {#Parameter 1})}}} + (function'' [head tail] {#Item head tail})) + {#End} + list)) + (def:'' .private (list#each f xs) {#UnivQ {#End} {#UnivQ {#End} {#Function {#Function {#Parameter 3} {#Parameter 1}} {#Function ($' List {#Parameter 3}) ($' List {#Parameter 1})}}}} - ({{#End} - {#End} - - {#Item x xs'} - {#Item (f x) (list#each f xs')}} - xs)) + (list#mix (function'' [head tail] {#Item (f head) tail}) + {#End} + (list#reversed xs))) (def:'' .private Replacement_Environment Type @@ -897,21 +931,6 @@ ("lux type as" Int param) ("lux type as" Int subject)))) -(def:'' .private (list#mix f init xs) - ... (All (_ a b) (-> (-> b a a) a (List b) a)) - {#UnivQ {#End} {#UnivQ {#End} {#Function {#Function {#Parameter 1} - {#Function {#Parameter 3} - {#Parameter 3}}} - {#Function {#Parameter 3} - {#Function ($' List {#Parameter 1}) - {#Parameter 3}}}}}} - ({{#End} - init - - {#Item x xs'} - (list#mix f (f x init) xs')} - xs)) - (def:'' .private (list#size list) {#UnivQ {#End} {#Function ($' List {#Parameter 1}) Nat}} @@ -1132,15 +1151,6 @@ {#Left "Wrong syntax for Ex"}} tokens)) -(def:'' .private (list#reversed list) - (All (_ a) - {#Function ($' List a) ($' List a)}) - (list#mix ("lux type check" (All (_ a) - {#Function a {#Function ($' List a) ($' List a)}}) - (function'' [head tail] {#Item head tail})) - {#End} - list)) - (macro:' .public (-> tokens) ({{#Item output inputs} (in_meta {#Item (list#mix ("lux type check" {#Function Code {#Function Code Code}} @@ -4878,8 +4888,8 @@ (in (` [(~ g!meta) { (~ (untemplated_list =elems))}])))))] [.#Form untemplated_form] - [.#Tuple untemplated_tuple] [.#Variant untemplated_variant] + [.#Tuple untemplated_tuple] ) (def: (untemplated_pattern pattern) @@ -4890,12 +4900,12 @@ (^template [ ] [[_ { value}] (in (` [(~ g!meta) { (~ ( value))}]))]) - ([.#Bit bit$] - [.#Nat nat$] - [.#Int int$] - [.#Rev rev$] - [.#Frac frac$] - [.#Text text$] + ([.#Bit bit$] + [.#Nat nat$] + [.#Int int$] + [.#Rev rev$] + [.#Frac frac$] + [.#Text text$] [.#Symbol name$]) [_ {#Form {#Item [[_ {#Symbol ["" "~"]}] {#Item [unquoted {#End}]}]}}] @@ -4945,7 +4955,7 @@ (list localT (` (..as_is (~ valueT)))))) (list#mix list#composite (list))))] (~ bodyT))))) - + {#None} (..failure ":let requires an even number of parts")) @@ -4981,7 +4991,7 @@ {#Some methods} (in (list (` (..Tuple (~+ (list#each product#right methods)))) (tuple$ (list#each (|>> product#left text$) methods)))) - + {#None} (failure "Wrong syntax for Interface")))) -- cgit v1.2.3