diff options
Diffstat (limited to '')
457 files changed, 8663 insertions, 8663 deletions
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index 483362c7d..28507c829 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -823,7 +823,7 @@ {#End}}}))) #0) -("lux def" def:'' +("lux def" def'' ("lux macro" (function'' [tokens] ({{#Item [export_policy @@ -840,7 +840,7 @@ {#End}]}) _ - (failure "Wrong syntax for def:''")} + (failure "Wrong syntax for def''")} tokens))) #0) @@ -856,580 +856,580 @@ tokens))) #1) -(def:'' .public comment - Macro - (macro (_ tokens) - (meta#in {#End}))) +(def'' .public comment + Macro + (macro (_ tokens) + (meta#in {#End}))) -(def:'' .private $' - Macro - (macro (_ tokens) - ({{#Item x {#End}} - (meta#in tokens) +(def'' .private $' + Macro + (macro (_ tokens) + ({{#Item x {#End}} + (meta#in tokens) - {#Item x {#Item y xs}} - (meta#in {#Item (form$ {#Item (symbol$ [..prelude "$'"]) - {#Item (variant$ {#Item (symbol$ [..prelude "#Apply"]) - {#Item y {#Item x {#End}}}}) - xs}}) - {#End}}) + {#Item x {#Item y xs}} + (meta#in {#Item (form$ {#Item (symbol$ [..prelude "$'"]) + {#Item (variant$ {#Item (symbol$ [..prelude "#Apply"]) + {#Item y {#Item x {#End}}}}) + xs}}) + {#End}}) - _ - (failure "Wrong syntax for $'")} - tokens))) - -(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 + _ + (failure "Wrong syntax for $'")} + tokens))) + +(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})}}}} + (list#mix (function'' [head tail] {#Item (f head) tail}) + {#End} + (list#reversed xs))) + +(def'' .private Replacement_Environment + Type + ($' List {#Product Text Code})) - {#Item x xs'} - (list#mix f (f x init) xs')} - xs)) +(def'' .private (replacement_environment xs ys) + {#Function ($' List Text) {#Function ($' List Code) Replacement_Environment}} + ({[{#Item x xs'} {#Item y ys'}] + {#Item [x y] (replacement_environment xs' ys')} -(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})}}}} - (list#mix (function'' [head tail] {#Item (f head) tail}) - {#End} - (list#reversed xs))) + _ + {#End}} + [xs ys])) -(def:'' .private Replacement_Environment - Type - ($' List {#Product Text Code})) +(def'' .private (text#= reference sample) + {#Function Text {#Function Text Bit}} + ("lux text =" reference sample)) -(def:'' .private (replacement_environment xs ys) - {#Function ($' List Text) {#Function ($' List Code) Replacement_Environment}} - ({[{#Item x xs'} {#Item y ys'}] - {#Item [x y] (replacement_environment xs' ys')} +(def'' .private (replacement for environment) + {#Function Text {#Function Replacement_Environment ($' Maybe Code)}} + ({{#End} + {#None} - _ - {#End}} - [xs ys])) + {#Item [k v] environment'} + ({[#1] {#Some v} + [#0] (replacement for environment')} + (text#= k for))} + environment)) -(def:'' .private (text#= reference sample) - {#Function Text {#Function Text Bit}} - ("lux text =" reference sample)) +(def'' .private (with_replacements reps syntax) + {#Function Replacement_Environment {#Function Code Code}} + ({[_ {#Symbol "" name}] + ({{#Some replacement} + replacement -(def:'' .private (replacement for environment) - {#Function Text {#Function Replacement_Environment ($' Maybe Code)}} - ({{#End} - {#None} + {#None} + syntax} + (..replacement name reps)) - {#Item [k v] environment'} - ({[#1] {#Some v} - [#0] (replacement for environment')} - (text#= k for))} - environment)) + [meta {#Form parts}] + [meta {#Form (list#each (with_replacements reps) parts)}] -(def:'' .private (with_replacements reps syntax) - {#Function Replacement_Environment {#Function Code Code}} - ({[_ {#Symbol "" name}] - ({{#Some replacement} - replacement + [meta {#Variant members}] + [meta {#Variant (list#each (with_replacements reps) members)}] - {#None} - syntax} - (..replacement name reps)) + [meta {#Tuple members}] + [meta {#Tuple (list#each (with_replacements reps) members)}] + + _ + syntax} + syntax)) + +(def'' .private (n/* param subject) + {#Function Nat {#Function Nat Nat}} + ("lux type as" Nat + ("lux i64 *" + ("lux type as" Int param) + ("lux type as" Int subject)))) + +(def'' .private (list#size list) + {#UnivQ {#End} + {#Function ($' List {#Parameter 1}) Nat}} + (list#mix (function'' [_ acc] ("lux i64 +" 1 acc)) 0 list)) + +(def'' .private (let$ binding value body) + {#Function Code {#Function Code {#Function Code Code}}} + (form$ {#Item (variant$ {#Item binding {#Item body {#End}}}) + {#Item value {#End}}})) + +(def'' .private |#End| + Code + (variant$ {#Item (symbol$ [..prelude "#End"]) {#End}})) + +(def'' .private (|#Item| head tail) + {#Function Code {#Function Code Code}} + (variant$ {#Item (symbol$ [..prelude "#Item"]) + {#Item head + {#Item tail + {#End}}}})) + +(def'' .private (UnivQ$ body) + {#Function Code Code} + (variant$ {#Item (symbol$ [..prelude "#UnivQ"]) {#Item ..|#End| {#Item body {#End}}}})) + +(def'' .private (ExQ$ body) + {#Function Code Code} + (variant$ {#Item (symbol$ [..prelude "#ExQ"]) {#Item ..|#End| {#Item body {#End}}}})) + +(def'' .private quantification_level + Text + ("lux text concat" double_quote + ("lux text concat" "quantification_level" + double_quote))) + +(def'' .private quantified + {#Function Code Code} + (let$ (local$ ..quantification_level) (nat$ 0))) + +(def'' .private (quantified_type_parameter idx) + {#Function Nat Code} + (variant$ {#Item (symbol$ [..prelude "#Parameter"]) + {#Item (form$ {#Item (text$ "lux i64 +") + {#Item (local$ ..quantification_level) + {#Item (nat$ idx) + {#End}}}}) + {#End}}})) + +(def'' .private (next_level depth) + {#Function Nat Nat} + ("lux i64 +" 2 depth)) + +(def'' .private (self_id? id) + {#Function Nat Bit} + ("lux i64 =" id ("lux type as" Nat + ("lux i64 *" +2 + ("lux i64 /" +2 + ("lux type as" Int + id)))))) + +(def'' .public (__adjusted_quantified_type__ permission depth type) + {#Function Nat {#Function Nat {#Function Type Type}}} + ({0 + ({... Jackpot! + {#Parameter id} + ({id' + ({[#0] {#Parameter id'} + [#1] {#Parameter ("lux i64 -" 2 id')}} + (self_id? id))} + ("lux i64 -" ("lux i64 -" depth id) 0)) + + ... Recur + {#Primitive name parameters} + {#Primitive name (list#each (__adjusted_quantified_type__ permission depth) + parameters)} + + {#Sum left right} + {#Sum (__adjusted_quantified_type__ permission depth left) + (__adjusted_quantified_type__ permission depth right)} + + {#Product left right} + {#Product (__adjusted_quantified_type__ permission depth left) + (__adjusted_quantified_type__ permission depth right)} + + {#Function input output} + {#Function (__adjusted_quantified_type__ permission depth input) + (__adjusted_quantified_type__ permission depth output)} + + {#UnivQ environment body} + {#UnivQ environment + (__adjusted_quantified_type__ permission (next_level depth) body)} + + {#ExQ environment body} + {#ExQ environment + (__adjusted_quantified_type__ permission (next_level depth) body)} + + {#Apply parameter function} + {#Apply (__adjusted_quantified_type__ permission depth parameter) + (__adjusted_quantified_type__ permission depth function)} - [meta {#Form parts}] - [meta {#Form (list#each (with_replacements reps) parts)}] + ... Leave these alone. + {#Named name anonymous} type + {#Var id} type + {#Ex id} type} + type) - [meta {#Variant members}] - [meta {#Variant (list#each (with_replacements reps) members)}] + _ + type} + permission)) + +(def'' .private (with_correct_quantification body) + {#Function Code Code} + (form$ {#Item (symbol$ [prelude "__adjusted_quantified_type__"]) + {#Item (local$ ..quantification_level) + {#Item (nat$ 0) + {#Item body + {#End}}}}})) + +(def'' .private (with_quantification depth body) + {#Function Nat {#Function Code Code}} + ({g!level + (let$ g!level + (form$ {#Item (text$ "lux i64 +") + {#Item g!level + {#Item (nat$ ("lux type as" Nat + ("lux i64 *" +2 + ("lux type as" Int + depth)))) + {#End}}}}) + body)} + (local$ ..quantification_level))) + +(def'' .private (initialized_quantification? lux) + {#Function Lux Bit} + ({[..#info _ ..#source _ ..#current_module _ ..#modules _ + ..#scopes scopes ..#type_context _ ..#host _ + ..#seed _ ..#expected _ ..#location _ ..#extensions _ + ..#scope_type_vars _ ..#eval _] + (list#mix (function'' [scope verdict] + ({[#1] #1 + _ ({[..#name _ ..#inner _ ..#captured _ + ..#locals [..#counter _ + ..#mappings locals]] + (list#mix (function'' [local verdict] + ({[local _] + ({[#1] #1 + _ ("lux text =" ..quantification_level local)} + verdict)} + local)) + #0 + locals)} + scope)} + verdict)) + #0 + scopes)} + lux)) + +(def'' .public All + Macro + (macro (_ tokens lux) + ({{#Item [_ {#Form {#Item self_name args}}] + {#Item body {#End}}} + {#Right [lux + {#Item ({raw + ({[#1] raw + [#0] (..quantified raw)} + (initialized_quantification? lux))} + ({{#End} + body + + {#Item head tail} + (with_correct_quantification + (let$ self_name (quantified_type_parameter 0) + ({[_ raw] + raw} + (list#mix (function'' [parameter offset,body'] + ({[offset body'] + [("lux i64 +" 2 offset) + (let$ parameter (quantified_type_parameter ("lux i64 +" offset 1)) + (UnivQ$ body'))]} + offset,body')) + [0 (with_quantification (list#size args) + body)] + args))))} + args)) + {#End}}]} + + _ + {#Left "Wrong syntax for All"}} + tokens))) + +(def'' .public Ex + Macro + (macro (_ tokens lux) + ({{#Item [_ {#Form {#Item self_name args}}] + {#Item body {#End}}} + {#Right [lux + {#Item ({raw + ({[#1] raw + [#0] (..quantified raw)} + (initialized_quantification? lux))} + ({{#End} + body + + {#Item head tail} + (with_correct_quantification + (let$ self_name (quantified_type_parameter 0) + ({[_ raw] + raw} + (list#mix (function'' [parameter offset,body'] + ({[offset body'] + [("lux i64 +" 2 offset) + (let$ parameter (quantified_type_parameter ("lux i64 +" offset 1)) + (ExQ$ body'))]} + offset,body')) + [0 (with_quantification (list#size args) + body)] + args))))} + args)) + {#End}}]} + + _ + {#Left "Wrong syntax for Ex"}} + tokens))) + +(def'' .public -> + Macro + (macro (_ tokens) + ({{#Item output inputs} + (meta#in {#Item (list#mix ("lux type check" {#Function Code {#Function Code Code}} + (function'' [i o] (variant$ {#Item (symbol$ [..prelude "#Function"]) {#Item i {#Item o {#End}}}}))) + output + inputs) + {#End}}) + + _ + (failure "Wrong syntax for ->")} + (list#reversed tokens)))) - [meta {#Tuple members}] - [meta {#Tuple (list#each (with_replacements reps) members)}] - - _ - syntax} - syntax)) - -(def:'' .private (n/* param subject) - {#Function Nat {#Function Nat Nat}} - ("lux type as" Nat - ("lux i64 *" - ("lux type as" Int param) - ("lux type as" Int subject)))) - -(def:'' .private (list#size list) - {#UnivQ {#End} - {#Function ($' List {#Parameter 1}) Nat}} - (list#mix (function'' [_ acc] ("lux i64 +" 1 acc)) 0 list)) - -(def:'' .private (let$ binding value body) - {#Function Code {#Function Code {#Function Code Code}}} - (form$ {#Item (variant$ {#Item binding {#Item body {#End}}}) - {#Item value {#End}}})) - -(def:'' .private |#End| - Code - (variant$ {#Item (symbol$ [..prelude "#End"]) {#End}})) - -(def:'' .private (|#Item| head tail) - {#Function Code {#Function Code Code}} - (variant$ {#Item (symbol$ [..prelude "#Item"]) - {#Item head - {#Item tail - {#End}}}})) - -(def:'' .private (UnivQ$ body) - {#Function Code Code} - (variant$ {#Item (symbol$ [..prelude "#UnivQ"]) {#Item ..|#End| {#Item body {#End}}}})) - -(def:'' .private (ExQ$ body) - {#Function Code Code} - (variant$ {#Item (symbol$ [..prelude "#ExQ"]) {#Item ..|#End| {#Item body {#End}}}})) - -(def:'' .private quantification_level - Text - ("lux text concat" double_quote - ("lux text concat" "quantification_level" - double_quote))) - -(def:'' .private quantified - {#Function Code Code} - (let$ (local$ ..quantification_level) (nat$ 0))) - -(def:'' .private (quantified_type_parameter idx) - {#Function Nat Code} - (variant$ {#Item (symbol$ [..prelude "#Parameter"]) - {#Item (form$ {#Item (text$ "lux i64 +") - {#Item (local$ ..quantification_level) - {#Item (nat$ idx) - {#End}}}}) - {#End}}})) - -(def:'' .private (next_level depth) - {#Function Nat Nat} - ("lux i64 +" 2 depth)) - -(def:'' .private (self_id? id) - {#Function Nat Bit} - ("lux i64 =" id ("lux type as" Nat - ("lux i64 *" +2 - ("lux i64 /" +2 - ("lux type as" Int - id)))))) - -(def:'' .public (__adjusted_quantified_type__ permission depth type) - {#Function Nat {#Function Nat {#Function Type Type}}} - ({0 - ({... Jackpot! - {#Parameter id} - ({id' - ({[#0] {#Parameter id'} - [#1] {#Parameter ("lux i64 -" 2 id')}} - (self_id? id))} - ("lux i64 -" ("lux i64 -" depth id) 0)) - - ... Recur - {#Primitive name parameters} - {#Primitive name (list#each (__adjusted_quantified_type__ permission depth) - parameters)} - - {#Sum left right} - {#Sum (__adjusted_quantified_type__ permission depth left) - (__adjusted_quantified_type__ permission depth right)} - - {#Product left right} - {#Product (__adjusted_quantified_type__ permission depth left) - (__adjusted_quantified_type__ permission depth right)} - - {#Function input output} - {#Function (__adjusted_quantified_type__ permission depth input) - (__adjusted_quantified_type__ permission depth output)} - - {#UnivQ environment body} - {#UnivQ environment - (__adjusted_quantified_type__ permission (next_level depth) body)} - - {#ExQ environment body} - {#ExQ environment - (__adjusted_quantified_type__ permission (next_level depth) body)} - - {#Apply parameter function} - {#Apply (__adjusted_quantified_type__ permission depth parameter) - (__adjusted_quantified_type__ permission depth function)} +(def'' .public list + Macro + (macro (_ xs) + (meta#in {#Item (list#mix |#Item| |#End| (list#reversed xs)) + {#End}}))) - ... Leave these alone. - {#Named name anonymous} type - {#Var id} type - {#Ex id} type} - type) +(def'' .private partial_list + Macro + (macro (_ xs) + ({{#Item last init} + (meta#in (list (list#mix |#Item| last init))) - _ - type} - permission)) - -(def:'' .private (with_correct_quantification body) - {#Function Code Code} - (form$ {#Item (symbol$ [prelude "__adjusted_quantified_type__"]) - {#Item (local$ ..quantification_level) - {#Item (nat$ 0) - {#Item body - {#End}}}}})) - -(def:'' .private (with_quantification depth body) - {#Function Nat {#Function Code Code}} - ({g!level - (let$ g!level - (form$ {#Item (text$ "lux i64 +") - {#Item g!level - {#Item (nat$ ("lux type as" Nat - ("lux i64 *" +2 - ("lux type as" Int - depth)))) - {#End}}}}) - body)} - (local$ ..quantification_level))) - -(def:'' .private (initialized_quantification? lux) - {#Function Lux Bit} - ({[..#info _ ..#source _ ..#current_module _ ..#modules _ - ..#scopes scopes ..#type_context _ ..#host _ - ..#seed _ ..#expected _ ..#location _ ..#extensions _ - ..#scope_type_vars _ ..#eval _] - (list#mix (function'' [scope verdict] - ({[#1] #1 - _ ({[..#name _ ..#inner _ ..#captured _ - ..#locals [..#counter _ - ..#mappings locals]] - (list#mix (function'' [local verdict] - ({[local _] - ({[#1] #1 - _ ("lux text =" ..quantification_level local)} - verdict)} - local)) - #0 - locals)} - scope)} - verdict)) - #0 - scopes)} - lux)) - -(def:'' .public All - Macro - (macro (_ tokens lux) - ({{#Item [_ {#Form {#Item self_name args}}] - {#Item body {#End}}} - {#Right [lux - {#Item ({raw - ({[#1] raw - [#0] (..quantified raw)} - (initialized_quantification? lux))} - ({{#End} - body - - {#Item head tail} - (with_correct_quantification - (let$ self_name (quantified_type_parameter 0) - ({[_ raw] - raw} - (list#mix (function'' [parameter offset,body'] - ({[offset body'] - [("lux i64 +" 2 offset) - (let$ parameter (quantified_type_parameter ("lux i64 +" offset 1)) - (UnivQ$ body'))]} - offset,body')) - [0 (with_quantification (list#size args) - body)] - args))))} - args)) - {#End}}]} - - _ - {#Left "Wrong syntax for All"}} - tokens))) + _ + (failure "Wrong syntax for partial_list")} + (list#reversed xs)))) -(def:'' .public Ex - Macro - (macro (_ tokens lux) - ({{#Item [_ {#Form {#Item self_name args}}] - {#Item body {#End}}} - {#Right [lux - {#Item ({raw - ({[#1] raw - [#0] (..quantified raw)} - (initialized_quantification? lux))} - ({{#End} - body - - {#Item head tail} - (with_correct_quantification - (let$ self_name (quantified_type_parameter 0) - ({[_ raw] - raw} - (list#mix (function'' [parameter offset,body'] - ({[offset body'] - [("lux i64 +" 2 offset) - (let$ parameter (quantified_type_parameter ("lux i64 +" offset 1)) - (ExQ$ body'))]} - offset,body')) - [0 (with_quantification (list#size args) - body)] - args))))} - args)) - {#End}}]} - - _ - {#Left "Wrong syntax for Ex"}} - tokens))) +(def'' .public Union + Macro + (macro (_ tokens) + ({{#End} + (meta#in (list (symbol$ [..prelude "Nothing"]))) -(def:'' .public -> - Macro - (macro (_ tokens) - ({{#Item output inputs} - (meta#in {#Item (list#mix ("lux type check" {#Function Code {#Function Code Code}} - (function'' [i o] (variant$ {#Item (symbol$ [..prelude "#Function"]) {#Item i {#Item o {#End}}}}))) - output - inputs) - {#End}}) - - _ - (failure "Wrong syntax for ->")} - (list#reversed tokens)))) + {#Item last prevs} + (meta#in (list (list#mix (function'' [left right] (variant$ (list (symbol$ [..prelude "#Sum"]) left right))) + last + prevs)))} + (list#reversed tokens)))) -(def:'' .public list - Macro - (macro (_ xs) - (meta#in {#Item (list#mix |#Item| |#End| (list#reversed xs)) - {#End}}))) +(def'' .public Tuple + Macro + (macro (_ tokens) + ({{#End} + (meta#in (list (symbol$ [..prelude "Any"]))) -(def:'' .private partial_list - Macro - (macro (_ xs) - ({{#Item last init} - (meta#in (list (list#mix |#Item| last init))) + {#Item last prevs} + (meta#in (list (list#mix (function'' [left right] (variant$ (list (symbol$ [..prelude "#Product"]) left right))) + last + prevs)))} + (list#reversed tokens)))) - _ - (failure "Wrong syntax for partial_list")} - (list#reversed xs)))) +(def'' .private function' + Macro + (macro (_ tokens) + (let'' [name tokens'] ({{#Item [[_ {#Symbol ["" name]}] tokens']} + [name tokens'] -(def:'' .public Union - Macro - (macro (_ tokens) - ({{#End} - (meta#in (list (symbol$ [..prelude "Nothing"]))) + _ + ["" tokens]} + tokens) + ({{#Item [[_ {#Tuple args}] {#Item [body {#End}]}]} + ({{#End} + (failure "function' requires a non-empty arguments tuple.") + + {#Item [harg targs]} + (meta#in (list (form$ (list (tuple$ (list (local$ name) + harg)) + (list#mix (function'' [arg body'] + (form$ (list (tuple$ (list (local$ "") + arg)) + body'))) + body + (list#reversed targs))))))} + args) - {#Item last prevs} - (meta#in (list (list#mix (function'' [left right] (variant$ (list (symbol$ [..prelude "#Sum"]) left right))) - last - prevs)))} - (list#reversed tokens)))) + _ + (failure "Wrong syntax for function'")} + tokens')))) + +(def'' .private def''' + Macro + (macro (_ tokens) + ({{#Item [export_policy + {#Item [[_ {#Form {#Item [name args]}}] + {#Item [type {#Item [body {#End}]}]}]}]} + (meta#in (list (form$ (list (text$ "lux def") + name + (form$ (list (text$ "lux type check") + type + (form$ (list (symbol$ [..prelude "function'"]) + name + (tuple$ args) + body)))) + export_policy)))) + + {#Item [export_policy {#Item [name {#Item [type {#Item [body {#End}]}]}]}]} + (meta#in (list (form$ (list (text$ "lux def") + name + (form$ (list (text$ "lux type check") + type + body)) + export_policy)))) -(def:'' .public Tuple - Macro - (macro (_ tokens) - ({{#End} - (meta#in (list (symbol$ [..prelude "Any"]))) + _ + (failure "Wrong syntax for def'''")} + tokens))) - {#Item last prevs} - (meta#in (list (list#mix (function'' [left right] (variant$ (list (symbol$ [..prelude "#Product"]) left right))) - last - prevs)))} - (list#reversed tokens)))) +(def''' .public Or + Macro + ..Union) -(def:'' .private function' +(def''' .public And Macro - (macro (_ tokens) - (let'' [name tokens'] ({{#Item [[_ {#Symbol ["" name]}] tokens']} - [name tokens'] + ..Tuple) - _ - ["" tokens]} - tokens) - ({{#Item [[_ {#Tuple args}] {#Item [body {#End}]}]} - ({{#End} - (failure "function' requires a non-empty arguments tuple.") - - {#Item [harg targs]} - (meta#in (list (form$ (list (tuple$ (list (local$ name) - harg)) - (list#mix (function'' [arg body'] - (form$ (list (tuple$ (list (local$ "") - arg)) - body'))) - body - (list#reversed targs))))))} - args) +(def''' .private (pairs xs) + (All (_ a) (-> ($' List a) ($' Maybe ($' List (Tuple a a))))) + ({{#Item x {#Item y xs'}} + ({{#Some tail} + {#Some {#Item [x y] tail}} + + {#None} + {#None}} + (pairs xs')) - _ - (failure "Wrong syntax for function'")} - tokens')))) + {#End} + {#Some {#End}} -(def:'' .private def:''' - Macro - (macro (_ tokens) - ({{#Item [export_policy - {#Item [[_ {#Form {#Item [name args]}}] - {#Item [type {#Item [body {#End}]}]}]}]} - (meta#in (list (form$ (list (text$ "lux def") - name - (form$ (list (text$ "lux type check") - type - (form$ (list (symbol$ [..prelude "function'"]) - name - (tuple$ args) - body)))) - export_policy)))) - - {#Item [export_policy {#Item [name {#Item [type {#Item [body {#End}]}]}]}]} - (meta#in (list (form$ (list (text$ "lux def") - name - (form$ (list (text$ "lux type check") - type - body)) - export_policy)))) + _ + {#None}} + xs)) - _ - (failure "Wrong syntax for def:'''")} - tokens))) - -(def:''' .public Or - Macro - ..Union) - -(def:''' .public And - Macro - ..Tuple) - -(def:''' .private (pairs xs) - (All (_ a) (-> ($' List a) ($' Maybe ($' List (Tuple a a))))) - ({{#Item x {#Item y xs'}} - ({{#Some tail} - {#Some {#Item [x y] tail}} +(def'' .private let' + Macro + (macro (_ tokens) + ({{#Item [_ {#Tuple bindings}] {#Item body {#End}}} + ({{#Some bindings} + (meta#in (list (list#mix ("lux type check" (-> (Tuple Code Code) Code + Code) + (function' [binding body] + ({[label value] + (form$ (list (variant$ (list label body)) value))} + binding))) + body + (list#reversed bindings)))) {#None} - {#None}} - (pairs xs')) - - {#End} - {#Some {#End}} + (failure "Wrong syntax for let'")} + (pairs bindings)) _ - {#None}} - xs)) - -(def:'' .private let' - Macro - (macro (_ tokens) - ({{#Item [_ {#Tuple bindings}] {#Item body {#End}}} - ({{#Some bindings} - (meta#in (list (list#mix ("lux type check" (-> (Tuple Code Code) Code - Code) - (function' [binding body] - ({[label value] - (form$ (list (variant$ (list label body)) value))} - binding))) - body - (list#reversed bindings)))) - - {#None} - (failure "Wrong syntax for let'")} - (pairs bindings)) + (failure "Wrong syntax for let'")} + tokens))) - _ - (failure "Wrong syntax for let'")} - tokens))) +(def''' .private (any? p xs) + (All (_ a) + (-> (-> a Bit) ($' List a) Bit)) + ({{#End} + #0 -(def:''' .private (any? p xs) - (All (_ a) - (-> (-> a Bit) ($' List a) Bit)) - ({{#End} - #0 + {#Item x xs'} + ({[#1] #1 + [#0] (any? p xs')} + (p x))} + xs)) - {#Item x xs'} - ({[#1] #1 - [#0] (any? p xs')} - (p x))} - xs)) +(def''' .private (with_location content) + (-> Code Code) + (tuple$ (list (tuple$ (list (text$ "") (nat$ 0) (nat$ 0))) + content))) -(def:''' .private (with_location content) - (-> Code Code) - (tuple$ (list (tuple$ (list (text$ "") (nat$ 0) (nat$ 0))) - content))) +(def''' .private (untemplated_list tokens) + (-> ($' List Code) Code) + ({{#End} + |#End| -(def:''' .private (untemplated_list tokens) - (-> ($' List Code) Code) - ({{#End} - |#End| + {#Item token tokens'} + (|#Item| token (untemplated_list tokens'))} + tokens)) - {#Item token tokens'} - (|#Item| token (untemplated_list tokens'))} - tokens)) +(def''' .private (list#composite xs ys) + (All (_ a) (-> ($' List a) ($' List a) ($' List a))) + (list#mix (function' [head tail] {#Item head tail}) + ys + (list#reversed xs))) -(def:''' .private (list#composite xs ys) - (All (_ a) (-> ($' List a) ($' List a) ($' List a))) - (list#mix (function' [head tail] {#Item head tail}) - ys - (list#reversed xs))) +(def''' .private (right_associativity op a1 a2) + (-> Code Code Code Code) + ({[_ {#Form parts}] + (form$ (list#composite parts (list a1 a2))) -(def:''' .private (right_associativity op a1 a2) - (-> Code Code Code Code) - ({[_ {#Form parts}] - (form$ (list#composite parts (list a1 a2))) + _ + (form$ (list op a1 a2))} + op)) + +(def''' .private (function#flipped func) + (All (_ a b c) + (-> (-> a b c) (-> b a c))) + (function' [right left] + (func left right))) + +(def'' .public left + Macro + (macro (_ tokens) + ({{#Item op tokens'} + ({{#Item first nexts} + (meta#in (list (list#mix (function#flipped (right_associativity op)) first nexts))) + _ + (failure "Wrong syntax for left")} + tokens') + _ - (form$ (list op a1 a2))} - op)) - -(def:''' .private (function#flipped func) - (All (_ a b c) - (-> (-> a b c) (-> b a c))) - (function' [right left] - (func left right))) + (failure "Wrong syntax for left")} + tokens))) -(def:'' .public left - Macro - (macro (_ tokens) - ({{#Item op tokens'} - ({{#Item first nexts} - (meta#in (list (list#mix (function#flipped (right_associativity op)) first nexts))) - - _ - (failure "Wrong syntax for left")} - tokens') - - _ - (failure "Wrong syntax for left")} - tokens))) +(def'' .public right + Macro + (macro (_ tokens) + ({{#Item op tokens'} + ({{#Item last prevs} + (meta#in (list (list#mix (right_associativity op) last prevs))) -(def:'' .public right - Macro - (macro (_ tokens) - ({{#Item op tokens'} - ({{#Item last prevs} - (meta#in (list (list#mix (right_associativity op) last prevs))) - - _ - (failure "Wrong syntax for right")} - (list#reversed tokens')) - - _ - (failure "Wrong syntax for right")} - tokens))) + _ + (failure "Wrong syntax for right")} + (list#reversed tokens')) + + _ + (failure "Wrong syntax for right")} + tokens))) -(def:''' .public all Macro ..right) +(def''' .public all Macro ..right) ... (type: (Monad m) ... (Interface @@ -1449,1499 +1449,1499 @@ ["#in" "#then"] #0) -(def:''' .private maybe#monad - ($' Monad Maybe) - [#in - (function' [x] {#Some x}) - - #then - (function' [f ma] - ({{#None} {#None} - {#Some a} (f a)} - ma))]) - -(def:''' .private meta#monad - ($' Monad Meta) - [#in - (function' [x] - (function' [state] - {#Right state x})) - - #then - (function' [f ma] - (function' [state] - ({{#Left msg} - {#Left msg} +(def''' .private maybe#monad + ($' Monad Maybe) + [#in + (function' [x] {#Some x}) + + #then + (function' [f ma] + ({{#None} {#None} + {#Some a} (f a)} + ma))]) + +(def''' .private meta#monad + ($' Monad Meta) + [#in + (function' [x] + (function' [state] + {#Right state x})) + + #then + (function' [f ma] + (function' [state] + ({{#Left msg} + {#Left msg} + + {#Right [state' a]} + (f a state')} + (ma state))))]) + +(def'' .private do + Macro + (macro (_ tokens) + ({{#Item monad {#Item [_ {#Tuple bindings}] {#Item body {#End}}}} + ({{#Some bindings} + (let' [g!in (local$ "in") + g!then (local$ " then ") + body' (list#mix ("lux type check" (-> (Tuple Code Code) Code Code) + (function' [binding body'] + (let' [[var value] binding] + ({[_ {#Symbol [module short]}] + ({"" + (form$ (list g!then + (form$ (list (tuple$ (list (local$ "") var)) body')) + value)) + + _ + (form$ (list var value body'))} + module) + + + _ + (form$ (list g!then + (form$ (list (tuple$ (list (local$ "") var)) body')) + value))} + var)))) + body + (list#reversed bindings))] + (meta#in (list (form$ (list (variant$ (list (tuple$ (list g!in g!then)) + body')) + monad))))) + + {#None} + (failure "Wrong syntax for do")} + (pairs bindings)) - {#Right [state' a]} - (f a state')} - (ma state))))]) + _ + (failure "Wrong syntax for do")} + tokens))) + +(def''' .private (monad#each m f xs) + (All (_ m a b) + (-> ($' Monad m) + (-> a ($' m b)) + ($' List a) + ($' m ($' List b)))) + (let' [[..#in in ..#then _] m] + ({{#End} + (in {#End}) + + {#Item x xs'} + (do m + [y (f x) + ys (monad#each m f xs')] + (in {#Item y ys}))} + xs))) + +(def''' .private (monad#mix m f y xs) + (All (_ m a b) + (-> ($' Monad m) + (-> a b ($' m b)) + b + ($' List a) + ($' m b))) + (let' [[..#in in ..#then _] m] + ({{#End} + (in y) + + {#Item x xs'} + (do m + [y' (f x y)] + (monad#mix m f y' xs'))} + xs))) + +(def'' .public if + Macro + (macro (_ tokens) + ({{#Item test {#Item then {#Item else {#End}}}} + (meta#in (list (form$ (list (variant$ (list (bit$ #1) then + (bit$ #0) else)) + test)))) -(def:'' .private do - Macro - (macro (_ tokens) - ({{#Item monad {#Item [_ {#Tuple bindings}] {#Item body {#End}}}} - ({{#Some bindings} - (let' [g!in (local$ "in") - g!then (local$ " then ") - body' (list#mix ("lux type check" (-> (Tuple Code Code) Code Code) - (function' [binding body'] - (let' [[var value] binding] - ({[_ {#Symbol [module short]}] - ({"" - (form$ (list g!then - (form$ (list (tuple$ (list (local$ "") var)) body')) - value)) - - _ - (form$ (list var value body'))} - module) - + _ + (failure "Wrong syntax for if")} + tokens))) - _ - (form$ (list g!then - (form$ (list (tuple$ (list (local$ "") var)) body')) - value))} - var)))) - body - (list#reversed bindings))] - (meta#in (list (form$ (list (variant$ (list (tuple$ (list g!in g!then)) - body')) - monad))))) - - {#None} - (failure "Wrong syntax for do")} - (pairs bindings)) +(def''' .private PList + Type + (All (_ a) ($' List (Tuple Text a)))) + +(def''' .private (plist#value k plist) + (All (_ a) + (-> Text ($' PList a) ($' Maybe a))) + ({{#Item [[k' v] plist']} + (if (text#= k k') + {#Some v} + (plist#value k plist')) + + {#End} + {#None}} + plist)) + +(def''' .private (plist#with k v plist) + (All (_ a) + (-> Text a ($' PList a) ($' PList a))) + ({{#Item [k' v'] plist'} + (if (text#= k k') + (partial_list [k v] plist') + (partial_list [k' v'] (plist#with k v plist'))) + + {#End} + (list [k v])} + plist)) + +(def''' .private (global_symbol full_name state) + (-> Symbol ($' Meta Symbol)) + (let' [[module name] full_name + [..#info info ..#source source ..#current_module _ ..#modules modules + ..#scopes scopes ..#type_context types ..#host host + ..#seed seed ..#expected expected ..#location location ..#extensions extensions + ..#scope_type_vars scope_type_vars ..#eval _eval] state] + ({{#Some [..#module_hash _ ..#module_aliases _ ..#definitions definitions ..#imports _ ..#module_state _]} + ({{#Some constant} + ({{#Definition _} {#Right [state full_name]} + {#Tag _} {#Right [state full_name]} + {#Slot _} {#Right [state full_name]} + {#Type _} {#Right [state full_name]} + + {#Alias real_name} + {#Right [state real_name]}} + constant) - _ - (failure "Wrong syntax for do")} - tokens))) - -(def:''' .private (monad#each m f xs) - (All (_ m a b) - (-> ($' Monad m) - (-> a ($' m b)) - ($' List a) - ($' m ($' List b)))) - (let' [[..#in in ..#then _] m] - ({{#End} - (in {#End}) - - {#Item x xs'} - (do m - [y (f x) - ys (monad#each m f xs')] - (in {#Item y ys}))} - xs))) - -(def:''' .private (monad#mix m f y xs) - (All (_ m a b) - (-> ($' Monad m) - (-> a b ($' m b)) - b - ($' List a) - ($' m b))) - (let' [[..#in in ..#then _] m] - ({{#End} - (in y) + {#None} + {#Left (all text#composite "Unknown definition: " (symbol#encoded full_name))}} + (plist#value name definitions)) + + {#None} + {#Left (all text#composite "Unknown module: " module " @ " (symbol#encoded full_name))}} + (plist#value module modules)))) + +(def''' .private (:List<Code> expression) + (-> Code Code) + (let' [type (variant$ (list (symbol$ [..prelude "#Apply"]) + (symbol$ [..prelude "Code"]) + (symbol$ [..prelude "List"])))] + (form$ (list (text$ "lux type check") type expression)))) + +(def''' .private (spliced replace? untemplated elems) + (-> Bit (-> Code ($' Meta Code)) ($' List Code) ($' Meta Code)) + ({[#1] ({{#End} + (meta#in |#End|) - {#Item x xs'} - (do m - [y' (f x y)] - (monad#mix m f y' xs'))} - xs))) + {#Item lastI inits} + (do meta#monad + [lastO ({[_ {#Form {#Item [[_ {#Symbol ["" "~+"]}] {#Item [spliced {#End}]}]}}] + (in (:List<Code> spliced)) -(def:'' .public if - Macro - (macro (_ tokens) - ({{#Item test {#Item then {#Item else {#End}}}} - (meta#in (list (form$ (list (variant$ (list (bit$ #1) then - (bit$ #0) else)) - test)))) + _ + (do meta#monad + [lastO (untemplated lastI)] + (in (:List<Code> (|#Item| lastO |#End|))))} + lastI)] + (monad#mix meta#monad + (function' [leftI rightO] + ({[_ {#Form {#Item [[_ {#Symbol ["" "~+"]}] {#Item [spliced {#End}]}]}}] + (let' [g!in-module (form$ (list (text$ "lux in-module") + (text$ ..prelude) + (symbol$ [..prelude "list#composite"])))] + (in (form$ (list g!in-module (:List<Code> spliced) rightO)))) + + _ + (do meta#monad + [leftO (untemplated leftI)] + (in (|#Item| leftO rightO)))} + leftI)) + lastO + inits))} + (list#reversed elems)) + [#0] (do meta#monad + [=elems (monad#each meta#monad untemplated elems)] + (in (untemplated_list =elems)))} + replace?)) + +(def''' .private (untemplated_text value) + (-> Text Code) + (with_location (variant$ (list (symbol$ [..prelude "#Text"]) (text$ value))))) + +(def''' .private (untemplated replace? subst token) + (-> Bit Text Code ($' Meta Code)) + ({[_ [_ {#Bit value}]] + (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Bit"]) (bit$ value))))) + + [_ [_ {#Nat value}]] + (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Nat"]) (nat$ value))))) + + [_ [_ {#Int value}]] + (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Int"]) (int$ value))))) + + [_ [_ {#Rev value}]] + (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Rev"]) (rev$ value))))) + + [_ [_ {#Frac value}]] + (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Frac"]) (frac$ value))))) - _ - (failure "Wrong syntax for if")} - tokens))) + [_ [_ {#Text value}]] + (meta#in (untemplated_text value)) -(def:''' .private PList - Type - (All (_ a) ($' List (Tuple Text a)))) + [#1 [_ {#Symbol [module name]}]] + (do meta#monad + [real_name ({"" + (if (text#= "" subst) + (in [module name]) + (global_symbol [subst name])) -(def:''' .private (plist#value k plist) - (All (_ a) - (-> Text ($' PList a) ($' Maybe a))) - ({{#Item [[k' v] plist']} - (if (text#= k k') - {#Some v} - (plist#value k plist')) + _ + (in [module name])} + module) + .let' [[module name] real_name]] + (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Symbol"]) (tuple$ (list (text$ module) (text$ name)))))))) - {#End} - {#None}} - plist)) + [#0 [_ {#Symbol [module name]}]] + (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Symbol"]) (tuple$ (list (text$ module) (text$ name))))))) -(def:''' .private (plist#with k v plist) - (All (_ a) - (-> Text a ($' PList a) ($' PList a))) - ({{#Item [k' v'] plist'} - (if (text#= k k') - (partial_list [k v] plist') - (partial_list [k' v'] (plist#with k v plist'))) + [#1 [_ {#Form {#Item [[_ {#Symbol ["" "~"]}] {#Item [unquoted {#End}]}]}}]] + (meta#in (form$ (list (text$ "lux type check") + (symbol$ [..prelude "Code"]) + unquoted))) - {#End} - (list [k v])} - plist)) - -(def:''' .private (global_symbol full_name state) - (-> Symbol ($' Meta Symbol)) - (let' [[module name] full_name - [..#info info ..#source source ..#current_module _ ..#modules modules - ..#scopes scopes ..#type_context types ..#host host - ..#seed seed ..#expected expected ..#location location ..#extensions extensions - ..#scope_type_vars scope_type_vars ..#eval _eval] state] - ({{#Some [..#module_hash _ ..#module_aliases _ ..#definitions definitions ..#imports _ ..#module_state _]} - ({{#Some constant} - ({{#Definition _} {#Right [state full_name]} - {#Tag _} {#Right [state full_name]} - {#Slot _} {#Right [state full_name]} - {#Type _} {#Right [state full_name]} - - {#Alias real_name} - {#Right [state real_name]}} - constant) - - {#None} - {#Left (all text#composite "Unknown definition: " (symbol#encoded full_name))}} - (plist#value name definitions)) - - {#None} - {#Left (all text#composite "Unknown module: " module " @ " (symbol#encoded full_name))}} - (plist#value module modules)))) - -(def:''' .private (:List<Code> expression) - (-> Code Code) - (let' [type (variant$ (list (symbol$ [..prelude "#Apply"]) - (symbol$ [..prelude "Code"]) - (symbol$ [..prelude "List"])))] - (form$ (list (text$ "lux type check") type expression)))) - -(def:''' .private (spliced replace? untemplated elems) - (-> Bit (-> Code ($' Meta Code)) ($' List Code) ($' Meta Code)) - ({[#1] ({{#End} - (meta#in |#End|) - - {#Item lastI inits} - (do meta#monad - [lastO ({[_ {#Form {#Item [[_ {#Symbol ["" "~+"]}] {#Item [spliced {#End}]}]}}] - (in (:List<Code> spliced)) + [#1 [_ {#Form {#Item [[_ {#Symbol ["" "~!"]}] {#Item [dependent {#End}]}]}}]] + (do meta#monad + [independent (untemplated replace? subst dependent)] + (in (with_location (variant$ (list (symbol$ [..prelude "#Form"]) + (untemplated_list (list (untemplated_text "lux in-module") + (untemplated_text subst) + independent))))))) - _ - (do meta#monad - [lastO (untemplated lastI)] - (in (:List<Code> (|#Item| lastO |#End|))))} - lastI)] - (monad#mix meta#monad - (function' [leftI rightO] - ({[_ {#Form {#Item [[_ {#Symbol ["" "~+"]}] {#Item [spliced {#End}]}]}}] - (let' [g!in-module (form$ (list (text$ "lux in-module") - (text$ ..prelude) - (symbol$ [..prelude "list#composite"])))] - (in (form$ (list g!in-module (:List<Code> spliced) rightO)))) - - _ - (do meta#monad - [leftO (untemplated leftI)] - (in (|#Item| leftO rightO)))} - leftI)) - lastO - inits))} - (list#reversed elems)) - [#0] (do meta#monad - [=elems (monad#each meta#monad untemplated elems)] - (in (untemplated_list =elems)))} - replace?)) - -(def:''' .private (untemplated_text value) - (-> Text Code) - (with_location (variant$ (list (symbol$ [..prelude "#Text"]) (text$ value))))) - -(def:''' .private (untemplated replace? subst token) - (-> Bit Text Code ($' Meta Code)) - ({[_ [_ {#Bit value}]] - (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Bit"]) (bit$ value))))) - - [_ [_ {#Nat value}]] - (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Nat"]) (nat$ value))))) - - [_ [_ {#Int value}]] - (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Int"]) (int$ value))))) - - [_ [_ {#Rev value}]] - (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Rev"]) (rev$ value))))) - - [_ [_ {#Frac value}]] - (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Frac"]) (frac$ value))))) + [#1 [_ {#Form {#Item [[_ {#Symbol ["" "~'"]}] {#Item [keep_quoted {#End}]}]}}]] + (untemplated #0 subst keep_quoted) - [_ [_ {#Text value}]] - (meta#in (untemplated_text value)) + [_ [meta {#Form elems}]] + (do meta#monad + [output (spliced replace? (untemplated replace? subst) elems) + .let' [[_ output'] (with_location (variant$ (list (symbol$ [..prelude "#Form"]) output)))]] + (in [meta output'])) - [#1 [_ {#Symbol [module name]}]] - (do meta#monad - [real_name ({"" - (if (text#= "" subst) - (in [module name]) - (global_symbol [subst name])) + [_ [meta {#Variant elems}]] + (do meta#monad + [output (spliced replace? (untemplated replace? subst) elems) + .let' [[_ output'] (with_location (variant$ (list (symbol$ [..prelude "#Variant"]) output)))]] + (in [meta output'])) - _ - (in [module name])} - module) - .let' [[module name] real_name]] - (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Symbol"]) (tuple$ (list (text$ module) (text$ name)))))))) + [_ [meta {#Tuple elems}]] + (do meta#monad + [output (spliced replace? (untemplated replace? subst) elems) + .let' [[_ output'] (with_location (variant$ (list (symbol$ [..prelude "#Tuple"]) output)))]] + (in [meta output']))} + [replace? token])) - [#0 [_ {#Symbol [module name]}]] - (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Symbol"]) (tuple$ (list (text$ module) (text$ name))))))) +(def'' .public Primitive + Macro + (macro (_ tokens) + ({{#Item [_ {#Text class_name}] {#End}} + (meta#in (list (variant$ (list (symbol$ [..prelude "#Primitive"]) (text$ class_name) |#End|)))) - [#1 [_ {#Form {#Item [[_ {#Symbol ["" "~"]}] {#Item [unquoted {#End}]}]}}]] - (meta#in (form$ (list (text$ "lux type check") - (symbol$ [..prelude "Code"]) - unquoted))) + {#Item [_ {#Text class_name}] {#Item [_ {#Tuple params}] {#End}}} + (meta#in (list (variant$ (list (symbol$ [..prelude "#Primitive"]) (text$ class_name) (untemplated_list params))))) - [#1 [_ {#Form {#Item [[_ {#Symbol ["" "~!"]}] {#Item [dependent {#End}]}]}}]] + _ + (failure "Wrong syntax for Primitive")} + tokens))) + +(def'' .private (current_module_name state) + ($' Meta Text) + ({[..#info info ..#source source ..#current_module current_module ..#modules modules + ..#scopes scopes ..#type_context types ..#host host + ..#seed seed ..#expected expected ..#location location ..#extensions extensions + ..#scope_type_vars scope_type_vars ..#eval _eval] + ({{#Some module_name} + {#Right [state module_name]} + + _ + {#Left "Cannot get the module name without a module!"}} + current_module)} + state)) + +(def'' .public ` + Macro + (macro (_ tokens) + ({{#Item template {#End}} (do meta#monad - [independent (untemplated replace? subst dependent)] - (in (with_location (variant$ (list (symbol$ [..prelude "#Form"]) - (untemplated_list (list (untemplated_text "lux in-module") - (untemplated_text subst) - independent))))))) + [current_module current_module_name + =template (untemplated #1 current_module template)] + (in (list (form$ (list (text$ "lux type check") + (symbol$ [..prelude "Code"]) + =template))))) - [#1 [_ {#Form {#Item [[_ {#Symbol ["" "~'"]}] {#Item [keep_quoted {#End}]}]}}]] - (untemplated #0 subst keep_quoted) + _ + (failure "Wrong syntax for `")} + tokens))) - [_ [meta {#Form elems}]] +(def'' .public `' + Macro + (macro (_ tokens) + ({{#Item template {#End}} (do meta#monad - [output (spliced replace? (untemplated replace? subst) elems) - .let' [[_ output'] (with_location (variant$ (list (symbol$ [..prelude "#Form"]) output)))]] - (in [meta output'])) + [=template (untemplated #1 "" template)] + (in (list (form$ (list (text$ "lux type check") (symbol$ [..prelude "Code"]) =template))))) - [_ [meta {#Variant elems}]] - (do meta#monad - [output (spliced replace? (untemplated replace? subst) elems) - .let' [[_ output'] (with_location (variant$ (list (symbol$ [..prelude "#Variant"]) output)))]] - (in [meta output'])) + _ + (failure "Wrong syntax for `")} + tokens))) - [_ [meta {#Tuple elems}]] +(def'' .public ' + Macro + (macro (_ tokens) + ({{#Item template {#End}} (do meta#monad - [output (spliced replace? (untemplated replace? subst) elems) - .let' [[_ output'] (with_location (variant$ (list (symbol$ [..prelude "#Tuple"]) output)))]] - (in [meta output']))} - [replace? token])) + [=template (untemplated #0 "" template)] + (in (list (form$ (list (text$ "lux type check") (symbol$ [..prelude "Code"]) =template))))) -(def:'' .public Primitive - Macro - (macro (_ tokens) - ({{#Item [_ {#Text class_name}] {#End}} - (meta#in (list (variant$ (list (symbol$ [..prelude "#Primitive"]) (text$ class_name) |#End|)))) - - {#Item [_ {#Text class_name}] {#Item [_ {#Tuple params}] {#End}}} - (meta#in (list (variant$ (list (symbol$ [..prelude "#Primitive"]) (text$ class_name) (untemplated_list params))))) + _ + (failure "Wrong syntax for '")} + tokens))) - _ - (failure "Wrong syntax for Primitive")} - tokens))) +(def'' .public |> + Macro + (macro (_ tokens) + ({{#Item [init apps]} + (meta#in (list (list#mix ("lux type check" (-> Code Code Code) + (function' [app acc] + ({[_ {#Variant parts}] + (variant$ (list#composite parts (list acc))) -(def:'' .private (current_module_name state) - ($' Meta Text) - ({[..#info info ..#source source ..#current_module current_module ..#modules modules - ..#scopes scopes ..#type_context types ..#host host - ..#seed seed ..#expected expected ..#location location ..#extensions extensions - ..#scope_type_vars scope_type_vars ..#eval _eval] - ({{#Some module_name} - {#Right [state module_name]} + [_ {#Tuple parts}] + (tuple$ (list#composite parts (list acc))) - _ - {#Left "Cannot get the module name without a module!"}} - current_module)} - state)) + [_ {#Form parts}] + (form$ (list#composite parts (list acc))) -(def:'' .public ` - Macro - (macro (_ tokens) - ({{#Item template {#End}} - (do meta#monad - [current_module current_module_name - =template (untemplated #1 current_module template)] - (in (list (form$ (list (text$ "lux type check") - (symbol$ [..prelude "Code"]) - =template))))) + _ + (` ((~ app) (~ acc)))} + app))) + init + apps))) - _ - (failure "Wrong syntax for `")} - tokens))) + _ + (failure "Wrong syntax for |>")} + tokens))) -(def:'' .public `' - Macro - (macro (_ tokens) - ({{#Item template {#End}} - (do meta#monad - [=template (untemplated #1 "" template)] - (in (list (form$ (list (text$ "lux type check") (symbol$ [..prelude "Code"]) =template))))) +(def'' .public <| + Macro + (macro (_ tokens) + ({{#Item [init apps]} + (meta#in (list (list#mix ("lux type check" (-> Code Code Code) + (function' [app acc] + ({[_ {#Variant parts}] + (variant$ (list#composite parts (list acc))) - _ - (failure "Wrong syntax for `")} - tokens))) + [_ {#Tuple parts}] + (tuple$ (list#composite parts (list acc))) -(def:'' .public ' - Macro - (macro (_ tokens) - ({{#Item template {#End}} - (do meta#monad - [=template (untemplated #0 "" template)] - (in (list (form$ (list (text$ "lux type check") (symbol$ [..prelude "Code"]) =template))))) + [_ {#Form parts}] + (form$ (list#composite parts (list acc))) - _ - (failure "Wrong syntax for '")} - tokens))) + _ + (` ((~ app) (~ acc)))} + app))) + init + apps))) -(def:'' .public |> - Macro - (macro (_ tokens) - ({{#Item [init apps]} - (meta#in (list (list#mix ("lux type check" (-> Code Code Code) - (function' [app acc] - ({[_ {#Variant parts}] - (variant$ (list#composite parts (list acc))) + _ + (failure "Wrong syntax for <|")} + (list#reversed tokens)))) - [_ {#Tuple parts}] - (tuple$ (list#composite parts (list acc))) +(def''' .private (function#composite f g) + (All (_ a b c) + (-> (-> b c) (-> a b) (-> a c))) + (function' [x] (f (g x)))) - [_ {#Form parts}] - (form$ (list#composite parts (list acc))) +(def''' .private (symbol_name x) + (-> Code ($' Maybe Symbol)) + ({[_ {#Symbol sname}] + {#Some sname} - _ - (` ((~ app) (~ acc)))} - app))) - init - apps))) + _ + {#None}} + x)) - _ - (failure "Wrong syntax for |>")} - tokens))) +(def''' .private (symbol_short x) + (-> Code ($' Maybe Text)) + ({[_ {#Symbol "" sname}] + {#Some sname} -(def:'' .public <| - Macro - (macro (_ tokens) - ({{#Item [init apps]} - (meta#in (list (list#mix ("lux type check" (-> Code Code Code) - (function' [app acc] - ({[_ {#Variant parts}] - (variant$ (list#composite parts (list acc))) + _ + {#None}} + x)) - [_ {#Tuple parts}] - (tuple$ (list#composite parts (list acc))) +(def''' .private (tuple_list tuple) + (-> Code ($' Maybe ($' List Code))) + ({[_ {#Tuple members}] + {#Some members} - [_ {#Form parts}] - (form$ (list#composite parts (list acc))) + _ + {#None}} + tuple)) - _ - (` ((~ app) (~ acc)))} - app))) - init - apps))) +(def''' .private (realized_template env template) + (-> Replacement_Environment Code Code) + ({[_ {#Symbol "" sname}] + ({{#Some subst} + subst _ - (failure "Wrong syntax for <|")} - (list#reversed tokens)))) - -(def:''' .private (function#composite f g) - (All (_ a b c) - (-> (-> b c) (-> a b) (-> a c))) - (function' [x] (f (g x)))) + template} + (..replacement sname env)) -(def:''' .private (symbol_name x) - (-> Code ($' Maybe Symbol)) - ({[_ {#Symbol sname}] - {#Some sname} + [meta {#Form elems}] + [meta {#Form (list#each (realized_template env) elems)}] - _ - {#None}} - x)) - -(def:''' .private (symbol_short x) - (-> Code ($' Maybe Text)) - ({[_ {#Symbol "" sname}] - {#Some sname} + [meta {#Tuple elems}] + [meta {#Tuple (list#each (realized_template env) elems)}] - _ - {#None}} - x)) + [meta {#Variant elems}] + [meta {#Variant (list#each (realized_template env) elems)}] -(def:''' .private (tuple_list tuple) - (-> Code ($' Maybe ($' List Code))) - ({[_ {#Tuple members}] - {#Some members} - - _ - {#None}} - tuple)) - -(def:''' .private (realized_template env template) - (-> Replacement_Environment Code Code) - ({[_ {#Symbol "" sname}] - ({{#Some subst} - subst + _ + template} + template)) + +(def''' .private (every? p xs) + (All (_ a) + (-> (-> a Bit) ($' List a) Bit)) + (list#mix (function' [_2 _1] (if _1 (p _2) #0)) #1 xs)) + +(def''' .private (high_bits value) + (-> ($' I64 Any) I64) + ("lux i64 right-shift" 32 value)) + +(def''' .private low_mask + I64 + (|> 1 ("lux i64 left-shift" 32) ("lux i64 -" 1))) + +(def''' .private (low_bits value) + (-> ($' I64 Any) I64) + ("lux i64 and" low_mask value)) + +(def''' .private (n/< reference sample) + (-> Nat Nat Bit) + (let' [referenceH (high_bits reference) + sampleH (high_bits sample)] + (if ("lux i64 <" referenceH sampleH) + #1 + (if ("lux i64 =" referenceH sampleH) + ("lux i64 <" + (low_bits reference) + (low_bits sample)) + #0)))) + +(def''' .private (list#conjoint xs) + (All (_ a) + (-> ($' List ($' List a)) ($' List a))) + (list#mix list#composite {#End} (list#reversed xs))) + +(def'' .public with_template + Macro + (macro (_ tokens) + ({{#Item [[_ {#Tuple bindings}] {#Item [[_ {#Tuple templates}] data]}]} + ({[{#Some bindings'} {#Some data'}] + (let' [apply ("lux type check" (-> Replacement_Environment ($' List Code)) + (function' [env] (list#each (realized_template env) templates))) + num_bindings (list#size bindings')] + (if (every? (function' [size] ("lux i64 =" num_bindings size)) + (list#each list#size data')) + (|> data' + (list#each (function#composite apply (replacement_environment bindings'))) + list#conjoint + meta#in) + (failure (..wrong_syntax_error [..prelude "with_template"])))) _ - template} - (..replacement sname env)) + (failure (..wrong_syntax_error [..prelude "with_template"]))} + [(monad#each maybe#monad symbol_short bindings) + (monad#each maybe#monad tuple_list data)]) - [meta {#Form elems}] - [meta {#Form (list#each (realized_template env) elems)}] + _ + (failure (..wrong_syntax_error [..prelude "with_template"]))} + tokens))) + +(def''' .private (n// param subject) + (-> Nat Nat Nat) + (if ("lux i64 <" +0 ("lux type as" Int param)) + (if (n/< param subject) + 0 + 1) + (let' [quotient (|> subject + ("lux i64 right-shift" 1) + ("lux i64 /" ("lux type as" Int param)) + ("lux i64 left-shift" 1)) + flat ("lux i64 *" + ("lux type as" Int param) + ("lux type as" Int quotient)) + remainder ("lux i64 -" flat subject)] + (if (n/< param remainder) + quotient + ("lux i64 +" 1 quotient))))) + +(def''' .private (n/% param subject) + (-> Nat Nat Nat) + (let' [flat ("lux i64 *" + ("lux type as" Int param) + ("lux type as" Int (n// param subject)))] + ("lux i64 -" flat subject))) + +(def''' .private (n/min left right) + (-> Nat Nat Nat) + (if (n/< right left) + left + right)) + +(def''' .private (bit#encoded x) + (-> Bit Text) + (if x "#1" "#0")) + +(def''' .private (digit::format digit) + (-> Nat Text) + ({[0] "0" + [1] "1" [2] "2" [3] "3" + [4] "4" [5] "5" [6] "6" + [7] "7" [8] "8" [9] "9" + _ ("lux io error" "@digit::format Undefined behavior.")} + digit)) + +(def''' .private (nat#encoded value) + (-> Nat Text) + ({[0] "0" + _ (let' [loop ("lux type check" (-> Nat Text Text) + (function' again [input output] + (if ("lux i64 =" 0 input) + output + (again (n// 10 input) + (text#composite (|> input (n/% 10) digit::format) + output)))))] + (loop value ""))} + value)) + +(def''' .private (int#abs value) + (-> Int Int) + (if ("lux i64 <" +0 value) + ("lux i64 *" -1 value) + value)) - [meta {#Tuple elems}] - [meta {#Tuple (list#each (realized_template env) elems)}] +(def''' .private (int#encoded value) + (-> Int Text) + (if ("lux i64 =" +0 value) + "+0" + (let' [sign (if ("lux i64 <" value +0) + "+" + "-")] + (("lux type check" (-> Int Text Text) + (function' again [input output] + (if ("lux i64 =" +0 input) + (text#composite sign output) + (again ("lux i64 /" +10 input) + (text#composite (|> input ("lux i64 %" +10) ("lux type as" Nat) digit::format) + output))))) + (|> value ("lux i64 /" +10) int#abs) + (|> value ("lux i64 %" +10) int#abs ("lux type as" Nat) digit::format))))) + +(def''' .private (frac#encoded x) + (-> Frac Text) + ("lux f64 encode" x)) + +(def''' .public (not x) + (-> Bit Bit) + (if x #0 #1)) + +(def''' .private (macro_type? type) + (-> Type Bit) + ({{#Named ["library/lux" "Macro"] {#Primitive "#Macro" {#End}}} + #1 - [meta {#Variant elems}] - [meta {#Variant (list#each (realized_template env) elems)}] + _ + #0} + type)) + +(def''' .private (named_macro' modules current_module module name) + (-> ($' List (Tuple Text Module)) + Text Text Text + ($' Maybe Macro)) + (do maybe#monad + [$module (plist#value module modules) + gdef (let' [[..#module_hash _ ..#module_aliases _ ..#definitions bindings ..#imports _ ..#module_state _] ("lux type check" Module $module)] + (plist#value name bindings))] + ({{#Alias [r_module r_name]} + (named_macro' modules current_module r_module r_name) + + {#Definition [exported? def_type def_value]} + (if (macro_type? def_type) + (if exported? + {#Some ("lux type as" Macro def_value)} + (if (text#= module current_module) + {#Some ("lux type as" Macro def_value)} + {#None})) + {#None}) + + {#Type [exported? type labels]} + {#None} - _ - template} - template)) - -(def:''' .private (every? p xs) - (All (_ a) - (-> (-> a Bit) ($' List a) Bit)) - (list#mix (function' [_2 _1] (if _1 (p _2) #0)) #1 xs)) - -(def:''' .private (high_bits value) - (-> ($' I64 Any) I64) - ("lux i64 right-shift" 32 value)) - -(def:''' .private low_mask - I64 - (|> 1 ("lux i64 left-shift" 32) ("lux i64 -" 1))) - -(def:''' .private (low_bits value) - (-> ($' I64 Any) I64) - ("lux i64 and" low_mask value)) - -(def:''' .private (n/< reference sample) - (-> Nat Nat Bit) - (let' [referenceH (high_bits reference) - sampleH (high_bits sample)] - (if ("lux i64 <" referenceH sampleH) - #1 - (if ("lux i64 =" referenceH sampleH) - ("lux i64 <" - (low_bits reference) - (low_bits sample)) - #0)))) - -(def:''' .private (list#conjoint xs) - (All (_ a) - (-> ($' List ($' List a)) ($' List a))) - (list#mix list#composite {#End} (list#reversed xs))) - -(def:'' .public with_template - Macro - (macro (_ tokens) - ({{#Item [[_ {#Tuple bindings}] {#Item [[_ {#Tuple templates}] data]}]} - ({[{#Some bindings'} {#Some data'}] - (let' [apply ("lux type check" (-> Replacement_Environment ($' List Code)) - (function' [env] (list#each (realized_template env) templates))) - num_bindings (list#size bindings')] - (if (every? (function' [size] ("lux i64 =" num_bindings size)) - (list#each list#size data')) - (|> data' - (list#each (function#composite apply (replacement_environment bindings'))) - list#conjoint - meta#in) - (failure (..wrong_syntax_error [..prelude "with_template"])))) + {#Tag _} + {#None} - _ - (failure (..wrong_syntax_error [..prelude "with_template"]))} - [(monad#each maybe#monad symbol_short bindings) - (monad#each maybe#monad tuple_list data)]) + {#Slot _} + {#None}} + ("lux type check" Global gdef)))) - _ - (failure (..wrong_syntax_error [..prelude "with_template"]))} - tokens))) - -(def:''' .private (n// param subject) - (-> Nat Nat Nat) - (if ("lux i64 <" +0 ("lux type as" Int param)) - (if (n/< param subject) - 0 - 1) - (let' [quotient (|> subject - ("lux i64 right-shift" 1) - ("lux i64 /" ("lux type as" Int param)) - ("lux i64 left-shift" 1)) - flat ("lux i64 *" - ("lux type as" Int param) - ("lux type as" Int quotient)) - remainder ("lux i64 -" flat subject)] - (if (n/< param remainder) - quotient - ("lux i64 +" 1 quotient))))) - -(def:''' .private (n/% param subject) - (-> Nat Nat Nat) - (let' [flat ("lux i64 *" - ("lux type as" Int param) - ("lux type as" Int (n// param subject)))] - ("lux i64 -" flat subject))) - -(def:''' .private (n/min left right) - (-> Nat Nat Nat) - (if (n/< right left) - left - right)) - -(def:''' .private (bit#encoded x) - (-> Bit Text) - (if x "#1" "#0")) - -(def:''' .private (digit::format digit) - (-> Nat Text) - ({[0] "0" - [1] "1" [2] "2" [3] "3" - [4] "4" [5] "5" [6] "6" - [7] "7" [8] "8" [9] "9" - _ ("lux io error" "@digit::format Undefined behavior.")} - digit)) - -(def:''' .private (nat#encoded value) - (-> Nat Text) - ({[0] "0" - _ (let' [loop ("lux type check" (-> Nat Text Text) - (function' again [input output] - (if ("lux i64 =" 0 input) - output - (again (n// 10 input) - (text#composite (|> input (n/% 10) digit::format) - output)))))] - (loop value ""))} - value)) +(def''' .private (normal name) + (-> Symbol ($' Meta Symbol)) + ({["" name] + (do meta#monad + [module_name ..current_module_name] + (in [module_name name])) -(def:''' .private (int#abs value) - (-> Int Int) - (if ("lux i64 <" +0 value) - ("lux i64 *" -1 value) - value)) - -(def:''' .private (int#encoded value) - (-> Int Text) - (if ("lux i64 =" +0 value) - "+0" - (let' [sign (if ("lux i64 <" value +0) - "+" - "-")] - (("lux type check" (-> Int Text Text) - (function' again [input output] - (if ("lux i64 =" +0 input) - (text#composite sign output) - (again ("lux i64 /" +10 input) - (text#composite (|> input ("lux i64 %" +10) ("lux type as" Nat) digit::format) - output))))) - (|> value ("lux i64 /" +10) int#abs) - (|> value ("lux i64 %" +10) int#abs ("lux type as" Nat) digit::format))))) - -(def:''' .private (frac#encoded x) - (-> Frac Text) - ("lux f64 encode" x)) - -(def:''' .public (not x) - (-> Bit Bit) - (if x #0 #1)) - -(def:''' .private (macro_type? type) - (-> Type Bit) - ({{#Named ["library/lux" "Macro"] {#Primitive "#Macro" {#End}}} - #1 + _ + (meta#in name)} + name)) - _ - #0} - type)) +(def''' .private (named_macro full_name) + (-> Symbol ($' Meta ($' Maybe Macro))) + (do meta#monad + [current_module current_module_name] + (let' [[module name] full_name] + (function' [state] + ({[..#info info ..#source source ..#current_module _ ..#modules modules + ..#scopes scopes ..#type_context types ..#host host + ..#seed seed ..#expected expected + ..#location location ..#extensions extensions + ..#scope_type_vars scope_type_vars ..#eval _eval] + {#Right state (named_macro' modules current_module module name)}} + state))))) + +(def''' .private (macro? name) + (-> Symbol ($' Meta Bit)) + (do meta#monad + [name (normal name) + output (named_macro name)] + (in ({{#Some _} #1 + {#None} #0} + output)))) + +(def''' .private (list#interposed sep xs) + (All (_ a) + (-> a ($' List a) ($' List a))) + ({{#End} + xs -(def:''' .private (named_macro' modules current_module module name) - (-> ($' List (Tuple Text Module)) - Text Text Text - ($' Maybe Macro)) - (do maybe#monad - [$module (plist#value module modules) - gdef (let' [[..#module_hash _ ..#module_aliases _ ..#definitions bindings ..#imports _ ..#module_state _] ("lux type check" Module $module)] - (plist#value name bindings))] - ({{#Alias [r_module r_name]} - (named_macro' modules current_module r_module r_name) - - {#Definition [exported? def_type def_value]} - (if (macro_type? def_type) - (if exported? - {#Some ("lux type as" Macro def_value)} - (if (text#= module current_module) - {#Some ("lux type as" Macro def_value)} - {#None})) - {#None}) - - {#Type [exported? type labels]} - {#None} + {#Item [x {#End}]} + xs - {#Tag _} - {#None} + {#Item [x xs']} + (partial_list x sep (list#interposed sep xs'))} + xs)) - {#Slot _} - {#None}} - ("lux type check" Global gdef)))) +(def''' .private (single_expansion token) + (-> Code ($' Meta ($' List Code))) + ({[_ {#Form {#Item [_ {#Symbol name}] args}}] + (do meta#monad + [name' (normal name) + ?macro (named_macro name')] + ({{#Some macro} + (("lux type as" Macro' macro) args) + + {#None} + (in (list token))} + ?macro)) -(def:''' .private (normal name) - (-> Symbol ($' Meta Symbol)) - ({["" name] - (do meta#monad - [module_name ..current_module_name] - (in [module_name name])) + _ + (meta#in (list token))} + token)) - _ - (meta#in name)} - name)) - -(def:''' .private (named_macro full_name) - (-> Symbol ($' Meta ($' Maybe Macro))) - (do meta#monad - [current_module current_module_name] - (let' [[module name] full_name] - (function' [state] - ({[..#info info ..#source source ..#current_module _ ..#modules modules - ..#scopes scopes ..#type_context types ..#host host - ..#seed seed ..#expected expected - ..#location location ..#extensions extensions - ..#scope_type_vars scope_type_vars ..#eval _eval] - {#Right state (named_macro' modules current_module module name)}} - state))))) - -(def:''' .private (macro? name) - (-> Symbol ($' Meta Bit)) - (do meta#monad - [name (normal name) - output (named_macro name)] - (in ({{#Some _} #1 - {#None} #0} - output)))) - -(def:''' .private (list#interposed sep xs) - (All (_ a) - (-> a ($' List a) ($' List a))) - ({{#End} - xs +(def''' .private (expansion token) + (-> Code ($' Meta ($' List Code))) + ({[_ {#Form {#Item [_ {#Symbol name}] args}}] + (do meta#monad + [name' (normal name) + ?macro (named_macro name')] + ({{#Some macro} + (do meta#monad + [top_level_expansion (("lux type as" Macro' macro) args) + recursive_expansion (monad#each meta#monad expansion top_level_expansion)] + (in (list#conjoint recursive_expansion))) + + {#None} + (in (list token))} + ?macro)) - {#Item [x {#End}]} - xs + _ + (meta#in (list token))} + token)) - {#Item [x xs']} - (partial_list x sep (list#interposed sep xs'))} - xs)) +(def''' .private (full_expansion' full_expansion name args) + (-> (-> Code ($' Meta ($' List Code))) Symbol ($' List Code) ($' Meta ($' List Code))) + (do meta#monad + [name' (normal name) + ?macro (named_macro name')] + ({{#Some macro} + (do meta#monad + [expansion (("lux type as" Macro' macro) args) + expansion' (monad#each meta#monad full_expansion expansion)] + (in (list#conjoint expansion'))) + + {#None} + (do meta#monad + [args' (monad#each meta#monad full_expansion args)] + (in (list (form$ {#Item (symbol$ name) (list#conjoint args')}))))} + ?macro))) + +(def''' .private (in_module module meta) + (All (_ a) + (-> Text ($' Meta a) ($' Meta a))) + (function' [lux] + ({[..#info info ..#source source + ..#current_module current_module ..#modules modules + ..#scopes scopes ..#type_context type_context + ..#host host ..#seed seed + ..#expected expected ..#location location + ..#extensions extensions ..#scope_type_vars scope_type_vars + ..#eval eval] + ({{#Left error} + {#Left error} + + {#Right [[..#info info' ..#source source' + ..#current_module _ ..#modules modules' + ..#scopes scopes' ..#type_context type_context' + ..#host host' ..#seed seed' + ..#expected expected' ..#location location' + ..#extensions extensions' ..#scope_type_vars scope_type_vars' + ..#eval eval'] + output]} + {#Right [[..#info info' ..#source source' + ..#current_module current_module ..#modules modules' + ..#scopes scopes' ..#type_context type_context' + ..#host host' ..#seed seed' + ..#expected expected' ..#location location' + ..#extensions extensions' ..#scope_type_vars scope_type_vars' + ..#eval eval'] + output]}} + (meta [..#info info ..#source source + ..#current_module {.#Some module} ..#modules modules + ..#scopes scopes ..#type_context type_context + ..#host host ..#seed seed + ..#expected expected ..#location location + ..#extensions extensions ..#scope_type_vars scope_type_vars + ..#eval eval]))} + lux))) + +(def''' .private (full_expansion expand_in_module?) + (-> Bit Code ($' Meta ($' List Code))) + (function' again [syntax] + ({[_ {#Form {#Item head tail}}] + ({[_ {#Form {#Item [_ {#Text "lux in-module"}] + {#Item [_ {#Text module}] + {#Item [_ {#Symbol name}] + {#End}}}}}] + (if expand_in_module? + (..in_module module (..full_expansion' again name tail)) + (do meta#monad + [members' (monad#each meta#monad again {#Item head tail})] + (in (list (form$ (list#conjoint members')))))) + + [_ {#Symbol name}] + (..full_expansion' again name tail) + + _ + (do meta#monad + [members' (monad#each meta#monad again {#Item head tail})] + (in (list (form$ (list#conjoint members')))))} + head) + + [_ {#Variant members}] + (do meta#monad + [members' (monad#each meta#monad again members)] + (in (list (variant$ (list#conjoint members'))))) + + [_ {#Tuple members}] + (do meta#monad + [members' (monad#each meta#monad again members)] + (in (list (tuple$ (list#conjoint members'))))) + + _ + (meta#in (list syntax))} + syntax))) + +(def''' .private (text#encoded original) + (-> Text Text) + (all text#composite ..double_quote original ..double_quote)) + +(def''' .private (code#encoded code) + (-> Code Text) + ({[_ {#Bit value}] + (bit#encoded value) + + [_ {#Nat value}] + (nat#encoded value) + + [_ {#Int value}] + (int#encoded value) + + [_ {#Rev value}] + ("lux io error" "@code#encoded Undefined behavior.") + + [_ {#Frac value}] + (frac#encoded value) -(def:''' .private (single_expansion token) - (-> Code ($' Meta ($' List Code))) - ({[_ {#Form {#Item [_ {#Symbol name}] args}}] - (do meta#monad - [name' (normal name) - ?macro (named_macro name')] - ({{#Some macro} - (("lux type as" Macro' macro) args) - - {#None} - (in (list token))} - ?macro)) + [_ {#Text value}] + (text#encoded value) + + [_ {#Symbol [module name]}] + (symbol#encoded [module name]) + + [_ {#Form xs}] + (all text#composite "(" (|> xs + (list#each code#encoded) + (list#interposed " ") + list#reversed + (list#mix text#composite "")) ")") + + [_ {#Tuple xs}] + (all text#composite "[" (|> xs + (list#each code#encoded) + (list#interposed " ") + list#reversed + (list#mix text#composite "")) "]") + + [_ {#Variant xs}] + (all text#composite "{" (|> xs + (list#each code#encoded) + (list#interposed " ") + list#reversed + (list#mix text#composite "")) "}")} + code)) + +(def''' .private (normal_type type) + (-> Code Code) + ({[_ {#Variant {#Item [_ {#Symbol symbol}] parts}}] + (` {(~ (symbol$ symbol)) (~+ (list#each normal_type parts))}) + + [_ {#Tuple members}] + (` (Tuple (~+ (list#each normal_type members)))) + + [_ {#Form {#Item [_ {#Text "lux in-module"}] + {#Item [_ {#Text module}] + {#Item type' + {#End}}}}}] + (` ("lux in-module" (~ (text$ module)) (~ (normal_type type')))) + + [_ {#Form {#Item [_ {#Symbol ["" "~"]}] {#Item expression {#End}}}}] + expression + + [_0 {#Form {#Item [_1 {#Variant {#Item binding {#Item body {#End}}}}] + {#Item value + {#End}}}}] + [_0 {#Form {#Item [_1 {#Variant {#Item binding {#Item (normal_type body) {#End}}}}] + {#Item value + {#End}}}}] + + [_0 {#Form {#Item [_1 {#Symbol ["library/lux" "__adjusted_quantified_type__"]}] + {#Item _permission + {#Item _level + {#Item body + {#End}}}}}}] + [_0 {#Form {#Item [_1 {#Symbol [..prelude "__adjusted_quantified_type__"]}] + {#Item _permission + {#Item _level + {#Item (normal_type body) + {#End}}}}}}] + + [_ {#Form {#Item type_fn args}}] + (list#mix ("lux type check" (-> Code Code Code) + (function' [arg type_fn] (` {.#Apply (~ arg) (~ type_fn)}))) + (normal_type type_fn) + (list#each normal_type args)) - _ - (meta#in (list token))} - token)) + _ + type} + type)) -(def:''' .private (expansion token) - (-> Code ($' Meta ($' List Code))) - ({[_ {#Form {#Item [_ {#Symbol name}] args}}] +(def'' .public type + Macro + (macro (_ tokens) + ({{#Item type {#End}} (do meta#monad - [name' (normal name) - ?macro (named_macro name')] - ({{#Some macro} + [initialized_quantification? (function' [lux] {#Right [lux (initialized_quantification? lux)]})] + (if initialized_quantification? (do meta#monad - [top_level_expansion (("lux type as" Macro' macro) args) - recursive_expansion (monad#each meta#monad expansion top_level_expansion)] - (in (list#conjoint recursive_expansion))) - - {#None} - (in (list token))} - ?macro)) - - _ - (meta#in (list token))} - token)) - -(def:''' .private (full_expansion' full_expansion name args) - (-> (-> Code ($' Meta ($' List Code))) Symbol ($' List Code) ($' Meta ($' List Code))) - (do meta#monad - [name' (normal name) - ?macro (named_macro name')] - ({{#Some macro} - (do meta#monad - [expansion (("lux type as" Macro' macro) args) - expansion' (monad#each meta#monad full_expansion expansion)] - (in (list#conjoint expansion'))) - - {#None} - (do meta#monad - [args' (monad#each meta#monad full_expansion args)] - (in (list (form$ {#Item (symbol$ name) (list#conjoint args')}))))} - ?macro))) - -(def:''' .private (in_module module meta) - (All (_ a) - (-> Text ($' Meta a) ($' Meta a))) - (function' [lux] - ({[..#info info ..#source source - ..#current_module current_module ..#modules modules - ..#scopes scopes ..#type_context type_context - ..#host host ..#seed seed - ..#expected expected ..#location location - ..#extensions extensions ..#scope_type_vars scope_type_vars - ..#eval eval] - ({{#Left error} - {#Left error} - - {#Right [[..#info info' ..#source source' - ..#current_module _ ..#modules modules' - ..#scopes scopes' ..#type_context type_context' - ..#host host' ..#seed seed' - ..#expected expected' ..#location location' - ..#extensions extensions' ..#scope_type_vars scope_type_vars' - ..#eval eval'] - output]} - {#Right [[..#info info' ..#source source' - ..#current_module current_module ..#modules modules' - ..#scopes scopes' ..#type_context type_context' - ..#host host' ..#seed seed' - ..#expected expected' ..#location location' - ..#extensions extensions' ..#scope_type_vars scope_type_vars' - ..#eval eval'] - output]}} - (meta [..#info info ..#source source - ..#current_module {.#Some module} ..#modules modules - ..#scopes scopes ..#type_context type_context - ..#host host ..#seed seed - ..#expected expected ..#location location - ..#extensions extensions ..#scope_type_vars scope_type_vars - ..#eval eval]))} - lux))) - -(def:''' .private (full_expansion expand_in_module?) - (-> Bit Code ($' Meta ($' List Code))) - (function' again [syntax] - ({[_ {#Form {#Item head tail}}] - ({[_ {#Form {#Item [_ {#Text "lux in-module"}] - {#Item [_ {#Text module}] - {#Item [_ {#Symbol name}] - {#End}}}}}] - (if expand_in_module? - (..in_module module (..full_expansion' again name tail)) - (do meta#monad - [members' (monad#each meta#monad again {#Item head tail})] - (in (list (form$ (list#conjoint members')))))) + [type+ (full_expansion #0 type)] + ({{#Item type' {#End}} + (in (list (normal_type type'))) - [_ {#Symbol name}] - (..full_expansion' again name tail) - - _ - (do meta#monad - [members' (monad#each meta#monad again {#Item head tail})] - (in (list (form$ (list#conjoint members')))))} - head) - - [_ {#Variant members}] - (do meta#monad - [members' (monad#each meta#monad again members)] - (in (list (variant$ (list#conjoint members'))))) - - [_ {#Tuple members}] - (do meta#monad - [members' (monad#each meta#monad again members)] - (in (list (tuple$ (list#conjoint members'))))) - - _ - (meta#in (list syntax))} - syntax))) - -(def:''' .private (text#encoded original) - (-> Text Text) - (all text#composite ..double_quote original ..double_quote)) - -(def:''' .private (code#encoded code) - (-> Code Text) - ({[_ {#Bit value}] - (bit#encoded value) - - [_ {#Nat value}] - (nat#encoded value) - - [_ {#Int value}] - (int#encoded value) - - [_ {#Rev value}] - ("lux io error" "@code#encoded Undefined behavior.") - - [_ {#Frac value}] - (frac#encoded value) - - [_ {#Text value}] - (text#encoded value) - - [_ {#Symbol [module name]}] - (symbol#encoded [module name]) - - [_ {#Form xs}] - (all text#composite "(" (|> xs - (list#each code#encoded) - (list#interposed " ") - list#reversed - (list#mix text#composite "")) ")") - - [_ {#Tuple xs}] - (all text#composite "[" (|> xs - (list#each code#encoded) - (list#interposed " ") - list#reversed - (list#mix text#composite "")) "]") - - [_ {#Variant xs}] - (all text#composite "{" (|> xs - (list#each code#encoded) - (list#interposed " ") - list#reversed - (list#mix text#composite "")) "}")} - code)) - -(def:''' .private (normal_type type) - (-> Code Code) - ({[_ {#Variant {#Item [_ {#Symbol symbol}] parts}}] - (` {(~ (symbol$ symbol)) (~+ (list#each normal_type parts))}) - - [_ {#Tuple members}] - (` (Tuple (~+ (list#each normal_type members)))) - - [_ {#Form {#Item [_ {#Text "lux in-module"}] - {#Item [_ {#Text module}] - {#Item type' - {#End}}}}}] - (` ("lux in-module" (~ (text$ module)) (~ (normal_type type')))) - - [_ {#Form {#Item [_ {#Symbol ["" "~"]}] {#Item expression {#End}}}}] - expression - - [_0 {#Form {#Item [_1 {#Variant {#Item binding {#Item body {#End}}}}] - {#Item value - {#End}}}}] - [_0 {#Form {#Item [_1 {#Variant {#Item binding {#Item (normal_type body) {#End}}}}] - {#Item value - {#End}}}}] - - [_0 {#Form {#Item [_1 {#Symbol ["library/lux" "__adjusted_quantified_type__"]}] - {#Item _permission - {#Item _level - {#Item body - {#End}}}}}}] - [_0 {#Form {#Item [_1 {#Symbol [..prelude "__adjusted_quantified_type__"]}] - {#Item _permission - {#Item _level - {#Item (normal_type body) - {#End}}}}}}] - - [_ {#Form {#Item type_fn args}}] - (list#mix ("lux type check" (-> Code Code Code) - (function' [arg type_fn] (` {.#Apply (~ arg) (~ type_fn)}))) - (normal_type type_fn) - (list#each normal_type args)) + _ + (failure "The expansion of the type-syntax had to yield a single element.")} + type+)) + (in (list (..quantified (` (..type (~ type)))))))) _ - type} - type)) - -(def:'' .public type - Macro - (macro (_ tokens) - ({{#Item type {#End}} - (do meta#monad - [initialized_quantification? (function' [lux] {#Right [lux (initialized_quantification? lux)]})] - (if initialized_quantification? - (do meta#monad - [type+ (full_expansion #0 type)] - ({{#Item type' {#End}} - (in (list (normal_type type'))) - - _ - (failure "The expansion of the type-syntax had to yield a single element.")} - type+)) - (in (list (..quantified (` (..type (~ type)))))))) - - _ - (failure "Wrong syntax for type")} - tokens))) - -(def:'' .public is - Macro - (macro (_ tokens) - ({{#Item type {#Item value {#End}}} - (meta#in (list (` ("lux type check" - (..type (~ type)) - (~ value))))) + (failure "Wrong syntax for type")} + tokens))) - _ - (failure "Wrong syntax for :")} - tokens))) +(def'' .public is + Macro + (macro (_ tokens) + ({{#Item type {#Item value {#End}}} + (meta#in (list (` ("lux type check" + (..type (~ type)) + (~ value))))) -(def:'' .public as - Macro - (macro (_ tokens) - ({{#Item type {#Item value {#End}}} - (meta#in (list (` ("lux type as" - (..type (~ type)) - (~ value))))) + _ + (failure "Wrong syntax for :")} + tokens))) - _ - (failure "Wrong syntax for as")} - tokens))) +(def'' .public as + Macro + (macro (_ tokens) + ({{#Item type {#Item value {#End}}} + (meta#in (list (` ("lux type as" + (..type (~ type)) + (~ value))))) -(def:''' .private (empty? xs) - (All (_ a) - (-> ($' List a) Bit)) - ({{#End} #1 - _ #0} - xs)) + _ + (failure "Wrong syntax for as")} + tokens))) + +(def''' .private (empty? xs) + (All (_ a) + (-> ($' List a) Bit)) + ({{#End} #1 + _ #0} + xs)) (with_template [<name> <type> <value>] - [(def:''' .private (<name> xy) - (All (_ a b) - (-> (Tuple a b) <type>)) - (let' [[x y] xy] - <value>))] + [(def''' .private (<name> xy) + (All (_ a b) + (-> (Tuple a b) <type>)) + (let' [[x y] xy] + <value>))] [product#left a x] [product#right b y]) -(def:''' .private (generated_symbol prefix state) - (-> Text ($' Meta Code)) - ({[..#info info ..#source source ..#current_module _ ..#modules modules - ..#scopes scopes ..#type_context types ..#host host - ..#seed seed ..#expected expected - ..#location location ..#extensions extensions - ..#scope_type_vars scope_type_vars ..#eval _eval] - {#Right [..#info info ..#source source ..#current_module _ ..#modules modules - ..#scopes scopes ..#type_context types ..#host host - ..#seed ("lux i64 +" 1 seed) ..#expected expected - ..#location location ..#extensions extensions - ..#scope_type_vars scope_type_vars ..#eval _eval] - (local$ (all text#composite "__gensym__" prefix (nat#encoded seed)))}} - state)) - -(def:'' .public exec - Macro - (macro (_ tokens) - ({{#Item value actions} - (let' [dummy (local$ "")] - (meta#in (list (list#mix ("lux type check" (-> Code Code Code) - (function' [pre post] (` ({(~ dummy) (~ post)} - (~ pre))))) - value - actions)))) - - _ - (failure "Wrong syntax for exec")} - (list#reversed tokens)))) - -(def:'' .private def:' - Macro - (macro (_ tokens) - (let' [parts (is (Maybe [Code Code (List Code) (Maybe Code) Code]) - ({{#Item export_policy {#Item [_ {#Form {#Item name args}}] {#Item type {#Item body {#End}}}}} - {#Some [export_policy name args {#Some type} body]} - - {#Item export_policy {#Item name {#Item type {#Item body {#End}}}}} - {#Some [export_policy name {#End} {#Some type} body]} - - {#Item export_policy {#Item [_ {#Form {#Item name args}}] {#Item body {#End}}}} - {#Some [export_policy name args {#None} body]} - - {#Item export_policy {#Item name {#Item body {#End}}}} - {#Some [export_policy name {#End} {#None} body]} +(def''' .private (generated_symbol prefix state) + (-> Text ($' Meta Code)) + ({[..#info info ..#source source ..#current_module _ ..#modules modules + ..#scopes scopes ..#type_context types ..#host host + ..#seed seed ..#expected expected + ..#location location ..#extensions extensions + ..#scope_type_vars scope_type_vars ..#eval _eval] + {#Right [..#info info ..#source source ..#current_module _ ..#modules modules + ..#scopes scopes ..#type_context types ..#host host + ..#seed ("lux i64 +" 1 seed) ..#expected expected + ..#location location ..#extensions extensions + ..#scope_type_vars scope_type_vars ..#eval _eval] + (local$ (all text#composite "__gensym__" prefix (nat#encoded seed)))}} + state)) - _ - {#None}} - tokens))] - ({{#Some [export_policy name args ?type body]} - (let' [body' ({{#End} - body +(def'' .public exec + Macro + (macro (_ tokens) + ({{#Item value actions} + (let' [dummy (local$ "")] + (meta#in (list (list#mix ("lux type check" (-> Code Code Code) + (function' [pre post] (` ({(~ dummy) (~ post)} + (~ pre))))) + value + actions)))) - _ - (` (function' (~ name) [(~+ args)] (~ body)))} - args) - body'' ({{#Some type} - (` (is (~ type) (~ body'))) - - {#None} - body'} - ?type)] - (meta#in (list (` ("lux def" (~ name) - (~ body'') - (~ export_policy)))))) - - {#None} - (failure "Wrong syntax for def'")} - parts)))) - -(def:' .private (case_expansion branches) - (-> (List Code) (Meta (List Code))) - ({{#Item [_ {#Form {#Item [_ {#Symbol name}] args}}] - {#Item body - branches'}} - (do meta#monad - [??? (macro? name)] - (if ??? - (do meta#monad - [init_expansion (single_expansion (form$ (partial_list (symbol$ name) (form$ args) body branches')))] - (case_expansion init_expansion)) - (do meta#monad - [sub_expansion (case_expansion branches')] - (in (partial_list (form$ (partial_list (symbol$ name) args)) - body - sub_expansion))))) - - {#Item pattern {#Item body branches'}} - (do meta#monad - [sub_expansion (case_expansion branches')] - (in (partial_list pattern body sub_expansion))) - - {#End} - (do meta#monad [] (in (list))) + _ + (failure "Wrong syntax for exec")} + (list#reversed tokens)))) + +(def'' .private def' + Macro + (macro (_ tokens) + (let' [parts (is (Maybe [Code Code (List Code) (Maybe Code) Code]) + ({{#Item export_policy {#Item [_ {#Form {#Item name args}}] {#Item type {#Item body {#End}}}}} + {#Some [export_policy name args {#Some type} body]} + + {#Item export_policy {#Item name {#Item type {#Item body {#End}}}}} + {#Some [export_policy name {#End} {#Some type} body]} + + {#Item export_policy {#Item [_ {#Form {#Item name args}}] {#Item body {#End}}}} + {#Some [export_policy name args {#None} body]} + + {#Item export_policy {#Item name {#Item body {#End}}}} + {#Some [export_policy name {#End} {#None} body]} - _ - (failure (all text#composite "'lux.case' expects an even number of tokens: " (|> branches - (list#each code#encoded) - (list#interposed " ") - list#reversed - (list#mix text#composite ""))))} - branches)) - -(def:'' .public case - Macro - (macro (_ tokens) - ({{#Item value branches} + _ + {#None}} + tokens))] + ({{#Some [export_policy name args ?type body]} + (let' [body' ({{#End} + body + + _ + (` (function' (~ name) [(~+ args)] (~ body)))} + args) + body'' ({{#Some type} + (` (is (~ type) (~ body'))) + + {#None} + body'} + ?type)] + (meta#in (list (` ("lux def" (~ name) + (~ body'') + (~ export_policy)))))) + + {#None} + (failure "Wrong syntax for def'")} + parts)))) + +(def' .private (case_expansion branches) + (-> (List Code) (Meta (List Code))) + ({{#Item [_ {#Form {#Item [_ {#Symbol name}] args}}] + {#Item body + branches'}} + (do meta#monad + [??? (macro? name)] + (if ??? (do meta#monad - [expansion (case_expansion branches)] - (in (list (` ((~ (variant$ expansion)) (~ value)))))) - - _ - (failure "Wrong syntax for case")} - tokens))) - -(def:'' .public pattern - Macro - (macro (_ tokens) - (case tokens - {#Item [_ {#Form {#Item pattern {#End}}}] {#Item body branches}} + [init_expansion (single_expansion (form$ (partial_list (symbol$ name) (form$ args) body branches')))] + (case_expansion init_expansion)) (do meta#monad - [pattern+ (full_expansion #1 pattern)] - (case pattern+ - {#Item pattern' {#End}} - (in (partial_list pattern' body branches)) - - _ - (failure "`pattern` can only expand to 1 pattern."))) - - _ - (failure "Wrong syntax for `pattern` macro")))) + [sub_expansion (case_expansion branches')] + (in (partial_list (form$ (partial_list (symbol$ name) args)) + body + sub_expansion))))) -(def:'' .private pattern#or - Macro - (macro (_ tokens) - (case tokens - (pattern (partial_list [_ {#Form patterns}] body branches)) - (case patterns - {#End} - (failure "pattern#or cannot have 0 patterns") + {#Item pattern {#Item body branches'}} + (do meta#monad + [sub_expansion (case_expansion branches')] + (in (partial_list pattern body sub_expansion))) - _ - (let' [pairs (|> patterns - (list#each (function' [pattern] (list pattern body))) - (list#conjoint))] - (meta#in (list#composite pairs branches)))) - _ - (failure "Wrong syntax for pattern#or")))) + {#End} + (do meta#monad [] (in (list))) -(def:'' .public symbol - Macro - (macro (_ tokens) - (case tokens - (pattern (list [_ {#Symbol [module name]}])) - (meta#in (list (` [(~ (text$ module)) (~ (text$ name))]))) - - _ - (failure (..wrong_syntax_error [..prelude "symbol"]))))) + _ + (failure (all text#composite "'lux.case' expects an even number of tokens: " (|> branches + (list#each code#encoded) + (list#interposed " ") + list#reversed + (list#mix text#composite ""))))} + branches)) + +(def'' .public case + Macro + (macro (_ tokens) + ({{#Item value branches} + (do meta#monad + [expansion (case_expansion branches)] + (in (list (` ((~ (variant$ expansion)) (~ value)))))) -(def:' .private (symbol? code) - (-> Code Bit) - (case code - [_ {#Symbol _}] - #1 + _ + (failure "Wrong syntax for case")} + tokens))) + +(def'' .public pattern + Macro + (macro (_ tokens) + (case tokens + {#Item [_ {#Form {#Item pattern {#End}}}] {#Item body branches}} + (do meta#monad + [pattern+ (full_expansion #1 pattern)] + (case pattern+ + {#Item pattern' {#End}} + (in (partial_list pattern' body branches)) + + _ + (failure "`pattern` can only expand to 1 pattern."))) + + _ + (failure "Wrong syntax for `pattern` macro")))) - _ - #0)) +(def'' .private pattern#or + Macro + (macro (_ tokens) + (case tokens + (pattern (partial_list [_ {#Form patterns}] body branches)) + (case patterns + {#End} + (failure "pattern#or cannot have 0 patterns") -(def:'' .public let - Macro - (macro (_ tokens) - (case tokens - (pattern (list [_ {#Tuple bindings}] body)) - (case (..pairs bindings) - {#Some bindings} - (|> bindings - list#reversed - (list#mix (is (-> [Code Code] Code Code) - (function' [lr body'] - (let' [[l r] lr] - (if (symbol? l) - (` ({(~ l) (~ body')} (~ r))) - (` (case (~ r) (~ l) (~ body'))))))) - body) - list - meta#in) + _ + (let' [pairs (|> patterns + (list#each (function' [pattern] (list pattern body))) + (list#conjoint))] + (meta#in (list#composite pairs branches)))) + _ + (failure "Wrong syntax for pattern#or")))) + +(def'' .public symbol + Macro + (macro (_ tokens) + (case tokens + (pattern (list [_ {#Symbol [module name]}])) + (meta#in (list (` [(~ (text$ module)) (~ (text$ name))]))) + + _ + (failure (..wrong_syntax_error [..prelude "symbol"]))))) - {#None} - (failure "let requires an even number of parts")) +(def' .private (symbol? code) + (-> Code Bit) + (case code + [_ {#Symbol _}] + #1 - _ - (failure (..wrong_syntax_error (symbol ..let)))))) + _ + #0)) + +(def'' .public let + Macro + (macro (_ tokens) + (case tokens + (pattern (list [_ {#Tuple bindings}] body)) + (case (..pairs bindings) + {#Some bindings} + (|> bindings + list#reversed + (list#mix (is (-> [Code Code] Code Code) + (function' [lr body'] + (let' [[l r] lr] + (if (symbol? l) + (` ({(~ l) (~ body')} (~ r))) + (` (case (~ r) (~ l) (~ body'))))))) + body) + list + meta#in) -(def:'' .public function - Macro - (macro (_ tokens) - (case (is (Maybe [Text Code (List Code) Code]) - (case tokens - (pattern (list [_ {#Form (partial_list [_ {#Symbol ["" name]}] head tail)}] body)) - {#Some name head tail body} - - _ - {#None})) - {#Some g!name head tail body} - (let [g!blank (local$ "") - nest (is (-> Code (-> Code Code Code)) - (function' [g!name] - (function' [arg body'] - (if (symbol? arg) - (` ([(~ g!name) (~ arg)] (~ body'))) - (` ([(~ g!name) (~ g!blank)] - (.case (~ g!blank) (~ arg) (~ body'))))))))] - (meta#in (list (nest (..local$ g!name) head - (list#mix (nest g!blank) body (list#reversed tail)))))) + {#None} + (failure "let requires an even number of parts")) - {#None} - (failure (..wrong_syntax_error (symbol ..function)))))) + _ + (failure (..wrong_syntax_error (symbol ..let)))))) + +(def'' .public function + Macro + (macro (_ tokens) + (case (is (Maybe [Text Code (List Code) Code]) + (case tokens + (pattern (list [_ {#Form (partial_list [_ {#Symbol ["" name]}] head tail)}] body)) + {#Some name head tail body} + + _ + {#None})) + {#Some g!name head tail body} + (let [g!blank (local$ "") + nest (is (-> Code (-> Code Code Code)) + (function' [g!name] + (function' [arg body'] + (if (symbol? arg) + (` ([(~ g!name) (~ arg)] (~ body'))) + (` ([(~ g!name) (~ g!blank)] + (.case (~ g!blank) (~ arg) (~ body'))))))))] + (meta#in (list (nest (..local$ g!name) head + (list#mix (nest g!blank) body (list#reversed tail)))))) -(def:' .private Parser - Type - {#Named [..prelude "Parser"] - (..type (All (_ a) - (-> (List Code) (Maybe [(List Code) a]))))}) + {#None} + (failure (..wrong_syntax_error (symbol ..function)))))) -(def:' .private (parsed parser tokens) - (All (_ a) (-> (Parser a) (List Code) (Maybe a))) - (case (parser tokens) - (pattern {#Some [(list) it]}) - {#Some it} +(def' .private Parser + Type + {#Named [..prelude "Parser"] + (..type (All (_ a) + (-> (List Code) (Maybe [(List Code) a]))))}) - _ - {#None})) - -(def:' .private (inP it tokens) - (All (_ a) - (-> a (Parser a))) - {#Some [tokens it]}) - -(def:' .private (orP leftP rightP tokens) - (All (_ l r) - (-> (Parser l) - (Parser r) - (Parser (Or l r)))) - (case (leftP tokens) - {#Some [tokens left]} - {#Some [tokens {#Left left}]} +(def' .private (parsed parser tokens) + (All (_ a) (-> (Parser a) (List Code) (Maybe a))) + (case (parser tokens) + (pattern {#Some [(list) it]}) + {#Some it} - _ - (case (rightP tokens) - {#Some [tokens right]} - {#Some [tokens {#Right right}]} + _ + {#None})) + +(def' .private (inP it tokens) + (All (_ a) + (-> a (Parser a))) + {#Some [tokens it]}) + +(def' .private (orP leftP rightP tokens) + (All (_ l r) + (-> (Parser l) + (Parser r) + (Parser (Or l r)))) + (case (leftP tokens) + {#Some [tokens left]} + {#Some [tokens {#Left left}]} - _ - {#None}))) - -(def:' .private (eitherP leftP rightP tokens) - (All (_ a) - (-> (Parser a) - (Parser a) - (Parser a))) - (case (leftP tokens) - {#None} - (rightP tokens) - - it - it)) - -(def:' .private (andP leftP rightP tokens) - (All (_ l r) - (-> (Parser l) - (Parser r) - (Parser [l r]))) - (do maybe#monad - [left (leftP tokens) - .let [[tokens left] left] - right (rightP tokens) - .let [[tokens right] right]] - (in [tokens [left right]]))) - -(def:' .private (afterP leftP rightP tokens) - (All (_ l r) - (-> (Parser l) - (Parser r) - (Parser r))) - (do maybe#monad - [left (leftP tokens) - .let [[tokens left] left]] - (rightP tokens))) - -(def:' .private (someP itP tokens) - (All (_ a) - (-> (Parser a) - (Parser (List a)))) - (case (itP tokens) - {#Some [tokens head]} - (do maybe#monad - [it (someP itP tokens) - .let [[tokens tail] it]] - (in [tokens (partial_list head tail)])) + _ + (case (rightP tokens) + {#Some [tokens right]} + {#Some [tokens {#Right right}]} - {#None} - {#Some [tokens (list)]})) - -(def:' .private (manyP itP tokens) - (All (_ a) - (-> (Parser a) - (Parser (List a)))) - (do maybe#monad - [it (itP tokens) - .let [[tokens head] it] - it (someP itP tokens) - .let [[tokens tail] it]] - (in [tokens (partial_list head tail)]))) - -(def:' .private (maybeP itP tokens) - (All (_ a) - (-> (Parser a) - (Parser (Maybe a)))) - (case (itP tokens) - {#Some [tokens it]} - {#Some [tokens {#Some it}]} + _ + {#None}))) + +(def' .private (eitherP leftP rightP tokens) + (All (_ a) + (-> (Parser a) + (Parser a) + (Parser a))) + (case (leftP tokens) + {#None} + (rightP tokens) + + it + it)) + +(def' .private (andP leftP rightP tokens) + (All (_ l r) + (-> (Parser l) + (Parser r) + (Parser [l r]))) + (do maybe#monad + [left (leftP tokens) + .let [[tokens left] left] + right (rightP tokens) + .let [[tokens right] right]] + (in [tokens [left right]]))) + +(def' .private (afterP leftP rightP tokens) + (All (_ l r) + (-> (Parser l) + (Parser r) + (Parser r))) + (do maybe#monad + [left (leftP tokens) + .let [[tokens left] left]] + (rightP tokens))) + +(def' .private (someP itP tokens) + (All (_ a) + (-> (Parser a) + (Parser (List a)))) + (case (itP tokens) + {#Some [tokens head]} + (do maybe#monad + [it (someP itP tokens) + .let [[tokens tail] it]] + (in [tokens (partial_list head tail)])) - {#None} - {#Some [tokens {#None}]})) + {#None} + {#Some [tokens (list)]})) + +(def' .private (manyP itP tokens) + (All (_ a) + (-> (Parser a) + (Parser (List a)))) + (do maybe#monad + [it (itP tokens) + .let [[tokens head] it] + it (someP itP tokens) + .let [[tokens tail] it]] + (in [tokens (partial_list head tail)]))) + +(def' .private (maybeP itP tokens) + (All (_ a) + (-> (Parser a) + (Parser (Maybe a)))) + (case (itP tokens) + {#Some [tokens it]} + {#Some [tokens {#Some it}]} -(def:' .private (tupleP itP tokens) - (All (_ a) - (-> (Parser a) (Parser a))) - (case tokens - (pattern (partial_list [_ {#Tuple input}] tokens')) - (do maybe#monad - [it (parsed itP input)] - (in [tokens' it])) + {#None} + {#Some [tokens {#None}]})) - _ - {#None})) +(def' .private (tupleP itP tokens) + (All (_ a) + (-> (Parser a) (Parser a))) + (case tokens + (pattern (partial_list [_ {#Tuple input}] tokens')) + (do maybe#monad + [it (parsed itP input)] + (in [tokens' it])) -(def:' .private (formP itP tokens) - (All (_ a) - (-> (Parser a) (Parser a))) - (case tokens - (pattern (partial_list [_ {#Form input}] tokens')) - (do maybe#monad - [it (parsed itP input)] - (in [tokens' it])) + _ + {#None})) - _ - {#None})) +(def' .private (formP itP tokens) + (All (_ a) + (-> (Parser a) (Parser a))) + (case tokens + (pattern (partial_list [_ {#Form input}] tokens')) + (do maybe#monad + [it (parsed itP input)] + (in [tokens' it])) -(def:' .private (bindingP tokens) - (Parser [Text Code]) - (case tokens - (pattern (partial_list [_ {#Symbol ["" name]}] value &rest)) - {#Some [&rest [name value]]} + _ + {#None})) - _ - {#None})) +(def' .private (bindingP tokens) + (Parser [Text Code]) + (case tokens + (pattern (partial_list [_ {#Symbol ["" name]}] value &rest)) + {#Some [&rest [name value]]} -(def:' .private (endP tokens) - (Parser Any) - (case tokens - (pattern (list)) - {#Some [tokens []]} + _ + {#None})) - _ - {#None})) +(def' .private (endP tokens) + (Parser Any) + (case tokens + (pattern (list)) + {#Some [tokens []]} -(def:' .private (anyP tokens) - (Parser Code) - (case tokens - (pattern (partial_list code tokens')) - {#Some [tokens' code]} + _ + {#None})) - _ - {#None})) +(def' .private (anyP tokens) + (Parser Code) + (case tokens + (pattern (partial_list code tokens')) + {#Some [tokens' code]} -(def:' .private (localP tokens) - (-> (List Code) (Maybe [(List Code) Text])) - (case tokens - (pattern (partial_list [_ {#Symbol ["" local]}] tokens')) - {#Some [tokens' local]} + _ + {#None})) - _ - {#None})) +(def' .private (localP tokens) + (-> (List Code) (Maybe [(List Code) Text])) + (case tokens + (pattern (partial_list [_ {#Symbol ["" local]}] tokens')) + {#Some [tokens' local]} + + _ + {#None})) -(def:' .private (symbolP tokens) - (-> (List Code) (Maybe [(List Code) Symbol])) - (case tokens - (pattern (partial_list [_ {#Symbol it}] tokens')) - {#Some [tokens' it]} +(def' .private (symbolP tokens) + (-> (List Code) (Maybe [(List Code) Symbol])) + (case tokens + (pattern (partial_list [_ {#Symbol it}] tokens')) + {#Some [tokens' it]} - _ - {#None})) + _ + {#None})) (with_template [<parser> <item_type> <item_parser>] - [(def:' .private (<parser> tokens) - (-> (List Code) (Maybe (List <item_type>))) - (case tokens - {#End} - {#Some {#End}} + [(def' .private (<parser> tokens) + (-> (List Code) (Maybe (List <item_type>))) + (case tokens + {#End} + {#Some {#End}} - _ - (do maybe#monad - [% (<item_parser> tokens) - .let' [[tokens head] %] - tail (<parser> tokens)] - (in {#Item head tail}))))] + _ + (do maybe#monad + [% (<item_parser> tokens) + .let' [[tokens head] %] + tail (<parser> tokens)] + (in {#Item head tail}))))] [parametersP Text localP] [enhanced_parametersP Code anyP] ) (with_template [<parser> <parameter_type> <parameters_parser>] - [(def:' .private (<parser> tokens) - (Parser [Text (List <parameter_type>)]) - (case tokens - (pattern (partial_list [_ {#Form local_declaration}] tokens')) - (do maybe#monad - [% (localP local_declaration) - .let' [[local_declaration name] %] - parameters (<parameters_parser> local_declaration)] - (in [tokens' [name parameters]])) - - _ - (do maybe#monad - [% (localP tokens) - .let' [[tokens' name] %]] - (in [tokens' [name {#End}]]))))] + [(def' .private (<parser> tokens) + (Parser [Text (List <parameter_type>)]) + (case tokens + (pattern (partial_list [_ {#Form local_declaration}] tokens')) + (do maybe#monad + [% (localP local_declaration) + .let' [[local_declaration name] %] + parameters (<parameters_parser> local_declaration)] + (in [tokens' [name parameters]])) + + _ + (do maybe#monad + [% (localP tokens) + .let' [[tokens' name] %]] + (in [tokens' [name {#End}]]))))] [local_declarationP Text parametersP] [enhanced_local_declarationP Code enhanced_parametersP] ) -(def:' .private (export_policyP tokens) - (-> (List Code) [(List Code) Code]) - (case tokens - (pattern (partial_list candidate tokens')) - (case candidate - [_ {#Bit it}] - [tokens' candidate] - - [_ {#Symbol ["" _]}] - [tokens (` .private)] - - [_ {#Symbol it}] - [tokens' candidate] +(def' .private (export_policyP tokens) + (-> (List Code) [(List Code) Code]) + (case tokens + (pattern (partial_list candidate tokens')) + (case candidate + [_ {#Bit it}] + [tokens' candidate] + + [_ {#Symbol ["" _]}] + [tokens (` .private)] + + [_ {#Symbol it}] + [tokens' candidate] - _ - [tokens (` .private)]) + _ + [tokens (` .private)]) - _ - [tokens (` .private)])) + _ + [tokens (` .private)])) (with_template [<parser> <parameter_type> <local>] - [(def:' .private (<parser> tokens) - (-> (List Code) (Maybe [(List Code) [Code Text (List <parameter_type>)]])) - (do maybe#monad - [.let' [[tokens export_policy] (export_policyP tokens)] - % (<local> tokens) - .let' [[tokens [name parameters]] %]] - (in [tokens [export_policy name parameters]])))] + [(def' .private (<parser> tokens) + (-> (List Code) (Maybe [(List Code) [Code Text (List <parameter_type>)]])) + (do maybe#monad + [.let' [[tokens export_policy] (export_policyP tokens)] + % (<local> tokens) + .let' [[tokens [name parameters]] %]] + (in [tokens [export_policy name parameters]])))] [declarationP Text local_declarationP] [enhanced_declarationP Code enhanced_local_declarationP] ) -(def:' .private (bodyP tokens) - (-> (List Code) (Maybe [(List Code) [(Maybe Code) Code]])) - (case tokens - ... TB - (pattern (partial_list type body tokens')) - {#Some [tokens' [{#Some type} body]]} +(def' .private (bodyP tokens) + (-> (List Code) (Maybe [(List Code) [(Maybe Code) Code]])) + (case tokens + ... TB + (pattern (partial_list type body tokens')) + {#Some [tokens' [{#Some type} body]]} - ... B - (pattern (partial_list body tokens')) - {#Some [tokens' [{#None} body]]} + ... B + (pattern (partial_list body tokens')) + {#Some [tokens' [{#None} body]]} - _ - {#None})) - -(def:' .private (definitionP tokens) - (-> (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]))) - -(def:'' .public def: - Macro - (macro (_ tokens) - (case (definitionP tokens) - {#Some [export_policy name parameters ?type body]} - (let [body (case parameters - {#End} - body + _ + {#None})) + +(def' .private (definitionP tokens) + (-> (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]))) + +(def'' .public def + Macro + (macro (_ tokens) + (case (definitionP tokens) + {#Some [export_policy name parameters ?type body]} + (let [body (case parameters + {#End} + body - _ - (` (function ((~ (..local$ name)) (~+ parameters)) - (~ body)))) - body (case ?type - {#Some type} - (` (is (~ type) - (~ body))) - - {#None} - body)] - (meta#in (list (` ("lux def" (~ (..local$ name)) - (~ body) - (~ export_policy)))))) - - {#None} - (failure (..wrong_syntax_error (symbol ..def:)))))) + _ + (` (function ((~ (..local$ name)) (~+ parameters)) + (~ body)))) + body (case ?type + {#Some type} + (` (is (~ type) + (~ body))) + + {#None} + body)] + (meta#in (list (` ("lux def" (~ (..local$ name)) + (~ body) + (~ export_policy)))))) + + {#None} + (failure (..wrong_syntax_error (symbol ..def)))))) -(def: (list#one f xs) +(def (list#one f xs) (All (_ a b) (-> (-> a (Maybe b)) (List a) (Maybe b))) (case xs @@ -2957,7 +2957,7 @@ {#Some y}))) (with_template [<name> <form> <message>] - [(def: .public <name> + [(def .public <name> (macro (_ tokens) (case (list#reversed tokens) (pattern (partial_list last init)) @@ -2972,15 +2972,15 @@ [and (if (~ pre) (~ post) #0) "'and' requires >=1 clauses."] [or (if (~ pre) #1 (~ post)) "'or' requires >=1 clauses."]) -(def: (index part text) +(def (index part text) (-> Text Text (Maybe Nat)) ("lux text index" 0 part text)) -(def: .public (panic! message) +(def .public (panic! message) (-> Text Nothing) ("lux io error" message)) -(def: maybe#else +(def maybe#else (macro (_ tokens state) (case tokens (pattern (list else maybe)) @@ -2996,7 +2996,7 @@ _ {#Left (..wrong_syntax_error (symbol ..maybe#else))}))) -(def: (text#all_split_by splitter input) +(def (text#all_split_by splitter input) (-> Text Text (List Text)) (case (..index splitter input) {#None} @@ -3011,7 +3011,7 @@ ("lux text size" input))] ("lux text clip" after_offset after_length input)))))) -(def: (item idx xs) +(def (item idx xs) (All (_ a) (-> Nat (List a) (Maybe a))) (case xs @@ -3024,7 +3024,7 @@ (item ("lux i64 -" 1 idx) xs')))) ... https://en.wikipedia.org/wiki/Lambda_calculus#%CE%B2-reduction -(def: (reduced env type) +(def (reduced env type) (-> (List Type) Type Type) (case type {#Sum left right} @@ -3070,7 +3070,7 @@ type )) -(def: (applied_type param type_fn) +(def (applied_type param type_fn) (-> Type Type (Maybe Type)) (case type_fn {#UnivQ env body} @@ -3091,7 +3091,7 @@ {#None})) (with_template [<name> <tag>] - [(def: (<name> type) + [(def (<name> type) (-> Type (List Type)) (case type {<tag> left right} @@ -3105,7 +3105,7 @@ [flat_lambda #Function] ) -(def: (flat_application type) +(def (flat_application type) (-> Type [Type (List Type)]) (case type {#Apply head func'} @@ -3115,7 +3115,7 @@ _ [type (list)])) -(def: (interface_methods type) +(def (interface_methods type) (-> Type (Maybe (List Type))) (case type {#Product _} @@ -3141,7 +3141,7 @@ _ {#Some (list type)})) -(def: (module name) +(def (module name) (-> Text (Meta Module)) (function (_ state) (let [[..#info info ..#source source ..#current_module _ ..#modules modules @@ -3155,7 +3155,7 @@ _ {#Left (all text#composite "Unknown module: " name)})))) -(def: (type_slot [module name]) +(def (type_slot [module name]) (-> Symbol (Meta [Nat (List Symbol) Bit Type])) (do meta#monad [=module (..module module) @@ -3176,7 +3176,7 @@ _ (failure (text#composite "Unknown slot: " (symbol#encoded [module name])))))) -(def: (record_slots type) +(def (record_slots type) (-> Type (Meta (Maybe [(List Symbol) (List Type)]))) (case type {#Apply arg func} @@ -3213,7 +3213,7 @@ _ (meta#in {#None}))) -(def: expected_type +(def expected_type (Meta Type) (function (_ state) (let [[..#info info ..#source source ..#current_module _ ..#modules modules @@ -3227,7 +3227,7 @@ {#None} {#Left "Not expecting any type."})))) -(def: (type#encoded type) +(def (type#encoded type) (-> Type Text) (case type {#Primitive name params} @@ -3273,7 +3273,7 @@ (symbol#encoded name) )) -(def: .public implementation +(def .public implementation (macro (_ tokens) (do meta#monad [tokens' (monad#each meta#monad expansion tokens) @@ -3310,7 +3310,7 @@ (list#conjoint tokens'))] (in (list (tuple$ (list#conjoint members))))))) -(def: (text#interposed separator parts) +(def (text#interposed separator parts) (-> Text (List Text) Text) (case parts {#End} @@ -3322,12 +3322,12 @@ head tail))) -(def: (function#identity value) +(def (function#identity value) (All (_ a) (-> a a)) value) -(def: (everyP itP tokens) +(def (everyP itP tokens) (All (_ a) (-> (-> (List Code) (Maybe [(List Code) a])) (-> (List Code) (Maybe (List a))))) @@ -3347,7 +3347,7 @@ {#End} {#Some (list)})) -(def: (caseP tokens) +(def (caseP tokens) (-> (List Code) (Maybe [(List Code) [Text Code]])) (case tokens (pattern (partial_list [_ {#Variant (list [_ {#Symbol ["" niladic]}])}] tokens')) @@ -3359,7 +3359,7 @@ _ {#None})) -(def: .public Variant +(def .public Variant (macro (_ tokens) (case (everyP caseP tokens) {#Some cases} @@ -3371,7 +3371,7 @@ {#None} (failure (..wrong_syntax_error (symbol ..Variant)))))) -(def: (slotP tokens) +(def (slotP tokens) (-> (List Code) (Maybe [(List Code) [Text Code]])) (case tokens (pattern (partial_list [_ {#Symbol ["" slot]}] type tokens')) @@ -3380,7 +3380,7 @@ _ {#None})) -(def: .public Record +(def .public Record (macro (_ tokens) (case tokens (pattern (list [_ {#Tuple record}])) @@ -3397,7 +3397,7 @@ _ (failure (..wrong_syntax_error (symbol ..Record)))))) -(def: (typeP tokens) +(def (typeP tokens) (-> (List Code) (Maybe [Code Text (List Text) Code])) (do maybe#monad [% (declarationP tokens) @@ -3407,7 +3407,7 @@ _ (endP tokens)] (in [export_policy name parameters definition]))) -(def: (textP tokens) +(def (textP tokens) (-> (List Code) (Maybe [(List Code) Text])) (case tokens (pattern (partial_list [_ {#Text it}] tokens')) @@ -3416,7 +3416,7 @@ _ {#None})) -(def: (type_declaration it) +(def (type_declaration it) (-> Code (Meta (Tuple Code (Maybe (Either (List Text) (List Text)))))) ({[_ {#Form {#Item [_ {#Symbol declarer}] parameters}}] (do meta#monad @@ -3448,7 +3448,7 @@ (meta#in [type {#None}])} it)) -(def: .public type: +(def .public type: (macro (_ tokens) (case (typeP tokens) {#Some [export_policy name args type_codes]} @@ -3503,11 +3503,11 @@ #import_alias (Maybe Text) #import_referrals (List Referral)])) -(def: referral_parser +(def referral_parser (Parser Referral) (formP (andP symbolP (someP anyP)))) -(def: (referrals_parser aliased?) +(def (referrals_parser aliased?) (-> Bit (Parser (List Referral))) (all eitherP (manyP referral_parser) @@ -3517,12 +3517,12 @@ (list)))) (inP (list)))) -(def: (text#split_at' at x) +(def (text#split_at' at x) (-> Nat Text [Text Text]) [("lux text clip" 0 at x) ("lux text clip" at (|> x "lux text size" ("lux i64 -" at)) x)]) -(def: (text#split_by token sample) +(def (text#split_by token sample) (-> Text Text (Maybe [Text Text])) (do ..maybe#monad [index (..index token sample) @@ -3530,7 +3530,7 @@ [_ post] (text#split_at' ("lux text size" token) post')]] (in [pre post]))) -(def: (replaced pattern replacement template) +(def (replaced pattern replacement template) (-> Text Text Text Text) ((is (-> Text Text Text) (function (again left right) @@ -3542,11 +3542,11 @@ ("lux text concat" left right)))) "" template)) -(def: (alias_stand_in index) +(def (alias_stand_in index) (-> Nat Text) (all "lux text concat" "[" (nat#encoded index) "]")) -(def: (module_alias context aliased) +(def (module_alias context aliased) (-> (List Text) Text Text) (product#right (list#mix (function (_ replacement [index aliased]) @@ -3555,13 +3555,13 @@ [0 aliased] context))) -(def: .public module_separator +(def .public module_separator "/") -(def: parallel_hierarchy_sigil +(def parallel_hierarchy_sigil "\") -(def: (normal_parallel_path' hierarchy root) +(def (normal_parallel_path' hierarchy root) (-> Text Text Text) (case [(text#split_by ..module_separator hierarchy) (text#split_by ..parallel_hierarchy_sigil root)] @@ -3574,7 +3574,7 @@ "" hierarchy _ (all text#composite root ..module_separator hierarchy)))) -(def: (normal_parallel_path hierarchy root) +(def (normal_parallel_path hierarchy root) (-> Text Text (Maybe Text)) (case (text#split_by ..parallel_hierarchy_sigil root) {#Some ["" root']} @@ -3583,7 +3583,7 @@ _ {#None})) -(def: (relative_ups relatives input) +(def (relative_ups relatives input) (-> Nat Text Nat) (case ("lux text index" relatives ..module_separator input) {#None} @@ -3594,7 +3594,7 @@ (relative_ups ("lux i64 +" 1 relatives) input) relatives))) -(def: (list#after amount list) +(def (list#after amount list) (All (_ a) (-> Nat (List a) (List a))) (case [amount list] (pattern#or [0 _] [_ {#End}]) @@ -3603,7 +3603,7 @@ [_ {#Item _ tail}] (list#after ("lux i64 -" 1 amount) tail))) -(def: (absolute_module_name nested? relative_root module) +(def (absolute_module_name nested? relative_root module) (-> Bit Text Text (Meta Text)) (case (relative_ups 0 module) 0 @@ -3630,7 +3630,7 @@ "Importing module: " module \n " Relative Root: " relative_root \n)))))) -(def: (imports_parser nested? relative_root context imports) +(def (imports_parser nested? relative_root context imports) (-> Bit Text (List Text) (List Code) (Meta (List Importation))) (do meta#monad [imports' (monad#each meta#monad @@ -3701,7 +3701,7 @@ imports)] (in (list#conjoint imports')))) -(def: (exported_definitions module state) +(def (exported_definitions module state) (-> Text (Meta (List Text))) (let [[current_module modules] (case state [..#info info ..#source source ..#current_module current_module ..#modules modules @@ -3753,7 +3753,7 @@ code#encoded))}) )) -(def: (list#only p xs) +(def (list#only p xs) (All (_ a) (-> (-> a Bit) (List a) (List a))) (case xs @@ -3765,7 +3765,7 @@ {#Item x (list#only p xs')} (list#only p xs')))) -(def: (is_member? cases name) +(def (is_member? cases name) (-> (List Text) Text Bit) (let [output (list#mix (function (_ case prev) (or prev @@ -3774,7 +3774,7 @@ cases)] output)) -(def: (test_referrals current_module imported_module all_defs referred_defs) +(def (test_referrals current_module imported_module all_defs referred_defs) (-> Text Text (List Text) (List Text) (Meta (List Any))) (monad#each meta#monad (is (-> Text (Meta Any)) @@ -3784,11 +3784,11 @@ (failure (all text#composite _def " is not defined in module " imported_module " @ " current_module))))) referred_defs)) -(def: (alias_definition imported_module def) +(def (alias_definition imported_module def) (-> Text Text Code) (` ("lux def alias" (~ (local$ def)) (~ (symbol$ [imported_module def]))))) -(def: .public only +(def .public only (macro (_ tokens) (case (..parsed (all ..andP ..textP @@ -3805,21 +3805,21 @@ {.#None} (failure (..wrong_syntax_error (symbol ..only)))))) -(def: .public |>> +(def .public |>> (macro (_ tokens) (do meta#monad [g!_ (..generated_symbol "_") g!arg (..generated_symbol "arg")] (meta#in (list (` (function ((~ g!_) (~ g!arg)) (|> (~ g!arg) (~+ tokens))))))))) -(def: .public <<| +(def .public <<| (macro (_ tokens) (do meta#monad [g!_ (..generated_symbol "_") g!arg (..generated_symbol "arg")] (meta#in (list (` (function ((~ g!_) (~ g!arg)) (<| (~+ tokens) (~ g!arg))))))))) -(def: .public except +(def .public except (macro (_ tokens) (case (..parsed (all ..andP ..textP @@ -3838,7 +3838,7 @@ {.#None} (failure (..wrong_syntax_error (symbol ..except)))))) -(def: (in_env name state) +(def (in_env name state) (-> Text Lux (Maybe Type)) (case state [..#info info ..#source source ..#current_module _ ..#modules modules @@ -3860,7 +3860,7 @@ locals)))) scopes))) -(def: (definition_type name state) +(def (definition_type name state) (-> Symbol Lux (Maybe Type)) (let [[v_module v_name] name [..#info info ..#source source ..#current_module _ ..#modules modules @@ -3897,7 +3897,7 @@ {#Slot _} {#None}))))) -(def: (definition_value name state) +(def (definition_value name state) (-> Symbol (Meta [Type Any])) (let [[v_module v_name] name [..#info info ..#source source ..#current_module _ ..#modules modules @@ -3934,7 +3934,7 @@ {#Slot _} {#Left (text#composite "Unknown definition: " (symbol#encoded name))}))))) -(def: (type_variable idx bindings) +(def (type_variable idx bindings) (-> Nat (List [Nat (Maybe Type)]) (Maybe Type)) (case bindings {#End} @@ -3945,7 +3945,7 @@ bound (type_variable idx bindings')))) -(def: (type_definition full_name) +(def (type_definition full_name) (-> Symbol (Meta Type)) (do meta#monad [.let [[module name] full_name] @@ -3988,7 +3988,7 @@ temp)) ))) -(def: (zipped_2 xs ys) +(def (zipped_2 xs ys) (All (_ a b) (-> (List a) (List b) (List [a b]))) (case xs @@ -4003,7 +4003,7 @@ _ (list))) -(def: .public open +(def .public open (macro (_ tokens) (case tokens (pattern (partial_list [_ {#Form (list [_ {#Text alias}])}] body branches)) @@ -4060,7 +4060,7 @@ _ (failure (..wrong_syntax_error (symbol ..open)))))) -(def: .public cond +(def .public cond (macro (_ tokens) (case (list#reversed tokens) (pattern (partial_list else branches')) @@ -4079,7 +4079,7 @@ _ (failure (..wrong_syntax_error (symbol ..cond)))))) -(def: (enumeration' idx xs) +(def (enumeration' idx xs) (All (_ a) (-> Nat (List a) (List [Nat a]))) (case xs @@ -4089,12 +4089,12 @@ {#End} {#End})) -(def: (enumeration xs) +(def (enumeration xs) (All (_ a) (-> (List a) (List [Nat a]))) (enumeration' 0 xs)) -(def: .public the +(def .public the (macro (_ tokens) (case tokens (pattern (list [_ {#Symbol slot'}] record)) @@ -4136,7 +4136,7 @@ _ (failure (..wrong_syntax_error (symbol ..the)))))) -(def: (open_declaration imported_module alias tags my_tag_index [module short] source type) +(def (open_declaration imported_module alias tags my_tag_index [module short] source type) (-> Text Text (List Symbol) Nat Symbol Code Type (Meta (List Code))) (do meta#monad [output (record_slots type) @@ -4165,7 +4165,7 @@ (~ source+) #0))))))) -(def: (implementation_declarations imported_module alias implementation) +(def (implementation_declarations imported_module alias implementation) (-> Text Text Symbol (Meta (List Code))) (do meta#monad [interface (type_definition implementation) @@ -4185,7 +4185,7 @@ "Can only 'open:' structs: " (symbol#encoded implementation) " : " (type#encoded interface)))))) -(def: (localized module global) +(def (localized module global) (-> Text Symbol Symbol) (case global ["" local] @@ -4194,7 +4194,7 @@ _ global)) -(def: .public open: +(def .public open: (macro (_ tokens) (case (..parsed (all ..andP (..maybeP (all ..andP @@ -4252,14 +4252,14 @@ {.#None} (failure (..wrong_syntax_error (symbol ..open:)))))) -(def: (imported_by? import_name module_name) +(def (imported_by? import_name module_name) (-> Text Text (Meta Bit)) (do meta#monad [module (module module_name) .let [[..#module_hash _ ..#module_aliases _ ..#definitions _ ..#imports imports ..#module_state _] module]] (in (is_member? imports import_name)))) -(def: (referrals module_name extra) +(def (referrals module_name extra) (-> Text (List Code) (Meta (List Referral))) (do meta#monad [extra,referral (case (referrals_parser #0 extra) @@ -4281,7 +4281,7 @@ (list#interposed " ") (list#mix text#composite ""))))))) -(def: refer +(def refer (macro (_ tokens) (case tokens (pattern (partial_list [_ {#Text imported_module}] [_ {#Text alias}] options)) @@ -4299,7 +4299,7 @@ _ (failure (..wrong_syntax_error (symbol ..refer)))))) -(def: .public with +(def .public with (macro (_ tokens) (case (..parsed (..andP ..anyP ..anyP) tokens) @@ -4310,7 +4310,7 @@ {.#None} (failure (..wrong_syntax_error (symbol ..with)))))) -(def: .public at +(def .public at (macro (_ tokens) (case tokens (pattern (list implementation [_ {#Symbol member}])) @@ -4322,7 +4322,7 @@ _ (failure (..wrong_syntax_error (symbol ..at)))))) -(def: .public has +(def .public has (macro (_ tokens) (case tokens (pattern (list [_ {#Symbol slot'}] value record)) @@ -4406,7 +4406,7 @@ _ (failure (..wrong_syntax_error (symbol ..has)))))) -(def: .public revised +(def .public revised (macro (_ tokens) (case tokens (pattern (list [_ {#Symbol slot'}] fun record)) @@ -4476,7 +4476,7 @@ _ (failure (..wrong_syntax_error (symbol ..revised)))))) -(def: .private with_template#pattern +(def .private with_template#pattern (macro (_ tokens) (case tokens (pattern (partial_list [_ {#Form (list [_ {#Tuple bindings}] @@ -4507,7 +4507,7 @@ (failure (..wrong_syntax_error (symbol ..with_template#pattern)))))) (with_template [<name> <extension>] - [(def: .public <name> + [(def .public <name> (All (_ s) (-> (I64 s) (I64 s))) (|>> (<extension> 1)))] @@ -4516,7 +4516,7 @@ [-- "lux i64 -"] ) -(def: (interleaved xs ys) +(def (interleaved xs ys) (All (_ a) (-> (List a) (List a) (List a))) (case xs @@ -4531,7 +4531,7 @@ {#Item y ys'} (partial_list x y (interleaved xs' ys'))))) -(def: (type_code type) +(def (type_code type) (-> Type Code) (case type {#Primitive name params} @@ -4562,7 +4562,7 @@ ... (~ (type_code anonymous))}) (symbol$ [module name]))) -(def: .public loop +(def .public loop (macro (_ tokens) (let [?params (case tokens (pattern (list [_ {#Form (list name [_ {#Tuple bindings}])}] body)) @@ -4605,7 +4605,7 @@ {#None} (failure (..wrong_syntax_error (symbol ..loop))))))) -(def: (with_expansions' label tokens target) +(def (with_expansions' label tokens target) (-> Text (List Code) Code (List Code)) (case target (pattern#or [_ {#Bit _}] [_ {#Nat _}] [_ {#Int _}] [_ {#Rev _}] [_ {#Frac _}] [_ {#Text _}]) @@ -4624,7 +4624,7 @@ [#Variant] [#Tuple]))) -(def: .public with_expansions +(def .public with_expansions (macro (_ tokens) (case (parsed (andP (tupleP (someP bindingP)) (someP anyP)) tokens) {#Some [bindings bodies]} @@ -4657,7 +4657,7 @@ {#None} (failure (..wrong_syntax_error (symbol ..with_expansions)))))) -(def: (flat_alias type) +(def (flat_alias type) (-> Type Type) (case type (with_template#pattern [<name>] @@ -4676,7 +4676,7 @@ _ type)) -(def: (static_simple_literal name) +(def (static_simple_literal name) (-> Symbol (Meta Code)) (do meta#monad [type+value (definition_value name) @@ -4695,7 +4695,7 @@ _ (failure (text#composite "Cannot anti-quote type: " (symbol#encoded name)))))) -(def: (static_literal token) +(def (static_literal token) (-> Code (Meta Code)) (case token [_ {#Symbol [def_module def_name]}] @@ -4720,7 +4720,7 @@ ... (at meta#monad in token) )) -(def: .public static +(def .public static (macro (_ tokens) (case tokens (pattern (list pattern)) @@ -4734,7 +4734,7 @@ (type: Multi_Level_Case [Code (List [Code Code])]) -(def: (case_level^ level) +(def (case_level^ level) (-> Code (Meta [Code Code])) (case level (pattern [_ {#Tuple (list expr binding)}]) @@ -4744,7 +4744,7 @@ (meta#in [level (` #1)]) )) -(def: (multi_level_case^ levels) +(def (multi_level_case^ levels) (-> (List Code) (Meta Multi_Level_Case)) (case levels {#End} @@ -4755,7 +4755,7 @@ [extras' (monad#each meta#monad case_level^ extras)] (in [init extras'])))) -(def: (multi_level_case$ g!_ [[init_pattern levels] body]) +(def (multi_level_case$ g!_ [[init_pattern levels] body]) (-> Code [Multi_Level_Case Code] (List Code)) (let [inner_pattern_body (list#mix (function (_ [calculation pattern] success) (let [bind? (case pattern @@ -4775,7 +4775,7 @@ (is (List [Code Code]) (list#reversed levels)))] (list init_pattern inner_pattern_body))) -(def: pattern#multi +(def pattern#multi (macro (_ tokens) (case tokens (pattern (partial_list [_meta {#Form levels}] body next_branches)) @@ -4807,12 +4807,12 @@ _ (failure (..wrong_syntax_error (symbol ..pattern#multi)))))) -(def: .public (same? reference sample) +(def .public (same? reference sample) (All (_ a) (-> a a Bit)) ("lux is" reference sample)) -(def: .public as_expected +(def .public as_expected (macro (_ tokens) (case tokens (pattern (list expr)) @@ -4823,12 +4823,12 @@ _ (failure (..wrong_syntax_error (symbol ..as_expected)))))) -(def: location +(def location (Meta Location) (function (_ compiler) {#Right [compiler (the #location compiler)]})) -(def: .public undefined +(def .public undefined (macro (_ tokens) (case tokens {#End} @@ -4842,7 +4842,7 @@ _ (failure (..wrong_syntax_error (symbol ..undefined)))))) -(def: .public type_of +(def .public type_of (macro (_ tokens) (case tokens (pattern (list [_ {#Symbol var_name}])) @@ -4859,7 +4859,7 @@ _ (failure (..wrong_syntax_error (symbol ..type_of)))))) -(def: (templateP tokens) +(def (templateP tokens) (-> (List Code) (Maybe [Text (List Text) (List Code)])) (do maybe#monad [% (local_declarationP tokens) @@ -4869,7 +4869,7 @@ _ (endP tokens)] (in [name parameters templates]))) -(def: .public template +(def .public template (macro (_ tokens) (case (templateP tokens) {#Some [name args input_templates]} @@ -4897,7 +4897,7 @@ (failure (..wrong_syntax_error (symbol ..template)))))) (with_template [<name> <to>] - [(def: .public <name> + [(def .public <name> (template (<name> it) [(..|> it (..is (..I64 ..Any)) (..as <to>))]))] @@ -4907,11 +4907,11 @@ [rev ..Rev] ) -(def: .public these +(def .public these (macro (_ tokens compiler) {#Right [compiler tokens]})) -(def: .public char +(def .public char (macro (_ tokens compiler) (case tokens (pattern#multi (pattern (list [_ {#Text input}])) @@ -4923,12 +4923,12 @@ _ {#Left (..wrong_syntax_error (symbol ..char))}))) -(def: target +(def target (Meta Text) (function (_ compiler) {#Right [compiler (the [#info #target] compiler)]})) -(def: (platform_name choice) +(def (platform_name choice) (-> Code (Meta Text)) (case choice [_ {#Text platform}] @@ -4954,7 +4954,7 @@ "Invalid target platform syntax: " (..code#encoded choice) \n "Must be either a text literal or a symbol.")))) -(def: (target_pick target options default) +(def (target_pick target options default) (-> Text (List [Code Code]) (Maybe Code) (Meta (List Code))) (case options {#End} @@ -4972,7 +4972,7 @@ (meta#in (list pick)) (target_pick target options' default))))) -(def: .public for +(def .public for (macro (_ tokens) (case (..parsed (..andP (..someP (..andP ..anyP ..anyP)) (..maybeP ..anyP)) @@ -4986,7 +4986,7 @@ (failure (..wrong_syntax_error (symbol ..for)))))) ... TODO: Delete "scope_type_vars" (including the #scope_type_vars Lux state) and "parameter" ASAP. -(for "{old}" (these (def: (scope_type_vars state) +(for "{old}" (these (def (scope_type_vars state) (Meta (List Nat)) (case state [..#info info ..#source source ..#current_module _ ..#modules modules @@ -4995,7 +4995,7 @@ ..#scope_type_vars scope_type_vars ..#eval _eval] {#Right [state scope_type_vars]})) - (def: .public parameter + (def .public parameter (macro (_ tokens) (case tokens (pattern (list [_ {#Nat idx}])) @@ -5010,9 +5010,9 @@ _ (failure (..wrong_syntax_error (symbol ..$))))))) - (these (def: .public parameter ""))) + (these (def .public parameter ""))) -(def: (refer_code imported_module alias referrals) +(def (refer_code imported_module alias referrals) (-> Text Text (List Referral) Code) (` ((~! ..refer) (~ (text$ imported_module)) @@ -5021,7 +5021,7 @@ (` ((~ (symbol$ macro)) (~+ parameters)))) referrals))))) -(def: .public using +(def .public using (macro (_ _imports) (do meta#monad [current_module ..current_module_name @@ -5048,12 +5048,12 @@ =refers) =refers)})))) -(def: (symbol#= [moduleL shortL] [moduleR shortR]) +(def (symbol#= [moduleL shortL] [moduleR shortR]) (-> Symbol Symbol Bit) (and (text#= moduleL moduleR) (text#= shortL shortR))) -(def: (type#= left right) +(def (type#= left right) (-> Type Type Bit) (case [left right] [{#Primitive nameL parametersL} {#Primitive nameR parametersR}] @@ -5099,15 +5099,15 @@ (type: .public Immediate_UnQuote (Primitive "#Macro/Immediate_UnQuote")) -(def: .public immediate_unquote +(def .public immediate_unquote (-> Macro Immediate_UnQuote) (|>> (as Immediate_UnQuote))) -(def: immediate_unquote_macro +(def immediate_unquote_macro (-> Immediate_UnQuote Macro') (|>> (as Macro'))) -(def: .public ~~ +(def .public ~~ (..immediate_unquote (macro (_ it) (case it @@ -5117,7 +5117,7 @@ _ (failure (wrong_syntax_error (symbol ..~~))))))) -(def: aggregate_embedded_expansions +(def aggregate_embedded_expansions (template (_ embedded_expansions <@> <tag> <*>) [(do meta#monad [<*>' (monad#each meta#monad embedded_expansions <*>)] @@ -5127,7 +5127,7 @@ (list#mix list#composite (list))) [<@> {<tag> (list#each product#right <*>')}]]))])) -(def: (meta#try it) +(def (meta#try it) (All (_ a) (-> (Meta a) (Meta (Either Text a)))) (function (_ state) (case (it state) @@ -5137,7 +5137,7 @@ {#Right [state output]} {#Right [state {#Right output}]}))) -(def: (embedded_expansions code) +(def (embedded_expansions code) (-> Code (Meta [(List Code) Code])) (case code (pattern [@ {#Form (partial_list [@symbol {#Symbol original_symbol}] parameters)}]) @@ -5175,7 +5175,7 @@ _ (meta#in [(list) code]))) -(def: .public `` +(def .public `` (macro (_ tokens) (case tokens (pattern (list raw)) @@ -5188,15 +5188,15 @@ _ (failure (..wrong_syntax_error (symbol ..``)))))) -(def: .public false +(def .public false Bit #0) -(def: .public true +(def .public true Bit #1) -(def: .public try +(def .public try (macro (_ tokens) (case tokens (pattern (list expression)) @@ -5209,7 +5209,7 @@ _ (..failure (..wrong_syntax_error (symbol ..try)))))) -(def: (methodP tokens) +(def (methodP tokens) (-> (List Code) (Maybe [(List Code) [Text Code]])) (case tokens (pattern (partial_list [_ {#Form (list [_ {#Text "lux type check"}] @@ -5221,7 +5221,7 @@ _ {#None})) -(def: .public Interface +(def .public Interface (macro (_ tokens) (do meta#monad [methods' (monad#each meta#monad expansion tokens)] @@ -5233,14 +5233,14 @@ {#None} (failure (..wrong_syntax_error (symbol ..Interface))))))) -(def: (recursive_type g!self g!dummy name body) +(def (recursive_type g!self g!dummy name body) (-> Code Code Text Code Code) (` {.#Apply (..Primitive "") (.All ((~ g!self) (~ g!dummy)) (~ (let$ (local$ name) (` {.#Apply (..Primitive "") (~ g!self)}) body)))})) -(def: .public Rec +(def .public Rec (macro (_ tokens) (case tokens (pattern (list [_ {#Symbol "" name}] body)) diff --git a/stdlib/source/library/lux/abstract/apply.lux b/stdlib/source/library/lux/abstract/apply.lux index 0685484d5..35320cbd4 100644 --- a/stdlib/source/library/lux/abstract/apply.lux +++ b/stdlib/source/library/lux/abstract/apply.lux @@ -14,16 +14,16 @@ (-> (f a) (f (-> a b)) (f b))) on))) -(def: .public (composite f_monad f_apply g_apply) +(def .public (composite f_monad f_apply g_apply) (All (_ F G) (-> (Monad F) (Apply F) (Apply G) ... TODO: Replace (All (_ a) (F (G a))) with (functor.Then F G) (Apply (All (_ a) (F (G a)))))) (implementation - (def: functor + (def functor (functor.composite (the functor f_apply) (the functor g_apply))) - (def: (on fgx fgf) + (def (on fgx fgf) ... TODO: Switch from this version to the one below (in comments) ASAP. (for @.old (let [fgf' (at f_apply on fgf diff --git a/stdlib/source/library/lux/abstract/codec.lux b/stdlib/source/library/lux/abstract/codec.lux index ce6bab822..1af71150f 100644 --- a/stdlib/source/library/lux/abstract/codec.lux +++ b/stdlib/source/library/lux/abstract/codec.lux @@ -14,16 +14,16 @@ (is (-> m (Try a)) decoded))) -(def: .public (composite cb_codec ba_codec) +(def .public (composite cb_codec ba_codec) (All (_ a b c) (-> (Codec c b) (Codec b a) (Codec c a))) (implementation - (def: encoded + (def encoded (|>> (at ba_codec encoded) (at cb_codec encoded))) - (def: (decoded cy) + (def (decoded cy) (do try.monad [by (at cb_codec decoded cy)] (at ba_codec decoded by))))) diff --git a/stdlib/source/library/lux/abstract/comonad.lux b/stdlib/source/library/lux/abstract/comonad.lux index 54f8707a3..405acfbf1 100644 --- a/stdlib/source/library/lux/abstract/comonad.lux +++ b/stdlib/source/library/lux/abstract/comonad.lux @@ -23,7 +23,7 @@ (-> (w a) (w (w a)))) disjoint))) -(def: .public be +(def .public be (macro (_ tokens state) (case (is (Maybe [(Maybe Text) Code (List Code) Code]) (case tokens diff --git a/stdlib/source/library/lux/abstract/comonad/free.lux b/stdlib/source/library/lux/abstract/comonad/free.lux index 60cbb883b..2e7e7cf1c 100644 --- a/stdlib/source/library/lux/abstract/comonad/free.lux +++ b/stdlib/source/library/lux/abstract/comonad/free.lux @@ -8,20 +8,20 @@ (type: .public (Free F a) [a (F (Free F a))]) -(def: .public (functor dsl) +(def .public (functor dsl) (All (_ F) (-> (Functor F) (Functor (Free F)))) (implementation - (def: (each f [head tail]) + (def (each f [head tail]) [(f head) (at dsl each (each f) tail)]))) -(def: .public (comonad dsl) +(def .public (comonad dsl) (All (_ F) (-> (Functor F) (CoMonad (Free F)))) (implementation - (def: functor (..functor dsl)) + (def functor (..functor dsl)) - (def: (out [head tail]) + (def (out [head tail]) head) - (def: (disjoint [head tail]) + (def (disjoint [head tail]) [[head tail] (at dsl each disjoint tail)]))) diff --git a/stdlib/source/library/lux/abstract/enum.lux b/stdlib/source/library/lux/abstract/enum.lux index fbc9249ba..58e127f7d 100644 --- a/stdlib/source/library/lux/abstract/enum.lux +++ b/stdlib/source/library/lux/abstract/enum.lux @@ -10,7 +10,7 @@ (is (-> e e) succ) (is (-> e e) pred))) -(def: .public (range enum from to) +(def .public (range enum from to) (All (_ a) (-> (Enum a) a a (List a))) (let [(open "/#[0]") enum] (loop (again [end to diff --git a/stdlib/source/library/lux/abstract/equivalence.lux b/stdlib/source/library/lux/abstract/equivalence.lux index 064492b0f..fcd0f41cd 100644 --- a/stdlib/source/library/lux/abstract/equivalence.lux +++ b/stdlib/source/library/lux/abstract/equivalence.lux @@ -10,17 +10,17 @@ (is (-> a a Bit) =))) -(def: .public (rec sub) +(def .public (rec sub) (All (_ a) (-> (-> (Equivalence a) (Equivalence a)) (Equivalence a))) (implementation - (def: (= left right) + (def (= left right) (sub = left right)))) -(def: .public functor +(def .public functor (contravariant.Functor Equivalence) (implementation - (def: (each f equivalence) + (def (each f equivalence) (implementation - (def: (= reference sample) + (def (= reference sample) (at equivalence = (f reference) (f sample))))))) diff --git a/stdlib/source/library/lux/abstract/functor.lux b/stdlib/source/library/lux/abstract/functor.lux index fb80f0f1f..43bfa28d9 100644 --- a/stdlib/source/library/lux/abstract/functor.lux +++ b/stdlib/source/library/lux/abstract/functor.lux @@ -12,10 +12,10 @@ (type: .public (Or f g) (All (_ a) (.Or (f a) (g a)))) -(def: .public (sum (open "f#[0]") (open "g#[0]")) +(def .public (sum (open "f#[0]") (open "g#[0]")) (All (_ F G) (-> (Functor F) (Functor G) (Functor (..Or F G)))) (implementation - (def: (each f fa|ga) + (def (each f fa|ga) (case fa|ga {.#Left fa} {.#Left (f#each f fa)} @@ -26,18 +26,18 @@ (type: .public (And f g) (All (_ a) (.And (f a) (g a)))) -(def: .public (product (open "f#[0]") (open "g#[0]")) +(def .public (product (open "f#[0]") (open "g#[0]")) (All (_ F G) (-> (Functor F) (Functor G) (Functor (..And F G)))) (implementation - (def: (each f [fa ga]) + (def (each f [fa ga]) [(f#each f fa) (g#each f ga)]))) (type: .public (Then f g) (All (_ a) (f (g a)))) -(def: .public (composite (open "f#[0]") (open "g#[0]")) +(def .public (composite (open "f#[0]") (open "g#[0]")) (All (_ F G) (-> (Functor F) (Functor G) (Functor (..Then F G)))) (implementation - (def: (each f fga) + (def (each f fga) (f#each (g#each f) fga)))) diff --git a/stdlib/source/library/lux/abstract/hash.lux b/stdlib/source/library/lux/abstract/hash.lux index 31a8d24b7..ef5df6022 100644 --- a/stdlib/source/library/lux/abstract/hash.lux +++ b/stdlib/source/library/lux/abstract/hash.lux @@ -13,14 +13,14 @@ (is (-> a Nat) hash))) -(def: .public functor +(def .public functor (contravariant.Functor Hash) (implementation - (def: (each f super) + (def (each f super) (implementation - (def: equivalence + (def equivalence (at equivalence.functor each f (at super equivalence))) - (def: hash + (def hash (|>> f (at super hash))))))) diff --git a/stdlib/source/library/lux/abstract/interval.lux b/stdlib/source/library/lux/abstract/interval.lux index 9f4a4a6ec..0a538e925 100644 --- a/stdlib/source/library/lux/abstract/interval.lux +++ b/stdlib/source/library/lux/abstract/interval.lux @@ -18,22 +18,22 @@ (is a top))) -(def: .public (between enum bottom top) +(def .public (between enum bottom top) (All (_ a) (-> (Enum a) a a (Interval a))) (implementation - (def: enum enum) - (def: bottom bottom) - (def: top top))) + (def enum enum) + (def bottom bottom) + (def top top))) -(def: .public (singleton enum elem) +(def .public (singleton enum elem) (All (_ a) (-> (Enum a) a (Interval a))) (implementation - (def: enum enum) - (def: bottom elem) - (def: top elem))) + (def enum enum) + (def bottom elem) + (def top elem))) (with_template [<name> <comp>] - [(def: .public (<name> interval) + [(def .public (<name> interval) (All (_ a) (-> (Interval a) Bit)) (let [(open ",#[0]") interval] (<comp> ,#bottom ,#top)))] @@ -43,7 +43,7 @@ [singleton? ,#=] ) -(def: .public (within? interval elem) +(def .public (within? interval elem) (All (_ a) (-> (Interval a) a Bit)) (let [(open ",#[0]") interval] (cond (inner? interval) @@ -59,7 +59,7 @@ (,#= ,#top elem))))) (with_template [<name> <limit>] - [(def: .public (<name> elem interval) + [(def .public (<name> elem interval) (All (_ a) (-> a (Interval a) Bit)) (let [(open "[0]") interval] (= <limit> elem)))] @@ -68,45 +68,45 @@ [ends_with? top] ) -(def: .public (borders? interval elem) +(def .public (borders? interval elem) (All (_ a) (-> (Interval a) a Bit)) (or (starts_with? elem interval) (ends_with? elem interval))) -(def: .public (union left right) +(def .public (union left right) (All (_ a) (-> (Interval a) (Interval a) (Interval a))) (implementation - (def: enum (the enum right)) - (def: bottom (order.min (at right order) (at left bottom) (at right bottom))) - (def: top (order.max (at right order) (at left top) (at right top))))) + (def enum (the enum right)) + (def bottom (order.min (at right order) (at left bottom) (at right bottom))) + (def top (order.max (at right order) (at left top) (at right top))))) -(def: .public (intersection left right) +(def .public (intersection left right) (All (_ a) (-> (Interval a) (Interval a) (Interval a))) (implementation - (def: enum (the enum right)) - (def: bottom (order.max (at right order) (at left bottom) (at right bottom))) - (def: top (order.min (at right order) (at left top) (at right top))))) + (def enum (the enum right)) + (def bottom (order.max (at right order) (at left bottom) (at right bottom))) + (def top (order.min (at right order) (at left top) (at right top))))) -(def: .public (complement interval) +(def .public (complement interval) (All (_ a) (-> (Interval a) (Interval a))) (implementation - (def: enum (the enum interval)) - (def: bottom (at interval succ (at interval top))) - (def: top (at interval pred (at interval bottom))))) + (def enum (the enum interval)) + (def bottom (at interval succ (at interval top))) + (def top (at interval pred (at interval bottom))))) -(def: .public (precedes? reference sample) +(def .public (precedes? reference sample) (All (_ a) (-> (Interval a) (Interval a) Bit)) (let [(open "[0]") reference limit (at reference bottom)] (and (< limit (at sample bottom)) (< limit (at sample top))))) -(def: .public (succeeds? reference sample) +(def .public (succeeds? reference sample) (All (_ a) (-> (Interval a) (Interval a) Bit)) (precedes? sample reference)) (with_template [<name> <comp>] - [(def: .public (<name> reference sample) + [(def .public (<name> reference sample) (All (_ a) (-> a (Interval a) Bit)) (let [(open ",#[0]") sample] (and (<comp> reference ,#bottom) @@ -116,20 +116,20 @@ [after? (order.> ,#order)] ) -(def: .public (meets? reference sample) +(def .public (meets? reference sample) (All (_ a) (-> (Interval a) (Interval a) Bit)) (let [(open ",#[0]") reference limit (at reference bottom)] (and (,#= limit (at sample top)) (order.<= ,#order limit (at sample bottom))))) -(def: .public (touches? reference sample) +(def .public (touches? reference sample) (All (_ a) (-> (Interval a) (Interval a) Bit)) (or (meets? reference sample) (meets? sample reference))) (with_template [<name> <eq_side> <ineq> <ineq_side>] - [(def: .public (<name> reference sample) + [(def .public (<name> reference sample) (All (_ a) (-> (Interval a) (Interval a) Bit)) (let [(open ",#[0]") reference] (and (,#= (at reference <eq_side>) @@ -142,15 +142,15 @@ [finishes? ,#top order.>= ,#bottom] ) -(def: .public equivalence +(def .public equivalence (All (_ a) (Equivalence (Interval a))) (implementation - (def: (= reference sample) + (def (= reference sample) (let [(open ",#[0]") reference] (and (,#= ,#bottom (at sample bottom)) (,#= ,#top (at sample top))))))) -(def: .public (nested? reference sample) +(def .public (nested? reference sample) (All (_ a) (-> (Interval a) (Interval a) Bit)) (cond (or (singleton? sample) (and (inner? reference) (inner? sample)) @@ -171,7 +171,7 @@ (order.<= ,#order (at reference top) (at sample top))))) )) -(def: .public (overlaps? reference sample) +(def .public (overlaps? reference sample) (All (_ a) (-> (Interval a) (Interval a) Bit)) (let [(open ",#[0]") reference] (and (not (at ..equivalence = reference sample)) diff --git a/stdlib/source/library/lux/abstract/mix.lux b/stdlib/source/library/lux/abstract/mix.lux index 3dc3ecc71..ea317146b 100644 --- a/stdlib/source/library/lux/abstract/mix.lux +++ b/stdlib/source/library/lux/abstract/mix.lux @@ -10,7 +10,7 @@ (-> (-> b a a) a (F b) a)) mix))) -(def: .public (with_monoid monoid mix value) +(def .public (with_monoid monoid mix value) (All (_ F a) (-> (Monoid a) (Mix F) (F a) a)) (let [(open "/#[0]") monoid] diff --git a/stdlib/source/library/lux/abstract/monad.lux b/stdlib/source/library/lux/abstract/monad.lux index 18c22027d..ecd4e1ac4 100644 --- a/stdlib/source/library/lux/abstract/monad.lux +++ b/stdlib/source/library/lux/abstract/monad.lux @@ -6,7 +6,7 @@ [// [functor (.only Functor)]]) -(def: (list#mix f init xs) +(def (list#mix f init xs) (All (_ a b) (-> (-> b a a) a (List b) a)) (case xs @@ -16,7 +16,7 @@ {.#Item x xs'} (list#mix f (f x init) xs'))) -(def: (list#size xs) +(def (list#size xs) (All (_ a) (-> (List a) Nat)) (loop (again [counter 0 xs xs]) @@ -27,14 +27,14 @@ {.#Item _ xs'} (again (++ counter) xs')))) -(def: (reversed xs) +(def (reversed xs) (All (_ a) (-> (List a) (List a))) (list#mix (function (_ head tail) {.#Item head tail}) {.#End} xs)) -(def: (pairs xs) +(def (pairs xs) (All (_ a) (-> (List a) (List [a a]))) (case xs {.#Item x1 {.#Item x2 xs'}} @@ -54,7 +54,7 @@ (-> (m (m a)) (m a))) conjoint))) -(def: .public do +(def .public do (macro (_ tokens state) (case (is (Maybe [(Maybe Text) Code (List Code) Code]) (case tokens @@ -107,14 +107,14 @@ {.#None} {.#Left "Wrong syntax for 'do'"}))) -(def: .public (then monad f) +(def .public (then monad f) (All (_ ! a b) (-> (Monad !) (-> a (! b)) (-> (! a) (! b)))) (|>> (at monad each f) (at monad conjoint))) -(def: .public (all monad) +(def .public (all monad) (All (_ ! a) (-> (Monad !) (List (! a)) (! (List a)))) @@ -130,7 +130,7 @@ (!#each (|>> {.#Item _x}) (again xs')))) !#conjoint))))) -(def: .public (each monad f) +(def .public (each monad f) (All (_ M a b) (-> (Monad M) (-> a (M b)) (List a) (M (List b)))) @@ -146,7 +146,7 @@ (!#each (|>> {.#Item _x}) (again xs')))) !#conjoint))))) -(def: .public (only monad f) +(def .public (only monad f) (All (_ ! a b) (-> (Monad !) (-> a (! Bit)) (List a) (! (List a)))) @@ -166,7 +166,7 @@ (again xs')))) !#conjoint))))) -(def: .public (mix monad f init xs) +(def .public (mix monad f init xs) (All (_ M a b) (-> (Monad M) (-> b a (M a)) a (List b) (M a))) diff --git a/stdlib/source/library/lux/abstract/monad/free.lux b/stdlib/source/library/lux/abstract/monad/free.lux index af3436ab4..f4e440054 100644 --- a/stdlib/source/library/lux/abstract/monad/free.lux +++ b/stdlib/source/library/lux/abstract/monad/free.lux @@ -11,10 +11,10 @@ {#Pure a} {#Effect (F (Free F a))})) -(def: .public (functor dsl) +(def .public (functor dsl) (All (_ F) (-> (Functor F) (Functor (Free F)))) (implementation - (def: (each f ea) + (def (each f ea) (case ea {#Pure a} {#Pure (f a)} @@ -22,13 +22,13 @@ {#Effect value} {#Effect (at dsl each (each f) value)})))) -(def: .public (apply dsl) +(def .public (apply dsl) (All (_ F) (-> (Functor F) (Apply (Free F)))) (implementation - (def: functor + (def functor (..functor dsl)) - (def: (on ea ef) + (def (on ea ef) (case [ef ea] [{#Pure f} {#Pure a}] {#Pure (f a)} @@ -42,15 +42,15 @@ {#Effect (at dsl each (on ea) ff)} )))) -(def: .public (monad dsl) +(def .public (monad dsl) (All (_ F) (-> (Functor F) (Monad (Free F)))) (implementation - (def: functor (..functor dsl)) + (def functor (..functor dsl)) - (def: (in a) + (def (in a) {#Pure a}) - (def: (conjoint efefa) + (def (conjoint efefa) (case efefa {#Pure efa} (case efa diff --git a/stdlib/source/library/lux/abstract/monad/indexed.lux b/stdlib/source/library/lux/abstract/monad/indexed.lux index f1d774637..30d3b403f 100644 --- a/stdlib/source/library/lux/abstract/monad/indexed.lux +++ b/stdlib/source/library/lux/abstract/monad/indexed.lux @@ -27,7 +27,7 @@ (type: Binding [Code Code]) -(def: binding +(def binding (Parser Binding) (<>.and <code>.any <code>.any)) @@ -36,24 +36,24 @@ {#Macro Symbol Code} {#Binding Binding})) -(def: global +(def global (Parser Symbol) (//.do <>.monad [[module short] <code>.symbol _ (<>.assertion "" (case module "" false _ true))] (in [module short]))) -(def: context +(def context (Parser Context) (<>.or (<>.and ..global <code>.any) binding)) -(def: (pair_list [binding value]) +(def (pair_list [binding value]) (All (_ a) (-> [a a] (List a))) (list binding value)) -(def: named_monad +(def named_monad (Parser [(Maybe Text) Code]) (<>.either (<code>.tuple (<>.and (at <>.monad each (|>> {.#Some}) <code>.local) @@ -61,7 +61,7 @@ (at <>.monad each (|>> [{.#None}]) <code>.any))) -(def: .public do +(def .public do (syntax (_ [[?name monad] ..named_monad context (<code>.tuple (<>.some context)) expression <code>.any]) diff --git a/stdlib/source/library/lux/abstract/monoid.lux b/stdlib/source/library/lux/abstract/monoid.lux index a93d844a8..f5afe510a 100644 --- a/stdlib/source/library/lux/abstract/monoid.lux +++ b/stdlib/source/library/lux/abstract/monoid.lux @@ -9,13 +9,13 @@ (is (-> a a a) composite))) -(def: .public (and left right) +(def .public (and left right) (All (_ l r) (-> (Monoid l) (Monoid r) (Monoid [l r]))) (implementation - (def: identity + (def identity [(at left identity) (at right identity)]) - (def: (composite [lL rL] [lR rR]) + (def (composite [lL rL] [lR rR]) [(at left composite lL lR) (at right composite rL rR)]))) diff --git a/stdlib/source/library/lux/abstract/order.lux b/stdlib/source/library/lux/abstract/order.lux index e8dfbc834..71e546ed4 100644 --- a/stdlib/source/library/lux/abstract/order.lux +++ b/stdlib/source/library/lux/abstract/order.lux @@ -19,16 +19,16 @@ (type: .public (Comparison a) (-> (Order a) a a Bit)) -(def: .public (<= order parameter subject) +(def .public (<= order parameter subject) Comparison (or (at order < parameter subject) (at order = parameter subject))) -(def: .public (> order parameter subject) +(def .public (> order parameter subject) Comparison (at order < subject parameter)) -(def: .public (>= order parameter subject) +(def .public (>= order parameter subject) Comparison (or (at order < subject parameter) (at order = subject parameter))) @@ -36,21 +36,21 @@ (type: .public (Choice a) (-> (Order a) a a a)) -(def: .public (min order x y) +(def .public (min order x y) Choice (if (at order < y x) x y)) -(def: .public (max order x y) +(def .public (max order x y) Choice (if (at order < y x) y x)) -(def: .public functor +(def .public functor (contravariant.Functor Order) (implementation - (def: (each f order) + (def (each f order) (implementation - (def: equivalence + (def equivalence (at equivalence.functor each f (at order equivalence))) - (def: (< reference sample) + (def (< reference sample) (at order < (f reference) (f sample))))))) diff --git a/stdlib/source/library/lux/abstract/predicate.lux b/stdlib/source/library/lux/abstract/predicate.lux index 61a2bb41c..8becf51cd 100644 --- a/stdlib/source/library/lux/abstract/predicate.lux +++ b/stdlib/source/library/lux/abstract/predicate.lux @@ -12,11 +12,11 @@ (-> a Bit)) (with_template [<identity_name> <identity_value> <composition_name> <composition>] - [(def: .public <identity_name> + [(def .public <identity_name> Predicate (function.constant <identity_value>)) - (def: .public (<composition_name> left right) + (def .public (<composition_name> left right) (All (_ a) (-> (Predicate a) (Predicate a) (Predicate a))) (function (_ value) (<composition> (left value) @@ -27,35 +27,35 @@ ) (with_template [<name> <identity> <composition>] - [(def: .public <name> + [(def .public <name> (All (_ a) (Monoid (Predicate a))) (implementation - (def: identity <identity>) - (def: composite <composition>)))] + (def identity <identity>) + (def composite <composition>)))] [union ..none ..or] [intersection ..all ..and] ) -(def: .public (complement predicate) +(def .public (complement predicate) (All (_ a) (-> (Predicate a) (Predicate a))) (|>> predicate not)) -(def: .public (difference sub base) +(def .public (difference sub base) (All (_ a) (-> (Predicate a) (Predicate a) (Predicate a))) (function (_ value) (.and (base value) (not (sub value))))) -(def: .public (rec predicate) +(def .public (rec predicate) (All (_ a) (-> (-> (Predicate a) (Predicate a)) (Predicate a))) (function (again input) (predicate again input))) -(def: .public functor +(def .public functor (contravariant.Functor Predicate) (implementation - (def: (each f fb) + (def (each f fb) (|>> f fb)))) diff --git a/stdlib/source/library/lux/control/concatenative.lux b/stdlib/source/library/lux/control/concatenative.lux index 4661a546e..2fe9f788f 100644 --- a/stdlib/source/library/lux/control/concatenative.lux +++ b/stdlib/source/library/lux/control/concatenative.lux @@ -32,29 +32,29 @@ [#bottom (Maybe Code) #top (List Code)])) -(def: top +(def top (Parser (List Code)) (<code>.tuple (<>.some <code>.any))) -(def: bottom +(def bottom (Parser Code) (<code>.not ..top)) -(def: stack +(def stack (Parser Stack) (<>.either (<>.and (<>.maybe bottom) ..top) (<>.and (<>#each (|>> {.#Some}) bottom) (<>#in (list))))) -(def: (stack_type tops bottom) +(def (stack_type tops bottom) (-> (List Code) Code Code) (list#mix (function (_ top bottom) (` [(~ bottom) (~ top)])) bottom tops)) -(def: .public => +(def .public => (syntax (_ [inputs stack outputs stack]) (with_symbols [g!_ common_bottom] @@ -70,14 +70,14 @@ (` (-> (~ input_stack) (~ output_stack)))))))))) -(def: .public (value it) +(def .public (value it) (All (_ ,,, a) (-> (=> [] ,,, [a]) a)) (|> [] it product.right)) -(def: .public apply +(def .public apply (syntax (_ [arity (<>.only (n.> 0) <code>.nat)]) (with_symbols [g!_ g!func g!stack g!output] (monad.do [! meta.monad] @@ -90,65 +90,65 @@ [(~ g!stack) ((~ g!func) (~+ g!inputs))])))))))))) (with_template [<arity>] - [(`` (def: .public (~~ (template.symbol ["apply_" <arity>])) + [(`` (def .public (~~ (template.symbol ["apply_" <arity>])) (..apply <arity>)))] [1] [2] [3] [4] [5] [6] [7] [8] ) -(def: .public (push x) +(def .public (push x) (All (_ a) (-> a (=> [] [a]))) (function (_ stack) [stack x])) -(def: .public drop +(def .public drop (All (_ t) (=> [t] [])) (function (_ [stack top]) stack)) -(def: .public nip +(def .public nip (All (_ _ a) (=> [_ a] [a])) (function (_ [[stack _] top]) [stack top])) -(def: .public dup +(def .public dup (All (_ a) (=> [a] [a a])) (function (_ [stack top]) [[stack top] top])) -(def: .public swap +(def .public swap (All (_ a b) (=> [a b] [b a])) (function (_ [[stack l] r]) [[stack r] l])) -(def: .public left_rotation +(def .public left_rotation (All (_ a b c) (=> [a b c] [b c a])) (function (_ [[[stack a] b] c]) [[[stack b] c] a])) -(def: .public right_rotation +(def .public right_rotation (All (_ a b c) (=> [a b c] [c a b])) (function (_ [[[stack a] b] c]) [[[stack c] a] b])) -(def: .public && +(def .public && (All (_ a b) (=> [a b] [(Tuple a b)])) (function (_ [[stack l] r]) [stack [l r]])) -(def: .public left +(def .public left (All (_ a b) (=> [a] [(Or a b)])) (function (_ [stack l]) [stack {0 #0 l}])) -(def: .public right +(def .public right (All (_ a b) (=> [b] [(Or a b)])) (function (_ [stack r]) [stack {0 #1 r}])) (with_template [<input> <output> <word> <func>] - [(`` (def: .public <word> + [(`` (def .public <word> (=> [<input> <input>] [<output>]) (function (_ [[stack subject] param]) [stack (<func> param subject)])))] @@ -198,7 +198,7 @@ [Frac Bit f/>= f.>=] ) -(def: .public if +(def .public if (All (_ ,,,0 ,,,1) (type.let [then (=> ,,,0 ,,,1) else (=> ,,,0 ,,,1)] @@ -209,7 +209,7 @@ (then stack) (else stack)))) -(def: .public call +(def .public call (All (_ ,,,0 ,,,1) (type.let [quote (=> ,,,0 ,,,1)] (=> ,,,0 [quote] @@ -217,7 +217,7 @@ (function (_ [stack quote]) (quote stack))) -(def: .public loop +(def .public loop (All (_ ,,,) (type.let [test (=> ,,, ,,, [Bit])] @@ -229,21 +229,21 @@ (loop [stack' pred]) stack')))) -(def: .public dip +(def .public dip (All (_ ,,, a) (=> ,,, [a (=> ,,, ,,,)] ,,, [a])) (function (_ [[stack a] quote]) [(quote stack) a])) -(def: .public dip_2 +(def .public dip_2 (All (_ ,,, a b) (=> ,,, [a b (=> ,,, ,,,)] ,,, [a b])) (function (_ [[[stack a] b] quote]) [[(quote stack) a] b])) -(def: .public do +(def .public do (All (_ ,,,0 ,,,1) (type.let [body (=> ,,,0 ,,,1) pred (=> ,,,1 ,,,0 [Bit])] @@ -252,7 +252,7 @@ (function (_ [[stack pred] body]) [[(body stack) pred] body])) -(def: .public while +(def .public while (All (_ ,,,0 ,,,1) (type.let [body (=> ,,,1 ,,,0) pred (=> ,,,0 ,,,1 [Bit])] @@ -264,21 +264,21 @@ (while [[(body stack') pred] body]) stack')))) -(def: .public compose +(def .public compose (All (_ ,,,0 ,,, ,,,1) (=> [(=> ,,,0 ,,,) (=> ,,, ,,,1)] [(=> ,,,0 ,,,1)])) (function (_ [[stack f] g]) [stack (|>> f g)])) -(def: .public partial +(def .public partial (All (_ ,,,0 ,,,1 a) (=> ,,,0 [a (=> ,,,0 [a] ,,,1)] ,,,0 [(=> ,,,0 ,,,1)])) (function (_ [[stack arg] quote]) [stack (|>> (push arg) quote)])) -(def: .public when +(def .public when (All (_ ,,,) (type.let [body (=> ,,, ,,,)] (=> ,,, [Bit body] @@ -288,7 +288,7 @@ (push ..drop) if)) -(def: .public ? +(def .public ? (All (_ a) (=> [Bit a a] [a])) (|>> left_rotation diff --git a/stdlib/source/library/lux/control/concurrency/actor.lux b/stdlib/source/library/lux/control/concurrency/actor.lux index 40bc65ec2..e67bb3f2b 100644 --- a/stdlib/source/library/lux/control/concurrency/actor.lux +++ b/stdlib/source/library/lux/control/concurrency/actor.lux @@ -31,7 +31,7 @@ [(Rec Mailbox [(Async [(<Mail> Actor s) Mailbox]) (Resolver [(<Mail> Actor s) Mailbox])])])] - (these (def: (pending [read write]) + (these (def (pending [read write]) (All (_ a) (-> (Rec Mailbox [(Async [a Mailbox]) @@ -62,7 +62,7 @@ (type: .public (Behavior s) (-> (Mail s) s (Actor s) (Async (Try s)))) - (def: .public (spawn! behavior init) + (def .public (spawn! behavior init) (All (_ s) (-> (Behavior s) s (IO (Actor s)))) (io (let [self (sharing [s] (is (Behavior s) @@ -88,7 +88,7 @@ (again state' tail))))] self))) - (def: .public (alive? actor) + (def .public (alive? actor) (All (_ s) (-> (Actor s) (IO Bit))) (let [[obituary _] (the #obituary (representation actor))] (|> obituary @@ -101,18 +101,18 @@ _ bit.no)))))) - (def: .public (obituary' actor) + (def .public (obituary' actor) (All (_ s) (-> (Actor s) (IO (Maybe (Obituary s))))) (let [[obituary _] (the #obituary (representation actor))] (async.value obituary))) - (def: .public obituary + (def .public obituary (All (_ s) (-> (Actor s) (Async (Obituary s)))) (|>> representation (the #obituary) product.left)) - (def: .public (mail! mail actor) + (def .public (mail! mail actor) (All (_ s) (-> (Mail s) (Actor s) (IO (Try Any)))) (do [! io.monad] [alive? (..alive? actor)] @@ -140,7 +140,7 @@ (type: .public (Message s o) (-> s (Actor s) (Async (Try [s o])))) - (def: (mail message) + (def (mail message) (All (_ s o) (-> (Message s o) [(Async (Try o)) (Mail s)])) (let [[async resolve] (sharing [s o] (is (Message s o) @@ -163,7 +163,7 @@ (io.run! (resolve {try.#Failure error})) (async.resolved {try.#Failure error})))))])) - (def: .public (tell! message actor) + (def .public (tell! message actor) (All (_ s o) (-> (Message s o) (Actor s) (Async (Try o)))) (let [[async mail] (..mail message)] (do async.monad @@ -176,12 +176,12 @@ (in {try.#Failure error}))))) ))) -(def: .public default +(def .public default Behavior (function (_ mail state self) (mail state self))) -(def: .public (poison! actor) +(def .public (poison! actor) (All (_ s) (-> (Actor s) (IO (Try Any)))) (..mail! (function (_ state self) (async.resolved (exception.except ..poisoned []))) @@ -190,10 +190,10 @@ (type: .public Stop (IO Any)) -(def: continue! true) -(def: stop! false) +(def continue! true) +(def stop! false) -(def: .public (observe! action channel actor) +(def .public (observe! action channel actor) (All (_ r w s) (-> (-> r Stop (Mail s)) (Channel' r w) (Actor s) (IO Any))) (let [signal (is (Atom Bit) (atom.atom ..continue!)) diff --git a/stdlib/source/library/lux/control/concurrency/async.lux b/stdlib/source/library/lux/control/concurrency/async.lux index 192c4e24c..11020adad 100644 --- a/stdlib/source/library/lux/control/concurrency/async.lux +++ b/stdlib/source/library/lux/control/concurrency/async.lux @@ -34,7 +34,7 @@ (-> w (IO Bit))) ... Sets an async's value if it has not been done yet. - (def: (resolver async) + (def (resolver async) (All (_ r w) (-> (Async' r w) (Resolver w))) (function (resolve value) (let [async (representation async)] @@ -54,23 +54,23 @@ (in #1)) (resolve value)))))))) - (def: .public (resolved value) + (def .public (resolved value) (All (_ a) (-> a (Async a))) (abstraction (atom [{.#Some (variance.write value)} (list)]))) - (def: .public (async _) + (def .public (async _) (All (_ r w) (-> Any [(Async' r w) (Resolver w)])) (let [async (abstraction (atom [{.#None} (list)]))] [async (..resolver async)])) - (def: .public value + (def .public value (All (_ r w) (-> (Async' r w) (IO (Maybe r)))) (|>> representation atom.read! (at io.functor each (|>> product.left (maybe#each (|>> variance.read)))))) - (def: .public (upon! f async) + (def .public (upon! f async) (All (_ r w) (-> (-> r (IO Any)) (Async' r w) (IO Any))) (do [! io.monad] [.let [async (representation async)] @@ -87,7 +87,7 @@ (upon! f (abstraction async))))))) ) -(def: .public resolved? +(def .public resolved? (All (_ r w) (-> (Async' r w) (IO Bit))) (|>> ..value (at io.functor each @@ -98,10 +98,10 @@ {.#Some _} #1))))) -(def: .public functor +(def .public functor (Functor Async) (implementation - (def: (each f fa) + (def (each f fa) (let [[fb resolve] (sharing [a b] (is (-> a b) f) @@ -111,12 +111,12 @@ (io.run! (..upon! (|>> f resolve) fa)) fb))))) -(def: .public apply +(def .public apply (Apply Async) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (let [[fb resolve] (sharing [a b] (is (Async (-> a b)) ff) @@ -128,14 +128,14 @@ ff)) fb))))) -(def: .public monad +(def .public monad (Monad Async) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: in ..resolved) + (def in ..resolved) - (def: (conjoint mma) + (def (conjoint mma) (let [[ma resolve] (sharing [a] (is (Async (Async a)) mma) @@ -145,7 +145,7 @@ (io.run! (..upon! (..upon! resolve) mma)) ma))))) -(def: .public (and left right) +(def .public (and left right) (All (_ lr lw rr rw) (-> (Async' lr lw) (Async' rr rw) (Async [lr rr]))) (let [[read! write!] (sharing [lr lw rr rw] (is [(Async' lr lw) (Async' rr rw)] @@ -159,7 +159,7 @@ left))] read!)) -(def: .public (or left right) +(def .public (or left right) (All (_ lr lw rr rw) (-> (Async' lr lw) (Async' rr rw) (Async (Or lr rr)))) (let [[left|right resolve] (sharing [lr lw rr rw] (is [(Async' lr lw) (Async' rr rw)] @@ -177,7 +177,7 @@ <sides> left|right)))) -(def: .public (either left right) +(def .public (either left right) (All (_ a lw rw) (-> (Async' a lw) (Async' a rw) (Async a))) (let [[left||right resolve] (sharing [a lw rw] (is [(Async' a lw) (Async' a rw)] @@ -192,7 +192,7 @@ [right])) left||right)))) -(def: .public (schedule! milli_seconds computation) +(def .public (schedule! milli_seconds computation) (All (_ a) (-> Nat (IO a) (Async a))) (let [[!out resolve] (sharing [a] (is (IO a) @@ -207,19 +207,19 @@ io.run!) !out))) -(def: .public future +(def .public future (All (_ a) (-> (IO a) (Async a))) (..schedule! 0)) -(def: .public (after milli_seconds value) +(def .public (after milli_seconds value) (All (_ a) (-> Nat a (Async a))) (..schedule! milli_seconds (io value))) -(def: .public (delay milli_seconds) +(def .public (delay milli_seconds) (-> Nat (Async Any)) (..after milli_seconds [])) -(def: .public (within milli_seconds async) +(def .public (within milli_seconds async) (All (_ r w) (-> Nat (Async' r w) (Async (Maybe r)))) (..or (..delay milli_seconds) async)) diff --git a/stdlib/source/library/lux/control/concurrency/atom.lux b/stdlib/source/library/lux/control/concurrency/atom.lux index 86399e1a6..e98479e10 100644 --- a/stdlib/source/library/lux/control/concurrency/atom.lux +++ b/stdlib/source/library/lux/control/concurrency/atom.lux @@ -38,7 +38,7 @@ (type: .public (Atom a) (Atom'' (Mutable a a))) - (def: .public (atom value) + (def .public (atom value) (All (_ a) (-> a (Atom a))) (abstraction (with_expansions [<jvm> (as_expected (java/util/concurrent/atomic/AtomicReference::new value))] @@ -46,14 +46,14 @@ @.jvm <jvm> (array.has! 0 (variance.write value) (array.empty 1)))))) - (def: .public (read! atom) + (def .public (read! atom) (All (_ r w) (-> (Atom' r w) (IO r))) (with_expansions [<jvm> (java/util/concurrent/atomic/AtomicReference::get (representation atom))] (io.io (for @.old (variance.read <jvm>) @.jvm <jvm> (variance.read (array.item 0 (representation atom))))))) - (def: .public (compare_and_swap! current new atom) + (def .public (compare_and_swap! current new atom) (All (_ r w) (-> r w (Atom' r w) (IO Bit))) (io.io (for @.old (ffi.of_boolean (java/util/concurrent/atomic/AtomicReference::compareAndSet (variance.write @@ -73,7 +73,7 @@ false)))) ) -(def: .public (update! f atom) +(def .public (update! f atom) (All (_ r w) (-> (-> r w) (Atom' r w) (IO [r w]))) (loop (again [_ []]) (do io.monad @@ -84,7 +84,7 @@ (in [old new]) (again []))))) -(def: .public (write! value atom) +(def .public (write! value atom) (All (_ r w) (-> w (Atom' r w) (IO r))) (|> atom (..update! (function.constant value)) diff --git a/stdlib/source/library/lux/control/concurrency/frp.lux b/stdlib/source/library/lux/control/concurrency/frp.lux index 43aae713f..16ef2927c 100644 --- a/stdlib/source/library/lux/control/concurrency/frp.lux +++ b/stdlib/source/library/lux/control/concurrency/frp.lux @@ -35,13 +35,13 @@ (is (-> w (IO (Try Any))) feed))) -(def: (sink resolution) +(def (sink resolution) (All (_ a) (-> (async.Resolver (Maybe [(Mutable a a) (Channel a)])) (Sink a))) (let [sink (atom.atom resolution)] (implementation - (def: close + (def close (loop (again [_ []]) (do [! io.monad] [current (atom.read! sink) @@ -58,7 +58,7 @@ ... Someone else fed the sink while I was closing it. (again []))))))) - (def: (feed value) + (def (feed value) (loop (again [_ []]) (do [! io.monad] [current (atom.read! sink) @@ -83,27 +83,27 @@ ... Someone else fed the sink. (again [])))))))))) -(def: .public (channel _) +(def .public (channel _) (All (_ a) (-> Any [(Channel a) (Sink a)])) (let [[async resolve] (async.async [])] [async (..sink resolve)])) -(def: .public functor +(def .public functor (Functor Channel) (implementation - (def: (each f) + (def (each f) (async#each (maybe#each (function (_ [head tail]) [(variance.write (f (variance.read head))) (each f tail)])))))) -(def: .public apply +(def .public apply (Apply Channel) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (do async.monad [item_f ff item_a fa] @@ -115,19 +115,19 @@ _ (in {.#None})))))) -(def: empty +(def empty Channel (async.resolved {.#None})) -(def: .public monad +(def .public monad (Monad Channel) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in a) + (def (in a) (async.resolved {.#Some [(variance.write a) ..empty]})) - (def: (conjoint mma) + (def (conjoint mma) (let [[output sink] (sharing [a] (is (Channel (Channel a)) mma) @@ -161,7 +161,7 @@ (type: .public (Subscriber a) (-> a (IO (Maybe Any)))) -(def: .public (subscribe! subscriber channel) +(def .public (subscribe! subscriber channel) (All (_ r w) (-> (Subscriber r) (Channel' r w) (IO Any))) (io (exec (is (Async Any) @@ -181,7 +181,7 @@ (in []))))) []))) -(def: .public (only pass? channel) +(def .public (only pass? channel) (All (_ a) (-> (-> a Bit) (Channel a) (Channel a))) (do async.monad [item channel] @@ -195,13 +195,13 @@ {.#None} (in {.#None})))) -(def: .public (of_async async) +(def .public (of_async async) (All (_ a) (-> (Async a) (Channel a))) (async#each (function (_ value) {.#Some [(variance.write value) ..empty]}) async)) -(def: .public (mix f init channel) +(def .public (mix f init channel) (All (_ a b) (-> (-> b a (Async a)) a (Channel b) (Async a))) @@ -216,7 +216,7 @@ [init' (f (variance.read head) init)] (mix f init' tail))))) -(def: .public (mixes f init channel) +(def .public (mixes f init channel) (All (_ a b) (-> (-> b a (Async a)) a (Channel b) (Channel a))) @@ -234,7 +234,7 @@ [init' (f (variance.read head) init)] (mixes f init' tail)))))) -(def: .public (poll milli_seconds action) +(def .public (poll milli_seconds action) (All (_ a) (-> Nat (IO a) [(Channel a) (Sink a)])) (let [[output sink] (channel [])] @@ -246,11 +246,11 @@ (async.upon! again (async.delay milli_seconds))))) [output sink]))) -(def: .public (periodic milli_seconds) +(def .public (periodic milli_seconds) (-> Nat [(Channel Any) (Sink Any)]) (..poll milli_seconds (io []))) -(def: .public (iterations f init) +(def .public (iterations f init) (All (_ s o) (-> (-> s (Async (Maybe [s o]))) s (Channel o))) (do async.monad [?next (f init)] @@ -261,7 +261,7 @@ {.#None} {.#None})))) -(def: (distinct' equivalence previous channel) +(def (distinct' equivalence previous channel) (All (_ a) (-> (Equivalence a) a (Channel a) (Channel a))) (do async.monad [item channel] @@ -274,7 +274,7 @@ {.#None} (in {.#None})))) -(def: .public (distinct equivalence channel) +(def .public (distinct equivalence channel) (All (_ a) (-> (Equivalence a) (Channel a) (Channel a))) (do async.monad [item channel] @@ -285,7 +285,7 @@ {.#None} {.#None})))) -(def: .public (list channel) +(def .public (list channel) (All (_ a) (-> (Channel a) (Async (List a)))) (do [! async.monad] [item channel] @@ -297,7 +297,7 @@ {.#None} (in {.#End})))) -(def: .public (sequential milli_seconds values) +(def .public (sequential milli_seconds values) (All (_ a) (-> Nat (List a) (Channel a))) (case values {.#End} diff --git a/stdlib/source/library/lux/control/concurrency/semaphore.lux b/stdlib/source/library/lux/control/concurrency/semaphore.lux index 5cf050d4b..fbfacf228 100644 --- a/stdlib/source/library/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/library/lux/control/concurrency/semaphore.lux @@ -33,10 +33,10 @@ (primitive .public Semaphore (Atom State) - (def: most_positions_possible + (def most_positions_possible (.nat (at i.interval top))) - (def: .public (semaphore initial_open_positions) + (def .public (semaphore initial_open_positions) (-> Nat Semaphore) (let [max_positions (n.min initial_open_positions ..most_positions_possible)] @@ -44,7 +44,7 @@ #open_positions (.int max_positions) #waiting_list queue.empty])))) - (def: .public (wait! semaphore) + (def .public (wait! semaphore) (Ex (_ k) (-> Semaphore (Async Any))) (let [semaphore (representation semaphore) [signal sink] (is [(Async Any) (Resolver Any)] @@ -69,7 +69,7 @@ (exception.report "Max Positions" (%.nat max_positions))) - (def: .public (signal! semaphore) + (def .public (signal! semaphore) (Ex (_ k) (-> Semaphore (Async (Try Int)))) (let [semaphore (representation semaphore)] (async.future @@ -97,19 +97,19 @@ (primitive .public Mutex Semaphore - (def: .public (mutex _) + (def .public (mutex _) (-> Any Mutex) (abstraction (semaphore 1))) - (def: acquire! + (def acquire! (-> Mutex (Async Any)) (|>> representation ..wait!)) - (def: release! + (def release! (-> Mutex (Async (Try Int))) (|>> representation ..signal!)) - (def: .public (synchronize! mutex procedure) + (def .public (synchronize! mutex procedure) (All (_ a) (-> Mutex (IO (Async a)) (Async a))) (do async.monad [_ (..acquire! mutex) @@ -118,7 +118,7 @@ (in output))) ) -(def: .public limit +(def .public limit (refinement.refiner (n.> 0))) (type: .public Limit @@ -131,14 +131,14 @@ #start_turnstile Semaphore #end_turnstile Semaphore]) - (def: .public (barrier limit) + (def .public (barrier limit) (-> Limit Barrier) (abstraction [#limit limit #count (atom.atom 0) #start_turnstile (..semaphore 0) #end_turnstile (..semaphore 0)])) - (def: (un_block! times turnstile) + (def (un_block! times turnstile) (-> Nat Semaphore (Async Any)) (loop (again [step 0]) (if (n.< times step) @@ -148,7 +148,7 @@ (at async.monad in [])))) (with_template [<phase> <update> <goal> <turnstile>] - [(def: (<phase> barrier) + [(def (<phase> barrier) (-> Barrier (Async Any)) (do async.monad [.let [barrier (representation barrier) @@ -164,7 +164,7 @@ [end! -- 0 #end_turnstile] ) - (def: .public (block! barrier) + (def .public (block! barrier) (-> Barrier (Async Any)) (do async.monad [_ (..start! barrier)] diff --git a/stdlib/source/library/lux/control/concurrency/stm.lux b/stdlib/source/library/lux/control/concurrency/stm.lux index 2a0ae3956..87dd101c9 100644 --- a/stdlib/source/library/lux/control/concurrency/stm.lux +++ b/stdlib/source/library/lux/control/concurrency/stm.lux @@ -35,15 +35,15 @@ (type: .public (Var a) (Var'' (Mutable a a))) - (def: .public (var value) + (def .public (var value) (All (_ a) (-> a (Var a))) (abstraction (atom.atom [(variance.write value) (list)]))) - (def: read! + (def read! (All (_ r w) (-> (Var' r w) r)) (|>> representation atom.read! io.run! product.left variance.read)) - (def: (write! new_value var) + (def (write! new_value var) (All (_ r w) (-> w (Var' r w) (IO Any))) (do [! io.monad] [.let [var' (representation var)] @@ -70,7 +70,7 @@ (in [])) (write! new_value var)))) - (def: .public (changes target) + (def .public (changes target) (All (_ a) (-> (Var a) (IO [(Channel a) (Sink a)]))) (do io.monad [.let [[channel sink] (sharing [a] @@ -80,8 +80,8 @@ (frp.channel [])))] _ (atom.update! (function (_ [value observers]) [value {.#Item (implementation - (def: close (at sink close)) - (def: feed (|>> variance.read (at sink feed)))) + (def close (at sink close)) + (def feed (|>> variance.read (at sink feed)))) observers}]) (representation target))] (in [channel sink]))) @@ -99,7 +99,7 @@ (type: .public (STM a) (-> Tx [Tx a])) -(def: (var_value var tx) +(def (var_value var tx) (All (_ r w) (-> (Var' r w) Tx (Maybe r))) (|> tx (list.example (function (_ [_var _original _current]) @@ -109,7 +109,7 @@ _current)) as_expected)) -(def: .public (read var) +(def .public (read var) (All (_ r w) (-> (Var' r w) (STM r))) (function (_ tx) (case (var_value var tx) @@ -124,7 +124,7 @@ tx} value])))) -(def: (with_updated_var var value tx) +(def (with_updated_var var value tx) (All (_ r w) (-> (Var' r w) w Tx Tx)) (case tx {.#End} @@ -142,7 +142,7 @@ #current _current] (with_updated_var var value tx')}))) -(def: .public (write value var) +(def .public (write value var) (All (_ r w) (-> w (Var' r w) (STM Any))) (function (_ tx) (case (var_value var tx) @@ -157,40 +157,40 @@ tx} []]))) -(def: .public functor +(def .public functor (Functor STM) (implementation - (def: (each f fa) + (def (each f fa) (function (_ tx) (let [[tx' a] (fa tx)] [tx' (f a)]))))) -(def: .public apply +(def .public apply (Apply STM) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (function (_ tx) (let [[tx' f] (ff tx) [tx'' a] (fa tx')] [tx'' (f a)]))))) -(def: .public monad +(def .public monad (Monad STM) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in a) + (def (in a) (function (_ tx) [tx a])) - (def: (conjoint mma) + (def (conjoint mma) (function (_ tx) (let [[tx' ma] (mma tx)] (ma tx')))))) -(def: .public (update f var) +(def .public (update f var) (All (_ r w) (-> (-> r w) (Var' r w) (STM [r w]))) (do ..monad [before (..read var) @@ -198,36 +198,36 @@ _ (..write after var)] (in [before after]))) -(def: (can_commit? tx) +(def (can_commit? tx) (-> Tx Bit) (list.every? (function (_ [_var _original _current]) (same? _original (..read! _var))) tx)) -(def: (commit_var! [_var _original _current]) +(def (commit_var! [_var _original _current]) (-> (Ex (_ r w) (Tx_Frame r w)) (IO Any)) (if (same? (as Any _original) (as Any _current)) (io []) (..write! _current _var))) -(def: fresh_tx Tx (list)) +(def fresh_tx Tx (list)) (type: (Commit a) [(STM a) (Async a) (Resolver a)]) -(def: pending_commits +(def pending_commits (Atom (Rec Commits [(Async [(Ex (_ a) (Commit a)) Commits]) (Resolver [(Ex (_ a) (Commit a)) Commits])])) (atom (async.async []))) -(def: commit_processor_flag +(def commit_processor_flag (Atom Bit) (atom #0)) -(def: (issue_commit! commit) +(def (issue_commit! commit) (All (_ a) (-> (Commit a) (IO Any))) (let [entry [commit (async.async [])]] (do [! io.monad] @@ -246,7 +246,7 @@ {.#Some [head tail]} (again tail))))))) -(def: (process_commit! commit) +(def (process_commit! commit) (All (_ a) (-> (Commit a) (IO Any))) (let [[stm_proc output resolve] commit [finished_tx value] (stm_proc fresh_tx)] @@ -256,7 +256,7 @@ (resolve value)) (..issue_commit! commit)))) -(def: start_commit_processor! +(def start_commit_processor! (IO Any) (do [! io.monad] [flag (atom.read! commit_processor_flag)] @@ -275,7 +275,7 @@ (in []))) ))) -(def: .public (commit! stm_proc) +(def .public (commit! stm_proc) (All (_ a) (-> (STM a) (Async a))) (let [[output resolver] (async.async [])] (exec diff --git a/stdlib/source/library/lux/control/concurrency/thread.lux b/stdlib/source/library/lux/control/concurrency/thread.lux index 4428f9daa..030e0c053 100644 --- a/stdlib/source/library/lux/control/concurrency/thread.lux +++ b/stdlib/source/library/lux/control/concurrency/thread.lux @@ -73,7 +73,7 @@ #action (IO Any)])) )) -(def: .public parallelism +(def .public parallelism Nat (with_expansions [<default> 1 <jvm> (<| (configuration.for ["lua_compiler?" ""] @@ -88,7 +88,7 @@ ... Default <default>))) -(with_expansions [<jvm> (these (def: runner +(with_expansions [<jvm> (these (def runner java/util/concurrent/ScheduledThreadPoolExecutor (|> ..parallelism .int @@ -100,14 +100,14 @@ @.python (these) ... Default - (these (def: started? + (these (def started? (Atom Bit) (atom.atom false)) - (def: runner + (def runner (Atom (List Thread)) (atom.atom (list)))))) -(def: (execute! action) +(def (execute! action) (-> (IO Any) Any) (case (try (io.run! action)) {try.#Failure error} @@ -120,7 +120,7 @@ {try.#Success _} [])) -(def: .public (schedule! milli_seconds action) +(def .public (schedule! milli_seconds action) (-> Nat (IO Any) (IO Any)) (with_expansions [<jvm> (let [runnable (ffi.object [] [java/lang/Runnable] [] @@ -163,7 +163,7 @@ ... https://en.wikipedia.org/wiki/Event_loop ... Starts the event-loop. - (def: .public run! + (def .public run! (IO Any) (do [! io.monad] [started? (atom.read! ..started?)] diff --git a/stdlib/source/library/lux/control/continuation.lux b/stdlib/source/library/lux/control/continuation.lux index 3cbd80b92..5c3ac3e9c 100644 --- a/stdlib/source/library/lux/control/continuation.lux +++ b/stdlib/source/library/lux/control/continuation.lux @@ -16,15 +16,15 @@ (type: .public (Cont i o) (-> (-> i o) o)) -(def: .public (continued next cont) +(def .public (continued next cont) (All (_ i o) (-> (-> i o) (Cont i o) o)) (cont next)) -(def: .public result +(def .public result (All (_ a) (-> (Cont a a) a)) (..continued function.identity)) -(def: .public (with_current f) +(def .public (with_current f) (All (_ a b z) (-> (-> (-> a (Cont b z)) (Cont a z)) @@ -33,17 +33,17 @@ (f (function (_ a) (function (_ _) (k a))) k))) -(def: .public pending +(def .public pending (syntax (_ [expr <code>.any]) (with_symbols [g!_ g!k] (in (list (` (.function ((~ g!_) (~ g!k)) ((~ g!k) (~ expr))))))))) -(def: .public (reset scope) +(def .public (reset scope) (All (_ i o) (-> (Cont i i) (Cont i o))) (function (_ k) (k (result scope)))) -(def: .public (shift f) +(def .public (shift f) (All (_ a) (-> (-> (-> a (Cont a a)) (Cont a a)) @@ -52,37 +52,37 @@ (f (function (_ a) (function (_ ic) (ic (oc a)))) function.identity))) -(def: .public functor +(def .public functor (All (_ o) (Functor (All (_ i) (Cont i o)))) (implementation - (def: (each f fv) + (def (each f fv) (function (_ k) (fv (function.composite k f)))))) -(def: .public apply +(def .public apply (All (_ o) (Apply (All (_ i) (Cont i o)))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fv ff) + (def (on fv ff) (function (_ k) (|> (k (f v)) (function (_ v)) fv (function (_ f)) ff))))) -(def: .public monad +(def .public monad (All (_ o) (Monad (All (_ i) (Cont i o)))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in value) + (def (in value) (function (_ k) (k value))) - (def: (conjoint ffa) + (def (conjoint ffa) (function (_ k) (ffa (continued k)))))) -(def: .public (portal init) +(def .public (portal init) (All (_ i o z) (-> i (Cont [(-> i (Cont o z)) diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux index 81e46e66d..f80419c98 100644 --- a/stdlib/source/library/lux/control/exception.lux +++ b/stdlib/source/library/lux/control/exception.lux @@ -31,11 +31,11 @@ [#label Text #constructor (-> a Text)])) -(def: .public (match? exception error) +(def .public (match? exception error) (All (_ e) (-> (Exception e) Text Bit)) (text.starts_with? (the #label exception) error)) -(def: .public (when exception then try) +(def .public (when exception then try) (All (_ e a) (-> (Exception e) (-> Text a) (Try a) (Try a))) @@ -52,7 +52,7 @@ then)} {//.#Failure error})))) -(def: .public (otherwise else try) +(def .public (otherwise else try) (All (_ a) (-> (-> Text a) (Try a) a)) (case try @@ -62,21 +62,21 @@ {//.#Failure error} (else error))) -(def: .public (error exception message) +(def .public (error exception message) (All (_ e) (-> (Exception e) e Text)) ((the ..#constructor exception) message)) -(def: .public (except exception message) +(def .public (except exception message) (All (_ e a) (-> (Exception e) e (Try a))) {//.#Failure (..error exception message)}) -(def: .public (assertion exception message test) +(def .public (assertion exception message test) (All (_ e) (-> (Exception e) e Bit (Try Any))) (if test {//.#Success []} (..except exception message))) -(def: exception +(def exception (Parser [Code (List |type_variable|.Variable) [Text (List |input|.Input)] (Maybe Code)]) (let [private (is (Parser [(List |type_variable|.Variable) [Text (List |input|.Input)] (Maybe Code)]) (all <>.and @@ -90,14 +90,14 @@ (<>.and (<>#in (` .private)) private) ))) -(def: .public exception: +(def .public exception: (syntax (_ [[export_policy t_vars [name inputs] body] ..exception]) (macro.with_symbols [g!_ g!descriptor] (do meta.monad [current_module meta.current_module_name .let [descriptor (all text#composite "{" current_module "." name "}" text.new_line) g!self (code.local name)]] - (in (list (` (def: (~ export_policy) + (in (list (` (def (~ export_policy) (~ g!self) (All ((~ g!_) (~+ (list#each |type_variable|.format t_vars))) (..Exception [(~+ (list#each (the |input|.#type) inputs))])) @@ -107,7 +107,7 @@ ((~! text#composite) (~ g!descriptor) (~ (maybe.else (' "") body))))]))))))))) -(def: (report' entries) +(def (report' entries) (-> (List [Text Text]) Text) (let [header_separator ": " largest_header_size (list#mix (function (_ [header _] max) @@ -138,13 +138,13 @@ (on_entry head) tail)))) -(def: .public report +(def .public report (syntax (_ [entries (<>.many (<>.and <code>.any <code>.any))]) (in (list (` ((~! ..report') (list (~+ (|> entries (list#each (function (_ [header message]) (` [(~ header) (~ message)])))))))))))) -(def: .public (listing format entries) +(def .public (listing format entries) (All (_ a) (-> (-> a Text) (List a) Text)) (|> entries @@ -157,7 +157,7 @@ list.reversed ..report')) -(def: separator +(def separator (let [gap (all "lux text concat" text.new_line text.new_line) horizontal_line (|> "-" (list.repeated 64) text.together)] (all "lux text concat" @@ -165,14 +165,14 @@ horizontal_line gap))) -(def: (decorated prelude error) +(def (decorated prelude error) (-> Text Text Text) (all "lux text concat" prelude ..separator error)) -(def: .public (with exception message computation) +(def .public (with exception message computation) (All (_ e a) (-> (Exception e) e (Try a) (Try a))) (case computation {//.#Failure error} diff --git a/stdlib/source/library/lux/control/function.lux b/stdlib/source/library/lux/control/function.lux index 15cd56f93..bbf4969b3 100644 --- a/stdlib/source/library/lux/control/function.lux +++ b/stdlib/source/library/lux/control/function.lux @@ -4,31 +4,31 @@ [abstract [monoid (.only Monoid)]]]]) -(def: .public identity +(def .public identity (All (_ a) (-> a a)) (|>>)) -(def: .public (composite f g) +(def .public (composite f g) (All (_ a b c) (-> (-> b c) (-> a b) (-> a c))) (|>> g f)) -(def: .public (constant value) +(def .public (constant value) (All (_ o) (-> o (All (_ i) (-> i o)))) (function (_ _) value)) -(def: .public (flipped f) +(def .public (flipped f) (All (_ a b c) (-> (-> a b c) (-> b a c))) (function (_ x y) (f y x))) -(def: .public (on input function) +(def .public (on input function) (All (_ i o) (-> i (-> i o) o)) (function input)) -(def: .public monoid +(def .public monoid (All (_ a) (Monoid (-> a a))) (implementation - (def: identity ..identity) - (def: composite ..composite))) + (def identity ..identity) + (def composite ..composite))) diff --git a/stdlib/source/library/lux/control/function/contract.lux b/stdlib/source/library/lux/control/function/contract.lux index 753a90460..4bae3020d 100644 --- a/stdlib/source/library/lux/control/function/contract.lux +++ b/stdlib/source/library/lux/control/function/contract.lux @@ -24,13 +24,13 @@ [post_condition_failed] ) -(def: (assert! message test) +(def (assert! message test) (-> Text Bit []) (if test [] (panic! message))) -(def: .public pre +(def .public pre (syntax (_ [test <code>.any expr <code>.any]) (in (list (` (exec @@ -38,7 +38,7 @@ (~ test)) (~ expr))))))) -(def: .public post +(def .public post (syntax (_ [test <code>.any expr <code>.any]) (with_symbols [g!output] diff --git a/stdlib/source/library/lux/control/function/inline.lux b/stdlib/source/library/lux/control/function/inline.lux index e171f1f87..9481dd27c 100644 --- a/stdlib/source/library/lux/control/function/inline.lux +++ b/stdlib/source/library/lux/control/function/inline.lux @@ -15,11 +15,11 @@ [syntax (.only syntax) ["|[0]|" export]]]]]) -(def: declaration +(def declaration (Parser [Text (List Code)]) (<code>.form (<>.and <code>.local (<>.some <code>.any)))) -(def: inline +(def inline (Parser [Code [Text (List Code)] Code Code]) (|export|.parser (all <>.and @@ -28,7 +28,7 @@ <code>.any ))) -(def: .public inline: +(def .public inlined (syntax (_ [[privacy [name parameters] type term] ..inline]) (do [! meta.monad] [@ meta.current_module_name @@ -47,6 +47,6 @@ (list#each (function (_ parameter) (list parameter (` (~! <code>.any))))) list#conjoint)]] - (in (list (` (def: (~ privacy) (~ (code.local name)) + (in (list (` (def (~ privacy) (~ (code.local name)) ((~! syntax) ((~ (code.local name)) [(~+ g!parameters)]) (.at (~! meta.monad) (~' in) (.list (.`' (~ inlined)))))))))))) diff --git a/stdlib/source/library/lux/control/function/memo.lux b/stdlib/source/library/lux/control/function/memo.lux index 47ed679d5..60c464887 100644 --- a/stdlib/source/library/lux/control/function/memo.lux +++ b/stdlib/source/library/lux/control/function/memo.lux @@ -17,7 +17,7 @@ ["[0]" // ["[1]" mixin (.only Mixin Recursive)]]) -(def: .public memoization +(def .public memoization (All (_ i o) (Mixin i (State (Dictionary i o) o))) (function (_ delegate recur) @@ -37,7 +37,7 @@ (type: .public (Memo i o) (Recursive i (State (Dictionary i o) o))) -(def: .public (open memo) +(def .public (open memo) (All (_ i o) (type.let [Memory (Dictionary i o)] (-> (Memo i o) (-> [Memory i] [Memory o])))) @@ -45,14 +45,14 @@ (function (_ [memory input]) (|> input memo (state.result memory))))) -(def: .public (closed hash memo) +(def .public (closed hash memo) (All (_ i o) (-> (Hash i) (Memo i o) (-> i o))) (let [memo (//.fixed (//.mixed ..memoization (//.of_recursive memo))) empty (dictionary.empty hash)] (|>> memo (state.result empty) product.right))) -(def: .public (none hash memo) +(def .public (none hash memo) (All (_ i o) (-> (Hash i) (Memo i o) (-> i o))) (let [memo (//.fixed (//.of_recursive memo)) diff --git a/stdlib/source/library/lux/control/function/mixin.lux b/stdlib/source/library/lux/control/function/mixin.lux index d23e86e04..44796c733 100644 --- a/stdlib/source/library/lux/control/function/mixin.lux +++ b/stdlib/source/library/lux/control/function/mixin.lux @@ -12,42 +12,42 @@ (type: .public (Mixin i o) (-> (-> i o) (-> i o) (-> i o))) -(def: .public (fixed f) +(def .public (fixed f) (All (_ i o) (-> (Mixin i o) (-> i o))) (function (mix input) ((f mix mix) input))) -(def: .public nothing +(def .public nothing Mixin (function (_ delegate recur) delegate)) -(def: .public (mixed parent child) +(def .public (mixed parent child) (All (_ i o) (-> (Mixin i o) (Mixin i o) (Mixin i o))) (function (_ delegate recur) (parent (child delegate recur) recur))) -(def: .public monoid +(def .public monoid (All (_ i o) (Monoid (Mixin i o))) (implementation - (def: identity ..nothing) - (def: composite ..mixed))) + (def identity ..nothing) + (def composite ..mixed))) -(def: .public (advice when then) +(def .public (advice when then) (All (_ i o) (-> (Predicate i) (Mixin i o) (Mixin i o))) (function (_ delegate recur input) (if (when input) ((then delegate recur) input) (delegate input)))) -(def: .public (before monad action) +(def .public (before monad action) (All (_ ! i o) (-> (Monad !) (-> i (! Any)) (Mixin i (! o)))) (function (_ delegate recur input) (do monad [_ (action input)] (delegate input)))) -(def: .public (after monad action) +(def .public (after monad action) (All (_ ! i o) (-> (Monad !) (-> i o (! Any)) (Mixin i (! o)))) (function (_ delegate recur input) (do monad @@ -58,7 +58,7 @@ (type: .public (Recursive i o) (-> (-> i o) (-> i o))) -(def: .public (of_recursive recursive) +(def .public (of_recursive recursive) (All (_ i o) (-> (Recursive i o) (Mixin i o))) (function (_ delegate recur) (recursive recur))) diff --git a/stdlib/source/library/lux/control/function/mutual.lux b/stdlib/source/library/lux/control/function/mutual.lux index bdf3fbde9..d0b03aa08 100644 --- a/stdlib/source/library/lux/control/function/mutual.lux +++ b/stdlib/source/library/lux/control/function/mutual.lux @@ -1,6 +1,6 @@ (.using [library - [lux (.except Definition let def: macro) + [lux (.except Definition let def macro) ["[0]" meta] [abstract ["[0]" monad (.only do)]] @@ -30,7 +30,7 @@ #type Code #body Code])) -(.def: mutual +(.def mutual (Parser [Declaration Code Code]) (all <>.and declaration.parser @@ -38,21 +38,21 @@ <code>.any )) -(.def: (mutual_definition context g!context [g!name mutual]) +(.def (mutual_definition context g!context [g!name mutual]) (-> (List Code) Code [Code Mutual] Code) (` (function ((~ g!name) (~ g!context)) (.let [[(~+ context)] (~ g!context)] (function (~ (declaration.format (the #declaration mutual))) (~ (the #body mutual))))))) -(.def: (macro g!context g!self) +(.def (macro g!context g!self) (-> Code Code Macro) (<| (as Macro) (is Macro') (function (_ parameters) (at meta.monad in (list (` (((~ g!self) (~ g!context)) (~+ parameters)))))))) -(.def: .public let +(.def .public let (syntax (_ [functions (<code>.tuple (<>.some ..mutual)) body <code>.any]) (case functions @@ -101,12 +101,12 @@ [#export_policy Code #mutual Mutual])) -(.def: definition +(.def definition (Parser Definition) (<code>.tuple (<>.either (<>.and <code>.any ..mutual) (<>.and (<>#in (` .private)) ..mutual)))) -(.def: .public def: +(.def .public def (syntax (_ [functions (<>.many ..definition)]) (case functions {.#End} @@ -115,7 +115,7 @@ {.#Item definition {.#End}} (.let [(open "_[0]") definition (open "_[0]") _#mutual] - (in (list (` (.def: (~ _#export_policy) (~ (declaration.format _#declaration)) + (in (list (` (.def (~ _#export_policy) (~ (declaration.format _#declaration)) (~ _#type) (~ _#body)))))) @@ -138,7 +138,7 @@ (..macro g!context g!name)]) (list.zipped_2 hidden_names functions)))] - (in (list.partial (` (.def: (~ g!context) + (in (list.partial (` (.def (~ g!context) [(~+ (list#each (the [#mutual #type]) functions))] (.let [(~ g!context) (is (Rec (~ g!context) [(~+ context_types)]) @@ -150,7 +150,7 @@ g!pop (list#each (function (_ mutual) (.let [g!name (|> mutual (the [#mutual #declaration declaration.#name]) code.local)] - (` (.def: + (` (.def (~ (the #export_policy mutual)) (~ g!name) (~ (the [#mutual #type] mutual)) diff --git a/stdlib/source/library/lux/control/io.lux b/stdlib/source/library/lux/control/io.lux index 0b2372c6b..fecb0ee7b 100644 --- a/stdlib/source/library/lux/control/io.lux +++ b/stdlib/source/library/lux/control/io.lux @@ -17,54 +17,54 @@ (primitive .public (IO a) (-> Any a) - (def: label + (def label (All (_ a) (-> (-> Any a) (IO a))) (|>> abstraction)) - (def: !io + (def !io (template (!io computation) [(abstraction (template.with_locals [g!func g!arg] (function (g!func g!arg) computation)))])) - (def: run!' + (def run!' (template (run!' io) ... creatio ex nihilo [((representation io) [])])) - (def: .public io + (def .public io (syntax (_ [computation <code>.any]) (with_symbols [g!func g!arg] (in (list (` ((~! ..label) (function ((~ g!func) (~ g!arg)) (~ computation))))))))) - (def: .public run! + (def .public run! (All (_ a) (-> (IO a) a)) (|>> ..run!')) - (def: .public functor + (def .public functor (Functor IO) (implementation - (def: (each f) + (def (each f) (|>> ..run!' f !io)))) - (def: .public apply + (def .public apply (Apply IO) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (!io ((..run!' ff) (..run!' fa)))))) - (def: .public monad + (def .public monad (Monad IO) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: in + (def in (|>> !io)) - (def: conjoint + (def conjoint (|>> ..run!' ..run!' !io)))) ) diff --git a/stdlib/source/library/lux/control/lazy.lux b/stdlib/source/library/lux/control/lazy.lux index 343f866f7..50f18e0dd 100644 --- a/stdlib/source/library/lux/control/lazy.lux +++ b/stdlib/source/library/lux/control/lazy.lux @@ -20,7 +20,7 @@ (primitive .public (Lazy a) (-> [] a) - (def: (lazy' generator) + (def (lazy' generator) (All (_ a) (-> (-> [] a) (Lazy a))) (let [cache (atom.atom (sharing [a] (is (-> [] a) @@ -38,38 +38,38 @@ (io.run! (atom.compare_and_swap! _ {.#Some value} cache)) value))))))) - (def: .public (value lazy) + (def .public (value lazy) (All (_ a) (-> (Lazy a) a)) ((representation lazy) []))) -(def: .public lazy +(def .public lazy (syntax (_ [expression <code>.any]) (with_symbols [g!_] (in (list (` ((~! ..lazy') (function ((~ g!_) (~ g!_)) (~ expression))))))))) -(def: .public (equivalence (open "_#[0]")) +(def .public (equivalence (open "_#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (Lazy a)))) (implementation - (def: (= left right) + (def (= left right) (_#= (..value left) (..value right))))) -(def: .public functor +(def .public functor (Functor Lazy) (implementation - (def: (each f fa) + (def (each f fa) (lazy (f (value fa)))))) -(def: .public apply +(def .public apply (Apply Lazy) (implementation - (def: functor ..functor) - (def: (on fa ff) + (def functor ..functor) + (def (on fa ff) (lazy ((value ff) (value fa)))))) -(def: .public monad +(def .public monad (Monad Lazy) (implementation - (def: functor ..functor) - (def: in (|>> lazy)) - (def: conjoint ..value))) + (def functor ..functor) + (def in (|>> lazy)) + (def conjoint ..value))) diff --git a/stdlib/source/library/lux/control/maybe.lux b/stdlib/source/library/lux/control/maybe.lux index 00cef670e..b138ab65c 100644 --- a/stdlib/source/library/lux/control/maybe.lux +++ b/stdlib/source/library/lux/control/maybe.lux @@ -15,13 +15,13 @@ ... {.#None} ... {.#Some a}) -(def: .public monoid +(def .public monoid (All (_ a) (Monoid (Maybe a))) (implementation - (def: identity + (def identity {.#None}) - (def: (composite mx my) + (def (composite mx my) (case mx {.#None} my @@ -29,10 +29,10 @@ _ mx)))) -(def: .public functor +(def .public functor (Functor Maybe) (implementation - (def: (each f ma) + (def (each f ma) (case ma {.#Some a} {.#Some (f a)} @@ -41,12 +41,12 @@ it (as_expected it))))) -(def: .public apply +(def .public apply (Apply Maybe) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (case [ff fa] [{.#Some f} {.#Some a}] {.#Some (f a)} @@ -54,15 +54,15 @@ _ {.#None})))) -(def: .public monad +(def .public monad (Monad Maybe) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in x) + (def (in x) {.#Some x}) - (def: (conjoint mma) + (def (conjoint mma) (case mma {.#Some mx} mx @@ -71,10 +71,10 @@ it (as_expected it))))) -(def: .public (equivalence super) +(def .public (equivalence super) (All (_ a) (-> (Equivalence a) (Equivalence (Maybe a)))) (implementation - (def: (= mx my) + (def (= mx my) (case [mx my] [{.#None} {.#None}] #1 @@ -85,13 +85,13 @@ _ #0)))) -(def: .public (hash super) +(def .public (hash super) (All (_ a) (-> (Hash a) (Hash (Maybe a)))) (implementation - (def: equivalence + (def equivalence (..equivalence (at super equivalence))) - (def: (hash value) + (def (hash value) (case value {.#None} 1 @@ -99,18 +99,18 @@ {.#Some value} (at super hash value))))) -(def: .public (with monad) +(def .public (with monad) (All (_ M) (-> (Monad M) (Monad (All (_ a) (M (Maybe a)))))) (implementation - (def: functor + (def functor (functor.composite (the monad.functor monad) ..functor)) - (def: in + (def in (|>> (at ..monad in) (at monad in))) - (def: (conjoint MmMma) + (def (conjoint MmMma) (do monad [mMma MmMma] (case mMma @@ -121,11 +121,11 @@ it (in (as_expected it))))))) -(def: .public (lifted monad) +(def .public (lifted monad) (All (_ M a) (-> (Monad M) (-> (M a) (M (Maybe a))))) (at monad each (at ..monad in))) -(def: .public else +(def .public else (macro (_ tokens state) (case tokens (pattern (.list else maybe)) @@ -141,11 +141,11 @@ _ {.#Left "Wrong syntax for 'else'"}))) -(def: .public trusted +(def .public trusted (All (_ a) (-> (Maybe a) a)) (|>> (..else (undefined)))) -(def: .public (list value) +(def .public (list value) (All (_ a) (-> (Maybe a) (List a))) (case value {.#Some value} @@ -155,7 +155,7 @@ _ (.list))) -(def: .public when +(def .public when (macro (_ tokens state) (case tokens (pattern (.list test then)) diff --git a/stdlib/source/library/lux/control/parser.lux b/stdlib/source/library/lux/control/parser.lux index fef41832d..1c402df83 100644 --- a/stdlib/source/library/lux/control/parser.lux +++ b/stdlib/source/library/lux/control/parser.lux @@ -19,10 +19,10 @@ (type: .public (Parser s a) (-> s (Try [s a]))) -(def: .public functor +(def .public functor (All (_ s) (Functor (Parser s))) (implementation - (def: (each f ma) + (def (each f ma) (function (_ input) (case (ma input) {try.#Success [input' a]} @@ -31,12 +31,12 @@ {try.#Failure msg} {try.#Failure msg}))))) -(def: .public apply +(def .public apply (All (_ s) (Apply (Parser s))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (function (_ input) (case (ff input) {try.#Success [input' f]} @@ -50,16 +50,16 @@ {try.#Failure msg} {try.#Failure msg}))))) -(def: .public monad +(def .public monad (All (_ s) (Monad (Parser s))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in x) + (def (in x) (function (_ input) {try.#Success [input x]})) - (def: (conjoint mma) + (def (conjoint mma) (function (_ input) (case (mma input) {try.#Success [input' ma]} @@ -68,14 +68,14 @@ {try.#Failure msg} {try.#Failure msg}))))) -(def: .public (assertion message test) +(def .public (assertion message test) (All (_ s) (-> Text Bit (Parser s Any))) (function (_ input) (if test {try.#Success [input []]} {try.#Failure message}))) -(def: .public (maybe parser) +(def .public (maybe parser) (All (_ s a) (-> (Parser s a) (Parser s (Maybe a)))) (function (_ input) @@ -86,19 +86,19 @@ {try.#Failure _} {try.#Success [input {.#None}]}))) -(def: .public (result parser input) +(def .public (result parser input) (All (_ s a) (-> (Parser s a) s (Try [s a]))) (parser input)) -(def: .public (and first second) +(def .public (and first second) (All (_ s a b) (-> (Parser s a) (Parser s b) (Parser s [a b]))) (do [! ..monad] [head first] (at ! each (|>> [head]) second))) -(def: .public (or left right) +(def .public (or left right) (All (_ s a b) (-> (Parser s a) (Parser s b) (Parser s (Or a b)))) (function (_ tokens) @@ -114,7 +114,7 @@ {try.#Failure error} {try.#Failure error})))) -(def: .public (either this that) +(def .public (either this that) (All (_ s a) (-> (Parser s a) (Parser s a) (Parser s a))) (function (_ tokens) @@ -125,7 +125,7 @@ output output))) -(def: .public (some parser) +(def .public (some parser) (All (_ s a) (-> (Parser s a) (Parser s (List a)))) (function (_ input) @@ -138,14 +138,14 @@ {try.#Failure _} {try.#Success [input (list)]}))) -(def: .public (many parser) +(def .public (many parser) (All (_ s a) (-> (Parser s a) (Parser s (List a)))) (|> (..some parser) (..and parser) (at ..monad each (|>> {.#Item})))) -(def: .public (exactly amount parser) +(def .public (exactly amount parser) (All (_ s a) (-> Nat (Parser s a) (Parser s (List a)))) (case amount 0 (at ..monad in (list)) @@ -155,13 +155,13 @@ (exactly (-- amount)) (at ! each (|>> {.#Item x})))))) -(def: .public (at_least amount parser) +(def .public (at_least amount parser) (All (_ s a) (-> Nat (Parser s a) (Parser s (List a)))) (do [! ..monad] [minimum (..exactly amount parser)] (at ! each (list#composite minimum) (..some parser)))) -(def: .public (at_most amount parser) +(def .public (at_most amount parser) (All (_ s a) (-> Nat (Parser s a) (Parser s (List a)))) (case amount 0 (at ..monad in (list)) @@ -175,7 +175,7 @@ {try.#Failure msg} {try.#Success [input (list)]})))) -(def: .public (between minimum additional parser) +(def .public (between minimum additional parser) (All (_ s a) (-> Nat Nat (Parser s a) (Parser s (List a)))) (do [! ..monad] [minimum (..exactly minimum parser)] @@ -184,7 +184,7 @@ _ (at ! each (list#composite minimum) (..at_most additional parser))))) -(def: .public (separated_by separator parser) +(def .public (separated_by separator parser) (All (_ s a b) (-> (Parser s b) (Parser s a) (Parser s (List a)))) (do [! ..monad] [?x (..maybe parser)] @@ -198,7 +198,7 @@ {.#None} (in {.#End})))) -(def: .public (not parser) +(def .public (not parser) (All (_ s a) (-> (Parser s a) (Parser s Any))) (function (_ input) (case (parser input) @@ -208,12 +208,12 @@ _ {try.#Failure "Expected to fail; yet succeeded."}))) -(def: .public (failure message) +(def .public (failure message) (All (_ s a) (-> Text (Parser s a))) (function (_ input) {try.#Failure message})) -(def: .public (lifted operation) +(def .public (lifted operation) (All (_ s a) (-> (Try a) (Parser s a))) (function (_ input) (case operation @@ -223,7 +223,7 @@ {try.#Failure error} {try.#Failure error}))) -(def: .public (else value parser) +(def .public (else value parser) (All (_ s a) (-> a (Parser s a) (Parser s a))) (function (_ input) (case (parser input) @@ -233,37 +233,37 @@ {try.#Failure error} {try.#Success [input value]}))) -(def: .public remaining +(def .public remaining (All (_ s) (Parser s s)) (function (_ inputs) {try.#Success [inputs inputs]})) -(def: .public (rec parser) +(def .public (rec parser) (All (_ s a) (-> (-> (Parser s a) (Parser s a)) (Parser s a))) (function (_ inputs) (..result (parser (rec parser)) inputs))) -(def: .public (after param subject) +(def .public (after param subject) (All (_ s _ a) (-> (Parser s _) (Parser s a) (Parser s a))) (do ..monad [_ param] subject)) -(def: .public (before param subject) +(def .public (before param subject) (All (_ s _ a) (-> (Parser s _) (Parser s a) (Parser s a))) (do ..monad [output subject _ param] (in output))) -(def: .public (only test parser) +(def .public (only test parser) (All (_ s a) (-> (-> a Bit) (Parser s a) (Parser s a))) (do ..monad [output parser _ (..assertion "Constraint failed." (test output))] (in output))) -(def: .public (parses? parser) +(def .public (parses? parser) (All (_ s a) (-> (Parser s a) (Parser s Bit))) (function (_ input) (case (parser input) @@ -273,7 +273,7 @@ {try.#Failure error} {try.#Success [input false]}))) -(def: .public (parses parser) +(def .public (parses parser) (All (_ s a) (-> (Parser s a) (Parser s Any))) (function (_ input) (case (parser input) @@ -283,7 +283,7 @@ {try.#Failure error} {try.#Failure error}))) -(def: .public (speculative parser) +(def .public (speculative parser) (All (_ s a) (-> (Parser s a) (Parser s a))) (function (_ input) (case (parser input) @@ -293,7 +293,7 @@ failure failure))) -(def: .public (codec codec parser) +(def .public (codec codec parser) (All (_ s a z) (-> (Codec a z) (Parser s a) (Parser s z))) (function (_ input) (case (parser input) diff --git a/stdlib/source/library/lux/control/parser/cli.lux b/stdlib/source/library/lux/control/parser/cli.lux index 89ea21893..b00698644 100644 --- a/stdlib/source/library/lux/control/parser/cli.lux +++ b/stdlib/source/library/lux/control/parser/cli.lux @@ -13,7 +13,7 @@ (type: .public (Parser a) (//.Parser (List Text) a)) -(def: .public (result parser inputs) +(def .public (result parser inputs) (All (_ a) (-> (Parser a) (List Text) (Try a))) (case (//.result parser inputs) {try.#Success [remaining output]} @@ -27,7 +27,7 @@ {try.#Failure try} {try.#Failure try})) -(def: .public any +(def .public any (Parser Text) (function (_ inputs) (case inputs @@ -37,7 +37,7 @@ _ {try.#Failure "Cannot parse empty arguments."}))) -(def: .public (parse parser) +(def .public (parse parser) (All (_ a) (-> (-> Text (Try a)) (Parser a))) (function (_ inputs) (do try.monad @@ -45,7 +45,7 @@ output (parser raw)] (in [remaining output])))) -(def: .public (this reference) +(def .public (this reference) (-> Text (Parser Any)) (function (_ inputs) (do try.monad @@ -54,7 +54,7 @@ (in [remaining []]) {try.#Failure (format "Missing token: '" reference "'")})))) -(def: .public (somewhere cli) +(def .public (somewhere cli) (All (_ a) (-> (Parser a) (Parser a))) (function (_ inputs) (loop (again [immediate inputs]) @@ -73,20 +73,20 @@ (in [{.#Item to_omit remaining} output]))))))) -(def: .public end +(def .public end (Parser Any) (function (_ inputs) (case inputs {.#End} {try.#Success [inputs []]} _ {try.#Failure (format "Unknown parameters: " (text.interposed " " inputs))}))) -(def: .public (named name value) +(def .public (named name value) (All (_ a) (-> Text (Parser a) (Parser a))) (|> value (//.after (..this name)) ..somewhere)) -(def: .public (parameter [short long] value) +(def .public (parameter [short long] value) (All (_ a) (-> [Text Text] (Parser a) (Parser a))) (|> value (//.after (//.either (..this short) (..this long))) diff --git a/stdlib/source/library/lux/control/parser/code.lux b/stdlib/source/library/lux/control/parser/code.lux index abdcb7075..337201593 100644 --- a/stdlib/source/library/lux/control/parser/code.lux +++ b/stdlib/source/library/lux/control/parser/code.lux @@ -22,7 +22,7 @@ ["[0]" symbol]]]] ["[0]" //]) -(def: (un_paired pairs) +(def (un_paired pairs) (All (_ a) (-> (List [a a]) (List a))) (case pairs {.#End} @@ -34,13 +34,13 @@ (type: .public Parser (//.Parser (List Code))) -(def: remaining_inputs +(def remaining_inputs (-> (List Code) Text) (|>> (list#each code.format) (text.interposed " ") (all text#composite text.new_line "Remaining input: "))) -(def: .public any +(def .public any (Parser Code) (function (_ tokens) (case tokens @@ -50,7 +50,7 @@ {.#Item [t tokens']} {try.#Success [tokens' t]}))) -(def: .public next +(def .public next (Parser Code) (function (_ tokens) (case tokens @@ -62,7 +62,7 @@ (with_template [<query> <check> <type> <tag> <eq> <desc>] [(with_expansions [<failure> (these {try.#Failure (all text#composite "Cannot parse " <desc> (remaining_inputs tokens))})] - (def: .public <query> + (def .public <query> (Parser <type>) (function (_ tokens) (case tokens @@ -72,7 +72,7 @@ _ <failure>))) - (def: .public (<check> expected) + (def .public (<check> expected) (-> <type> (Parser Any)) (function (_ tokens) (case tokens @@ -93,7 +93,7 @@ [symbol this_symbol Symbol .#Symbol symbol.equivalence "symbol"] ) -(def: .public (this code) +(def .public (this code) (-> Code (Parser Any)) (function (_ tokens) (case tokens @@ -107,7 +107,7 @@ {try.#Failure "There are no tokens to parse!"}))) (with_expansions [<failure> (these {try.#Failure (all text#composite "Cannot parse local symbol" (remaining_inputs tokens))})] - (def: .public local + (def .public local (Parser Text) (function (_ tokens) (case tokens @@ -117,7 +117,7 @@ _ <failure>))) - (def: .public (this_local expected) + (def .public (this_local expected) (-> Text (Parser Any)) (function (_ tokens) (case tokens @@ -130,7 +130,7 @@ <failure>)))) (with_expansions [<failure> (these {try.#Failure (all text#composite "Cannot parse local symbol" (remaining_inputs tokens))})] - (def: .public global + (def .public global (Parser Symbol) (function (_ tokens) (case tokens @@ -143,7 +143,7 @@ _ <failure>))) - (def: .public (this_global expected) + (def .public (this_global expected) (-> Symbol (Parser Any)) (function (_ tokens) (case tokens @@ -159,7 +159,7 @@ <failure>)))) (with_template [<name> <tag> <desc>] - [(def: .public (<name> p) + [(def .public (<name> p) (All (_ a) (-> (Parser a) (Parser a))) (function (_ tokens) @@ -177,21 +177,21 @@ [tuple .#Tuple "tuple"] ) -(def: .public end +(def .public end (Parser Any) (function (_ tokens) (case tokens {.#End} {try.#Success [tokens []]} _ {try.#Failure (all text#composite "Expected list of tokens to be empty!" (remaining_inputs tokens))}))) -(def: .public end? +(def .public end? (Parser Bit) (function (_ tokens) {try.#Success [tokens (case tokens {.#End} true _ false)]})) -(def: .public (result parser inputs) +(def .public (result parser inputs) (All (_ a) (-> (Parser a) (List Code) (Try a))) (case (parser inputs) {try.#Failure error} @@ -208,14 +208,14 @@ (text.interposed ", ") (text#composite "Unconsumed inputs: "))}))) -(def: .public (locally inputs parser) +(def .public (locally inputs parser) (All (_ a) (-> (List Code) (Parser a) (Parser a))) (function (_ real) (do try.monad [value (..result parser inputs)] (in [real value])))) -(def: .public (not parser) +(def .public (not parser) (All (_ a) (-> (Parser a) (Parser Code))) (do //.monad [sample ..next diff --git a/stdlib/source/library/lux/control/parser/environment.lux b/stdlib/source/library/lux/control/parser/environment.lux index b6a669a56..601cd9a5d 100644 --- a/stdlib/source/library/lux/control/parser/environment.lux +++ b/stdlib/source/library/lux/control/parser/environment.lux @@ -25,11 +25,11 @@ (type: .public (Parser a) (//.Parser Environment a)) -(def: .public empty +(def .public empty Environment (dictionary.empty text.hash)) -(def: .public (property name) +(def .public (property name) (-> Property (Parser Text)) (function (_ environment) (case (dictionary.value name environment) @@ -39,6 +39,6 @@ {.#None} (exception.except ..unknown_property [name])))) -(def: .public (result parser environment) +(def .public (result parser environment) (All (_ a) (-> (Parser a) Environment (Try a))) (at try.monad each product.right (parser environment))) diff --git a/stdlib/source/library/lux/control/parser/json.lux b/stdlib/source/library/lux/control/parser/json.lux index 8f7fe459f..308c8c918 100644 --- a/stdlib/source/library/lux/control/parser/json.lux +++ b/stdlib/source/library/lux/control/parser/json.lux @@ -31,7 +31,7 @@ (exception: .public empty_input) -(def: .public (result parser json) +(def .public (result parser json) (All (_ a) (-> (Parser a) JSON (Try a))) (case (//.result parser (list json)) {try.#Success [remainder output]} @@ -45,7 +45,7 @@ {try.#Failure error} {try.#Failure error})) -(def: .public any +(def .public any (Parser JSON) (<| (function (_ inputs)) (case inputs @@ -60,7 +60,7 @@ "Value" (/.format value))) (with_template [<name> <type> <tag>] - [(def: .public <name> + [(def .public <name> (Parser <type>) (do //.monad [head ..any] @@ -84,7 +84,7 @@ "Sample" (/.format sample))) (with_template [<test> <check> <type> <equivalence> <tag>] - [(def: .public (<test> test) + [(def .public (<test> test) (-> <type> (Parser Bit)) (do //.monad [head ..any] @@ -95,7 +95,7 @@ _ (//.failure (exception.error ..unexpected_value [head]))))) - (def: .public (<check> test) + (def .public (<check> test) (-> <type> (Parser Any)) (do //.monad [head ..any] @@ -113,12 +113,12 @@ [string? this_string /.String text.equivalence /.#String] ) -(def: .public (nullable parser) +(def .public (nullable parser) (All (_ a) (-> (Parser a) (Parser (Maybe a)))) (//.or ..null parser)) -(def: .public (array parser) +(def .public (array parser) (All (_ a) (-> (Parser a) (Parser a))) (do //.monad [head ..any] @@ -139,7 +139,7 @@ _ (//.failure (exception.error ..unexpected_value [head]))))) -(def: .public (object parser) +(def .public (object parser) (All (_ a) (-> (Parser a) (Parser a))) (do //.monad [head ..any] @@ -165,7 +165,7 @@ _ (//.failure (exception.error ..unexpected_value [head]))))) -(def: .public (field field_name parser) +(def .public (field field_name parser) (All (_ a) (-> Text (Parser a) (Parser a))) (function (again inputs) (case inputs @@ -191,7 +191,7 @@ _ (exception.except ..unconsumed_input inputs)))) -(def: .public dictionary +(def .public dictionary (All (_ a) (-> (Parser a) (Parser (Dictionary Text a)))) (|>> (//.and ..string) //.some diff --git a/stdlib/source/library/lux/control/parser/tree.lux b/stdlib/source/library/lux/control/parser/tree.lux index 751d370db..b7a37f0ef 100644 --- a/stdlib/source/library/lux/control/parser/tree.lux +++ b/stdlib/source/library/lux/control/parser/tree.lux @@ -15,17 +15,17 @@ (type: .public (Parser t a) (//.Parser (Zipper t) a)) -(def: .public (result' parser zipper) +(def .public (result' parser zipper) (All (_ t a) (-> (Parser t a) (Zipper t) (Try a))) (do try.monad [[zipper output] (//.result parser zipper)] (in output))) -(def: .public (result parser tree) +(def .public (result parser tree) (All (_ t a) (-> (Parser t a) (Tree t) (Try a))) (result' parser (zipper.zipper tree))) -(def: .public value +(def .public value (All (_ t) (Parser t t)) (function (_ zipper) {try.#Success [zipper (zipper.value zipper)]})) @@ -33,7 +33,7 @@ (exception: .public cannot_move_further) (with_template [<name> <direction>] - [(def: .public <name> + [(def .public <name> (All (_ t) (Parser t [])) (function (_ zipper) (case (<direction> zipper) diff --git a/stdlib/source/library/lux/control/parser/type.lux b/stdlib/source/library/lux/control/parser/type.lux index 1b8a9de5a..cff760d80 100644 --- a/stdlib/source/library/lux/control/parser/type.lux +++ b/stdlib/source/library/lux/control/parser/type.lux @@ -23,7 +23,7 @@ ["[0]" check]]]] ["[0]" //]) -(def: |recursion_dummy| +(def |recursion_dummy| (template (|recursion_dummy|) [{.#Primitive "" {.#End}}])) @@ -69,11 +69,11 @@ (type: .public (Parser a) (//.Parser [Env (List Type)] a)) -(def: .public fresh +(def .public fresh Env (dictionary.empty n.hash)) -(def: (result' env poly types) +(def (result' env poly types) (All (_ a) (-> Env (Parser a) (List Type) (Try a))) (case (//.result poly [env types]) {try.#Failure error} @@ -87,16 +87,16 @@ _ (exception.except ..unconsumed_input remaining)))) -(def: .public (result poly type) +(def .public (result poly type) (All (_ a) (-> (Parser a) Type (Try a))) (result' ..fresh poly (list type))) -(def: .public env +(def .public env (Parser Env) (.function (_ [env inputs]) {try.#Success [[env inputs] env]})) -(def: (with_env temp poly) +(def (with_env temp poly) (All (_ a) (-> Env (Parser a) (Parser a))) (.function (_ [env inputs]) (case (//.result poly [temp inputs]) @@ -106,7 +106,7 @@ {try.#Success [[_ remaining] output]} {try.#Success [[env remaining] output]}))) -(def: .public next +(def .public next (Parser Type) (.function (_ [env inputs]) (case inputs @@ -116,7 +116,7 @@ {.#Item headT tail} {try.#Success [[env inputs] headT]}))) -(def: .public any +(def .public any (Parser Type) (.function (_ [env inputs]) (case inputs @@ -126,7 +126,7 @@ {.#Item headT tail} {try.#Success [[env tail] headT]}))) -(def: .public (local types poly) +(def .public (local types poly) (All (_ a) (-> (List Type) (Parser a) (Parser a))) (.function (_ [env pass_through]) (case (result' env poly types) @@ -136,11 +136,11 @@ {try.#Success output} {try.#Success [[env pass_through] output]}))) -(def: (label idx) +(def (label idx) (-> Nat Code) (code.local (all text#composite "label" text.tab (n#encoded idx)))) -(def: .public (with_extension type poly) +(def .public (with_extension type poly) (All (_ a) (-> Type (Parser a) (Parser [Code a]))) (.function (_ [env inputs]) (let [current_id (dictionary.size env) @@ -155,7 +155,7 @@ {try.#Success [[env inputs'] [g!var output]]})))) (with_template [<name> <flattener> <exception>] - [(`` (def: .public (<name> poly) + [(`` (def .public (<name> poly) (All (_ a) (-> (Parser a) (Parser a))) (do //.monad [headT ..any] @@ -168,7 +168,7 @@ [tuple type.flat_tuple ..not_tuple] ) -(def: polymorphic' +(def polymorphic' (Parser [Nat Type]) (do //.monad [headT any @@ -177,7 +177,7 @@ (//.failure (exception.error ..not_polymorphic headT)) (in [num_arg bodyT])))) -(def: .public (polymorphic poly) +(def .public (polymorphic poly) (All (_ a) (-> (Parser a) (Parser [Code (List Code) a]))) (do [! //.monad] [headT any @@ -214,7 +214,7 @@ [output poly] (in [funcL all_varsL output]))))) -(def: .public (function in_poly out_poly) +(def .public (function in_poly out_poly) (All (_ i o) (-> (Parser i) (Parser o) (Parser [i o]))) (do //.monad [headT any @@ -224,7 +224,7 @@ (local (list outputT) out_poly)) (//.failure (exception.error ..not_function headT))))) -(def: .public (applied poly) +(def .public (applied poly) (All (_ a) (-> (Parser a) (Parser a))) (do //.monad [headT any @@ -234,7 +234,7 @@ (..local {.#Item funcT paramsT} poly)))) (with_template [<name> <test>] - [(def: .public (<name> expected) + [(def .public (<name> expected) (-> Type (Parser Any)) (do //.monad [actual any] @@ -247,14 +247,14 @@ [super (function.flipped check.subsumes?)] ) -(def: .public (argument env idx) +(def .public (argument env idx) (-> Env Nat Nat) (let [env_level (n./ 2 (dictionary.size env)) parameter_level (n./ 2 idx) parameter_idx (n.% 2 idx)] (|> env_level -- (n.- parameter_level) (n.* 2) (n.+ parameter_idx)))) -(def: .public parameter +(def .public parameter (Parser Code) (do //.monad [env ..env @@ -271,7 +271,7 @@ _ (//.failure (exception.error ..not_parameter headT))))) -(def: .public (this_parameter id) +(def .public (this_parameter id) (-> Nat (Parser Any)) (do //.monad [env ..env @@ -285,7 +285,7 @@ _ (//.failure (exception.error ..not_parameter headT))))) -(def: .public existential +(def .public existential (Parser Nat) (do //.monad [headT any] @@ -296,7 +296,7 @@ _ (//.failure (exception.error ..not_existential headT))))) -(def: .public named +(def .public named (Parser [Symbol Type]) (do //.monad [inputT any] @@ -307,7 +307,7 @@ _ (//.failure (exception.error ..not_named inputT))))) -(def: .public (recursive poly) +(def .public (recursive poly) (All (_ a) (-> (Parser a) (Parser [Code a]))) (do [! //.monad] [headT any] @@ -323,7 +323,7 @@ _ (//.failure (exception.error ..not_recursive headT))))) -(def: .public recursive_self +(def .public recursive_self (Parser Code) (do //.monad [env ..env @@ -337,7 +337,7 @@ _ (//.failure (exception.error ..not_recursive headT))))) -(def: .public recursive_call +(def .public recursive_call (Parser Code) (do [! //.monad] [env ..env diff --git a/stdlib/source/library/lux/control/parser/xml.lux b/stdlib/source/library/lux/control/parser/xml.lux index 05680953a..16802de51 100644 --- a/stdlib/source/library/lux/control/parser/xml.lux +++ b/stdlib/source/library/lux/control/parser/xml.lux @@ -40,7 +40,7 @@ (exception.report "Inputs" (exception.listing (at /.codec encoded) inputs))) -(def: (result' parser attrs documents) +(def (result' parser attrs documents) (All (_ a) (-> (Parser a) Attrs (List XML) (Try a))) (case (//.result parser [attrs documents]) {try.#Success [[attrs' remaining] output]} @@ -51,11 +51,11 @@ {try.#Failure error} {try.#Failure error})) -(def: .public (result parser documents) +(def .public (result parser documents) (All (_ a) (-> (Parser a) (List XML) (Try a))) (..result' parser /.attributes documents)) -(def: .public text +(def .public text (Parser Text) (function (_ [attrs documents]) (case documents @@ -70,7 +70,7 @@ {/.#Node _} (exception.except ..unexpected_input []))))) -(def: .public tag +(def .public tag (Parser Tag) (function (_ [attrs documents]) (case documents @@ -85,7 +85,7 @@ {/.#Node tag _ _} {try.#Success [[attrs documents] tag]})))) -(def: .public (attribute name) +(def .public (attribute name) (-> Attribute (Parser Text)) (function (_ [attrs documents]) (case (dictionary.value name attrs) @@ -95,7 +95,7 @@ {.#Some value} {try.#Success [[attrs documents] value]}))) -(def: .public (node expected parser) +(def .public (node expected parser) (All (_ a) (-> Tag (Parser a) (Parser a))) (function (_ [attrs documents]) (case documents @@ -114,7 +114,7 @@ (try#each (|>> [[attrs tail]]))) (exception.except ..wrong_tag [expected actual])))))) -(def: .public any +(def .public any (Parser XML) (function (_ [attrs documents]) (case documents @@ -126,7 +126,7 @@ (exception: .public nowhere) -(def: .public (somewhere parser) +(def .public (somewhere parser) (All (_ a) (-> (Parser a) (Parser a))) (function (again [attrs input]) (case (//.result parser [attrs input]) diff --git a/stdlib/source/library/lux/control/pipe.lux b/stdlib/source/library/lux/control/pipe.lux index 611aaf179..7f7762924 100644 --- a/stdlib/source/library/lux/control/pipe.lux +++ b/stdlib/source/library/lux/control/pipe.lux @@ -19,29 +19,29 @@ ["n" nat] ["i" int]]]]]) -(def: body +(def body (Parser (List Code)) (<code>.tuple (<>.some <code>.any))) -(def: .public new +(def .public new (syntax (_ [start <code>.any body ..body prev <code>.any]) (in (list (` (|> (~ start) (~+ body))))))) -(def: .public let +(def .public let (syntax (_ [binding <code>.any body <code>.any prev <code>.any]) (in (list (` (.let [(~ binding) (~ prev)] (~ body))))))) -(def: _reversed_ +(def _reversed_ (Parser Any) (function (_ tokens) {try.#Success [(list.reversed tokens) []]})) -(def: .public cond +(def .public cond (syntax (_ [_ _reversed_ prev <code>.any else ..body @@ -55,7 +55,7 @@ (` (|> (~ g!temp) (~+ then)))))) (|> (~ g!temp) (~+ else)))))))))) -(def: .public if +(def .public if (syntax (_ [test ..body then ..body else ..body @@ -64,7 +64,7 @@ [(~+ else)] (~ prev))))))) -(def: .public when +(def .public when (syntax (_ [test ..body then ..body prev <code>.any]) @@ -72,7 +72,7 @@ [] (~ prev))))))) -(def: .public while +(def .public while (syntax (_ [test ..body then ..body prev <code>.any]) @@ -82,7 +82,7 @@ ((~ g!again) (|> (~ g!temp) (~+ then))) (~ g!temp))))))))) -(def: .public do +(def .public do (syntax (_ [monad <code>.any steps (<>.some ..body) prev <code>.any]) @@ -100,7 +100,7 @@ _ (in (list prev)))))) -(def: .public exec +(def .public exec (syntax (_ [body ..body prev <code>.any]) (with_symbols [g!temp] @@ -108,7 +108,7 @@ (.exec (|> (~ g!temp) (~+ body)) (~ g!temp))))))))) -(def: .public tuple +(def .public tuple (syntax (_ [paths (<>.many ..body) prev <code>.any]) (with_symbols [g!temp] @@ -116,7 +116,7 @@ [(~+ (list#each (function (_ body) (` (|> (~ g!temp) (~+ body)))) paths))]))))))) -(def: .public case +(def .public case (syntax (_ [branches (<>.many (<>.and <code>.any <code>.any)) prev <code>.any]) (in (list (` (.case (~ prev) diff --git a/stdlib/source/library/lux/control/reader.lux b/stdlib/source/library/lux/control/reader.lux index dc9c65f57..923b10562 100644 --- a/stdlib/source/library/lux/control/reader.lux +++ b/stdlib/source/library/lux/control/reader.lux @@ -10,62 +10,62 @@ (type: .public (Reader r a) (-> r a)) -(def: .public read +(def .public read (All (_ r) (Reader r r)) (function (_ env) env)) -(def: .public (local change proc) +(def .public (local change proc) (All (_ r a) (-> (-> r r) (Reader r a) (Reader r a))) (|>> change proc)) -(def: .public (result env proc) +(def .public (result env proc) (All (_ r a) (-> r (Reader r a) a)) (proc env)) -(def: .public functor +(def .public functor (All (_ r) (Functor (Reader r))) (implementation - (def: (each f fa) + (def (each f fa) (function (_ env) (f (fa env)))))) -(def: .public apply +(def .public apply (All (_ r) (Apply (Reader r))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (function (_ env) ((ff env) (fa env)))))) -(def: .public monad +(def .public monad (All (_ r) (Monad (Reader r))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in x) + (def (in x) (function (_ env) x)) - (def: (conjoint mma) + (def (conjoint mma) (function (_ env) (mma env env))))) -(def: .public (with monad) +(def .public (with monad) (All (_ !) (-> (Monad !) (All (_ e) (Monad (All (_ a) (Reader e (! a))))))) (implementation - (def: functor + (def functor (functor.composite ..functor (the monad.functor monad))) - (def: in + (def in (|>> (at monad in) (at ..monad in))) - (def: (conjoint eMeMa) + (def (conjoint eMeMa) (function (_ env) (do monad [eMa (result env eMeMa)] (result env eMa)))))) -(def: .public lifted +(def .public lifted (All (_ ! e a) (-> (! a) (Reader e (! a)))) (at ..monad in)) diff --git a/stdlib/source/library/lux/control/region.lux b/stdlib/source/library/lux/control/region.lux index ea1abcec3..2c91dbbb8 100644 --- a/stdlib/source/library/lux/control/region.lux +++ b/stdlib/source/library/lux/control/region.lux @@ -23,7 +23,7 @@ (! [(List (Cleaner r !)) (Try a)]))) -(def: separator +(def separator Text (format text.new_line "-----------------------------------------" text.new_line @@ -42,7 +42,7 @@ (format separator error|output)))) -(def: (clean clean_up output) +(def (clean clean_up output) (All (_ a) (-> (Try Any) (Try a) (Try a))) (case clean_up {try.#Success _} @@ -51,7 +51,7 @@ {try.#Failure error} (exception.except ..clean_up_error [error output]))) -(def: .public (run! monad computation) +(def .public (run! monad computation) (All (_ ! a) (-> (Monad !) (All (_ r) (Region r ! a)) (! (Try a)))) @@ -61,7 +61,7 @@ (monad.each ! (function (_ cleaner) (cleaner []))) (at ! each (list#mix clean output))))) -(def: .public (acquire! monad cleaner value) +(def .public (acquire! monad cleaner value) (All (_ ! a) (-> (Monad !) (-> a (! (Try Any))) a (All (_ r) (Region r ! a)))) (function (_ [region cleaners]) @@ -69,12 +69,12 @@ cleaners} {try.#Success value}]))) -(def: .public (functor super) +(def .public (functor super) (All (_ !) (-> (Functor !) (All (_ r) (Functor (Region r !))))) (implementation - (def: (each f) + (def (each f) (function (_ fa) (function (_ region+cleaners) (at super each @@ -87,15 +87,15 @@ {try.#Failure error})]) (fa region+cleaners))))))) -(def: .public (apply super) +(def .public (apply super) (All (_ !) (-> (Monad !) (All (_ r) (Apply (Region r !))))) (implementation - (def: functor + (def functor (..functor (the monad.functor super))) - (def: (on fa ff) + (def (on fa ff) (function (_ [region cleaners]) (do super [[cleaners ef] (ff [region cleaners]) @@ -112,19 +112,19 @@ {try.#Failure error} (in [cleaners {try.#Failure error}]))))))) -(def: .public (monad super) +(def .public (monad super) (All (_ !) (-> (Monad !) (All (_ r) (Monad (Region r !))))) (implementation - (def: functor + (def functor (..functor (the monad.functor super))) - (def: (in value) + (def (in value) (function (_ [region cleaners]) (at super in [cleaners {try.#Success value}]))) - (def: (conjoint ffa) + (def (conjoint ffa) (function (_ [region cleaners]) (do super [[cleaners efa] (ffa [region cleaners])] @@ -135,20 +135,20 @@ {try.#Failure error} (in [cleaners {try.#Failure error}]))))))) -(def: .public (failure monad error) +(def .public (failure monad error) (All (_ ! a) (-> (Monad !) Text (All (_ r) (Region r ! a)))) (function (_ [region cleaners]) (at monad in [cleaners {try.#Failure error}]))) -(def: .public (except monad exception message) +(def .public (except monad exception message) (All (_ ! e a) (-> (Monad !) (Exception e) e (All (_ r) (Region r ! a)))) (failure monad (exception.error exception message))) -(def: .public (lifted monad operation) +(def .public (lifted monad operation) (All (_ ! a) (-> (Monad !) (! a) (All (_ r) (Region r ! a)))) diff --git a/stdlib/source/library/lux/control/remember.lux b/stdlib/source/library/lux/control/remember.lux index 8cd386ca6..1110c57bf 100644 --- a/stdlib/source/library/lux/control/remember.lux +++ b/stdlib/source/library/lux/control/remember.lux @@ -36,7 +36,7 @@ {.#None} ""))) -(def: deadline +(def deadline (Parser Date) (all <>.either (<>#each (|>> instant.of_millis instant.date) @@ -50,7 +50,7 @@ {try.#Failure message} (<>.failure message))))) -(def: .public remember +(def .public remember (syntax (_ [deadline ..deadline message <c>.text focus (<>.maybe <c>.any)]) @@ -66,7 +66,7 @@ (meta.failure (exception.error ..must_remember [deadline today message focus])))))) (with_template [<name> <message>] - [(`` (def: .public <name> + [(`` (def .public <name> (syntax (_ [deadline ..deadline message <c>.text focus (<>.maybe <c>.any)]) diff --git a/stdlib/source/library/lux/control/security/capability.lux b/stdlib/source/library/lux/control/security/capability.lux index 482f61161..6df5eaf19 100644 --- a/stdlib/source/library/lux/control/security/capability.lux +++ b/stdlib/source/library/lux/control/security/capability.lux @@ -26,20 +26,20 @@ (primitive .public (Capability brand input output) (-> input output) - (def: capability + (def capability (All (_ brand input output) (-> (-> input output) (Capability brand input output))) (|>> abstraction)) - (def: .public (use capability input) + (def .public (use capability input) (All (_ brand input output) (-> (Capability brand input output) input output)) ((representation capability) input)) - (def: .public capability: + (def .public capability: (syntax (_ [[export_policy declaration [forger input output]] (|export|.parser (all <>.and @@ -55,14 +55,14 @@ (in (list (` (type: (~ export_policy) (~ (|declaration|.format declaration)) (~ capability))) - (` (def: (~ (code.local forger)) + (` (def (~ (code.local forger)) (All ((~ g!_) (~+ (list#each code.local vars))) (-> (-> (~ input) (~ output)) (~ capability))) (~! ..capability))) )))))) - (def: .public (async capability) + (def .public (async capability) (All (_ brand input output) (-> (Capability brand input (IO output)) (Capability brand input (Async output)))) diff --git a/stdlib/source/library/lux/control/security/policy.lux b/stdlib/source/library/lux/control/security/policy.lux index f8856c593..fe683cf05 100644 --- a/stdlib/source/library/lux/control/security/policy.lux +++ b/stdlib/source/library/lux/control/security/policy.lux @@ -27,7 +27,7 @@ (-> (Policy brand value from) (Policy brand value to)))) - (def: .public (delegation downgrade upgrade) + (def .public (delegation downgrade upgrade) (All (_ brand from to) (-> (Can_Downgrade brand from) (Can_Upgrade brand to) (Delegation brand from to))) @@ -37,43 +37,43 @@ (-> (Privilege brand label) (scope label))) - (def: privilege + (def privilege Privilege [#can_upgrade (|>> abstraction) #can_downgrade (|>> representation)]) - (def: .public (with_policy context) + (def .public (with_policy context) (All (_ brand scope) (Ex (_ label) (-> (Context brand scope label) (scope label)))) (context ..privilege)) - (def: (of_policy constructor) + (def (of_policy constructor) (-> Type Type) (type (All (_ brand label) (constructor (All (_ value) (Policy brand value label)))))) - (def: .public functor + (def .public functor (~ (..of_policy Functor)) (implementation - (def: (each f fa) + (def (each f fa) (|> fa representation f abstraction)))) - (def: .public apply + (def .public apply (~ (..of_policy Apply)) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (abstraction ((representation ff) (representation fa)))))) - (def: .public monad + (def .public monad (~ (..of_policy Monad)) (implementation - (def: functor ..functor) - (def: in (|>> abstraction)) - (def: conjoint (|>> representation)))) + (def functor ..functor) + (def in (|>> abstraction)) + (def conjoint (|>> representation)))) ) (with_template [<brand> <value> <upgrade> <downgrade>] diff --git a/stdlib/source/library/lux/control/state.lux b/stdlib/source/library/lux/control/state.lux index dc007f65a..484592e71 100644 --- a/stdlib/source/library/lux/control/state.lux +++ b/stdlib/source/library/lux/control/state.lux @@ -9,70 +9,70 @@ (type: .public (State s a) (-> s [s a])) -(def: .public get +(def .public get (All (_ s) (State s s)) (function (_ state) [state state])) -(def: .public (put new_state) +(def .public (put new_state) (All (_ s) (-> s (State s Any))) (function (_ state) [new_state []])) -(def: .public (update change) +(def .public (update change) (All (_ s) (-> (-> s s) (State s Any))) (function (_ state) [(change state) []])) -(def: .public (use user) +(def .public (use user) (All (_ s a) (-> (-> s a) (State s a))) (function (_ state) [state (user state)])) -(def: .public (local change action) +(def .public (local change action) (All (_ s a) (-> (-> s s) (State s a) (State s a))) (function (_ state) (let [[state' output] (action (change state))] [state output]))) -(def: .public (result state action) +(def .public (result state action) (All (_ s a) (-> s (State s a) [s a])) (action state)) -(def: .public functor +(def .public functor (All (_ s) (Functor (State s))) (implementation - (def: (each f ma) + (def (each f ma) (function (_ state) (let [[state' a] (ma state)] [state' (f a)]))))) -(def: .public apply +(def .public apply (All (_ s) (Apply (State s))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (function (_ state) (let [[state' f] (ff state) [state'' a] (fa state')] [state'' (f a)]))))) -(def: .public monad +(def .public monad (All (_ s) (Monad (State s))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in a) + (def (in a) (function (_ state) [state a])) - (def: (conjoint mma) + (def (conjoint mma) (function (_ state) (let [[state' ma] (mma state)] (ma state')))))) -(def: .public (while condition body) +(def .public (while condition body) (All (_ s) (-> (State s Bit) (State s Any) (State s Any))) (do [! ..monad] [execute? condition] @@ -82,26 +82,26 @@ (while condition body)) (in [])))) -(def: .public (do_while condition body) +(def .public (do_while condition body) (All (_ s) (-> (State s Bit) (State s Any) (State s Any))) (do ..monad [_ body] (while condition body))) -(def: (with//functor functor) +(def (with//functor functor) (All (_ M s) (-> (Functor M) (Functor (All (_ a) (-> s (M [s a])))))) (implementation - (def: (each f sfa) + (def (each f sfa) (function (_ state) (at functor each (function (_ [s a]) [s (f a)]) (sfa state)))))) -(def: (with//apply monad) +(def (with//apply monad) (All (_ M s) (-> (Monad M) (Apply (All (_ a) (-> s (M [s a])))))) (implementation - (def: functor (with//functor (at monad functor))) + (def functor (with//functor (at monad functor))) - (def: (on sFa sFf) + (def (on sFa sFf) (function (_ state) (do monad [[state f] (sFf state) @@ -111,26 +111,26 @@ (type: .public (+State M s a) (-> s (M [s a]))) -(def: .public (result' state action) +(def .public (result' state action) (All (_ M s a) (-> s (+State M s a) (M [s a]))) (action state)) -(def: .public (with monad) +(def .public (with monad) (All (_ M s) (-> (Monad M) (Monad (+State M s)))) (implementation - (def: functor (with//functor (at monad functor))) + (def functor (with//functor (at monad functor))) - (def: (in a) + (def (in a) (function (_ state) (at monad in [state a]))) - (def: (conjoint sMsMa) + (def (conjoint sMsMa) (function (_ state) (do monad [[state' sMa] (sMsMa state)] (sMa state')))))) -(def: .public (lifted monad ma) +(def .public (lifted monad ma) (All (_ M s a) (-> (Monad M) (M a) (+State M s a))) (function (_ state) (do monad diff --git a/stdlib/source/library/lux/control/thread.lux b/stdlib/source/library/lux/control/thread.lux index bb48b31b0..4dbe81f34 100644 --- a/stdlib/source/library/lux/control/thread.lux +++ b/stdlib/source/library/lux/control/thread.lux @@ -28,14 +28,14 @@ (type: .public (Box t a) (Box'' t (Mutable a a))) - (def: .public (box init) + (def .public (box init) (All (_ a) (-> a (All (_ !) (Thread ! (Box ! a))))) (function (_ !) (|> (array.empty 1) (array.has! 0 (variance.write init)) abstraction))) - (def: .public (read! box) + (def .public (read! box) (All (_ ! r w) (-> (Box' ! r w) (Thread ! r))) (function (_ !) (|> box @@ -43,7 +43,7 @@ (array.item 0) variance.read))) - (def: .public (write! value box) + (def .public (write! value box) (All (_ r w) (-> w (All (_ !) (-> (Box' ! r w) (Thread ! Any))))) (function (_ !) (|> box @@ -52,49 +52,49 @@ abstraction))) ) -(def: .public (result thread) +(def .public (result thread) (All (_ a) (-> (All (_ !) (Thread ! a)) a)) (thread [])) -(def: .public io +(def .public io (All (_ a) (-> (All (_ !) (Thread ! a)) (IO a))) (|>> ..result io.io)) -(def: .public functor +(def .public functor (All (_ !) (Functor (Thread !))) (implementation - (def: (each f) + (def (each f) (function (_ fa) (function (_ !) (f (fa !))))))) -(def: .public apply +(def .public apply (All (_ !) (Apply (Thread !))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (function (_ !) ((ff !) (fa !)))))) -(def: .public monad +(def .public monad (All (_ !) (Monad (Thread !))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in value) + (def (in value) (function (_ !) value)) - (def: (conjoint ffa) + (def (conjoint ffa) (function (_ !) ((ffa !) !))))) -(def: .public (update! f box) +(def .public (update! f box) (All (_ ! r w) (-> (-> r w) (Box' ! r w) (Thread ! [r w]))) (do ..monad [old (read! box) diff --git a/stdlib/source/library/lux/control/try.lux b/stdlib/source/library/lux/control/try.lux index 6d0467043..23d3cf178 100644 --- a/stdlib/source/library/lux/control/try.lux +++ b/stdlib/source/library/lux/control/try.lux @@ -15,10 +15,10 @@ {#Failure Text} {#Success a})) -(def: .public functor +(def .public functor (Functor Try) (implementation - (def: (each f ma) + (def (each f ma) (case ma {#Success datum} {#Success (f datum)} @@ -27,12 +27,12 @@ it (as_expected it))))) -(def: .public apply +(def .public apply (Apply Try) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (case ff {#Success f} (case fa @@ -47,15 +47,15 @@ it (as_expected it))))) -(def: .public monad +(def .public monad (Monad Try) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in a) + (def (in a) {#Success a}) - (def: (conjoint mma) + (def (conjoint mma) (case mma {#Success ma} ma @@ -64,19 +64,19 @@ it (as_expected it))))) -(def: .public (with monad) +(def .public (with monad) ... TODO: Replace (All (_ a) (! (Try a))) with (functor.Then ! Try) (All (_ !) (-> (Monad !) (Monad (All (_ a) (! (Try a)))))) (implementation - (def: functor + (def functor (functor.composite (the monad.functor monad) ..functor)) - (def: in + (def in (|>> (at ..monad in) (at monad in))) - (def: (conjoint MeMea) + (def (conjoint MeMea) (do monad [eMea MeMea] (case eMea @@ -87,14 +87,14 @@ it (in (as_expected it))))))) -(def: .public (lifted monad) +(def .public (lifted monad) (All (_ ! a) (-> (Monad !) (-> (! a) (! (Try a))))) (at monad each (at ..monad in))) -(def: .public (equivalence (open "_#[0]")) +(def .public (equivalence (open "_#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (Try a)))) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{#Success reference} {#Success sample}] (_#= reference sample) @@ -106,7 +106,7 @@ false )))) -(def: .public (trusted try) +(def .public (trusted try) (All (_ a) (-> (Try a) a)) (case try @@ -116,7 +116,7 @@ {#Failure message} (panic! message))) -(def: .public (maybe try) +(def .public (maybe try) (All (_ a) (-> (Try a) (Maybe a))) (case try @@ -127,7 +127,7 @@ _ {.#None})) -(def: .public (of_maybe maybe) +(def .public (of_maybe maybe) (All (_ a) (-> (Maybe a) (Try a))) (case maybe @@ -138,7 +138,7 @@ {#Failure (`` (("lux in-module" (~~ (static .prelude)) .symbol#encoded) (symbol ..of_maybe)))})) -(def: .public else +(def .public else (macro (_ tokens compiler) (case tokens (pattern (list else try)) @@ -153,7 +153,7 @@ _ {#Failure "Wrong syntax for 'else'"}))) -(def: .public when +(def .public when (macro (_ tokens state) (case tokens (pattern (.list test then)) diff --git a/stdlib/source/library/lux/control/writer.lux b/stdlib/source/library/lux/control/writer.lux index 88b536e30..6df2cf695 100644 --- a/stdlib/source/library/lux/control/writer.lux +++ b/stdlib/source/library/lux/control/writer.lux @@ -13,54 +13,54 @@ [#log log #value value])) -(def: .public (write message) +(def .public (write message) (All (_ log) (-> log (Writer log Any))) [message []]) -(def: .public functor +(def .public functor (All (_ l) (Functor (Writer l))) (implementation - (def: (each f fa) + (def (each f fa) (let [[log datum] fa] [log (f datum)])))) -(def: .public (apply monoid) +(def .public (apply monoid) (All (_ l) (-> (Monoid l) (Apply (Writer l)))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (let [[log1 f] ff [log2 a] fa] [(at monoid composite log1 log2) (f a)])))) -(def: .public (monad monoid) +(def .public (monad monoid) (All (_ l) (-> (Monoid l) (Monad (Writer l)))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: in + (def in (|>> [(at monoid identity)])) - (def: (conjoint mma) + (def (conjoint mma) (let [[log1 [log2 a]] mma] [(at monoid composite log1 log2) a])))) -(def: .public (with monoid monad) +(def .public (with monoid monad) (All (_ l M) (-> (Monoid l) (Monad M) (Monad (All (_ a) (M (Writer l a)))))) (implementation - (def: functor + (def functor (functor.composite (the monad.functor monad) ..functor)) - (def: in + (def in (let [writer (..monad monoid)] (|>> (at writer in) (at monad in)))) - (def: (conjoint MlMla) + (def (conjoint MlMla) (do monad [[l1 Mla] (for @.old (is {.#Apply (Writer (parameter 0) @@ -74,7 +74,7 @@ [l2 a] Mla] (in [(at monoid composite l1 l2) a]))))) -(def: .public (lifted monoid monad) +(def .public (lifted monoid monad) (All (_ l M a) (-> (Monoid l) (Monad M) (-> (M a) (M (Writer l a))))) diff --git a/stdlib/source/library/lux/data/binary.lux b/stdlib/source/library/lux/data/binary.lux index b80d38724..102440856 100644 --- a/stdlib/source/library/lux/data/binary.lux +++ b/stdlib/source/library/lux/data/binary.lux @@ -23,15 +23,15 @@ (type: .public Binary /.Binary) -(def: .public size +(def .public size (-> Binary Nat) (|>> /.size)) -(def: .public empty +(def .public empty (-> Nat Binary) (|>> /.empty)) -(def: .public (mix $ init it) +(def .public (mix $ init it) (All (_ a) (-> (-> I64 a a) a Binary a)) (let [size (/.size it)] (loop (again [index 0 @@ -47,7 +47,7 @@ "Index" (%.nat index))) (with_template [<safe> <unsafe> <shift>] - [(def: .public (<safe> index it) + [(def .public (<safe> index it) (-> Nat Binary (Try I64)) (if (n.< (/.size it) (|> index <shift>)) {try.#Success (<unsafe> index it)} @@ -60,7 +60,7 @@ ) (with_template [<safe> <unsafe> <shift>] - [(def: .public (<safe> index value it) + [(def .public (<safe> index value it) (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (/.size it) (|> index <shift>)) {try.#Success (<unsafe> index value it)} @@ -72,10 +72,10 @@ [has_64! /.has_64! (n.+ 7)] ) -(def: .public equivalence +(def .public equivalence (Equivalence Binary) (implementation - (def: (= reference sample) + (def (= reference sample) (/.= reference sample)))) (exception: .public (cannot_copy [bytes Nat @@ -86,7 +86,7 @@ "Source input space" (%.nat source_input) "Target output space" (%.nat target_output))) -(def: .public (copy! bytes source_offset source target_offset target) +(def .public (copy! bytes source_offset source target_offset target) (-> Nat Nat Binary Nat Binary (Try Binary)) (let [source_input (n.- source_offset (/.size source)) target_output (n.- target_offset (/.size target))] @@ -103,7 +103,7 @@ "Offset" (%.nat offset) "Length" (%.nat length))) -(def: .public (slice offset length binary) +(def .public (slice offset length binary) (-> Nat Nat Binary (Try Binary)) (let [size (/.size binary) limit (n.+ length offset)] @@ -111,7 +111,7 @@ (exception.except ..slice_out_of_bounds [size offset length]) {try.#Success (/.slice offset length binary)}))) -(def: .public (after bytes binary) +(def .public (after bytes binary) (-> Nat Binary Binary) (cond (n.= 0 bytes) binary @@ -122,13 +122,13 @@ ... else (/.empty 0))) -(def: .public monoid +(def .public monoid (Monoid Binary) (implementation - (def: identity + (def identity (/.empty 0)) - (def: (composite left right) + (def (composite left right) (let [sizeL (/.size left) sizeR (/.size right) output (/.empty (n.+ sizeL sizeR))] diff --git a/stdlib/source/library/lux/data/bit.lux b/stdlib/source/library/lux/data/bit.lux index 6d9988573..369c9002c 100644 --- a/stdlib/source/library/lux/data/bit.lux +++ b/stdlib/source/library/lux/data/bit.lux @@ -10,56 +10,56 @@ ["[0]" function]]]]) (with_template [<zero> <one>] - [(def: .public <zero> Bit #0) - (def: .public <one> Bit #1)] + [(def .public <zero> Bit #0) + (def .public <one> Bit #1)] [no yes] [off on] ) -(def: .public equivalence +(def .public equivalence (Equivalence Bit) (implementation - (def: (= x y) + (def (= x y) (if x y (not y))))) -(def: .public hash +(def .public hash (Hash Bit) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (hash value) + (def (hash value) (case value #0 2 #1 3)))) (with_template [<name> <identity> <op>] - [(def: .public <name> + [(def .public <name> (Monoid Bit) (implementation - (def: identity <identity>) - (def: (composite x y) (<op> x y))))] + (def identity <identity>) + (def (composite x y) (<op> x y))))] [disjunction #0 or] [conjunction #1 and] ) -(def: .public codec +(def .public codec (Codec Text Bit) (implementation - (def: (encoded x) + (def (encoded x) (if x "#1" "#0")) - (def: (decoded input) + (def (decoded input) (case input "#1" {.#Right #1} "#0" {.#Right #0} _ {.#Left "Wrong syntax for Bit."})))) -(def: .public complement +(def .public complement (All (_ a) (-> (-> a Bit) (-> a Bit))) (function.composite not)) diff --git a/stdlib/source/library/lux/data/collection/array.lux b/stdlib/source/library/lux/data/collection/array.lux index f4e987ca9..0d02cef25 100644 --- a/stdlib/source/library/lux/data/collection/array.lux +++ b/stdlib/source/library/lux/data/collection/array.lux @@ -14,7 +14,7 @@ [variance (.only)]]]] ["!" \\unsafe]) -(def: .public type_name +(def .public type_name Text !.type) @@ -24,123 +24,123 @@ (type: .public Array !.Array) -(def: .public empty +(def .public empty (All (_ a) (-> Nat (Array a))) (|>> !.empty)) -(def: .public size +(def .public size (All (_ r w) (-> (Array' r w) Nat)) (|>> !.size)) -(def: .public (item index array) +(def .public (item index array) (All (_ r w) (-> Nat (Array' r w) (Maybe r))) (if (!.lacks? index array) {.#None} {.#Some (!.item index array)})) -(def: .public (has! index value array) +(def .public (has! index value array) (All (_ r w) (-> Nat w (Array' r w) (Array' r w))) (!.has! index value array)) -(def: .public (lacks! index array) +(def .public (lacks! index array) (All (_ r w) (-> Nat (Array' r w) (Array' r w))) (!.lacks! index array)) -(def: .public (lacks? index array) +(def .public (lacks? index array) (All (_ r w) (-> Nat (Array' r w) Bit)) (!.lacks? index array)) -(def: .public (has? index array) +(def .public (has? index array) (All (_ r w) (-> Nat (Array' r w) Bit)) (!.has? index array)) -(def: .public (revised! index $ array) +(def .public (revised! index $ array) (All (_ r w) (-> Nat (-> r w) (Array' r w) (Array' r w))) (!.revised! index $ array)) -(def: .public (upsert! index default transform array) +(def .public (upsert! index default transform array) (All (_ r w) (-> Nat r (-> r w) (Array' r w) (Array' r w))) (!.upsert! index default transform array)) -(def: .public (copy! length src_start src_array dest_start dest_array) +(def .public (copy! length src_start src_array dest_start dest_array) (All (_ r w) (-> Nat Nat (Array' w Nothing) Nat (Array' r w) (Array' r w))) (!.copy! length src_start src_array dest_start dest_array)) -(def: .public occupancy +(def .public occupancy (All (_ r w) (-> (Array' r w) Nat)) (|>> !.occupancy)) -(def: .public vacancy +(def .public vacancy (All (_ r w) (-> (Array' r w) Nat)) (|>> !.vacancy)) -(def: .public (only! ? it) +(def .public (only! ? it) (All (_ r w) (-> (Predicate r) (Array' r w) (Array' r w))) (!.only! ? it)) -(def: .public (example ? it) +(def .public (example ? it) (All (_ r w) (-> (Predicate r) (Array' r w) (Maybe r))) (!.example ? it)) -(def: .public (example' ? it) +(def .public (example' ? it) (All (_ r w) (-> (-> Nat r Bit) (Array' r w) (Maybe [Nat r]))) (!.example' ? it)) -(def: .public clone +(def .public clone (All (_ a) (-> (Array a) (Array a))) (|>> !.clone)) -(def: .public of_list +(def .public of_list (All (_ a) (-> (List a) (Array a))) (|>> !.of_list)) -(def: .public (list default array) +(def .public (list default array) (All (_ r w) (-> (Maybe r) (Array' r w) (List r))) (!.list default array)) -(def: .public (equivalence //) +(def .public (equivalence //) (All (_ r) (-> (Equivalence r) (Equivalence (Ex (_ w) (Array' r w))))) (implementation - (def: (= left/* right/*) + (def (= left/* right/*) (!.= // left/* right/*)))) -(def: .public monoid +(def .public monoid (All (_ a) (Monoid (Array a))) (implementation - (def: identity (!.empty 0)) + (def identity (!.empty 0)) - (def: (composite left/* right/*) + (def (composite left/* right/*) (!.composite left/* right/*)))) -(def: .public mix +(def .public mix (Mix (All (_ r) (Array' r Nothing))) (implementation - (def: (mix $ init it) + (def (mix $ init it) (!.mix (function (_ index partial total) ($ partial total)) init it)))) -(def: .public functor +(def .public functor (Functor Array) (implementation - (def: (each $ input) + (def (each $ input) (!.each $ input)))) (with_template [<safe> <unsafe>] - [(def: .public (<safe> ? it) + [(def .public (<safe> ? it) (All (_ r w) (-> (Predicate r) (Predicate (Array' r w)))) (<unsafe> ? it))] @@ -149,7 +149,7 @@ [any? !.any?] ) -(def: .public (one ? it) +(def .public (one ? it) (All (_ r r' w) (-> (-> r (Maybe r')) (Array' r w) (Maybe r'))) (!.one ? it)) diff --git a/stdlib/source/library/lux/data/collection/bits.lux b/stdlib/source/library/lux/data/collection/bits.lux index c33ecd77f..8c524156e 100644 --- a/stdlib/source/library/lux/data/collection/bits.lux +++ b/stdlib/source/library/lux/data/collection/bits.lux @@ -17,36 +17,36 @@ (type: .public Chunk I64) -(def: .public chunk_size +(def .public chunk_size i64.width) (type: .public Bits (Array Chunk)) -(def: empty_chunk +(def empty_chunk Chunk (.i64 0)) -(def: .public empty +(def .public empty Bits (array.empty 0)) -(def: .public (size bits) +(def .public (size bits) (-> Bits Nat) (array#mix (function (_ chunk total) (|> chunk i64.ones (n.+ total))) 0 bits)) -(def: .public (capacity bits) +(def .public (capacity bits) (-> Bits Nat) (|> bits array.size (n.* chunk_size))) -(def: .public empty? +(def .public empty? (-> Bits Bit) (|>> ..size (n.= 0))) -(def: .public (bit index bits) +(def .public (bit index bits) (-> Nat Bits Bit) (let [[chunk_index bit_index] (n./% chunk_size index)] (.and (n.< (array.size bits) chunk_index) @@ -54,14 +54,14 @@ (maybe.else empty_chunk) (i64.one? bit_index))))) -(def: (chunk idx bits) +(def (chunk idx bits) (-> Nat Bits Chunk) (if (n.< (array.size bits) idx) (|> bits (array.item idx) (maybe.else empty_chunk)) empty_chunk)) (with_template [<name> <op>] - [(def: .public (<name> index input) + [(def .public (<name> index input) (-> Nat Bits Bits) (let [[chunk_index bit_index] (n./% chunk_size index)] (loop (again [size|output (n.max (++ chunk_index) @@ -94,7 +94,7 @@ [flipped i64.flipped] ) -(def: .public (intersects? reference sample) +(def .public (intersects? reference sample) (-> Bits Bits Bit) (let [chunks (n.min (array.size reference) (array.size sample))] @@ -107,7 +107,7 @@ (again (++ idx))) #0)))) -(def: .public (not input) +(def .public (not input) (-> Bits Bits) (case (array.size input) 0 @@ -131,7 +131,7 @@ output)))))) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Bits Bits Bits) (case (n.max (array.size param) (array.size subject)) @@ -162,10 +162,10 @@ [xor i64.xor] ) -(def: .public equivalence +(def .public equivalence (Equivalence Bits) (implementation - (def: (= reference sample) + (def (= reference sample) (let [size (n.max (array.size reference) (array.size sample))] (loop (again [idx 0]) diff --git a/stdlib/source/library/lux/data/collection/dictionary.lux b/stdlib/source/library/lux/data/collection/dictionary.lux index 124adeceb..a9f167556 100644 --- a/stdlib/source/library/lux/data/collection/dictionary.lux +++ b/stdlib/source/library/lux/data/collection/dictionary.lux @@ -88,7 +88,7 @@ ... Which is the same as 0000 0000 0000 0000 0000 0000 0000 0000. ... Or 0x00000000. ... Which is 32 zeroes, since the branching factor is 32. -(def: clean_bitmap +(def clean_bitmap Bit_Map 0) @@ -101,41 +101,41 @@ ... factor). ... The initial shifting level, though, is 0 (which corresponds to the ... shift in the shallowest node on the tree, which is the root node). -(def: root_level +(def root_level Level 0) ... The exponent to which 2 must be elevated, to reach the branching ... factor of the data-structure. -(def: branching_exponent +(def branching_exponent Nat 5) ... The threshold on which #Hierarchy nodes are demoted to #Base nodes, ... which is 1/4 of the branching factor (or a left-shift 2). -(def: demotion_threshold +(def demotion_threshold Nat (i64.left_shifted (n.- 2 branching_exponent) 1)) ... The threshold on which #Base nodes are promoted to #Hierarchy nodes, ... which is 1/2 of the branching factor (or a left-shift 1). -(def: promotion_threshold +(def promotion_threshold Nat (i64.left_shifted (n.- 1 branching_exponent) 1)) ... The size of hierarchy-nodes, which is 2^(branching-exponent). -(def: hierarchy_nodes_size +(def hierarchy_nodes_size Nat (i64.left_shifted branching_exponent 1)) ... The cannonical empty node, which is just an empty #Base node. -(def: empty_node +(def empty_node Node {#Base clean_bitmap (array.empty 0)}) ... Expands a copy of the array, to have 1 extra slot, which is used ... for storing the value. -(def: (array#has idx value old_array) +(def (array#has idx value old_array) (All (_ a) (-> Index a (Array a) (Array a))) (let [old_size (array.size old_array)] (|> (array.empty (++ old_size)) @@ -144,19 +144,19 @@ (array.copy! (n.- idx old_size) idx old_array (++ idx))))) ... Creates a copy of an array with an index set to a particular value. -(def: (array#revised idx value array) +(def (array#revised idx value array) (All (_ a) (-> Index a (Array a) (Array a))) (|> array array.clone (array.has! idx value))) ... Creates a clone of the array, with an empty position at index. -(def: (array#clear idx array) +(def (array#clear idx array) (All (_ a) (-> Index (Array a) (Array a))) (|> array array.clone (array.lacks! idx))) ... Shrinks a copy of the array by removing the space at index. -(def: (array#lacks idx array) +(def (array#lacks idx array) (All (_ a) (-> Index (Array a) (Array a))) (let [new_size (-- (array.size array))] (|> (array.empty new_size) @@ -165,32 +165,32 @@ ... Increases the level-shift by the branching-exponent, to explore ... levels further down the tree. -(def: level_up +(def level_up (-> Level Level) (n.+ branching_exponent)) -(def: hierarchy_mask +(def hierarchy_mask Bit_Map (-- hierarchy_nodes_size)) ... Gets the branching-factor sized section of the hash corresponding ... to a particular level, and uses that as an index into the array. -(def: (level_index level hash) +(def (level_index level hash) (-> Level Hash_Code Index) (i64.and ..hierarchy_mask (i64.right_shifted level hash))) ... A mechanism to go from indices to bit-positions. -(def: (to_bit_position index) +(def (to_bit_position index) (-> Index Bit_Position) (i64.left_shifted index 1)) ... The bit-position within a base that a given hash-code would have. -(def: (level_bit_position level hash) +(def (level_bit_position level hash) (-> Level Hash_Code Bit_Position) (to_bit_position (level_index level hash))) -(def: (with_bit_position? bit bitmap) +(def (with_bit_position? bit bitmap) (-> Bit_Position Bit_Map Bit) (|> bitmap (i64.and bit) @@ -198,39 +198,39 @@ not)) ... Figures out whether a bitmap only contains a single bit-position. -(def: only_bit_position? +(def only_bit_position? (-> Bit_Position Bit_Map Bit) n.=) -(def: (with_bit_position bit bitmap) +(def (with_bit_position bit bitmap) (-> Bit_Position Bit_Map Bit_Map) (i64.or bit bitmap)) -(def: without_bit_position +(def without_bit_position (-> Bit_Position Bit_Map Bit_Map) i64.xor) ... Figures out the size of a bitmap-indexed array by counting all the ... 1s within the bitmap. -(def: bitmap_size +(def bitmap_size (-> Bit_Map Nat) i64.ones) ... A mask that, for a given bit position, only allows all the 1s prior ... to it, which would indicate the bitmap-size (and, thus, index) ... associated with it. -(def: bit_position_mask +(def bit_position_mask (-> Bit_Position Bit_Map) --) ... The index on the base array, based on its bit-position. -(def: (base_index bit_position bitmap) +(def (base_index bit_position bitmap) (-> Bit_Position Bit_Map Index) (bitmap_size (i64.and (bit_position_mask bit_position) bitmap))) ... Produces the index of a KV-pair within a #Collisions node. -(def: (collision_index key_hash key colls) +(def (collision_index key_hash key colls) (All (_ k v) (-> (Hash k) k (Collisions k v) (Maybe Index))) (at maybe.monad each product.left (array.example' (function (_ idx [key' val']) @@ -239,7 +239,7 @@ ... When #Hierarchy nodes grow too small, they're demoted to #Base ... nodes to save space. -(def: (demotion except_idx [h_size h_array]) +(def (demotion except_idx [h_size h_array]) (All (_ k v) (-> Index (Hierarchy k v) [Bit_Map (Base k v)])) (product.right (list#mix (function (_ idx [insertion_idx node]) (let [[bitmap base] node] @@ -256,11 +256,11 @@ ... When #Base nodes grow too large, they're promoted to #Hierarchy to ... add some depth to the tree and help keep its balance. -(def: hierarchy_indices +(def hierarchy_indices (List Index) (list.indices hierarchy_nodes_size)) -(def: (promotion node#has key_hash level bitmap base) +(def (promotion node#has key_hash level bitmap base) (All (_ k v) (-> (-> Level Hash_Code k v (Hash k) (Node k v) (Node k v)) (Hash k) Level @@ -286,7 +286,7 @@ ... All empty nodes look the same (a #Base node with clean bitmap is ... used). ... So, this test is introduced to detect them. -(def: (node#empty? node) +(def (node#empty? node) (All (_ k v) (-> (Node k v) Bit)) (`` (case node {#Base (~~ (static ..clean_bitmap)) _} @@ -295,7 +295,7 @@ _ #0))) -(def: (node#has level hash key val key_hash node) +(def (node#has level hash key val key_hash node) (All (_ k v) (-> Level Hash_Code k v (Hash k) (Node k v) (Node k v))) (case node ... For #Hierarchy nodes, check whether one can add the element to @@ -387,7 +387,7 @@ (node#has level hash key val key_hash))) )) -(def: (node#lacks level hash key key_hash node) +(def (node#lacks level hash key key_hash node) (All (_ k v) (-> Level Hash_Code k (Hash k) (Node k v) (Node k v))) (case node ... For #Hierarchy nodes, find out if there's a valid sub-node for @@ -474,7 +474,7 @@ {#Collisions _hash (array#lacks idx _colls)})) )) -(def: (node#value level hash key key_hash node) +(def (node#value level hash key key_hash node) (All (_ k v) (-> Level Hash_Code k (Hash k) (Node k v) (Maybe v))) (case node ... For #Hierarchy nodes, just look-up the key on its children. @@ -505,7 +505,7 @@ _colls)) )) -(def: (node#size node) +(def (node#size node) (All (_ k v) (-> (Node k v) Nat)) (case node {#Hierarchy _size hierarchy} @@ -528,7 +528,7 @@ (array.size colls) )) -(def: (node#mix f init node) +(def (node#mix f init node) (All (_ k v a) (-> (-> [k v] a a) a (Node k v) a)) (case node {#Hierarchy _size hierarchy} @@ -554,7 +554,7 @@ init colls))) -(def: node#entries +(def node#entries (All (_ k v) (-> (Node k v) (List [k v]))) (node#mix (function (_ head tail) {.#Item head tail}) @@ -565,31 +565,31 @@ [#hash (Hash k) #root (Node k v)])) -(def: .public key_hash +(def .public key_hash (All (_ k v) (-> (Dictionary k v) (Hash k))) (the ..#hash)) -(def: .public (empty key_hash) +(def .public (empty key_hash) (All (_ k v) (-> (Hash k) (Dictionary k v))) [#hash key_hash #root ..empty_node]) -(def: .public (has key val dict) +(def .public (has key val dict) (All (_ k v) (-> k v (Dictionary k v) (Dictionary k v))) (let [[key_hash node] dict] [key_hash (node#has root_level (at key_hash hash key) key val key_hash node)])) -(def: .public (lacks key dict) +(def .public (lacks key dict) (All (_ k v) (-> k (Dictionary k v) (Dictionary k v))) (let [[key_hash node] dict] [key_hash (node#lacks root_level (at key_hash hash key) key key_hash node)])) -(def: .public (value key dict) +(def .public (value key dict) (All (_ k v) (-> k (Dictionary k v) (Maybe v))) (let [[key_hash node] dict] (node#value root_level (at key_hash hash key) key key_hash node))) -(def: .public (key? dict key) +(def .public (key? dict key) (All (_ k v) (-> (Dictionary k v) k Bit)) (case (value key dict) {.#None} #0 @@ -597,13 +597,13 @@ (exception: .public key_already_exists) -(def: .public (has' key val dict) +(def .public (has' key val dict) (All (_ k v) (-> k v (Dictionary k v) (Try (Dictionary k v)))) (case (value key dict) {.#None} {try.#Success (has key val dict)} {.#Some _} (exception.except ..key_already_exists []))) -(def: .public (revised key f dict) +(def .public (revised key f dict) (All (_ k v) (-> k (-> v v) (Dictionary k v) (Dictionary k v))) (case (value key dict) {.#None} @@ -612,26 +612,26 @@ {.#Some val} (has key (f val) dict))) -(def: .public (revised' key default f dict) +(def .public (revised' key default f dict) (All (_ k v) (-> k v (-> v v) (Dictionary k v) (Dictionary k v))) (..has key (f (maybe.else default (..value key dict))) dict)) -(def: .public size +(def .public size (All (_ k v) (-> (Dictionary k v) Nat)) (|>> (the #root) ..node#size)) -(def: .public empty? +(def .public empty? (All (_ k v) (-> (Dictionary k v) Bit)) (|>> size (n.= 0))) -(def: .public entries +(def .public entries (All (_ k v) (-> (Dictionary k v) (List [k v]))) (|>> (the #root) ..node#entries)) -(def: .public (of_list key_hash kvs) +(def .public (of_list key_hash kvs) (All (_ k v) (-> (Hash k) (List [k v]) (Dictionary k v))) (list#mix (function (_ [k v] dict) (..has k v dict)) @@ -639,7 +639,7 @@ kvs)) (with_template [<side> <name>] - [(def: .public <name> + [(def .public <name> (All (_ k v) (-> (Dictionary k v) (List <side>))) (|>> (the #root) (node#mix (function (_ [k v] bundle) @@ -650,14 +650,14 @@ [v values] ) -(def: .public (composite dict2 dict1) +(def .public (composite dict2 dict1) (All (_ k v) (-> (Dictionary k v) (Dictionary k v) (Dictionary k v))) (node#mix (function (_ [key val] dict) (has key val dict)) dict1 (the #root dict2))) -(def: .public (composite_with f dict2 dict1) +(def .public (composite_with f dict2 dict1) (All (_ k v) (-> (-> v v v) (Dictionary k v) (Dictionary k v) (Dictionary k v))) (node#mix (function (_ [key val2] dict) (case (value key dict) @@ -669,7 +669,7 @@ dict1 (the #root dict2))) -(def: .public (re_bound from_key to_key dict) +(def .public (re_bound from_key to_key dict) (All (_ k v) (-> k k (Dictionary k v) (Dictionary k v))) (case (value from_key dict) {.#None} @@ -680,7 +680,7 @@ (lacks from_key) (has to_key val)))) -(def: .public (sub keys dict) +(def .public (sub keys dict) (All (_ k v) (-> (List k) (Dictionary k v) (Dictionary k v))) (let [[key_hash _] dict] (list#mix (function (_ key new_dict) @@ -690,10 +690,10 @@ (empty key_hash) keys))) -(def: .public (equivalence (open ",#[0]")) +(def .public (equivalence (open ",#[0]")) (All (_ k v) (-> (Equivalence v) (Equivalence (Dictionary k v)))) (implementation - (def: (= reference subject) + (def (= reference subject) (and (n.= (..size reference) (..size subject)) (list.every? (function (_ [k rv]) @@ -705,10 +705,10 @@ #0)) (..entries reference)))))) -(def: node_functor +(def node_functor (All (_ k) (Functor (Node k))) (implementation - (def: (each f fa) + (def (each f fa) (case fa {#Hierarchy size hierarchy} {#Hierarchy size (array.each (each f) hierarchy)} @@ -728,14 +728,14 @@ [k (f v)]) collisions)})))) -(def: .public functor +(def .public functor (All (_ k) (Functor (Dictionary k))) (implementation - (def: (each f fa) + (def (each f fa) (.revised #root (at ..node_functor each f) fa)))) -(def: .public (monoid hash) +(def .public (monoid hash) (All (_ k v) (-> (Hash k) (Monoid (Dictionary k v)))) (implementation - (def: identity (..empty hash)) - (def: composite ..composite))) + (def identity (..empty hash)) + (def composite ..composite))) diff --git a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux index 38521368c..8592aaeec 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux @@ -17,7 +17,7 @@ [number ["n" nat]]]]]) -(def: error_message +(def error_message "Invariant violation") (type: Color @@ -34,7 +34,7 @@ #right (Maybe (Node k v))])) (with_template [<create> <color>] - [(def: (<create> key value left right) + [(def (<create> key value left right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) [#color {<color>} #key key @@ -51,14 +51,14 @@ [#order (Order k) #root (Maybe (Node k v))])) -(def: .public (empty order) +(def .public (empty order) (All (_ k v) (-> (Order k) (Dictionary k v))) [#order order #root {.#None}]) ... TODO: Doing inneficient access of Order functions due to compiler bug. ... TODO: Must improve it as soon as bug is fixed. -(def: .public (value key dict) +(def .public (value key dict) (All (_ k v) (-> k (Dictionary k v) (Maybe v))) (let [... (open "_#[0]") (the #order dict) ] @@ -83,7 +83,7 @@ ... TODO: Doing inneficient access of Order functions due to compiler bug. ... TODO: Must improve it as soon as bug is fixed. -(def: .public (key? dict key) +(def .public (key? dict key) (All (_ k v) (-> (Dictionary k v) k Bit)) (let [... (open "_#[0]") (the #order dict) ] @@ -102,7 +102,7 @@ (again (the #right node))))))))) (with_template [<name> <side>] - [(def: .public (<name> dict) + [(def .public (<name> dict) (All (_ k v) (-> (Dictionary k v) (Maybe v))) (case (the #root dict) {.#None} @@ -121,7 +121,7 @@ [max #right] ) -(def: .public (size dict) +(def .public (size dict) (All (_ k v) (-> (Dictionary k v) Nat)) (loop (again [node (the #root dict)]) (case node @@ -132,12 +132,12 @@ (++ (n.+ (again (the #left node)) (again (the #right node))))))) -(def: .public empty? +(def .public empty? (All (_ k v) (-> (Dictionary k v) Bit)) (|>> ..size (n.= 0))) (with_template [<name> <other_color> <self_color> <no_change>] - [(def: (<name> self) + [(def (<name> self) (All (_ k v) (-> (Node k v) (Node k v))) (case (the #color self) {<other_color>} @@ -151,7 +151,7 @@ [reddened #Black #Red (panic! error_message)] ) -(def: (with_left addition center) +(def (with_left addition center) (All (_ k v) (-> (Node k v) (Node k v) (Node k v))) (case (the #color center) {#Red} @@ -200,7 +200,7 @@ {#Black} <default_behavior>)))) -(def: (with_right addition center) +(def (with_right addition center) (All (_ k v) (-> (Node k v) (Node k v) (Node k v))) (case (the #color center) {#Red} @@ -249,7 +249,7 @@ {#Black} <default_behavior>)))) -(def: .public (has key value dict) +(def .public (has key value dict) (All (_ k v) (-> k v (Dictionary k v) (Dictionary k v))) (let [(open "_#[0]") (the #order dict) root' (loop (again [?root (the #root dict)]) @@ -278,7 +278,7 @@ ))] (.has #root root' dict))) -(def: (left_balanced key value ?left ?right) +(def (left_balanced key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?left (^.multi {.#Some left} @@ -307,7 +307,7 @@ _ (black key value ?left ?right))) -(def: (right_balanced key value ?left ?right) +(def (right_balanced key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?right (^.multi {.#Some right} @@ -334,7 +334,7 @@ _ (black key value ?left ?right))) -(def: (without_left key value ?left ?right) +(def (without_left key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?left (^.multi {.#Some left} @@ -363,7 +363,7 @@ (panic! error_message)) )) -(def: (without_right key value ?left ?right) +(def (without_right key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?right (^.multi {.#Some right} @@ -392,7 +392,7 @@ (panic! error_message) ))) -(def: (prepended ?left ?right) +(def (prepended ?left ?right) (All (_ k v) (-> (Maybe (Node k v)) (Maybe (Node k v)) (Maybe (Node k v)))) (case [?left ?right] [{.#None} _] @@ -472,7 +472,7 @@ _ (undefined))) -(def: .public (lacks key dict) +(def .public (lacks key dict) (All (_ k v) (-> k (Dictionary k v) (Dictionary k v))) (let [(open "_#[0]") (the #order dict) [?root found?] (loop (again [?root (the #root dict)]) @@ -527,7 +527,7 @@ (.has #root {.#Some (blackened root)} dict) ))) -(def: .public (revised key transform dict) +(def .public (revised key transform dict) (All (_ k v) (-> k (-> v v) (Dictionary k v) (Dictionary k v))) (case (..value key dict) {.#Some old} @@ -536,7 +536,7 @@ {.#None} dict)) -(def: .public (of_list order list) +(def .public (of_list order list) (All (_ k v) (-> (Order k) (List [k v]) (Dictionary k v))) (list#mix (function (_ [key value] dict) (..has key value dict)) @@ -544,7 +544,7 @@ list)) (with_template [<name> <type> <output>] - [(def: .public (<name> dict) + [(def .public (<name> dict) (All (_ k v) (-> (Dictionary k v) (List <type>))) (loop (again [node (the #root dict)]) (case node @@ -562,10 +562,10 @@ [values v (the #value node')] ) -(def: .public (equivalence (open ",#[0]")) +(def .public (equivalence (open ",#[0]")) (All (_ k v) (-> (Equivalence v) (Equivalence (Dictionary k v)))) (implementation - (def: (= reference sample) + (def (= reference sample) (let [(open "/#[0]") (the #order reference)] (loop (again [entriesR (entries reference) entriesS (entries sample)]) diff --git a/stdlib/source/library/lux/data/collection/dictionary/plist.lux b/stdlib/source/library/lux/data/collection/dictionary/plist.lux index d594f7b5e..3dd3521c4 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/plist.lux @@ -19,19 +19,19 @@ (type: .public (PList a) (List [Text a])) -(def: .public empty +(def .public empty PList {.#End}) -(def: .public size +(def .public size (All (_ a) (-> (PList a) Nat)) list.size) -(def: .public empty? +(def .public empty? (All (_ a) (-> (PList a) Bit)) (|>> ..size (n.= 0))) -(def: .public (value key properties) +(def .public (value key properties) (All (_ a) (-> Text (PList a) (Maybe a))) (case properties {.#End} @@ -43,7 +43,7 @@ (value key properties')))) (with_template [<name> <type> <access>] - [(def: .public <name> + [(def .public <name> (All (_ a) (-> (PList a) (List <type>))) (list#each <access>))] @@ -51,7 +51,7 @@ [values a product.right] ) -(def: .public (contains? key properties) +(def .public (contains? key properties) (All (_ a) (-> Text (PList a) Bit)) (case (..value key properties) {.#Some _} @@ -60,7 +60,7 @@ {.#None} false)) -(def: .public (has key val properties) +(def .public (has key val properties) (All (_ a) (-> Text a (PList a) (PList a))) (case properties {.#End} @@ -73,7 +73,7 @@ {.#Item [k' v'] (has key val properties')}))) -(def: .public (revised key f properties) +(def .public (revised key f properties) (All (_ a) (-> Text (-> a a) (PList a) (PList a))) (case properties {.#End} @@ -84,7 +84,7 @@ {.#Item [k' (f v')] properties'} {.#Item [k' v'] (revised key f properties')}))) -(def: .public (lacks key properties) +(def .public (lacks key properties) (All (_ a) (-> Text (PList a) (PList a))) (case properties {.#End} @@ -96,10 +96,10 @@ {.#Item [k' v'] (lacks key properties')}))) -(def: .public (equivalence (open "/#[0]")) +(def .public (equivalence (open "/#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (PList a)))) (implementation - (def: (= reference subject) + (def (= reference subject) (and (n.= (list.size reference) (list.size subject)) (list.every? (function (_ [key val]) @@ -109,13 +109,13 @@ (maybe.else false))) subject))))) -(def: .public monoid +(def .public monoid (All (_ a) (Monoid (PList a))) (implementation - (def: identity + (def identity ..empty) - (def: (composite left right) + (def (composite left right) (list#mix (function (_ [key val] it) (..has key val it)) right diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux index dec3d00c1..6be267e78 100644 --- a/stdlib/source/library/lux/data/collection/list.lux +++ b/stdlib/source/library/lux/data/collection/list.lux @@ -23,10 +23,10 @@ ... #End ... {#Item a (List a)}) -(def: .public mix +(def .public mix (Mix List) (implementation - (def: (mix f init xs) + (def (mix f init xs) (case xs {.#End} init @@ -34,7 +34,7 @@ {.#Item x xs'} (mix f (f x init) xs'))))) -(def: .public (mixes f init inputs) +(def .public (mixes f init inputs) (All (_ a b) (-> (-> a b b) b (List a) (List b))) (case inputs {.#End} @@ -43,7 +43,7 @@ {.#Item [head tail]} {.#Item [init (mixes f (f head init) tail)]})) -(def: .public (reversed xs) +(def .public (reversed xs) (All (_ a) (-> (List a) (List a))) (mix (function (_ head tail) @@ -51,7 +51,7 @@ {.#End} xs)) -(def: .public (only keep? xs) +(def .public (only keep? xs) (All (_ a) (-> (Predicate a) (List a) (List a))) (case xs @@ -63,7 +63,7 @@ {.#Item x (only keep? xs')} (only keep? xs')))) -(def: .public (partition satisfies? list) +(def .public (partition satisfies? list) (All (_ a) (-> (Predicate a) (List a) [(List a) (List a)])) (case list {.#End} @@ -75,12 +75,12 @@ [{.#Item head in} out] [in {.#Item head out}])))) -(def: wrong_syntax_error +(def wrong_syntax_error (template (_ <it>) [((`` ("lux in-module" (~~ (static .prelude)) .wrong_syntax_error)) (symbol <it>))])) -(def: .public partial +(def .public partial (macro (_ tokens state) (case (reversed tokens) {.#Item tail heads} @@ -92,7 +92,7 @@ _ {.#Left (wrong_syntax_error ..partial)}))) -(def: .public (pairs xs) +(def .public (pairs xs) (All (_ a) (-> (List a) (Maybe (List [a a])))) (case xs (pattern (partial x1 x2 xs')) @@ -110,7 +110,7 @@ {.#None})) (with_template [<name> <then> <else>] - [(def: .public (<name> n xs) + [(def .public (<name> n xs) (All (_ a) (-> Nat (List a) (List a))) (if (n.> 0 n) @@ -127,7 +127,7 @@ ) (with_template [<name> <then> <else>] - [(def: .public (<name> predicate xs) + [(def .public (<name> predicate xs) (All (_ a) (-> (Predicate a) (List a) (List a))) (case xs @@ -143,7 +143,7 @@ [until (until predicate xs') xs] ) -(def: .public (split_at n xs) +(def .public (split_at n xs) (All (_ a) (-> Nat (List a) [(List a) (List a)])) (case n @@ -156,7 +156,7 @@ (let [[tail rest] (split_at (-- n) xs')] [{.#Item x tail} rest])))) -(def: (split_when' predicate ys xs) +(def (split_when' predicate ys xs) (All (_ a) (-> (Predicate a) (List a) (List a) [(List a) (List a)])) (case xs @@ -168,13 +168,13 @@ [ys xs] (split_when' predicate {.#Item x ys} xs')))) -(def: .public (split_when predicate xs) +(def .public (split_when predicate xs) (All (_ a) (-> (Predicate a) (List a) [(List a) (List a)])) (let [[ys' xs'] (split_when' predicate {.#End} xs)] [(reversed ys') xs'])) -(def: .public (sub size list) +(def .public (sub size list) (All (_ a) (-> Nat (List a) (List (List a)))) (case list {.#End} @@ -184,14 +184,14 @@ (let [[pre post] (split_at size list)] {.#Item pre (sub size post)}))) -(def: .public (repeated n x) +(def .public (repeated n x) (All (_ a) (-> Nat a (List a))) (case n 0 {.#End} _ {.#Item x (repeated (-- n) x)})) -(def: (iterations' f x) +(def (iterations' f x) (All (_ a) (-> (-> a (Maybe a)) a (List a))) (case (f x) @@ -201,7 +201,7 @@ {.#None} (list))) -(def: .public (iterations f x) +(def .public (iterations f x) (All (_ a) (-> (-> a (Maybe a)) a (List a))) (case (f x) @@ -211,7 +211,7 @@ {.#None} (list x))) -(def: .public (one check xs) +(def .public (one check xs) (All (_ a b) (-> (-> a (Maybe b)) (List a) (Maybe b))) (case xs @@ -226,7 +226,7 @@ {.#None} (one check xs')))) -(def: .public (all check xs) +(def .public (all check xs) (All (_ a b) (-> (-> a (Maybe b)) (List a) (List b))) (for @.js @@ -252,7 +252,7 @@ {.#None} (all check xs'))))) -(def: .public (example predicate xs) +(def .public (example predicate xs) (All (_ a) (-> (Predicate a) (List a) (Maybe a))) (..one (function (_ value) @@ -261,7 +261,7 @@ {.#None})) xs)) -(def: .public (interposed sep xs) +(def .public (interposed sep xs) (All (_ a) (-> a (List a) (List a))) (case xs @@ -274,12 +274,12 @@ {.#Item x xs'} (partial x sep (interposed sep xs')))) -(def: .public (size list) +(def .public (size list) (All (_ a) (-> (List a) Nat)) (mix (function (_ _ acc) (n.+ 1 acc)) 0 list)) (with_template [<name> <init> <op>] - [(def: .public (<name> predicate items) + [(def .public (<name> predicate items) (All (_ a) (-> (Predicate a) (List a) Bit)) (case items @@ -294,7 +294,7 @@ [any? #0 or] ) -(def: .public (item i xs) +(def .public (item i xs) (All (_ a) (-> Nat (List a) (Maybe a))) (case xs @@ -306,10 +306,10 @@ 0 {.#Some x} _ (item (-- i) xs')))) -(def: .public (equivalence Equivalence<a>) +(def .public (equivalence Equivalence<a>) (All (_ a) (-> (Equivalence a) (Equivalence (List a)))) (implementation - (def: (= xs ys) + (def (= xs ys) (case [xs ys] [{.#End} {.#End}] #1 @@ -322,24 +322,24 @@ #0 )))) -(def: .public (hash super) +(def .public (hash super) (All (_ a) (-> (Hash a) (Hash (List a)))) (implementation - (def: equivalence + (def equivalence (..equivalence (at super equivalence))) - (def: hash + (def hash (at ..mix mix (function (_ member hash) (n.+ (at super hash member) hash)) 0)))) -(def: .public monoid +(def .public monoid (All (_ a) (Monoid (List a))) (implementation - (def: identity + (def identity {.#End}) - (def: (composite xs ys) + (def (composite xs ys) (case xs {.#End} ys @@ -349,10 +349,10 @@ (open: "[0]" ..monoid) -(def: .public functor +(def .public functor (Functor List) (implementation - (def: (each f ma) + (def (each f ma) (case ma {.#End} {.#End} @@ -362,12 +362,12 @@ (open: "[0]" ..functor) -(def: .public apply +(def .public apply (Apply List) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (case ff {.#End} {.#End} @@ -377,18 +377,18 @@ (on fa) (composite (each f fa))))))) -(def: .public monad +(def .public monad (Monad List) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in a) + (def (in a) {.#Item a {.#End}}) - (def: conjoint + (def conjoint (|>> reversed (mix composite identity))))) -(def: .public (sorted < xs) +(def .public (sorted < xs) (All (_ a) (-> (-> a a Bit) (List a) (List a))) (case xs {.#End} @@ -406,7 +406,7 @@ xs')] (.all composite (sorted < pre) (list x) (sorted < post))))) -(def: .public (empty? xs) +(def .public (empty? xs) (All (_ a) (Predicate (List a))) (case xs {.#End} @@ -415,7 +415,7 @@ _ false)) -(def: .public (member? eq xs x) +(def .public (member? eq xs x) (All (_ a) (-> (Equivalence a) (List a) a Bit)) (case xs {.#End} @@ -426,7 +426,7 @@ (member? eq xs' x)))) (with_template [<name> <output> <side>] - [(def: .public (<name> xs) + [(def .public (<name> xs) (All (_ a) (-> (List a) (Maybe <output>))) (case xs {.#End} @@ -439,17 +439,17 @@ [tail (List a) xs'] ) -(def: .public (indices size) +(def .public (indices size) (All (_ a) (-> Nat (List Nat))) (case size 0 (list) _ (|> size -- (enum.range n.enum 0)))) -(def: (symbol$ name) +(def (symbol$ name) (-> Text Code) [["" 0 0] {.#Symbol "" name}]) -(def: (nat#encoded value) +(def (nat#encoded value) (-> Nat Text) (loop (again [input value output ""]) @@ -471,7 +471,7 @@ 0 output' _ (again input' output'))))) -(def: .public zipped +(def .public zipped (macro (_ tokens state) (case tokens (pattern (list [_ {.#Nat num_lists}])) @@ -509,10 +509,10 @@ _ {.#Left (wrong_syntax_error ..zipped)}))) -(def: .public zipped_2 (zipped 2)) -(def: .public zipped_3 (zipped 3)) +(def .public zipped_2 (zipped 2)) +(def .public zipped_3 (zipped 3)) -(def: .public zipped_with +(def .public zipped_with (macro (_ tokens state) (case tokens (pattern (list [_ {.#Nat num_lists}])) @@ -553,10 +553,10 @@ _ {.#Left (wrong_syntax_error ..zipped_with)}))) -(def: .public zipped_with_2 (zipped_with 2)) -(def: .public zipped_with_3 (zipped_with 3)) +(def .public zipped_with_2 (zipped_with 2)) +(def .public zipped_with_3 (zipped_with 3)) -(def: .public (last xs) +(def .public (last xs) (All (_ a) (-> (List a) (Maybe a))) (case xs {.#End} @@ -568,7 +568,7 @@ {.#Item x xs'} (last xs'))) -(def: .public (inits xs) +(def .public (inits xs) (All (_ a) (-> (List a) (Maybe (List a)))) (case xs {.#End} @@ -586,21 +586,21 @@ {.#Some {.#Item x tail}}) )) -(def: .public together +(def .public together (All (_ a) (-> (List (List a)) (List a))) (at ..monad conjoint)) -(def: .public (with monad) +(def .public (with monad) (All (_ M) (-> (Monad M) (Monad (All (_ a) (M (List a)))))) (implementation - (def: functor + (def functor (functor.composite (the monad.functor monad) ..functor)) - (def: in + (def in (|>> (at ..monad in) (at monad in))) - (def: (conjoint MlMla) + (def (conjoint MlMla) (do [! monad] [lMla MlMla ... TODO: Remove this version ASAP and use one below. @@ -610,11 +610,11 @@ (monad.all ! lMla))] (in (..together lla)))))) -(def: .public (lifted monad) +(def .public (lifted monad) (All (_ M a) (-> (Monad M) (-> (M a) (M (List a))))) (at monad each (at ..monad in))) -(def: .public (enumeration xs) +(def .public (enumeration xs) (All (_ a) (-> (List a) (List [Nat a]))) (loop (again [idx 0 xs xs]) @@ -625,7 +625,7 @@ {.#Item x xs'} {.#Item [idx x] (again (++ idx) xs')}))) -(def: .public when +(def .public when (macro (_ tokens state) (case tokens (pattern (.list test then)) @@ -636,7 +636,7 @@ _ {.#Left (wrong_syntax_error ..when)}))) -(def: .public (revised item revision it) +(def .public (revised item revision it) (All (_ a) (-> Nat (-> a a) (List a) (List a))) (case it {.#End} diff --git a/stdlib/source/library/lux/data/collection/queue.lux b/stdlib/source/library/lux/data/collection/queue.lux index d6d421304..54c1024b6 100644 --- a/stdlib/source/library/lux/data/collection/queue.lux +++ b/stdlib/source/library/lux/data/collection/queue.lux @@ -16,42 +16,42 @@ [#front (List a) #rear (List a)])) -(def: .public empty +(def .public empty Queue [#front (.list) #rear (.list)]) -(def: .public (of_list entries) +(def .public (of_list entries) (All (_ a) (-> (List a) (Queue a))) [#front entries #rear (.list)]) -(def: .public (list queue) +(def .public (list queue) (All (_ a) (-> (Queue a) (List a))) (let [(open "_[0]") queue] (list#composite _#front (list.reversed _#rear)))) -(def: .public front +(def .public front (All (_ a) (-> (Queue a) (Maybe a))) (|>> (the #front) list.head)) -(def: .public (size queue) +(def .public (size queue) (All (_ a) (-> (Queue a) Nat)) (let [(open "_[0]") queue] (n.+ (list.size _#front) (list.size _#rear)))) -(def: .public empty? +(def .public empty? (All (_ a) (-> (Queue a) Bit)) (|>> (the #front) list.empty?)) -(def: .public (member? equivalence queue member) +(def .public (member? equivalence queue member) (All (_ a) (-> (Equivalence a) (Queue a) a Bit)) (let [(open "_[0]") queue] (or (list.member? equivalence _#front member) (list.member? equivalence _#rear member)))) -(def: .public (next queue) +(def .public (next queue) (All (_ a) (-> (Queue a) (Queue a))) (case (the #front queue) ... Empty... @@ -69,7 +69,7 @@ (|> queue (has #front front')))) -(def: .public (end val queue) +(def .public (end val queue) (All (_ a) (-> a (Queue a) (Queue a))) (case (the #front queue) {.#End} @@ -78,17 +78,17 @@ _ (revised #rear (|>> {.#Item val}) queue))) -(def: .public (equivalence super) +(def .public (equivalence super) (All (_ a) (-> (Equivalence a) (Equivalence (Queue a)))) (implementation - (def: (= reference subject) + (def (= reference subject) (at (list.equivalence super) = (..list reference) (..list subject))))) -(def: .public functor +(def .public functor (Functor Queue) (implementation - (def: (each f fa) + (def (each f fa) [#front (|> fa (the #front) (list#each f)) #rear (|> fa (the #rear) (list#each f))]))) diff --git a/stdlib/source/library/lux/data/collection/queue/priority.lux b/stdlib/source/library/lux/data/collection/queue/priority.lux index e3016e239..30cc94613 100644 --- a/stdlib/source/library/lux/data/collection/queue/priority.lux +++ b/stdlib/source/library/lux/data/collection/queue/priority.lux @@ -19,18 +19,18 @@ (type: .public Priority Nat) -(def: .public max +(def .public max Priority n#top) -(def: .public min +(def .public min Priority n#bottom) -(def: builder +(def builder (tree.builder n.maximum)) -(def: :@: +(def :@: (by_example [@] (is (tree.Builder @ Priority) ..builder) @@ -39,18 +39,18 @@ (primitive .public (Queue a) (Maybe (Tree :@: Priority a)) - (def: .public empty + (def .public empty Queue (abstraction {.#None})) - (def: .public (front queue) + (def .public (front queue) (All (_ a) (-> (Queue a) (Maybe a))) (do maybe.monad [tree (representation queue)] (tree.one (n.= (tree.tag tree)) tree))) - (def: .public (size queue) + (def .public (size queue) (All (_ a) (-> (Queue a) Nat)) (case (representation queue) {.#None} @@ -65,7 +65,7 @@ {0 #1 [left right]} (n.+ (again left) (again right)))))) - (def: .public (member? equivalence queue member) + (def .public (member? equivalence queue member) (All (_ a) (-> (Equivalence a) (Queue a) a Bit)) (case (representation queue) {.#None} @@ -81,7 +81,7 @@ (or (again left) (again right)))))) - (def: .public (next queue) + (def .public (next queue) (All (_ a) (-> (Queue a) (Queue a))) (abstraction (do maybe.monad @@ -109,7 +109,7 @@ {.#Some =right} {.#Some (at ..builder branch left =right)}))))))) - (def: .public (end priority value queue) + (def .public (end priority value queue) (All (_ a) (-> Priority a (Queue a) (Queue a))) (let [addition (at ..builder leaf priority value)] (abstraction @@ -121,6 +121,6 @@ {.#Some (at ..builder branch tree addition)})))) ) -(def: .public empty? +(def .public empty? (All (_ a) (-> (Queue a) Bit)) (|>> ..size (n.= 0))) diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux index bae056369..da7ea73c1 100644 --- a/stdlib/source/library/lux/data/collection/sequence.lux +++ b/stdlib/source/library/lux/data/collection/sequence.lux @@ -51,16 +51,16 @@ (type: Index Nat) -(def: branching_exponent +(def branching_exponent Nat 5) -(def: root_level +(def root_level Level 0) (with_template [<name> <op>] - [(def: <name> + [(def <name> (-> Level Level) (<op> branching_exponent))] @@ -68,23 +68,23 @@ [level_down n.-] ) -(def: full_node_size +(def full_node_size Nat (i64.left_shifted branching_exponent 1)) -(def: branch_idx_mask +(def branch_idx_mask Nat (-- full_node_size)) -(def: branch_idx +(def branch_idx (-> Index Index) (i64.and branch_idx_mask)) -(def: (empty_hierarchy _) +(def (empty_hierarchy _) (All (_ a) (-> Any (Hierarchy a))) (array.empty ..full_node_size)) -(def: (tail_off sequence_size) +(def (tail_off sequence_size) (-> Nat Nat) (if (n.< full_node_size sequence_size) 0 @@ -92,7 +92,7 @@ (i64.right_shifted branching_exponent) (i64.left_shifted branching_exponent)))) -(def: (path level tail) +(def (path level tail) (All (_ a) (-> Level (Base a) (Node a))) (if (n.= 0 level) {#Base tail} @@ -100,12 +100,12 @@ (array.has! 0 (path (level_down level) tail)) {#Hierarchy}))) -(def: (tail singleton) +(def (tail singleton) (All (_ a) (-> a (Base a))) (|> (array.empty 1) (array.has! 0 singleton))) -(def: (with_tail size level tail parent) +(def (with_tail size level tail parent) (All (_ a) (-> Nat Level (Base a) (Hierarchy a) (Hierarchy a))) (let [sub_idx (branch_idx (i64.right_shifted level (-- size))) ... If we're currently on a bottom node @@ -126,14 +126,14 @@ (|> (array.clone parent) (array.has! sub_idx sub_node)))) -(def: (expanded_tail val tail) +(def (expanded_tail val tail) (All (_ a) (-> a (Base a) (Base a))) (let [tail_size (array.size tail)] (|> (array.empty (++ tail_size)) (array.copy! tail_size 0 tail 0) (array.has! tail_size val)))) -(def: (hierarchy#has level idx val hierarchy) +(def (hierarchy#has level idx val hierarchy) (All (_ a) (-> Level Index a (Hierarchy a) (Hierarchy a))) (let [sub_idx (branch_idx (i64.right_shifted level idx))] (case (array.item sub_idx hierarchy) @@ -151,7 +151,7 @@ _ (undefined)))) -(def: (without_tail size level hierarchy) +(def (without_tail size level hierarchy) (All (_ a) (-> Nat Level (Hierarchy a) (Maybe (Hierarchy a)))) (let [sub_idx (branch_idx (i64.right_shifted level (n.- 2 size)))] (cond (n.= 0 sub_idx) @@ -176,7 +176,7 @@ {.#Some}) ))) -(def: (node#list node) +(def (node#list node) (All (_ a) (-> (Node a) (List a))) (case node {#Base base} @@ -197,18 +197,18 @@ #root (Hierarchy a) #tail (Base a)])) -(def: .public empty +(def .public empty Sequence [#level (level_up root_level) #size 0 #root (empty_hierarchy []) #tail (array.empty 0)]) -(def: .public (size sequence) +(def .public (size sequence) (All (_ a) (-> (Sequence a) Nat)) (the #size sequence)) -(def: .public (suffix val sequence) +(def .public (suffix val sequence) (All (_ a) (-> a (Sequence a) (Sequence a))) ... Check if there is room in the tail. (let [sequence_size (the #size sequence)] @@ -249,11 +249,11 @@ (exception: base_was_not_found) -(def: .public (within_bounds? sequence idx) +(def .public (within_bounds? sequence idx) (All (_ a) (-> (Sequence a) Nat Bit)) (n.< (the #size sequence) idx)) -(def: (base_for idx sequence) +(def (base_for idx sequence) (All (_ a) (-> Index (Sequence a) (Try (Base a)))) (if (within_bounds? sequence idx) (if (n.< (tail_off (the #size sequence)) idx) @@ -275,7 +275,7 @@ {try.#Success (the #tail sequence)}) (exception.except ..index_out_of_bounds [sequence idx]))) -(def: .public (item idx sequence) +(def .public (item idx sequence) (All (_ a) (-> Nat (Sequence a) (Try a))) (do try.monad [base (base_for idx sequence) @@ -284,7 +284,7 @@ (exception.except ..incorrect_sequence_structure []) {try.#Success (array.item index base)}))) -(def: .public (has idx val sequence) +(def .public (has idx val sequence) (All (_ a) (-> Nat a (Sequence a) (Try (Sequence a)))) (let [sequence_size (the #size sequence)] (if (within_bounds? sequence idx) @@ -297,13 +297,13 @@ sequence))} (exception.except ..index_out_of_bounds [sequence idx])))) -(def: .public (revised idx revision it) +(def .public (revised idx revision it) (All (_ a) (-> Nat (-> a a) (Sequence a) (Try (Sequence a)))) (do try.monad [val (..item idx it)] (..has idx (revision val) it))) -(def: .public (prefix sequence) +(def .public (prefix sequence) (All (_ a) (-> (Sequence a) (Sequence a))) (case (the #size sequence) 0 @@ -348,31 +348,31 @@ (.has #tail new_tail)))))) )) -(def: .public (list sequence) +(def .public (list sequence) (All (_ a) (-> (Sequence a) (List a))) (list#composite (node#list {#Hierarchy (the #root sequence)}) (node#list {#Base (the #tail sequence)}))) -(def: .public of_list +(def .public of_list (All (_ a) (-> (List a) (Sequence a))) (list#mix ..suffix ..empty)) -(def: .public (member? equivalence sequence val) +(def .public (member? equivalence sequence val) (All (_ a) (-> (Equivalence a) (Sequence a) a Bit)) (list.member? equivalence (list sequence) val)) -(def: .public empty? +(def .public empty? (All (_ a) (-> (Sequence a) Bit)) (|>> (the #size) (n.= 0))) -(def: .public sequence +(def .public sequence (syntax (_ [elems (<>.some <code>.any)]) (in (.list (` (..of_list (.list (~+ elems)))))))) -(def: (node_equivalence //#=) +(def (node_equivalence //#=) (All (_ a) (-> (Equivalence a) (Equivalence (Node a)))) (implementation - (def: (= v1 v2) + (def (= v1 v2) (case [v1 v2] [{#Base b1} {#Base b2}] (array.= //#= b1 b2) @@ -383,10 +383,10 @@ _ #0)))) -(def: .public (equivalence //#=) +(def .public (equivalence //#=) (All (_ a) (-> (Equivalence a) (Equivalence (Sequence a)))) (implementation - (def: (= v1 v2) + (def (= v1 v2) (and (n.= (the #size v1) (the #size v2)) (let [(open "node#[0]") (node_equivalence //#=)] (and (node#= {#Base (the #tail v1)} @@ -394,10 +394,10 @@ (node#= {#Hierarchy (the #root v1)} {#Hierarchy (the #root v2)}))))))) -(def: node_mix +(def node_mix (Mix Node) (implementation - (def: (mix $ init xs) + (def (mix $ init xs) (case xs {#Base base} (array.mix (function (_ _ item output) ($ item output)) @@ -409,10 +409,10 @@ init hierarchy))))) -(def: .public mix +(def .public mix (Mix Sequence) (implementation - (def: (mix $ init xs) + (def (mix $ init xs) (let [(open "[0]") node_mix] (mix $ (mix $ @@ -420,18 +420,18 @@ {#Hierarchy (the #root xs)}) {#Base (the #tail xs)}))))) -(def: .public monoid +(def .public monoid (All (_ a) (Monoid (Sequence a))) (implementation - (def: identity ..empty) + (def identity ..empty) - (def: (composite xs ys) + (def (composite xs ys) (list#mix suffix xs (..list ys))))) -(def: node_functor +(def node_functor (Functor Node) (implementation - (def: (each $ xs) + (def (each $ xs) (case xs {#Base base} {#Base (array.each $ base)} @@ -439,10 +439,10 @@ {#Hierarchy hierarchy} {#Hierarchy (array.each (each $) hierarchy)})))) -(def: .public functor +(def .public functor (Functor Sequence) (implementation - (def: (each $ xs) + (def (each $ xs) [#level (the #level xs) #size (the #size xs) #root (let [ ... TODO: This binding was established to get around a compilation error. Fix and inline! @@ -450,12 +450,12 @@ (|> xs (the #root) (array.each $))) #tail (|> xs (the #tail) (array.each $))]))) -(def: .public apply +(def .public apply (Apply Sequence) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (let [(open "[0]") ..functor (open "[0]") ..mix (open "[0]") ..monoid @@ -463,27 +463,27 @@ ff)] (mix composite identity results))))) -(def: .public monad +(def .public monad (Monad Sequence) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: in + (def in (|>> sequence)) - (def: conjoint + (def conjoint (let [(open "[0]") ..mix (open "[0]") ..monoid] (mix (function (_ post pre) (composite pre post)) identity))))) -(def: .public reversed +(def .public reversed (All (_ a) (-> (Sequence a) (Sequence a))) (|>> ..list list.reversed (list#mix suffix ..empty))) (with_template [<name> <array> <init> <op>] - [(def: .public <name> + [(def .public <name> (All (_ a) (-> (Predicate a) (Sequence a) Bit)) (let [help (is (All (_ a) @@ -504,7 +504,7 @@ [any? array.any? #0 or] ) -(def: .public (only when items) +(def .public (only when items) (All (_ a) (-> (-> a Bit) (Sequence a) (Sequence a))) (..mix (function (_ item output) (if (when item) @@ -513,7 +513,7 @@ ..empty items)) -(def: (one|node check items) +(def (one|node check items) (All (_ a b) (-> (-> a (Maybe b)) (Node a) (Maybe b))) (case items @@ -523,7 +523,7 @@ {#Hierarchy items} (array.one (one|node check) items))) -(def: .public (one check items) +(def .public (one check items) (All (_ a b) (-> (-> a (Maybe b)) (Sequence a) (Maybe b))) (case (let [... TODO: This binding was established to get around a compilation error. Fix and inline! diff --git a/stdlib/source/library/lux/data/collection/set.lux b/stdlib/source/library/lux/data/collection/set.lux index 138d5c351..fd2e32815 100644 --- a/stdlib/source/library/lux/data/collection/set.lux +++ b/stdlib/source/library/lux/data/collection/set.lux @@ -20,88 +20,88 @@ (type: .public (Set a) (Dictionary a Any)) -(def: .public member_hash +(def .public member_hash (All (_ a) (-> (Set a) (Hash a))) //.key_hash) -(def: .public empty +(def .public empty (All (_ a) (-> (Hash a) (Set a))) //.empty) -(def: .public size +(def .public size (All (_ a) (-> (Set a) Nat)) //.size) -(def: .public (has elem set) +(def .public (has elem set) (All (_ a) (-> a (Set a) (Set a))) (|> set (//.has elem []))) -(def: .public lacks +(def .public lacks (All (_ a) (-> a (Set a) (Set a))) //.lacks) -(def: .public member? +(def .public member? (All (_ a) (-> (Set a) a Bit)) //.key?) -(def: .public list +(def .public list (All (_ a) (-> (Set a) (List a))) //.keys) -(def: .public union +(def .public union (All (_ a) (-> (Set a) (Set a) (Set a))) //.composite) -(def: .public (difference sub base) +(def .public (difference sub base) (All (_ a) (-> (Set a) (Set a) (Set a))) (list#mix ..lacks base (..list sub))) -(def: .public (intersection filter base) +(def .public (intersection filter base) (All (_ a) (-> (Set a) (Set a) (Set a))) (//.sub (//.keys filter) base)) -(def: .public equivalence +(def .public equivalence (All (_ a) (Equivalence (Set a))) (implementation - (def: (= (^.let reference [hash _]) sample) + (def (= (^.let reference [hash _]) sample) (and (n.= (..size reference) (..size sample)) (list.every? (..member? reference) (..list sample)))))) -(def: .public hash +(def .public hash (All (_ a) (Hash (Set a))) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (hash set) + (def (hash set) (|> set ..list (at (list.hash (..member_hash set)) hash))))) -(def: .public (monoid hash) +(def .public (monoid hash) (All (_ a) (-> (Hash a) (Monoid (Set a)))) (implementation - (def: identity (..empty hash)) - (def: composite ..union))) + (def identity (..empty hash)) + (def composite ..union))) -(def: .public empty? +(def .public empty? (All (_ a) (-> (Set a) Bit)) (|>> ..size (n.= 0))) -(def: .public (of_list hash elements) +(def .public (of_list hash elements) (All (_ a) (-> (Hash a) (List a) (Set a))) (list#mix ..has (..empty hash) elements)) -(def: .public (sub? super sub) +(def .public (sub? super sub) (All (_ a) (-> (Set a) (Set a) Bit)) (list.every? (..member? super) (..list sub))) -(def: .public (super? sub super) +(def .public (super? sub super) (All (_ a) (-> (Set a) (Set a) Bit)) (..sub? super sub)) -(def: .public predicate +(def .public predicate (All (_ a) (-> (Set a) (Predicate a))) ..member?) diff --git a/stdlib/source/library/lux/data/collection/set/multi.lux b/stdlib/source/library/lux/data/collection/set/multi.lux index 3e63b2926..72e1e1620 100644 --- a/stdlib/source/library/lux/data/collection/set/multi.lux +++ b/stdlib/source/library/lux/data/collection/set/multi.lux @@ -23,15 +23,15 @@ (primitive .public (Set a) (Dictionary a Nat) - (def: .public empty + (def .public empty (All (_ a) (-> (Hash a) (Set a))) (|>> dictionary.empty abstraction)) - (def: .public size + (def .public size (All (_ a) (-> (Set a) Nat)) (|>> representation dictionary.values (list#mix n.+ 0))) - (def: .public (has multiplicity elem set) + (def .public (has multiplicity elem set) (All (_ a) (-> Nat a (Set a) (Set a))) (case multiplicity 0 set @@ -40,7 +40,7 @@ (dictionary.revised' elem 0 (n.+ multiplicity)) abstraction))) - (def: .public (lacks multiplicity elem set) + (def .public (lacks multiplicity elem set) (All (_ a) (-> Nat a (Set a) (Set a))) (case multiplicity 0 set @@ -54,11 +54,11 @@ {.#None} set))) - (def: .public (multiplicity set elem) + (def .public (multiplicity set elem) (All (_ a) (-> (Set a) a Nat)) (|> set representation (dictionary.value elem) (maybe.else 0))) - (def: .public list + (def .public list (All (_ a) (-> (Set a) (List a))) (|>> representation dictionary.entries @@ -67,7 +67,7 @@ {.#End}))) (with_template [<name> <composite>] - [(def: .public (<name> parameter subject) + [(def .public (<name> parameter subject) (All (_ a) (-> (Set a) (Set a) (Set a))) (abstraction (dictionary.composite_with <composite> (representation parameter) (representation subject))))] @@ -75,7 +75,7 @@ [sum n.+] ) - (def: .public (intersection parameter subject) + (def .public (intersection parameter subject) (All (_ a) (-> (Set a) (Set a) (Set a))) (let [subject (representation subject)] (list#mix (function (_ [elem multiplicity] output) @@ -86,7 +86,7 @@ (..empty (dictionary.key_hash subject)) (dictionary.entries subject)))) - (def: .public (difference parameter subject) + (def .public (difference parameter subject) (All (_ a) (-> (Set a) (Set a) (Set a))) (|> parameter representation @@ -95,7 +95,7 @@ (..lacks multiplicity elem output)) subject))) - (def: .public (sub? reference subject) + (def .public (sub? reference subject) (All (_ a) (-> (Set a) (Set a) Bit)) (|> subject representation @@ -105,17 +105,17 @@ (..multiplicity reference) (n.>= multiplicity)))))) - (def: .public (support set) + (def .public (support set) (All (_ a) (-> (Set a) (//.Set a))) (let [(^.let set [hash _]) (representation set)] (|> set dictionary.keys (//.of_list hash)))) - (def: .public equivalence + (def .public equivalence (All (_ a) (Equivalence (Set a))) (implementation - (def: (= reference sample) + (def (= reference sample) (let [reference (representation reference)] (and (n.= (dictionary.size reference) (dictionary.size (representation sample))) @@ -126,12 +126,12 @@ (..multiplicity sample) (n.= multiplicity)))))))))) - (def: .public hash + (def .public hash (All (_ a) (Hash (Set a))) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (hash set) + (def (hash set) (let [set (representation set) [hash _] set] (list#mix (function (_ [elem multiplicity] acc) @@ -140,23 +140,23 @@ (dictionary.entries set)))))) ) -(def: .public (member? set elem) +(def .public (member? set elem) (All (_ a) (-> (Set a) a Bit)) (|> elem (..multiplicity set) (n.> 0))) -(def: .public empty? +(def .public empty? (All (_ a) (-> (Set a) Bit)) (|>> ..size (n.= 0))) -(def: .public (of_list hash subject) +(def .public (of_list hash subject) (All (_ a) (-> (Hash a) (List a) (Set a))) (list#mix (..has 1) (..empty hash) subject)) -(def: .public (of_set subject) +(def .public (of_set subject) (All (_ a) (-> (//.Set a) (Set a))) (..of_list (//.member_hash subject) (//.list subject))) -(def: .public super? +(def .public super? (All (_ a) (-> (Set a) (Set a) Bit)) (function.flipped sub?)) diff --git a/stdlib/source/library/lux/data/collection/set/ordered.lux b/stdlib/source/library/lux/data/collection/set/ordered.lux index c876afca0..5cdd23dec 100644 --- a/stdlib/source/library/lux/data/collection/set/ordered.lux +++ b/stdlib/source/library/lux/data/collection/set/ordered.lux @@ -15,16 +15,16 @@ (primitive .public (Set a) (/.Dictionary a a) - (def: .public empty + (def .public empty (All (_ a) (-> (Order a) (Set a))) (|>> /.empty abstraction)) - (def: .public (member? set elem) + (def .public (member? set elem) (All (_ a) (-> (Set a) a Bit)) (/.key? (representation set) elem)) (with_template [<type> <name> <alias>] - [(def: .public <name> + [(def .public <name> (All (_ a) (-> (Set a) <type>)) (|>> representation <alias>))] @@ -34,52 +34,52 @@ [Bit empty? /.empty?] ) - (def: .public (has elem set) + (def .public (has elem set) (All (_ a) (-> a (Set a) (Set a))) (|> set representation (/.has elem elem) abstraction)) - (def: .public (lacks elem set) + (def .public (lacks elem set) (All (_ a) (-> a (Set a) (Set a))) (|> set representation (/.lacks elem) abstraction)) - (def: .public list + (def .public list (All (_ a) (-> (Set a) (List a))) (|>> representation /.keys)) - (def: .public (of_list order list) + (def .public (of_list order list) (All (_ a) (-> (Order a) (List a) (Set a))) (list#mix has (..empty order) list)) - (def: .public (union left right) + (def .public (union left right) (All (_ a) (-> (Set a) (Set a) (Set a))) (list#mix ..has right (..list left))) - (def: .public (intersection left right) + (def .public (intersection left right) (All (_ a) (-> (Set a) (Set a) (Set a))) (|> (..list right) (list.only (..member? left)) (..of_list (the /.#order (representation right))))) - (def: .public (difference param subject) + (def .public (difference param subject) (All (_ a) (-> (Set a) (Set a) (Set a))) (|> (..list subject) (list.only (|>> (..member? param) not)) (..of_list (the /.#order (representation subject))))) - (def: .public equivalence + (def .public equivalence (All (_ a) (Equivalence (Set a))) (implementation - (def: (= reference sample) + (def (= reference sample) (at (list.equivalence (at (representation reference) equivalence)) = (..list reference) (..list sample))))) ) -(def: .public (sub? super sub) +(def .public (sub? super sub) (All (_ a) (-> (Set a) (Set a) Bit)) (|> sub ..list (list.every? (..member? super)))) -(def: .public (super? sub super) +(def .public (super? sub super) (All (_ a) (-> (Set a) (Set a) Bit)) (sub? super sub)) diff --git a/stdlib/source/library/lux/data/collection/stack.lux b/stdlib/source/library/lux/data/collection/stack.lux index 086b727ca..5a7f19904 100644 --- a/stdlib/source/library/lux/data/collection/stack.lux +++ b/stdlib/source/library/lux/data/collection/stack.lux @@ -13,19 +13,19 @@ (primitive .public (Stack a) (List a) - (def: .public empty + (def .public empty Stack (abstraction (list))) - (def: .public size + (def .public size (All (_ a) (-> (Stack a) Nat)) (|>> representation //.size)) - (def: .public empty? + (def .public empty? (All (_ a) (-> (Stack a) Bit)) (|>> representation //.empty?)) - (def: .public (value stack) + (def .public (value stack) (All (_ a) (-> (Stack a) (Maybe a))) (case (representation stack) {.#End} @@ -34,7 +34,7 @@ {.#Item value _} {.#Some value})) - (def: .public (next stack) + (def .public (next stack) (All (_ a) (-> (Stack a) (Maybe [a (Stack a)]))) (case (representation stack) {.#End} @@ -43,22 +43,22 @@ {.#Item top stack'} {.#Some [top (abstraction stack')]})) - (def: .public (top value stack) + (def .public (top value stack) (All (_ a) (-> a (Stack a) (Stack a))) (abstraction {.#Item value (representation stack)})) - (def: .public (equivalence super) + (def .public (equivalence super) (All (_ a) (-> (Equivalence a) (Equivalence (Stack a)))) (implementation - (def: (= reference subject) + (def (= reference subject) (at (//.equivalence super) = (representation reference) (representation subject))))) - (def: .public functor + (def .public functor (Functor Stack) (implementation - (def: (each f value) + (def (each f value) (|> value representation (at //.functor each f) diff --git a/stdlib/source/library/lux/data/collection/stream.lux b/stdlib/source/library/lux/data/collection/stream.lux index f2f45add6..29b789e09 100644 --- a/stdlib/source/library/lux/data/collection/stream.lux +++ b/stdlib/source/library/lux/data/collection/stream.lux @@ -22,18 +22,18 @@ (type: .public (Stream a) (Cont [a (Stream a)])) -(def: .public (iterations step init) +(def .public (iterations step init) (All (_ a b) (-> (-> a [a b]) a (Stream b))) (let [[next x] (step init)] (//.pending [x (iterations step next)]))) -(def: .public (repeated x) +(def .public (repeated x) (All (_ a) (-> a (Stream a))) (//.pending [x (repeated x)])) -(def: .public (cycle [start next]) +(def .public (cycle [start next]) (All (_ a) (-> [a (List a)] (Stream a))) (loop (again [head start @@ -46,7 +46,7 @@ (again head' tail'))]))) (with_template [<name> <return>] - [(def: .public (<name> stream) + [(def .public (<name> stream) (All (_ a) (-> (Stream a) <return>)) (let [[head tail] (//.result stream)] <name>))] @@ -55,7 +55,7 @@ [tail (Stream a)] ) -(def: .public (item idx stream) +(def .public (item idx stream) (All (_ a) (-> Nat (Stream a) a)) (let [[head tail] (//.result stream)] (case idx @@ -63,7 +63,7 @@ _ (item (-- idx) tail)))) (with_template [<taker> <dropper> <pred_type> <pred_test> <pred_step> <post_test>] - [(def: .public (<taker> pred xs) + [(def .public (<taker> pred xs) (All (_ a) (-> <pred_type> (Stream a) (List a))) (let [[x xs'] (//.result xs)] @@ -71,7 +71,7 @@ (list.partial x (<taker> <pred_step> xs')) (list)))) - (def: .public (<dropper> pred xs) + (def .public (<dropper> pred xs) (All (_ a) (-> <pred_type> (Stream a) (Stream a))) (let [[x xs'] (//.result xs)] @@ -84,7 +84,7 @@ ) (with_template [<splitter> <pred_type> <pred_test> <pred_step>] - [(def: .public (<splitter> pred xs) + [(def .public (<splitter> pred xs) (All (_ a) (-> <pred_type> (Stream a) [(List a) (Stream a)])) (let [[x xs'] (//.result xs)] @@ -97,37 +97,37 @@ [split_at Nat (n.= 0 pred) (-- pred)] ) -(def: .public (only predicate stream) +(def .public (only predicate stream) (All (_ a) (-> (-> a Bit) (Stream a) (Stream a))) (let [[head tail] (//.result stream)] (if (predicate head) (//.pending [head (only predicate tail)]) (only predicate tail)))) -(def: .public (partition left? xs) +(def .public (partition left? xs) (All (_ a) (-> (-> a Bit) (Stream a) [(Stream a) (Stream a)])) [(..only left? xs) (..only (bit.complement left?) xs)]) -(def: .public functor +(def .public functor (Functor Stream) (implementation - (def: (each f fa) + (def (each f fa) (let [[head tail] (//.result fa)] (//.pending [(f head) (each f tail)]))))) -(def: .public comonad +(def .public comonad (CoMonad Stream) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: out head) + (def out head) - (def: (disjoint wa) + (def (disjoint wa) (let [[head tail] (//.result wa)] (//.pending [wa (disjoint tail)]))))) -(def: .public pattern +(def .public pattern (syntax (_ [patterns (<code>.form (<>.many <code>.any)) body <code>.any branches (<>.some <code>.any)]) diff --git a/stdlib/source/library/lux/data/collection/tree.lux b/stdlib/source/library/lux/data/collection/tree.lux index 64b0d13f7..d1f9d46ba 100644 --- a/stdlib/source/library/lux/data/collection/tree.lux +++ b/stdlib/source/library/lux/data/collection/tree.lux @@ -21,7 +21,7 @@ [#value a #children (List (Tree a))])) -(def: .public (flat tree) +(def .public (flat tree) (All (_ a) (-> (Tree a) (List a))) (|> tree (the #children) @@ -29,12 +29,12 @@ list#conjoint {.#Item (the #value tree)})) -(def: .public (leaf value) +(def .public (leaf value) (All (_ a) (-> a (Tree a))) [#value value #children (list)]) -(def: .public (branch value children) +(def .public (branch value children) (All (_ a) (-> a (List (Tree a)) (Tree a))) [#value value #children children]) @@ -43,7 +43,7 @@ (Rec Tree_Code [Code (List Tree_Code)])) -(def: tree^ +(def tree^ (Parser Tree_Code) (|> (|>> <>.some <code>.variant @@ -54,31 +54,31 @@ (<>.else (list)) (<>.and <code>.any))) -(def: .public tree +(def .public tree (syntax (_ [root tree^]) (in (list (loop (again [[value children] root]) (` [#value (~ value) #children (list (~+ (list#each again children)))])))))) -(def: .public (equivalence super) +(def .public (equivalence super) (All (_ a) (-> (Equivalence a) (Equivalence (Tree a)))) (implementation - (def: (= tx ty) + (def (= tx ty) (and (at super = (the #value tx) (the #value ty)) (at (list.equivalence (equivalence super)) = (the #children tx) (the #children ty)))))) -(def: .public functor +(def .public functor (Functor Tree) (implementation - (def: (each f fa) + (def (each f fa) [#value (f (the #value fa)) #children (list#each (each f) (the #children fa))]))) -(def: .public mix +(def .public mix (Mix Tree) (implementation - (def: (mix f init tree) + (def (mix f init tree) (list#mix (function (_ tree' init') (mix f init' tree')) (f (the #value tree) init) diff --git a/stdlib/source/library/lux/data/collection/tree/finger.lux b/stdlib/source/library/lux/data/collection/tree/finger.lux index 0d8527308..3046509d3 100644 --- a/stdlib/source/library/lux/data/collection/tree/finger.lux +++ b/stdlib/source/library/lux/data/collection/tree/finger.lux @@ -30,7 +30,7 @@ branch))) (with_template [<name> <tag> <output>] - [(def: .public <name> + [(def .public <name> (All (_ @ t v) (-> (Tree @ t v) <output>)) (|>> representation (the <tag>)))] @@ -38,22 +38,22 @@ [root #root (Either v [(Tree @ t v) (Tree @ t v)])] ) - (def: .public (builder monoid) + (def .public (builder monoid) (All (_ t) (Ex (_ @) (-> (Monoid t) (Builder @ t)))) (implementation - (def: (leaf tag value) + (def (leaf tag value) (abstraction [#monoid monoid #tag tag #root {.#Left value}])) - (def: (branch left right) + (def (branch left right) (abstraction [#monoid monoid #tag (at monoid composite (..tag left) (..tag right)) #root {.#Right [left right]}])))) - (def: .public (value tree) + (def .public (value tree) (All (_ @ t v) (-> (Tree @ t v) v)) (case (the #root (representation tree)) {0 #0 value} @@ -62,7 +62,7 @@ {0 #1 [left right]} (value left))) - (def: .public (tags tree) + (def .public (tags tree) (All (_ @ t v) (-> (Tree @ t v) (List t))) (case (the #root (representation tree)) {0 #0 value} @@ -72,7 +72,7 @@ (list#composite (tags left) (tags right)))) - (def: .public (values tree) + (def .public (values tree) (All (_ @ t v) (-> (Tree @ t v) (List v))) (case (the #root (representation tree)) {0 #0 value} @@ -82,7 +82,7 @@ (list#composite (values left) (values right)))) - (def: .public (one predicate tree) + (def .public (one predicate tree) (All (_ @ t v) (-> (Predicate t) (Tree @ t v) (Maybe v))) (let [[monoid tag root] (representation tree)] (if (predicate tag) @@ -101,7 +101,7 @@ {.#None}))) ) -(def: .public (exists? predicate tree) +(def .public (exists? predicate tree) (All (_ @ t v) (-> (Predicate t) (Tree @ t v) Bit)) (case (..one predicate tree) {.#Some _} diff --git a/stdlib/source/library/lux/data/collection/tree/zipper.lux b/stdlib/source/library/lux/data/collection/tree/zipper.lux index d02c354bb..e6bb39ba6 100644 --- a/stdlib/source/library/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/library/lux/data/collection/tree/zipper.lux @@ -29,12 +29,12 @@ [#family (Maybe (Family Zipper a)) #node (Tree a)])) -(def: .public (equivalence super) +(def .public (equivalence super) (All (_ a) (-> (Equivalence a) (Equivalence (Zipper a)))) (implementation - (def: (= reference sample) + (def (= reference sample) (let [== (all product.equivalence (maybe.equivalence (all product.equivalence @@ -44,40 +44,40 @@ (//.equivalence super))] (== reference sample))))) -(def: .public (zipper tree) +(def .public (zipper tree) (All (_ a) (-> (Tree a) (Zipper a))) [#family {.#None} #node tree]) -(def: .public tree +(def .public tree (All (_ a) (-> (Zipper a) (Tree a))) (the #node)) -(def: .public value +(def .public value (All (_ a) (-> (Zipper a) a)) (the [#node //.#value])) -(def: .public (set value zipper) +(def .public (set value zipper) (All (_ a) (-> a (Zipper a) (Zipper a))) (has [#node //.#value] value zipper)) -(def: .public (update transform zipper) +(def .public (update transform zipper) (All (_ a) (-> (-> a a) (Zipper a) (Zipper a))) (revised [#node //.#value] transform zipper)) -(def: children +(def children (All (_ a) (-> (Zipper a) (List (Tree a)))) (the [#node //.#children])) -(def: .public leaf? +(def .public leaf? (All (_ a) (-> (Zipper a) Bit)) (|>> ..children list.empty?)) -(def: .public branch? +(def .public branch? (All (_ a) (-> (Zipper a) Bit)) (|>> ..leaf? not)) -(def: .public (start? zipper) +(def .public (start? zipper) (All (_ a) (-> (Zipper a) Bit)) (case (the #family zipper) {.#None} @@ -86,7 +86,7 @@ _ false)) -(def: .public (down zipper) +(def .public (down zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (..children zipper) {.#End} @@ -98,7 +98,7 @@ #rights tail]} #node head]})) -(def: .public (up zipper) +(def .public (up zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (do maybe.monad [family (the #family zipper)] @@ -117,7 +117,7 @@ _#parent)))))) (with_template [<one> <all> <side> <op_side>] - [(def: .public (<one> zipper) + [(def .public (<one> zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (the #family zipper) {.#Some family} @@ -141,7 +141,7 @@ {.#None} {.#None})) - (def: .public (<all> zipper) + (def .public (<all> zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (the #family zipper) {.#None} @@ -170,7 +170,7 @@ [left leftmost #lefts #rights] ) -(def: .public (next zipper) +(def .public (next zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (..down zipper) {.#Some forward} @@ -187,7 +187,7 @@ [@ (..up @)] (again @)))))) -(def: (bottom zipper) +(def (bottom zipper) (All (_ a) (-> (Zipper a) (Zipper a))) (case (..right zipper) {.#Some forward} @@ -201,7 +201,7 @@ {.#None} zipper))) -(def: .public (previous zipper) +(def .public (previous zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (..left zipper) {.#None} @@ -216,7 +216,7 @@ backward)})) (with_template [<name> <move>] - [(def: .public (<name> zipper) + [(def .public (<name> zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (<move> zipper) {.#None} @@ -235,7 +235,7 @@ [start ..previous] ) -(def: .public (end? zipper) +(def .public (end? zipper) (All (_ a) (-> (Zipper a) Bit)) (case (..end zipper) {.#None} @@ -244,19 +244,19 @@ {.#Some _} false)) -(def: .public (interpose value zipper) +(def .public (interpose value zipper) (All (_ a) (-> a (Zipper a) (Zipper a))) (revised [#node //.#children] (|>> (//.branch value) list) zipper)) -(def: .public (adopt value zipper) +(def .public (adopt value zipper) (All (_ a) (-> a (Zipper a) (Zipper a))) (revised [#node //.#children] (|>> {.#Item (//.leaf value)}) zipper)) -(def: .public (remove zipper) +(def .public (remove zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (do maybe.monad [family (the #family zipper)] @@ -274,7 +274,7 @@ (has #node next)))))) (with_template [<name> <side>] - [(def: .public (<name> value zipper) + [(def .public (<name> value zipper) (All (_ a) (-> a (Zipper a) (Maybe (Zipper a)))) (case (the #family zipper) {.#None} @@ -289,10 +289,10 @@ [insert_right #rights] ) -(def: .public functor +(def .public functor (Functor Zipper) (implementation - (def: (each f (open "_[0]")) + (def (each f (open "_[0]")) [#family (maybe#each (function (_ (open "_[0]")) [#parent (each f _#parent) #lefts (list#each (//#each f) _#lefts) @@ -300,16 +300,16 @@ _#family) #node (//#each f _#node)]))) -(def: .public comonad +(def .public comonad (CoMonad Zipper) (implementation - (def: functor + (def functor ..functor) - (def: out + (def out (the [#node //.#value])) - (def: (disjoint (open "_[0]")) + (def (disjoint (open "_[0]")) (let [tree_splitter (is (All (_ a) (-> (Tree a) (Tree (Zipper a)))) (function (tree_splitter tree) [//.#value (..zipper tree) diff --git a/stdlib/source/library/lux/data/color.lux b/stdlib/source/library/lux/data/color.lux index 2a89c02fe..519b0f020 100644 --- a/stdlib/source/library/lux/data/color.lux +++ b/stdlib/source/library/lux/data/color.lux @@ -18,17 +18,17 @@ [type [primitive (.except)]]]]) -(def: rgb_limit 256) -(def: top (-- rgb_limit)) +(def rgb_limit 256) +(def top (-- rgb_limit)) -(def: rgb_factor +(def rgb_factor (|> top .int int.frac)) -(def: down +(def down (-> Nat Frac) (|>> .int int.frac (f./ rgb_factor))) -(def: up +(def up (-> Frac Nat) (|>> (f.* rgb_factor) f.int .nat)) @@ -54,79 +54,79 @@ (primitive .public Color RGB - (def: .public (of_rgb [red green blue]) + (def .public (of_rgb [red green blue]) (-> RGB Color) (abstraction [#red (n.% ..rgb_limit red) #green (n.% ..rgb_limit green) #blue (n.% ..rgb_limit blue)])) - (def: .public rgb + (def .public rgb (-> Color RGB) (|>> representation)) - (def: .public equivalence + (def .public equivalence (Equivalence Color) (implementation - (def: (= reference sample) + (def (= reference sample) (let [[rR gR bR] (representation reference) [rS gS bS] (representation sample)] (and (n.= rR rS) (n.= gR gS) (n.= bR bS)))))) - (def: .public hash + (def .public hash (Hash Color) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (hash value) + (def (hash value) (let [[r g b] (representation value)] (all i64.or (i64.left_shifted 16 r) (i64.left_shifted 8 g) b))))) - (def: .public black + (def .public black Color (..of_rgb [#red 0 #green 0 #blue 0])) - (def: .public white + (def .public white Color (..of_rgb [#red ..top #green ..top #blue ..top])) - (def: .public addition + (def .public addition (Monoid Color) (implementation - (def: identity ..black) + (def identity ..black) - (def: (composite left right) + (def (composite left right) (let [[lR lG lB] (representation left) [rR rG rB] (representation right)] (abstraction [#red (n.max lR rR) #green (n.max lG rG) #blue (n.max lB rB)]))))) - (def: (opposite_intensity value) + (def (opposite_intensity value) (-> Nat Nat) (|> ..top (n.- value))) - (def: .public (complement color) + (def .public (complement color) (-> Color Color) (let [[red green blue] (representation color)] (abstraction [#red (opposite_intensity red) #green (opposite_intensity green) #blue (opposite_intensity blue)]))) - (def: .public subtraction + (def .public subtraction (Monoid Color) (implementation - (def: identity ..white) + (def identity ..white) - (def: (composite left right) + (def (composite left right) (let [[lR lG lB] (representation (..complement left)) [rR rG rB] (representation right)] (abstraction [#red (n.min lR rR) @@ -134,7 +134,7 @@ #blue (n.min lB rB)]))))) ) -(def: .public (hsl color) +(def .public (hsl color) (-> Color HSL) (let [[red green blue] (rgb color) red (..down red) @@ -169,7 +169,7 @@ saturation luminance])))) -(def: (hue_rgb p q t) +(def (hue_rgb p q t) (-> Frac Frac Frac Nat) (let [t (cond (f.< +0.0 t) (f.+ +1.0 t) (f.> +1.0 t) (f.- +1.0 t) @@ -188,7 +188,7 @@ ... else p)))) -(def: .public (of_hsl [hue saturation luminance]) +(def .public (of_hsl [hue saturation luminance]) (-> HSL Color) (if (f.= +0.0 saturation) ... Achromatic @@ -206,7 +206,7 @@ #green (|> hue (hue_rgb p q)) #blue (|> hue (f.- third) (hue_rgb p q))])))) -(def: .public (hsb color) +(def .public (hsb color) (-> Color HSB) (let [[red green blue] (rgb color) red (..down red) @@ -238,7 +238,7 @@ saturation brightness])))) -(def: .public (of_hsb [hue saturation brightness]) +(def .public (of_hsb [hue saturation brightness]) (-> HSB Color) (let [hue (|> hue (f.* +6.0)) i (f.floor hue) @@ -255,7 +255,7 @@ #green (..up green) #blue (..up blue)]))) -(def: .public (cmyk color) +(def .public (cmyk color) (-> Color CMYK) (let [[red green blue] (rgb color) red (..down red) @@ -273,7 +273,7 @@ #yellow yellow #key key])) -(def: .public (of_cmyk [cyan magenta yellow key]) +(def .public (of_cmyk [cyan magenta yellow key]) (-> CMYK Color) (if (f.= +1.0 key) (of_rgb [#red 0 @@ -289,7 +289,7 @@ #green (..up green) #blue (..up blue)])))) -(def: (normal ratio) +(def (normal ratio) (-> Frac Frac) (cond (f.> +1.0 ratio) (f.% +1.0 ratio) @@ -300,7 +300,7 @@ ... else ratio)) -(def: .public (interpolated ratio end start) +(def .public (interpolated ratio end start) (-> Frac Color Color Color) (let [dS (..normal ratio) dE (|> +1.0 (f.- dS)) @@ -317,7 +317,7 @@ #blue (interpolated' blueE blueS)]))) (with_template [<name> <target>] - [(def: .public (<name> ratio color) + [(def .public (<name> ratio color) (-> Frac Color Color) (..interpolated ratio <target> color))] @@ -326,7 +326,7 @@ ) (with_template [<op> <name>] - [(def: .public (<name> ratio color) + [(def .public (<name> ratio color) (-> Frac Color Color) (let [[hue saturation luminance] (hsl color)] (of_hsl [hue @@ -339,7 +339,7 @@ [f.- un_saturated] ) -(def: .public (gray_scale color) +(def .public (gray_scale color) (-> Color Color) (let [[_ _ luminance] (hsl color)] (of_hsl [+0.0 @@ -347,7 +347,7 @@ luminance]))) (with_template [<name> <1> <2>] - [(`` (def: .public (<name> color) + [(`` (def .public (<name> color) (-> Color [Color Color Color]) (let [[hue saturation luminance] (hsl color)] [color @@ -364,7 +364,7 @@ ) (with_template [<name> <1> <2> <3>] - [(`` (def: .public (<name> color) + [(`` (def .public (<name> color) (-> Color [Color Color Color Color]) (let [[hue saturation luminance] (hsb color)] [color @@ -388,7 +388,7 @@ (type: .public Palette (-> Spread Nat Color (List Color))) -(`` (def: .public (analogous spread variations color) +(`` (def .public (analogous spread variations color) Palette (let [[hue saturation brightness] (hsb color) spread (..normal spread)] @@ -398,7 +398,7 @@ brightness])) (list.indices variations))))) -(`` (def: .public (monochromatic spread variations color) +(`` (def .public (monochromatic spread variations color) Palette (let [[hue saturation brightness] (hsb color) spread (..normal spread)] @@ -413,15 +413,15 @@ (type: .public Alpha Rev) -(def: .public transparent +(def .public transparent Alpha rev#bottom) -(def: .public translucent +(def .public translucent Alpha .5) -(def: .public opaque +(def .public opaque Alpha rev#top) diff --git a/stdlib/source/library/lux/data/color/named.lux b/stdlib/source/library/lux/data/color/named.lux index 99fae8434..43633595d 100644 --- a/stdlib/source/library/lux/data/color/named.lux +++ b/stdlib/source/library/lux/data/color/named.lux @@ -7,7 +7,7 @@ ... https://developer.mozilla.org/en-US/docs/Web/CSS/color_value (with_template [<red> <green> <blue> <name>] - [(`` (def: .public <name> + [(`` (def .public <name> Color (//.of_rgb [//.#red (hex <red>) //.#green (hex <green>) diff --git a/stdlib/source/library/lux/data/format/css.lux b/stdlib/source/library/lux/data/format/css.lux index df39b6b61..dca23f87c 100644 --- a/stdlib/source/library/lux/data/format/css.lux +++ b/stdlib/source/library/lux/data/format/css.lux @@ -30,29 +30,29 @@ (primitive .public (CSS brand) Text - (def: .public css + (def .public css (-> (CSS Any) Text) (|>> representation)) - (def: .public empty + (def .public empty (CSS Any) (abstraction "")) (type: .public Style (List (Ex (_ brand) [(Property brand) (Value brand)]))) - (def: .public (rule selector style) + (def .public (rule selector style) (-> (Selector Any) Style (CSS Common)) (abstraction (format (/selector.selector selector) "{" (/style.inline (/style.style style)) "}"))) - (def: .public char_set + (def .public char_set (-> Encoding (CSS Special)) (|>> encoding.name %.text (text.enclosed ["@charset " ";"]) abstraction)) - (def: .public (font font) + (def .public (font font) (-> Font (CSS Special)) (let [with_unicode (case (the /font.#unicode_range font) {.#Some unicode_range} @@ -75,7 +75,7 @@ (format "@font-face") abstraction))) - (def: .public (import url query) + (def .public (import url query) (-> URL (Maybe Query) (CSS Special)) (abstraction (format (format "@import url(" (%.text url) ")") (case query @@ -86,7 +86,7 @@ "") ";"))) - (def: separator + (def separator text.new_line) (type: .public Frame @@ -94,7 +94,7 @@ [#when (Value Percentage) #what Style])) - (def: .public (key_frames animation frames) + (def .public (key_frames animation frames) (-> (Value Animation) (List Frame) (CSS Special)) (abstraction (format "@keyframes " (/value.value animation) " {" (|> frames @@ -105,18 +105,18 @@ (text.interposed ..separator)) "}"))) - (def: !composite + (def !composite (template (!composite <pre> <post>) [(abstraction (format (representation <pre>) ..separator (representation <post>)))])) - (def: .public (and pre post) + (def .public (and pre post) (All (_ kind) (-> (CSS kind) (CSS kind) (CSS kind))) (!composite pre post)) - (def: .public (in_context combinator selector css) + (def .public (in_context combinator selector css) (-> Combinator (Selector Any) (CSS Common) (CSS Common)) (|> css representation @@ -128,13 +128,13 @@ (text.interposed ..separator) abstraction)) - (def: .public (dependent combinator selector style inner) + (def .public (dependent combinator selector style inner) (-> Combinator (Selector Any) Style (CSS Common) (CSS Common)) (!composite (..rule selector style) (..in_context combinator selector inner))) (with_template [<name> <combinator>] - [(def: .public <name> + [(def .public <name> (-> (Selector Any) Style (CSS Common) (CSS Common)) (..dependent <combinator>))] @@ -142,7 +142,7 @@ [with_children /selector.sub] ) - (def: .public (in_case specializer selector css) + (def .public (in_case specializer selector css) (All (_ kind) (-> (Specializer kind) (Selector (Generic Any)) (CSS Common) (CSS Common))) (|> css @@ -155,14 +155,14 @@ (text.interposed ..separator) abstraction)) - (def: .public (specialized combinator selector style inner) + (def .public (specialized combinator selector style inner) (All (_ kind) (-> (Specializer kind) (Selector (Generic Any)) Style (CSS Common) (CSS Common))) (!composite (..rule selector style) (..in_case combinator selector inner))) (with_template [<name> <combinator>] - [(def: .public <name> + [(def .public <name> (-> (Selector (Generic Any)) Style (CSS Common) (CSS Common)) (..specialized <combinator>))] diff --git a/stdlib/source/library/lux/data/format/css/class.lux b/stdlib/source/library/lux/data/format/css/class.lux index 1fb58b4d7..6a867e331 100644 --- a/stdlib/source/library/lux/data/format/css/class.lux +++ b/stdlib/source/library/lux/data/format/css/class.lux @@ -16,15 +16,15 @@ (primitive .public Class Text - (def: .public class + (def .public class (-> Class Text) (|>> representation)) - (def: .public custom + (def .public custom (-> Text Class) (|>> abstraction)) - (def: .public generic + (def .public generic (syntax (_ []) (do meta.monad [module meta.current_module_name diff --git a/stdlib/source/library/lux/data/format/css/id.lux b/stdlib/source/library/lux/data/format/css/id.lux index 2ba540356..96a9ef1d2 100644 --- a/stdlib/source/library/lux/data/format/css/id.lux +++ b/stdlib/source/library/lux/data/format/css/id.lux @@ -16,15 +16,15 @@ (primitive .public ID Text - (def: .public id + (def .public id (-> ID Text) (|>> representation)) - (def: .public custom + (def .public custom (-> Text ID) (|>> abstraction)) - (def: .public generic + (def .public generic (syntax (_ []) (do meta.monad [module meta.current_module_name diff --git a/stdlib/source/library/lux/data/format/css/property.lux b/stdlib/source/library/lux/data/format/css/property.lux index 21348e82d..5fa507633 100644 --- a/stdlib/source/library/lux/data/format/css/property.lux +++ b/stdlib/source/library/lux/data/format/css/property.lux @@ -54,20 +54,20 @@ White_Space Word_Break Word_Wrap Writing_Mode Z_Index)]]) -(def: text_symbol +(def text_symbol (syntax (_ [symbol s.text]) (in (list (code.local (text.replaced "-" "_" symbol)))))) (primitive .public (Property brand) Text - (def: .public name + (def .public name (-> (Property Any) Text) (|>> representation)) (with_template [<brand> <alias>+ <property>+] [(`` (with_template [<alias> <property>] - [(def: .public <alias> + [(def .public <alias> (Property <brand>) (abstraction <property>))] @@ -75,7 +75,7 @@ (with_expansions [<rows> (template.spliced <property>+)] (with_template [<property>] - [(`` (def: .public (~~ (text_symbol <property>)) + [(`` (def .public (~~ (text_symbol <property>)) (Property <brand>) (abstraction <property>)))] diff --git a/stdlib/source/library/lux/data/format/css/query.lux b/stdlib/source/library/lux/data/format/css/query.lux index f4d2fccd5..6af2f5539 100644 --- a/stdlib/source/library/lux/data/format/css/query.lux +++ b/stdlib/source/library/lux/data/format/css/query.lux @@ -21,19 +21,19 @@ Pointer Hover Light Scripting Motion Color_Scheme)]]) -(def: text_symbol +(def text_symbol (syntax (_ [symbol s.text]) (in (list (code.local (text.replaced "-" "_" symbol)))))) (primitive .public Media Text - (def: .public media + (def .public media (-> Media Text) (|>> representation)) (with_template [<media>] - [(`` (def: .public (~~ (text_symbol <media>)) + [(`` (def .public (~~ (text_symbol <media>)) Media (abstraction <media>)))] @@ -46,12 +46,12 @@ (primitive .public Feature Text - (def: .public feature + (def .public feature (-> Feature Text) (|>> representation)) (with_template [<feature> <brand>] - [(`` (def: .public ((~~ (text_symbol <feature>)) input) + [(`` (def .public ((~~ (text_symbol <feature>)) input) (-> (Value <brand>) Feature) (abstraction (format "(" <feature> ": " (//value.value input) ")"))))] @@ -106,12 +106,12 @@ (primitive .public Query Text - (def: .public query + (def .public query (-> Query Text) (|>> representation)) (with_template [<name> <operator>] - [(def: .public <name> + [(def .public <name> (-> Media Query) (|>> ..media (format <operator>) abstraction))] @@ -119,12 +119,12 @@ [only "only "] ) - (def: .public not + (def .public not (-> Feature Query) (|>> ..feature (format "not ") abstraction)) (with_template [<name> <operator>] - [(def: .public (<name> left right) + [(def .public (<name> left right) (-> Query Query Query) (abstraction (format (representation left) <operator> diff --git a/stdlib/source/library/lux/data/format/css/selector.lux b/stdlib/source/library/lux/data/format/css/selector.lux index 2fe5ae11e..ee3291e33 100644 --- a/stdlib/source/library/lux/data/format/css/selector.lux +++ b/stdlib/source/library/lux/data/format/css/selector.lux @@ -38,20 +38,20 @@ (primitive .public (Selector kind) Text - (def: .public selector + (def .public selector (-> (Selector Any) Text) (|>> representation)) - (def: .public any + (def .public any (Selector Cannot_Chain) (abstraction "*")) - (def: .public tag + (def .public tag (-> Tag (Selector Cannot_Chain)) (|>> abstraction)) (with_template [<name> <type> <prefix> <kind> <out>] - [(def: .public <name> + [(def .public <name> (-> <type> (Selector <kind>)) (|>> <out> (format <prefix>) abstraction))] @@ -61,7 +61,7 @@ (with_template [<right> <left> <combinator>+] [(`` (with_template [<combinator> <name>] - [(def: .public (<name> right left) + [(def .public (<name> right left) (-> (Selector <right>) (Selector <left>) (Selector Composite)) (abstraction (format (representation left) <combinator> @@ -89,12 +89,12 @@ (type: .public Combinator (-> (Selector Any) (Selector Any) (Selector Composite))) - (def: .public (with? attribute) + (def .public (with? attribute) (-> Attribute (Selector Can_Chain)) (abstraction (format "[" attribute "]"))) (with_template [<check> <name>] - [(def: .public (<name> attribute value) + [(def .public (<name> attribute value) (-> Attribute Text (Selector Can_Chain)) (abstraction (format "[" attribute <check> value "]")))] @@ -108,7 +108,7 @@ (with_template [<kind> <pseudo>+] [(`` (with_template [<name> <pseudo>] - [(def: .public <name> + [(def .public <name> (Selector <kind>) (abstraction <pseudo>))] @@ -152,7 +152,7 @@ [selection "::selection"]]] ) - (def: .public (language locale) + (def .public (language locale) (-> Locale (Selector Can_Chain)) (|> locale locale.code @@ -160,7 +160,7 @@ (format ":lang") abstraction)) - (def: .public not + (def .public not (-> (Selector Any) (Selector Can_Chain)) (|>> representation (text.enclosed ["(" ")"]) @@ -170,12 +170,12 @@ (primitive .public Index Text - (def: .public index + (def .public index (-> Nat Index) (|>> %.nat abstraction)) (with_template [<name> <index>] - [(def: .public <name> Index (abstraction <index>))] + [(def .public <name> Index (abstraction <index>))] [odd "odd"] [even "even"] @@ -186,7 +186,7 @@ [#constant Int #variable Int])) - (def: .public (formula input) + (def .public (formula input) (-> Formula Index) (let [(open "_[0]") input] (abstraction (format (if (i.< +0 _#variable) @@ -195,7 +195,7 @@ (%.int _#constant))))) (with_template [<name> <pseudo>] - [(def: .public (<name> index) + [(def .public (<name> index) (-> Index (Selector Can_Chain)) (|> (representation index) (text.enclosed ["(" ")"]) diff --git a/stdlib/source/library/lux/data/format/css/style.lux b/stdlib/source/library/lux/data/format/css/style.lux index eba1e112d..50df42453 100644 --- a/stdlib/source/library/lux/data/format/css/style.lux +++ b/stdlib/source/library/lux/data/format/css/style.lux @@ -15,11 +15,11 @@ (primitive .public Style Text - (def: .public empty + (def .public empty Style (abstraction "")) - (def: .public (with [property value]) + (def .public (with [property value]) (All (_ brand) (-> [(Property brand) (Value brand)] (-> Style Style))) @@ -27,11 +27,11 @@ (format (//property.name property) ": " (//value.value value) ";") abstraction)) - (def: .public inline + (def .public inline (-> Style Text) (|>> representation)) - (def: .public (style config) + (def .public (style config) (-> (List (Ex (_ brand) [(Property brand) (Value brand)])) Style) (list#mix ..with ..empty config)) diff --git a/stdlib/source/library/lux/data/format/css/value.lux b/stdlib/source/library/lux/data/format/css/value.lux index 66c82fe50..79afc29d6 100644 --- a/stdlib/source/library/lux/data/format/css/value.lux +++ b/stdlib/source/library/lux/data/format/css/value.lux @@ -29,28 +29,28 @@ [// [selector (.only Label)]]) -(def: text_symbol +(def text_symbol (syntax (_ [symbol <code>.text]) (in (list (code.local (text.replaced "-" "_" symbol)))))) -(def: enumeration +(def enumeration (template (_ <abstraction> <representation> <out> <sample>+ <definition>+) [(primitive .public <abstraction> <representation> - (def: .public <out> + (def .public <out> (-> <abstraction> <representation>) (|>> representation)) (`` (with_template [<name> <value>] - [(def: .public <name> <abstraction> (abstraction <value>))] + [(def .public <name> <abstraction> (abstraction <value>))] (~~ (template.spliced <sample>+)) )) (template.spliced <definition>+))])) -(def: (%number value) +(def (%number value) (Format Frac) (let [raw (%.frac value)] (if (f.< +0.0 value) @@ -60,12 +60,12 @@ (primitive .public (Value brand) Text - (def: .public value + (def .public value (-> (Value Any) Text) (|>> representation)) (with_template [<name> <value>] - [(def: .public <name> Value (abstraction <value>))] + [(def .public <name> Value (abstraction <value>))] [initial "initial"] [inherit "inherit"] @@ -90,7 +90,7 @@ [(primitive .public <brand> Any) (`` (with_template [<name> <value>] - [(def: .public <name> + [(def .public <name> (Value <brand>) (abstraction <value>))] @@ -98,7 +98,7 @@ (with_expansions [<rows> (template.spliced <value>+)] (with_template [<value>] - [(`` (def: .public (~~ (..text_symbol <value>)) + [(`` (def .public (~~ (..text_symbol <value>)) (Value <brand>) (abstraction <value>)))] @@ -775,9 +775,9 @@ []] ) - (def: value_separator ",") + (def value_separator ",") - (def: (apply name inputs) + (def (apply name inputs) (-> Text (List Text) Value) (|> inputs (text.interposed ..value_separator) @@ -793,18 +793,18 @@ [end "end"]] []) - (def: .public (steps intervals step) + (def .public (steps intervals step) (-> Nat Step (Value Timing)) (..apply "steps" (list (%.nat intervals) (..step step)))) - (def: .public (cubic_bezier p0 p1 p2 p3) + (def .public (cubic_bezier p0 p1 p2 p3) (-> Frac Frac Frac Frac (Value Timing)) (|> (list p0 p1 p2 p3) (list#each %number) (..apply "cubic-bezier"))) (with_template [<name> <brand>] - [(def: .public <name> + [(def .public <name> (-> Nat (Value <brand>)) (|>> %.nat abstraction))] @@ -814,18 +814,18 @@ [span_line Grid_Span] ) - (def: .public animation + (def .public animation (-> Label (Value Animation)) (|>> abstraction)) - (def: .public (rgb color) + (def .public (rgb color) (-> color.Color (Value Color)) (let [[red green blue] (color.rgb color)] (..apply "rgb" (list (%.nat red) (%.nat green) (%.nat blue))))) - (def: .public (rgba pigment) + (def .public (rgba pigment) (-> color.Pigment (Value Color)) (let [(open "_[0]") pigment [red green blue] (color.rgb _#color)] @@ -837,7 +837,7 @@ (format "0" (%.rev _#alpha))))))) (with_template [<name> <suffix>] - [(def: .public (<name> value) + [(def .public (<name> value) (-> Frac (Value Length)) (abstraction (format (%number value) <suffix>)))] @@ -859,14 +859,14 @@ [fr "fr"] ) - (def: (%int value) + (def (%int value) (Format Int) (if (i.< +0 value) (%.int value) (%.nat (.nat value)))) (with_template [<name> <suffix>] - [(def: .public (<name> value) + [(def .public (<name> value) (-> Int (Value Time)) (abstraction (format (if (i.< +0 value) (%.int value) @@ -878,13 +878,13 @@ [milli_seconds "ms"] ) - (def: .public thickness + (def .public thickness (-> (Value Length) (Value Thickness)) (|>> transmutation)) - (def: slice_separator " ") + (def slice_separator " ") - (def: .public (slice_number/2 horizontal vertical) + (def .public (slice_number/2 horizontal vertical) (-> Nat Nat (Value Slice)) (abstraction (format (%.nat horizontal) ..slice_separator (%.nat vertical)))) @@ -892,18 +892,18 @@ (primitive .public Stop Text - (def: .public stop + (def .public stop (-> (Value Color) Stop) (|>> (representation Value) (abstraction Stop))) - (def: stop_separator " ") + (def stop_separator " ") - (def: .public (single_stop length color) + (def .public (single_stop length color) (-> (Value Length) (Value Color) Stop) (abstraction (format (representation Value color) ..stop_separator (representation Value length)))) - (def: .public (double_stop start end color) + (def .public (double_stop start end color) (-> (Value Length) (Value Length) (Value Color) Stop) (abstraction (format (representation Value color) ..stop_separator (representation Value start) ..stop_separator @@ -912,11 +912,11 @@ (primitive .public Hint Text - (def: .public hint + (def .public hint (-> (Value Length) Hint) (|>> (representation Value) (abstraction Hint))) - (def: (with_hint [hint stop]) + (def (with_hint [hint stop]) (-> [(Maybe Hint) Stop] Text) (case hint {.#None} @@ -931,22 +931,22 @@ (primitive .public Angle Text - (def: .public angle + (def .public angle (-> Angle Text) (|>> representation)) - (def: .public (turn value) + (def .public (turn value) (-> Rev Angle) (abstraction (format (%.rev value) "turn"))) - (def: degree_limit Nat 360) + (def degree_limit Nat 360) - (def: .public (degree value) + (def .public (degree value) (-> Nat Angle) (abstraction (format (%.nat (n.% ..degree_limit value)) "deg"))) (with_template [<degree> <name>] - [(def: .public <name> + [(def .public <name> Angle (..degree <degree>))] @@ -957,7 +957,7 @@ ) (with_template [<name> <function>] - [(def: .public (<name> angle start next) + [(def .public (<name> angle start next) (-> Angle Stop (List/1 [(Maybe Hint) Stop]) (Value Image)) (let [[now after] next] (..apply <function> (list.partial (representation Angle angle) @@ -969,24 +969,24 @@ ) ) - (def: percentage_limit Nat (.++ 100)) + (def percentage_limit Nat (.++ 100)) - (def: .public (%% value) + (def .public (%% value) (-> Nat (Value Percentage)) (abstraction (format (%.nat (n.% percentage_limit value)) "%"))) - (def: .public slice_percent/1 + (def .public slice_percent/1 (-> (Value Percentage) (Value Slice)) (|>> transmutation)) - (def: .public (slice_percent/2 horizontal vertical) + (def .public (slice_percent/2 horizontal vertical) (-> (Value Percentage) (Value Percentage) (Value Slice)) (abstraction (format (representation horizontal) ..slice_separator (representation vertical)))) (with_template [<input> <pre> <function>+] [(`` (with_template [<name> <function>] - [(def: .public <name> + [(def .public <name> (-> <input> (Value Filter)) (|>> <pre> (list) (..apply <function>)))] @@ -1006,13 +1006,13 @@ [sepia "sepia"]]] ) - (def: .public svg_filter + (def .public svg_filter (-> URL (Value Filter)) (|>> (list) (..apply "url"))) - (def: default_shadow_length (px +0.0)) + (def default_shadow_length (px +0.0)) - (def: .public (drop_shadow horizontal vertical blur spread color) + (def .public (drop_shadow horizontal vertical blur spread color) (-> (Value Length) (Value Length) (Maybe (Value Length)) (Maybe (Value Length)) (Value Color) @@ -1026,10 +1026,10 @@ (list) (..apply "drop-shadow"))) - (def: length_separator " ") + (def length_separator " ") (with_template [<name> <type>] - [(def: .public (<name> horizontal vertical) + [(def .public (<name> horizontal vertical) (-> (Value Length) (Value Length) (Value <type>)) (abstraction (format (representation horizontal) ..length_separator @@ -1039,11 +1039,11 @@ [fit Fit] ) - (def: .public (fit/1 length) + (def .public (fit/1 length) (-> (Value Length) (Value Fit)) (..fit length length)) - (def: .public image + (def .public image (-> URL (Value Image)) (|>> %.text (list) @@ -1068,7 +1068,7 @@ []) (with_template [<name> <function>] - [(def: .public (<name> shape extent location start next) + [(def .public (<name> shape extent location start next) (-> Shape (Maybe Extent) (Value Location) Stop (List/1 [(Maybe Hint) Stop]) (Value Image)) @@ -1089,7 +1089,7 @@ [repeating_radial_gradient "repeating-radial-gradient"] ) - (def: .public (shadow horizontal vertical blur spread color inset?) + (def .public (shadow horizontal vertical blur spread color inset?) (-> (Value Length) (Value Length) (Maybe (Value Length)) (Maybe (Value Length)) (Value Color) Bit @@ -1113,30 +1113,30 @@ #bottom (Value Length) #left (Value Length)])) - (def: .public (clip rectangle) + (def .public (clip rectangle) (-> Rectangle (Value Clip)) (`` (..apply "rect" (list (~~ (with_template [<side>] [(representation (the <side> rectangle))] [#top] [#right] [#bottom] [#left])))))) - (def: .public counter + (def .public counter (-> Label (Value Counter)) (|>> abstraction)) - (def: .public current_count + (def .public current_count (-> (Value Counter) (Value Content)) (|>> representation (list) (..apply "counter"))) - (def: .public text + (def .public text (-> Text (Value Content)) (|>> %.text abstraction)) - (def: .public attribute + (def .public attribute (-> Label (Value Content)) (|>> (list) (..apply "attr"))) - (def: .public media + (def .public media (-> URL (Value Content)) (|>> (list) (..apply "url"))) @@ -1149,11 +1149,11 @@ [cursive "cursive"] [fantasy "fantasy"] [monospace "monospace"]] - [(def: .public font + [(def .public font (-> Text Font) (|>> %.text abstraction)) - (def: .public (font_family options) + (def .public (font_family options) (-> (List Font) (Value Font)) (case options {.#Item _} @@ -1165,35 +1165,35 @@ {.#End} ..initial))]) - (def: .public font_size + (def .public font_size (-> (Value Length) (Value Font_Size)) (|>> transmutation)) - (def: .public number + (def .public number (-> Frac (Value Number)) (|>> %number abstraction)) - (def: .public grid + (def .public grid (-> Label (Value Grid)) (|>> abstraction)) - (def: .public fit_content + (def .public fit_content (-> (Value Length) (Value Grid_Content)) (|>> representation (list) (..apply "fit-content"))) - (def: .public (min_max min max) + (def .public (min_max min max) (-> (Value Grid_Content) (Value Grid_Content) (Value Grid_Content)) (..apply "minmax" (list (representation min) (representation max)))) - (def: .public grid_span + (def .public grid_span (-> Nat (Value Grid_Span)) (|>> %.nat (format "span ") abstraction)) - (def: grid_column_separator " ") - (def: grid_row_separator " ") + (def grid_column_separator " ") + (def grid_row_separator " ") - (def: .public grid_template + (def .public grid_template (-> (List (List (Maybe (Value Grid)))) (Value Grid_Template)) (let [empty (is (Value Grid) (abstraction "."))] @@ -1204,11 +1204,11 @@ (text.interposed ..grid_row_separator) abstraction))) - (def: .public (resolution dpi) + (def .public (resolution dpi) (-> Nat (Value Resolution)) (abstraction (format (%.nat dpi) "dpi"))) - (def: .public (ratio numerator denominator) + (def .public (ratio numerator denominator) (-> Nat Nat (Value Ratio)) (abstraction (format (%.nat numerator) "/" (%.nat denominator)))) @@ -1227,20 +1227,20 @@ [double_left_quote "\201C"] [double_right_quote "\201D"] [low_double_quote "\201E"]] - [(def: .public quote + [(def .public quote (-> Text Quote) (|>> abstraction))]) - (def: quote_separator " ") + (def quote_separator " ") - (def: .public (quotes [left0 right0] [left1 right1]) + (def .public (quotes [left0 right0] [left1 right1]) (-> [Quote Quote] [Quote Quote] (Value Quotes)) (|> (list left0 right0 left1 right1) (list#each (|>> ..quote_text %.text)) (text.interposed ..quote_separator) abstraction)) - (def: .public (matrix_2d [a b] [c d] [tx ty]) + (def .public (matrix_2d [a b] [c d] [tx ty]) (-> [Frac Frac] [Frac Frac] [Frac Frac] @@ -1249,7 +1249,7 @@ (list#each %number) (..apply "matrix"))) - (def: .public (matrix_3d [a0 b0 c0 d0] [a1 b1 c1 d1] [a2 b2 c2 d2] [a3 b3 c3 d3]) + (def .public (matrix_3d [a0 b0 c0 d0] [a1 b1 c1 d1] [a2 b2 c2 d2] [a3 b3 c3 d3]) (-> [Frac Frac Frac Frac] [Frac Frac Frac Frac] [Frac Frac Frac Frac] @@ -1260,7 +1260,7 @@ (..apply "matrix3d"))) (with_template [<name> <function> <input_types> <input_values>] - [(`` (def: .public (<name> [(~~ (template.spliced <input_values>))]) + [(`` (def .public (<name> [(~~ (template.spliced <input_values>))]) (-> [(~~ (template.spliced <input_types>))] (Value Transform)) (|> (list (~~ (template.spliced <input_values>))) (list#each %number) @@ -1282,7 +1282,7 @@ ) (with_template [<name> <function> <input_types> <input_values>] - [(`` (def: .public (<name> [(~~ (template.spliced <input_values>))]) + [(`` (def .public (<name> [(~~ (template.spliced <input_values>))]) (-> [(~~ (template.spliced <input_types>))] (Value Transform)) (|> (list (~~ (template.spliced <input_values>))) (list#each ..angle) @@ -1298,36 +1298,36 @@ [skew_y "skewY" [Angle] [angle]] ) - (def: .public (rotate_3d [x y z angle]) + (def .public (rotate_3d [x y z angle]) (-> [Frac Frac Frac Angle] (Value Transform)) (..apply "rotate3d" (list (%number x) (%number y) (%number z) (..angle angle)))) - (def: origin_separator " ") + (def origin_separator " ") - (def: .public (origin_2d x y) + (def .public (origin_2d x y) (-> (Value Length) (Value Length) (Value Transform_Origin)) (abstraction (format (representation x) ..origin_separator (representation y)))) - (def: .public (origin_3d x y z) + (def .public (origin_3d x y z) (-> (Value Length) (Value Length) (Value Length) (Value Transform_Origin)) (abstraction (format (representation x) ..origin_separator (representation y) ..origin_separator (representation z)))) - (def: .public vertical_align + (def .public vertical_align (-> (Value Length) (Value Vertical_Align)) (|>> transmutation)) - (def: .public (z_index index) + (def .public (z_index index) (-> Int (Value Z_Index)) (abstraction (if (i.< +0 index) (%.int index) (%.nat (.nat index))))) (with_template [<separator> <type> <multi>] - [(def: .public (<multi> pre post) + [(def .public (<multi> pre post) (-> (Value <type>) (Value <type>) (Value <type>)) (abstraction (format (representation pre) <separator> @@ -1340,7 +1340,7 @@ ... https://developer.mozilla.org/en-US/docs/Web/CSS/calc() (with_template [<name> <parameter>] - [(def: .public (<name> parameter subject) + [(def .public (<name> parameter subject) (.All (_ kind) (-> (Value <parameter>) (Value (Numeric kind)) (Value (Numeric kind)))) diff --git a/stdlib/source/library/lux/data/format/html.lux b/stdlib/source/library/lux/data/format/html.lux index 3a8bcd5c6..7a9d61adc 100644 --- a/stdlib/source/library/lux/data/format/html.lux +++ b/stdlib/source/library/lux/data/format/html.lux @@ -43,7 +43,7 @@ {#Top} {#Frame Text})) -(def: (target value) +(def (target value) (-> Target Text) (case value {#Blank} "_blank" @@ -53,7 +53,7 @@ {#Frame name} name)) ... Properly formats text to ensure no injection can happen on the HTML. -(def: safe +(def safe (-> Text Text) (|>> (text.replaced "&" "&") (text.replaced "<" "<") @@ -62,20 +62,20 @@ (text.replaced "'" "'") (text.replaced "/" "/"))) -(def: attributes +(def attributes (-> Attributes Text) (|>> (list#each (function (_ [key val]) (format " " key "=" text.double_quote (..safe val) text.double_quote))) text.together)) -(def: (open tag attributes) +(def (open tag attributes) (-> Tag Attributes Text) (|> attributes ..attributes (format tag) (text.enclosed ["<" ">"]))) -(def: close +(def close (-> Tag Text) (text.enclosed ["</" ">"])) @@ -119,40 +119,40 @@ [Track Track']]] ) - (def: .public html + (def .public html (-> Document Text) (|>> representation)) - (def: .public (and pre post) + (def .public (and pre post) (All (_ brand) (-> (HTML brand) (HTML brand) (HTML brand))) (abstraction (format (representation pre) (representation post)))) - (def: .public (comment content node) + (def .public (comment content node) (All (_ brand) (-> Text (HTML brand) (HTML brand))) (abstraction (format (text.enclosed ["<!--" "-->"] content) (representation node)))) - (def: (empty name attributes) + (def (empty name attributes) (-> Tag Attributes HTML) (abstraction (format (..open name attributes) (..close name)))) - (def: (simple tag attributes) + (def (simple tag attributes) (-> Tag Attributes HTML) (|> attributes (..open tag) abstraction)) - (def: (tag name attributes content) + (def (tag name attributes content) (-> Tag Attributes (HTML Any) HTML) (abstraction (format (..open name attributes) (representation content) (..close name)))) - (def: (raw tag attributes content) + (def (raw tag attributes content) (-> Text Attributes Text HTML) (abstraction (format (..open tag attributes) @@ -160,7 +160,7 @@ (..close tag)))) (.with_template [<name> <tag> <brand>] - [(def: .public <name> + [(def .public <name> (-> Attributes <brand>) (..simple <tag>))] @@ -172,7 +172,7 @@ [parameter "param" Parameter] ) - (def: .public (base href target) + (def .public (base href target) (-> URL (Maybe Target) Meta) (let [partial (list ["href" href]) full (case target @@ -183,40 +183,40 @@ partial)] (..simple "base" full))) - (def: .public style + (def .public style (-> Style Meta) (|>> style.inline (..raw "style" (list)))) - (def: .public (script attributes inline) + (def .public (script attributes inline) (-> Attributes (Maybe Script) Meta) (|> inline (maybe#each js.code) (maybe.else "") (..raw "script" attributes))) - (def: .public text + (def .public text (-> Text Content) (|>> ..safe abstraction)) (.with_template [<tag> <alias> <name>] - [(def: .public <name> + [(def .public <name> Element (..simple <tag> (list))) - (def: .public <alias> <name>)] + (def .public <alias> <name>)] ["br" br line_break] ["wbr" wbr word_break] ["hr" hr separator] ) - (def: .public (image source attributes) + (def .public (image source attributes) (-> URL Attributes Image) (|> attributes {.#Item ["src" source]} (..simple "img"))) - (def: .public (svg attributes content) + (def .public (svg attributes content) (-> Attributes XML Element) (|> content (at xml.codec encoded) @@ -227,10 +227,10 @@ [#horizontal Nat #vertical Nat])) - (def: metric_separator ",") - (def: coord_separator ",") + (def metric_separator ",") + (def coord_separator ",") - (def: (%coord [horizontal vertical]) + (def (%coord [horizontal vertical]) (Format Coord) (format (%.nat horizontal) ..metric_separator (%.nat vertical))) @@ -251,15 +251,15 @@ #third Coord #extra (List Coord)])) - (def: (%rectangle [start end]) + (def (%rectangle [start end]) (Format Rectangle) (format (%coord start) ..coord_separator (%coord end))) - (def: (%circle [center radius]) + (def (%circle [center radius]) (Format Circle) (format (%coord center) ..metric_separator (%.nat radius))) - (def: (%polygon [first second third extra]) + (def (%polygon [first second third extra]) (Format Polygon) (|> (list.partial first second third extra) (list#each %coord) @@ -272,7 +272,7 @@ {#Polygon Polygon})) (.with_template [<name> <shape> <type> <format>] - [(def: (<name> attributes shape) + [(def (<name> attributes shape) (-> Attributes <type> (HTML Any)) (..simple "area" (list.partial ["shape" <shape>] ["coords" (<format> shape)] @@ -283,7 +283,7 @@ [polygon "poly" Polygon ..%polygon] ) - (def: (area attributes shape) + (def (area attributes shape) (-> Attributes Shape (HTML Any)) (case shape {#Rectangle rectangle} @@ -295,7 +295,7 @@ {#Polygon polygon} (..polygon attributes polygon))) - (def: .public (each attributes areas for) + (def .public (each attributes areas for) (-> Attributes (List [Attributes Shape]) Image Image) (all ..and for @@ -308,7 +308,7 @@ (list#mix (function.flipped ..and) head tail))))) (.with_template [<name> <tag> <type>] - [(def: .public <name> + [(def .public <name> (-> Attributes <type>) (..empty <tag>))] @@ -320,7 +320,7 @@ ) (.with_template [<name> <tag>] - [(def: .public (<name> attributes media on_unsupported) + [(def .public (<name> attributes media on_unsupported) (-> Attributes Media (Maybe Content) Element) (..tag <tag> attributes (|> on_unsupported @@ -331,20 +331,20 @@ [video "video"] ) - (def: .public (picture attributes sources image) + (def .public (picture attributes sources image) (-> Attributes Source Image Element) (..tag "picture" attributes (..and sources image))) - (def: .public (anchor href attributes content) + (def .public (anchor href attributes content) (-> URL Attributes Element Element) (..tag "a" (list.partial ["href" href] attributes) content)) - (def: .public label + (def .public label (-> ID Input) (|>> ["for"] list (..empty "label"))) (.with_template [<name> <container_tag> <description_tag> <type>] - [(def: .public (<name> description attributes content) + [(def .public (<name> description attributes content) (-> (Maybe Content) Attributes <type> <type>) (..tag <container_tag> attributes (case description @@ -362,7 +362,7 @@ ) (.with_template [<name> <tag> <type>] - [(def: .public (<name> attributes content) + [(def .public (<name> attributes content) (-> Attributes (Maybe Content) <type>) (|> content (maybe.else (..text "")) @@ -376,7 +376,7 @@ (-> Attributes Content Element)) (.with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> Phrase (..tag <tag>))] @@ -412,9 +412,9 @@ [variable "var"] ) - (def: .public incorrect ..struck) + (def .public incorrect ..struck) - (def: (ruby_pronunciation pronunciation) + (def (ruby_pronunciation pronunciation) (-> Content (HTML Any)) (..tag "rt" (list) (all ..and @@ -422,7 +422,7 @@ pronunciation (..tag "rp" (list) (..text ")"))))) - (def: .public (ruby attributes content pronunciation) + (def .public (ruby attributes content pronunciation) (-> Attributes Content Content Element) (..tag "ruby" attributes (all ..and @@ -433,7 +433,7 @@ (-> Attributes Element Element)) (.with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> Composite (..tag <tag>))] @@ -451,7 +451,7 @@ ) (.with_template [<tag> <name> <input>] - [(def: <name> + [(def <name> (-> <input> (HTML Any)) (..tag <tag> (list)))] @@ -459,7 +459,7 @@ ["dd" description Element] ) - (def: .public (description_list attributes descriptions) + (def .public (description_list attributes descriptions) (-> Attributes (List [Content Element]) Element) (case (list#each (function (_ [term description]) (all ..and @@ -473,10 +473,10 @@ (..tag "dl" attributes (list#mix (function.flipped ..and) head tail)))) - (def: .public p ..paragraph) + (def .public p ..paragraph) (.with_template [<name> <tag> <input> <output>] - [(def: .public <name> + [(def .public <name> (-> Attributes <input> <output>) (..tag <tag>))] @@ -495,7 +495,7 @@ ) (.with_template [<name> <tag> <input> <output>] - [(def: .public <name> + [(def .public <name> (-> <input> <output>) (..tag <tag> (list)))] @@ -509,7 +509,7 @@ ) (.with_template [<name> <tag> <input> <output>] - [(def: <name> + [(def <name> (-> <input> <output>) (..tag <tag> (list)))] @@ -520,7 +520,7 @@ [columns_group "colgroup" Column HTML] ) - (def: .public (table attributes caption columns headers rows footer) + (def .public (table attributes caption columns headers rows footer) (-> Attributes (Maybe Content) (Maybe Column) Header (List Cell) (Maybe Cell) Element) (let [head (..table_head (..table_row headers)) content (case (list#each table_row rows) @@ -556,7 +556,7 @@ content))) (.with_template [<name> <doc_type>] - [(def: .public <name> + [(def .public <name> (-> Head Body Document) (let [doc_type <doc_type>] (function (_ head body) diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux index 19c3a9bba..af8a52bb4 100644 --- a/stdlib/source/library/lux/data/format/json.lux +++ b/stdlib/source/library/lux/data/format/json.lux @@ -59,12 +59,12 @@ [Object (Dictionary String JSON)] ) -(def: .public null? +(def .public null? (Predicate JSON) (|>> (pipe.case {#Null} true _ false))) -(def: .public object +(def .public object (-> (List [String JSON]) JSON) (|>> (dictionary.of_list text.hash) {..#Object})) @@ -79,7 +79,7 @@ {#Object' (Dictionary String JSON')} {#Code' Code}))) -(def: jsonP +(def jsonP (<code>.Parser JSON') (<>.rec (function (_ jsonP) @@ -95,7 +95,7 @@ <code>.any )))) -(def: (jsonF token) +(def (jsonF token) (-> JSON' Code) (case token {#Null' _} @@ -122,11 +122,11 @@ {#Code' code} code)) -(def: .public json +(def .public json (syntax (_ [token ..jsonP]) (in (list (` (is JSON (~ (jsonF token)))))))) -(def: .public (fields json) +(def .public (fields json) (-> JSON (Try (List String))) (case json {#Object obj} @@ -135,7 +135,7 @@ _ {try.#Failure (all text#composite "Cannot get the fields of a non-object.")})) -(def: .public (field key json) +(def .public (field key json) (-> String JSON (Try JSON)) (case json {#Object obj} @@ -149,7 +149,7 @@ _ {try.#Failure (all text#composite "Cannot get field '" key "' on a non-object.")})) -(def: .public (has key value json) +(def .public (has key value json) (-> String JSON JSON (Try JSON)) (case json {#Object obj} @@ -159,7 +159,7 @@ {try.#Failure (all text#composite "Cannot set field '" key "' on a non-object.")})) (with_template [<name> <tag> <type>] - [(def: .public (<name> key json) + [(def .public (<name> key json) (-> Text JSON (Try <type>)) (case (field key json) {try.#Success {<tag> value}} @@ -178,10 +178,10 @@ [object_field #Object Object] ) -(def: .public equivalence +(def .public equivalence (Equivalence JSON) (implementation - (def: (= x y) + (def (= x y) (case [x y] [{#Null} {#Null}] #1 @@ -222,17 +222,17 @@ ............................................................ ............................................................ -(def: (null_format _) +(def (null_format _) (-> Null Text) "null") -(def: boolean_format +(def boolean_format (-> Boolean Text) (|>> (pipe.case #0 "false" #1 "true"))) -(def: number_format +(def number_format (-> Number Text) (|>> (pipe.case +0.0 ... OR -0.0 @@ -244,16 +244,16 @@ raw (|> raw (text.split_at 1) maybe.trusted product.right)))))) -(def: escape "\") -(def: escaped_dq (text#composite ..escape text.double_quote)) +(def escape "\") +(def escaped_dq (text#composite ..escape text.double_quote)) -(def: string_format +(def string_format (-> String Text) (|>> (text.replaced text.double_quote ..escaped_dq) (text.enclosed [text.double_quote text.double_quote]))) (with_template [<token> <name>] - [(def: <name> + [(def <name> Text <token>)] @@ -267,14 +267,14 @@ ["}" object_end] ) -(def: (array_format format) +(def (array_format format) (-> (-> JSON Text) (-> Array Text)) (|>> (sequence#each format) sequence.list (text.interposed ..value_separator) (text.enclosed [..array_start ..array_end]))) -(def: (kv_format format [key value]) +(def (kv_format format [key value]) (-> (-> JSON Text) (-> [String JSON] Text)) (all text#composite (..string_format key) @@ -282,14 +282,14 @@ (format value) )) -(def: (object_format format) +(def (object_format format) (-> (-> JSON Text) (-> Object Text)) (|>> dictionary.entries (list#each (..kv_format format)) (text.interposed ..value_separator) (text.enclosed [..object_start ..object_end]))) -(def: .public (format json) +(def .public (format json) (-> JSON Text) (case json (^.with_template [<tag> <format>] @@ -307,25 +307,25 @@ ............................................................ ............................................................ -(def: space_parser +(def space_parser (Parser Text) (<text>.some <text>.space)) -(def: value_separator_parser +(def value_separator_parser (Parser [Text Any Text]) (all <>.and ..space_parser (<text>.this ..value_separator) ..space_parser)) -(def: null_parser +(def null_parser (Parser Null) (do <>.monad [_ (<text>.this "null")] (in []))) (with_template [<name> <token> <value>] - [(def: <name> + [(def <name> (Parser Boolean) (do <>.monad [_ (<text>.this <token>)] @@ -335,13 +335,13 @@ [false_parser "false" #0] ) -(def: boolean_parser +(def boolean_parser (Parser Boolean) (all <>.either ..true_parser ..false_parser)) -(def: number_parser +(def number_parser (Parser Number) (do [! <>.monad] [signed? (<>.parses? (<text>.this "-")) @@ -363,7 +363,7 @@ {try.#Success value} (in value)))) -(def: escaped_parser +(def escaped_parser (Parser Text) (all <>.either (<>.after (<text>.this "\t") @@ -381,7 +381,7 @@ (<>.after (<text>.this "\\") (<>#in "\")))) -(def: string_parser +(def string_parser (Parser String) (<| (<text>.enclosed [text.double_quote text.double_quote]) (loop (again [_ []])) @@ -395,7 +395,7 @@ (in (all text#composite chars escaped next_chars))) (in chars)))) -(def: (kv_parser json_parser) +(def (kv_parser json_parser) (-> (Parser JSON) (Parser [String JSON])) (do <>.monad [key ..string_parser @@ -406,7 +406,7 @@ (in [key value]))) (with_template [<name> <type> <open> <close> <elem_parser> <prep>] - [(def: (<name> json_parser) + [(def (<name> json_parser) (-> (Parser JSON) (Parser <type>)) (do <>.monad [_ (<text>.this <open>) @@ -420,7 +420,7 @@ [object_parser Object ..object_start ..object_end (kv_parser json_parser) (dictionary.of_list text.hash)] ) -(def: json_parser +(def json_parser (Parser JSON) (<>.rec (function (_ json_parser) @@ -432,8 +432,8 @@ (array_parser json_parser) (object_parser json_parser))))) -(def: .public codec +(def .public codec (Codec Text JSON) (implementation - (def: encoded ..format) - (def: decoded (<text>.result json_parser)))) + (def encoded ..format) + (def decoded (<text>.result json_parser)))) diff --git a/stdlib/source/library/lux/data/format/markdown.lux b/stdlib/source/library/lux/data/format/markdown.lux index d65c5e6f6..f328045dc 100644 --- a/stdlib/source/library/lux/data/format/markdown.lux +++ b/stdlib/source/library/lux/data/format/markdown.lux @@ -13,7 +13,7 @@ ... https://www.markdownguide.org/basic-syntax/ -(def: safe +(def safe (-> Text Text) (|>> (text.replaced "\" "\\") (text.replaced "`" "\`") @@ -37,19 +37,19 @@ (primitive .public (Markdown brand) Text - (def: .public empty + (def .public empty Markdown (abstraction "")) - (def: .public text + (def .public text (-> Text (Markdown Span)) (|>> ..safe abstraction)) - (def: blank_line + (def blank_line (format text.new_line text.new_line)) (with_template [<name> <prefix>] - [(def: .public (<name> content) + [(def .public (<name> content) (-> Text (Markdown Block)) (abstraction (format <prefix> " " (..safe content) ..blank_line)))] @@ -61,20 +61,20 @@ [heading/6 "######"] ) - (def: (block content) + (def (block content) (-> Text (Markdown Block)) (abstraction (format content ..blank_line))) - (def: .public paragraph + (def .public paragraph (-> (Markdown Span) (Markdown Block)) (|>> representation ..block)) - (def: .public break + (def .public break (Markdown Span) (abstraction (format " " text.new_line))) (with_template [<name> <wrapper>] - [(def: .public <name> + [(def .public <name> (-> (Markdown Span) (Markdown Span)) (|>> representation (text.enclosed [<wrapper> <wrapper>]) @@ -84,7 +84,7 @@ [italic "_"] ) - (def: (prefix with) + (def (prefix with) (-> Text (-> Text Text)) (|>> (text.all_split_by text.new_line) (list#each (function (_ line) @@ -93,17 +93,17 @@ (format with line)))) (text.interposed text.new_line))) - (def: indent + (def indent (-> Text Text) (..prefix text.tab)) - (def: .public quote + (def .public quote (-> (Markdown Block) (Markdown Block)) (|>> representation (..prefix "> ") abstraction)) - (def: .public numbered_list + (def .public numbered_list (-> (List [(Markdown Span) (Maybe (Markdown Block))]) (Markdown Block)) (|>> list.enumeration @@ -122,7 +122,7 @@ (text.interposed text.new_line) ..block)) - (def: .public bullet_list + (def .public bullet_list (-> (List [(Markdown Span) (Maybe (Markdown Block))]) (Markdown Block)) (|>> (list#each (function (_ [summary detail]) @@ -141,19 +141,19 @@ ..block)) ... A snippet of code. - (def: .public snippet + (def .public snippet (-> Text (Markdown Span)) (|>> (text.enclosed ["`` " " ``"]) abstraction)) ... A (generic) block of code. - (def: .public generic_code + (def .public generic_code (-> Text (Markdown Block)) (let [open (format "```" text.new_line) close (format text.new_line "```")] (|>> (text.enclosed [open close]) ..block))) ... A block of code of a specific language. - (def: .public (code language block) + (def .public (code language block) (-> Text Text (Markdown Block)) (let [open (format "```" language text.new_line) close (format text.new_line "```")] @@ -161,15 +161,15 @@ (text.enclosed [open close]) ..block))) - (def: .public (image description url) + (def .public (image description url) (-> Text URL (Markdown Span)) (abstraction (format "![" (..safe description) "](" url ")"))) - (def: .public horizontal_rule + (def .public horizontal_rule (Markdown Block) (..block "___")) - (def: .public (link description url) + (def .public (link description url) (-> (Markdown Span) URL (Markdown Span)) (abstraction (format "[" (representation description) "](" url ")"))) @@ -177,7 +177,7 @@ Text) (with_template [<name> <type>] - [(def: .public <name> + [(def .public <name> (-> <type> (Markdown Span)) (|>> (text.enclosed ["<" ">"]) abstraction))] @@ -186,7 +186,7 @@ ) (with_template [<name> <brand> <infix>] - [(def: .public (<name> pre post) + [(def .public (<name> pre post) (-> (Markdown <brand>) (Markdown <brand>) (Markdown <brand>)) (abstraction (format (representation pre) <infix> (representation post))))] @@ -194,7 +194,7 @@ [then Block ""] ) - (def: .public markdown + (def .public markdown (All (_ a) (-> (Markdown a) Text)) (|>> representation)) ) diff --git a/stdlib/source/library/lux/data/format/tar.lux b/stdlib/source/library/lux/data/format/tar.lux index 272d666de..4fd668306 100644 --- a/stdlib/source/library/lux/data/format/tar.lux +++ b/stdlib/source/library/lux/data/format/tar.lux @@ -41,11 +41,11 @@ (type: Size Nat) -(def: octal_size +(def octal_size Size 8) -(def: (octal_padding max_size number) +(def (octal_padding max_size number) (-> Size Text Text) (let [padding_size (n.- (text.size number) max_size) @@ -54,16 +54,16 @@ text.together)] (format padding number))) -(def: blank " ") -(def: null text.null) +(def blank " ") +(def null text.null) -(def: small_size Size 6) -(def: big_size Size 11) +(def small_size Size 6) +(def big_size Size 11) (with_template [<exception> <limit> <size> <type> <in> <out> <writer> <suffix> <coercion>] - [(def: .public <limit> + [(def .public <limit> Nat (|> ..octal_size (list.repeated <size>) @@ -78,17 +78,17 @@ (primitive .public <type> Nat - (def: .public (<in> value) + (def .public (<in> value) (-> Nat (Try <type>)) (if (n.< <limit> value) {try.#Success (abstraction value)} (exception.except <exception> [value]))) - (def: .public <out> + (def .public <out> (-> <type> Nat) (|>> representation)) - (def: <writer> + (def <writer> (Writer <type>) (let [suffix <suffix> padded_size (n.+ (text.size suffix) <size>)] @@ -99,7 +99,7 @@ (at utf8.codec encoded) (\\format.segment padded_size)))) - (def: <coercion> + (def <coercion> (-> Nat <type>) (|>> (n.% <limit>) abstraction)) @@ -121,7 +121,7 @@ "Expected" (%.nat expected) "Actual" (%.nat actual))) -(def: small_suffix +(def small_suffix (Parser Any) (do <>.monad [pre_end <binary>.bits_8 @@ -135,7 +135,7 @@ (n.= expected end)))] (in []))) -(def: small_parser +(def small_parser (Parser Small) (do <>.monad [digits (<binary>.segment ..small_size) @@ -146,7 +146,7 @@ [value (at n.octal decoded digits)] (..small value))))) -(def: big_parser +(def big_parser (Parser Big) (do <>.monad [digits (<binary>.segment ..big_size) @@ -163,28 +163,28 @@ (primitive Checksum Text - (def: from_checksum + (def from_checksum (-> Checksum Text) (|>> representation)) - (def: dummy_checksum + (def dummy_checksum Checksum (abstraction " ")) - (def: checksum_suffix + (def checksum_suffix (format ..blank ..null)) - (def: checksum + (def checksum (-> Binary Nat) (binary.mix n.+ 0)) - (def: checksum_checksum + (def checksum_checksum (|> ..dummy_checksum representation (at utf8.codec encoded) ..checksum)) - (def: checksum_code + (def checksum_code (-> Binary Checksum) (|>> ..checksum ..as_small @@ -194,7 +194,7 @@ (text.suffix ..checksum_suffix) abstraction)) - (def: checksum_writer + (def checksum_writer (Writer Checksum) (let [padded_size (n.+ (text.size ..checksum_suffix) ..small_size)] @@ -202,7 +202,7 @@ (at utf8.codec encoded) (\\format.segment padded_size)))) - (def: checksum_parser + (def checksum_parser (Parser [Nat Checksum]) (do <>.monad [ascii (<binary>.segment ..small_size) @@ -214,11 +214,11 @@ (abstraction (format digits ..checksum_suffix))]))) ) -(def: last_ascii +(def last_ascii Char (number.hex "007F")) -(def: ascii? +(def ascii? (-> Text Bit) (|>> (at utf8.codec encoded) (binary.mix (function (_ char verdict) @@ -230,10 +230,10 @@ (exception.report "Text" (%.text text))) -(def: .public name_size Size 31) -(def: .public path_size Size 99) +(def .public name_size Size 31) +(def .public path_size Size 99) -(def: (un_padded string) +(def (un_padded string) (-> Binary Binary) (case (binary!.size string) 0 string @@ -258,7 +258,7 @@ "Size" (%.nat (text.size value)) "Maximum" (%.nat <size>))) - (def: .public (<in> value) + (def .public (<in> value) (-> <representation> (Try <type>)) (if (..ascii? value) (if (|> value @@ -269,11 +269,11 @@ {try.#Success (abstraction value)}) (exception.except ..not_ascii [value]))) - (def: .public <out> + (def .public <out> (-> <type> <representation>) (|>> representation)) - (def: <writer> + (def <writer> (Writer <type>) (let [suffix ..null padded_size (n.+ (text.size suffix) <size>)] @@ -282,7 +282,7 @@ (at utf8.codec encoded) (\\format.segment padded_size)))) - (def: <parser> + (def <parser> (Parser <type>) (do <>.monad [string (<binary>.segment <size>) @@ -295,7 +295,7 @@ [text (at utf8.codec decoded (..un_padded string))] (<in> text))))) - (def: .public <none> + (def .public <none> <type> (try.trusted (<in> ""))) )] @@ -304,19 +304,19 @@ [Path file.Path ..path_size path_is_too_long path from_path path_writer path_parser no_path] ) -(def: magic_size Size 7) +(def magic_size Size 7) (primitive Magic Text - (def: ustar + (def ustar (abstraction "ustar ")) - (def: from_magic + (def from_magic (-> Magic Text) (|>> representation)) - (def: magic_writer + (def magic_writer (Writer Magic) (let [padded_size (n.+ (text.size ..null) ..magic_size)] @@ -324,7 +324,7 @@ (at utf8.codec encoded) (\\format.segment padded_size)))) - (def: magic_parser + (def magic_parser (Parser Magic) (do <>.monad [string (<binary>.segment ..magic_size) @@ -337,32 +337,32 @@ (at utf8.codec decoded string))))) ) -(def: block_size Size 512) +(def block_size Size 512) -(def: owner_id_size ..small_size) +(def owner_id_size ..small_size) -(def: blank_size Size (text.size ..blank)) -(def: null_size Size (text.size ..null)) -(def: mode_size Size ..small_size) -(def: content_size Size ..big_size) -(def: modification_time_size Size ..big_size) -(def: checksum_size Size ..small_size) -(def: link_flag_size Size 1) -(def: device_size Size ..small_size) +(def blank_size Size (text.size ..blank)) +(def null_size Size (text.size ..null)) +(def mode_size Size ..small_size) +(def content_size Size ..big_size) +(def modification_time_size Size ..big_size) +(def checksum_size Size ..small_size) +(def link_flag_size Size 1) +(def device_size Size ..small_size) -(def: small_number +(def small_number (-> Size Size) (|>> (all n.+ ..blank_size ..null_size))) -(def: big_number +(def big_number (-> Size Size) (|>> (all n.+ ..blank_size))) -(def: string +(def string (-> Size Size) (|>> (all n.+ ..null_size))) -(def: header_size +(def header_size (all n.+ ... name (..string ..path_size) @@ -396,11 +396,11 @@ (primitive Link_Flag Char - (def: link_flag + (def link_flag (-> Link_Flag Char) (|>> representation)) - (def: link_flag_writer + (def link_flag_writer (Writer Link_Flag) (|>> representation \\format.bits_8)) @@ -415,7 +415,7 @@ [(char "6") fifo] [(char "7") contiguous])] (with_template [<flag> <name>] - [(def: <name> + [(def <name> Link_Flag (abstraction <flag>))] @@ -426,7 +426,7 @@ (exception.report "Value" (%.nat value))) - (def: link_flag_parser + (def link_flag_parser (Parser Link_Flag) (do <>.monad [it <binary>.bits_8] @@ -444,17 +444,17 @@ (primitive .public Mode Nat - (def: .public mode + (def .public mode (-> Mode Nat) (|>> representation)) - (def: .public (and left right) + (def .public (and left right) (-> Mode Mode Mode) (abstraction (i64.or (representation left) (representation right)))) - (def: mode_writer + (def mode_writer (Writer Mode) (|>> representation ..small @@ -483,14 +483,14 @@ ["2000" set_group_id_on_execution] ["4000" set_user_id_on_execution])] (with_template [<code> <name>] - [(def: .public <name> + [(def .public <name> Mode (abstraction (number.oct <code>)))] <options> ) - (def: maximum_mode + (def maximum_mode Mode (all and ..none @@ -512,7 +512,7 @@ ..set_user_id_on_execution )) - (def: mode_parser + (def mode_parser (Parser Mode) (do [! <>.monad] [value (at ! each ..from_small ..small_parser)] @@ -523,7 +523,7 @@ (in (abstraction value)))))) ) -(def: maximum_content_size +(def maximum_content_size Nat (|> ..octal_size (list.repeated ..content_size) @@ -532,17 +532,17 @@ (primitive .public Content [Big Binary] - (def: .public (content content) + (def .public (content content) (-> Binary (Try Content)) (do try.monad [size (..big (binary!.size content))] (in (abstraction [size content])))) - (def: from_content + (def from_content (-> Content [Big Binary]) (|>> representation)) - (def: .public data + (def .public data (-> Content Binary) (|>> representation product.right)) ) @@ -550,7 +550,7 @@ (type: .public ID Small) -(def: .public no_id +(def .public no_id ID (..as_small 0)) @@ -582,14 +582,14 @@ (type: Device Small) -(def: no_device +(def no_device Device (try.trusted (..small 0))) (type: .public Tar (Sequence Entry)) -(def: (blocks size) +(def (blocks size) (-> Big Nat) (n.+ (n./ ..block_size (..from_big size)) @@ -597,7 +597,7 @@ 0 0 _ 1))) -(def: rounded_content_size +(def rounded_content_size (-> Big Nat) (|>> ..blocks (n.* ..block_size))) @@ -619,7 +619,7 @@ #major_device Device #minor_device Device])) -(def: header_writer' +(def header_writer' (Writer Header) (all \\format.and ..path_writer @@ -638,7 +638,7 @@ ..small_writer )) -(def: (header_writer header) +(def (header_writer header) (Writer Header) (let [checksum (|> header (has #checksum ..dummy_checksum) @@ -649,14 +649,14 @@ (\\format.result ..header_writer') (\\format.segment ..block_size)))) -(def: modification_time +(def modification_time (-> Instant Big) (|>> instant.relative (duration.ticks duration.second) .nat ..as_big)) -(def: (file_writer link_flag) +(def (file_writer link_flag) (-> Link_Flag (Writer File)) (function (_ [path modification_time mode ownership content]) (let [[size content] (..from_content content) @@ -679,15 +679,15 @@ #minor_device ..no_device] content])))) -(def: normal_file_writer +(def normal_file_writer (Writer File) (..file_writer ..normal)) -(def: contiguous_file_writer +(def contiguous_file_writer (Writer File) (..file_writer ..contiguous)) -(def: (symbolic_link_writer path) +(def (symbolic_link_writer path) (Writer Path) (..header_writer [#path ..no_path @@ -705,7 +705,7 @@ #major_device ..no_device #minor_device ..no_device])) -(def: (directory_writer path) +(def (directory_writer path) (Writer Path) (..header_writer [#path path @@ -723,7 +723,7 @@ #major_device ..no_device #minor_device ..no_device])) -(def: entry_writer +(def entry_writer (Writer Entry) (|>> (pipe.case {#Normal value} (..normal_file_writer value) @@ -731,11 +731,11 @@ {#Directory value} (..directory_writer value) {#Contiguous value} (..contiguous_file_writer value)))) -(def: end_of_archive_size +(def end_of_archive_size Size (n.* 2 ..block_size)) -(def: .public writer +(def .public writer (Writer Tar) (let [end_of_archive (binary!.empty ..end_of_archive_size)] (function (_ tar) @@ -751,7 +751,7 @@ "Expected" (%.nat expected) "Actual" (%.nat actual))) -(def: header_padding_size +(def header_padding_size (n.- header_size block_size)) ... When the checksum gets originally calculated, the assumption is that all the characters in the checksum field @@ -760,7 +760,7 @@ ... an incorrect result, as the contents of the checksum field would be an actual checksum, instead of just spaces. ... To correct for this, it is necessary to calculate the checksum of just the checksum field, subtract that, and then ... add-in the checksum of the spaces. -(def: (expected_checksum checksum header) +(def (expected_checksum checksum header) (-> Checksum Binary Nat) (let [|checksum| (|> checksum ..from_checksum @@ -770,7 +770,7 @@ (n.- |checksum|) (n.+ ..checksum_checksum)))) -(def: header_parser +(def header_parser (Parser Header) (do <>.monad [binary_header (<>.speculative (<binary>.segment block_size)) @@ -808,7 +808,7 @@ #major_device major_device #minor_device minor_device]))) -(def: (file_parser header) +(def (file_parser header) (-> Header (Parser File)) (do <>.monad [.let [size (the #size header) @@ -831,7 +831,7 @@ #id (the #group_id header)]] content]))) -(def: entry_parser +(def entry_parser (Parser Entry) (do [! <>.monad] [header ..header_parser] @@ -850,7 +850,7 @@ ... It's safe to implement the parser this way because the range of values for Nat is 2^64 ... Whereas the maximum possible value for the checksum of a 512 block is (256 × 512) = 131,072 -(def: end_of_archive_block_parser +(def end_of_archive_block_parser (Parser Any) (do <>.monad [block (<binary>.segment ..block_size)] @@ -861,7 +861,7 @@ (exception: .public invalid_end_of_archive) -(def: end_of_archive_parser +(def end_of_archive_parser (Parser Any) (do <>.monad [_ (<>.at_most 2 end_of_archive_block_parser) @@ -870,7 +870,7 @@ (exception.assertion ..invalid_end_of_archive [] done?)))) -(def: .public parser +(def .public parser (Parser Tar) (|> (<>.some ..entry_parser) (at <>.monad each sequence.of_list) diff --git a/stdlib/source/library/lux/data/format/xml.lux b/stdlib/source/library/lux/data/format/xml.lux index ff08ad834..41ec13be0 100644 --- a/stdlib/source/library/lux/data/format/xml.lux +++ b/stdlib/source/library/lux/data/format/xml.lux @@ -31,7 +31,7 @@ (type: .public Attrs (Dictionary Attribute Text)) -(def: .public attributes +(def .public attributes Attrs (dictionary.empty symbol.hash)) @@ -41,10 +41,10 @@ {#Text Text} {#Node Tag Attrs (List XML)}))) -(def: namespace_separator +(def namespace_separator ":") -(def: xml_standard_escape_char^ +(def xml_standard_escape_char^ (Parser Text) (all <>.either (<>.after (<text>.this "<") (<>#in "<")) @@ -54,7 +54,7 @@ (<>.after (<text>.this """) (<>#in text.double_quote)) )) -(def: xml_unicode_escape_char^ +(def xml_unicode_escape_char^ (Parser Text) (|> (do [! <>.monad] [hex? (<>.maybe (<text>.this "x"))] @@ -71,17 +71,17 @@ (<>.before (<text>.this ";")) (<>.after (<text>.this "&#")))) -(def: xml_escape_char^ +(def xml_escape_char^ (Parser Text) (<>.either xml_standard_escape_char^ xml_unicode_escape_char^)) -(def: xml_char^ +(def xml_char^ (Parser Text) (<>.either (<text>.none_of (all text#composite "<>&" text.double_quote)) xml_escape_char^)) -(def: xml_identifier +(def xml_identifier (Parser Text) (<text>.slice (all <text>.and! @@ -90,7 +90,7 @@ (<text>.some! (<>.either (<text>.one_of! "_.-") <text>.alpha_num!))))) -(def: namespaced_symbol^ +(def namespaced_symbol^ (Parser Symbol) (do <>.monad [first_part xml_identifier @@ -102,22 +102,22 @@ {.#Some second_part} (in [first_part second_part])))) -(def: tag^ namespaced_symbol^) -(def: attr_name^ namespaced_symbol^) +(def tag^ namespaced_symbol^) +(def attr_name^ namespaced_symbol^) -(def: spaced^ +(def spaced^ (All (_ a) (-> (Parser a) (Parser a))) (let [white_space^ (<>.some <text>.space)] (|>> (<>.before white_space^) (<>.after white_space^)))) -(def: attr_value^ +(def attr_value^ (Parser Text) (let [value^ (<text>.some xml_char^)] (<>.either (<text>.enclosed [text.double_quote text.double_quote] value^) (<text>.enclosed ["'" "'"] value^)))) -(def: attrs^ +(def attrs^ (Parser Attrs) (<| (at <>.monad each (dictionary.of_list symbol.hash)) <>.some @@ -125,7 +125,7 @@ (<>.after (<text>.this "=")) (..spaced^ attr_value^))) -(def: (close_tag^ expected) +(def (close_tag^ expected) (-> Tag (Parser [])) (do <>.monad [actual (|> tag^ @@ -137,21 +137,21 @@ " Actual: " (symbol#encoded actual) \n) (symbol#= expected actual)))) -(def: comment^ +(def comment^ (Parser Slice) (|> (<text>.not! (<text>.this "--")) <text>.some! (<text>.enclosed ["<!--" "-->"]) ..spaced^)) -(def: xml_header^ +(def xml_header^ (Parser Attrs) (|> (..spaced^ attrs^) (<>.before (<text>.this "?>")) (<>.after (<text>.this "<?xml")) ..spaced^)) -(def: cdata^ +(def cdata^ (Parser Slice) (let [end (<text>.this "]]>")] (|> (<text>.some! (<text>.not! end)) @@ -159,17 +159,17 @@ (<>.after (<text>.this "<![CDATA[")) ..spaced^))) -(def: text^ +(def text^ (Parser XML) (|> (..spaced^ (<text>.many xml_char^)) (<>.either (<text>.slice cdata^)) (<>#each (|>> {#Text})))) -(def: null^ +(def null^ (Parser Any) (<text>.this (text.of_char 0))) -(def: xml^ +(def xml^ (Parser XML) (|> (<>.rec (function (_ node^) @@ -202,7 +202,7 @@ (<>.before (<>.some ..null^)) (<>.after (<>.maybe ..xml_header^)))) -(def: (sanitize_value input) +(def (sanitize_value input) (-> Text Text) (|> input (text.replaced "&" "&") @@ -211,17 +211,17 @@ (text.replaced "'" "'") (text.replaced text.double_quote """))) -(def: .public (tag [namespace name]) +(def .public (tag [namespace name]) (-> Tag Text) (case namespace "" name _ (all text#composite namespace ..namespace_separator name))) -(def: .public attribute +(def .public attribute (-> Attribute Text) ..tag) -(def: xml_header +(def xml_header Text (let [quote (is (-> Text Text) (function (_ value) @@ -232,10 +232,10 @@ " encoding=" (quote "UTF-8") "?>"))) -(def: .public codec +(def .public codec (Codec Text XML) (implementation - (def: encoded + (def encoded (let [attributes (is (-> Attrs Text) (function (_ attrs) (|> attrs @@ -275,13 +275,13 @@ text.together) text.new_line prefix "</" tag ">"))))) )))) - (def: decoded + (def decoded (<text>.result ..xml^)))) -(def: .public equivalence +(def .public equivalence (Equivalence XML) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{#Text reference/value} {#Text sample/value}] (text#= reference/value sample/value) diff --git a/stdlib/source/library/lux/data/identity.lux b/stdlib/source/library/lux/data/identity.lux index 55e942681..30d890dff 100644 --- a/stdlib/source/library/lux/data/identity.lux +++ b/stdlib/source/library/lux/data/identity.lux @@ -12,28 +12,28 @@ (type: .public (Identity a) a) -(def: .public functor +(def .public functor (Functor Identity) (implementation - (def: each function.identity))) + (def each function.identity))) -(def: .public apply +(def .public apply (Apply Identity) (implementation - (def: functor ..functor) - (def: (on fa ff) + (def functor ..functor) + (def (on fa ff) (ff fa)))) -(def: .public monad +(def .public monad (Monad Identity) (implementation - (def: functor ..functor) - (def: in function.identity) - (def: conjoint function.identity))) + (def functor ..functor) + (def in function.identity) + (def conjoint function.identity))) -(def: .public comonad +(def .public comonad (CoMonad Identity) (implementation - (def: functor ..functor) - (def: out function.identity) - (def: disjoint function.identity))) + (def functor ..functor) + (def out function.identity) + (def disjoint function.identity))) diff --git a/stdlib/source/library/lux/data/product.lux b/stdlib/source/library/lux/data/product.lux index 02caab668..6e8767e04 100644 --- a/stdlib/source/library/lux/data/product.lux +++ b/stdlib/source/library/lux/data/product.lux @@ -6,7 +6,7 @@ [hash (.only Hash)]]]]) (with_template [<name>] - [(def: .public (<name> [left right]) + [(def .public (<name> [left right]) (All (_ left right) (-> [left right] <name>)) <name>)] @@ -16,14 +16,14 @@ ) ... https://en.wikipedia.org/wiki/Currying -(def: .public (curried f) +(def .public (curried f) (All (_ a b c) (-> (-> [a b] c) (-> a b c))) (function (_ x y) (f [x y]))) -(def: .public (uncurried f) +(def .public (uncurried f) (All (_ a b c) (-> (-> a b c) (-> [a b] c))) @@ -31,38 +31,38 @@ (let [[x y] xy] (f x y)))) -(def: .public (swapped [left right]) +(def .public (swapped [left right]) (All (_ left right) (-> [left right] [right left])) [right left]) -(def: .public (then f g) +(def .public (then f g) (All (_ a b c d) (-> (-> a c) (-> b d) (-> [a b] [c d]))) (function (_ [x y]) [(f x) (g y)])) -(def: .public (forked f g) +(def .public (forked f g) (All (_ a l r) (-> (-> a l) (-> a r) (-> a [l r]))) (function (_ x) [(f x) (g x)])) -(def: .public (equivalence left right) +(def .public (equivalence left right) (All (_ l r) (-> (Equivalence l) (Equivalence r) (Equivalence [l r]))) (implementation - (def: (= [rl rr] [sl sr]) + (def (= [rl rr] [sl sr]) (and (at left = rl sl) (at right = rr sr))))) -(def: .public (hash left right) +(def .public (hash left right) (All (_ l r) (-> (Hash l) (Hash r) (Hash [l r]))) (implementation - (def: equivalence + (def equivalence (..equivalence (at left equivalence) (at right equivalence))) - (def: (hash [leftV rightV]) + (def (hash [leftV rightV]) ("lux i64 +" (at left hash leftV) (at right hash rightV))))) diff --git a/stdlib/source/library/lux/data/store.lux b/stdlib/source/library/lux/data/store.lux index c5b82a4c5..8e4c0746d 100644 --- a/stdlib/source/library/lux/data/store.lux +++ b/stdlib/source/library/lux/data/store.lux @@ -12,43 +12,43 @@ [#cursor s #peek (-> s a)])) -(def: (extend f wa) +(def (extend f wa) (All (_ s a b) (-> (-> (Store s a) b) (Store s a) (Store s b))) [#cursor (the #cursor wa) #peek (function (_ s) (f (has #cursor s wa)))]) -(def: .public functor +(def .public functor (All (_ s) (Functor (Store s))) (implementation - (def: (each f fa) + (def (each f fa) (extend (function (_ store) (f (at store peek (at store cursor)))) fa)))) -(def: .public comonad +(def .public comonad (All (_ s) (CoMonad (Store s))) (implementation - (def: functor + (def functor ..functor) - (def: (out wa) + (def (out wa) (a/an peek (a/an cursor))) - (def: disjoint + (def disjoint (extend id)))) -(def: .public (peeks trans store) +(def .public (peeks trans store) (All (_ s a) (-> (-> s s) (Store s a) a)) (|> (a/an cursor) trans (a/an peek))) -(def: .public (seek cursor store) +(def .public (seek cursor store) (All (_ s a) (-> s (Store s a) (Store s a))) (at (a/an disjoint store) peek cursor)) -(def: .public (seeks change store) +(def .public (seeks change store) (All (_ s a) (-> (-> s s) (Store s a) (Store s a))) (|> store (a/an disjoint) (peeks change))) -(def: .public (experiment Functor<f> change store) +(def .public (experiment Functor<f> change store) (All (_ f s a) (-> (Functor f) (-> s (f s)) (Store s a) (f a))) (at Functor<f> each (a/an peek) (change (a/an cursor)))) diff --git a/stdlib/source/library/lux/data/sum.lux b/stdlib/source/library/lux/data/sum.lux index 00dddc0e6..ce03e75d6 100644 --- a/stdlib/source/library/lux/data/sum.lux +++ b/stdlib/source/library/lux/data/sum.lux @@ -6,7 +6,7 @@ [hash (.only Hash)]]]]) (with_template [<right?> <name>] - [(def: .public (<name> value) + [(def .public (<name> value) (All (_ left right) (-> <name> (Or left right))) {0 <right?> value})] @@ -14,7 +14,7 @@ [#0 left] [#1 right]) -(def: .public (either on_left on_right) +(def .public (either on_left on_right) (All (_ a b c) (-> (-> a c) (-> b c) (-> (Or a b) c))) @@ -23,7 +23,7 @@ {0 #0 l} (on_left l) {0 #1 r} (on_right r)))) -(def: .public (then on_left on_right) +(def .public (then on_left on_right) (All (_ l l' r r') (-> (-> l l') (-> r r') (-> (Or l r) (Or l' r')))) @@ -33,7 +33,7 @@ {0 #1 r} {0 #1 (on_right r)}))) (with_template [<name> <side> <right?>] - [(def: .public (<name> items) + [(def .public (<name> items) (All (_ a b) (-> (List (Or a b)) (List <side>))) (case items {.#End} @@ -49,7 +49,7 @@ [rights b #1] ) -(def: .public (partition xs) +(def .public (partition xs) (All (_ a b) (-> (List (Or a b)) [(List a) (List b)])) (case xs {.#End} @@ -61,10 +61,10 @@ {0 #0 x'} [{.#Item x' lefts} rights] {0 #1 x'} [lefts {.#Item x' rights}])))) -(def: .public (equivalence left right) +(def .public (equivalence left right) (All (_ l r) (-> (Equivalence l) (Equivalence r) (Equivalence (Or l r)))) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{.#Left reference} {.#Left sample}] (at left = reference sample) @@ -75,13 +75,13 @@ _ false)))) -(def: .public (hash left right) +(def .public (hash left right) (All (_ l r) (-> (Hash l) (Hash r) (Hash (Or l r)))) (implementation - (def: equivalence + (def equivalence (..equivalence (at left equivalence) (at right equivalence))) - (def: (hash value) + (def (hash value) (.nat (case value {.#Left value} ("lux i64 *" +2 (.int (at left hash value))) diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux index 918fde82a..9c2649f55 100644 --- a/stdlib/source/library/lux/data/text.lux +++ b/stdlib/source/library/lux/data/text.lux @@ -26,13 +26,13 @@ ... TODO: Instead of ints, chars should be produced fron nats. ... (The JVM specifies chars as 16-bit unsigned integers) -(def: .public of_char +(def .public of_char (-> Char Text) (|>> .int "lux i64 char")) (with_template [<code> <short> <long>] - [(def: .public <long> (..of_char <code>)) - (def: .public <short> <long>)] + [(def .public <long> (..of_char <code>)) + (def .public <short> <long>)] [00 \0 null] [07 \a alarm] @@ -45,28 +45,28 @@ [34 \'' double_quote] ) -(def: .public line_feed +(def .public line_feed ..new_line) -(def: .public size +(def .public size (-> Text Nat) (|>> "lux text size")) -(def: .public (char index input) +(def .public (char index input) (-> Nat Text (Maybe Char)) (if (n.< ("lux text size" input) index) {.#Some ("lux text char" index input)} {.#None})) -(def: .public (index_since offset pattern input) +(def .public (index_since offset pattern input) (-> Nat Text Text (Maybe Nat)) ("lux text index" offset pattern input)) -(def: .public (index pattern input) +(def .public (index pattern input) (-> Text Text (Maybe Nat)) (index_since 0 pattern input)) -(def: .public (last_index part text) +(def .public (last_index part text) (-> Text Text (Maybe Nat)) (loop (again [offset 0 output (is (Maybe Nat) @@ -79,7 +79,7 @@ {.#Some offset'} (again (++ offset') output'))))) -(def: .public (starts_with? prefix x) +(def .public (starts_with? prefix x) (-> Text Text Bit) (case (index prefix x) {.#Some 0} @@ -88,7 +88,7 @@ _ false)) -(def: .public (ends_with? postfix x) +(def .public (ends_with? postfix x) (-> Text Text Bit) (case (last_index postfix x) {.#Some n} @@ -98,12 +98,12 @@ _ false)) -(def: .public (enclosed_by? boundary value) +(def .public (enclosed_by? boundary value) (-> Text Text Bit) (and (starts_with? boundary value) (ends_with? boundary value))) -(def: .public (contains? sub text) +(def .public (contains? sub text) (-> Text Text Bit) (case ("lux text index" 0 sub text) {.#Some _} @@ -112,40 +112,40 @@ _ false)) -(def: .public (prefix param subject) +(def .public (prefix param subject) (-> Text Text Text) ("lux text concat" param subject)) -(def: .public (suffix param subject) +(def .public (suffix param subject) (-> Text Text Text) ("lux text concat" subject param)) -(def: .public (enclosed [left right] content) +(def .public (enclosed [left right] content) (-> [Text Text] Text Text) (all "lux text concat" left content right)) -(def: .public (enclosed' boundary content) +(def .public (enclosed' boundary content) (-> Text Text Text) (enclosed [boundary boundary] content)) -(def: .public format +(def .public format (-> Text Text) (..enclosed' ..double_quote)) -(def: .public (clip offset size input) +(def .public (clip offset size input) (-> Nat Nat Text (Maybe Text)) (if (|> size (n.+ offset) (n.> ("lux text size" input))) {.#None} {.#Some ("lux text clip" offset size input)})) -(def: .public (clip_since offset input) +(def .public (clip_since offset input) (-> Nat Text (Maybe Text)) (let [size ("lux text size" input)] (if (n.> size offset) {.#None} {.#Some ("lux text clip" offset (n.- offset size) input)}))) -(def: .public (split_at at x) +(def .public (split_at at x) (-> Nat Text (Maybe [Text Text])) (case [(..clip 0 at x) (..clip_since at x)] [{.#Some pre} {.#Some post}] @@ -154,7 +154,7 @@ _ {.#None})) -(def: .public (split_by token sample) +(def .public (split_by token sample) (-> Text Text (Maybe [Text Text])) (do maybe.monad [index (index token sample) @@ -162,7 +162,7 @@ [_ post] (split_at (size token) post')] (in [pre post]))) -(def: .public (all_split_by token sample) +(def .public (all_split_by token sample) (-> Text Text (List Text)) (loop (again [input sample output (is (List Text) (list))]) @@ -177,14 +177,14 @@ {.#Item input} list.reversed)))) -(def: .public (replaced_once pattern replacement template) +(def .public (replaced_once pattern replacement template) (-> Text Text Text Text) (<| (maybe.else template) (do maybe.monad [[pre post] (..split_by pattern template)] (in (all "lux text concat" pre replacement post))))) -(for @.js (these (def: defined? +(for @.js (these (def defined? (macro (_ tokens lux) (case tokens (pattern (list it)) @@ -197,7 +197,7 @@ _ {.#Left ""}))) - (def: if_nashorn + (def if_nashorn (macro (_ tokens lux) (case tokens (pattern (list then else)) @@ -211,7 +211,7 @@ {.#Left ""})))) (these)) -(def: .public (replaced pattern replacement template) +(def .public (replaced pattern replacement template) (-> Text Text Text Text) (with_expansions [... Inefficient default <default> (loop (again [left "" @@ -258,34 +258,34 @@ ... Inefficient default <default>))) -(def: .public equivalence +(def .public equivalence (Equivalence Text) (implementation - (def: (= reference sample) + (def (= reference sample) ("lux text =" reference sample)))) -(def: .public order +(def .public order (Order Text) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (< reference sample) + (def (< reference sample) ("lux text <" reference sample)))) -(def: .public monoid +(def .public monoid (Monoid Text) (implementation - (def: identity "") + (def identity "") - (def: (composite left right) + (def (composite left right) ("lux text concat" left right)))) -(def: .public hash +(def .public hash (Hash Text) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (hash input) + (def (hash input) (for @.old (|> input (is (Primitive "java.lang.Object")) @@ -313,29 +313,29 @@ (n.+ ("lux text char" index input)))) hash))))))) -(def: .public together +(def .public together (-> (List Text) Text) (let [(^.open "[0]") ..monoid] (|>> list.reversed (list#mix composite identity)))) -(def: .public (interposed separator texts) +(def .public (interposed separator texts) (-> Text (List Text) Text) (case separator "" (..together texts) _ (|> texts (list.interposed separator) ..together))) -(def: .public (empty? text) +(def .public (empty? text) (-> Text Bit) (case text "" true _ false)) -(def: .public space +(def .public space Text " ") -(def: .public (space? char) +(def .public (space? char) (-> Char Bit) (with_expansions [<options> (with_template [<char>] [(pattern (.char (~~ (static <char>))))] @@ -354,7 +354,7 @@ _ false)))) -(def: .public (lower_cased value) +(def .public (lower_cased value) (-> Text Text) (for @.old (as Text @@ -377,7 +377,7 @@ (as Text ("ruby object do" "downcase" value [])))) -(def: .public (upper_cased value) +(def .public (upper_cased value) (-> Text Text) (for @.old (as Text diff --git a/stdlib/source/library/lux/data/text/buffer.lux b/stdlib/source/library/lux/data/text/buffer.lux index a099758f5..82404b2dd 100644 --- a/stdlib/source/library/lux/data/text/buffer.lux +++ b/stdlib/source/library/lux/data/text/buffer.lux @@ -56,7 +56,7 @@ ... default (Sequence Text)) - (def: .public empty + (def .public empty Buffer (abstraction (with_expansions [<jvm> [0 function.identity]] (for @.old <jvm> @@ -66,7 +66,7 @@ ... default sequence.empty)))) - (def: .public (then chunk buffer) + (def .public (then chunk buffer) (-> Text Buffer Buffer) (with_expansions [<jvm> (let [[capacity transform] (representation buffer) then! (is (-> Text java/lang/StringBuilder java/lang/StringBuilder) @@ -98,7 +98,7 @@ ... default (|> buffer representation (sequence.suffix chunk) abstraction)))) - (def: .public size + (def .public size (-> Buffer Nat) (with_expansions [<jvm> (|>> representation product.left)] (for @.old <jvm> @@ -111,7 +111,7 @@ (n.+ (//.size chunk) total)) 0))))) - (def: .public (text buffer) + (def .public (text buffer) (-> Buffer Text) (with_expansions [<jvm> (let [[capacity transform] (representation buffer)] (|> (java/lang/StringBuilder::new (ffi.as_int (.int capacity))) diff --git a/stdlib/source/library/lux/data/text/encoding.lux b/stdlib/source/library/lux/data/text/encoding.lux index 2863d9623..16a0a2891 100644 --- a/stdlib/source/library/lux/data/text/encoding.lux +++ b/stdlib/source/library/lux/data/text/encoding.lux @@ -11,7 +11,7 @@ Text (with_template [<name> <encoding>] - [(`` (def: .public <name> + [(`` (def .public <name> Encoding (abstraction <encoding>)))] @@ -160,7 +160,7 @@ [koi8_u "KOI8-U"] ) - (def: .public name + (def .public name (-> Encoding Text) (|>> representation)) ) diff --git a/stdlib/source/library/lux/data/text/encoding/utf8.lux b/stdlib/source/library/lux/data/text/encoding/utf8.lux index a95d4f163..8c7e5ef26 100644 --- a/stdlib/source/library/lux/data/text/encoding/utf8.lux +++ b/stdlib/source/library/lux/data/text/encoding/utf8.lux @@ -55,7 +55,7 @@ (these (ffi.import Almost_Binary) (ffi.import (unpack [ffi.String ffi.String] Almost_Binary)) (ffi.import (array_values [Almost_Binary] Binary)) - (def: php_byte_array_format "C*")) + (def php_byte_array_format "C*")) @.scheme ... https://srfi.schemers.org/srfi-140/srfi-140.html @@ -63,7 +63,7 @@ (ffi.import (utf8->string [Binary] Text))) (these))) -(def: (encoded value) +(def (encoded value) (-> Text Binary) (for @.old (java/lang/String::getBytes (ffi.as_string (//.name //.utf_8)) @@ -109,7 +109,7 @@ @.scheme (..string->utf8 value))) -(def: (decoded value) +(def (decoded value) (-> Binary (Try Text)) (with_expansions [<jvm> {try.#Success (ffi.of_string (java/lang/String::new value (ffi.as_string (//.name //.utf_8))))}] (for @.old <jvm> @@ -155,8 +155,8 @@ ..utf8->string {try.#Success})))) -(def: .public codec +(def .public codec (Codec Binary Text) (implementation - (def: encoded ..encoded) - (def: decoded ..decoded))) + (def encoded ..encoded) + (def decoded ..decoded))) diff --git a/stdlib/source/library/lux/data/text/escape.lux b/stdlib/source/library/lux/data/text/escape.lux index 258c5c3a9..f2c21a26e 100644 --- a/stdlib/source/library/lux/data/text/escape.lux +++ b/stdlib/source/library/lux/data/text/escape.lux @@ -20,10 +20,10 @@ ["[0]" // (.only Char) ["%" \\format (.only format)]]) -(def: sigil "\") +(def sigil "\") (with_template [<char> <sigil>] - [(def: <char> + [(def <char> (|> <sigil> (//.char 0) maybe.trusted))] [sigil_char ..sigil] @@ -31,10 +31,10 @@ ) (with_template [<literal> <sigil> <escaped>] - [(def: <sigil> + [(def <sigil> (|> <literal> (//.char 0) maybe.trusted)) - (def: <escaped> + (def <escaped> (format ..sigil <literal>))] ["0" \0_sigil escaped_\0] @@ -50,7 +50,7 @@ ) (with_template [<char> <text>] - [(def: <char> + [(def <char> (|> <text> (//.char 0) maybe.trusted))] [\0 //.\0] @@ -65,10 +65,10 @@ [\\ ..sigil] ) -(def: ascii_bottom (hex "20")) -(def: ascii_top (hex "7E")) +(def ascii_bottom (hex "20")) +(def ascii_top (hex "7E")) -(def: .public (escapable? char) +(def .public (escapable? char) (-> Char Bit) (or (n.< ..ascii_bottom char) (n.> ..ascii_top char) @@ -83,7 +83,7 @@ _ false))) -(def: (ascii_escaped replacement pre_offset pre_limit previous current) +(def (ascii_escaped replacement pre_offset pre_limit previous current) (-> Text Nat Nat Text Text [Text Text Nat]) (let [post_offset (++ pre_offset) post_limit (n.- post_offset pre_limit)] @@ -93,7 +93,7 @@ ("lux text clip" post_offset post_limit current) post_limit])) -(def: (unicode_escaped char pre_offset pre_limit previous current) +(def (unicode_escaped char pre_offset pre_limit previous current) (-> Char Nat Nat Text Text [Text Text Nat]) (let [code (at n.hex encoded char) replacement (format ..sigil "u" @@ -110,7 +110,7 @@ ("lux text clip" post_offset post_limit current) post_limit])) -(def: .public (escaped text) +(def .public (escaped text) (-> Text Text) (loop (again [offset 0 previous "" @@ -160,16 +160,16 @@ "In" (%.text text) "At" (%.nat offset))) -(def: code_size +(def code_size 4) -(def: ascii_escape_offset +(def ascii_escape_offset 2) -(def: unicode_escape_offset +(def unicode_escape_offset (n.+ ..ascii_escape_offset ..code_size)) -(def: (ascii_un_escaped replacement offset previous current limit) +(def (ascii_un_escaped replacement offset previous current limit) (-> Text Nat Text Text Nat [Text Text Nat]) (let [limit' (|> limit (n.- offset) (n.- ..ascii_escape_offset))] [(format previous @@ -178,7 +178,7 @@ ("lux text clip" (n.+ ..ascii_escape_offset offset) limit' current) limit'])) -(def: (unicode_un_escaped offset previous current limit) +(def (unicode_un_escaped offset previous current limit) (-> Nat Text Text Nat (Try [Text Text Nat])) (case (|> current ("lux text clip" (n.+ ..ascii_escape_offset offset) ..code_size) @@ -194,7 +194,7 @@ {try.#Failure error} (exception.except ..invalid_unicode_escape [current offset]))) -(def: .public (un_escaped text) +(def .public (un_escaped text) (-> Text (Try Text)) (loop (again [offset 0 previous "" @@ -239,7 +239,7 @@ "" current _ (format previous current))}))) -(def: .public literal +(def .public literal (syntax (_ [literal <code>.text]) (case (..un_escaped literal) {try.#Success un_escaped} diff --git a/stdlib/source/library/lux/data/text/regex.lux b/stdlib/source/library/lux/data/text/regex.lux index 34ce70739..6648375ba 100644 --- a/stdlib/source/library/lux/data/text/regex.lux +++ b/stdlib/source/library/lux/data/text/regex.lux @@ -26,11 +26,11 @@ ["[0]" // (.only) ["%" \\format (.only format)]]) -(def: regex_char^ +(def regex_char^ (Parser Text) (<text>.none_of "\.|&()[]{}")) -(def: escaped_char^ +(def escaped_char^ (Parser Text) (do <>.monad [? (<>.parses? (<text>.this "\"))] @@ -38,31 +38,31 @@ <text>.any regex_char^))) -(def: (refine^ refinement^ base^) +(def (refine^ refinement^ base^) (All (_ a) (-> (Parser a) (Parser Text) (Parser Text))) (do <>.monad [output base^ _ (<text>.local output refinement^)] (in output))) -(def: word^ +(def word^ (Parser Text) (<>.either <text>.alpha_num (<text>.one_of "_"))) -(def: (copy reference) +(def (copy reference) (-> Text (Parser Text)) (<>.after (<text>.this reference) (<>#in reference))) -(def: together^ +(def together^ (-> (Parser (List Text)) (Parser Text)) (at <>.monad each //.together)) -(def: symbol_char^ +(def symbol_char^ (Parser Text) (<text>.none_of (format "[]{}()s.<>" //.double_quote))) -(def: symbol_part^ +(def symbol_part^ (Parser Text) (do <>.monad [head (refine^ (<text>.not <text>.decimal) @@ -70,7 +70,7 @@ tail (<text>.some symbol_char^)] (in (format head tail)))) -(def: (symbol^ current_module) +(def (symbol^ current_module) (-> Text (Parser Symbol)) (all <>.either (<>.and (<>#in current_module) (<>.after (<text>.this "..") symbol_part^)) @@ -78,13 +78,13 @@ (<>.and (<>#in .prelude) (<>.after (<text>.this ".") symbol_part^)) (<>.and (<>#in "") symbol_part^))) -(def: (re_var^ current_module) +(def (re_var^ current_module) (-> Text (Parser Code)) (do <>.monad [symbol (<text>.enclosed ["\@<" ">"] (symbol^ current_module))] (in (` (is ((~! <text>.Parser) Text) (~ (code.symbol symbol))))))) -(def: re_range^ +(def re_range^ (Parser Code) (do [! <>.monad] [from (|> regex_char^ (at ! each (|>> (//.char 0) maybe.trusted))) @@ -92,19 +92,19 @@ to (|> regex_char^ (at ! each (|>> (//.char 0) maybe.trusted)))] (in (` ((~! <text>.range) (~ (code.nat from)) (~ (code.nat to))))))) -(def: re_char^ +(def re_char^ (Parser Code) (do <>.monad [char escaped_char^] (in (` ((~! ..copy) (~ (code.text char))))))) -(def: re_options^ +(def re_options^ (Parser Code) (do <>.monad [options (<text>.many escaped_char^)] (in (` ((~! <text>.one_of) (~ (code.text options))))))) -(def: re_user_class^' +(def re_user_class^' (Parser Code) (do <>.monad [negate? (<>.maybe (<text>.this "^")) @@ -115,7 +115,7 @@ {.#Some _} (` ((~! <text>.not) (all ((~! <>.either)) (~+ parts)))) {.#None} (` (all ((~! <>.either)) (~+ parts))))))) -(def: re_user_class^ +(def re_user_class^ (Parser Code) (do <>.monad [init ..re_user_class^' @@ -127,34 +127,34 @@ init rest)))) -(def: blank^ +(def blank^ (Parser Text) (<text>.one_of (format " " //.tab))) -(def: ascii^ +(def ascii^ (Parser Text) (<text>.range (hex "0") (hex "7F"))) -(def: control^ +(def control^ (Parser Text) (<>.either (<text>.range (hex "0") (hex "1F")) (<text>.one_of (//.of_char (hex "7F"))))) -(def: punct^ +(def punct^ (Parser Text) (<text>.one_of (format "!#$%&'()*+,-./:;<=>?@[\]^_`{|}~" //.double_quote))) -(def: graph^ +(def graph^ (Parser Text) (<>.either punct^ <text>.alpha_num)) -(def: print^ +(def print^ (Parser Text) (<>.either graph^ (<text>.one_of (//.of_char (hex "20"))))) -(def: re_system_class^ +(def re_system_class^ (Parser Code) (do <>.monad [] @@ -183,17 +183,17 @@ (<>.after (<text>.this "\p{Print}") (in (` (~! print^)))) ))) -(def: re_class^ +(def re_class^ (Parser Code) (<>.either re_system_class^ (<text>.enclosed ["[" "]"] re_user_class^))) -(def: number^ +(def number^ (Parser Nat) (|> (<text>.many <text>.decimal) (<>.codec n.decimal))) -(def: re_back_reference^ +(def re_back_reference^ (Parser Code) (<>.either (do <>.monad [_ (<text>.this "\") @@ -205,7 +205,7 @@ _ (<text>.this ">")] (in (` ((~! ..copy) (~ (code.symbol ["" captured_symbol])))))))) -(def: (re_simple^ current_module) +(def (re_simple^ current_module) (-> Text (Parser Code)) (all <>.either re_class^ @@ -214,7 +214,7 @@ re_char^ )) -(def: (re_simple_quantified^ current_module) +(def (re_simple_quantified^ current_module) (-> Text (Parser Code)) (do <>.monad [base (re_simple^ current_module) @@ -237,7 +237,7 @@ "Input" (format (%.nat from) "," (%.nat to)) "Should be" (format (%.nat to) "," (%.nat from)))) -(def: (re_counted_quantified^ current_module) +(def (re_counted_quantified^ current_module) (-> Text (Parser Code)) (do [! <>.monad] [base (re_simple^ current_module)] @@ -261,12 +261,12 @@ [limit number^] (in (` ((~! together^) ((~! <>.exactly) (~ (code.nat limit)) (~ base)))))))))) -(def: (re_quantified^ current_module) +(def (re_quantified^ current_module) (-> Text (Parser Code)) (<>.either (re_simple_quantified^ current_module) (re_counted_quantified^ current_module))) -(def: (re_complex^ current_module) +(def (re_complex^ current_module) (-> Text (Parser Code)) (all <>.either (re_quantified^ current_module) @@ -277,7 +277,7 @@ {#Non_Capturing} {#Capturing [(Maybe Text) Nat]})) -(def: (re_sequential^ capturing? re_scoped^ current_module) +(def (re_sequential^ capturing? re_scoped^ current_module) (-> Bit (-> Text (Parser [Re_Group Code])) Text @@ -329,11 +329,11 @@ ((~ (' in)) [(~ g!total) (~+ (list.reversed names))])))]) )) -(def: (unflatten^ lexer) +(def (unflatten^ lexer) (-> (Parser Text) (Parser [Text Any])) (<>.and lexer (at <>.monad in []))) -(def: (|||^ left right) +(def (|||^ left right) (All (_ l r) (-> (Parser [Text l]) (Parser [Text r]) (Parser [Text (Or l r)]))) (function (_ input) (case (left input) @@ -348,7 +348,7 @@ {try.#Failure error} {try.#Failure error})))) -(def: (|||_^ left right) +(def (|||_^ left right) (All (_ l r) (-> (Parser [Text l]) (Parser [Text r]) (Parser Text))) (function (_ input) (case (left input) @@ -363,13 +363,13 @@ {try.#Failure error} {try.#Failure error})))) -(def: (prep_alternative [num_captures alt]) +(def (prep_alternative [num_captures alt]) (-> [Nat Code] Code) (if (n.> 0 num_captures) alt (` ((~! unflatten^) (~ alt))))) -(def: (re_alternative^ capturing? re_scoped^ current_module) +(def (re_alternative^ capturing? re_scoped^ current_module) (-> Bit (-> Text (Parser [Re_Group Code])) Text @@ -387,7 +387,7 @@ (~ (prep_alternative head)) (~+ (list#each prep_alternative tail))))])))) -(def: (re_scoped^ current_module) +(def (re_scoped^ current_module) (-> Text (Parser [Re_Group Code])) (all <>.either (do <>.monad @@ -411,11 +411,11 @@ _ (<text>.this ")")] (in [{#Capturing [{.#None} num_captures]} pattern])))) -(def: (regex^ current_module) +(def (regex^ current_module) (-> Text (Parser Code)) (at <>.monad each product.right (re_alternative^ #1 re_scoped^ current_module))) -(def: .public regex +(def .public regex (syntax (_ [pattern <code>.text]) (do meta.monad [current_module meta.current_module_name] @@ -428,7 +428,7 @@ {try.#Success regex} (in (list regex)))))) -(def: .public pattern +(def .public pattern (syntax (_ [[pattern bindings] (<code>.form (<>.and <code>.text (<>.maybe <code>.any))) body <code>.any branches (<>.many <code>.any)]) diff --git a/stdlib/source/library/lux/data/text/unicode/block.lux b/stdlib/source/library/lux/data/text/unicode/block.lux index 7f3eeb32d..db55002a9 100644 --- a/stdlib/source/library/lux/data/text/unicode/block.lux +++ b/stdlib/source/library/lux/data/text/unicode/block.lux @@ -17,14 +17,14 @@ (primitive .public Block (Interval Char) - (def: .public monoid + (def .public monoid (Monoid Block) (implementation - (def: identity + (def identity (abstraction (interval.between n.enum n#top n#bottom))) - (def: (composite left right) + (def (composite left right) (let [left (representation left) right (representation right)] (abstraction @@ -34,12 +34,12 @@ (n.max (at left top) (at right top)))))))) - (def: .public (block start additional) + (def .public (block start additional) (-> Char Nat Block) (abstraction (interval.between n.enum start (n.+ additional start)))) (with_template [<name> <slot>] - [(def: .public <name> + [(def .public <name> (-> Block Char) (|>> representation (the <slot>)))] @@ -47,34 +47,34 @@ [end interval.top] ) - (def: .public (size block) + (def .public (size block) (-> Block Nat) (let [start (the interval.bottom (representation block)) end (the interval.top (representation block))] (|> end (n.- start) ++))) - (def: .public (within? block char) + (def .public (within? block char) (All (_ a) (-> Block Char Bit)) (interval.within? (representation block) char)) ) -(def: .public equivalence +(def .public equivalence (Equivalence Block) (implementation - (def: (= reference subject) + (def (= reference subject) (and (n.= (..start reference) (..start subject)) (n.= (..end reference) (..end subject)))))) -(def: .public hash +(def .public hash (Hash Block) (implementation - (def: equivalence ..equivalence) - (def: (hash value) + (def equivalence ..equivalence) + (def (hash value) (i64.or (i64.left_shifted 32 (..start value)) (..end value))))) (with_template [<start> <end> <name>] - [(def: .public <name> + [(def .public <name> Block (let [start (hex <start>) end (hex <end>)] diff --git a/stdlib/source/library/lux/data/text/unicode/set.lux b/stdlib/source/library/lux/data/text/unicode/set.lux index 287c78ca0..1abe5427f 100644 --- a/stdlib/source/library/lux/data/text/unicode/set.lux +++ b/stdlib/source/library/lux/data/text/unicode/set.lux @@ -16,10 +16,10 @@ [// (.only Char)] ["[1][0]" block (.only Block)]]]) -(def: builder +(def builder (tree.builder //block.monoid)) -(def: :@: +(def :@: (by_example [@] (is (tree.Builder @ Block) ..builder) @@ -29,19 +29,19 @@ (primitive .public Set (Tree :@: Block []) - (def: .public (composite left right) + (def .public (composite left right) (-> Set Set Set) (abstraction (at builder branch (representation left) (representation right)))) - (def: (singleton block) + (def (singleton block) (-> Block Set) (abstraction (at builder leaf block []))) - (def: .public (set [head tail]) + (def .public (set [head tail]) (-> [Block (List Block)] Set) (list#mix (is (-> Block Set Set) (function (_ block set) @@ -49,7 +49,7 @@ (..singleton head) tail)) - (def: character/0 + (def character/0 Set (..set [//block.basic_latin (list //block.latin_1_supplement @@ -82,7 +82,7 @@ //block.myanmar //block.georgian)])) - (def: character/1 + (def character/1 Set (..set [//block.hangul_jamo (list //block.ethiopic @@ -116,7 +116,7 @@ //block.enclosed_alphanumerics //block.box_drawing)])) - (def: character/2 + (def character/2 Set (..set [//block.block_elements (list //block.geometric_shapes @@ -150,7 +150,7 @@ //block.hangul_syllables )])) - (def: .public character + (def .public character Set (all ..composite ..character/0 @@ -158,7 +158,7 @@ ..character/2 )) - (def: .public non_character + (def .public non_character Set (..set [//block.high_surrogates (list //block.high_private_use_surrogates @@ -193,26 +193,26 @@ ... //block.tags )])) - (def: .public full + (def .public full Set (all ..composite ..character ..non_character )) - (def: .public start + (def .public start (-> Set Char) (|>> representation tree.tag //block.start)) - (def: .public end + (def .public end (-> Set Char) (|>> representation tree.tag //block.end)) - (def: .public (member? set character) + (def .public (member? set character) (-> Set Char Bit) (loop (again [tree (representation set)]) (if (//block.within? (tree.tag tree) character) @@ -225,16 +225,16 @@ (again right))) false))) - (def: .public equivalence + (def .public equivalence (Equivalence Set) (implementation - (def: (= reference subject) + (def (= reference subject) (set#= (set.of_list //block.hash (tree.tags (representation reference))) (set.of_list //block.hash (tree.tags (representation subject))))))) ) (with_template [<name> <blocks>] - [(def: .public <name> + [(def .public <name> Set (..set <blocks>))] diff --git a/stdlib/source/library/lux/data/trace.lux b/stdlib/source/library/lux/data/trace.lux index cc92f72ac..87032785f 100644 --- a/stdlib/source/library/lux/data/trace.lux +++ b/stdlib/source/library/lux/data/trace.lux @@ -12,22 +12,22 @@ [#monoid (Monoid t) #trace (-> t a)])) -(def: .public functor +(def .public functor (All (_ t) (Functor (Trace t))) (implementation - (def: (each f fa) + (def (each f fa) (revised #trace (composite f) fa)))) -(def: .public comonad +(def .public comonad (All (_ t) (CoMonad (Trace t))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (out wa) + (def (out wa) ((the #trace wa) (the [#monoid monoid.#identity] wa))) - (def: (disjoint wa) + (def (disjoint wa) (let [monoid (the #monoid wa)] [#monoid monoid #trace (function (_ t1) @@ -36,6 +36,6 @@ ((the #trace wa) (at monoid composite t1 t2)))])])))) -(def: .public (result context tracer) +(def .public (result context tracer) (All (_ t a) (-> t (Trace t a) a)) (at tracer trace context)) diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index 5aa890145..a4cbd9b25 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -119,10 +119,10 @@ (import (format [Text .Any] Text))) )) -(def: Inspector +(def Inspector (.type (Format Any))) -(for @.lua (def: (tuple_array tuple) +(for @.lua (def (tuple_array tuple) (-> (array.Array Any) (array.Array Any)) (array.of_list (loop (again [idx 0]) @@ -132,7 +132,7 @@ {.#Item member (again (++ idx))}))))) (these)) -(def: (tuple_inspection inspection) +(def (tuple_inspection inspection) (-> Inspector Inspector) (with_expansions [<adaption> (for @.lua (~~ (these ..tuple_array)) (~~ (these)))] @@ -143,7 +143,7 @@ (text.interposed " ") (text.enclosed ["[" "]"]))))) -(def: .public (inspection value) +(def .public (inspection value) Inspector (with_expansions [<jvm> (let [object (as java/lang/Object value)] (`` (<| (~~ (with_template [<class> <processing>] @@ -387,7 +387,7 @@ (type: Representation (-> Any Text)) -(def: primitive_representation +(def primitive_representation (Parser Representation) (`` (all <>.either (do <>.monad @@ -407,7 +407,7 @@ [Text %.text])) ))) -(def: (special_representation representation) +(def (special_representation representation) (-> (Parser Representation) (Parser Representation)) (`` (all <>.either (~~ (with_template [<type> <formatter>] @@ -442,7 +442,7 @@ (in (|>> (as (Maybe Any)) (%.maybe elemR))))))) -(def: (variant_representation representation) +(def (variant_representation representation) (-> (Parser Representation) (Parser Representation)) (do <>.monad [membersR+ (<type>.variant (<>.many representation))] @@ -468,7 +468,7 @@ (undefined)))] (%.format "{" (%.nat lefts) " " (%.bit right?) " " sub_repr "}")))))) -(def: (tuple_representation representation) +(def (tuple_representation representation) (-> (Parser Representation) (Parser Representation)) (do <>.monad [membersR+ (<type>.tuple (<>.many representation))] @@ -487,7 +487,7 @@ (%.format (headR leftV) " " (again tailR rightV)))))] (%.format "[" tuple_body "]")))))) -(def: representation_parser +(def representation_parser (Parser Representation) (<>.rec (function (_ representation) @@ -513,7 +513,7 @@ (<>.failure "") )))) -(def: .public (representation type value) +(def .public (representation type value) (-> Type Any (Try Text)) (case (<type>.result ..representation_parser type) {try.#Success representation} @@ -522,14 +522,14 @@ {try.#Failure _} (exception.except ..cannot_represent_value type))) -(def: .public private +(def .public private (syntax (_ [definition <code>.symbol]) (let [[module _] definition] (in (list (` ("lux in-module" (~ (code.text module)) (~ (code.symbol definition))))))))) -(def: .public (log! message) +(def .public (log! message) (-> Text Any) ("lux io log" message)) @@ -539,7 +539,7 @@ "Location" (%.location location) "Type" (%.type type))) -(def: .public hole +(def .public hole (syntax (_ []) (do meta.monad [location meta.location @@ -549,7 +549,7 @@ (type: Target [Text (Maybe Code)]) -(def: target +(def target (<code>.Parser Target) (<>.either (<>.and <code>.local (at <>.monad in {.#None})) @@ -560,7 +560,7 @@ (exception.report "Name" (%.text name))) -(def: .public here +(def .public here (syntax (_ [targets (is (<code>.Parser (List Target)) (|> ..target <>.some diff --git a/stdlib/source/library/lux/documentation.lux b/stdlib/source/library/lux/documentation.lux index abe8d3ff3..3c5ad2e10 100644 --- a/stdlib/source/library/lux/documentation.lux +++ b/stdlib/source/library/lux/documentation.lux @@ -35,7 +35,7 @@ [lux ["[0]" syntax]]]]]]]) -(def: |recursion_dummy| +(def |recursion_dummy| (template (_) [{.#Primitive "" {.#End}}])) @@ -44,12 +44,12 @@ {#Comment Text} {#Code Code})) -(def: fragment +(def fragment (Parser Fragment) (<>.or <code>.text <code>.any)) -(def: (reference_column code) +(def (reference_column code) (-> Code Nat) (case code (^.with_template [<tag>] @@ -73,7 +73,7 @@ [.#Tuple]) )) -(def: (padding reference_column [_ old_line old_column] [_ new_line new_column]) +(def (padding reference_column [_ old_line old_column] [_ new_line new_column]) (-> Nat Location Location Text) (if (n.= old_line new_line) (if (n.< old_column new_column) @@ -86,7 +86,7 @@ "" (text.together (list.repeated (n.- reference_column new_column) " ")))))) -(def: (code_documentation expected_module old_location reference_column example) +(def (code_documentation expected_module old_location reference_column example) (-> Text Location Nat Code [Location Text]) (case example [new_location {.#Symbol [module short]}] @@ -130,15 +130,15 @@ [syntax.open_tuple syntax.close_tuple .#Tuple]) )) -(def: blank_line +(def blank_line Text (format \n \n)) -(def: single_line_comment +(def single_line_comment (-> Text Text) (text.prefix "... ")) -(def: (fragment_documentation module fragment) +(def (fragment_documentation module fragment) (-> Text Fragment Text) (case fragment {#Comment comment} @@ -151,10 +151,10 @@ (..code_documentation module (has .#column reference_column location) reference_column) product.right)))) -(def: parameter_name_options "abcdefghijklmnopqrstuvwxyz") -(def: parameter_name_options_count (text.size parameter_name_options)) +(def parameter_name_options "abcdefghijklmnopqrstuvwxyz") +(def parameter_name_options_count (text.size parameter_name_options)) -(def: (parameter_type_name id) +(def (parameter_type_name id) (-> Nat Text) (format "_" (%.nat id)) ... (case (text.char id ..parameter_name_options) @@ -166,13 +166,13 @@ ... (parameter_type_name (n.% parameter_name_options_count id)))) ) -(def: type_variable_names +(def type_variable_names (Stream Text) (stream.iterations (product.forked ++ parameter_type_name) 0)) (with_template [<name> <partition>] - [(def: (<name> id) + [(def (<name> id) (-> Nat Bit) (<partition> id))] @@ -180,11 +180,11 @@ [type_parameter? n.odd?] ) -(def: (parameter_id level id) +(def (parameter_id level id) (-> Nat Nat Nat) (n.- (n./ 2 id) level)) -(def: (parameter_name [type_function_name type_function_arguments] level id) +(def (parameter_name [type_function_name type_function_arguments] level id) (-> [Text (List Text)] Nat Nat Text) (if (type_parameter? id) (let [parameter_id (..parameter_id level id)] @@ -200,7 +200,7 @@ (stream.item parameter_id))))) type_function_name)) -(def: (level_parameters offset level) +(def (level_parameters offset level) (-> Nat Nat (List Text)) (if (n.= 0 level) (list) @@ -209,14 +209,14 @@ (enum.range n.enum 0) (list#each (|>> (n.+ (++ offset)) parameter_type_name))))) -(def: (nested line_prefix body) +(def (nested line_prefix body) (-> Text Text Text) (|> body (text.all_split_by \n) (list#each (text.prefix line_prefix)) (text.interposed \n))) -(def: (%type' level type_function_name nestable? module type) +(def (%type' level type_function_name nestable? module type) (-> Nat Text Bit Text Type Text) (case type {.#Primitive name params} @@ -298,11 +298,11 @@ (%.symbol [_module _name])) )) -(def: type +(def type (-> Text Type Text) (%type' (-- 0) "?" true)) -(def: (parameterized_type arity type) +(def (parameterized_type arity type) (-> Nat Type (Maybe Type)) (case arity 0 {.#Some type} @@ -313,7 +313,7 @@ _ {.#None}))) -(def: (type_definition' nestable? level arity type_function_info tags module type) +(def (type_definition' nestable? level arity type_function_info tags module type) (-> Bit Nat Nat [Text (List Text)] (List Text) Text Type Text) (case tags (pattern (list single_tag)) @@ -436,7 +436,7 @@ (%.symbol [_module _name])) ))) -(def: (type_definition module [name parameters] tags type) +(def (type_definition module [name parameters] tags type) (-> Text [Text (List Text)] (List Text) Type Text) (let [arity (list.size parameters)] (case (parameterized_type arity type) @@ -446,7 +446,7 @@ {.#None} (..type module type)))) -(def: description +(def description (Parser (Maybe Code)) (<>.or (<code>.this_text "") <code>.any)) @@ -455,7 +455,7 @@ (exception.report "Name" (%.symbol name))) -(def: qualified_symbol +(def qualified_symbol (Parser Symbol) (do <>.monad [name <code>.symbol] @@ -466,7 +466,7 @@ _ (in name)))) -(def: example_separator +(def example_separator Code (let [c/01 "...." c/04 (format c/01 c/01 c/01 c/01) @@ -478,11 +478,11 @@ (type: Example (List Fragment)) -(def: example +(def example (Parser Example) (<code>.tuple (<>.many ..fragment))) -(def: (example_documentation module example) +(def (example_documentation module example) (-> Text Example Code) (|> example (list#each (..fragment_documentation module)) @@ -493,13 +493,13 @@ (type: Declaration [Symbol (List Text)]) -(def: declaration +(def declaration (Parser Declaration) (<>.either (<>.and ..qualified_symbol (<>#in (list))) (<code>.form (<>.and ..qualified_symbol (<>.some (<code>.local)))))) -(def: minimal_definition_documentation +(def minimal_definition_documentation (syntax (_ [[name parameters] ..declaration]) (do meta.monad [.let [g!module (code.text (product.left name))] @@ -538,7 +538,7 @@ (` ((~! ..type) (~ g!module) (~ g!type)))))))) )))))))) -(def: definition_documentation +(def definition_documentation (syntax (_ [[name parameters] ..declaration description ..description examples (<>.some ..example)]) @@ -581,7 +581,7 @@ #expected (Set Text) #definitions (List Definition)])) -(def: .public default +(def .public default (syntax (_ [[name parameters] ..declaration]) (macro.with_symbols [g!_] (let [[_ short] name] @@ -593,7 +593,7 @@ (~+ (list#each code.local parameters))))])))] ((~ g!_) []))))))))) -(def: .public documentation +(def .public documentation (syntax (_ [[name parameters] ..declaration extra (<>.some <code>.any)]) (macro.with_symbols [g!_] @@ -607,7 +607,7 @@ (~+ extra))])))] ((~ g!_) []))))))))) -(def: definitions_documentation +(def definitions_documentation (-> (List Definition) (Markdown Block)) (|>> (list.sorted (function (_ left right) (text#< (the #definition right) @@ -615,11 +615,11 @@ (list#each (the #documentation)) (list#mix md.then md.empty))) -(def: expected_separator +(def expected_separator Text (text.of_char 31)) -(def: expected_format +(def expected_format (-> (List Text) Text) (list#mix (function (_ short aggregate) (case aggregate @@ -627,12 +627,12 @@ _ (format aggregate ..expected_separator short))) "")) -(def: expected +(def expected (-> Text (Set Text)) (|>> (text.all_split_by ..expected_separator) (set.of_list text.hash))) -(def: .public module +(def .public module (syntax (_ [[name _] ..qualified_symbol description <code>.any definitions (<code>.tuple (<>.some <code>.any)) @@ -652,7 +652,7 @@ (at (~! list.monoid) (~' identity))) (~+ subs)))))))))) -(def: listing +(def listing (-> (List Text) (Markdown Block)) (|>> (list.sorted text#<) (list#each (function (_ definition) @@ -660,7 +660,7 @@ {.#None}])) md.numbered_list)) -(def: (module_documentation module) +(def (module_documentation module) (-> Module (Markdown Block)) (let [(open "_[0]") module] (all md.then @@ -709,7 +709,7 @@ (..listing un_expected))) ))) -(def: .public markdown +(def .public markdown (-> (List Module) Text) (|>> (list.sorted (function (_ left right) (text#< (the #module right) (the #module left)))) diff --git a/stdlib/source/library/lux/extension.lux b/stdlib/source/library/lux/extension.lux index 424cfcba8..1cbaf8642 100644 --- a/stdlib/source/library/lux/extension.lux +++ b/stdlib/source/library/lux/extension.lux @@ -31,7 +31,7 @@ #archive Text #inputs (List Code)])) -(def: (declaration default) +(def (declaration default) (-> Code (Parser Declaration)) (<c>.form (all <>.and <c>.any @@ -41,7 +41,7 @@ (<c>.tuple (<>.some <c>.any))))) (with_template [<any> <end> <and> <result> <extension> <name>] - [(def: .public <name> + [(def .public <name> (syntax (_ [[name extension phase archive inputs] (..declaration (` <any>)) body <c>.any]) (let [g!name (code.local extension) diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux index 9fc79a2d9..49042f104 100644 --- a/stdlib/source/library/lux/ffi.jvm.lux +++ b/stdlib/source/library/lux/ffi.jvm.lux @@ -39,23 +39,23 @@ ["[0]" type (.open: "[1]#[0]" equivalence) ["[0]" check]]]]) -(def: internal +(def internal (-> External Text) (|>> name.internal name.read)) -(def: signature +(def signature (All (_ category) (-> (Type category) Text)) (|>> jvm.signature signature.signature)) -(def: reflection +(def reflection (All (_ category) (-> (Type (<| Return' Value' category)) Text)) (|>> jvm.reflection reflection.reflection)) (with_template [<name> <class>] - [(`` (def: .public <name> + [(`` (def .public <name> .Type {.#Primitive <class> {.#End}}))] @@ -71,7 +71,7 @@ ) (with_template [<name> <class>] - [(`` (def: .public <name> + [(`` (def .public <name> .Type {.#Primitive (reflection.reflection <class>) {.#End}}))] @@ -86,20 +86,20 @@ [char reflection.char] ) -(def: (get_static_field class field) +(def (get_static_field class field) (-> Text Text Code) (` ("jvm member get static" (~ (code.text class)) (~ (code.text field))))) -(def: (get_virtual_field class field object) +(def (get_virtual_field class field object) (-> Text Text Code Code) (` ("jvm member get virtual" (~ (code.text class)) (~ (code.text field)) (~ object)))) -(def: boxes +(def boxes (Dictionary (Type Value) Text) (|> (list [jvm.boolean box.boolean] [jvm.byte box.byte] @@ -112,7 +112,7 @@ (dictionary.of_list jvm.hash))) (with_template [<name> <pre> <post>] - [(def: (<name> unboxed boxed raw) + [(def (<name> unboxed boxed raw) (-> (Type Value) Text Code Code) (let [unboxed (..reflection unboxed)] (` (|> (~ raw) @@ -125,7 +125,7 @@ ) (with_template [<name> <op> <from> <to>] - [(def: .public <name> + [(def .public <name> (template (<name> value) [(|> value (.is <from>) @@ -166,7 +166,7 @@ ) (with_template [<name> <from> <to> <0> <1>] - [(def: .public <name> + [(def .public <name> (template (<name> value) [(|> value <0> <1>)]))] @@ -177,7 +177,7 @@ [short_to_char ..Short ..Character ..short_to_int ..int_to_char] ) -(def: constructor_method_name +(def constructor_method_name "<init>") (type: Primitive_Mode @@ -327,7 +327,7 @@ {#MethodDecl [ImportMethodCommons ImportMethodDecl]} {#FieldAccessDecl ImportFieldDecl})) -(def: (primitive_type mode type) +(def (primitive_type mode type) (-> Primitive_Mode (Type Primitive) Code) (case mode {#ManualPrM} @@ -362,7 +362,7 @@ ... else (undefined)))) -(def: (parameter_type value_type type) +(def (parameter_type value_type type) (-> (-> (Type Value) Code) (-> (Type Parameter) Code)) (`` (<| (~~ (with_template [<when> <binding> <then>] @@ -390,7 +390,7 @@ (undefined) ))) -(def: (value_type mode type) +(def (value_type mode type) (-> Primitive_Mode (Type Value) Code) (`` (<| (~~ (with_template [<when> <binding> <then>] [(case (<when> type) @@ -404,25 +404,25 @@ (undefined) ))) -(def: declaration_type$ +(def declaration_type$ (-> (Type Declaration) Code) (|>> ..signature code.text)) -(def: (get_const_parser class_name field_name) +(def (get_const_parser class_name field_name) (-> Text Text (Parser Code)) (do <>.monad [.let [dotted_name (format "::" field_name)] _ (<code>.this (code.symbol ["" dotted_name]))] (in (get_static_field class_name field_name)))) -(def: (get_var_parser class_name field_name self_name) +(def (get_var_parser class_name field_name self_name) (-> Text Text Text (Parser Code)) (do <>.monad [.let [dotted_name (format "::" field_name)] _ (<code>.this (code.symbol ["" dotted_name]))] (in (get_virtual_field class_name field_name (code.local self_name))))) -(def: (put_var_parser class_name field_name self_name) +(def (put_var_parser class_name field_name self_name) (-> Text Text Text (Parser Code)) (do <>.monad [.let [dotted_name (format "::" field_name)] @@ -434,7 +434,7 @@ (~ value) (~ (code.local self_name))))))) -(def: (replaced f input) +(def (replaced f input) (-> (-> Code Code) Code Code) (case (f input) (^.with_template [<tag>] @@ -447,7 +447,7 @@ ast' ast')) -(def: (parser->replacer p ast) +(def (parser->replacer p ast) (-> (Parser Code) (-> Code Code)) (case (<>.result p (list ast)) {.#Right [{.#End} ast']} @@ -457,7 +457,7 @@ ast )) -(def: (field->parser class_name self_name [[field_name _ _] field]) +(def (field->parser class_name self_name [[field_name _ _] field]) (-> Text Text [Member_Declaration FieldDecl] (Parser Code)) (case field {#ConstantField _} @@ -467,11 +467,11 @@ (<>.either (get_var_parser class_name field_name self_name) (put_var_parser class_name field_name self_name)))) -(def: (decorate_input [class value]) +(def (decorate_input [class value]) (-> [(Type Value) Code] Code) (` [(~ (code.text (..signature class))) (~ value)])) -(def: (constructor_parser class_name arguments) +(def (constructor_parser class_name arguments) (-> Text (List Argument) (Parser Code)) (do <>.monad [args (.is (Parser (List Code)) @@ -482,7 +482,7 @@ (list.zipped_2 (list#each product.right arguments)) (list#each ..decorate_input)))))))) -(def: (static_method_parser class_name method_name arguments) +(def (static_method_parser class_name method_name arguments) (-> Text Text (List Argument) (Parser Code)) (do <>.monad [.let [dotted_name (format "::" method_name "!")] @@ -495,7 +495,7 @@ (list#each ..decorate_input)))))))) (with_template [<name> <jvm_op>] - [(def: (<name> class_vars class_name type_vars method_name arguments self_name) + [(def (<name> class_vars class_name type_vars method_name arguments self_name) (-> (List (Type Var)) Text (List (Type Var)) Text (List Argument) Text (Parser Code)) (do <>.monad [.let [dotted_name (format "::" method_name "!")] @@ -514,7 +514,7 @@ [virtual_method_parser "jvm member invoke virtual"] ) -(def: (method->parser class_vars class_name [[method_name _ _] meth_def]) +(def (method->parser class_vars class_name [[method_name _ _] meth_def]) (-> (List (Type Var)) Text [Member_Declaration Method_Definition] (Parser Code)) (case meth_def {#ConstructorMethod strict? type_vars self_name args constructor_args return_expr exs} @@ -535,7 +535,7 @@ {#NativeMethod type_vars args return_type exs} (virtual_method_parser class_vars class_name type_vars method_name args ""))) -(def: privacy_modifier^ +(def privacy_modifier^ (Parser Privacy) (let [(open "[0]") <>.monad] (all <>.or @@ -544,7 +544,7 @@ (<code>.this (' "protected")) (in [])))) -(def: inheritance_modifier^ +(def inheritance_modifier^ (Parser Inheritance) (let [(open "[0]") <>.monad] (all <>.or @@ -562,12 +562,12 @@ "Name" (%.text name) "Type Variables" (exception.listing parser.name type_vars))) -(def: (assertion exception payload test) +(def (assertion exception payload test) (All (_ e) (-> (Exception e) e Bit (Parser Any))) (<>.assertion (exception.error exception payload) test)) -(def: (valid_class_name type_vars) +(def (valid_class_name type_vars) (-> (List (Type Var)) (Parser External)) (do <>.monad [name <code>.local @@ -579,7 +579,7 @@ name)))] (in name))) -(def: (class^' parameter^ type_vars) +(def (class^' parameter^ type_vars) (-> (-> (List (Type Var)) (Parser (Type Parameter))) (-> (List (Type Var)) (Parser (Type Class)))) (do <>.monad @@ -596,7 +596,7 @@ "Unexpected Type Variable" (%.text name) "Expected Type Variables" (exception.listing parser.name type_vars))) -(def: (type_variable options) +(def (type_variable options) (-> (List (Type Var)) (Parser (Type Parameter))) (do <>.monad [name <code>.local @@ -604,14 +604,14 @@ (list.member? text.equivalence (list#each parser.name options) name))] (in (jvm.var name)))) -(def: wildcard^ +(def wildcard^ (Parser (Type Parameter)) (do <>.monad [_ (<code>.this (' ?))] (in jvm.wildcard))) (with_template [<name> <comparison> <constructor>] - [(def: <name> + [(def <name> (-> (Parser (Type Class)) (Parser (Type Parameter))) (|>> (<>.after (<code>.this (' <comparison>))) (<>.after ..wildcard^) @@ -622,7 +622,7 @@ [lower^ > jvm.lower] ) -(def: (parameter^ type_vars) +(def (parameter^ type_vars) (-> (List (Type Var)) (Parser (Type Parameter))) (<>.rec (function (_ _) @@ -635,7 +635,7 @@ class^ ))))) -(def: (itself^ type) +(def (itself^ type) (All (_ category) (-> (Type (<| Return' Value' category)) (Parser (Type (<| Return' Value' category))))) @@ -643,7 +643,7 @@ [_ (<code>.this_symbol ["" (..reflection type)])] (in type))) -(def: primitive^ +(def primitive^ (Parser (Type Primitive)) (all <>.either (itself^ jvm.boolean) @@ -656,12 +656,12 @@ (itself^ jvm.char) )) -(def: array^ +(def array^ (-> (Parser (Type Value)) (Parser (Type Array))) (|>> <code>.tuple (at <>.monad each jvm.array))) -(def: (type^ type_vars) +(def (type^ type_vars) (-> (List (Type Var)) (Parser (Type Value))) (<>.rec (function (_ type^) @@ -671,26 +671,26 @@ (..array^ type^) )))) -(def: void^ +(def void^ (Parser (Type Void)) (do <>.monad [_ (<code>.this_symbol ["" (reflection.reflection reflection.void)])] (in jvm.void))) -(def: (return^ type_vars) +(def (return^ type_vars) (-> (List (Type Var)) (Parser (Type Return))) (<>.either ..void^ (..type^ type_vars))) -(def: var^ +(def var^ (Parser (Type Var)) (at <>.monad each jvm.var <code>.local)) -(def: vars^ +(def vars^ (Parser (List (Type Var))) (<code>.tuple (<>.some var^))) -(def: declaration^ +(def declaration^ (Parser (Type Declaration)) (do <>.monad [[name variables] (.is (Parser [External (List (Type Var))]) @@ -701,15 +701,15 @@ ))] (in (jvm.declaration name variables)))) -(def: (class^ type_vars) +(def (class^ type_vars) (-> (List (Type Var)) (Parser (Type Class))) (class^' parameter^ type_vars)) -(def: annotation_parameters^ +(def annotation_parameters^ (Parser (List Annotation_Parameter)) (<code>.tuple (<>.some (<>.and <code>.text <code>.any)))) -(def: annotation^ +(def annotation^ (Parser Annotation) (<>.either (do <>.monad [ann_name <code>.local] @@ -717,21 +717,21 @@ (<code>.form (<>.and <code>.local annotation_parameters^)))) -(def: annotations^ +(def annotations^ (Parser (List Annotation)) (<| (<>.else (list)) (do <>.monad [_ (<code>.this (' "ann"))] (<code>.tuple (<>.some ..annotation^))))) -(def: (throws_decl^ type_vars) +(def (throws_decl^ type_vars) (-> (List (Type Var)) (Parser (List (Type Class)))) (<| (<>.else (list)) (do <>.monad [_ (<code>.this (' "throws"))] (<code>.tuple (<>.some (..class^ type_vars)))))) -(def: (method_decl^ type_vars) +(def (method_decl^ type_vars) (-> (List (Type Var)) (Parser [Member_Declaration MethodDecl])) (<code>.form (do <>.monad [tvars (<>.else (list) ..vars^) @@ -746,14 +746,14 @@ #method_output output #method_exs exs]])))) -(def: state_modifier^ +(def state_modifier^ (Parser State) (all <>.or (<code>.this (' "volatile")) (<code>.this (' "final")) (at <>.monad in []))) -(def: (field_decl^ type_vars) +(def (field_decl^ type_vars) (-> (List (Type Var)) (Parser [Member_Declaration FieldDecl])) (<>.either (<code>.form (do <>.monad [_ (<code>.this (' "const")) @@ -771,24 +771,24 @@ type (..type^ type_vars)] (in [[name pm anns] {#VariableField [sm static? type]}]))))) -(def: (argument^ type_vars) +(def (argument^ type_vars) (-> (List (Type Var)) (Parser Argument)) (<>.and <code>.local (..type^ type_vars))) -(def: (arguments^ type_vars) +(def (arguments^ type_vars) (-> (List (Type Var)) (Parser (List Argument))) (<code>.tuple (<>.some (..argument^ type_vars)))) -(def: (constructor_arg^ type_vars) +(def (constructor_arg^ type_vars) (-> (List (Type Var)) (Parser (Typed Code))) (<>.and (..type^ type_vars) <code>.any)) -(def: (constructor_args^ type_vars) +(def (constructor_args^ type_vars) (-> (List (Type Var)) (Parser (List (Typed Code)))) (<code>.tuple (<>.some (..constructor_arg^ type_vars)))) -(def: (constructor_method^ class_vars) +(def (constructor_method^ class_vars) (-> (List (Type Var)) (Parser [Member_Declaration Method_Definition])) (<code>.form (do <>.monad [pm privacy_modifier^ @@ -808,7 +808,7 @@ #member_anns annotations] {#ConstructorMethod strict_fp? method_vars self_name arguments constructor_args body exs}])))) -(def: (virtual_method_def^ class_vars) +(def (virtual_method_def^ class_vars) (-> (List (Type Var)) (Parser [Member_Declaration Method_Definition])) (<code>.form (do <>.monad [pm privacy_modifier^ @@ -829,7 +829,7 @@ #member_anns annotations] {#VirtualMethod final? strict_fp? method_vars self_name arguments return_type body exs}])))) -(def: overriden_method_def^ +(def overriden_method_def^ (Parser [Member_Declaration Method_Definition]) (<code>.form (do <>.monad [strict_fp? (<>.parses? (<code>.this (' "strict"))) @@ -850,7 +850,7 @@ #member_anns annotations] {#OverridenMethod strict_fp? owner_class method_vars self_name arguments return_type body exs}])))) -(def: static_method_def^ +(def static_method_def^ (Parser [Member_Declaration Method_Definition]) (<code>.form (do <>.monad [pm privacy_modifier^ @@ -869,7 +869,7 @@ #member_anns annotations] {#StaticMethod strict_fp? method_vars arguments return_type body exs}])))) -(def: abstract_method_def^ +(def abstract_method_def^ (Parser [Member_Declaration Method_Definition]) (<code>.form (do <>.monad [pm privacy_modifier^ @@ -886,7 +886,7 @@ #member_anns annotations] {#AbstractMethod method_vars arguments return_type exs}])))) -(def: native_method_def^ +(def native_method_def^ (Parser [Member_Declaration Method_Definition]) (<code>.form (do <>.monad [pm privacy_modifier^ @@ -903,7 +903,7 @@ #member_anns annotations] {#NativeMethod method_vars arguments return_type exs}])))) -(def: (method_def^ class_vars) +(def (method_def^ class_vars) (-> (List (Type Var)) (Parser [Member_Declaration Method_Definition])) (all <>.either (..constructor_method^ class_vars) @@ -913,34 +913,34 @@ ..abstract_method_def^ ..native_method_def^)) -(def: partial_call^ +(def partial_call^ (Parser Partial_Call) (<code>.form (<>.and <code>.symbol (<>.some <code>.any)))) -(def: import_member_alias^ +(def import_member_alias^ (Parser (Maybe Text)) (<>.maybe (do <>.monad [_ (<code>.this (' "as"))] <code>.local))) -(def: (import_member_args^ type_vars) +(def (import_member_args^ type_vars) (-> (List (Type Var)) (Parser (List [Bit (Type Value)]))) (<code>.tuple (<>.some (<>.and (<>.parses? (<code>.this (' "?"))) (..type^ type_vars))))) -(def: import_member_return_flags^ +(def import_member_return_flags^ (Parser [Bit Bit Bit]) (all <>.and (<>.parses? (<code>.this (' "io"))) (<>.parses? (<code>.this (' "try"))) (<>.parses? (<code>.this (' "?"))))) -(def: primitive_mode^ +(def primitive_mode^ (Parser Primitive_Mode) (<>.or (<code>.this (' "manual")) (<code>.this (' "auto")))) -(def: (import_member_decl^ owner_vars) +(def (import_member_decl^ owner_vars) (-> (List (Type Var)) (Parser Import_Member_Declaration)) (all <>.either (<code>.form (do <>.monad @@ -1002,7 +1002,7 @@ #import_field_type gtype]}))) )) -(def: (privacy_modifier$ pm) +(def (privacy_modifier$ pm) (-> Privacy Code) (case pm {#PublicP} (code.text "public") @@ -1010,23 +1010,23 @@ {#ProtectedP} (code.text "protected") {#DefaultP} (code.text "default"))) -(def: (inheritance_modifier$ im) +(def (inheritance_modifier$ im) (-> Inheritance Code) (case im {#FinalI} (code.text "final") {#AbstractI} (code.text "abstract") {#DefaultI} (code.text "default"))) -(def: (annotation_parameter$ [name value]) +(def (annotation_parameter$ [name value]) (-> Annotation_Parameter Code) (` [(~ (code.text name)) (~ value)])) -(def: (annotation$ [name params]) +(def (annotation$ [name params]) (-> Annotation Code) (` ((~ (code.text name)) (~+ (list#each annotation_parameter$ params))))) (with_template [<name> <category>] - [(def: <name> + [(def <name> (-> (Type <category>) Code) (|>> ..signature code.text))] @@ -1038,11 +1038,11 @@ [class$ Class] ) -(def: var$' +(def var$' (-> (Type Var) Code) (|>> ..signature code.local)) -(def: (method_decl$ [[name pm anns] method_decl]) +(def (method_decl$ [[name pm anns] method_decl]) (-> [Member_Declaration MethodDecl] Code) (let [(open "[0]") method_decl] (` ((~ (code.text name)) @@ -1052,14 +1052,14 @@ [(~+ (list#each value$ #method_inputs))] (~ (return$ #method_output)))))) -(def: (state_modifier$ it) +(def (state_modifier$ it) (-> State Code) (case it {#VolatileS} (' "volatile") {#FinalS} (' "final") {#DefaultS} (' "default"))) -(def: (field_decl$ [[name pm anns] field]) +(def (field_decl$ [[name pm anns] field]) (-> [Member_Declaration FieldDecl] Code) (case field {#ConstantField class value} @@ -1081,15 +1081,15 @@ )) )) -(def: (argument$ [name type]) +(def (argument$ [name type]) (-> Argument Code) (` [(~ (code.text name)) (~ (value$ type))])) -(def: (constructor_arg$ [class term]) +(def (constructor_arg$ [class term]) (-> (Typed Code) Code) (` [(~ (value$ class)) (~ term)])) -(def: (overriden_method_macro super_class name declaration type_vars self_name expected_arguments) +(def (overriden_method_macro super_class name declaration type_vars self_name expected_arguments) (-> (Type Class) Text (Type Declaration) (List (Type Var)) Text (List Argument) Macro) (syntax (_ [_ (<code>.this (' "super")) actual_arguments (<code>.tuple (<>.exactly (list.size expected_arguments) <code>.any))]) @@ -1104,7 +1104,7 @@ (list.zipped_2 (list#each product.right expected_arguments)) (list#each ..decorate_input))))))))) -(def: (method_def$ fully_qualified_class_name method_parser super_class fields [[name pm anns] method_def]) +(def (method_def$ fully_qualified_class_name method_parser super_class fields [[name pm anns] method_def]) (-> External (Parser Code) (Type Class) (List [Member_Declaration FieldDecl]) [Member_Declaration Method_Definition] (Meta Code)) (case method_def {#ConstructorMethod strict_fp? type_vars self_name arguments constructor_args body exs} @@ -1195,15 +1195,15 @@ (~ (return$ return_type))))) )) -(def: (complete_call$ g!obj [method args]) +(def (complete_call$ g!obj [method args]) (-> Code Partial_Call Code) (` ((~ (code.symbol method)) (~+ args) (~ g!obj)))) -(def: $Object +(def $Object (Type Class) (jvm.class "java.lang.Object" (list))) -(def: .public class +(def .public class (syntax (_ [.let [! <>.monad] im inheritance_modifier^ [full_class_name class_vars] (at ! each parser.declaration ..declaration^) @@ -1230,7 +1230,7 @@ [(~+ (list#each field_decl$ fields))] [(~+ methods)]))))))) -(def: .public interface +(def .public interface (syntax (_ [.let [! <>.monad] [full_class_name class_vars] (at ! each parser.declaration ..declaration^) supers (<>.else (list) @@ -1243,7 +1243,7 @@ [(~+ (list#each annotation$ annotations))] (~+ (list#each method_decl$ members)))))))) -(def: .public object +(def .public object (syntax (_ [class_vars ..vars^ super (<>.else $Object (class^ class_vars)) @@ -1260,15 +1260,15 @@ [(~+ (list#each constructor_arg$ constructor_args))] [(~+ methods)]))))))) -(def: .public null +(def .public null (syntax (_ []) (in (list (` ("jvm object null")))))) -(def: .public (null? obj) +(def .public (null? obj) (-> (.Primitive "java.lang.Object") Bit) ("jvm object null?" obj)) -(def: .public ??? +(def .public ??? (syntax (_ [expr <code>.any]) (with_symbols [g!temp] (in (list (` (let [(~ g!temp) (~ expr)] @@ -1276,7 +1276,7 @@ {.#Some (~ g!temp)} {.#None})))))))) -(def: .public !!! +(def .public !!! (syntax (_ [expr <code>.any]) (with_symbols [g!value] (in (list (` (.case (~ expr) @@ -1286,7 +1286,7 @@ {.#None} ("jvm object null")))))))) -(def: .public as +(def .public as (syntax (_ [class (..type^ (list)) unchecked (<>.maybe <code>.any)]) (with_symbols [g!_ g!unchecked] @@ -1309,12 +1309,12 @@ (~ check_code)))))) ))))) -(def: .public synchronized +(def .public synchronized (syntax (_ [lock <code>.any body <code>.any]) (in (list (` ("jvm object synchronized" (~ lock) (~ body))))))) -(def: .public do_to +(def .public do_to (syntax (_ [obj <code>.any methods (<>.some partial_call^)]) (with_symbols [g!obj] @@ -1322,19 +1322,19 @@ (exec (~+ (list#each (complete_call$ g!obj) methods)) (~ g!obj))))))))) -(def: (class_import$ declaration) +(def (class_import$ declaration) (-> (Type Declaration) Code) (let [[full_name params] (parser.declaration declaration) def_name (..internal full_name) params' (list#each ..var$' params)] (template.with_locals [g!_] - (` (def: (~ (code.symbol ["" def_name])) + (` (def (~ (code.symbol ["" def_name])) .Type (All ((~ (' g!_)) (~+ params')) (.Primitive (~ (code.text full_name)) [(~+ params')]))))))) -(def: (member_type_vars class_tvars member) +(def (member_type_vars class_tvars member) (-> (List (Type Var)) Import_Member_Declaration (List (Type Var))) (case member {#ConstructorDecl [commons _]} @@ -1351,7 +1351,7 @@ _ class_tvars)) -(def: (member_def_arg_bindings vars member) +(def (member_def_arg_bindings vars member) (-> (List (Type Var)) Import_Member_Declaration (Meta [(List [Bit Code]) (List (Type Value)) (List Code)])) (case member (^.or {#ConstructorDecl [commons _]} {#MethodDecl [commons _]}) @@ -1376,7 +1376,7 @@ _ (at meta.monad in [(list) (list) (list)]))) -(def: (with_return_maybe member never_null? unboxed return_term) +(def (with_return_maybe member never_null? unboxed return_term) (-> Import_Member_Declaration Bit (Type Value) Code Code) (case member (^.or {#ConstructorDecl [commons _]} {#MethodDecl [commons _]}) @@ -1399,7 +1399,7 @@ return_term)) (with_template [<name> <tag> <term_trans>] - [(def: (<name> member return_term) + [(def (<name> member return_term) (-> Import_Member_Declaration Code Code) (case member (^.or {#ConstructorDecl [commons _]} {#MethodDecl [commons _]}) @@ -1415,7 +1415,7 @@ ) (with_template [<input?> <name> <unbox/box> <special+>] - [(def: (<name> mode [unboxed raw]) + [(def (<name> mode [unboxed raw]) (-> Primitive_Mode [(Type Value) Code] Code) (let [[unboxed refined post] (.is [(Type Value) Code (List Code)] (case mode @@ -1472,11 +1472,11 @@ [jvm.double (list) [(` (.is (.Primitive (~ (code.text box.double)))))]]]] ) -(def: (un_quoted quoted) +(def (un_quoted quoted) (-> Code Code) (` ((~' ~) (~ quoted)))) -(def: (jvm_invoke_inputs mode classes inputs) +(def (jvm_invoke_inputs mode classes inputs) (-> Primitive_Mode (List (Type Value)) (List [Bit Code]) (List Code)) (|> inputs (list.zipped_2 classes) @@ -1488,13 +1488,13 @@ [class] (with_automatic_input_conversion mode)))))) -(def: (import_name format class member) +(def (import_name format class member) (-> Text Text Text Text) (|> format (text.replaced "[1]" class) (text.replaced "[0]" member))) -(def: syntax_inputs +(def syntax_inputs (-> (List Code) (List Code)) (|>> (list#each (function (_ name) (list name (` (~! <code>.any))))) @@ -1506,7 +1506,7 @@ "Class" (%.text class) "Field" (%.text field))) -(def: (member_def_interop vars kind class [arg_function_inputs input_jvm_types arg_types] member method_prefix import_format) +(def (member_def_interop vars kind class [arg_function_inputs input_jvm_types arg_types] member method_prefix import_format) (-> (List (Type Var)) Class_Kind (Type Declaration) [(List [Bit Code]) (List (Type Value)) (List Code)] Import_Member_Declaration Text Text (Meta (List Code))) (let [[full_name class_tvars] (parser.declaration class)] (case member @@ -1525,7 +1525,7 @@ getter_interop (.is (-> Text Code) (function (_ name) (let [getter_name (code.symbol ["" (..import_name import_format method_prefix name)])] - (` (def: (~ getter_name) + (` (def (~ getter_name) (~ enum_type) (~ (get_static_field full_name name)))))))]] (in (list#each getter_interop enum_members)))) @@ -1546,7 +1546,7 @@ (with_return_maybe member true classT) (with_return_try member) (with_return_io member))]] - (in (list (` (def: (~ def_name) + (in (list (` (def (~ def_name) ((~! syntax) ((~ def_name) [(~+ (syntax_inputs (list#each product.right arg_function_inputs)))]) ((~' in) (.list (.` (~ jvm_interop)))))))))) @@ -1601,7 +1601,7 @@ (|> callC (with_return_try member) (with_return_io member))))]] - (in (list (` (def: (~ def_name) + (in (list (` (def (~ def_name) ((~! syntax) ((~ def_name) [(~+ (syntax_inputs (list#each product.right arg_function_inputs))) (~+ (syntax_inputs object_ast))]) ((~' in) (.list (.` (~ jvm_interop))))))))))) @@ -1657,14 +1657,14 @@ (` {.#Right []}) (` {.#Right [(~ g!obj)]})) (` ((~' in) (.list (.` (~ getter_body))))))] - (list (` (def: (~ g!name) + (list (` (def (~ g!name) ((~! syntax) ((~ g!name) [(~ write|read) (~ parser)]) (case (~ write|read) (~+ write) (~+ read)))))))))) ))) -(def: (member_import$ vars kind class [import_format member]) +(def (member_import$ vars kind class [import_format member]) (-> (List (Type Var)) Class_Kind (Type Declaration) [Text Import_Member_Declaration] (Meta (List Code))) (let [[full_name _] (parser.declaration class) method_prefix (..internal full_name)] @@ -1672,21 +1672,21 @@ [=args (member_def_arg_bindings vars member)] (member_def_interop vars kind class =args member method_prefix import_format)))) -(def: interface? +(def interface? (All (_ a) (-> (.Primitive "java.lang.Class" [a]) Bit)) (|>> ("jvm member invoke virtual" [] "java.lang.Class" "isInterface" []) "jvm object cast" (.is ..Boolean) (.as Bit))) -(def: load_class +(def load_class (-> External (Try (.Primitive "java.lang.Class" [Any]))) (|>> (.as (.Primitive "java.lang.String")) ["Ljava/lang/String;"] ("jvm member invoke static" [] "java.lang.Class" "forName" []) try)) -(def: (class_kind declaration) +(def (class_kind declaration) (-> (Type Declaration) (Meta Class_Kind)) (let [[class_name _] (parser.declaration declaration)] (case (load_class class_name) @@ -1698,7 +1698,7 @@ {.#Left _} (meta.failure (format "Unknown class: " class_name))))) -(def: .public import +(def .public import (syntax (_ [declaration ..declaration^ .let [[class_name class_type_vars] (parser.declaration declaration)] import_format <code>.text @@ -1710,7 +1710,7 @@ (monad.each ! (member_import$ class_type_vars kind declaration)))] (in (list.partial (class_import$ declaration) (list#conjoint =members)))))) -(def: .public array +(def .public array (syntax (_ [type (..type^ (list)) size <code>.any]) (let [g!size (` (|> (~ size) @@ -1740,7 +1740,7 @@ "Lux Type" (%.type type))) (with_expansions [<failure> (these (meta.failure (exception.error ..cannot_convert_to_jvm_type [type])))] - (def: (lux_type->jvm_type context type) + (def (lux_type->jvm_type context type) (-> Type_Context .Type (Meta (Type Value))) (if (type#= .Any type) (at meta.monad in $Object) @@ -1838,7 +1838,7 @@ _ <failure>)))) -(def: .public length +(def .public length (syntax (_ [array <code>.any]) (case array [_ {.#Symbol array_name}] @@ -1874,7 +1874,7 @@ (in (list (` (let [(~ g!array) (~ array)] (..length (~ g!array)))))))))) -(def: .public read! +(def .public read! (syntax (_ [idx <code>.any array <code>.any]) (case array @@ -1913,7 +1913,7 @@ (in (list (` (let [(~ g!array) (~ array)] (..read! (~ idx) (~ g!array)))))))))) -(def: .public write! +(def .public write! (syntax (_ [idx <code>.any value <code>.any array <code>.any]) @@ -1954,11 +1954,11 @@ (in (list (` (let [(~ g!array) (~ array)] (..write! (~ idx) (~ value) (~ g!array)))))))))) -(def: .public class_for +(def .public class_for (syntax (_ [type (..type^ (list))]) (in (list (` ("jvm object class" (~ (code.text (..reflection type))))))))) -(def: .public type +(def .public type (syntax (_ [type (..type^ (list))]) (in (list (..value_type {#ManualPrM} type))))) @@ -1967,7 +1967,7 @@ "Signature" (..signature type) "Reflection" (..reflection type))) -(def: .public is +(def .public is (syntax (_ [type (..type^ (list)) object <code>.any]) (case [(parser.array? type) @@ -1980,11 +1980,11 @@ (meta.failure (exception.error ..cannot_cast_to_non_object [type]))))) (with_template [<forward> <from> <to> <backward>] - [(def: .public <forward> + [(def .public <forward> (template (<forward> it) [(|> it (.is <from>) (.as <to>))])) - (def: .public <backward> + (def .public <backward> (template (<backward> it) [(|> it (.is <to>) (.as <from>))]))] @@ -1995,11 +1995,11 @@ ) (with_template [<forward> <from> <$> <mid> <$'> <to> <backward>] - [(def: .public <forward> + [(def .public <forward> (template (<forward> it) [(|> it (.is <from>) (.as <mid>) <$> (.is <to>))])) - (def: .public <backward> + (def .public <backward> (template (<backward> it) [(|> it (.is <to>) <$'> (.is <mid>) (.as <from>))]))] diff --git a/stdlib/source/library/lux/ffi.lux b/stdlib/source/library/lux/ffi.lux index 65fb0ea9c..d63363c38 100644 --- a/stdlib/source/library/lux/ffi.lux +++ b/stdlib/source/library/lux/ffi.lux @@ -96,7 +96,7 @@ (type: Alias (Maybe Text)) - (def: alias + (def alias (Parser Alias) (<>.maybe (<>.after (<code>.this (' "as")) <code>.local))) @@ -105,7 +105,7 @@ [#optional? Bit #mandatory Code])) - (def: optional + (def optional (Parser Optional) (let [token "?"] (<| (<>.and (<>.parses? (<code>.this_text token))) @@ -119,7 +119,7 @@ #anonymous a])) (with_template [<case> <name>] - [(def: <case> + [(def <case> (All (_ a) (-> (Parser a) (Parser (Named a)))) (|>> (all <>.and <name> @@ -133,18 +133,18 @@ (type: Output Optional) - (def: output + (def output (Parser Output) ..optional) (type: Global (Named Output)) - (def: variables + (def variables (Parser (List Text)) (<>.else (list) (<code>.tuple (<>.some <code>.local)))) - (def: (generalized $ it) + (def (generalized $ it) (All (_ a) (-> (-> (List Text) a a) (-> (Parser a) (Parser a)))) @@ -160,7 +160,7 @@ #io? Bit #try? Bit])) - (def: input + (def input (Parser Input) (all <>.and (<>#in (list)) @@ -171,7 +171,7 @@ (type: Constructor (Named Input)) - (def: constructor + (def constructor (Parser Constructor) (<| <code>.form (..generalized (has [#anonymous #variables])) @@ -183,11 +183,11 @@ [#static? Bit #member a])) - (def: static! + (def static! (Parser Any) (<code>.this_text "static")) - (def: (member it) + (def (member it) (All (_ a) (-> (Parser a) (Parser (Member a)))) @@ -201,7 +201,7 @@ (type: Field (Member (Named Output))) - (def: field + (def field (Parser Field) (<| <code>.form ..member @@ -213,7 +213,7 @@ [#input Input #output Optional])) - (def: procedure + (def procedure (Parser (Named Procedure)) (<| (..generalized (has [#anonymous #input #variables])) ..named @@ -225,7 +225,7 @@ (type: Method (Member (Named Procedure))) - (def: method + (def method (Parser Method) (<| <code>.form ..member @@ -239,7 +239,7 @@ {#Field Field} {#Method Method})))) - (`` (`` (def: sub + (`` (`` (def sub (Parser Sub) (all <>.or (~~ (for @.lua (~~ (these)) @@ -249,14 +249,14 @@ ..method )))) - (def: parameters + (def parameters (-> (List Optional) (List Optional)) (|>> list.enumeration (list#each (.function (_ [idx [optional? type]]) [#optional? optional? #mandatory (|> idx %.nat code.local)])))) - (def: (output_type it) + (def (output_type it) (-> Optional Code) (if (the #optional? it) (` (.Maybe (~ (the #mandatory it)))) @@ -264,17 +264,17 @@ (`` (with_template [<lux_it> <host_it> <lux_?> <host_?>] - [(def: .public (<lux_it> _) + [(def .public (<lux_it> _) (-> Any Nothing) (as_expected (<host_it>))) - (def: .public <lux_?> + (def .public <lux_?> (-> Any Bit) (|>> <host_?>)) (template.with_locals [g!it] - (these (def: g!it' (' g!it)) - (def: (host_optional it) + (these (def g!it' (' g!it)) + (def (host_optional it) (-> Optional Code) (.if (.the #optional? it) (` (.case (~ (the #mandatory it)) @@ -285,7 +285,7 @@ (<host_it>))) (the #mandatory it))) - (def: (lux_optional it output) + (def (lux_optional it output) (-> Optional Code Code) (` (.let [(~ g!it') (~ output)] (~ (if (the #optional? it) @@ -319,7 +319,7 @@ #namespace Namespace #members (List Sub)])) - (def: class + (def class (Parser Class) (all <>.and (<>.either (<>.and <code>.local @@ -336,14 +336,14 @@ {#Procedure (Named Procedure)} {#Global Global})) - (def: importP + (def importP (Parser Import) (all <>.or ..class (<code>.form ..procedure) (<code>.form (..named ..output)))) - (def: (input_type input :it:) + (def (input_type input :it:) (-> Input Code Code) (let [:it: (if (the #try? input) (` (.Either .Text (~ :it:))) @@ -352,7 +352,7 @@ (` ((~! io.IO) (~ :it:))) :it:))) - (def: (input_term input term) + (def (input_term input term) (-> Input Code Code) (let [term (if (the #try? input) (` (.try (~ term))) @@ -361,7 +361,7 @@ (` ((~! io.io) (~ term))) term))) - (def: (procedure_definition import! source it) + (def (procedure_definition import! source it) (-> (List Code) Code (Named Procedure) Code) (let [g!it (|> (the #alias it) (maybe.else (the #name it)) @@ -377,7 +377,7 @@ parameters (list#each ..output_type :parameters:))] - (` (.def: ((~ g!it) (~+ (case g!parameters + (` (.def ((~ g!it) (~+ (case g!parameters {.#End} (list g!it) _ (list#each (the #mandatory) g!parameters)))) (.All ((~ g!it) (~+ g!variables)) @@ -393,19 +393,19 @@ (` (<apply> (.as_expected (~ source)) [(~+ (list#each ..host_optional g!parameters))])))))))))) - (def: (namespaced namespace class alias member) + (def (namespaced namespace class alias member) (-> Namespace Text Alias Text Text) (|> namespace (text.replaced "[1]" (maybe.else class alias)) (text.replaced "[0]" member))) - (def: class_separator ".") + (def class_separator ".") - (def: host_path + (def host_path (text.replaced .module_separator ..class_separator)) (for @.js (these) - (def: (imported class) + (def (imported class) (-> Text Code) (case (text.all_split_by .module_separator class) {.#Item head tail} @@ -419,13 +419,13 @@ {.#End} (` (<import> (~ (code.text class))))))) - (def: (global_definition import! it) + (def (global_definition import! it) (-> (List Code) Global Code) (let [g!name (|> (the #alias it) (maybe.else (the #name it)) code.local) :output: (the #anonymous it)] - (` (.def: (~ g!name) + (` (.def (~ g!name) (~ (..output_type :output:)) (.exec (~+ import!) @@ -435,7 +435,7 @@ (for @.lua (these) @.ruby (these) - (def: (constructor_definition [class_name class_parameters] alias namespace it) + (def (constructor_definition [class_name class_parameters] alias namespace it) (-> Declaration Alias Namespace Constructor Code) (let [g!it (|> it (the #alias) @@ -449,7 +449,7 @@ g!class_variables (list#each code.local class_parameters) g!class (` ((~ (code.local (maybe.else class_name alias))) (~+ g!class_variables))) :output: [#optional? false #mandatory g!class]] - (` (.def: ((~ g!it) (~+ (case g!parameters + (` (.def ((~ g!it) (~+ (case g!parameters {.#End} (list g!it) _ (list#each (the #mandatory) g!parameters)))) (.All ((~ g!it) (~+ g!class_variables) (~+ g!input_variables)) @@ -465,7 +465,7 @@ (~ (..imported class_name)))))) [(~+ (list#each ..host_optional g!parameters))])))))))))) - (def: (static_field_definition import! [class_name class_parameters] alias namespace it) + (def (static_field_definition import! [class_name class_parameters] alias namespace it) (-> (List Code) Declaration Alias Namespace (Named Output) Code) (let [field (the #name it) g!it (|> (the #alias it) @@ -473,7 +473,7 @@ (..namespaced namespace class_name alias) code.local) :field: (the #anonymous it)] - (` (def: (~ g!it) + (` (def (~ g!it) ((~! syntax) ((~ g!it) []) (.at (~! meta.monad) (~' in) (.list (`' (.exec @@ -485,7 +485,7 @@ (` (<get> (~ (code.text field)) (~ (..imported class_name))))))))))))))))) - (def: (virtual_field_definition [class_name class_parameters] alias namespace it) + (def (virtual_field_definition [class_name class_parameters] alias namespace it) (-> Declaration Alias Namespace (Named Output) Code) (let [name (the #name it) g!it (|> (the #alias it) @@ -496,7 +496,7 @@ :field: (the #anonymous it) g!variables (list#each code.local class_parameters) g!class (` ((~ (code.local (maybe.else class_name alias))) (~+ g!variables)))] - (` (.def: ((~ g!it) (~ g!it)) + (` (.def ((~ g!it) (~ g!it)) (.All ((~ g!it) (~+ g!variables)) (.-> (~ g!class) (~ (..output_type :field:)))) @@ -504,13 +504,13 @@ (~ (<| (lux_optional :field:) (` (<get> (~ (code.text name)) (~ g!it)))))))))) - (def: (field_definition import! class alias namespace it) + (def (field_definition import! class alias namespace it) (-> (List Code) Declaration Alias Namespace Field Code) (if (the #static? it) (..static_field_definition import! class alias namespace (the #member it)) (..virtual_field_definition class alias namespace (the #member it)))) - (def: (static_method_definition import! [class_name class_parameters] alias namespace it) + (def (static_method_definition import! [class_name class_parameters] alias namespace it) (-> (List Code) Declaration Alias Namespace (Named Procedure) Code) (let [method (the #name it) name (|> (the #alias it) @@ -525,7 +525,7 @@ (.as (..Object .Any) (~ (..imported class_name)))))))))) - (def: (virtual_method_definition [class_name class_parameters] alias namespace it) + (def (virtual_method_definition [class_name class_parameters] alias namespace it) (-> Declaration Alias Namespace (Named Procedure) Code) (let [method (the #name it) g!it (|> (the #alias it) @@ -540,7 +540,7 @@ g!class_variables (list#each code.local class_parameters) g!class (` ((~ (code.local (maybe.else class_name alias))) (~+ g!class_variables))) :output: (the #output procedure)] - (` (.def: ((~ g!it) (~+ (list#each (the #mandatory) g!parameters)) (~ g!it)) + (` (.def ((~ g!it) (~+ (list#each (the #mandatory) g!parameters)) (~ g!it)) (.All ((~ g!it) (~+ g!class_variables) (~+ g!input_variables)) (.-> (~+ (list#each ..output_type :parameters:)) (~ g!class) @@ -554,13 +554,13 @@ (~ g!it) [(~+ (list#each ..host_optional g!parameters))]))))))))) - (def: (method_definition import! class alias namespace it) + (def (method_definition import! class alias namespace it) (-> (List Code) Declaration Alias Namespace Method Code) (if (the #static? it) (static_method_definition import! class alias namespace (the #member it)) (virtual_method_definition class alias namespace (the #member it)))) - (def: .public import + (def .public import (syntax (_ [host_module (<>.maybe <code>.text) it ..importP]) (let [host_module_import! (is (List Code) @@ -606,7 +606,7 @@ )))) (for @.ruby (these) - (def: .public function + (def .public function (syntax (_ [[self inputs] (<code>.form (all <>.and <code>.local @@ -622,11 +622,11 @@ (.function ((~ (code.local self)) [(~+ (list#each product.left inputs))]) (~ term))))))))) - (for @.js (these (def: .public type_of + (for @.js (these (def .public type_of (template (type_of object) [("js type-of" object)])) - (def: .public global + (def .public global (syntax (_ [type <code>.any [head tail] (<code>.tuple (<>.and <code>.local (<>.some <code>.local)))]) (with_symbols [g!_] @@ -652,7 +652,7 @@ (..global (~ type) [(~ (code.local (%.format head "." next))) (~+ (list#each code.local tail))])))))))))))) - (def: !defined? + (def !defined? (template (_ <global>) [(.case (..global Any <global>) {.#None} @@ -662,7 +662,7 @@ .true)])) (with_template [<name> <global>] - [(def: .public <name> + [(def .public <name> Bit (!defined? <global>))] @@ -670,7 +670,7 @@ [on_nashorn? [java lang Object]] ) - (def: .public on_node_js? + (def .public on_node_js? Bit (|> (..global (Object Any) [process]) (maybe#each (|>> [] @@ -682,7 +682,7 @@ ... These extensions must be defined this way because importing any of the modules ... normally used when writing extensions would introduce a circular dependency ... because the Archive type depends on Binary, and that module depends on this ffi module. - (def: extension_name + (def extension_name (syntax (_ []) (do meta.monad [module meta.current_module_name @@ -692,15 +692,15 @@ (with_expansions [<undefined> (..extension_name) <undefined?> (..extension_name) <object> (..extension_name)] - (these (def: extension_analysis + (these (def extension_analysis (template (_ <name> <parameter>) [{5 #1 [<name> <parameter>]}])) - (def: text_analysis + (def text_analysis (template (_ <it>) [{0 #0 {5 #1 <it>}}])) - (def: analysis + (def analysis (template (_ <name> <bindings> <parser> <inputs> <body>) [("lux def analysis" <name> (.function (_ name phase archive inputs) @@ -714,7 +714,7 @@ {try.#Success <inputs>} <body>)))))])) - (def: generation + (def generation (template (_ <name> <bindings> <inputs> <body>) [("lux def generation" <name> (.function (_ name phase archive inputs) @@ -738,7 +738,7 @@ (list) {try.#Success [state js.undefined]}) - (def: .public undefined + (def .public undefined (template (undefined) [(.is ..Undefined (<undefined>))])) @@ -757,7 +757,7 @@ [[state it] (phase archive it state)] (in [state (js.= js.undefined it)]))) - (def: .public undefined? + (def .public undefined? (template (undefined? <it>) [(.as .Bit (.is .Any (<undefined?> <it>)))])) @@ -774,11 +774,11 @@ it)] (in [state (extension_analysis name (list.reversed output))]))) - (def: text_synthesis + (def text_synthesis (template (_ <it>) [{0 #0 {2 #1 <it>}}])) - (def: (pairs it) + (def (pairs it) (All (_ a) (-> (List a) (List [a a]))) (case it (pattern (list.partial left right tail)) @@ -808,7 +808,7 @@ (pairs (list.partial head_key head_value tail)))] (in [state (js.object (list.reversed output))]))) - (def: .public object + (def .public object (syntax (_ [it (<>.some <code>.any)]) (in (list (` (.as (..Object .Any) (<object> (~+ it)))))))) diff --git a/stdlib/source/library/lux/ffi.old.lux b/stdlib/source/library/lux/ffi.old.lux index 2fa4e5b7a..c7d8c3dd2 100644 --- a/stdlib/source/library/lux/ffi.old.lux +++ b/stdlib/source/library/lux/ffi.old.lux @@ -28,7 +28,7 @@ ["[0]" meta]]]) (with_template [<name> <op> <from> <to>] - [(def: .public (<name> value) + [(def .public (<name> value) (-> (Primitive <from>) (Primitive <to>)) (<op> value))] @@ -64,11 +64,11 @@ ) (with_template [<forward> <from> <to> <backward>] - [(def: .public <forward> + [(def .public <forward> (template (<forward> it) [(|> it (.is <from>) (.as (Primitive <to>)))])) - (def: .public <backward> + (def .public <backward> (template (<backward> it) [(|> it (.is (Primitive <to>)) (.as <from>))]))] @@ -79,11 +79,11 @@ ) (with_template [<forward> <from> <$> <mid> <$'> <to> <backward>] - [(def: .public <forward> + [(def .public <forward> (template (<forward> it) [(|> it (.is <from>) (.as (Primitive <mid>)) <$> (.is (Primitive <to>)))])) - (def: .public <backward> + (def .public <backward> (template (<backward> it) [(|> it (.is (Primitive <to>)) <$'> (.is (Primitive <mid>)) (.as <from>))]))] @@ -94,8 +94,8 @@ ) ... [Utils] -(def: constructor_method_name "<init>") -(def: member_separator "::") +(def constructor_method_name "<init>") +(def member_separator "::") ... Types (type: JVM_Code @@ -282,7 +282,7 @@ {#FieldAccessDecl ImportFieldDecl})) ... Utils -(def: (manual_primitive_type class) +(def (manual_primitive_type class) (-> Text (Maybe Code)) (case class (^.with_template [<prim> <type>] @@ -301,7 +301,7 @@ _ {.#None})) -(def: (auto_primitive_type class) +(def (auto_primitive_type class) (-> Text (Maybe Code)) (case class (^.with_template [<prim> <type>] @@ -319,11 +319,11 @@ _ {.#None})) -(def: safe +(def safe (-> Text Text) (text.replaced "/" ".")) -(def: (generic_class_type' mode type_params in_array? name+params +(def (generic_class_type' mode type_params in_array? name+params class_type') (-> Primitive_Mode (List Type_Parameter) Bit [Text (List GenericType)] (-> Primitive_Mode (List Type_Parameter) Bit GenericType Code) @@ -344,7 +344,7 @@ =params (list#each (class_type' mode type_params in_array?) params)] (` (Primitive (~ (code.text name)) [(~+ =params)]))))) -(def: (class_type' mode type_params in_array? class) +(def (class_type' mode type_params in_array? class) (-> Primitive_Mode (List Type_Parameter) Bit GenericType Code) (case class {#GenericTypeVar name} @@ -374,15 +374,15 @@ (class_type' mode type_params in_array? upper_bound) )) -(def: (class_type mode type_params class) +(def (class_type mode type_params class) (-> Primitive_Mode (List Type_Parameter) GenericType Code) (class_type' mode type_params #0 class)) -(def: (type_param_type$ [name bounds]) +(def (type_param_type$ [name bounds]) (-> Type_Parameter Code) (code.symbol ["" name])) -(def: (class_decl_type$ (open "[0]")) +(def (class_decl_type$ (open "[0]")) (-> Class_Declaration Code) (let [=params (list#each (.is (-> Type_Parameter Code) (function (_ [pname pbounds]) @@ -396,9 +396,9 @@ (` (Primitive (~ (code.text (safe #class_name))) [(~+ =params)])))) -(def: type_var_class Text "java.lang.Object") +(def type_var_class Text "java.lang.Object") -(def: (simple_class$ env class) +(def (simple_class$ env class) (-> (List Type_Parameter) GenericType Text) (case class {#GenericTypeVar name} @@ -443,21 +443,21 @@ (format "[L" (simple_class$ env param) ";")) )) -(def: (get_const_parser class_name field_name) +(def (get_const_parser class_name field_name) (-> Text Text (Parser Code)) (do <>.monad [.let [dotted_name (format "::" field_name)] _ (<code>.this (code.symbol ["" dotted_name]))] (in (`' ((~ (code.text (format "jvm getstatic" ":" class_name ":" field_name)))))))) -(def: (get_var_parser class_name field_name) +(def (get_var_parser class_name field_name) (-> Text Text (Parser Code)) (do <>.monad [.let [dotted_name (format "::" field_name)] _ (<code>.this (code.symbol ["" dotted_name]))] (in (`' ((~ (code.text (format "jvm getfield" ":" class_name ":" field_name))) _jvm_this))))) -(def: (put_var_parser class_name field_name) +(def (put_var_parser class_name field_name) (-> Text Text (Parser Code)) (do <>.monad [.let [dotted_name (format "::" field_name)] @@ -465,7 +465,7 @@ (<code>.form (all <>.and (<code>.this (' :=)) (<code>.this (code.symbol ["" dotted_name])) <code>.any)))] (in (`' ((~ (code.text (format "jvm putfield" ":" class_name ":" field_name))) _jvm_this (~ value)))))) -(def: (pre_walk_replace f input) +(def (pre_walk_replace f input) (-> (-> Code Code) Code Code) (case (f input) (^.with_template [<tag>] @@ -478,7 +478,7 @@ ast' ast')) -(def: (parser_replacer p ast) +(def (parser_replacer p ast) (-> (Parser Code) (-> Code Code)) (case (<>.result p (list ast)) {.#Right [{.#End} ast']} @@ -488,7 +488,7 @@ ast )) -(def: (field_parser class_name [[field_name _ _] field]) +(def (field_parser class_name [[field_name _ _] field]) (-> Text [Member_Declaration FieldDecl] (Parser Code)) (case field {#ConstantField _} @@ -498,7 +498,7 @@ (<>.either (get_var_parser class_name field_name) (put_var_parser class_name field_name)))) -(def: (constructor_parser params class_name arg_decls) +(def (constructor_parser params class_name arg_decls) (-> (List Type_Parameter) Text (List ArgDecl) (Parser Code)) (do <>.monad [args (.is (Parser (List Code)) @@ -508,7 +508,7 @@ (in (` ((~ (code.text (format "jvm new" ":" class_name ":" (text.interposed "," arg_decls')))) (~+ args)))))) -(def: (static_method_parser params class_name method_name arg_decls) +(def (static_method_parser params class_name method_name arg_decls) (-> (List Type_Parameter) Text Text (List ArgDecl) (Parser Code)) (do <>.monad [.let [dotted_name (format "::" method_name "!")] @@ -520,7 +520,7 @@ (~+ args)))))) (with_template [<name> <jvm_op>] - [(def: (<name> params class_name method_name arg_decls) + [(def (<name> params class_name method_name arg_decls) (-> (List Type_Parameter) Text Text (List ArgDecl) (Parser Code)) (do <>.monad [.let [dotted_name (format "::" method_name "!")] @@ -535,7 +535,7 @@ [virtual_method_parser "jvm invokevirtual"] ) -(def: (method_parser params class_name [[method_name _ _] meth_def]) +(def (method_parser params class_name [[method_name _ _] meth_def]) (-> (List Type_Parameter) Text [Member_Declaration Method_Definition] (Parser Code)) (case meth_def {#ConstructorMethod strict? type_vars args constructor_args return_expr exs} @@ -555,7 +555,7 @@ (virtual_method_parser params class_name method_name args))) ... Parsers -(def: privacy_modifier^ +(def privacy_modifier^ (Parser Privacy) (let [(open "[0]") <>.monad] (all <>.or @@ -564,7 +564,7 @@ (<code>.this (' "protected")) (in [])))) -(def: inheritance_modifier^ +(def inheritance_modifier^ (Parser Inheritance) (let [(open "[0]") <>.monad] (all <>.or @@ -572,17 +572,17 @@ (<code>.this (' "abstract")) (in [])))) -(def: bound_kind^ +(def bound_kind^ (Parser BoundKind) (<>.or (<code>.this (' <)) (<code>.this (' >)))) -(def: (no_periods_assertion name) +(def (no_periods_assertion name) (-> Text (Parser Any)) (<>.assertion "Names in class declarations cannot contain periods." (not (text.contains? "." name)))) -(def: (generic_type^ type_vars) +(def (generic_type^ type_vars) (-> (List Type_Parameter) (Parser GenericType)) (<>.rec (function (_ again^) @@ -627,7 +627,7 @@ (in {#GenericClass name params}))) )))) -(def: type_param^ +(def type_param^ (Parser Type_Parameter) (<>.either (do <>.monad [param_name <code>.local] @@ -638,14 +638,14 @@ bounds (<>.many (..generic_type^ (list)))] (in [param_name bounds]))))) -(def: type_params^ +(def type_params^ (Parser (List Type_Parameter)) (|> ..type_param^ <>.some <code>.tuple (<>.else (list)))) -(def: class_decl^ +(def class_decl^ (Parser Class_Declaration) (<>.either (do <>.monad [name <code>.local @@ -658,7 +658,7 @@ (in [name params]))) )) -(def: (super_class_decl^ type_vars) +(def (super_class_decl^ type_vars) (-> (List Type_Parameter) (Parser Super_Class_Decl)) (<>.either (do <>.monad [name <code>.local @@ -670,11 +670,11 @@ params (<>.some (..generic_type^ type_vars))] (in [name params]))))) -(def: annotation_params^ +(def annotation_params^ (Parser (List AnnotationParam)) (<code>.tuple (<>.some (<>.and <code>.text <code>.any)))) -(def: annotation^ +(def annotation^ (Parser Annotation) (<>.either (do <>.monad [ann_name <code>.local] @@ -682,31 +682,31 @@ (<code>.form (<>.and <code>.local annotation_params^)))) -(def: annotations^' +(def annotations^' (Parser (List Annotation)) (do <>.monad [_ (<code>.this (' "ann"))] (<code>.tuple (<>.some ..annotation^)))) -(def: annotations^ +(def annotations^ (Parser (List Annotation)) (do <>.monad [anns?? (<>.maybe ..annotations^')] (in (maybe.else (list) anns??)))) -(def: (throws_decl'^ type_vars) +(def (throws_decl'^ type_vars) (-> (List Type_Parameter) (Parser (List GenericType))) (do <>.monad [_ (<code>.this (' "throws"))] (<code>.tuple (<>.some (..generic_type^ type_vars))))) -(def: (throws_decl^ type_vars) +(def (throws_decl^ type_vars) (-> (List Type_Parameter) (Parser (List GenericType))) (do <>.monad [exs? (<>.maybe (throws_decl'^ type_vars))] (in (maybe.else (list) exs?)))) -(def: (method_decl^ type_vars) +(def (method_decl^ type_vars) (-> (List Type_Parameter) (Parser [Member_Declaration MethodDecl])) (<code>.form (do <>.monad [tvars ..type_params^ @@ -720,14 +720,14 @@ #method_output output #method_exs exs]])))) -(def: state_modifier^ +(def state_modifier^ (Parser State) (all <>.or (<code>.this (' "volatile")) (<code>.this (' "final")) (at <>.monad in []))) -(def: (field_decl^ type_vars) +(def (field_decl^ type_vars) (-> (List Type_Parameter) (Parser [Member_Declaration FieldDecl])) (<>.either (<code>.form (do <>.monad [_ (<code>.this (' "const")) @@ -744,24 +744,24 @@ type (..generic_type^ type_vars)] (in [[name pm anns] {#VariableField [sm type]}]))))) -(def: (arg_decl^ type_vars) +(def (arg_decl^ type_vars) (-> (List Type_Parameter) (Parser ArgDecl)) (<>.and <code>.local (..generic_type^ type_vars))) -(def: (arg_decls^ type_vars) +(def (arg_decls^ type_vars) (-> (List Type_Parameter) (Parser (List ArgDecl))) (<code>.tuple (<>.some (arg_decl^ type_vars)))) -(def: (constructor_arg^ type_vars) +(def (constructor_arg^ type_vars) (-> (List Type_Parameter) (Parser ConstructorArg)) (<>.and (..generic_type^ type_vars) <code>.any)) -(def: (constructor_args^ type_vars) +(def (constructor_args^ type_vars) (-> (List Type_Parameter) (Parser (List ConstructorArg))) (<code>.tuple (<>.some (constructor_arg^ type_vars)))) -(def: (constructor_method^ class_vars) +(def (constructor_method^ class_vars) (-> (List Type_Parameter) (Parser [Member_Declaration Method_Definition])) (<code>.form (do <>.monad [pm privacy_modifier^ @@ -779,7 +779,7 @@ #member_anns annotations] {#ConstructorMethod strict_fp? method_vars arg_decls constructor_args body exs}])))) -(def: (virtual_method_def^ class_vars) +(def (virtual_method_def^ class_vars) (-> (List Type_Parameter) (Parser [Member_Declaration Method_Definition])) (<code>.form (do <>.monad [pm privacy_modifier^ @@ -803,7 +803,7 @@ this_name arg_decls return_type body exs}])))) -(def: overriden_method_def^ +(def overriden_method_def^ (Parser [Member_Declaration Method_Definition]) (<code>.form (do <>.monad [strict_fp? (<>.parses? (<code>.this (' "strict"))) @@ -826,7 +826,7 @@ this_name arg_decls return_type body exs}])))) -(def: static_method_def^ +(def static_method_def^ (Parser [Member_Declaration Method_Definition]) (<code>.form (do <>.monad [pm privacy_modifier^ @@ -845,7 +845,7 @@ #member_anns annotations] {#StaticMethod strict_fp? method_vars arg_decls return_type body exs}])))) -(def: abstract_method_def^ +(def abstract_method_def^ (Parser [Member_Declaration Method_Definition]) (<code>.form (do <>.monad [pm privacy_modifier^ @@ -862,7 +862,7 @@ #member_anns annotations] {#AbstractMethod method_vars arg_decls return_type exs}])))) -(def: native_method_def^ +(def native_method_def^ (Parser [Member_Declaration Method_Definition]) (<code>.form (do <>.monad [pm privacy_modifier^ @@ -879,7 +879,7 @@ #member_anns annotations] {#NativeMethod method_vars arg_decls return_type exs}])))) -(def: (method_def^ class_vars) +(def (method_def^ class_vars) (-> (List Type_Parameter) (Parser [Member_Declaration Method_Definition])) (all <>.either (..constructor_method^ class_vars) @@ -889,30 +889,30 @@ ..abstract_method_def^ ..native_method_def^)) -(def: partial_call^ +(def partial_call^ (Parser Partial_Call) (<code>.form (<>.and <code>.symbol (<>.some <code>.any)))) -(def: import_member_alias^ +(def import_member_alias^ (Parser (Maybe Text)) (<>.maybe (do <>.monad [_ (<code>.this (' "as"))] <code>.local))) -(def: (import_member_args^ type_vars) +(def (import_member_args^ type_vars) (-> (List Type_Parameter) (Parser (List [Bit GenericType]))) (<code>.tuple (<>.some (<>.and (<>.parses? (<code>.this (' "?"))) (..generic_type^ type_vars))))) -(def: import_member_return_flags^ +(def import_member_return_flags^ (Parser [Bit Bit Bit]) (all <>.and (<>.parses? (<code>.this (' "io"))) (<>.parses? (<code>.this (' "try"))) (<>.parses? (<code>.this (' "?"))))) -(def: primitive_mode^ +(def primitive_mode^ (Parser Primitive_Mode) (<>.or (<code>.this (' "manual")) (<code>.this (' "auto")))) -(def: (import_member_decl^ owner_vars) +(def (import_member_decl^ owner_vars) (-> (List Type_Parameter) (Parser Import_Member_Declaration)) (all <>.either (<code>.form (do <>.monad @@ -974,19 +974,19 @@ )) ... Generators -(def: with_parens +(def with_parens (-> JVM_Code JVM_Code) (text.enclosed ["(" ")"])) -(def: with_brackets +(def with_brackets (-> JVM_Code JVM_Code) (text.enclosed ["[" "]"])) -(def: spaced +(def spaced (-> (List JVM_Code) JVM_Code) (text.interposed " ")) -(def: (privacy_modifier$ pm) +(def (privacy_modifier$ pm) (-> Privacy JVM_Code) (case pm {#PublicP} "public" @@ -994,28 +994,28 @@ {#ProtectedP} "protected" {#DefaultP} "default")) -(def: (inheritance_modifier$ im) +(def (inheritance_modifier$ im) (-> Inheritance JVM_Code) (case im {#FinalI} "final" {#AbstractI} "abstract" {#DefaultI} "default")) -(def: (annotation_param$ [name value]) +(def (annotation_param$ [name value]) (-> AnnotationParam JVM_Code) (format name "=" (code.format value))) -(def: (annotation$ [name params]) +(def (annotation$ [name params]) (-> Annotation JVM_Code) (format "(" name " " "{" (text.interposed text.tab (list#each annotation_param$ params)) "}" ")")) -(def: (bound_kind$ kind) +(def (bound_kind$ kind) (-> BoundKind JVM_Code) (case kind {#UpperBound} "<" {#LowerBound} ">")) -(def: (generic_type$ gtype) +(def (generic_type$ gtype) (-> GenericType JVM_Code) (case gtype {#GenericTypeVar name} @@ -1033,21 +1033,21 @@ {#GenericWildcard {.#Some [bound_kind bound]}} (format (bound_kind$ bound_kind) (generic_type$ bound)))) -(def: (type_param$ [name bounds]) +(def (type_param$ [name bounds]) (-> Type_Parameter JVM_Code) (format "(" name " " (spaced (list#each generic_type$ bounds)) ")")) -(def: (class_decl$ (open "[0]")) +(def (class_decl$ (open "[0]")) (-> Class_Declaration JVM_Code) (format "(" (safe #class_name) " " (spaced (list#each type_param$ #class_params)) ")")) -(def: (super_class_decl$ (open "[0]")) +(def (super_class_decl$ (open "[0]")) (-> Super_Class_Decl JVM_Code) (format "(" (safe #super_class_name) " " (spaced (list#each generic_type$ #super_class_params)) ")")) -(def: (method_decl$ [[name pm anns] method_decl]) +(def (method_decl$ [[name pm anns] method_decl]) (-> [Member_Declaration MethodDecl] JVM_Code) (let [(open "[0]") method_decl] (with_parens @@ -1059,14 +1059,14 @@ (generic_type$ #method_output)) )))) -(def: (state_modifier$ sm) +(def (state_modifier$ sm) (-> State JVM_Code) (case sm {#VolatileS} "volatile" {#FinalS} "final" {#DefaultS} "default")) -(def: (field_decl$ [[name pm anns] field]) +(def (field_decl$ [[name pm anns] field]) (-> [Member_Declaration FieldDecl] JVM_Code) (case field {#ConstantField class value} @@ -1087,17 +1087,17 @@ )) )) -(def: (arg_decl$ [name type]) +(def (arg_decl$ [name type]) (-> ArgDecl JVM_Code) (with_parens (spaced (list name (generic_type$ type))))) -(def: (constructor_arg$ [class term]) +(def (constructor_arg$ [class term]) (-> ConstructorArg JVM_Code) (with_brackets (spaced (list (generic_type$ class) (code.format term))))) -(def: (method_def$ replacer super_class [[name pm anns] method_def]) +(def (method_def$ replacer super_class [[name pm anns] method_def]) (-> (-> Code Code) Super_Class_Decl [Member_Declaration Method_Definition] JVM_Code) (case method_def {#ConstructorMethod strict_fp? type_vars arg_decls constructor_args body exs} @@ -1192,17 +1192,17 @@ (generic_type$ return_type)))) )) -(def: (complete_call$ g!obj [method args]) +(def (complete_call$ g!obj [method args]) (-> Code Partial_Call Code) (` ((~ (code.symbol method)) (~+ args) (~ g!obj)))) ... [Syntax] -(def: object_super_class +(def object_super_class Super_Class_Decl [#super_class_name "java/lang/Object" #super_class_params (list)]) -(def: .public class +(def .public class (syntax (_ [im inheritance_modifier^ class_decl ..class_decl^ .let [full_class_name (product.left class_decl)] @@ -1232,7 +1232,7 @@ (with_brackets (spaced (list#each (method_def$ replacer super) methods))))))]] (in (list (` ((~ (code.text def_code))))))))) -(def: .public interface +(def .public interface (syntax (_ [class_decl ..class_decl^ .let [class_vars (product.right class_decl)] supers (<>.else (list) @@ -1246,7 +1246,7 @@ (spaced (list#each method_decl$ members)))))] (in (list (` ((~ (code.text def_code))))))))) -(def: .public object +(def .public object (syntax (_ [class_vars (<code>.tuple (<>.some ..type_param^)) super (<>.else object_super_class (..super_class_decl^ class_vars)) @@ -1261,15 +1261,15 @@ (with_brackets (spaced (list#each (method_def$ function.identity super) methods))))))] (in (list (` ((~ (code.text def_code))))))))) -(def: .public null +(def .public null (syntax (_ []) (in (list (` ("jvm object null")))))) -(def: .public (null? obj) +(def .public (null? obj) (-> (Primitive "java.lang.Object") Bit) ("jvm object null?" obj)) -(def: .public ??? +(def .public ??? (syntax (_ [expr <code>.any]) (with_symbols [g!temp] (in (list (` (let [(~ g!temp) (~ expr)] @@ -1277,7 +1277,7 @@ {.#None} {.#Some (~ g!temp)})))))))) -(def: .public !!! +(def .public !!! (syntax (_ [expr <code>.any]) (with_symbols [g!value] (in (list (` (.case (~ expr) @@ -1287,7 +1287,7 @@ {.#None} ("jvm object null")))))))) -(def: .public as +(def .public as (syntax (_ [class (..generic_type^ (list)) unchecked (<>.maybe <code>.any)]) (with_symbols [g!_ g!unchecked] @@ -1310,12 +1310,12 @@ (~ check_code)))))) ))))) -(def: .public synchronized +(def .public synchronized (syntax (_ [lock <code>.any body <code>.any]) (in (list (` ("jvm object synchronized" (~ lock) (~ body))))))) -(def: .public do_to +(def .public do_to (syntax (_ [obj <code>.any methods (<>.some partial_call^)]) (with_symbols [g!obj] @@ -1323,17 +1323,17 @@ (exec (~+ (list#each (complete_call$ g!obj) methods)) (~ g!obj))))))))) -(def: (class_import$ [full_name params]) +(def (class_import$ [full_name params]) (-> Class_Declaration Code) (let [params' (list#each (|>> product.left code.local) params)] (template.with_locals [g!_] - (` (def: (~ (code.symbol ["" full_name])) + (` (def (~ (code.symbol ["" full_name])) Type (All ((~ (' g!_)) (~+ params')) (Primitive (~ (code.text (safe full_name))) [(~+ params')]))))))) -(def: (member_type_vars class_tvars member) +(def (member_type_vars class_tvars member) (-> (List Type_Parameter) Import_Member_Declaration (List Type_Parameter)) (case member {#ConstructorDecl [commons _]} @@ -1350,7 +1350,7 @@ _ class_tvars)) -(def: (member_def_arg_bindings type_params class member) +(def (member_def_arg_bindings type_params class member) (-> (List Type_Parameter) Class_Declaration Import_Member_Declaration (Meta [(List [Bit Code]) (List Text) (List Code)])) (case member (^.or {#ConstructorDecl [commons _]} {#MethodDecl [commons _]}) @@ -1377,7 +1377,7 @@ _ (at meta.monad in [(list) (list) (list)]))) -(def: (decorate_return_maybe class member return_term) +(def (decorate_return_maybe class member return_term) (-> Class_Declaration Import_Member_Declaration Code Code) (case member (^.or {#ConstructorDecl [commons _]} {#MethodDecl [commons _]}) @@ -1396,7 +1396,7 @@ return_term)) (with_template [<name> <tag> <term_trans>] - [(def: (<name> member return_term) + [(def (<name> member return_term) (-> Import_Member_Declaration Code Code) (case member (^.or {#ConstructorDecl [commons _]} {#MethodDecl [commons _]}) @@ -1411,18 +1411,18 @@ [decorate_return_io #import_member_io? (` ((~! io.io) (~ return_term)))] ) -(def: (free_type_param? [name bounds]) +(def (free_type_param? [name bounds]) (-> Type_Parameter Bit) (case bounds {.#End} #1 _ #0)) -(def: (lux_type_parameter [name _]) +(def (lux_type_parameter [name _]) (-> Type_Parameter Code) (code.symbol ["" name])) (with_template [<name> <byte> <short> <int> <float>] - [(def: (<name> mode [class expression]) + [(def (<name> mode [class expression]) (-> Primitive_Mode [Text Code] Code) (case mode {#ManualPrM} @@ -1435,11 +1435,11 @@ [auto_convert_output byte_to_long short_to_long int_to_long float_to_double] ) -(def: (un_quote quoted) +(def (un_quote quoted) (-> Code Code) (` ((~' ~) (~ quoted)))) -(def: (jvm_extension_inputs mode classes inputs) +(def (jvm_extension_inputs mode classes inputs) (-> Primitive_Mode (List Text) (List [Bit Code]) (List Code)) (|> inputs (list#each (function (_ [maybe? input]) @@ -1449,19 +1449,19 @@ (list.zipped_2 classes) (list#each (auto_convert_input mode)))) -(def: (import_name format class member) +(def (import_name format class member) (-> Text Text Text Text) (|> format (text.replaced "[1]" class) (text.replaced "[0]" member))) -(def: syntax_inputs +(def syntax_inputs (-> (List Code) (List Code)) (|>> (list#each (function (_ name) (list name (` (~! <code>.any))))) list#conjoint)) -(def: (member_def_interop type_params kind class [arg_function_inputs arg_classes arg_types] member method_prefix import_format) +(def (member_def_interop type_params kind class [arg_function_inputs arg_classes arg_types] member method_prefix import_format) (-> (List Type_Parameter) Class_Kind Class_Declaration [(List [Bit Code]) (List Text) (List Code)] Import_Member_Declaration Text Text (Meta (List Code))) (let [[full_name class_tvars] class full_name (safe full_name) @@ -1485,7 +1485,7 @@ getter_interop (.is (-> Text Code) (function (_ name) (let [getter_name (code.symbol ["" (..import_name import_format method_prefix name)])] - (` (def: (~ getter_name) + (` (def (~ getter_name) (~ enum_type) ((~ (code.text (format "jvm getstatic" ":" full_name ":" name)))))))))]] (in (list#each getter_interop enum_members)))) @@ -1499,7 +1499,7 @@ (decorate_return_maybe class member) (decorate_return_try member) (decorate_return_io member))]] - (in (list (` (def: (~ def_name) + (in (list (` (def (~ def_name) ((~! syntax) ((~ def_name) [(~+ (syntax_inputs (list#each product.right arg_function_inputs)))]) ((~' in) (.list (.` (~ jvm_interop)))))))))) @@ -1533,7 +1533,7 @@ (decorate_return_maybe class member) (decorate_return_try member) (decorate_return_io member))]] - (in (list (` (def: (~ def_name) + (in (list (` (def (~ def_name) ((~! syntax) ((~ def_name) [(~+ (syntax_inputs (list#each product.right arg_function_inputs))) (~+ (syntax_inputs object_ast))]) ((~' in) (.list (.` (~ jvm_interop))))))))))) @@ -1569,7 +1569,7 @@ getter_body (if #import_field_setter? (` ((~! io.io) (~ getter_body))) getter_body)] - (in (` (def: (~ getter_name) + (in (` (def (~ getter_name) ((~! syntax) (~ getter_call) ((~' in) (.list (.` (~ getter_body)))))))))) setter_interop (.is (Meta (List Code)) @@ -1590,14 +1590,14 @@ (if #import_field_static? (list) (list (un_quote g!obj))))] - (in (list (` (def: (~ setter_name) + (in (list (` (def (~ setter_name) ((~! syntax) (~ setter_call) ((~' in) (.list (.` ((~! io.io) ((~ (code.text setter_command)) (~+ g!obj+) (~ setter_value))))))))))))) (in (list))))] (in (list.partial getter_interop setter_interop))) ))) -(def: (member_import$ type_params kind class [import_format member]) +(def (member_import$ type_params kind class [import_format member]) (-> (List Type_Parameter) Class_Kind Class_Declaration [Text Import_Member_Declaration] (Meta (List Code))) (let [[method_prefix _] class] (do meta.monad @@ -1607,15 +1607,15 @@ (type: (java/lang/Class a) (Primitive "java.lang.Class" [a])) -(def: interface? +(def interface? (All (_ a) (-> (java/lang/Class a) Bit)) (|>> "jvm invokevirtual:java.lang.Class:isInterface:")) -(def: (load_class class_name) +(def (load_class class_name) (-> Text (Try (java/lang/Class Any))) (try ("jvm invokestatic:java.lang.Class:forName:java.lang.String" class_name))) -(def: (class_kind [class_name _]) +(def (class_kind [class_name _]) (-> Class_Declaration (Meta Class_Kind)) (let [class_name (..safe class_name)] (case (..load_class class_name) @@ -1628,7 +1628,7 @@ (meta.failure (format "Cannot load class: " class_name text.new_line error))))) -(def: .public import +(def .public import (syntax (_ [class_decl ..class_decl^ import_format <code>.text members (<>.some (..import_member_decl^ (product.right class_decl)))]) @@ -1639,7 +1639,7 @@ (monad.each ! (member_import$ (product.right class_decl) kind class_decl)))] (in (list.partial (class_import$ class_decl) (list#conjoint =members)))))) -(def: .public array +(def .public array (syntax (_ [type (..generic_type^ (list)) size <code>.any]) (case type @@ -1658,11 +1658,11 @@ _ (in (list (` ("jvm anewarray" (~ (code.text (generic_type$ type))) (~ size)))))))) -(def: .public length +(def .public length (syntax (_ [array <code>.any]) (in (list (` ("jvm arraylength" (~ array))))))) -(def: (type_class_name type) +(def (type_class_name type) (-> Type (Meta Text)) (if (type#= Any type) (at meta.monad in "java.lang.Object") @@ -1684,7 +1684,7 @@ _ (meta.failure (format "Cannot convert to JvmType: " (type.format type)))))) -(def: .public read! +(def .public read! (syntax (_ [idx <code>.any array <code>.any]) (case array @@ -1713,7 +1713,7 @@ (in (list (` (let [(~ g!array) (~ array)] (..read! (~ idx) (~ g!array)))))))))) -(def: .public write! +(def .public write! (syntax (_ [idx <code>.any value <code>.any array <code>.any]) @@ -1743,14 +1743,14 @@ (in (list (` (let [(~ g!array) (~ array)] (..write! (~ idx) (~ value) (~ g!array)))))))))) -(def: .public class_for +(def .public class_for (syntax (_ [type (..generic_type^ (list))]) (in (list (` ("jvm object class" (~ (code.text (simple_class$ (list) type))))))))) -(def: .public type +(def .public type (syntax (_ [type (..generic_type^ (list))]) (in (list (..class_type {#ManualPrM} (list) type))))) -(def: .public is +(def .public is (template (is type term) [(.as type term)])) diff --git a/stdlib/source/library/lux/ffi.php.lux b/stdlib/source/library/lux/ffi.php.lux index f354972a3..36f828a48 100644 --- a/stdlib/source/library/lux/ffi.php.lux +++ b/stdlib/source/library/lux/ffi.php.lux @@ -48,7 +48,7 @@ (type: Nullable [Bit Code]) -(def: nullable +(def nullable (Parser Nullable) (let [token (' "?")] (<| (<>.and (<>.parses? (<code>.this token))) @@ -58,18 +58,18 @@ (type: Alias Text) -(def: alias +(def alias (Parser Alias) (<>.after (<code>.this (' "as")) <code>.local)) (type: Field [Bit Text (Maybe Alias) Nullable]) -(def: static! +(def static! (Parser Any) (<code>.this (' "static"))) -(def: field +(def field (Parser Field) (<code>.form (all <>.and (<>.parses? ..static!) @@ -77,7 +77,7 @@ (<>.maybe ..alias) ..nullable))) -(def: constant +(def constant (Parser Field) (<code>.form (all <>.and (<>#in true) @@ -102,7 +102,7 @@ {#Static Static_Method} {#Virtual Virtual_Method})) -(def: common_method +(def common_method (Parser Common_Method) (all <>.and <code>.local @@ -112,10 +112,10 @@ (<>.parses? (<code>.this (' "try"))) ..nullable)) -(def: static_method +(def static_method (<>.after ..static! ..common_method)) -(def: method +(def method (Parser Method) (<code>.form (<>.or ..static_method ..common_method))) @@ -125,26 +125,26 @@ {#Field Field} {#Method Method})) -(def: member +(def member (Parser Member) (all <>.or ..field ..method )) -(def: input_variables +(def input_variables (-> (List Nullable) (List [Bit Code])) (|>> list.enumeration (list#each (function (_ [idx [nullable? type]]) [nullable? (|> idx %.nat code.local)])))) -(def: (nullable_type [nullable? type]) +(def (nullable_type [nullable? type]) (-> Nullable Code) (if nullable? (` (.Maybe (~ type))) type)) -(def: (with_null g!temp [nullable? input]) +(def (with_null g!temp [nullable? input]) (-> Code [Bit Code] Code) (if nullable? (` (case (~ input) @@ -155,7 +155,7 @@ ("php object null"))) input)) -(def: (without_null g!temp [nullable? outputT] output) +(def (without_null g!temp [nullable? outputT] output) (-> Code Nullable Code Code) (if nullable? (` (let [(~ g!temp) (~ output)] @@ -173,7 +173,7 @@ {#Function Static_Method} {#Constant Field})) -(def: import +(def import (Parser Import) (all <>.or (all <>.and @@ -186,7 +186,7 @@ ..constant )) -(def: .public try +(def .public try (syntax (_ [expression <code>.any]) ... {.#doc (example (case (try (risky_computation input)) ... {.#Right success} @@ -196,34 +196,34 @@ ... (recover_from_failure error)))} (in (list (` ("lux try" ((~! io.io) (~ expression)))))))) -(def: (with_io with? without) +(def (with_io with? without) (-> Bit Code Code) (if with? (` ((~! io.io) (~ without))) without)) -(def: (io_type io? rawT) +(def (io_type io? rawT) (-> Bit Code Code) (if io? (` ((~! io.IO) (~ rawT))) rawT)) -(def: (with_try with? without_try) +(def (with_try with? without_try) (-> Bit Code Code) (if with? (` (..try (~ without_try))) without_try)) -(def: (try_type try? rawT) +(def (try_type try? rawT) (-> Bit Code Code) (if try? (` (.Either .Text (~ rawT))) rawT)) -(def: (make_function g!method g!temp source inputsT io? try? outputT) +(def (make_function g!method g!temp source inputsT io? try? outputT) (-> Code Code Code (List Nullable) Bit Bit Nullable Code) (let [g!inputs (input_variables inputsT)] - (` (def: ((~ g!method) + (` (def ((~ g!method) [(~+ (list#each product.right g!inputs))]) (-> [(~+ (list#each nullable_type inputsT))] (~ (|> (nullable_type outputT) @@ -237,7 +237,7 @@ (as ..Function (~ source)) (~+ (list#each (with_null g!temp) g!inputs))))))))))) -(def: .public import +(def .public import (syntax (_ [import ..import]) (with_symbols [g!temp] (case import @@ -258,12 +258,12 @@ {#Field [static? field alias fieldT]} (let [g!field (qualify (maybe.else field alias))] (if static? - (` (def: (~ g!field) + (` (def (~ g!field) ((~! syntax) ((~ g!field) []) (at (~! meta.monad) (~' in) (list (` (.as (~ (nullable_type fieldT)) ("php constant" (~ (code.text (%.format class "::" field))))))))))) - (` (def: ((~ g!field) (~ g!object)) + (` (def ((~ g!field) (~ g!object)) (-> (~ g!type) (~ (nullable_type fieldT))) (as_expected @@ -285,7 +285,7 @@ {#Virtual [method alias inputsT io? try? outputT]} (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify (maybe.else method alias))) + (` (def ((~ (qualify (maybe.else method alias))) [(~+ (list#each product.right g!inputs))] (~ g!object)) (-> [(~+ (list#each nullable_type inputsT))] @@ -316,7 +316,7 @@ {#Constant [_ name alias fieldT]} (let [imported (` ("php constant" (~ (code.text name)))) g!name (code.local (maybe.else name alias))] - (in (list (` (def: (~ g!name) + (in (list (` (def (~ g!name) ((~! syntax) ((~ g!name) []) (at (~! meta.monad) (~' in) (list (` (.as (~ (nullable_type fieldT)) (~ imported))))))))))) diff --git a/stdlib/source/library/lux/ffi.scm.lux b/stdlib/source/library/lux/ffi.scm.lux index 79b59264d..0b4918927 100644 --- a/stdlib/source/library/lux/ffi.scm.lux +++ b/stdlib/source/library/lux/ffi.scm.lux @@ -48,7 +48,7 @@ (type: Nilable [Bit Code]) -(def: nilable +(def nilable (Parser Nilable) (let [token (' "?")] (<| (<>.and (<>.parses? (<code>.this token))) @@ -58,18 +58,18 @@ (type: Alias Text) -(def: alias +(def alias (Parser Alias) (<>.after (<code>.this (' "as")) <code>.local)) (type: Field [Bit Text (Maybe Alias) Nilable]) -(def: static! +(def static! (Parser Any) (<code>.this (' "static"))) -(def: field +(def field (Parser Field) (<code>.form (all <>.and (<>.parses? ..static!) @@ -77,7 +77,7 @@ (<>.maybe ..alias) ..nilable))) -(def: constant +(def constant (Parser Field) (<code>.form (all <>.and (<>#in true) @@ -94,7 +94,7 @@ #try? Bit #output Nilable])) -(def: common_method +(def common_method (Parser Common_Method) (all <>.and <code>.local @@ -104,19 +104,19 @@ (<>.parses? (<code>.this (' "try"))) ..nilable)) -(def: input_variables +(def input_variables (-> (List Nilable) (List [Bit Code])) (|>> list.enumeration (list#each (function (_ [idx [nilable? type]]) [nilable? (|> idx %.nat code.local)])))) -(def: (nilable_type [nilable? type]) +(def (nilable_type [nilable? type]) (-> Nilable Code) (if nilable? (` (.Maybe (~ type))) type)) -(def: (with_nil g!temp [nilable? input]) +(def (with_nil g!temp [nilable? input]) (-> Code [Bit Code] Code) (if nilable? (` (case (~ input) @@ -127,7 +127,7 @@ ("scheme object nil"))) input)) -(def: (without_nil g!temp [nilable? outputT] output) +(def (without_nil g!temp [nilable? outputT] output) (-> Code Nilable Code Code) (if nilable? (` (let [(~ g!temp) (~ output)] @@ -144,14 +144,14 @@ {#Function Common_Method} {#Constant Field})) -(def: import +(def import (Parser Import) (all <>.or (<code>.form ..common_method) ..constant )) -(def: .public try +(def .public try (syntax (_ [expression <code>.any]) ... {.#doc (example (case (try (risky_computation input)) ... {.#Right success} @@ -161,34 +161,34 @@ ... (recover_from_failure error)))} (in (list (` ("lux try" ((~! io.io) (~ expression)))))))) -(def: (with_io with? without) +(def (with_io with? without) (-> Bit Code Code) (if with? (` ((~! io.io) (~ without))) without)) -(def: (io_type io? rawT) +(def (io_type io? rawT) (-> Bit Code Code) (if io? (` ((~! io.IO) (~ rawT))) rawT)) -(def: (with_try with? without_try) +(def (with_try with? without_try) (-> Bit Code Code) (if with? (` (..try (~ without_try))) without_try)) -(def: (try_type try? rawT) +(def (try_type try? rawT) (-> Bit Code Code) (if try? (` (.Either .Text (~ rawT))) rawT)) -(def: (make_function g!method g!temp source inputsT io? try? outputT) +(def (make_function g!method g!temp source inputsT io? try? outputT) (-> Code Code Code (List Nilable) Bit Bit Nilable Code) (let [g!inputs (input_variables inputsT)] - (` (def: ((~ g!method) + (` (def ((~ g!method) [(~+ (list#each product.right g!inputs))]) (-> [(~+ (list#each nilable_type inputsT))] (~ (|> (nilable_type outputT) @@ -202,7 +202,7 @@ (as ..Function (~ source)) (~+ (list#each (with_nil g!temp) g!inputs))))))))))) -(def: .public import +(def .public import (syntax (_ [import ..import]) (with_symbols [g!temp] (case import @@ -219,7 +219,7 @@ {#Constant [_ name alias fieldT]} (let [imported (` ("scheme constant" (~ (code.text name)))) g!name (code.local (maybe.else name alias))] - (in (list (` (def: (~ g!name) + (in (list (` (def (~ g!name) ((~! syntax) ((~ g!name) []) (at (~! meta.monad) (~' in) (list (` (.as (~ (nilable_type fieldT)) (~ imported))))))))))) diff --git a/stdlib/source/library/lux/ffi/export.js.lux b/stdlib/source/library/lux/ffi/export.js.lux index d121509d5..001e58022 100644 --- a/stdlib/source/library/lux/ffi/export.js.lux +++ b/stdlib/source/library/lux/ffi/export.js.lux @@ -36,7 +36,7 @@ [analysis ["[0]" type]]]]]]]]) -(def: definition +(def definition (-> Code (Meta [Text Code])) (|>> (list) (<code>.result (<| <code>.form @@ -85,7 +85,7 @@ (generation.log! (%.format "Export " (%.text name)))))] (in directive.no_requirements))) - (def: .public export + (def .public export (syntax (_ [exports (<>.many <code>.any)]) (let [! meta.monad] (|> exports diff --git a/stdlib/source/library/lux/ffi/export.jvm.lux b/stdlib/source/library/lux/ffi/export.jvm.lux index ed68b06d6..402c8b8da 100644 --- a/stdlib/source/library/lux/ffi/export.jvm.lux +++ b/stdlib/source/library/lux/ffi/export.jvm.lux @@ -18,7 +18,7 @@ #type Code #term Code])) -(def: (api of) +(def (api of) (All (_ of) (-> (Parser of) (Parser (API of)))) (<code>.form (all <>.and @@ -30,7 +30,7 @@ (type: Constant Text) -(def: constant +(def constant (Parser Constant) <code>.local) @@ -40,7 +40,7 @@ #name Text #requirements (List [Text Code])])) -(def: function +(def function (Parser Function) (<code>.form (all <>.and @@ -57,14 +57,14 @@ {#Constant (API Constant)} {#Function (API Function)})) -(def: exportP +(def exportP (Parser Export) (all <>.or (..api ..constant) (..api ..function) )) -(def: .public export +(def .public export (syntax (_ [api <code>.local exports (<>.many ..exportP)]) (let [initialization (is (List (API Constant)) diff --git a/stdlib/source/library/lux/ffi/export.lua.lux b/stdlib/source/library/lux/ffi/export.lua.lux index 679c0e50d..2f4f8345e 100644 --- a/stdlib/source/library/lux/ffi/export.lua.lux +++ b/stdlib/source/library/lux/ffi/export.lua.lux @@ -36,7 +36,7 @@ [analysis ["[0]" type]]]]]]]]) -(def: definition +(def definition (-> Code (Meta [Text Code])) (|>> (list) (<code>.result (<| <code>.form @@ -101,7 +101,7 @@ (generation.log! (%.format "Export " (%.text name)))))] (in directive.no_requirements))) - (def: .public export + (def .public export (syntax (_ [exports (<>.many <code>.any)]) (let [! meta.monad] (|> exports diff --git a/stdlib/source/library/lux/ffi/export.py.lux b/stdlib/source/library/lux/ffi/export.py.lux index 6c0356abb..4ffa40ba8 100644 --- a/stdlib/source/library/lux/ffi/export.py.lux +++ b/stdlib/source/library/lux/ffi/export.py.lux @@ -36,7 +36,7 @@ [analysis ["[0]" type]]]]]]]]) -(def: definition +(def definition (-> Code (Meta [Text Code])) (|>> (list) (<code>.result (<| <code>.form @@ -78,7 +78,7 @@ (generation.log! (%.format "Export " (%.text name)))))] (in directive.no_requirements))) - (def: .public export + (def .public export (syntax (_ [exports (<>.many <code>.any)]) (let [! meta.monad] (|> exports diff --git a/stdlib/source/library/lux/ffi/export.rb.lux b/stdlib/source/library/lux/ffi/export.rb.lux index 16bc77b68..633164c92 100644 --- a/stdlib/source/library/lux/ffi/export.rb.lux +++ b/stdlib/source/library/lux/ffi/export.rb.lux @@ -38,12 +38,12 @@ ["[0]" analysis ["[1]" type]]]]]]]]) -(def: upper! (<text>.one_of! "ABCDEFGHIJKLMNOPQRSTUVWXYZ")) -(def: lower! (<text>.one_of! "abcdefghijklmnopqrstuvwxyz")) -(def: decimal! (<text>.one_of! "0123456789")) -(def: sigil! (<text>.one_of! "_")) +(def upper! (<text>.one_of! "ABCDEFGHIJKLMNOPQRSTUVWXYZ")) +(def lower! (<text>.one_of! "abcdefghijklmnopqrstuvwxyz")) +(def decimal! (<text>.one_of! "0123456789")) +(def sigil! (<text>.one_of! "_")) -(def: tail! +(def tail! (all <>.either ..upper! ..lower! @@ -52,7 +52,7 @@ )) (with_template [<name> <head>] - [(def: <name> + [(def <name> (Parser Text) (<| <text>.slice (<text>.and! <head>) @@ -68,13 +68,13 @@ {#Method Text} {#Global Text})) -(def: name +(def name (Parser Name) (<>.or ..method (<>.either ..global ..constant))) -(def: definition +(def definition (-> Code (Meta [Name Code])) (|>> (list) (<code>.result (<| <code>.form @@ -127,7 +127,7 @@ (generation.log! (%.format "Export " (%.text name)))))] (in directive.no_requirements))) - (def: .public export + (def .public export (syntax (_ [exports (<>.many <code>.any)]) (let [! meta.monad] (|> exports diff --git a/stdlib/source/library/lux/ffi/node_js.js.lux b/stdlib/source/library/lux/ffi/node_js.js.lux index 27d69787d..fb507fca0 100644 --- a/stdlib/source/library/lux/ffi/node_js.js.lux +++ b/stdlib/source/library/lux/ffi/node_js.js.lux @@ -7,7 +7,7 @@ ["[0]" maybe (.open: "[1]#[0]" monoid functor)]]]]) (with_template [<name> <path>] - [(def: <name> + [(def <name> (Maybe (-> Text Any)) (ffi.global (-> Text Any) <path>))] @@ -16,7 +16,7 @@ [process_load [global process mainModule constructor _load]] ) -(def: .public (require module) +(def .public (require module) (-> Text (Maybe Any)) (maybe#each (function.on module) (all maybe#composite diff --git a/stdlib/source/library/lux/locale.lux b/stdlib/source/library/lux/locale.lux index 9587c8a8f..7b90f5386 100644 --- a/stdlib/source/library/lux/locale.lux +++ b/stdlib/source/library/lux/locale.lux @@ -19,10 +19,10 @@ (primitive .public Locale Text - (def: territory_separator "_") - (def: encoding_separator ".") + (def territory_separator "_") + (def encoding_separator ".") - (def: .public (locale language territory encoding) + (def .public (locale language territory encoding) (-> Language (Maybe Territory) (Maybe Encoding) Locale) (abstraction (format (language.code language) (|> territory @@ -32,15 +32,15 @@ (maybe#each (|>> encoding.name (format ..encoding_separator))) (maybe.else ""))))) - (def: .public code + (def .public code (-> Locale Text) (|>> representation)) - (def: .public hash + (def .public hash (Hash Locale) (at hash.functor each ..code text.hash)) - (def: .public equivalence + (def .public equivalence (Equivalence Locale) (at ..hash equivalence)) ) diff --git a/stdlib/source/library/lux/locale/language.lux b/stdlib/source/library/lux/locale/language.lux index 21930e92f..0e6379d57 100644 --- a/stdlib/source/library/lux/locale/language.lux +++ b/stdlib/source/library/lux/locale/language.lux @@ -18,7 +18,7 @@ #code Text]) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (-> Language Text) (|>> representation (the <tag>)))] @@ -29,12 +29,12 @@ (with_template [<bundle>] [(with_expansions [<bundle>' (template.spliced <bundle>)] (with_template [<code> <name> <definition> <alias>+] - [(def: .public <definition> + [(def .public <definition> Language (abstraction [#name <name> #code <code>])) (`` (with_template [<alias>] - [(def: .public <alias> + [(def .public <alias> Language <definition>)] @@ -556,19 +556,19 @@ ["zun" "Zuni" zuni []] ["zza" "Zaza; Dimili; Dimli; Kirdki; Kirmanjki; Zazaki" zaza [[dimili] [dimli] [kirdki] [kirmanjki] [zazaki]]]]]) - (def: .public equivalence + (def .public equivalence (Equivalence Language) (implementation - (def: (= reference sample) + (def (= reference sample) (same? reference sample)))) - (def: .public hash + (def .public hash (Hash Language) (implementation - (def: equivalence + (def equivalence ..equivalence) - (def: hash + (def hash (|>> ..code (at text.hash hash))))) ) diff --git a/stdlib/source/library/lux/locale/territory.lux b/stdlib/source/library/lux/locale/territory.lux index b31531412..9dfed05f9 100644 --- a/stdlib/source/library/lux/locale/territory.lux +++ b/stdlib/source/library/lux/locale/territory.lux @@ -20,7 +20,7 @@ #code Nat]) (with_template [<name> <field> <type>] - [(def: .public <name> + [(def .public <name> (-> Territory <type>) (|>> representation (the <field>)))] @@ -32,7 +32,7 @@ ) (with_template [<short> <long> <number> <name> <main> <neighbor>+] - [(def: .public <main> + [(def .public <main> Territory (abstraction [#name <name> #short <short> @@ -40,7 +40,7 @@ #code <number>])) (`` (with_template [<neighbor>] - [(def: .public <neighbor> Territory <main>)] + [(def .public <neighbor> Territory <main>)] (~~ (template.spliced <neighbor>+))))] @@ -295,18 +295,18 @@ ["ZW" "ZWE" 716 "Zimbabwe" zimbabwe []] ) - (def: .public equivalence + (def .public equivalence (Equivalence Territory) (implementation - (def: (= reference sample) + (def (= reference sample) (same? reference sample)))) - (def: .public hash + (def .public hash (Hash Territory) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: hash + (def hash (|>> representation (the #long) (at text.hash hash))))) diff --git a/stdlib/source/library/lux/macro.lux b/stdlib/source/library/lux/macro.lux index e7dda08c5..35d94cb88 100644 --- a/stdlib/source/library/lux/macro.lux +++ b/stdlib/source/library/lux/macro.lux @@ -18,7 +18,7 @@ ["[0]" location] ["[0]" symbol (.open: "[1]#[0]" codec)]]]]) -(def: .public (single_expansion syntax) +(def .public (single_expansion syntax) (-> Code (Meta (List Code))) (case syntax [_ {.#Form {.#Item [[_ {.#Symbol name}] args]}}] @@ -34,7 +34,7 @@ _ (at //.monad in (list syntax)))) -(def: .public (expansion syntax) +(def .public (expansion syntax) (-> Code (Meta (List Code))) (case syntax [_ {.#Form {.#Item [[_ {.#Symbol name}] args]}}] @@ -54,7 +54,7 @@ _ (at //.monad in (list syntax)))) -(def: .public (full_expansion syntax) +(def .public (full_expansion syntax) (-> Code (Meta (List Code))) (case syntax [_ {.#Form {.#Item [[_ {.#Symbol name}] args]}}] @@ -91,7 +91,7 @@ _ (at //.monad in (list syntax)))) -(def: .public (symbol prefix) +(def .public (symbol prefix) (-> Text (Meta Code)) (do //.monad [id //.seed] @@ -100,7 +100,7 @@ (all text#composite "__gensym__" prefix) [""] code.symbol)))) -(def: (local ast) +(def (local ast) (-> Code (Meta Text)) (case ast [_ {.#Symbol [_ name]}] @@ -109,13 +109,13 @@ _ (//.failure (text#composite "Code is not a local symbol: " (code.format ast))))) -(def: .public wrong_syntax_error +(def .public wrong_syntax_error (-> Symbol Text) (|>> symbol#encoded (text.prefix (text#composite "Wrong syntax for " text.\'')) (text.suffix (text#composite text.\'' ".")))) -(def: .public with_symbols +(def .public with_symbols (.macro (_ tokens) (case tokens (pattern (list [_ {.#Tuple symbols}] body)) @@ -131,7 +131,7 @@ _ (//.failure (..wrong_syntax_error (.symbol ..with_symbols)))))) -(def: .public (one_expansion token) +(def .public (one_expansion token) (-> Code (Meta Code)) (do //.monad [token+ (..expansion token)] @@ -143,7 +143,7 @@ (//.failure "Macro expanded to more than 1 element.")))) (with_template [<macro> <func>] - [(def: .public <macro> + [(def .public <macro> (.macro (_ tokens) (let [[module _] (.symbol .._) [_ short] (.symbol <macro>) @@ -179,7 +179,7 @@ [log_full_expansion! ..full_expansion] ) -(def: .public times +(def .public times (.macro (_ tokens) (case tokens (pattern (list.partial [_ {.#Nat times}] terms)) @@ -199,17 +199,17 @@ _ (//.failure (..wrong_syntax_error (.symbol ..times)))))) -(def: .public final +(def .public final (.macro (_ it) (let [! //.monad] (|> it (monad.each ! ..expansion) (at ! each list#conjoint))))) -(def: .public function +(def .public function (-> Macro Macro') (|>> (as Macro'))) -(def: .public macro +(def .public macro (-> Macro' Macro) (|>> (as Macro))) diff --git a/stdlib/source/library/lux/macro/code.lux b/stdlib/source/library/lux/macro/code.lux index 72b09aff4..53b0d826e 100644 --- a/stdlib/source/library/lux/macro/code.lux +++ b/stdlib/source/library/lux/macro/code.lux @@ -37,7 +37,7 @@ ... (Ann Location (Code' (Ann Location)))) (with_template [<name> <type> <tag>] - [(def: .public (<name> x) + [(def .public (<name> x) (-> <type> Code) [location.dummy {<tag> x}])] @@ -54,16 +54,16 @@ ) (with_template [<name> <tag>] - [(def: .public (<name> name) + [(def .public (<name> name) (-> Text Code) [location.dummy {<tag> ["" name]}])] [local .#Symbol]) -(def: .public equivalence +(def .public equivalence (Equivalence Code) (implementation - (def: (= x y) + (def (= x y) (case [x y] (^.with_template [<tag> <eq>] [[[_ {<tag> x'}] [_ {<tag> y'}]] @@ -86,7 +86,7 @@ _ false)))) -(def: .public (format ast) +(def .public (format ast) (-> Code Text) (case ast (^.with_template [<tag> <struct>] @@ -119,7 +119,7 @@ [.#Tuple "[" "]"]) )) -(def: .public (replaced original substitute ast) +(def .public (replaced original substitute ast) (-> Code Code Code Code) (if (at ..equivalence = original ast) substitute diff --git a/stdlib/source/library/lux/macro/local.lux b/stdlib/source/library/lux/macro/local.lux index 2d93ea1fc..3538cc454 100644 --- a/stdlib/source/library/lux/macro/local.lux +++ b/stdlib/source/library/lux/macro/local.lux @@ -35,7 +35,7 @@ [unknown_definition] ) -(def: (with_module name body) +(def (with_module name body) (All (_ a) (-> Text (-> Module (Try [Module a])) (Meta a))) (function (_ compiler) (case (|> compiler (the .#modules) (plist.value name)) @@ -51,7 +51,7 @@ {.#None} (exception.except ..unknown_module [name])))) -(def: (push_one [name macro]) +(def (push_one [name macro]) (-> [Symbol Macro] (Meta Any)) (do meta.monad [[module_name definition_name] (meta.normal name) @@ -68,7 +68,7 @@ {.#Some _} (exception.except ..cannot_shadow_definition [module_name definition_name])))))) -(def: (pop_one name) +(def (pop_one name) (-> Symbol (Meta Any)) (do meta.monad [[module_name definition_name] (meta.normal name) @@ -84,7 +84,7 @@ {.#None} (exception.except ..unknown_definition [module_name definition_name])))))) -(def: (pop_all macros self) +(def (pop_all macros self) (-> (List Symbol) Symbol Macro) ("lux macro" (function (_ _) @@ -99,7 +99,7 @@ {.#None} (list))))))) -(def: .public (push macros) +(def .public (push macros) (-> (List [Symbol Macro]) (Meta Code)) (do meta.monad [_ (monad.each meta.monad ..push_one macros) @@ -110,7 +110,7 @@ (..push_one [g!pop (..pop_all (list#each product.left macros) g!pop)]))] (in (` ((~ g!pop)))))) -(def: .public (with macros expression? body) +(def .public (with macros expression? body) (-> (List [Symbol Macro]) Bit Code (Meta (List Code))) (do [! meta.monad] [g!pop (..push macros)] @@ -123,7 +123,7 @@ (in (list body g!pop))))) -(def: .public let +(def .public let (syntax (_ [locals (<code>.tuple (<>.some (<>.and <code>.local <code>.any))) body <code>.any]) (do [! meta.monad] diff --git a/stdlib/source/library/lux/macro/pattern.lux b/stdlib/source/library/lux/macro/pattern.lux index 9e8e64d70..7408d86e2 100644 --- a/stdlib/source/library/lux/macro/pattern.lux +++ b/stdlib/source/library/lux/macro/pattern.lux @@ -2,10 +2,10 @@ [library [lux (.except or let with_template |> `)]]) -(def: partial_list +(def partial_list (`` ("lux in-module" (~~ (static .prelude)) .partial_list))) -(def: locally +(def locally (macro (_ tokens lux) (.let [[prelude _] (symbol ._)] (case tokens @@ -17,7 +17,7 @@ {.#Left ""})))) (.with_template [<name>] - [(def: <name> (..locally <name>))] + [(def <name> (..locally <name>))] [list#size] [list#composite] @@ -72,7 +72,7 @@ [frac$] ) -(def: .public or +(def .public or (macro (_ tokens) (case tokens (pattern (partial_list [_ {.#Form patterns}] body branches)) @@ -88,7 +88,7 @@ _ (failure (..wrong_syntax_error (symbol ..or)))))) -(def: .public with_template +(def .public with_template (macro (_ tokens) (case tokens (pattern (partial_list [_ {.#Form (list [_ {.#Tuple bindings}] @@ -118,7 +118,7 @@ _ (failure (..wrong_syntax_error (symbol ..with_template)))))) -(def: .public multi +(def .public multi (macro (_ tokens) (case tokens (pattern (partial_list [_meta {.#Form levels}] body next_branches)) @@ -150,7 +150,7 @@ _ (failure (..wrong_syntax_error (symbol ..multi)))))) -(def: .public let +(def .public let (macro (_ tokens) (case tokens (pattern (partial_list [_meta {.#Form (list [_ {.#Symbol ["" name]}] pattern)}] body branches)) @@ -162,7 +162,7 @@ _ (failure (..wrong_syntax_error (symbol ..let)))))) -(def: .public |> +(def .public |> (macro (_ tokens) (case tokens (pattern (partial_list [_meta {.#Form (list [_ {.#Symbol ["" name]}] [_ {.#Tuple steps}])}] body branches)) @@ -175,11 +175,11 @@ _ (failure (..wrong_syntax_error (symbol ..|>)))))) -(def: (name$ [module name]) +(def (name$ [module name]) (-> Symbol Code) (.` [(~ (text$ module)) (~ (text$ name))])) -(def: (untemplated_partial_list last inits) +(def (untemplated_partial_list last inits) (-> Code (List Code) Code) (case inits {.#End} @@ -189,7 +189,7 @@ (.` {.#Item (~ init) (~ (untemplated_partial_list last inits'))}))) (.with_template [<tag> <name>] - [(def: (<name> g!meta untemplated_pattern elems) + [(def (<name> g!meta untemplated_pattern elems) (-> Code (-> Code (Meta Code)) (-> (List Code) (Meta Code))) (case (list#reversed elems) @@ -209,7 +209,7 @@ [.#Tuple untemplated_tuple] ) -(def: (untemplated_pattern pattern) +(def (untemplated_pattern pattern) (-> Code (Meta Code)) (do meta#monad [g!meta (..generated_symbol "g!meta")] @@ -239,7 +239,7 @@ [.#Tuple ..untemplated_tuple]) ))) -(def: .public ` +(def .public ` (macro (_ tokens) (case tokens (pattern (partial_list [_meta {.#Form (list template)}] body branches)) diff --git a/stdlib/source/library/lux/macro/syntax.lux b/stdlib/source/library/lux/macro/syntax.lux index 8c1a54eba..94ea416fe 100644 --- a/stdlib/source/library/lux/macro/syntax.lux +++ b/stdlib/source/library/lux/macro/syntax.lux @@ -24,7 +24,7 @@ ["[0]" / ["[1][0]" export]]) -(def: (self_documenting binding parser) +(def (self_documenting binding parser) (All (_ a) (-> Code (Parser a) (Parser a))) (function (_ tokens) (case (parser tokens) @@ -36,13 +36,13 @@ "Failed to parse: " (code.format binding) text.new_line error)}))) -(def: (un_paired pairs) +(def (un_paired pairs) (All (_ a) (-> (List [a a]) (List a))) (case pairs {.#End} {.#End} {.#Item [[x y] pairs']} (list.partial x y (un_paired pairs')))) -(def: syntaxP +(def syntaxP (Parser [[Text (Maybe Text) (List Code)] Code]) (all <>.and (</>.form (all <>.and @@ -51,7 +51,7 @@ (</>.tuple (<>.some </>.any)))) </>.any)) -(def: .public syntax +(def .public syntax (macro (_ tokens) (case (</>.result ..syntaxP tokens) {try.#Success [[name g!state args] body]} diff --git a/stdlib/source/library/lux/macro/syntax/check.lux b/stdlib/source/library/lux/macro/syntax/check.lux index 893f9bc88..774c59e17 100644 --- a/stdlib/source/library/lux/macro/syntax/check.lux +++ b/stdlib/source/library/lux/macro/syntax/check.lux @@ -14,7 +14,7 @@ [macro ["[0]" code]]]]) -(def: extension +(def extension "lux check") (type: .public Check @@ -22,20 +22,20 @@ [#type Code #value Code])) -(def: .public equivalence +(def .public equivalence (Equivalence Check) (all product.equivalence code.equivalence code.equivalence )) -(def: .public (format (open "_[0]")) +(def .public (format (open "_[0]")) (-> Check Code) (` ((~ (code.text ..extension)) (~ _#type) (~ _#value)))) -(def: .public parser +(def .public parser (Parser Check) (<| <code>.form (<>.after (<code>.this_text ..extension)) diff --git a/stdlib/source/library/lux/macro/syntax/declaration.lux b/stdlib/source/library/lux/macro/syntax/declaration.lux index b0c23e135..d5e7ab443 100644 --- a/stdlib/source/library/lux/macro/syntax/declaration.lux +++ b/stdlib/source/library/lux/macro/syntax/declaration.lux @@ -19,21 +19,21 @@ [#name Text #arguments (List Text)])) -(def: .public equivalence +(def .public equivalence (Equivalence Declaration) (all product.equivalence text.equivalence (list.equivalence text.equivalence) )) -(def: .public parser +(def .public parser (Parser Declaration) (<>.either (<>.and <code>.local (<>#in (list))) (<code>.form (<>.and <code>.local (<>.some <code>.local))))) -(def: .public (format value) +(def .public (format value) (-> Declaration Code) (let [g!name (code.local (the #name value))] (case (the #arguments value) diff --git a/stdlib/source/library/lux/macro/syntax/definition.lux b/stdlib/source/library/lux/macro/syntax/definition.lux index 7bc9a964f..02df002bb 100644 --- a/stdlib/source/library/lux/macro/syntax/definition.lux +++ b/stdlib/source/library/lux/macro/syntax/definition.lux @@ -30,7 +30,7 @@ Code) #export? Bit])) -(def: .public equivalence +(def .public equivalence (Equivalence Definition) (all product.equivalence text.equivalence @@ -41,16 +41,16 @@ bit.equivalence )) -(def: extension +(def extension "lux def") -(def: dummy +(def dummy Code (` [.#module (~ (code.text (the .#module location.dummy))) .#line (~ (code.nat (the .#line location.dummy))) .#column (~ (code.nat (the .#column location.dummy)))])) -(def: .public (format (open "_[0]")) +(def .public (format (open "_[0]")) (-> Definition Code) (` ((~ (code.text ..extension)) (~ (code.local _#name)) @@ -62,7 +62,7 @@ value)) (~ (code.bit _#export?))))) -(def: .public (parser compiler) +(def .public (parser compiler) (-> Lux (Parser Definition)) (do [! <>.monad] [raw <code>.any @@ -84,7 +84,7 @@ (exception.report "Definition" (%.code (..format definition)))) -(def: .public (typed compiler) +(def .public (typed compiler) (-> Lux (Parser Definition)) (do <>.monad [definition (..parser compiler) diff --git a/stdlib/source/library/lux/macro/syntax/export.lux b/stdlib/source/library/lux/macro/syntax/export.lux index 323b9d3b5..0aedf4a21 100644 --- a/stdlib/source/library/lux/macro/syntax/export.lux +++ b/stdlib/source/library/lux/macro/syntax/export.lux @@ -9,11 +9,11 @@ [macro ["^" pattern]]]]) -(def: .public default_policy +(def .public default_policy Code (` .private)) -(def: policy +(def policy (Parser Code) (do [! <>.monad] [candidate <code>.next] @@ -30,6 +30,6 @@ _ (in default_policy)))) -(def: .public parser +(def .public parser (All (_ a) (-> (Parser a) (Parser [Code a]))) (<>.and ..policy)) diff --git a/stdlib/source/library/lux/macro/syntax/input.lux b/stdlib/source/library/lux/macro/syntax/input.lux index bdac8cad3..bc6622bc6 100644 --- a/stdlib/source/library/lux/macro/syntax/input.lux +++ b/stdlib/source/library/lux/macro/syntax/input.lux @@ -18,14 +18,14 @@ [#binding Code #type Code])) -(def: .public equivalence +(def .public equivalence (Equivalence Input) (all product.equivalence code.equivalence code.equivalence )) -(def: .public format +(def .public format (-> (List Input) Code) (|>> (list#each (function (_ value) (list (the #binding value) @@ -33,7 +33,7 @@ list#conjoint code.tuple)) -(def: .public parser +(def .public parser (Parser (List Input)) (<| <code>.tuple <>.some diff --git a/stdlib/source/library/lux/macro/syntax/type/variable.lux b/stdlib/source/library/lux/macro/syntax/type/variable.lux index ca141f0bd..fb0f0db06 100644 --- a/stdlib/source/library/lux/macro/syntax/type/variable.lux +++ b/stdlib/source/library/lux/macro/syntax/type/variable.lux @@ -14,14 +14,14 @@ (type: .public Variable Text) -(def: .public equivalence +(def .public equivalence (Equivalence Variable) text.equivalence) -(def: .public format +(def .public format (-> Variable Code) code.local) -(def: .public parser +(def .public parser (Parser Variable) <code>.local) diff --git a/stdlib/source/library/lux/macro/template.lux b/stdlib/source/library/lux/macro/template.lux index 2251051d5..750f4fb8b 100644 --- a/stdlib/source/library/lux/macro/template.lux +++ b/stdlib/source/library/lux/macro/template.lux @@ -28,15 +28,15 @@ ["[0]" code] ["[0]" local]]) -(def: .public spliced +(def .public spliced (syntax (_ [parts (<code>.tuple (<>.some <code>.any))]) (in parts))) -(def: .public amount +(def .public amount (syntax (_ [parts (<code>.tuple (<>.some <code>.any))]) (in (list (code.nat (list.size parts)))))) -(def: .public with_locals +(def .public with_locals (syntax (_ [locals (<code>.tuple (<>.some <code>.local)) body <code>.any]) (do [! meta.monad] @@ -49,7 +49,7 @@ list#conjoint))] (~ body)))))))) -(def: (symbol_side module_side? parser) +(def (symbol_side module_side? parser) (-> Bit (Parser Symbol) (Parser Text)) (do <>.monad [[module short] parser] @@ -59,7 +59,7 @@ _ module) short)))) -(def: (snippet module_side?) +(def (snippet module_side?) (-> Bit (Parser Text)) (.let [full_symbol (..symbol_side module_side? <code>.symbol)] (all <>.either @@ -75,16 +75,16 @@ (<>#each frac#encoded <code>.frac) ))) -(def: (part module_side?) +(def (part module_side?) (-> Bit (Parser (List Text))) (<code>.tuple (<>.many (..snippet module_side?)))) -(def: .public text +(def .public text (syntax (_ [simple (..part false)]) (in (list (|> simple (text.interposed "") code.text))))) (with_template [<name> <simple> <complex>] - [(def: .public <name> + [(def .public <name> (syntax (_ [name (<>.or (<>.and (..part true) (..part false)) (..part false))]) (case name @@ -101,7 +101,7 @@ (type: Environment (Dictionary Text Code)) -(def: (applied env template) +(def (applied env template) (-> Environment Code Code) (case template [_ {.#Symbol "" name}] @@ -134,7 +134,7 @@ "Expected" (at nat.decimal encoded expected) "Actual" (at nat.decimal encoded actual))) -(def: (macro (open "_[0]")) +(def (macro (open "_[0]")) (-> Local Macro) ("lux macro" (function (_ inputs compiler) @@ -147,7 +147,7 @@ {.#Right [compiler (list#each (..applied environment) _#template)]}) (exception.except ..irregular_arguments [parameters_amount inputs_amount])))))) -(def: local +(def local (Parser Local) (do <>.monad [[name parameters] (<code>.form (<>.and <code>.local @@ -158,7 +158,7 @@ #template template]))) ... TODO: Get rid of this (and any local definitions it depends on) once the bootstrapping compiler is gone. -(def: .public let +(def .public let (syntax (_ [locals (<code>.tuple (<>.some ..local)) body <code>.any]) (do meta.monad diff --git a/stdlib/source/library/lux/math.lux b/stdlib/source/library/lux/math.lux index 6bd87711b..913a5c1b0 100644 --- a/stdlib/source/library/lux/math.lux +++ b/stdlib/source/library/lux/math.lux @@ -44,7 +44,7 @@ (exception.report "Type" (%.type type))) -(def: (composite phase archive <+> last prevs) +(def (composite phase archive <+> last prevs) (-> Phase Archive Code Analysis (List Analysis) (Operation Analysis)) (case <+> [_ {.#Text $}] @@ -109,7 +109,7 @@ ... else (phase.except ..no_arithmetic_for [:it:]))))))) - (def: .public <name> + (def .public <name> (syntax (_ [operands (<>.some <code>.any)]) (in (list (` (<extension> (~+ operands)))))))))] @@ -162,7 +162,7 @@ ... else (phase.except ..no_arithmetic_for [:it:])))))) - (def: .public <name> + (def .public <name> (syntax (_ [left <code>.any right <code>.any]) (in (list (` (<extension> (~ left) (~ right)))))))))] @@ -218,7 +218,7 @@ ... else (phase.except ..no_arithmetic_for [:it:])))))) - (def: .public <name> + (def .public <name> (syntax (_ [left <code>.any right <code>.any]) (in (list (` (<extension> (~ left) (~ right)))))))))] diff --git a/stdlib/source/library/lux/math/infix.lux b/stdlib/source/library/lux/math/infix.lux index bb3039035..2a6456e4f 100644 --- a/stdlib/source/library/lux/math/infix.lux +++ b/stdlib/source/library/lux/math/infix.lux @@ -26,7 +26,7 @@ {#Unary Code Infix} {#Binary Infix Code Infix}))) -(def: literal +(def literal (Parser Code) (all <>.either (<>#each code.bit <code>.bit) @@ -37,7 +37,7 @@ (<>#each code.text <code>.text) (<>#each code.symbol <code>.symbol))) -(def: expression +(def expression (Parser Infix) (<| <>.rec (function (_ expression)) (all <>.or @@ -55,7 +55,7 @@ steps)))) ))) -(def: (prefix infix) +(def (prefix infix) (-> Infix Code) (case infix {#Const value} @@ -70,6 +70,6 @@ {#Binary left op right} (` ((~ op) (~ (prefix right)) (~ (prefix left)))))) -(def: .public infix +(def .public infix (syntax (_ [expr ..expression]) (in (list (..prefix expr))))) diff --git a/stdlib/source/library/lux/math/logic/continuous.lux b/stdlib/source/library/lux/math/logic/continuous.lux index 195601894..738497496 100644 --- a/stdlib/source/library/lux/math/logic/continuous.lux +++ b/stdlib/source/library/lux/math/logic/continuous.lux @@ -8,34 +8,34 @@ [number ["/" rev (.open: "[1]#[0]" interval)]]]]]) -(def: .public false Rev /#bottom) -(def: .public true Rev /#top) +(def .public false Rev /#bottom) +(def .public true Rev /#top) (with_template [<name> <chooser> <monoid> <identity>] - [(def: .public <name> + [(def .public <name> (-> Rev Rev Rev) <chooser>) - (def: .public <monoid> + (def .public <monoid> (Monoid Rev) (implementation - (def: identity <identity>) - (def: composite <name>)))] + (def identity <identity>) + (def composite <name>)))] [or /.max disjunction ..false] [and /.min conjunction ..true] ) -(def: .public (not input) +(def .public (not input) (-> Rev Rev) (/.- input ..true)) -(def: .public (implies consequent antecedent) +(def .public (implies consequent antecedent) (-> Rev Rev Rev) (or (not antecedent) consequent)) -(def: .public (= left right) +(def .public (= left right) (-> Rev Rev Rev) (and (or (not left) right) (or left (not right)))) diff --git a/stdlib/source/library/lux/math/logic/fuzzy.lux b/stdlib/source/library/lux/math/logic/fuzzy.lux index d21962ea6..6d337604e 100644 --- a/stdlib/source/library/lux/math/logic/fuzzy.lux +++ b/stdlib/source/library/lux/math/logic/fuzzy.lux @@ -19,14 +19,14 @@ (type: .public (Fuzzy a) (-> a Rev)) -(def: .public functor +(def .public functor (contravariant.Functor Fuzzy) (implementation - (def: (each f fb) + (def (each f fb) (|>> f fb)))) (with_template [<name> <verdict>] - [(def: .public <name> + [(def .public <name> Fuzzy (function (_ _) <verdict>))] @@ -35,12 +35,12 @@ [full //.true] ) -(def: .public (membership set elem) +(def .public (membership set elem) (All (_ a) (-> (Fuzzy a) a Rev)) (set elem)) (with_template [<set_composition> <membership_composition>] - [(def: .public (<set_composition> left right) + [(def .public (<set_composition> left right) (All (_ a) (-> (Fuzzy a) (Fuzzy a) (Fuzzy a))) (function (_ elem) (<membership_composition> (left elem) @@ -50,31 +50,31 @@ [intersection //.and] ) -(def: .public (complement set) +(def .public (complement set) (All (_ a) (-> (Fuzzy a) (Fuzzy a))) (|>> set //.not)) -(def: .public (difference sub base) +(def .public (difference sub base) (All (_ a) (-> (Fuzzy a) (Fuzzy a) (Fuzzy a))) (..intersection (..complement sub) base)) -(def: .public (of_predicate predicate) +(def .public (of_predicate predicate) (All (_ a) (-> (Predicate a) (Fuzzy a))) (function (_ elem) (if (predicate elem) //.true //.false))) -(def: .public (predicate treshold set) +(def .public (predicate treshold set) (All (_ a) (-> Rev (Fuzzy a) (Predicate a))) (function (_ elem) (/.> treshold (set elem)))) -(def: .public of_set +(def .public of_set (All (_ a) (-> (Set a) (Fuzzy a))) (|>> set.member? ..of_predicate)) -(def: (ascending from to) +(def (ascending from to) (-> Rev Rev (Fuzzy Rev)) (let [measure (/.- from to)] (function (_ elem) @@ -91,23 +91,23 @@ ... above //.true)))) -(def: (descending from to) +(def (descending from to) (-> Rev Rev (Fuzzy Rev)) (..complement (..ascending from to))) -(def: .public (gradient from to) +(def .public (gradient from to) (-> Rev Rev (Fuzzy Rev)) (if (/.< to from) (..ascending from to) (..descending from to))) -(def: !sort_2 +(def !sort_2 (template (_ <low> <high>) [(if (/.> <low> <high>) [<low> <high>] [<high> <low>])])) -(def: .public (triangle bottom middle top) +(def .public (triangle bottom middle top) (-> Rev Rev Rev (Fuzzy Rev)) (let [[low_0 high_0] (!sort_2 bottom middle) [bottom' high_1] (!sort_2 low_0 top) @@ -115,7 +115,7 @@ (..intersection (..ascending bottom' middle') (..descending middle' top')))) -(def: .public (trapezoid bottom middle_bottom middle_top top) +(def .public (trapezoid bottom middle_bottom middle_top top) (-> Rev Rev Rev Rev (Fuzzy Rev)) (let [[low_0 high_0] (!sort_2 bottom middle_bottom) [low_1 high_1] (!sort_2 middle_top top) @@ -125,7 +125,7 @@ (..intersection (..ascending bottom' middle_bottom') (..descending middle_top' top')))) -(def: .public (cut treshold set) +(def .public (cut treshold set) (All (_ a) (-> Rev (Fuzzy a) (Fuzzy a))) (function (_ elem) (let [membership (set elem)] diff --git a/stdlib/source/library/lux/math/modular.lux b/stdlib/source/library/lux/math/modular.lux index c12f2111d..183679ce8 100644 --- a/stdlib/source/library/lux/math/modular.lux +++ b/stdlib/source/library/lux/math/modular.lux @@ -31,13 +31,13 @@ [#modulus (Modulus m) #value Int]) - (def: .public (modular modulus value) + (def .public (modular modulus value) (All (_ %) (-> (Modulus %) Int (Mod %))) (abstraction [#modulus modulus #value (i.mod (//.divisor modulus) value)])) (with_template [<name> <type> <side>] - [(def: .public <name> + [(def .public <name> (All (_ %) (-> (Mod %) <type>)) (|>> representation <side>))] @@ -51,25 +51,25 @@ "Expected" (i#encoded (//.divisor modulus)) "Actual" (i#encoded parsed))) - (def: separator + (def separator " mod ") - (def: intL + (def intL (Parser Int) (<>.codec i.decimal (<text>.and (<text>.one_of "-+") (<text>.many <text>.decimal)))) - (def: .public (codec expected) + (def .public (codec expected) (All (_ %) (-> (Modulus %) (Codec Text (Mod %)))) (implementation - (def: (encoded modular) + (def (encoded modular) (let [[_ value] (representation modular)] (all text#composite (i#encoded value) ..separator (i#encoded (//.divisor expected))))) - (def: decoded + (def decoded (<text>.result (do <>.monad [[value _ actual] (all <>.and intL (<text>.this ..separator) intL) @@ -78,7 +78,7 @@ (in (..modular expected value))))))) (with_template [<name> <op>] - [(def: .public (<name> reference subject) + [(def .public (<name> reference subject) (All (_ %) (-> (Mod %) (Mod %) Bit)) (let [[_ reference] (representation reference) [_ subject] (representation subject)] @@ -91,19 +91,19 @@ [>= i.>=] ) - (def: .public equivalence + (def .public equivalence (All (_ %) (Equivalence (Mod %))) (implementation - (def: = ..=))) + (def = ..=))) - (def: .public order + (def .public order (All (_ %) (Order (Mod %))) (implementation - (def: equivalence ..equivalence) - (def: < ..<))) + (def equivalence ..equivalence) + (def < ..<))) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (All (_ %) (-> (Mod %) (Mod %) (Mod %))) (let [[modulus param] (representation param) [_ subject] (representation subject)] @@ -118,19 +118,19 @@ ) (with_template [<composition> <identity> <monoid>] - [(def: .public (<monoid> modulus) + [(def .public (<monoid> modulus) (All (_ %) (-> (Modulus %) (Monoid (Mod %)))) (implementation - (def: identity + (def identity (..modular modulus <identity>)) - (def: composite + (def composite <composition>)))] [..+ +0 addition] [..* +1 multiplication] ) - (def: .public (inverse modular) + (def .public (inverse modular) (All (_ %) (-> (Mod %) (Maybe (Mod %)))) (let [[modulus value] (representation modular) [[vk mk] gcd] (i.extended_gcd value (//.divisor modulus))] @@ -145,7 +145,7 @@ "Reference" (i#encoded (//.divisor reference)) "Subject" (i#encoded (//.divisor subject)))) -(def: .public (adapter reference subject) +(def .public (adapter reference subject) (All (_ r% s%) (-> (Modulus r%) (Modulus s%) (Try (-> (Mod s%) (Mod r%))))) diff --git a/stdlib/source/library/lux/math/modulus.lux b/stdlib/source/library/lux/math/modulus.lux index 7071c834a..3f976476a 100644 --- a/stdlib/source/library/lux/math/modulus.lux +++ b/stdlib/source/library/lux/math/modulus.lux @@ -23,22 +23,22 @@ (primitive .public (Modulus %) Int - (def: .public (modulus value) + (def .public (modulus value) (Ex (_ %) (-> Int (Try (Modulus %)))) (if (i.= +0 value) (exception.except ..zero_cannot_be_a_modulus []) {try.#Success (abstraction value)})) - (def: .public divisor + (def .public divisor (All (_ %) (-> (Modulus %) Int)) (|>> representation)) - (def: .public (= reference subject) + (def .public (= reference subject) (All (_ %r %s) (-> (Modulus %r) (Modulus %s) Bit)) (i.= (representation reference) (representation subject))) - (def: .public (congruent? modulus reference subject) + (def .public (congruent? modulus reference subject) (All (_ %) (-> (Modulus %) Int Int Bit)) (|> subject (i.- reference) @@ -46,7 +46,7 @@ (i.= +0))) ) -(def: .public literal +(def .public literal (syntax (_ [divisor <code>.int]) (meta.lifted (do try.monad diff --git a/stdlib/source/library/lux/math/number.lux b/stdlib/source/library/lux/math/number.lux index 59310fc99..4e1beb005 100644 --- a/stdlib/source/library/lux/math/number.lux +++ b/stdlib/source/library/lux/math/number.lux @@ -15,10 +15,10 @@ ["[1][0]" rev] ["[1][0]" frac]]) -(def: separator +(def separator ",") -(def: (separator_prefixed? number) +(def (separator_prefixed? number) (-> Text Bit) (case ("lux text index" 0 ..separator number) {.#Some 0} @@ -27,12 +27,12 @@ _ #0)) -(def: without_separators +(def without_separators (-> Text Text) (text.replaced ..separator "")) (with_template [<macro> <nat> <int> <rev> <frac> <error>] - [(def: .public <macro> + [(def .public <macro> (macro (_ tokens state) (case tokens {.#Item [meta {.#Text repr'}] {.#End}} diff --git a/stdlib/source/library/lux/math/number/complex.lux b/stdlib/source/library/lux/math/number/complex.lux index 8708b9c7f..58a8cd4be 100644 --- a/stdlib/source/library/lux/math/number/complex.lux +++ b/stdlib/source/library/lux/math/number/complex.lux @@ -22,34 +22,34 @@ [#real Frac #imaginary Frac])) -(def: .public complex +(def .public complex (syntax (_ [real <code>.any ?imaginary (<>.maybe <code>.any)]) (in (list (` [..#real (~ real) ..#imaginary (~ (maybe.else (' +0.0) ?imaginary))]))))) -(def: .public i +(def .public i Complex (..complex +0.0 +1.0)) -(def: .public +one +(def .public +one Complex (..complex +1.0 +0.0)) -(def: .public -one +(def .public -one Complex (..complex -1.0 +0.0)) -(def: .public zero +(def .public zero Complex (..complex +0.0 +0.0)) -(def: .public (not_a_number? complex) +(def .public (not_a_number? complex) (-> Complex Bit) (or (f.not_a_number? (the #real complex)) (f.not_a_number? (the #imaginary complex)))) -(def: .public (= param input) +(def .public (= param input) (-> Complex Complex Bit) (and (f.= (the #real param) (the #real input)) @@ -57,7 +57,7 @@ (the #imaginary input)))) (with_template [<name> <op>] - [(def: .public (<name> param input) + [(def .public (<name> param input) (-> Complex Complex Complex) [#real (<op> (the #real param) (the #real input)) @@ -68,13 +68,13 @@ [- f.-] ) -(def: .public equivalence +(def .public equivalence (Equivalence Complex) (implementation - (def: = ..=))) + (def = ..=))) (with_template [<name> <transform>] - [(def: .public <name> + [(def .public <name> (-> Complex Complex) (|>> (revised #real <transform>) (revised #imaginary <transform>)))] @@ -83,18 +83,18 @@ [signum f.signum] ) -(def: .public conjugate +(def .public conjugate (-> Complex Complex) (revised #imaginary f.opposite)) -(def: .public (*' param input) +(def .public (*' param input) (-> Frac Complex Complex) [#real (f.* param (the #real input)) #imaginary (f.* param (the #imaginary input))]) -(def: .public (* param input) +(def .public (* param input) (-> Complex Complex Complex) [#real (f.- (f.* (the #imaginary param) (the #imaginary input)) @@ -105,7 +105,7 @@ (f.* (the #imaginary param) (the #real input)))]) -(def: .public (/ param input) +(def .public (/ param input) (-> Complex Complex Complex) (let [(open "[0]") param] (if (f.< (f.abs #imaginary) @@ -119,13 +119,13 @@ [..#real (|> (the ..#imaginary input) (f.* quot) (f.+ (the ..#real input)) (f./ denom)) ..#imaginary (|> (the ..#imaginary input) (f.- (f.* quot (the ..#real input))) (f./ denom))])))) -(def: .public (/' param subject) +(def .public (/' param subject) (-> Frac Complex Complex) (let [(open "[0]") subject] [..#real (f./ param #real) ..#imaginary (f./ param #imaginary)])) -(def: .public (% param input) +(def .public (% param input) (-> Complex Complex Complex) (let [scaled (/ param input) quotient (|> scaled @@ -134,7 +134,7 @@ (- (* quotient param) input))) -(def: .public (cos subject) +(def .public (cos subject) (-> Complex Complex) (let [(open "[0]") subject] [..#real (f.* (f.cosh #imaginary) @@ -142,7 +142,7 @@ ..#imaginary (f.opposite (f.* (f.sinh #imaginary) (f.sin #real)))])) -(def: .public (cosh subject) +(def .public (cosh subject) (-> Complex Complex) (let [(open "[0]") subject] [..#real (f.* (f.cos #imaginary) @@ -150,7 +150,7 @@ ..#imaginary (f.* (f.sin #imaginary) (f.sinh #real))])) -(def: .public (sin subject) +(def .public (sin subject) (-> Complex Complex) (let [(open "[0]") subject] [..#real (f.* (f.cosh #imaginary) @@ -158,7 +158,7 @@ ..#imaginary (f.* (f.sinh #imaginary) (f.cos #real))])) -(def: .public (sinh subject) +(def .public (sinh subject) (-> Complex Complex) (let [(open "[0]") subject] [..#real (f.* (f.cos #imaginary) @@ -166,7 +166,7 @@ ..#imaginary (f.* (f.sin #imaginary) (f.cosh #real))])) -(def: .public (tan subject) +(def .public (tan subject) (-> Complex Complex) (let [(open "[0]") subject r2 (f.* +2.0 #real) @@ -175,7 +175,7 @@ [..#real (f./ d (f.sin r2)) ..#imaginary (f./ d (f.sinh i2))])) -(def: .public (tanh subject) +(def .public (tanh subject) (-> Complex Complex) (let [(open "[0]") subject r2 (f.* +2.0 #real) @@ -184,7 +184,7 @@ [..#real (f./ d (f.sinh r2)) ..#imaginary (f./ d (f.sin i2))])) -(def: .public (abs subject) +(def .public (abs subject) (-> Complex Frac) (let [(open "[0]") subject] (if (f.< (f.abs #imaginary) @@ -200,21 +200,21 @@ (f.* (f.pow +0.5 (f.+ +1.0 (f.* q q))) (f.abs #real))))))) -(def: .public (exp subject) +(def .public (exp subject) (-> Complex Complex) (let [(open "[0]") subject r_exp (f.exp #real)] [..#real (f.* r_exp (f.cos #imaginary)) ..#imaginary (f.* r_exp (f.sin #imaginary))])) -(def: .public (log subject) +(def .public (log subject) (-> Complex Complex) (let [(open "[0]") subject] [..#real (|> subject ..abs f.log) ..#imaginary (f.atan_2 #real #imaginary)])) (with_template [<name> <type> <op>] - [(def: .public (<name> param input) + [(def .public (<name> param input) (-> <type> Complex Complex) (|> input log (<op> param) exp))] @@ -222,11 +222,11 @@ [pow' Frac ..*'] ) -(def: (with_sign sign magnitude) +(def (with_sign sign magnitude) (-> Frac Frac Frac) (f.* (f.signum sign) magnitude)) -(def: .public (root_2 input) +(def .public (root_2 input) (-> Complex Complex) (let [(open "[0]") input t (|> input ..abs (f.+ (f.abs #real)) (f./ +2.0) (f.pow +0.5))] @@ -238,11 +238,11 @@ ..#imaginary (f./ (f.* +2.0 t) #imaginary)]))) -(def: (root_2-1z input) +(def (root_2-1z input) (-> Complex Complex) (|> (complex +1.0) (- (* input input)) ..root_2)) -(def: .public (reciprocal (open "[0]")) +(def .public (reciprocal (open "[0]")) (-> Complex Complex) (if (f.< (f.abs #imaginary) (f.abs #real)) @@ -257,14 +257,14 @@ [..#real scale ..#imaginary (|> scale f.opposite (f.* q))]))) -(def: .public (acos input) +(def .public (acos input) (-> Complex Complex) (|> input (..+ (|> input ..root_2-1z (..* ..i))) ..log (..* (..opposite ..i)))) -(def: .public (asin input) +(def .public (asin input) (-> Complex Complex) (|> input ..root_2-1z @@ -272,7 +272,7 @@ ..log (..* (..opposite ..i)))) -(def: .public (atan input) +(def .public (atan input) (-> Complex Complex) (|> input (..+ ..i) @@ -280,11 +280,11 @@ ..log (..* (../ (..complex +2.0) ..i)))) -(def: .public (argument (open "[0]")) +(def .public (argument (open "[0]")) (-> Complex Frac) (f.atan_2 #real #imaginary)) -(def: .public (roots nth input) +(def .public (roots nth input) (-> Nat Complex (List Complex)) (case nth 0 (list) @@ -304,7 +304,7 @@ [..#real real ..#imaginary imaginary]))))))) -(def: .public (approximately? margin_of_error standard value) +(def .public (approximately? margin_of_error standard value) (-> Frac Complex Complex Bit) (and (f.approximately? margin_of_error (the ..#real standard) diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux index ea62f7c92..c3203335a 100644 --- a/stdlib/source/library/lux/math/number/frac.lux +++ b/stdlib/source/library/lux/math/number/frac.lux @@ -24,7 +24,7 @@ ["[1][0]" rev]]) (with_template [<name> <value>] - [(def: .public <name> + [(def .public <name> <value>)] [e +2.7182818284590452354] @@ -36,7 +36,7 @@ (for @.old (these (with_template [<name> <method>] - [(def: .public (<name> it) + [(def .public (<name> it) (-> Frac Frac) (<method> it))] @@ -57,18 +57,18 @@ [root_2 "jvm invokestatic:java.lang.Math:sqrt:double"] [root_3 "jvm invokestatic:java.lang.Math:cbrt:double"] ) - (def: .public (pow param subject) + (def .public (pow param subject) (-> Frac Frac Frac) ("jvm invokestatic:java.lang.Math:pow:double,double" subject param))) @.jvm - (these (def: !double + (these (def !double (template (_ value) [(|> value (as (Primitive "java.lang.Double")) "jvm object cast")])) - (def: !frac + (def !frac (template (_ value) [(|> value "jvm object cast" @@ -76,7 +76,7 @@ (as Frac))])) (with_template [<name> <method>] - [(def: .public <name> + [(def .public <name> (-> Frac Frac) (|>> !double ["D"] @@ -101,7 +101,7 @@ [root_3 "cbrt"] ) - (def: .public (pow param subject) + (def .public (pow param subject) (-> Frac Frac Frac) (|> ("jvm member invoke static" [] "java.lang.Math" "pow" [] ["D" (!double subject)] ["D" (!double param)]) @@ -109,7 +109,7 @@ @.js (these (with_template [<name> <method>] - [(def: .public <name> + [(def .public <name> (-> Frac Frac) (|>> [] ("js apply" ("js constant" <method>)) @@ -133,13 +133,13 @@ [root_3 "Math.cbrt"] ) - (def: .public (pow param subject) + (def .public (pow param subject) (-> Frac Frac Frac) (as Frac ("js apply" ("js constant" "Math.pow") [subject param])))) @.python (these (with_template [<name> <method>] - [(def: .public <name> + [(def .public <name> (-> Frac Frac) (|>> [] ("python object do" <method> ("python import" "math")) @@ -162,11 +162,11 @@ [root_2 "sqrt"] ) - (def: .public (pow param subject) + (def .public (pow param subject) (-> Frac Frac Frac) (as Frac ("python object do" "pow" ("python import" "math") [subject param]))) - (def: .public (root_3 it) + (def .public (root_3 it) (-> Frac Frac) (if ("lux f64 <" +0.0 it) (|> it @@ -178,7 +178,7 @@ @.lua (these (with_template [<name> <method>] - [(def: .public <name> + [(def .public <name> (-> Frac Frac) (|>> [] ("lua apply" ("lua constant" <method>)) @@ -201,11 +201,11 @@ [root_2 "math.sqrt"] ) - (def: .public (pow param subject) + (def .public (pow param subject) (-> Frac Frac Frac) ("lua power" param subject)) - (def: .public (root_3 it) + (def .public (root_3 it) (-> Frac Frac) (if ("lux f64 <" +0.0 it) (|> it @@ -217,7 +217,7 @@ @.ruby (these (with_template [<name> <method>] - [(def: .public <name> + [(def .public <name> (-> Frac Frac) (|>> [] ("ruby apply" ("ruby constant" <method>)) @@ -239,7 +239,7 @@ ) (with_template [<name> <method>] - [(def: .public (<name> it) + [(def .public (<name> it) (-> Frac Frac) (|> ("ruby object do" <method> it []) (as Int) @@ -249,13 +249,13 @@ [floor "floor"] ) - (def: .public (pow param subject) + (def .public (pow param subject) (-> Frac Frac Frac) (as Frac ("ruby object do" "**" subject [param])))) @.php (these (with_template [<name> <method>] - [(def: .public <name> + [(def .public <name> (-> Frac Frac) (|>> ("php apply" ("php constant" <method>)) (as Frac)))] @@ -277,17 +277,17 @@ [root_2 "sqrt"] ) - (def: .public (pow param subject) + (def .public (pow param subject) (-> Frac Frac Frac) (as Frac ("php apply" ("php constant" "pow") subject param))) - (def: .public root_3 + (def .public root_3 (-> Frac Frac) (..pow ("lux f64 /" +3.0 +1.0)))) @.scheme (these (with_template [<name> <method>] - [(def: .public <name> + [(def .public <name> (-> Frac Frac) (|>> ("scheme apply" ("scheme constant" <method>)) (as Frac)))] @@ -309,16 +309,16 @@ [root_2 "sqrt"] ) - (def: .public (pow param subject) + (def .public (pow param subject) (-> Frac Frac Frac) (as Frac ("scheme apply" ("scheme constant" "expt") subject param))) - (def: .public root_3 + (def .public root_3 (-> Frac Frac) (..pow ("lux f64 /" +3.0 +1.0)))) ) -(def: .public (round it) +(def .public (round it) (-> Frac Frac) (let [floored (floor it) diff ("lux f64 -" floored it)] @@ -331,7 +331,7 @@ ... else floored))) -(def: .public (atan_2 x y) +(def .public (atan_2 x y) (-> Frac Frac Frac) (cond ("lux f64 <" x +0.0) (..atan ("lux f64 /" x y)) @@ -352,13 +352,13 @@ ... ("lux f64 =" +0.0 y) ("lux f64 /" +0.0 +0.0)))) -(def: .public (log_by base it) +(def .public (log_by base it) (-> Frac Frac Frac) ("lux f64 /" (..log base) (..log it))) -(def: .public (factorial it) +(def .public (factorial it) (-> Nat Nat) (loop (again [acc 1 it it]) @@ -366,7 +366,7 @@ (again (//nat.* it acc) (-- it)) acc))) -(def: .public (hypotenuse catA catB) +(def .public (hypotenuse catA catB) (-> Frac Frac Frac) (..pow +0.5 ("lux f64 +" (..pow +2.0 catA) @@ -375,11 +375,11 @@ ... Hyperbolic functions ... https://en.wikipedia.org/wiki/Hyperbolic_function#Definitions (with_template [<name> <comp> <inverse>] - [(def: .public (<name> it) + [(def .public (<name> it) (-> Frac Frac) (|> (..exp it) (<comp> (..exp ("lux f64 *" -1.0 it))) ("lux f64 /" +2.0))) - (def: .public (<inverse> it) + (def .public (<inverse> it) (-> Frac Frac) (|> +2.0 ("lux f64 /" (|> (..exp it) (<comp> (..exp ("lux f64 *" -1.0 it)))))))] @@ -388,7 +388,7 @@ ) (with_template [<name> <top> <bottom>] - [(def: .public (<name> it) + [(def .public (<name> it) (-> Frac Frac) (let [e+ (exp it) e- (exp ("lux f64 *" -1.0 it)) @@ -402,7 +402,7 @@ ... https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions#Definitions_in_terms_of_logarithms (with_template [<name> <comp>] - [(def: .public (<name> it) + [(def .public (<name> it) (-> Frac Frac) (|> it (pow +2.0) (<comp> +1.0) (pow +0.5) ("lux f64 +" it) log))] @@ -411,7 +411,7 @@ ) (with_template [<name> <base> <diff>] - [(def: .public (<name> it) + [(def .public (<name> it) (-> Frac Frac) (let [it+ (|> <base> ("lux f64 +" <diff>)) it- (|> <base> ("lux f64 -" <diff>))] @@ -422,7 +422,7 @@ ) (with_template [<name> <op>] - [(def: .public (<name> it) + [(def .public (<name> it) (-> Frac Frac) (let [it^2 (|> it (pow +2.0))] (|> +1.0 (<op> it^2) (pow +0.5) ("lux f64 +" +1.0) ("lux f64 /" it) log)))] @@ -432,7 +432,7 @@ ) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Frac Frac Bit) (<op> param subject))] @@ -440,22 +440,22 @@ [< "lux f64 <"] ) -(def: .public (<= reference sample) +(def .public (<= reference sample) (-> Frac Frac Bit) (or ("lux f64 <" reference sample) ("lux f64 =" reference sample))) -(def: .public (> reference sample) +(def .public (> reference sample) (-> Frac Frac Bit) ("lux f64 <" sample reference)) -(def: .public (>= reference sample) +(def .public (>= reference sample) (-> Frac Frac Bit) (or ("lux f64 <" sample reference) ("lux f64 =" sample reference))) (with_template [<comparison> <name>] - [(def: .public <name> + [(def .public <name> (Predicate Frac) (<comparison> +0.0))] @@ -465,7 +465,7 @@ ) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Frac Frac Frac) (<op> param subject))] @@ -476,33 +476,33 @@ [% "lux f64 %"] ) -(def: .public (/% param subject) +(def .public (/% param subject) (-> Frac Frac [Frac Frac]) [(../ param subject) (..% param subject)]) -(def: .public opposite +(def .public opposite (-> Frac Frac) (..* -1.0)) -(def: .public (abs it) +(def .public (abs it) (-> Frac Frac) (if (..< +0.0 it) (..* -1.0 it) it)) -(def: .public (signum it) +(def .public (signum it) (-> Frac Frac) (cond (..= +0.0 it) +0.0 (..< +0.0 it) -1.0 ... else +1.0)) -(def: min_exponent -1022) -(def: max_exponent (//int.frac +1023)) +(def min_exponent -1022) +(def max_exponent (//int.frac +1023)) (with_template [<name> <test>] - [(def: .public (<name> left right) + [(def .public (<name> left right) (-> Frac Frac Frac) (if (<test> right left) left @@ -512,23 +512,23 @@ [max ..>] ) -(def: .public nat +(def .public nat (-> Frac Nat) (|>> "lux f64 i64" .nat)) -(def: .public int +(def .public int (-> Frac Int) (|>> "lux f64 i64")) -(def: mantissa_size Nat 52) -(def: exponent_size Nat 11) +(def mantissa_size Nat 52) +(def exponent_size Nat 11) -(def: frac_denominator +(def frac_denominator (|> -1 ("lux i64 right-shift" ..exponent_size) "lux i64 f64")) -(def: .public rev +(def .public rev (-> Frac Rev) (|>> ..abs (..% +1.0) @@ -537,7 +537,7 @@ ("lux i64 left-shift" ..exponent_size))) (with_template [<name> <numerator>] - [(def: .public <name> + [(def .public <name> Frac (../ +0.0 <numerator>))] @@ -545,40 +545,40 @@ [positive_infinity +1.0] ) -(def: .public negative_infinity +(def .public negative_infinity Frac (..* -1.0 ..positive_infinity)) -(def: .public (not_a_number? it) +(def .public (not_a_number? it) (-> Frac Bit) (not (..= it it))) -(def: .public (number? it) +(def .public (number? it) (-> Frac Bit) (not (or (..not_a_number? it) (..= ..positive_infinity it) (..= ..negative_infinity it)))) -(def: .public equivalence +(def .public equivalence (Equivalence Frac) (implementation - (def: (= left right) + (def (= left right) (or (..= left right) (and (..not_a_number? left) (..not_a_number? right)))))) -(def: .public order +(def .public order (Order Frac) (implementation - (def: equivalence ..equivalence) - (def: < ..<))) + (def equivalence ..equivalence) + (def < ..<))) -(def: .public smallest +(def .public smallest Frac (..pow (//int.frac (//int.- (.int ..mantissa_size) ..min_exponent)) +2.0)) -(def: .public biggest +(def .public biggest Frac (let [f2^-52 (..pow (//nat.frac (//nat.- ..mantissa_size 0)) +2.0) f2^+1023 (..pow ..max_exponent +2.0)] @@ -587,11 +587,11 @@ (..* f2^+1023)))) (with_template [<name> <composite> <identity>] - [(def: .public <name> + [(def .public <name> (Monoid Frac) (implementation - (def: identity <identity>) - (def: composite <composite>)))] + (def identity <identity>) + (def composite <composite>)))] [addition ..+ +0.0] [multiplication ..* +1.0] @@ -599,10 +599,10 @@ [maximum ..max (..* -1.0 ..biggest)] ) -(def: .public decimal +(def .public decimal (Codec Text Frac) (implementation - (def: (encoded x) + (def (encoded x) (case x -0.0 (let [output ("lux f64 encode" x)] (if (text.starts_with? "-" output) @@ -612,7 +612,7 @@ ("lux f64 encode" x) ("lux text concat" "+" ("lux f64 encode" x))))) - (def: (decoded input) + (def (decoded input) (case ("lux f64 decode" input) {.#Some value} {try.#Success value} @@ -620,20 +620,20 @@ {.#None} {try.#Failure "Could not decode Frac"})))) -(def: log/2 +(def log/2 (-> Frac Frac) (|>> ..log (../ (..log +2.0)))) -(def: double_bias Nat 1023) +(def double_bias Nat 1023) -(def: exponent_mask (//i64.mask ..exponent_size)) +(def exponent_mask (//i64.mask ..exponent_size)) -(def: exponent_offset ..mantissa_size) -(def: sign_offset (//nat.+ ..exponent_size ..exponent_offset)) +(def exponent_offset ..mantissa_size) +(def sign_offset (//nat.+ ..exponent_size ..exponent_offset)) (with_template [<cast> <hex> <name>] - [(def: <name> + [(def <name> (|> <hex> (at //nat.hex decoded) try.trusted @@ -647,10 +647,10 @@ [.nat "7FF" special_exponent_bits] ) -(def: smallest_exponent +(def smallest_exponent (..log/2 ..smallest)) -(def: .public (bits it) +(def .public (bits it) (-> Frac I64) (.i64 (cond (..not_a_number? it) ..not_a_number_bits @@ -703,7 +703,7 @@ ))) (with_template [<getter> <size> <offset>] - [(def: <getter> + [(def <getter> (-> (I64 Any) I64) (let [mask (|> 1 (//i64.left_shifted <size>) -- (//i64.left_shifted <offset>))] (|>> (//i64.and mask) (//i64.right_shifted <offset>) .i64)))] @@ -713,7 +713,7 @@ [sign 1 ..sign_offset] ) -(def: .public (of_bits it) +(def .public (of_bits it) (-> I64 Frac) (case [(is Nat (..exponent it)) (is Nat (..mantissa it)) @@ -752,7 +752,7 @@ (..* exponent) (..* sign))))) -(def: (representation_exponent codec representation) +(def (representation_exponent codec representation) (-> (Codec Text Nat) Text (Try [Text Int])) (case [("lux text index" 0 "e+" representation) ("lux text index" 0 "E+" representation) @@ -777,10 +777,10 @@ {try.#Success [representation +0]})) (with_template [<struct> <nat> <int> <error>] - [(def: .public <struct> + [(def .public <struct> (Codec Text Frac) (implementation - (def: (encoded value) + (def (encoded value) (let [bits (..bits value) mantissa (..mantissa bits) exponent (//int.- (.int ..double_bias) (..exponent bits)) @@ -794,7 +794,7 @@ ".0E" (at <int> encoded exponent)))) - (def: (decoded representation) + (def (decoded representation) (let [negative? (text.starts_with? "-" representation) positive? (text.starts_with? "+" representation)] (if (or negative? positive?) @@ -830,20 +830,20 @@ [hex //nat.hex //int.hex "Invalid hexadecimal syntax: "] ) -(def: .public hash +(def .public hash (Hash Frac) (implementation - (def: equivalence ..equivalence) - (def: hash ..bits))) + (def equivalence ..equivalence) + (def hash ..bits))) -(def: .public (approximately? margin_of_error standard value) +(def .public (approximately? margin_of_error standard value) (-> Frac Frac Frac Bit) (|> value (..- standard) ..abs (..< margin_of_error))) -(def: .public (mod divisor dividend) +(def .public (mod divisor dividend) (All (_ m) (-> Frac Frac Frac)) (let [remainder (..% divisor dividend)] (if (or (and (..< +0.0 divisor) diff --git a/stdlib/source/library/lux/math/number/i16.lux b/stdlib/source/library/lux/math/number/i16.lux index 76488032d..7f1cfda9b 100644 --- a/stdlib/source/library/lux/math/number/i16.lux +++ b/stdlib/source/library/lux/math/number/i16.lux @@ -9,10 +9,10 @@ [// ["[0]" i64 (.only Sub)]]) -(def: sub +(def sub (maybe.trusted (i64.sub 16))) -(def: .public I16 +(def .public I16 Type ... TODO: Switch to the cleaner approach ASAP. (case (type_of ..sub) @@ -27,7 +27,7 @@ ... (I64 size)) ) -(def: .public equivalence (Equivalence I16) (at ..sub sub_equivalence)) -(def: .public width Nat (at ..sub bits)) -(def: .public i16 (-> I64 I16) (at ..sub narrow)) -(def: .public i64 (-> I16 I64) (at ..sub wide)) +(def .public equivalence (Equivalence I16) (at ..sub sub_equivalence)) +(def .public width Nat (at ..sub bits)) +(def .public i16 (-> I64 I16) (at ..sub narrow)) +(def .public i64 (-> I16 I64) (at ..sub wide)) diff --git a/stdlib/source/library/lux/math/number/i32.lux b/stdlib/source/library/lux/math/number/i32.lux index 42a35144c..65958842e 100644 --- a/stdlib/source/library/lux/math/number/i32.lux +++ b/stdlib/source/library/lux/math/number/i32.lux @@ -9,12 +9,12 @@ [// ["[0]" i64 (.only Sub)]]) -(def: sub +(def sub ... TODO: Stop needing this coercion. (as (Sub (I64 (Primitive "#I32"))) (maybe.trusted (i64.sub 32)))) -(def: .public I32 +(def .public I32 Type ... TODO: Switch to the cleaner approach ASAP. (case (type_of ..sub) @@ -29,7 +29,7 @@ ... (I64 size)) ) -(def: .public equivalence (Equivalence I32) (at ..sub sub_equivalence)) -(def: .public width Nat (at ..sub bits)) -(def: .public i32 (-> I64 I32) (at ..sub narrow)) -(def: .public i64 (-> I32 I64) (at ..sub wide)) +(def .public equivalence (Equivalence I32) (at ..sub sub_equivalence)) +(def .public width Nat (at ..sub bits)) +(def .public i32 (-> I64 I32) (at ..sub narrow)) +(def .public i64 (-> I32 I64) (at ..sub wide)) diff --git a/stdlib/source/library/lux/math/number/i64.lux b/stdlib/source/library/lux/math/number/i64.lux index 78a5c798f..c476676a5 100644 --- a/stdlib/source/library/lux/math/number/i64.lux +++ b/stdlib/source/library/lux/math/number/i64.lux @@ -10,19 +10,19 @@ [// ["n" nat]]) -(def: .public bits_per_byte +(def .public bits_per_byte 8) -(def: .public bytes_per_i64 +(def .public bytes_per_i64 8) -(def: .public width +(def .public width Nat (n.* ..bits_per_byte ..bytes_per_i64)) (with_template [<parameter_type> <name> <op>] - [(def: .public (<name> parameter subject) + [(def .public (<name> parameter subject) (All (_ s) (-> <parameter_type> (I64 s) (I64 s))) (<op> parameter subject))] @@ -38,27 +38,27 @@ (type: .public Mask I64) -(def: .public (bit position) +(def .public (bit position) (-> Nat Mask) (|> 1 .i64 (..left_shifted (n.% ..width position)))) -(def: .public sign +(def .public sign Mask (..bit (-- ..width))) -(def: .public not +(def .public not (All (_ s) (-> (I64 s) (I64 s))) (..xor (.i64 (-- 0)))) -(def: .public false +(def .public false Mask (.i64 0)) -(def: .public true +(def .public true Mask (..not ..false)) -(def: .public (mask amount_of_bits) +(def .public (mask amount_of_bits) (-> Nat Mask) (case amount_of_bits 0 ..false @@ -66,11 +66,11 @@ 0 ..true bits (|> 1 .i64 (..left_shifted (n.% ..width bits)) .--)))) -(def: (with_shift shift value) +(def (with_shift shift value) (-> Nat Nat Nat) (|> value (right_shifted shift) (n.+ value))) -(def: .public (ones it) +(def .public (ones it) (-> (I64 Any) Nat) (let [ones' (n.- (|> it (right_shifted 1) (..and 6148914691236517205) i64) (i64 it))] @@ -82,12 +82,12 @@ (with_shift 32) (..and 127)))) -(def: .public (zero index input) +(def .public (zero index input) (All (_ s) (-> Nat (I64 s) (I64 s))) (|> index ..bit ..not (..and input))) (with_template [<name> <op>] - [(def: .public (<name> index input) + [(def .public (<name> index input) (All (_ s) (-> Nat (I64 s) (I64 s))) (|> index ..bit (<op> input)))] @@ -95,16 +95,16 @@ [flipped ..xor] ) -(def: .public (one? index input) +(def .public (one? index input) (-> Nat (I64 Any) Bit) (|> input .i64 (..and (..bit index)) (n.= 0) .not)) -(def: .public (zero? index input) +(def .public (zero? index input) (-> Nat (I64 Any) Bit) (.not (..one? index input))) (with_template [<name> <forward> <backward>] - [(def: .public (<name> distance input) + [(def .public (<name> distance input) (All (_ s) (-> Nat (I64 s) (I64 s))) (..or (<forward> distance input) (<backward> (n.- (n.% ..width distance) ..width) input)))] @@ -113,35 +113,35 @@ [right_rotated ..right_shifted ..left_shifted] ) -(def: .public (region offset size) +(def .public (region offset size) (-> Nat Nat Mask) (..left_rotated offset (..mask size))) -(def: .public equivalence +(def .public equivalence (All (_ a) (Equivalence (I64 a))) (implementation - (def: (= reference sample) + (def (= reference sample) ("lux i64 =" reference sample)))) -(def: .public hash +(def .public hash (All (_ a) (Hash (I64 a))) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: hash (|>> .nat)))) + (def hash (|>> .nat)))) (with_template [<monoid> <identity> <composite>] - [(def: .public <monoid> + [(def .public <monoid> (All (_ a) (Monoid (I64 a))) (implementation - (def: identity <identity>) - (def: composite <composite>)))] + (def identity <identity>) + (def composite <composite>)))] [disjunction ..false ..or] [conjunction ..true ..and] ) -(def: .public reversed +(def .public reversed (All (_ a) (-> (I64 a) (I64 a))) (let [swapper (is (-> Nat (All (_ a) (-> (I64 a) (I64 a)))) (function (_ power) @@ -189,7 +189,7 @@ (is (-> (I64 size) I64) wide))) -(def: .public (sub width) +(def .public (sub width) (Ex (_ size) (-> Nat (Maybe (Sub size)))) (if (.and (n.> 0 width) (n.< ..width width)) @@ -199,12 +199,12 @@ co_mantissa (..xor (.i64 -1) mantissa)] {.#Some (is Sub (implementation - (def: sub_equivalence ..equivalence) - (def: bits width) - (def: (narrow value) + (def sub_equivalence ..equivalence) + (def bits width) + (def (narrow value) (..or (|> value (..and ..sign) (..right_shifted sign_shift)) (|> value (..and mantissa)))) - (def: (wide value) + (def (wide value) (.i64 (case (.nat (..and sign value)) 0 value _ (..or co_mantissa value))))))}) diff --git a/stdlib/source/library/lux/math/number/i8.lux b/stdlib/source/library/lux/math/number/i8.lux index 36bafd4d6..6c13fc7ab 100644 --- a/stdlib/source/library/lux/math/number/i8.lux +++ b/stdlib/source/library/lux/math/number/i8.lux @@ -9,10 +9,10 @@ [// ["[0]" i64 (.only Sub)]]) -(def: sub +(def sub (maybe.trusted (i64.sub 8))) -(def: .public I8 +(def .public I8 Type ... TODO: Switch to the cleaner approach ASAP. (case (type_of ..sub) @@ -27,7 +27,7 @@ ... (I64 size)) ) -(def: .public equivalence (Equivalence I8) (at ..sub sub_equivalence)) -(def: .public width Nat (at ..sub bits)) -(def: .public i8 (-> I64 I8) (at ..sub narrow)) -(def: .public i64 (-> I8 I64) (at ..sub wide)) +(def .public equivalence (Equivalence I8) (at ..sub sub_equivalence)) +(def .public width Nat (at ..sub bits)) +(def .public i8 (-> I64 I8) (at ..sub narrow)) +(def .public i64 (-> I8 I64) (at ..sub wide)) diff --git a/stdlib/source/library/lux/math/number/int.lux b/stdlib/source/library/lux/math/number/int.lux index 19d2459f9..2f13df457 100644 --- a/stdlib/source/library/lux/math/number/int.lux +++ b/stdlib/source/library/lux/math/number/int.lux @@ -22,7 +22,7 @@ ["[1][0]" i64]]) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Int Int Bit) (<op> param subject))] @@ -30,24 +30,24 @@ [< "lux i64 <"] ) -(def: .public (<= reference sample) +(def .public (<= reference sample) (-> Int Int Bit) (if ("lux i64 <" reference sample) #1 ("lux i64 =" reference sample))) -(def: .public (> reference sample) +(def .public (> reference sample) (-> Int Int Bit) ("lux i64 <" sample reference)) -(def: .public (>= reference sample) +(def .public (>= reference sample) (-> Int Int Bit) (if ("lux i64 <" sample reference) #1 ("lux i64 =" reference sample))) (with_template [<comparison> <name>] - [(def: .public <name> + [(def .public <name> (Predicate Int) (<comparison> +0))] @@ -57,7 +57,7 @@ ) (with_template [<name> <test>] - [(def: .public (<name> left right) + [(def .public (<name> left right) (-> Int Int Int) (if (<test> right left) left @@ -68,7 +68,7 @@ ) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Int Int Int) (<op> param subject))] @@ -79,22 +79,22 @@ [% "lux i64 %"] ) -(def: .public (/% param subject) +(def .public (/% param subject) (-> Int Int [Int Int]) [(../ param subject) (..% param subject)]) -(def: .public (opposite it) +(def .public (opposite it) (-> Int Int) (..- it +0)) -(def: .public (abs it) +(def .public (abs it) (-> Int Int) (if (..< +0 it) (..* -1 it) it)) -(def: .public (signum it) +(def .public (signum it) (-> Int Int) (cond (..= +0 it) +0 (..< +0 it) -1 @@ -102,7 +102,7 @@ +1)) ... https://rob.conery.io/2018/08/21/mod-and-remainder-are-not-the-same/ -(def: .public (mod divisor dividend) +(def .public (mod divisor dividend) (All (_ m) (-> Int Int Int)) (let [remainder (..% divisor dividend)] (if (or (and (..< +0 divisor) @@ -112,27 +112,27 @@ (..+ divisor remainder) remainder))) -(def: .public even? +(def .public even? (-> Int Bit) (|>> (..% +2) ("lux i64 =" +0))) -(def: .public odd? +(def .public odd? (-> Int Bit) (|>> ..even? not)) ... https://en.wikipedia.org/wiki/Greatest_common_divisor -(def: .public (gcd a b) +(def .public (gcd a b) (-> Int Int Int) (case b +0 a _ (gcd b (..% b a)))) -(def: .public (co_prime? a b) +(def .public (co_prime? a b) (-> Int Int Bit) (..= +1 (..gcd a b))) ... https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm -(def: .public (extended_gcd a b) +(def .public (extended_gcd a b) (-> Int Int [[Int Int] Int]) (loop (again [x +1 x1 +0 y +0 y1 +1 @@ -145,7 +145,7 @@ b1 (- (* q b1) a1)))))) ... https://en.wikipedia.org/wiki/Least_common_multiple -(def: .public (lcm a b) +(def .public (lcm a b) (-> Int Int Int) (case [a b] (^.or [_ +0] [+0 _]) @@ -154,48 +154,48 @@ _ (|> a (/ (gcd a b)) (* b)))) -(def: .public frac +(def .public frac (-> Int Frac) (|>> "lux i64 f64")) -(def: .public equivalence +(def .public equivalence (Equivalence Int) (implementation - (def: = ..=))) + (def = ..=))) -(def: .public order +(def .public order (Order Int) (implementation - (def: equivalence ..equivalence) - (def: < ..<))) + (def equivalence ..equivalence) + (def < ..<))) -(def: .public enum +(def .public enum (Enum Int) (implementation - (def: order ..order) - (def: succ ++) - (def: pred --))) + (def order ..order) + (def succ ++) + (def pred --))) ... TODO: Find out why the numeric literals fail during JS compilation. -(def: .public interval +(def .public interval (Interval Int) (implementation - (def: enum ..enum) - (def: top + (def enum ..enum) + (def top ... +9,223,372,036,854,775,807 (let [half (//i64.left_shifted 62 +1)] (+ half (-- half)))) - (def: bottom + (def bottom ... -9,223,372,036,854,775,808 (//i64.left_shifted 63 +1)))) (with_template [<name> <composite> <identity>] - [(def: .public <name> + [(def .public <name> (Monoid Int) (implementation - (def: identity <identity>) - (def: composite <composite>)))] + (def identity <identity>) + (def composite <composite>)))] [addition ..+ +0] [multiplication ..* +1] @@ -203,19 +203,19 @@ [minimum ..min (at ..interval top)] ) -(def: -sign "-") -(def: +sign "+") +(def -sign "-") +(def +sign "+") (with_template [<struct> <codec> <error>] - [(def: .public <struct> + [(def .public <struct> (Codec Text Int) (implementation - (def: (encoded value) + (def (encoded value) (if (..< +0 value) (|> value ++ ..opposite .nat ++ (at <codec> encoded) ("lux text concat" ..-sign)) (|> value .nat (at <codec> encoded) ("lux text concat" ..+sign)))) - (def: (decoded repr) + (def (decoded repr) (let [input_size ("lux text size" repr)] (if (//nat.> 1 input_size) (case ("lux text clip" 0 1 repr) @@ -241,13 +241,13 @@ [hex //nat.hex "Invalid hexadecimal syntax for Int: "] ) -(def: .public hash +(def .public hash (Hash Int) (implementation - (def: equivalence ..equivalence) - (def: hash (|>> .nat)))) + (def equivalence ..equivalence) + (def hash (|>> .nat)))) -(def: .public (right_shifted parameter subject) +(def .public (right_shifted parameter subject) (-> Nat Int Int) (with_expansions [<positive> (//i64.right_shifted parameter subject)] (if (< +0 subject) diff --git a/stdlib/source/library/lux/math/number/nat.lux b/stdlib/source/library/lux/math/number/nat.lux index 206a6fe46..53828d2fa 100644 --- a/stdlib/source/library/lux/math/number/nat.lux +++ b/stdlib/source/library/lux/math/number/nat.lux @@ -17,7 +17,7 @@ ["^" pattern]]]]) (with_template [<extension> <output> <name>] - [(def: .public (<name> parameter subject) + [(def .public (<name> parameter subject) (-> Nat Nat <output>) (<extension> parameter subject))] @@ -26,16 +26,16 @@ ["lux i64 -" Nat -] ) -(def: high +(def high (-> (I64 Any) I64) (|>> ("lux i64 right-shift" 32))) -(def: low +(def low (-> (I64 Any) I64) (let [mask (|> 1 ("lux i64 left-shift" 32) ("lux i64 -" 1))] (|>> ("lux i64 and" mask)))) -(def: .public (< reference sample) +(def .public (< reference sample) (-> Nat Nat Bit) (let [referenceH (..high reference) sampleH (..high sample)] @@ -47,22 +47,22 @@ (..low sample)) #0)))) -(def: .public (<= reference sample) +(def .public (<= reference sample) (-> Nat Nat Bit) (or (..< reference sample) ("lux i64 =" reference sample))) -(def: .public (> reference sample) +(def .public (> reference sample) (-> Nat Nat Bit) (..< sample reference)) -(def: .public (>= reference sample) +(def .public (>= reference sample) (-> Nat Nat Bit) (or (..< sample reference) ("lux i64 =" reference sample))) (with_template [<name> <test>] - [(def: .public (<name> left right) + [(def .public (<name> left right) (-> Nat Nat Nat) (if (<test> right left) left @@ -72,13 +72,13 @@ [max ..>] ) -(def: .public (* parameter subject) +(def .public (* parameter subject) (-> Nat Nat Nat) (.nat ("lux i64 *" (.int parameter) (.int subject)))) -(def: .public (/ parameter subject) +(def .public (/ parameter subject) (-> Nat Nat Nat) (if ("lux i64 <" +0 (.int parameter)) (if (..< parameter subject) @@ -96,7 +96,7 @@ quotient ("lux i64 +" 1 quotient))))) -(def: .public (/% parameter subject) +(def .public (/% parameter subject) (-> Nat Nat [Nat Nat]) (let [quotient (../ parameter subject) flat ("lux i64 *" @@ -104,24 +104,24 @@ (.int quotient))] [quotient ("lux i64 -" flat subject)])) -(def: .public (% parameter subject) +(def .public (% parameter subject) (-> Nat Nat Nat) (let [flat ("lux i64 *" (.int parameter) (.int (../ parameter subject)))] ("lux i64 -" flat subject))) -(def: .public (gcd a b) +(def .public (gcd a b) (-> Nat Nat Nat) (case b 0 a _ (gcd b (..% b a)))) -(def: .public (co_prime? a b) +(def .public (co_prime? a b) (-> Nat Nat Bit) (..= 1 (..gcd a b))) -(def: .public (lcm a b) +(def .public (lcm a b) (-> Nat Nat Nat) (case [a b] (^.or [_ 0] [0 _]) @@ -130,49 +130,49 @@ _ (|> a (../ (..gcd a b)) (..* b)))) -(def: .public even? +(def .public even? (-> Nat Bit) (|>> (..% 2) ("lux i64 =" 0))) -(def: .public odd? +(def .public odd? (-> Nat Bit) (|>> ..even? not)) -(def: .public frac +(def .public frac (-> Nat Frac) (|>> .int "lux i64 f64")) -(def: .public equivalence +(def .public equivalence (Equivalence Nat) (implementation - (def: = ..=))) + (def = ..=))) -(def: .public order +(def .public order (Order Nat) (implementation - (def: equivalence ..equivalence) - (def: < ..<))) + (def equivalence ..equivalence) + (def < ..<))) -(def: .public enum +(def .public enum (Enum Nat) (implementation - (def: order ..order) - (def: succ ++) - (def: pred --))) + (def order ..order) + (def succ ++) + (def pred --))) -(def: .public interval +(def .public interval (Interval Nat) (implementation - (def: enum ..enum) - (def: top (-- 0)) - (def: bottom 0))) + (def enum ..enum) + (def top (-- 0)) + (def bottom 0))) (with_template [<name> <composite> <identity>] - [(def: .public <name> + [(def .public <name> (Monoid Nat) (implementation - (def: identity <identity>) - (def: composite <composite>)))] + (def identity <identity>) + (def composite <composite>)))] [addition ..+ 0] [multiplication ..* 1] @@ -180,21 +180,21 @@ [maximum ..max (at ..interval bottom)] ) -(def: (binary_character value) +(def (binary_character value) (-> Nat Text) (case value 0 "0" 1 "1" _ (undefined))) -(def: (binary_value digit) +(def (binary_value digit) (-> Nat (Maybe Nat)) (case digit (pattern (char "0")) {.#Some 0} (pattern (char "1")) {.#Some 1} _ {.#None})) -(def: (octal_character value) +(def (octal_character value) (-> Nat Text) (case value 0 "0" @@ -207,7 +207,7 @@ 7 "7" _ (undefined))) -(def: (octal_value digit) +(def (octal_value digit) (-> Nat (Maybe Nat)) (case digit (pattern (char "0")) {.#Some 0} @@ -220,7 +220,7 @@ (pattern (char "7")) {.#Some 7} _ {.#None})) -(def: (decimal_character value) +(def (decimal_character value) (-> Nat Text) (case value 0 "0" @@ -235,7 +235,7 @@ 9 "9" _ (undefined))) -(def: (decimal_value digit) +(def (decimal_value digit) (-> Nat (Maybe Nat)) (case digit (pattern (char "0")) {.#Some 0} @@ -250,7 +250,7 @@ (pattern (char "9")) {.#Some 9} _ {.#None})) -(def: (hexadecimal_character value) +(def (hexadecimal_character value) (-> Nat Text) (case value 0 "0" @@ -271,7 +271,7 @@ 15 "F" _ (undefined))) -(def: (hexadecimal_value digit) +(def (hexadecimal_value digit) (-> Nat (Maybe Nat)) (case digit (^.with_template [<character> <number>] @@ -286,10 +286,10 @@ _ {.#None})) (with_template [<shift> <struct> <to_character> <to_value> <error>] - [(def: .public <struct> + [(def .public <struct> (Codec Text Nat) (implementation - (def: encoded + (def encoded (let [mask (|> 1 ("lux i64 left-shift" <shift>) --)] (function (_ value) (loop (again [input value @@ -304,7 +304,7 @@ input' (again input' output'))))))) - (def: (decoded repr) + (def (decoded repr) (let [input_size ("lux text size" repr)] (if (..> 0 input_size) (loop (again [idx 0 @@ -327,10 +327,10 @@ [4 hex hexadecimal_character hexadecimal_value "Invalid hexadecimal syntax for Nat: "] ) -(def: .public decimal +(def .public decimal (Codec Text Nat) (implementation - (def: (encoded value) + (def (encoded value) (loop (again [input value output ""]) (let [digit (decimal_character (..% 10 input)) @@ -342,7 +342,7 @@ input' (again input' output'))))) - (def: (decoded repr) + (def (decoded repr) (let [input_size ("lux text size" repr)] (with_expansions [<failure> {try.#Failure ("lux text concat" "Invalid decimal syntax for Nat: " repr)}] (if (..> 0 input_size) @@ -359,8 +359,8 @@ {try.#Success output})) <failure>)))))) -(def: .public hash +(def .public hash (Hash Nat) (implementation - (def: equivalence ..equivalence) - (def: hash function.identity))) + (def equivalence ..equivalence) + (def hash function.identity))) diff --git a/stdlib/source/library/lux/math/number/ratio.lux b/stdlib/source/library/lux/math/number/ratio.lux index 225b8da06..c4fe7a26d 100644 --- a/stdlib/source/library/lux/math/number/ratio.lux +++ b/stdlib/source/library/lux/math/number/ratio.lux @@ -27,117 +27,117 @@ [#numerator Nat #denominator Nat])) -(def: .public (nat value) +(def .public (nat value) (-> Ratio (Maybe Nat)) (case (the #denominator value) 1 {.#Some (the #numerator value)} _ {.#None})) -(def: (normal (open "_[0]")) +(def (normal (open "_[0]")) (-> Ratio Ratio) (let [common (n.gcd _#numerator _#denominator)] [..#numerator (n./ common _#numerator) ..#denominator (n./ common _#denominator)])) -(def: .public ratio +(def .public ratio (syntax (_ [numerator <code>.any ?denominator (<>.maybe <code>.any)]) (in (list (` ((~! ..normal) [..#numerator (~ numerator) ..#denominator (~ (maybe.else (' 1) ?denominator))])))))) -(def: .public (= parameter subject) +(def .public (= parameter subject) (-> Ratio Ratio Bit) (and (n.= (the #numerator parameter) (the #numerator subject)) (n.= (the #denominator parameter) (the #denominator subject)))) -(def: .public equivalence +(def .public equivalence (Equivalence Ratio) (implementation - (def: = ..=))) + (def = ..=))) -(def: (equalized parameter subject) +(def (equalized parameter subject) (-> Ratio Ratio [Nat Nat]) [(n.* (the #denominator subject) (the #numerator parameter)) (n.* (the #denominator parameter) (the #numerator subject))]) -(def: .public (< parameter subject) +(def .public (< parameter subject) (-> Ratio Ratio Bit) (let [[parameter' subject'] (..equalized parameter subject)] (n.< parameter' subject'))) -(def: .public (<= parameter subject) +(def .public (<= parameter subject) (-> Ratio Ratio Bit) (or (< parameter subject) (= parameter subject))) -(def: .public (> parameter subject) +(def .public (> parameter subject) (-> Ratio Ratio Bit) (..< subject parameter)) -(def: .public (>= parameter subject) +(def .public (>= parameter subject) (-> Ratio Ratio Bit) (or (> parameter subject) (= parameter subject))) -(def: .public order +(def .public order (Order Ratio) (implementation - (def: equivalence ..equivalence) - (def: < ..<))) + (def equivalence ..equivalence) + (def < ..<))) -(def: .public (+ parameter subject) +(def .public (+ parameter subject) (-> Ratio Ratio Ratio) (let [[parameter' subject'] (..equalized parameter subject)] (normal [(n.+ parameter' subject') (n.* (the #denominator parameter) (the #denominator subject))]))) -(def: .public (- parameter subject) +(def .public (- parameter subject) (-> Ratio Ratio Ratio) (let [[parameter' subject'] (..equalized parameter subject)] (normal [(n.- parameter' subject') (n.* (the #denominator parameter) (the #denominator subject))]))) -(def: .public (* parameter subject) +(def .public (* parameter subject) (-> Ratio Ratio Ratio) (normal [(n.* (the #numerator parameter) (the #numerator subject)) (n.* (the #denominator parameter) (the #denominator subject))])) -(def: .public (/ parameter subject) +(def .public (/ parameter subject) (-> Ratio Ratio Ratio) (let [[parameter' subject'] (..equalized parameter subject)] (normal [subject' parameter']))) -(def: .public (% parameter subject) +(def .public (% parameter subject) (-> Ratio Ratio Ratio) (let [[parameter' subject'] (..equalized parameter subject) quot (n./ parameter' subject')] (..- (revised #numerator (n.* quot) parameter) subject))) -(def: .public (reciprocal (open "_[0]")) +(def .public (reciprocal (open "_[0]")) (-> Ratio Ratio) [..#numerator _#denominator ..#denominator _#numerator]) -(def: separator ":") +(def separator ":") -(def: .public codec +(def .public codec (Codec Text Ratio) (implementation - (def: (encoded (open "_[0]")) + (def (encoded (open "_[0]")) (all text#composite (n#encoded _#numerator) ..separator (n#encoded _#denominator))) - (def: (decoded input) + (def (decoded input) (case (text.split_by ..separator input) {.#Some [num denom]} (do try.monad @@ -150,11 +150,11 @@ {.#Left (text#composite "Invalid syntax for ratio: " input)})))) (with_template [<identity> <composite> <name>] - [(def: .public <name> + [(def .public <name> (Monoid Ratio) (implementation - (def: identity (..ratio <identity>)) - (def: composite <composite>)))] + (def identity (..ratio <identity>)) + (def composite <composite>)))] [0 ..+ addition] [1 ..* multiplication] diff --git a/stdlib/source/library/lux/math/number/rev.lux b/stdlib/source/library/lux/math/number/rev.lux index f7200c908..d74da6b2e 100644 --- a/stdlib/source/library/lux/math/number/rev.lux +++ b/stdlib/source/library/lux/math/number/rev.lux @@ -20,12 +20,12 @@ ["[1][0]" nat] ["[1][0]" int]]) -(def: .public /1 +(def .public /1 Rev (.rev -1)) (with_template [<power> <name>] - [(def: .public <name> + [(def .public <name> Rev (.rev (//i64.left_shifted (//nat.- <power> //i64.width) 1)))] @@ -43,30 +43,30 @@ [12 /4096] ) -(def: .public (= reference sample) +(def .public (= reference sample) (-> Rev Rev Bit) ("lux i64 =" reference sample)) -(def: .public (< reference sample) +(def .public (< reference sample) (-> Rev Rev Bit) (//nat.< (.nat reference) (.nat sample))) -(def: .public (<= reference sample) +(def .public (<= reference sample) (-> Rev Rev Bit) (or (//nat.< (.nat reference) (.nat sample)) ("lux i64 =" reference sample))) -(def: .public (> reference sample) +(def .public (> reference sample) (-> Rev Rev Bit) (..< sample reference)) -(def: .public (>= reference sample) +(def .public (>= reference sample) (-> Rev Rev Bit) (or (..< sample reference) ("lux i64 =" reference sample))) (with_template [<name> <test>] - [(def: .public (<name> left right) + [(def .public (<name> left right) (-> Rev Rev Rev) (if (<test> right left) left @@ -77,7 +77,7 @@ ) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Rev Rev Rev) (<op> param subject))] @@ -85,16 +85,16 @@ [- "lux i64 -"] ) -(def: high +(def high (-> (I64 Any) I64) (|>> ("lux i64 right-shift" 32))) -(def: low +(def low (-> (I64 Any) I64) (let [mask (|> 1 ("lux i64 left-shift" 32) ("lux i64 -" 1))] (|>> ("lux i64 and" mask)))) -(def: .public (* param subject) +(def .public (* param subject) (-> Rev Rev Rev) (let [subjectH (..high subject) subjectL (..low subject) @@ -112,26 +112,26 @@ ..high ("lux i64 +" top)))) -(def: even_one (//i64.right_rotated 1 1)) -(def: odd_one (-- 0)) +(def even_one (//i64.right_rotated 1 1)) +(def odd_one (-- 0)) -(def: (even_reciprocal numerator) +(def (even_reciprocal numerator) (-> Nat Nat) (//nat./ (//i64.right_shifted 1 numerator) ..even_one)) -(def: (odd_reciprocal numerator) +(def (odd_reciprocal numerator) (-> Nat Nat) (//nat./ numerator ..odd_one)) (with_expansions [<least_significant_bit> 1] - (def: .public (reciprocal numerator) + (def .public (reciprocal numerator) (-> Nat Rev) (.rev (case (is Nat ("lux i64 and" <least_significant_bit> numerator)) 0 (..even_reciprocal numerator) _ (..odd_reciprocal numerator)))) - (def: .public (/ param subject) + (def .public (/ param subject) (-> Rev Rev Rev) (if ("lux i64 =" +0 param) (panic! "Cannot divide Rev by zero!") @@ -141,7 +141,7 @@ (.rev (//nat.* reciprocal (.nat subject))))))) (with_template [<operator> <name> <output> <output_type>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Rev Rev <output_type>) (<output> (<operator> (.nat param) (.nat subject))))] @@ -150,7 +150,7 @@ ) (with_template [<operator> <name>] - [(def: .public (<name> scale subject) + [(def .public (<name> scale subject) (-> Nat Rev Rev) (.rev (<operator> (.nat scale) (.nat subject))))] @@ -158,76 +158,76 @@ [//nat./ down] ) -(def: .public (/% param subject) +(def .public (/% param subject) (-> Rev Rev [Rev Rev]) [(../ param subject) (..% param subject)]) -(def: mantissa +(def mantissa (-> (I64 Any) Frac) (|>> ("lux i64 right-shift" 11) "lux i64 f64")) -(def: frac_denominator +(def frac_denominator (..mantissa -1)) -(def: .public frac +(def .public frac (-> Rev Frac) (|>> ..mantissa ("lux f64 /" ..frac_denominator))) -(def: .public equivalence +(def .public equivalence (Equivalence Rev) (implementation - (def: = ..=))) + (def = ..=))) -(def: .public hash +(def .public hash (Hash Rev) (implementation - (def: equivalence ..equivalence) - (def: hash (|>> .nat)))) + (def equivalence ..equivalence) + (def hash (|>> .nat)))) -(def: .public order +(def .public order (Order Rev) (implementation - (def: equivalence ..equivalence) - (def: < ..<))) + (def equivalence ..equivalence) + (def < ..<))) -(def: .public enum +(def .public enum (Enum Rev) (implementation - (def: order ..order) - (def: succ ++) - (def: pred --))) + (def order ..order) + (def succ ++) + (def pred --))) -(def: .public interval +(def .public interval (Interval Rev) (implementation - (def: enum ..enum) - (def: top (.rev -1)) - (def: bottom (.rev 0)))) + (def enum ..enum) + (def top (.rev -1)) + (def bottom (.rev 0)))) (with_template [<name> <composite> <identity>] - [(def: .public <name> + [(def .public <name> (Monoid Rev) (implementation - (def: identity (at interval <identity>)) - (def: composite <composite>)))] + (def identity (at interval <identity>)) + (def composite <composite>)))] [addition ..+ bottom] [maximum ..max bottom] [minimum ..min top] ) -(def: (decimals input) +(def (decimals input) (-> Text Text) ("lux text clip" 1 (-- ("lux text size" input)) input)) (with_template [<struct> <codec> <char_bit_size> <error>] [(with_expansions [<failure> (these {try.#Failure ("lux text concat" <error> repr)})] - (def: .public <struct> + (def .public <struct> (Codec Text Rev) (implementation - (def: (encoded value) + (def (encoded value) (let [raw_output (at <codec> encoded (.nat value)) max_num_chars (//nat.+ (//nat./ <char_bit_size> //i64.width) (case (//nat.% <char_bit_size> //i64.width) @@ -245,7 +245,7 @@ ("lux text concat" zero_padding) ("lux text concat" ".")))) - (def: (decoded repr) + (def (decoded repr) (let [repr_size ("lux text size" repr)] (if (//nat.> 1 repr_size) (case ("lux text char" 0 repr) @@ -279,21 +279,21 @@ (type: Digits (Array Nat)) -(def: (digits _) +(def (digits _) (-> Any Digits) (array.empty //i64.width)) -(def: (digit idx digits) +(def (digit idx digits) (-> Nat Digits Nat) (|> digits (array.item idx) (maybe.else 0))) -(def: digits#put! +(def digits#put! (-> Nat Nat Digits Digits) array.has!) -(def: (digits#times_5! idx output) +(def (digits#times_5! idx output) (-> Nat Digits Digits) (loop (again [idx idx carry 0 @@ -307,7 +307,7 @@ (//nat./ 10 raw) (digits#put! idx (//nat.% 10 raw) output)))))) -(def: (power_digits power) +(def (power_digits power) (-> Nat Digits) (loop (again [times power output (|> (..digits []) @@ -317,7 +317,7 @@ (again (-- times) (digits#times_5! power output))))) -(def: (format digits) +(def (format digits) (-> Digits Text) (loop (again [idx (-- //i64.width) all_zeroes? true @@ -336,7 +336,7 @@ (at //nat.decimal encoded digit) output))))))) -(def: (digits#+! param subject) +(def (digits#+! param subject) (-> Digits Digits Digits) (loop (again [idx (-- //i64.width) carry 0 @@ -351,7 +351,7 @@ (//nat./ 10 raw) (digits#put! idx (//nat.% 10 raw) output)))))) -(def: (text_digits input) +(def (text_digits input) (-> Text (Maybe Digits)) (let [length ("lux text size" input)] (if (//nat.> //i64.width length) @@ -368,7 +368,7 @@ (digits#put! idx digit output))) {.#Some output}))))) -(def: (digits#< param subject) +(def (digits#< param subject) (-> Digits Digits Bit) (loop (again [idx 0]) (and (//nat.< //i64.width idx) @@ -378,7 +378,7 @@ (again (++ idx)) (//nat.< pd sd)))))) -(def: (digits#-!' idx param subject) +(def (digits#-!' idx param subject) (-> Nat Nat Digits Digits) (let [sd (..digit idx subject)] (if (//nat.< param sd) @@ -390,7 +390,7 @@ (digits#-!' (-- idx) 1))) (digits#put! idx (//nat.- param sd) subject)))) -(def: (digits#-! param subject) +(def (digits#-! param subject) (-> Digits Digits Digits) (loop (again [idx (-- //i64.width) output subject]) @@ -399,10 +399,10 @@ (again (-- idx) (digits#-!' idx (..digit idx param) output))))) -(def: .public decimal +(def .public decimal (Codec Text Rev) (implementation - (def: (encoded input) + (def (encoded input) (case (.nat input) 0 ".0" @@ -421,7 +421,7 @@ (again (-- idx) digits))))))) - (def: (decoded input) + (def (decoded input) (let [dotted? (case ("lux text index" 0 "." input) {.#Some 0} true diff --git a/stdlib/source/library/lux/math/random.lux b/stdlib/source/library/lux/math/random.lux index a1a94b0a1..c7e6d0663 100644 --- a/stdlib/source/library/lux/math/random.lux +++ b/stdlib/source/library/lux/math/random.lux @@ -44,40 +44,40 @@ (type: .public (Random a) (-> PRNG [PRNG a])) -(def: .public functor +(def .public functor (Functor Random) (implementation - (def: (each f fa) + (def (each f fa) (function (_ state) (let [[state' a] (fa state)] [state' (f a)]))))) -(def: .public apply +(def .public apply (Apply Random) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (function (_ state) (let [[state' f] (ff state) [state'' a] (fa state')] [state'' (f a)]))))) -(def: .public monad +(def .public monad (Monad Random) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in a) + (def (in a) (function (_ state) [state a])) - (def: (conjoint ffa) + (def (conjoint ffa) (function (_ state) (let [[state' fa] (ffa state)] (fa state')))))) -(def: .public (only pred gen) +(def .public (only pred gen) (All (_ a) (-> (-> a Bit) (Random a) (Random a))) (do ..monad [sample gen] @@ -85,7 +85,7 @@ (in sample) (only pred gen)))) -(def: .public (one check random) +(def .public (one check random) (All (_ a b) (-> (-> a (Maybe b)) (Random a) (Random b))) (do ..monad @@ -97,7 +97,7 @@ {.#None} (one check random)))) -(def: .public (refined refiner gen) +(def .public (refined refiner gen) (All (_ t r) (-> (Refiner t r) (Random t) (Random (Refined t r)))) (do ..monad [sample gen] @@ -108,13 +108,13 @@ {.#None} (refined refiner gen)))) -(def: .public bit +(def .public bit (Random Bit) (function (_ prng) (let [[prng output] (prng [])] [prng (|> output (i64.and 1) (n.= 1))]))) -(def: .public i64 +(def .public i64 (Random I64) (function (_ prng) (let [[prng left] (prng []) @@ -124,7 +124,7 @@ ("lux i64 +" right))]))) (with_template [<name> <type> <cast>] - [(def: .public <name> + [(def .public <name> (Random <type>) (at ..functor each (|>> <cast>) ..i64))] @@ -133,11 +133,11 @@ [rev Rev .rev] ) -(def: .public frac +(def .public frac (Random Frac) (at ..functor each (|>> .i64 f.of_bits) ..nat)) -(def: .public safe_frac +(def .public safe_frac (Random Frac) (let [mantissa_range (.int (i64.left_shifted 53 1)) mantissa_max (i.frac (-- mantissa_range))] @@ -147,7 +147,7 @@ (f./ mantissa_max)) ..int))) -(def: .public (char set) +(def .public (char set) (-> unicode.Set (Random Char)) (let [start (unicode.start set) end (unicode.end set) @@ -158,7 +158,7 @@ (at ..functor each in_range) (..only (unicode.member? set))))) -(def: .public (text char_gen size) +(def .public (text char_gen size) (-> (Random Char) Nat (Random Text)) (if (n.= 0 size) (at ..monad in "") @@ -168,7 +168,7 @@ (in (text#composite (text.of_char x) xs))))) (with_template [<name> <set>] - [(def: .public <name> + [(def .public <name> (-> Nat (Random Text)) (..text (..char <set>)))] @@ -182,7 +182,7 @@ ) (with_template [<name> <type> <ctor> <gen>] - [(def: .public <name> + [(def .public <name> (Random <type>) (do ..monad [left <gen> @@ -193,14 +193,14 @@ [complex c.Complex c.complex ..safe_frac] ) -(def: .public (and left right) +(def .public (and left right) (All (_ a b) (-> (Random a) (Random b) (Random [a b]))) (function (_ prng) (let [[prng left] (left prng) [prng right] (right prng)] [prng [left right]]))) -(def: .public (or left right) +(def .public (or left right) (All (_ a b) (-> (Random a) (Random b) (Random (Or a b)))) (function (_ prng) (let [[prng ?] (..bit prng)] @@ -210,7 +210,7 @@ (let [[prng right] (right prng)] [prng {0 #1 right}]))))) -(def: .public (either left right) +(def .public (either left right) (All (_ a) (-> (Random a) (Random a) (Random a))) (function (_ prng) (let [[prng ?] (..bit prng)] @@ -218,13 +218,13 @@ (left prng) (right prng))))) -(def: .public (rec gen) +(def .public (rec gen) (All (_ a) (-> (-> (Random a) (Random a)) (Random a))) (function (_ state) (let [gen' (gen (rec gen))] (gen' state)))) -(def: .public (maybe value_gen) +(def .public (maybe value_gen) (All (_ a) (-> (Random a) (Random (Maybe a)))) (do [! ..monad] [some? bit] @@ -234,7 +234,7 @@ (in {.#Some value})) (in {.#None})))) -(def: .public (list size value_gen) +(def .public (list size value_gen) (All (_ a) (-> Nat (Random a) (Random (List a)))) (if (n.> 0 size) (do ..monad @@ -243,7 +243,7 @@ (in {.#Item x xs})) (at ..monad in (.list)))) -(def: .public (sequence size value_gen) +(def .public (sequence size value_gen) (All (_ a) (-> Nat (Random a) (Random (Sequence a)))) (if (n.> 0 size) (do ..monad @@ -253,7 +253,7 @@ (at ..monad in sequence.empty))) (with_template [<name> <type> <ctor>] - [(def: .public (<name> size value_gen) + [(def .public (<name> size value_gen) (All (_ a) (-> Nat (Random a) (Random (<type> a)))) (do ..monad [values (list size value_gen)] @@ -264,7 +264,7 @@ [stack Stack (list#mix stack.top stack.empty)] ) -(def: .public (set hash size value_gen) +(def .public (set hash size value_gen) (All (_ a) (-> (Hash a) Nat (Random a) (Random (Set a)))) (if (n.> 0 size) (do [! ..monad] @@ -278,7 +278,7 @@ (again []))))) (at ..monad in (set.empty hash)))) -(def: .public (dictionary hash size key_gen value_gen) +(def .public (dictionary hash size key_gen value_gen) (All (_ k v) (-> (Hash k) Nat (Random k) (Random v) (Random (Dictionary k v)))) (if (n.> 0 size) (do [! ..monad] @@ -293,23 +293,23 @@ (again []))))) (at ..monad in (dictionary.empty hash)))) -(def: .public instant +(def .public instant (Random Instant) (at ..functor each instant.of_millis ..int)) -(def: .public date +(def .public date (Random Date) (at ..functor each instant.date ..instant)) -(def: .public time +(def .public time (Random Time) (at ..functor each instant.time ..instant)) -(def: .public duration +(def .public duration (Random Duration) (at ..functor each duration.of_millis ..int)) -(def: .public month +(def .public month (Random Month) (let [(open "_#[0]") ..monad] (..either (..either (..either (_#in {month.#January}) @@ -325,7 +325,7 @@ (..either (_#in {month.#November}) (_#in {month.#December}))))))) -(def: .public day +(def .public day (Random Day) (let [(open "_#[0]") ..monad] (..either (..either (_#in {day.#Sunday}) @@ -336,18 +336,18 @@ (..either (_#in {day.#Friday}) (_#in {day.#Saturday})))))) -(def: .public (result prng calc) +(def .public (result prng calc) (All (_ a) (-> PRNG (Random a) [PRNG a])) (calc prng)) -(def: .public (prng update return) +(def .public (prng update return) (All (_ a) (-> (-> a a) (-> a I64) (-> a PRNG))) (function (again state) (function (_ _) [(again (update state)) (return state)]))) -(def: .public (pcg_32 [increase seed]) +(def .public (pcg_32 [increase seed]) (-> [(I64 Any) (I64 Any)] PRNG) (let [magic 6364136223846793005] (function (_ _) @@ -360,7 +360,7 @@ (i64.right_rotated rot) .i64))]))) -(def: .public (xoroshiro_128+ [s0 s1]) +(def .public (xoroshiro_128+ [s0 s1]) (-> [(I64 Any) (I64 Any)] PRNG) (function (_ _) [(let [s01 (i64.xor s0 s1)] @@ -373,7 +373,7 @@ ... https://en.wikipedia.org/wiki/Xorshift#Initialization ... http://xorshift.di.unimi.it/splitmix64.c -(def: .public split_mix_64 +(def .public split_mix_64 (-> Nat PRNG) (let [twist (is (-> Nat Nat Nat) (function (_ shift value) diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux index a4a6d6ec3..3c0e85615 100644 --- a/stdlib/source/library/lux/meta.lux +++ b/stdlib/source/library/lux/meta.lux @@ -30,10 +30,10 @@ ... (type: (Meta a) ... (-> Lux (Try [Lux a]))) -(def: .public functor +(def .public functor (Functor Meta) (implementation - (def: (each f fa) + (def (each f fa) (function (_ lux) (case (fa lux) {try.#Failure msg} @@ -42,12 +42,12 @@ {try.#Success [lux' a]} {try.#Success [lux' (f a)]}))))) -(def: .public apply +(def .public apply (Apply Meta) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (function (_ lux) (case (ff lux) {try.#Success [lux' f]} @@ -61,16 +61,16 @@ {try.#Failure msg} {try.#Failure msg}))))) -(def: .public monad +(def .public monad (Monad Meta) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in x) + (def (in x) (function (_ lux) {try.#Success [lux x]})) - (def: (conjoint mma) + (def (conjoint mma) (function (_ lux) (case (mma lux) {try.#Failure msg} @@ -79,11 +79,11 @@ {try.#Success [lux' ma]} (ma lux')))))) -(def: .public (result' lux action) +(def .public (result' lux action) (All (_ a) (-> Lux (Meta a) (Try [Lux a]))) (action lux)) -(def: .public (result lux action) +(def .public (result lux action) (All (_ a) (-> Lux (Meta a) (Try a))) (case (action lux) {try.#Failure error} @@ -92,7 +92,7 @@ {try.#Success [_ output]} {try.#Success output})) -(def: .public (either left right) +(def .public (either left right) (All (_ a) (-> (Meta a) (Meta a) (Meta a))) (function (_ lux) (case (left lux) @@ -102,20 +102,20 @@ {try.#Success [lux' output]} {try.#Success [lux' output]}))) -(def: .public (assertion message test) +(def .public (assertion message test) (-> Text Bit (Meta Any)) (function (_ lux) (if test {try.#Success [lux []]} {try.#Failure message}))) -(def: .public (failure error) +(def .public (failure error) (All (_ a) (-> Text (Meta a))) (function (_ state) {try.#Failure (location.with (the .#location state) error)})) -(def: .public (module name) +(def .public (module name) (-> Text (Meta Module)) (function (_ lux) (case (plist.value name (the .#modules lux)) @@ -125,7 +125,7 @@ _ {try.#Failure (all text#composite "Unknown module: " name)}))) -(def: .public current_module_name +(def .public current_module_name (Meta Text) (function (_ lux) (case (the .#current_module lux) @@ -135,14 +135,14 @@ _ {try.#Failure "No current module."}))) -(def: .public current_module +(def .public current_module (Meta Module) (let [(open "#[0]") ..monad] (|> ..current_module_name (#each ..module) #conjoint))) -(def: (macro_type? type) +(def (macro_type? type) (-> Type Bit) (`` (case type {.#Named [(~~ (static .prelude)) "Macro"] {.#Primitive "#Macro" {.#End}}} @@ -151,7 +151,7 @@ _ false))) -(def: .public (normal name) +(def .public (normal name) (-> Symbol (Meta Symbol)) (case name ["" name] @@ -162,7 +162,7 @@ _ (at ..monad in name))) -(def: .public (macro full_name) +(def .public (macro full_name) (-> Symbol (Meta (Maybe Macro))) (do ..monad [[module name] (..normal full_name)] @@ -202,13 +202,13 @@ {.#Slot _} {.#None})))))]})))) -(def: .public seed +(def .public seed (Meta Nat) (function (_ lux) {try.#Success [(revised .#seed ++ lux) (the .#seed lux)]})) -(def: .public (module_exists? module) +(def .public (module_exists? module) (-> Text (Meta Bit)) (function (_ lux) {try.#Success [lux (case (plist.value module (the .#modules lux)) @@ -218,14 +218,14 @@ {.#None} #0)]})) -(def: (on_either f x1 x2) +(def (on_either f x1 x2) (All (_ a b) (-> (-> a (Maybe b)) a a (Maybe b))) (case (f x1) {.#None} (f x2) {.#Some y} {.#Some y})) -(def: (type_variable idx bindings) +(def (type_variable idx bindings) (-> Nat (List [Nat (Maybe Type)]) (Maybe Type)) (case bindings {.#End} @@ -236,7 +236,7 @@ bound (type_variable idx bindings')))) -(def: (clean_type type) +(def (clean_type type) (-> Type (Meta Type)) (case type {.#Var var} @@ -253,7 +253,7 @@ _ (at ..monad in type))) -(def: .public (var_type name) +(def .public (var_type name) (-> Text (Meta Type)) (function (_ lux) (let [test (is (-> [Text [Type Any]] Bit) @@ -277,23 +277,23 @@ {.#None} {try.#Failure (all text#composite "Unknown variable: " name)})))) -(def: without_lux_runtime +(def without_lux_runtime (-> (List Text) (List Text)) ... The Lux runtime shows up as "" ... so I'm excluding it. (list.only (|>> text.empty? not))) -(def: listing_separator +(def listing_separator Text (all text#composite text.new_line " ")) -(def: module_listing +(def module_listing (-> (List Text) Text) (|>> ..without_lux_runtime (list.sorted text#<) (text.interposed ..listing_separator))) -(def: .public (definition name) +(def .public (definition name) (-> Symbol (Meta Global)) (do ..monad [name (..normal name) @@ -361,7 +361,7 @@ "") " All known modules: " all_known_modules text.new_line)}))))) -(def: .public (export name) +(def .public (export name) (-> Symbol (Meta Definition)) (do ..monad [definition (..definition name)] @@ -392,7 +392,7 @@ "Slots are not considered exports: " (symbol#encoded name)))))) -(def: .public (definition_type name) +(def .public (definition_type name) (-> Symbol (Meta Type)) (do ..monad [definition (definition name)] @@ -416,7 +416,7 @@ "Slots have no type: " (symbol#encoded name)))))) -(def: .public (type name) +(def .public (type name) (-> Symbol (Meta Type)) (case name ["" _name] @@ -426,7 +426,7 @@ _ (definition_type name))) -(def: .public (type_definition name) +(def .public (type_definition name) (-> Symbol (Meta Type)) (do ..monad [definition (definition name)] @@ -452,7 +452,7 @@ {.#Slot _} (..failure (all text#composite "Slot is not a type: " (symbol#encoded name)))))) -(def: .public (globals module) +(def .public (globals module) (-> Text (Meta (List [Text Global]))) (function (_ lux) (case (plist.value module (the .#modules lux)) @@ -462,7 +462,7 @@ {.#Some module} {try.#Success [lux (the .#definitions module)]}))) -(def: .public (definitions module) +(def .public (definitions module) (-> Text (Meta (List [Text Definition]))) (at ..monad each (list.all (function (_ [name global]) @@ -483,7 +483,7 @@ {.#None}))) (..globals module))) -(def: .public (exports module_name) +(def .public (exports module_name) (-> Text (Meta (List [Text Definition]))) (do ..monad [constants (..definitions module_name)] @@ -493,7 +493,7 @@ (in [name [exported? def_type def_value]]) (list)))))) -(def: .public modules +(def .public modules (Meta (List [Text Module])) (function (_ lux) (|> lux @@ -501,7 +501,7 @@ [lux] {try.#Success}))) -(def: .public (tags_of type_name) +(def .public (tags_of type_name) (-> Symbol (Meta (Maybe (List Symbol)))) (do ..monad [.let [[module_name name] type_name] @@ -517,12 +517,12 @@ _ (in {.#None})))) -(def: .public location +(def .public location (Meta Location) (function (_ lux) {try.#Success [lux (the .#location lux)]})) -(def: .public expected_type +(def .public expected_type (Meta Type) (function (_ lux) (case (the .#expected lux) @@ -532,26 +532,26 @@ {.#None} {try.#Failure "Not expecting any type."}))) -(def: .public (imported_modules module_name) +(def .public (imported_modules module_name) (-> Text (Meta (List Text))) (do ..monad [(open "_[0]") (..module module_name)] (in _#imports))) -(def: .public (imported_by? import module) +(def .public (imported_by? import module) (-> Text Text (Meta Bit)) (do ..monad [(open "_[0]") (..module module)] (in (list.any? (text#= import) _#imports)))) -(def: .public (imported? import) +(def .public (imported? import) (-> Text (Meta Bit)) (at ..functor each (|>> (the .#imports) (list.any? (text#= import))) ..current_module)) (with_template [<name> <tag> <description>] - [(def: .public (<name> label_name) + [(def .public (<name> label_name) (-> Symbol (Meta [Nat (List Symbol) Type])) (do ..monad [.let [[module name] label_name] @@ -572,7 +572,7 @@ [slot .#Slot "slot"] ) -(def: .public (tag_lists module) +(def .public (tag_lists module) (-> Text (Meta (List [(List Symbol) Type]))) (do ..monad [=module (..module module) @@ -596,7 +596,7 @@ {.#None})) (the .#definitions =module))))) -(def: .public locals +(def .public locals (Meta (List (List [Text Type]))) (function (_ lux) (case (list.inits (the .#scopes lux)) @@ -610,7 +610,7 @@ [name type]))) scopes)]}))) -(def: .public (de_aliased def_name) +(def .public (de_aliased def_name) (-> Symbol (Meta Symbol)) (do ..monad [constant (..definition def_name)] @@ -630,17 +630,17 @@ {.#Slot _} def_name)))) -(def: .public compiler_state +(def .public compiler_state (Meta Lux) (function (_ lux) {try.#Success [lux lux]})) -(def: .public type_context +(def .public type_context (Meta Type_Context) (function (_ lux) {try.#Success [lux (the .#type_context lux)]})) -(def: .public (lifted result) +(def .public (lifted result) (All (_ a) (-> (Try a) (Meta a))) (case result {try.#Success output} @@ -649,14 +649,14 @@ {try.#Failure error} (..failure error))) -(def: .public (eval type code) +(def .public (eval type code) (-> Type Code (Meta Any)) (do [! ..monad] [eval (at ! each (the .#eval) ..compiler_state)] (eval type code))) -(def: .public (try computation) +(def .public (try computation) (All (_ it) (-> (Meta it) (Meta (Try it)))) (function (_ lux) (case (computation lux) @@ -667,7 +667,7 @@ {try.#Success [lux {try.#Failure error}]}))) (with_template [<type> <name> <slot>] - [(def: .public <name> + [(def .public <name> (Meta <type>) (function (_ lux) {try.#Success [lux diff --git a/stdlib/source/library/lux/meta/configuration.lux b/stdlib/source/library/lux/meta/configuration.lux index abd48664e..9d30b3590 100644 --- a/stdlib/source/library/lux/meta/configuration.lux +++ b/stdlib/source/library/lux/meta/configuration.lux @@ -28,20 +28,20 @@ (type: .public Configuration (/.PList Text)) -(def: .public equivalence +(def .public equivalence (Equivalence Configuration) (/.equivalence text.equivalence)) -(def: .public monoid +(def .public monoid (Monoid Configuration) /.monoid) -(def: .public empty +(def .public empty Configuration /.empty) (with_template [<ascii> <name>] - [(def: <name> + [(def <name> Text (text.of_char (hex <ascii>)))] @@ -49,17 +49,17 @@ ["03" end] ) -(def: format' +(def format' (-> Text Text) (text.enclosed [..start ..end])) -(def: .public format +(def .public format (%.Format Configuration) (|>> (list#each (function (_ [feature value]) (%.format (..format' feature) (..format' value)))) text.together)) -(def: .public parser +(def .public parser (Parser Configuration) (let [parser' (is (Parser Text) (<| (<>.after (<text>.this ..start)) @@ -69,11 +69,11 @@ (exception: .public invalid) -(def: configuration +(def configuration (<code>.Parser Configuration) (<code>.tuple (<>.some (<>.and <code>.text <code>.text)))) -(def: (subsumes? actual expected) +(def (subsumes? actual expected) (-> Configuration Configuration Bit) (case expected {.#End} @@ -86,7 +86,7 @@ (maybe.else false)) (subsumes? expected tail)))) -(def: .public for +(def .public for (syntax (_ [specializations (<>.some (<>.and ..configuration <code>.any)) default (<>.maybe <code>.any)]) (do meta.monad diff --git a/stdlib/source/library/lux/meta/location.lux b/stdlib/source/library/lux/meta/location.lux index c71dcd094..acb911ab8 100644 --- a/stdlib/source/library/lux/meta/location.lux +++ b/stdlib/source/library/lux/meta/location.lux @@ -4,21 +4,21 @@ [abstract [equivalence (.only Equivalence)]]]]) -(def: .public equivalence +(def .public equivalence (Equivalence Location) (implementation - (def: (= reference subject) + (def (= reference subject) (and ("lux text =" (the .#module reference) (the .#module subject)) ("lux i64 =" (the .#line reference) (the .#line subject)) ("lux i64 =" (the .#column reference) (the .#column subject)))))) -(def: .public dummy +(def .public dummy Location [.#module "" .#line 0 .#column 0]) -(def: .public here +(def .public here (macro (_ tokens compiler) (case tokens {.#End} @@ -32,7 +32,7 @@ _ {.#Left (`` (("lux in-module" (~~ (static .prelude)) wrong_syntax_error) (symbol ..here)))}))) -(def: .public (format it) +(def .public (format it) (-> Location Text) (let [separator "," [file line column] it] @@ -42,10 +42,10 @@ (`` (("lux in-module" (~~ (static .prelude)) .nat#encoded) line)) separator (`` (("lux in-module" (~~ (static .prelude)) .nat#encoded) column))))) -(def: \n +(def \n ("lux i64 char" +10)) -(def: .public (with location error) +(def .public (with location error) (-> Location Text Text) (all "lux text concat" (..format location) \n error)) diff --git a/stdlib/source/library/lux/meta/symbol.lux b/stdlib/source/library/lux/meta/symbol.lux index 7966482ce..fba56c993 100644 --- a/stdlib/source/library/lux/meta/symbol.lux +++ b/stdlib/source/library/lux/meta/symbol.lux @@ -14,7 +14,7 @@ ... [Text Text]) (with_template [<name>] - [(def: .public (<name> [module short]) + [(def .public (<name> [module short]) (-> Symbol Text) <name>)] @@ -22,35 +22,35 @@ [short] ) -(def: .public hash +(def .public hash (Hash Symbol) (product.hash text.hash text.hash)) -(def: .public equivalence +(def .public equivalence (Equivalence Symbol) (at ..hash equivalence)) -(def: .public order +(def .public order (Order Symbol) (implementation - (def: equivalence ..equivalence) - (def: (< [moduleP shortP] [moduleS shortS]) + (def equivalence ..equivalence) + (def (< [moduleP shortP] [moduleS shortS]) (if (text#= moduleP moduleS) (at text.order < shortP shortS) (at text.order < moduleP moduleS))))) -(def: .public separator +(def .public separator ".") -(def: .public codec +(def .public codec (Codec Text Symbol) (implementation - (def: (encoded [module short]) + (def (encoded [module short]) (case module "" short _ (all text#composite module ..separator short))) - (def: (decoded input) + (def (decoded input) (case (text.all_split_by ..separator input) (pattern (list short)) {.#Right ["" short]} diff --git a/stdlib/source/library/lux/meta/version.lux b/stdlib/source/library/lux/meta/version.lux index 4fc4b2409..e90c95a53 100644 --- a/stdlib/source/library/lux/meta/version.lux +++ b/stdlib/source/library/lux/meta/version.lux @@ -19,11 +19,11 @@ [compiler [version (.only Version)]]]]]) -(def: .public latest +(def .public latest Version 00,07,00) -(def: .public current +(def .public current (syntax (_ []) (do meta.monad [it meta.version] @@ -31,7 +31,7 @@ (exception: .public invalid) -(def: .public for +(def .public for (syntax (_ [specializations (<>.some (<>.and <code>.text <code>.any)) default (<>.maybe <code>.any)]) (do meta.monad diff --git a/stdlib/source/library/lux/program.lux b/stdlib/source/library/lux/program.lux index 11ddcdd16..1e4622bcc 100644 --- a/stdlib/source/library/lux/program.lux +++ b/stdlib/source/library/lux/program.lux @@ -20,12 +20,12 @@ {#Raw Text} {#Parsed (List Code)})) -(def: arguments^ +(def arguments^ (<code>.Parser Arguments) (<>.or <code>.local (<code>.tuple (<>.some <code>.any)))) -(def: .public program: +(def .public program: (syntax (_ [args ..arguments^ body <code>.any]) (with_symbols [g!program g!args g!_ g!output g!message] diff --git a/stdlib/source/library/lux/static.lux b/stdlib/source/library/lux/static.lux index ea40d2733..4fd6c1674 100644 --- a/stdlib/source/library/lux/static.lux +++ b/stdlib/source/library/lux/static.lux @@ -18,7 +18,7 @@ ["[0]" random (.only Random)]]]]) (with_template [<name> <type> <format>] - [(def: .public <name> + [(def .public <name> (syntax (_ [expression <code>.any]) (at meta.monad each (|>> (as <type>) <format> list) @@ -32,14 +32,14 @@ [text .Text code.text] ) -(def: pcg_32_magic_inc +(def pcg_32_magic_inc Nat (hex "FEDCBA9876543210")) (with_expansions [<type> (Ex (_ a) [(-> a Code) a])] - (def: .public literal + (def .public literal (syntax (_ [format <code>.any expression <code>.any]) (do meta.monad @@ -51,7 +51,7 @@ (with_expansions [<type> (Ex (_ a) [(-> a Code) (List a)])] - (def: .public literals + (def .public literals (syntax (_ [format <code>.any expression <code>.any]) (do meta.monad @@ -60,12 +60,12 @@ .let [[format expression] (as <type> pair)]] (in (list#each format expression)))))) -(def: .public seed +(def .public seed (syntax (_ []) (meta#each (|>> code.nat list) meta.seed))) (with_template [<name> <random> <format>] - [(def: .public <name> + [(def .public <name> (syntax (_ []) (do meta.monad [seed meta.seed @@ -83,7 +83,7 @@ (with_expansions [<type> (Ex (_ a) [(-> a Code) (Random a)])] - (def: .public random + (def .public random (syntax (_ [format <code>.any random <code>.any]) (do meta.monad @@ -98,7 +98,7 @@ (with_expansions [<type> (Ex (_ a) [(-> a Code) (Random (List a))])] - (def: .public randoms + (def .public randoms (syntax (_ [format <code>.any random <code>.any]) (do meta.monad @@ -110,7 +110,7 @@ random)]] (in (list#each format result)))))) -(def: .public if +(def .public if (syntax (_ [test <code>.any then <code>.any else <code>.any]) @@ -120,7 +120,7 @@ then else)))))) -(def: .public cond +(def .public cond (syntax (_ [test,then/* (<>.some (<>.and <code>.any <code>.any)) else <code>.any]) (in (list (list#mix (function (_ [test then] else) @@ -130,7 +130,7 @@ else (list.reversed test,then/*)))))) -(def: .public when +(def .public when (syntax (_ [test <code>.any then <code>.any]) (do meta.monad diff --git a/stdlib/source/library/lux/target.lux b/stdlib/source/library/lux/target.lux index 66e8ea31b..cee1e3084 100644 --- a/stdlib/source/library/lux/target.lux +++ b/stdlib/source/library/lux/target.lux @@ -1,12 +1,12 @@ (.using - [library - [lux (.except)]]) + [library + [lux (.except)]]) (type: .public Target Text) (with_template [<name> <value>] - [(def: .public <name> + [(def .public <name> Target <value>)] diff --git a/stdlib/source/library/lux/target/common_lisp.lux b/stdlib/source/library/lux/target/common_lisp.lux index a95e1df67..b0107d234 100644 --- a/stdlib/source/library/lux/target/common_lisp.lux +++ b/stdlib/source/library/lux/target/common_lisp.lux @@ -16,18 +16,18 @@ [type [primitive (.except)]]]]) -(def: as_form +(def as_form (-> Text Text) (text.enclosed ["(" ")"])) (primitive .public (Code brand) Text - (def: .public manual + (def .public manual (-> Text Code) (|>> abstraction)) - (def: .public code + (def .public code (-> (Code Any) Text) (|>> representation)) @@ -62,29 +62,29 @@ [#input Var/* #output (Expression Any)])) - (def: .public nil + (def .public nil Literal (abstraction "()")) (with_template [<prefix> <name>] - [(def: .public <name> + [(def .public <name> (-> Text Literal) (|>> (format <prefix>) abstraction))] ["'" symbol] [":" keyword]) - (def: .public bool + (def .public bool (-> Bit Literal) (|>> (pipe.case #0 ..nil #1 (..symbol "t")))) - (def: .public int + (def .public int (-> Int Literal) (|>> %.int abstraction)) - (def: .public float + (def .public float (-> Frac Literal) (|>> (pipe.cond [(f.= f.positive_infinity)] [(pipe.new "(/ 1.0 0.0)" [])] @@ -99,7 +99,7 @@ [%.frac]) abstraction)) - (def: .public (double value) + (def .public (double value) (-> Frac Literal) (abstraction (.cond (f.= f.positive_infinity value) @@ -117,7 +117,7 @@ (text.replaced_once "E" "d" raw) (format raw "d0")))))) - (def: safe + (def safe (-> Text Text) (`` (|>> (~~ (with_template [<find> <replace>] [(text.replaced <find> <replace>)] @@ -134,24 +134,24 @@ )) ))) - (def: .public string + (def .public string (-> Text Literal) (|>> ..safe (text.enclosed' text.double_quote) abstraction)) - (def: .public var + (def .public var (-> Text Var/1) (|>> abstraction)) - (def: .public args + (def .public args (-> (List Var/1) Var/*) (|>> (list#each ..code) (text.interposed " ") ..as_form abstraction)) - (def: .public (args& singles rest) + (def .public (args& singles rest) (-> (List Var/1) Var/1 Var/*) (|> (case singles {.#End} @@ -166,19 +166,19 @@ ..as_form abstraction)) - (def: form + (def form (-> (List (Expression Any)) Expression) (|>> (list#each ..code) (text.interposed " ") ..as_form abstraction)) - (def: .public (call/* func) + (def .public (call/* func) (-> (Expression Any) (-> (List (Expression Any)) (Computation Any))) (|>> {.#Item func} ..form)) (with_template [<name> <function>] - [(def: .public <name> + [(def .public <name> (-> (List (Expression Any)) (Computation Any)) (..call/* (..var <function>)))] @@ -186,7 +186,7 @@ [list/* "list"] ) - (def: .public (labels definitions body) + (def .public (labels definitions body) (-> (List [Var/1 Lambda]) (Expression Any) (Computation Any)) (..form (list (..var "labels") (..form (list#each (function (_ [def_name [def_args def_body]]) @@ -194,19 +194,19 @@ definitions)) body))) - (def: .public (destructuring_bind [bindings expression] body) + (def .public (destructuring_bind [bindings expression] body) (-> [Var/* (Expression Any)] (List (Expression Any)) (Computation Any)) (..form (list.partial (..var "destructuring-bind") (transmutation bindings) expression body))) (with_template [<call> <input_var>+ <input_type>+ <function>+] - [(`` (def: .public (<call> [(~~ (template.spliced <input_var>+))] function) + [(`` (def .public (<call> [(~~ (template.spliced <input_var>+))] function) (-> [(~~ (template.spliced <input_type>+))] (Expression Any) (Computation Any)) (..call/* function (list (~~ (template.spliced <input_var>+)))))) (`` (with_template [<lux_name> <host_name>] - [(def: .public (<lux_name> args) + [(def .public (<lux_name> args) (-> [(~~ (template.spliced <input_type>+))] (Computation Any)) (<call> args (..var <host_name>)))] @@ -264,7 +264,7 @@ (with_template [<call> <input_type>+ <function>+] [(`` (with_template [<lux_name> <host_name>] - [(def: .public (<lux_name> args) + [(def .public (<lux_name> args) (-> [(~~ (template.spliced <input_type>+))] (Access Any)) (transmutation (<call> args (..var <host_name>))))] @@ -281,29 +281,29 @@ [gethash/2 "gethash"]]] ) - (def: .public (make_hash_table/with_size size) + (def .public (make_hash_table/with_size size) (-> (Expression Any) (Computation Any)) (..call/* (..var "make-hash-table") (list (..keyword "size") size))) - (def: .public (funcall/+ [func args]) + (def .public (funcall/+ [func args]) (-> [(Expression Any) (List (Expression Any))] (Computation Any)) (..call/* (..var "funcall") (list.partial func args))) - (def: .public (search/3 [reference space start]) + (def .public (search/3 [reference space start]) (-> [(Expression Any) (Expression Any) (Expression Any)] (Computation Any)) (..call/* (..var "search") (list reference space (..keyword "start2") start))) - (def: .public (concatenate/2|string [left right]) + (def .public (concatenate/2|string [left right]) (-> [(Expression Any) (Expression Any)] (Computation Any)) (concatenate/3 [(..symbol "string") left right])) (with_template [<lux_name> <host_name>] - [(def: .public (<lux_name> left right) + [(def .public (<lux_name> left right) (-> (Expression Any) (Expression Any) (Computation Any)) (..form (list (..var <host_name>) left right)))] @@ -312,7 +312,7 @@ ) (with_template [<lux_name> <host_name>] - [(def: .public (<lux_name> [param subject]) + [(def .public (<lux_name> [param subject]) (-> [(Expression Any) (Expression Any)] (Computation Any)) (..form (list (..var <host_name>) subject param)))] @@ -332,20 +332,20 @@ [logxor/2 "logxor"] ) - (def: .public (if test then else) + (def .public (if test then else) (-> (Expression Any) (Expression Any) (Expression Any) (Computation Any)) (..form (list (..var "if") test then else))) - (def: .public (when test then) + (def .public (when test then) (-> (Expression Any) (Expression Any) (Computation Any)) (..form (list (..var "when") test then))) - (def: .public (lambda input body) + (def .public (lambda input body) (-> Var/* (Expression Any) Literal) (..form (list (..var "lambda") (transmutation input) body))) (with_template [<lux_name> <host_name>] - [(def: .public (<lux_name> bindings body) + [(def .public (<lux_name> bindings body) (-> (List [Var/1 (Expression Any)]) (List (Expression Any)) (Computation Any)) (..form (list.partial (..var <host_name>) (|> bindings @@ -358,16 +358,16 @@ [let* "let*"] ) - (def: .public (defparameter name body) + (def .public (defparameter name body) (-> Var/1 (Expression Any) (Expression Any)) (..form (list (..var "defparameter") name body))) - (def: .public (defun name inputs body) + (def .public (defun name inputs body) (-> Var/1 Var/* (Expression Any) (Expression Any)) (..form (list (..var "defun") name (transmutation inputs) body))) (with_template [<name> <symbol>] - [(def: .public <name> + [(def .public <name> (-> (List (Expression Any)) (Computation Any)) (|>> (list.partial (..var <symbol>)) ..form))] @@ -376,11 +376,11 @@ [values/* "values"] ) - (def: .public (setq name value) + (def .public (setq name value) (-> Var/1 (Expression Any) (Expression Any)) (..form (list (..var "setq") name value))) - (def: .public (setf access value) + (def .public (setf access value) (-> (Access Any) (Expression Any) (Expression Any)) (..form (list (..var "setf") access value))) @@ -390,7 +390,7 @@ #condition Var/1 #body (Expression Any)])) - (def: .public (handler_case handlers body) + (def .public (handler_case handlers body) (-> (List Handler) (Expression Any) (Computation Any)) (..form (list.partial (..var "handler-case") body @@ -401,7 +401,7 @@ handlers)))) (with_template [<name> <prefix>] - [(def: .public (<name> conditions expression) + [(def .public (<name> conditions expression) (-> (List Text) (Expression Any) (Expression Any)) (case conditions {.#End} @@ -421,23 +421,23 @@ [conditional+ "#+"] [conditional- "#-"]) - (def: .public label + (def .public label (-> Text Label) (|>> abstraction)) - (def: .public (block name body) + (def .public (block name body) (-> Label (List (Expression Any)) (Computation Any)) (..form (list.partial (..var "block") (transmutation name) body))) - (def: .public (return_from target value) + (def .public (return_from target value) (-> Label (Expression Any) (Computation Any)) (..form (list (..var "return-from") (transmutation target) value))) - (def: .public (return value) + (def .public (return value) (-> (Expression Any) (Computation Any)) (..form (list (..var "return") value))) - (def: .public (cond clauses else) + (def .public (cond clauses else) (-> (List [(Expression Any) (Expression Any)]) (Expression Any) (Computation Any)) (..form (list.partial (..var "cond") (list#composite (list#each (function (_ [test then]) @@ -445,28 +445,28 @@ clauses) (list (..form (list (..bool true) else))))))) - (def: .public tag + (def .public tag (-> Text Tag) (|>> abstraction)) - (def: .public go + (def .public go (-> Tag (Expression Any)) (|>> (list (..var "go")) ..form)) - (def: .public values_list/1 + (def .public values_list/1 (-> (Expression Any) (Expression Any)) (|>> (list (..var "values-list")) ..form)) - (def: .public (multiple_value_setq bindings values) + (def .public (multiple_value_setq bindings values) (-> Var/* (Expression Any) (Expression Any)) (..form (list (..var "multiple-value-setq") (transmutation bindings) values))) ) -(def: .public (while condition body) +(def .public (while condition body) (-> (Expression Any) (Expression Any) (Computation Any)) (..form (list (..var "loop") (..var "while") condition (..var "do") body))) diff --git a/stdlib/source/library/lux/target/js.lux b/stdlib/source/library/lux/target/js.lux index ae5ffe9d1..5b057a697 100644 --- a/stdlib/source/library/lux/target/js.lux +++ b/stdlib/source/library/lux/target/js.lux @@ -17,18 +17,18 @@ [type [primitive (.except)]]]]) -(def: expression +(def expression (text.enclosed ["(" ")"])) -(def: element +(def element (text.enclosed ["[" "]"])) ... Added the carriage return for better Windows compatibility. -(def: \n+ +(def \n+ Text (format text.carriage_return text.new_line)) -(def: nested +(def nested (-> Text Text) (|>> (format \n+) (text.replaced text.new_line (format text.new_line text.tab)))) @@ -36,7 +36,7 @@ (primitive .public (Code brand) Text - (def: .public code + (def .public code (-> (Code Any) Text) (|>> representation)) @@ -64,20 +64,20 @@ ) (with_template [<name> <literal>] - [(def: .public <name> Literal (abstraction <literal>))] + [(def .public <name> Literal (abstraction <literal>))] [null "null"] [undefined "undefined"] ) - (def: .public boolean + (def .public boolean (-> Bit Literal) (|>> (pipe.case #0 "false" #1 "true") abstraction)) - (def: .public (number value) + (def .public (number value) (-> Frac Literal) (abstraction (cond (f.not_a_number? value) @@ -92,7 +92,7 @@ ... else (|> value %.frac ..expression)))) - (def: safe + (def safe (-> Text Text) (`` (|>> (~~ (with_template [<replace> <find>] [(text.replaced <find> <replace>)] @@ -110,36 +110,36 @@ )) ))) - (def: .public string + (def .public string (-> Text Literal) (|>> ..safe (text.enclosed [text.double_quote text.double_quote]) abstraction)) - (def: argument_separator ", ") - (def: field_separator ": ") - (def: statement_suffix ";") + (def argument_separator ", ") + (def field_separator ": ") + (def statement_suffix ";") - (def: .public array + (def .public array (-> (List Expression) Computation) (|>> (list#each ..code) (text.interposed ..argument_separator) ..element abstraction)) - (def: .public var + (def .public var (-> Text Var) (|>> abstraction)) - (def: .public (at index array_or_object) + (def .public (at index array_or_object) (-> Expression Expression Access) (abstraction (format (representation array_or_object) (..element (representation index))))) - (def: .public (the field object) + (def .public (the field object) (-> Text Expression Access) (abstraction (format (representation object) "." field))) - (def: .public (apply function inputs) + (def .public (apply function inputs) (-> Expression (List Expression) Computation) (|> inputs (list#each ..code) @@ -148,11 +148,11 @@ (format (representation function)) abstraction)) - (def: .public (do method inputs object) + (def .public (do method inputs object) (-> Text (List Expression) Expression Computation) (apply (..the method object) inputs)) - (def: .public object + (def .public object (-> (List [Text Expression]) Computation) (|>> (list#each (.function (_ [key val]) (format (representation (..string key)) ..field_separator (representation val)))) @@ -161,19 +161,19 @@ ..expression abstraction)) - (def: .public (, pre post) + (def .public (, pre post) (-> Expression Expression Computation) (|> (format (representation pre) ..argument_separator (representation post)) ..expression abstraction)) - (def: .public (then pre post) + (def .public (then pre post) (-> Statement Statement Statement) (abstraction (format (representation pre) \n+ (representation post)))) - (def: block + (def block (-> Statement Text) (let [close (format \n+ "}")] (|>> representation @@ -181,7 +181,7 @@ (text.enclosed ["{" close])))) - (def: .public (function_definition name inputs body) + (def .public (function_definition name inputs body) (-> Var (List Var) Statement Statement) (|> body ..block @@ -193,14 +193,14 @@ " ") abstraction)) - (def: .public (function name inputs body) + (def .public (function name inputs body) (-> Var (List Var) Statement Computation) (|> (..function_definition name inputs body) representation ..expression abstraction)) - (def: .public (closure inputs body) + (def .public (closure inputs body) (-> (List Var) Statement Computation) (|> body ..block @@ -214,7 +214,7 @@ abstraction)) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Expression Expression Computation) (|> (format (representation subject) " " <op> " " (representation param)) ..expression @@ -244,7 +244,7 @@ ) (with_template [<prefix> <name>] - [(def: .public <name> + [(def .public <name> (-> Expression Computation) (|>> representation (text.prefix <prefix>) ..expression abstraction))] @@ -255,7 +255,7 @@ (with_template [<name> <input> <format>] [... A 32-bit integer expression. - (def: .public (<name> value) + (def .public (<name> value) (-> <input> Computation) (abstraction (..expression (format (<format> value) "|0"))))] @@ -263,13 +263,13 @@ [i32 Int %.int] ) - (def: .public (int value) + (def .public (int value) (-> Int Literal) (abstraction (.if (i.< +0 value) (%.int value) (%.nat (.nat value))))) - (def: .public (? test then else) + (def .public (? test then else) (-> Expression Expression Expression Computation) (|> (format (representation test) " ? " (representation then) @@ -277,14 +277,14 @@ ..expression abstraction)) - (def: .public type_of + (def .public type_of (-> Expression Computation) (|>> representation (format "typeof ") ..expression abstraction)) - (def: .public (new constructor inputs) + (def .public (new constructor inputs) (-> Expression (List Expression) Computation) (|> (format "new " (representation constructor) (|> inputs @@ -294,71 +294,71 @@ ..expression abstraction)) - (def: .public statement + (def .public statement (-> Expression Statement) (|>> representation (text.suffix ..statement_suffix) abstraction)) - (def: .public use_strict + (def .public use_strict Statement (abstraction (format text.double_quote "use strict" text.double_quote ..statement_suffix))) - (def: .public (declare name) + (def .public (declare name) (-> Var Statement) (abstraction (format "var " (representation name) ..statement_suffix))) - (def: .public (define name value) + (def .public (define name value) (-> Var Expression Statement) (abstraction (format "var " (representation name) " = " (representation value) ..statement_suffix))) - (def: .public (set name value) + (def .public (set name value) (-> Location Expression Statement) (abstraction (format (representation name) " = " (representation value) ..statement_suffix))) - (def: .public (throw message) + (def .public (throw message) (-> Expression Statement) (abstraction (format "throw " (representation message) ..statement_suffix))) - (def: .public (return value) + (def .public (return value) (-> Expression Statement) (abstraction (format "return " (representation value) ..statement_suffix))) - (def: .public delete + (def .public delete (-> Location Expression) (|>> representation (format "delete ") ..expression abstraction)) - (def: .public (if test then! else!) + (def .public (if test then! else!) (-> Expression Statement Statement Statement) (abstraction (format "if(" (representation test) ") " (..block then!) " else " (..block else!)))) - (def: .public (when test then!) + (def .public (when test then!) (-> Expression Statement Statement) (abstraction (format "if(" (representation test) ") " (..block then!)))) - (def: .public (while test body) + (def .public (while test body) (-> Expression Statement Loop) (abstraction (format "while(" (representation test) ") " (..block body)))) - (def: .public (do_while test body) + (def .public (do_while test body) (-> Expression Statement Loop) (abstraction (format "do " (..block body) " while(" (representation test) ")" ..statement_suffix))) - (def: .public (try body [exception catch]) + (def .public (try body [exception catch]) (-> Statement [Var Statement] Statement) (abstraction (format "try " (..block body) " catch(" (representation exception) ") " (..block catch)))) - (def: .public (for var init condition update iteration) + (def .public (for var init condition update iteration) (-> Var Expression Expression Expression Statement Loop) (abstraction (format "for(" (representation (..define var init)) " " (representation condition) @@ -366,20 +366,20 @@ ")" (..block iteration)))) - (def: .public label + (def .public label (-> Text Label) (|>> abstraction)) - (def: .public (with_label label loop) + (def .public (with_label label loop) (-> Label Loop Statement) (abstraction (format (representation label) ": " (representation loop)))) (with_template [<keyword> <0> <1>] - [(def: .public <0> + [(def .public <0> Statement (abstraction (format <keyword> ..statement_suffix))) - (def: .public (<1> label) + (def .public (<1> label) (-> Label Statement) (abstraction (format <keyword> " " (representation label) ..statement_suffix)))] @@ -388,7 +388,7 @@ ) (with_template [<name> <js>] - [(def: .public <name> + [(def .public <name> (-> Location Expression) (|>> representation (text.suffix <js>) @@ -398,11 +398,11 @@ [-- "--"] ) - (def: .public (comment commentary on) + (def .public (comment commentary on) (All (_ kind) (-> Text (Code kind) (Code kind))) (abstraction (format "/* " commentary " */" " " (representation on)))) - (def: .public (switch input cases default) + (def .public (switch input cases default) (-> Expression (List [(List Literal) Statement]) (Maybe Statement) Statement) (abstraction (format "switch (" (representation input) ") " (|> (format (|> cases @@ -425,13 +425,13 @@ ) (with_template [<apply> <arg>+ <type>+ <function>+] - [(`` (def: .public (<apply> function) + [(`` (def .public (<apply> function) (-> Expression (~~ (template.spliced <type>+)) Computation) (.function (_ (~~ (template.spliced <arg>+))) (..apply function (list (~~ (template.spliced <arg>+))))))) (`` (with_template [<definition> <function>] - [(def: .public <definition> (<apply> (..var <function>)))] + [(def .public <definition> (<apply> (..var <function>)))] (~~ (template.spliced <function>+))))] diff --git a/stdlib/source/library/lux/target/jvm/attribute.lux b/stdlib/source/library/lux/target/jvm/attribute.lux index 30a3fe5f3..eb6fd8566 100644 --- a/stdlib/source/library/lux/target/jvm/attribute.lux +++ b/stdlib/source/library/lux/target/jvm/attribute.lux @@ -35,7 +35,7 @@ #length U4 #info about])) -(def: .public (info_equivalence Equivalence<about>) +(def .public (info_equivalence Equivalence<about>) (All (_ about) (-> (Equivalence about) (Equivalence (Info about)))) @@ -44,7 +44,7 @@ //unsigned.equivalence Equivalence<about>)) -(def: (info_writer writer) +(def (info_writer writer) (All (_ about) (-> (Writer about) (Writer (Info about)))) @@ -67,7 +67,7 @@ <Code>) ) -(def: .public equivalence +(def .public equivalence (Equivalence Attribute) (equivalence.rec (function (_ equivalence) @@ -77,7 +77,7 @@ (info_equivalence //index.equivalence) )))) -(def: common_attribute_length +(def common_attribute_length (all n.+ ... u2 attribute_name_index; //unsigned.bytes/2 @@ -85,7 +85,7 @@ //unsigned.bytes/4 )) -(def: (length attribute) +(def (length attribute) (-> Attribute Nat) (case attribute (^.with_template [<tag>] @@ -96,19 +96,19 @@ [#Signature]))) ... TODO: Inline ASAP -(def: (constant' index @name) +(def (constant' index @name) (-> (Constant Any) (Index UTF8) Attribute) {#Constant [#name @name ... https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.2 #length (|> /constant.length //unsigned.u4 try.trusted) #info index]}) -(def: .public (constant index) +(def .public (constant index) (-> (Constant Any) (Resource Attribute)) (//pool#each (constant' index) (//pool.utf8 "ConstantValue"))) ... TODO: Inline ASAP -(def: (code' specification @name) +(def (code' specification @name) (-> Code (Index UTF8) Attribute) {#Code [#name @name ... https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3 @@ -118,26 +118,26 @@ try.trusted) #info specification]}) -(def: .public (code specification) +(def .public (code specification) (-> Code (Resource Attribute)) (//pool#each (code' specification) (//pool.utf8 "Code"))) ... TODO: Inline ASAP -(def: (signature' it @name) +(def (signature' it @name) (-> (Index UTF8) (Index UTF8) Attribute) {#Signature [#name @name ... https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.9 #length (|> //index.length //unsigned.u4 try.trusted) #info it]}) -(def: .public (signature it) +(def .public (signature it) (All (_ category) (-> (Signature category) (Resource Attribute))) (do [! //pool.monad] [it (|> it //signature.signature //pool.utf8)] (at ! each (signature' it) (//pool.utf8 "Signature")))) -(def: .public (writer it) +(def .public (writer it) (Writer Attribute) (case it {#Constant it} diff --git a/stdlib/source/library/lux/target/jvm/attribute/code.lux b/stdlib/source/library/lux/target/jvm/attribute/code.lux index cc795b920..835b6726a 100644 --- a/stdlib/source/library/lux/target/jvm/attribute/code.lux +++ b/stdlib/source/library/lux/target/jvm/attribute/code.lux @@ -29,7 +29,7 @@ #exception_table (Sequence Exception) #attributes (Sequence Attribute)])) -(def: .public (length length code) +(def .public (length length code) (All (_ Attribute) (-> (-> Attribute Nat) (Code Attribute) Nat)) (all n.+ ... u2 max_stack; @@ -54,7 +54,7 @@ (sequence#each length) (sequence#mix n.+ 0)))) -(def: .public (equivalence attribute_equivalence) +(def .public (equivalence attribute_equivalence) (All (_ attribute) (-> (Equivalence attribute) (Equivalence (Code attribute)))) (all product.equivalence @@ -65,7 +65,7 @@ )) ... https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3 -(def: .public (writer writer code) +(def .public (writer writer code) (All (_ Attribute) (-> (Writer Attribute) (Writer (Code Attribute)))) (all binaryF#composite ... u2 max_stack; diff --git a/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux b/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux index b71573669..f71d52cfd 100644 --- a/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux +++ b/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux @@ -26,7 +26,7 @@ #handler Address #catch (Index Class)])) -(def: .public equivalence +(def .public equivalence (Equivalence Exception) (all product.equivalence ////address.equivalence @@ -36,7 +36,7 @@ )) ... https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3 -(def: .public length +(def .public length Nat (all n.+ ... u2 start_pc; @@ -49,7 +49,7 @@ ////unsigned.bytes/2 )) -(def: .public writer +(def .public writer (Writer Exception) (all \\format.and ////address.writer diff --git a/stdlib/source/library/lux/target/jvm/attribute/constant.lux b/stdlib/source/library/lux/target/jvm/attribute/constant.lux index 6e20c2ad1..34c8582ca 100644 --- a/stdlib/source/library/lux/target/jvm/attribute/constant.lux +++ b/stdlib/source/library/lux/target/jvm/attribute/constant.lux @@ -15,13 +15,13 @@ (type: .public (Constant a) (Index (Value a))) -(def: .public equivalence +(def .public equivalence (All (_ a) (Equivalence (Constant a))) ///index.equivalence) -(def: .public length +(def .public length ///index.length) -(def: .public writer +(def .public writer (All (_ a) (Writer (Constant a))) ///index.writer) diff --git a/stdlib/source/library/lux/target/jvm/bytecode.lux b/stdlib/source/library/lux/target/jvm/bytecode.lux index 882c0dfdf..99901a4a3 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode.lux @@ -64,7 +64,7 @@ #next Label #known Resolver])) -(def: fresh +(def fresh Tracker [#program_counter /address.start #next 0 @@ -73,16 +73,16 @@ (type: .public Relative (-> Resolver (Try [(Sequence Exception) Instruction]))) -(def: no_exceptions +(def no_exceptions (Sequence Exception) sequence.empty) -(def: relative#identity +(def relative#identity Relative (function (_ _) {try.#Success [..no_exceptions _.empty]})) -(def: try|do +(def try|do (template (_ <binding> <term> <then>) [(.case <term> {try.#Success <binding>} @@ -91,11 +91,11 @@ failure (as_expected failure))])) -(def: try|in +(def try|in (template (_ <it>) [{try.#Success <it>}])) -(def: (relative#composite left right) +(def (relative#composite left right) (-> Relative Relative Relative) (cond (same? ..relative#identity left) right @@ -110,16 +110,16 @@ (try|in [(at sequence.monoid composite left_exceptions right_exceptions) (_#composite left_instruction right_instruction)]))))) -(def: relative_monoid +(def relative_monoid (Monoid Relative) (implementation - (def: identity ..relative#identity) - (def: composite ..relative#composite))) + (def identity ..relative#identity) + (def composite ..relative#composite))) (type: .public (Bytecode a) (+State Try [Pool Environment Tracker] (Writer Relative a))) -(def: .public new_label +(def .public new_label (Bytecode Label) (function (_ [pool environment tracker]) {try.#Success [[pool @@ -144,7 +144,7 @@ "Expected" (/stack.format expected) "Actual" (/stack.format actual))) -(def: .public (set? label) +(def .public (set? label) (-> Label (Bytecode (Maybe [Stack Address]))) (function (_ state) (let [[pool environment tracker] state] @@ -157,7 +157,7 @@ _ {.#None})]]}))) -(def: .public (acknowledged? label) +(def .public (acknowledged? label) (-> Label (Bytecode (Maybe Stack))) (function (_ state) (let [[pool environment tracker] state] @@ -170,7 +170,7 @@ _ {.#None})]]}))) -(def: .public stack +(def .public stack (Bytecode (Maybe Stack)) (function (_ state) (let [[pool environment tracker] state] @@ -185,7 +185,7 @@ tracker)] [..relative#identity []]]))] - (def: .public (set_label label) + (def .public (set_label label) (-> Label (Bytecode Any)) (function (_ [pool environment tracker]) (let [@here (the #program_counter tracker)] @@ -205,10 +205,10 @@ environment)) <success>)))))) -(def: .public functor +(def .public functor (Functor Bytecode) (implementation - (def: (each $ it) + (def (each $ it) (function (_ state) (case (it state) {try.#Success [state' [relative it]]} @@ -218,16 +218,16 @@ failure (as_expected failure)))))) -(def: .public monad +(def .public monad (Monad Bytecode) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in it) + (def (in it) (function (_ state) {try.#Success [state [relative#identity it]]})) - (def: (conjoint ^^it) + (def (conjoint ^^it) (function (_ state) (case (^^it state) {try.#Success [state' [left ^it]]} @@ -243,7 +243,7 @@ failure (as_expected failure)))))) -(def: .public (when_continuous it) +(def .public (when_continuous it) (-> (Bytecode Any) (Bytecode Any)) (do ..monad [stack ..stack] @@ -255,7 +255,7 @@ _ (in [])))) -(def: .public (when_acknowledged @ it) +(def .public (when_acknowledged @ it) (-> Label (Bytecode Any) (Bytecode Any)) (do ..monad [?@ (..acknowledged? @)] @@ -267,27 +267,27 @@ _ (in [])))) -(def: .public (failure error) +(def .public (failure error) (-> Text Bytecode) (function (_ _) {try.#Failure error})) -(def: .public (except exception value) +(def .public (except exception value) (All (_ e) (-> (exception.Exception e) e Bytecode)) (..failure (exception.error exception value))) -(def: .public (resolve environment bytecode) +(def .public (resolve environment bytecode) (All (_ a) (-> Environment (Bytecode a) (Resource [Environment (Sequence Exception) Instruction a]))) (function (_ pool) (<| (try|do [[pool environment tracker] [relative output]] (bytecode [pool environment ..fresh])) (try|do [exceptions instruction] (relative (the #known tracker))) (try|in [pool [environment exceptions instruction output]])))) -(def: (step estimator counter) +(def (step estimator counter) (-> Estimator Address (Try Address)) (/address.move (estimator counter) counter)) -(def: (bytecode consumption production registry [estimator bytecode] input) +(def (bytecode consumption production registry [estimator bytecode] input) (All (_ a) (-> U2 U2 Registry [Estimator (-> [a] Instruction)] a (Bytecode Any))) (function (_ [pool environment tracker]) (<| (try|do environment' (|> environment @@ -304,7 +304,7 @@ []]])))) (with_template [<name> <frames>] - [(def: <name> U2 + [(def <name> U2 (|> <frames> //unsigned.u2 try.trusted))] [$0 0] @@ -317,7 +317,7 @@ ) (with_template [<name> <registry>] - [(def: <name> Registry (|> <registry> //unsigned.u2 try.trusted /registry.registry))] + [(def <name> Registry (|> <registry> //unsigned.u2 try.trusted /registry.registry))] [@_ 0] [@0 1] @@ -328,7 +328,7 @@ ) (with_template [<name> <consumption> <production> <registry> <instruction>] - [(def: .public <name> + [(def .public <name> (Bytecode Any) (..bytecode <consumption> <production> @@ -511,7 +511,7 @@ [monitorexit $1 $0 @_ _.monitorexit] ) -(def: discontinuity! +(def discontinuity! (Bytecode Any) (function (_ [pool environment tracker]) (<| (try|do _ (/environment.stack environment)) @@ -522,7 +522,7 @@ []]])))) (with_template [<name> <consumption> <instruction>] - [(def: .public <name> + [(def .public <name> (Bytecode Any) (do ..monad [_ (..bytecode <consumption> $0 @_ <instruction> [])] @@ -538,11 +538,11 @@ [athrow $1 _.athrow] ) -(def: .public (bipush byte) +(def .public (bipush byte) (-> S1 (Bytecode Any)) (..bytecode $0 $1 @_ _.bipush [byte])) -(def: (lifted resource) +(def (lifted resource) (All (_ a) (-> (Resource a) (Bytecode a))) @@ -552,7 +552,7 @@ [..relative#identity output]])))) -(def: .public (string value) +(def .public (string value) (-> //constant.UTF8 (Bytecode Any)) (do ..monad [index (..lifted (//constant/pool.string value))] @@ -572,7 +572,7 @@ ("static" doubleToRawLongBits "manual" [double] long)) (with_template [<name> <type> <constructor> <constant> <wide> <to_lux> <specializations>] - [(def: .public (<name> value) + [(def .public (<name> value) (-> <type> (Bytecode Any)) (case (|> value <to_lux>) (^.with_template [<special> <instruction>] @@ -599,7 +599,7 @@ [+5 _.iconst_5])] ) -(def: (arbitrary_float value) +(def (arbitrary_float value) (-> java/lang/Float (Bytecode Any)) (do ..monad [index (..lifted (//constant/pool.float (//constant.float value)))] @@ -610,16 +610,16 @@ {try.#Failure _} (..bytecode $0 $1 @_ _.ldc_w/float [index])))) -(def: float_bits +(def float_bits (-> java/lang/Float Int) (|>> java/lang/Float::floatToRawIntBits ffi.int_to_long (as Int))) -(def: negative_zero_float_bits +(def negative_zero_float_bits (|> -0.0 (as java/lang/Double) ffi.double_to_float ..float_bits)) -(def: .public (float value) +(def .public (float value) (-> java/lang/Float (Bytecode Any)) (if (i.= ..negative_zero_float_bits (..float_bits value)) @@ -634,7 +634,7 @@ _ (..arbitrary_float value)))) (with_template [<name> <type> <constructor> <constant> <wide> <to_lux> <specializations>] - [(def: .public (<name> value) + [(def .public (<name> value) (-> <type> (Bytecode Any)) (case (|> value <to_lux>) (^.with_template [<special> <instruction>] @@ -651,21 +651,21 @@ [+1 _.lconst_1])] ) -(def: (arbitrary_double value) +(def (arbitrary_double value) (-> java/lang/Double (Bytecode Any)) (do ..monad [index (..lifted (//constant/pool.double (//constant.double (as Frac value))))] (..bytecode $0 $2 @_ _.ldc2_w/double [index]))) -(def: double_bits +(def double_bits (-> java/lang/Double Int) (|>> java/lang/Double::doubleToRawLongBits (as Int))) -(def: negative_zero_double_bits +(def negative_zero_double_bits (..double_bits (as java/lang/Double -0.0))) -(def: .public (double value) +(def .public (double value) (-> java/lang/Double (Bytecode Any)) (if (i.= ..negative_zero_double_bits (..double_bits value)) @@ -682,7 +682,7 @@ (exception.report "ID" (%.nat id))) -(def: (register id) +(def (register id) (-> Nat (Bytecode Register)) (case (//unsigned.u1 id) {try.#Success register} @@ -692,7 +692,7 @@ (..except ..invalid_register [id]))) (with_template [<for> <size> <name> <general> <specials>] - [(def: .public (<name> local) + [(def .public (<name> local) (-> Nat (Bytecode Any)) (with_expansions [<specials>' (template.spliced <specials>)] (`` (case local @@ -732,7 +732,7 @@ ) (with_template [<for> <size> <name> <general> <specials>] - [(def: .public (<name> local) + [(def .public (<name> local) (-> Nat (Bytecode Any)) (with_expansions [<specials>' (template.spliced <specials>)] (`` (case local @@ -772,7 +772,7 @@ ) (with_template [<consumption> <production> <name> <instruction> <input>] - [(def: .public <name> + [(def .public <name> (-> <input> (Bytecode Any)) (..bytecode <consumption> <production> @_ <instruction>))] @@ -796,7 +796,7 @@ (Either Big_Jump Jump)) -(def: (jump @from @to) +(def (jump @from @to) (-> Address Address (Try Any_Jump)) (<| (try|do jump (try#each //signed.value (/address.jump @from @to))) @@ -812,7 +812,7 @@ (exception.report "Label" (%.nat label))) -(def: (resolve_label label resolver) +(def (resolve_label label resolver) (-> Label Resolver (Try [Stack Address])) (case (dictionary.value label resolver) {.#Some [actual {.#Some address}]} @@ -825,7 +825,7 @@ _ (exception.except ..unknown_label [label]))) -(def: (acknowledge_label stack label tracker) +(def (acknowledge_label stack label tracker) (-> Stack Label Tracker Tracker) (case (dictionary.value label (the #known tracker)) {.#Some _} @@ -836,7 +836,7 @@ (revised #known (dictionary.has label [stack {.#None}]) tracker))) (with_template [<consumption> <name> <instruction>] - [(def: .public (<name> label) + [(def .public (<name> label) (-> Label (Bytecode Any)) (let [[estimator bytecode] <instruction>] (function (_ [pool environment tracker]) @@ -886,7 +886,7 @@ ) (with_template [<name> <instruction> <on_long_jump> <on_short_jump>] - [(def: .public (<name> label) + [(def .public (<name> label) (-> Label (Bytecode Any)) (let [[estimator bytecode] <instruction>] (function (_ [pool environment tracker]) @@ -928,7 +928,7 @@ (try|in [..no_exceptions (bytecode (/jump.lifted jump))])] ) -(def: (big_jump jump) +(def (big_jump jump) (-> Any_Jump Big_Jump) (case jump {.#Left big} @@ -939,7 +939,7 @@ (exception: .public invalid_tableswitch) -(def: .public (tableswitch minimum default [at_minimum afterwards]) +(def .public (tableswitch minimum default [at_minimum afterwards]) (-> S4 Label [Label (List Label)] (Bytecode Any)) (let [[estimator bytecode] _.tableswitch] (function (_ [pool environment tracker]) @@ -977,7 +977,7 @@ (exception: .public invalid_lookupswitch) -(def: .public (lookupswitch default cases) +(def .public (lookupswitch default cases) (-> Label (List [S4 Label]) (Bytecode Any)) (let [cases (list.sorted (function (_ [left _] [right _]) (i.< (//signed.value left) @@ -1016,13 +1016,13 @@ (exception.except ..invalid_lookupswitch [])))) []]])))))) -(def: reflection +(def reflection (All (_ category) (-> (Type (<| Return' Value' category)) Text)) (|>> type.reflection reflection.reflection)) (with_template [<consumption> <production> <name> <category> <instruction>] - [(def: .public (<name> class) + [(def .public (<name> class) (-> (Type <category>) (Bytecode Any)) (do ..monad [... TODO: Make sure it's impossible to have indexes greater than U2. @@ -1035,7 +1035,7 @@ [$1 $1 instanceof Object _.instanceof] ) -(def: .public (iinc register increase) +(def .public (iinc register increase) (-> Nat U1 (Bytecode Any)) (do ..monad [register (..register register)] @@ -1045,7 +1045,7 @@ (exception.report "Class" (..reflection class))) -(def: .public (multianewarray class dimensions) +(def .public (multianewarray class dimensions) (-> (Type Object) U1 (Bytecode Any)) (do ..monad [_ (is (Bytecode Any) @@ -1055,7 +1055,7 @@ index (..lifted (//constant/pool.class (//name.internal (..reflection class))))] (..bytecode (//unsigned.lifted/2 dimensions) $1 @_ _.multianewarray [index dimensions]))) -(def: (type_size type) +(def (type_size type) (-> (Type Return) Nat) (cond (same? type.void type) 0 @@ -1068,7 +1068,7 @@ 1)) (with_template [<static?> <name> <instruction> <method>] - [(def: .public (<name> class method type) + [(def .public (<name> class method type) (-> (Type Class) Text (Type Method) (Bytecode Any)) (let [[type_variables inputs output exceptions] (parser.method type)] (do ..monad @@ -1094,7 +1094,7 @@ ) (with_template [<consumption> <name> <1> <2>] - [(def: .public (<name> class field type) + [(def .public (<name> class field type) (-> (Type Class) Text (Type Value) (Bytecode Any)) (do ..monad [index (<| ..lifted @@ -1111,7 +1111,7 @@ ) (with_template [<name> <consumption/1> <1> <consumption/2> <2>] - [(def: .public (<name> class field type) + [(def .public (<name> class field type) (-> (Type Class) Text (Type Value) (Bytecode Any)) (do [! ..monad] [index (<| ..lifted @@ -1133,7 +1133,7 @@ "Start" (|> start /address.value //unsigned.value %.nat) "End" (|> end /address.value //unsigned.value %.nat))) -(def: .public (try @start @end @handler catch) +(def .public (try @start @end @handler catch) (-> Label Label Label (Type Class) (Bytecode Any)) (do ..monad [@catch (..lifted (//constant/pool.class (//name.internal (..reflection catch))))] @@ -1157,7 +1157,7 @@ _.empty]))) []]]}))) -(def: .public (composite pre post) +(def .public (composite pre post) (All (_ pre post) (-> (Bytecode pre) (Bytecode post) (Bytecode post))) (function (_ state) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/address.lux b/stdlib/source/library/lux/target/jvm/bytecode/address.lux index ddb1331dc..5c2dd04d2 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/address.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/address.lux @@ -26,49 +26,49 @@ (primitive .public Address U2 - (def: .public value + (def .public value (-> Address U2) (|>> representation)) - (def: .public start + (def .public start Address (|> 0 ///unsigned.u2 try.trusted abstraction)) - (def: .public (move distance) + (def .public (move distance) (-> U2 (-> Address (Try Address))) (|>> representation (///unsigned.+/2 distance) (at try.functor each (|>> abstraction)))) - (def: with_sign + (def with_sign (-> Address (Try S4)) (|>> representation ///unsigned.value .int ///signed.s4)) - (def: .public (jump from to) + (def .public (jump from to) (-> Address Address (Try Big_Jump)) (do try.monad [from (with_sign from) to (with_sign to)] (///signed.-/4 from to))) - (def: .public (after? reference subject) + (def .public (after? reference subject) (-> Address Address Bit) (n.> (|> reference representation ///unsigned.value) (|> subject representation ///unsigned.value))) - (def: .public equivalence + (def .public equivalence (Equivalence Address) (implementation - (def: (= reference subject) + (def (= reference subject) (at ///unsigned.equivalence = (representation reference) (representation subject))))) - (def: .public writer + (def .public writer (Writer Address) (|>> representation ///unsigned.writer/2)) - (def: .public format + (def .public format (Format Address) (|>> representation ///unsigned.value %.nat)) ) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux index cc3ff123c..14e8d5543 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux @@ -23,7 +23,7 @@ #stack (Maybe Stack)])) (with_template [<name> <limit>] - [(def: .public (<name> type) + [(def .public (<name> type) (-> (Type Method) (Try Environment)) (do try.monad [limit (<limit> type)] @@ -37,13 +37,13 @@ (type: .public Condition (-> Environment (Try Environment))) -(def: .public monoid +(def .public monoid (Monoid Condition) (implementation - (def: identity + (def identity (|>> {try.#Success})) - (def: (composite left right) + (def (composite left right) (function (_ environment) (do try.monad [environment (left environment)] @@ -51,7 +51,7 @@ (exception: .public discontinuity) -(def: .public (stack environment) +(def .public (stack environment) (-> Environment (Try Stack)) (case (the ..#stack environment) {.#Some stack} @@ -60,7 +60,7 @@ {.#None} (exception.except ..discontinuity []))) -(def: .public discontinue +(def .public discontinue (-> Environment Environment) (.has ..#stack {.#None})) @@ -70,7 +70,7 @@ "Expected" (/stack.format expected) "Actual" (/stack.format actual))) -(def: .public (continue expected environment) +(def .public (continue expected environment) (-> Stack Environment (Try [Stack Environment])) (case (the ..#stack environment) {.#Some actual} @@ -81,7 +81,7 @@ {.#None} {try.#Success [expected (.has ..#stack {.#Some expected} environment)]})) -(def: .public (consumes amount) +(def .public (consumes amount) (-> U2 Condition) ... TODO: Revisit this definition once lenses/optics have been implemented, ... since it can probably be simplified with them. @@ -91,7 +91,7 @@ current (/stack.pop amount previous)] (in (.has ..#stack {.#Some current} environment))))) -(def: .public (produces amount) +(def .public (produces amount) (-> U2 Condition) (function (_ environment) (do try.monad @@ -104,7 +104,7 @@ (.has ..#stack {.#Some current}) (.has [..#limit /limit.#stack] limit)))))) -(def: .public (has registry) +(def .public (has registry) (-> Registry Condition) (|>> (revised [..#limit /limit.#registry] (/registry.has registry)) {try.#Success})) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux index 7702e24e7..261e9a5ce 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux @@ -26,7 +26,7 @@ #registry Registry])) (with_template [<name> <registry>] - [(def: .public (<name> type) + [(def .public (<name> type) (-> (Type Method) (Try Limit)) (do try.monad [registry (<registry> type)] @@ -37,21 +37,21 @@ [virtual /registry.virtual] ) -(def: .public length +(def .public length (all n.+ ... u2 max_stack; /stack.length ... u2 max_locals; /registry.length)) -(def: .public equivalence +(def .public equivalence (Equivalence Limit) (all product.equivalence /stack.equivalence /registry.equivalence )) -(def: .public (writer limit) +(def .public (writer limit) (Writer Limit) (all \\format#composite (/stack.writer (the #stack limit)) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux index 6e3642501..3aae9a289 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux @@ -25,17 +25,17 @@ (type: .public Register U1) -(def: normal 1) -(def: wide 2) +(def normal 1) +(def wide 2) (primitive .public Registry U2 - (def: .public registry + (def .public registry (-> U2 Registry) (|>> abstraction)) - (def: (minimal type) + (def (minimal type) (-> (Type Method) Nat) (let [[type_variables inputs output exceptions] (/////type/parser.method type)] (|> inputs @@ -47,7 +47,7 @@ (list#mix n.+ 0)))) (with_template [<start> <name>] - [(def: .public <name> + [(def .public <name> (-> (Type Method) (Try Registry)) (|>> ..minimal (n.+ <start>) @@ -58,24 +58,24 @@ [1 virtual] ) - (def: .public equivalence + (def .public equivalence (Equivalence Registry) (at equivalence.functor each (|>> representation) /////unsigned.equivalence)) - (def: .public writer + (def .public writer (Writer Registry) (|>> representation /////unsigned.writer/2)) - (def: .public (has needed) + (def .public (has needed) (-> Registry Registry Registry) (|>> representation (/////unsigned.max/2 (representation needed)) abstraction)) (with_template [<name> <extra>] - [(def: .public <name> + [(def .public <name> (-> Register Registry) (let [extra (|> <extra> /////unsigned.u2 try.trusted)] (|>> /////unsigned.lifted/2 @@ -88,5 +88,5 @@ ) ) -(def: .public length +(def .public length /////unsigned.bytes/2) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux index a3cec4224..59c3c50ce 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux @@ -21,7 +21,7 @@ U2 (with_template [<frames> <name>] - [(def: .public <name> + [(def .public <name> Stack (|> <frames> /////unsigned.u2 maybe.trusted abstraction))] @@ -29,22 +29,22 @@ [1 catch] ) - (def: .public equivalence + (def .public equivalence (Equivalence Stack) (at equivalence.functor each (|>> representation) /////unsigned.equivalence)) - (def: .public writer + (def .public writer (Writer Stack) (|>> representation /////unsigned.writer/2)) - (def: stack + (def stack (-> U2 Stack) (|>> abstraction)) (with_template [<op> <name>] - [(def: .public (<name> amount) + [(def .public (<name> amount) (-> U2 (-> Stack (Try Stack))) (|>> representation (<op> amount) @@ -54,16 +54,16 @@ [/////unsigned.-/2 pop] ) - (def: .public (max left right) + (def .public (max left right) (-> Stack Stack Stack) (abstraction (/////unsigned.max/2 (representation left) (representation right)))) - (def: .public format + (def .public format (Format Stack) (|>> representation /////unsigned.value %.nat)) ) -(def: .public length +(def .public length /////unsigned.bytes/2) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux index 9345f2ec2..ca4dfcff6 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux @@ -44,18 +44,18 @@ (type: .public Estimator (-> Address Size)) -(def: fixed +(def fixed (-> Size Estimator) function.constant) (type: .public Instruction (-> Specification Specification)) -(def: .public empty +(def .public empty Instruction function.identity) -(def: .public result +(def .public result (-> Instruction Specification) (function.on \\format.no_op)) @@ -63,7 +63,7 @@ Nat) (with_template [<size> <name>] - [(def: <name> Size (|> <size> ///unsigned.u2 try.trusted))] + [(def <name> Size (|> <size> ///unsigned.u2 try.trusted))] [1 opcode_size] [1 register_size] @@ -73,14 +73,14 @@ [4 integer_size] ) -(def: (nullary' opcode) +(def (nullary' opcode) (-> Opcode Mutation) (function (_ [offset binary]) [(n.+ (///unsigned.value ..opcode_size) offset) (binary.has_8! offset opcode binary)])) -(def: nullary +(def nullary [Estimator (-> Opcode Instruction)] [(..fixed ..opcode_size) (function (_ opcode [size mutation]) @@ -89,7 +89,7 @@ (|>> mutation ((nullary' opcode)))])]) (with_template [<name> <size>] - [(def: <name> + [(def <name> Size (|> ..opcode_size (///unsigned.+/2 <size>) @@ -102,7 +102,7 @@ (with_template [<shift> <name> <inputT> <writer> <unwrap>] [(with_expansions [<private> (template.symbol ["'" <name>])] - (def: (<private> opcode input0) + (def (<private> opcode input0) (-> Opcode <inputT> Mutation) (function (_ [offset binary]) [(n.+ (///unsigned.value <shift>) offset) @@ -111,7 +111,7 @@ (<writer> (n.+ (///unsigned.value ..opcode_size) offset) (<unwrap> input0)))])) - (def: <name> + (def <name> [Estimator (-> Opcode <inputT> Instruction)] [(..fixed <shift>) (function (_ opcode input0 [size mutation]) @@ -126,7 +126,7 @@ (with_template [<shift> <name> <inputT> <writer>] [(with_expansions [<private> (template.symbol ["'" <name>])] - (def: (<private> opcode input0) + (def (<private> opcode input0) (-> Opcode <inputT> Mutation) (function (_ [offset binary]) [(n.+ (///unsigned.value <shift>) offset) @@ -135,7 +135,7 @@ (<writer> (n.+ (///unsigned.value ..opcode_size) offset) (///signed.value input0)))])) - (def: <name> + (def <name> [Estimator (-> Opcode <inputT> Instruction)] [(..fixed <shift>) (function (_ opcode input0 [size mutation]) @@ -146,13 +146,13 @@ [..size/2 unary/2' S2 binary.has_16!] ) -(def: size/11 +(def size/11 Size (|> ..opcode_size (///unsigned.+/2 ..register_size) try.trusted (///unsigned.+/2 ..byte_size) try.trusted)) -(def: (binary/11' opcode input0 input1) +(def (binary/11' opcode input0 input1) (-> Opcode U1 U1 Mutation) (function (_ [offset binary]) [(n.+ (///unsigned.value ..size/11) offset) @@ -163,20 +163,20 @@ (binary.has_8! (n.+ (///unsigned.value ..size/1) offset) (///unsigned.value input1)))])) -(def: binary/11 +(def binary/11 [Estimator (-> Opcode U1 U1 Instruction)] [(..fixed ..size/11) (function (_ opcode input0 input1 [size mutation]) [(n.+ (///unsigned.value ..size/11) size) (|>> mutation ((binary/11' opcode input0 input1)))])]) -(def: size/21 +(def size/21 Size (|> ..opcode_size (///unsigned.+/2 ..index_size) try.trusted (///unsigned.+/2 ..byte_size) try.trusted)) -(def: (binary/21' opcode input0 input1) +(def (binary/21' opcode input0 input1) (-> Opcode U2 U1 Mutation) (function (_ [offset binary]) [(n.+ (///unsigned.value ..size/21) offset) @@ -187,21 +187,21 @@ (binary.has_8! (n.+ (///unsigned.value ..size/2) offset) (///unsigned.value input1)))])) -(def: binary/21 +(def binary/21 [Estimator (-> Opcode U2 U1 Instruction)] [(..fixed ..size/21) (function (_ opcode input0 input1 [size mutation]) [(n.+ (///unsigned.value ..size/21) size) (|>> mutation ((binary/21' opcode input0 input1)))])]) -(def: size/211 +(def size/211 Size (|> ..opcode_size (///unsigned.+/2 ..index_size) try.trusted (///unsigned.+/2 ..byte_size) try.trusted (///unsigned.+/2 ..byte_size) try.trusted)) -(def: (trinary/211' opcode input0 input1 input2) +(def (trinary/211' opcode input0 input1 input2) (-> Opcode U2 U1 U1 Mutation) (function (_ [offset binary]) [(n.+ (///unsigned.value ..size/211) offset) @@ -214,7 +214,7 @@ (binary.has_8! (n.+ (///unsigned.value ..size/21) offset) (///unsigned.value input2)))])) -(def: trinary/211 +(def trinary/211 [Estimator (-> Opcode U2 U1 U1 Instruction)] [(..fixed ..size/211) (function (_ opcode input0 input1 input2 [size mutation]) @@ -224,12 +224,12 @@ (primitive .public Primitive_Array_Type U1 - (def: code + (def code (-> Primitive_Array_Type U1) (|>> representation)) (with_template [<code> <name>] - [(def: .public <name> + [(def .public <name> (|> <code> ///unsigned.u1 try.trusted abstraction))] [04 t_boolean] @@ -481,7 +481,7 @@ [<input_name>] <inputs>')] - (def: .public <name> + (def .public <name> [Estimator (-> [<input_types>] Instruction)] (let [[estimator <arity>'] <arity>] [estimator @@ -564,7 +564,7 @@ [["B9" invokeinterface [[index (Index (Reference Method))] [count U1] [output_count U1]] [(///index.value index) count (try.trusted (///unsigned.u1 0))]]]] )) -(def: (switch_padding offset) +(def (switch_padding offset) (-> Nat Nat) (let [parameter_start (n.+ (///unsigned.value ..opcode_size) offset)] @@ -572,7 +572,7 @@ (n.- (n.% 4 parameter_start) 4)))) -(def: .public tableswitch +(def .public tableswitch [(-> Nat Estimator) (-> S4 Big_Jump [Big_Jump (List Big_Jump)] Instruction)] (let [estimator (is (-> Nat Estimator) @@ -636,7 +636,7 @@ size) (|>> mutation tableswitch_mutation)]))))])) -(def: .public lookupswitch +(def .public lookupswitch [(-> Nat Estimator) (-> Big_Jump (List [S4 Big_Jump]) Instruction)] (let [case_size (n.+ (///unsigned.value ..integer_size) @@ -694,10 +694,10 @@ size) (|>> mutation lookupswitch_mutation)]))))])) -(def: .public monoid +(def .public monoid (Monoid Instruction) (implementation - (def: identity ..empty) + (def identity ..empty) - (def: (composite left right) + (def (composite left right) (|>> left right)))) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/jump.lux b/stdlib/source/library/lux/target/jvm/bytecode/jump.lux index 7d608a8e5..676930f65 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/jump.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/jump.lux @@ -13,17 +13,17 @@ (type: .public Jump S2) -(def: .public equivalence +(def .public equivalence (Equivalence Jump) ///signed.equivalence) -(def: .public writer +(def .public writer (Writer Jump) ///signed.writer/2) (type: .public Big_Jump S4) -(def: .public lifted +(def .public lifted (-> Jump Big_Jump) ///signed.lifted/4) diff --git a/stdlib/source/library/lux/target/jvm/class.lux b/stdlib/source/library/lux/target/jvm/class.lux index f93320b4c..cbbc47502 100644 --- a/stdlib/source/library/lux/target/jvm/class.lux +++ b/stdlib/source/library/lux/target/jvm/class.lux @@ -57,7 +57,7 @@ ["4000" enum] ) -(def: .public equivalence +(def .public equivalence (Equivalence Class) (all product.equivalence //unsigned.equivalence @@ -72,7 +72,7 @@ (sequence.equivalence //method.equivalence) (sequence.equivalence //attribute.equivalence))) -(def: (install_classes this super interfaces) +(def (install_classes this super interfaces) (-> Internal Internal (List Internal) (Resource [(Index //constant.Class) (Index //constant.Class) (Sequence (Index //constant.Class))])) (do [! //pool.monad] @@ -87,7 +87,7 @@ interfaces))] (in [@this @super @interfaces]))) -(def: .public (class version modifier +(def .public (class version modifier this signature super interfaces fields methods attributes) (-> Major (Modifier Class) @@ -127,7 +127,7 @@ {.#None} attributes)]))) -(def: .public (writer class) +(def .public (writer class) (Writer Class) (`` (all binaryF#composite (~~ (with_template [<writer> <slot>] diff --git a/stdlib/source/library/lux/target/jvm/constant.lux b/stdlib/source/library/lux/target/jvm/constant.lux index 8539fbf13..ebeccfaa4 100644 --- a/stdlib/source/library/lux/target/jvm/constant.lux +++ b/stdlib/source/library/lux/target/jvm/constant.lux @@ -36,28 +36,28 @@ (type: .public UTF8 Text) -(def: utf8_writer +(def utf8_writer (Writer UTF8) binaryF.utf8_16) (primitive .public Class (Index UTF8) - (def: .public index + (def .public index (-> Class (Index UTF8)) (|>> representation)) - (def: .public class + (def .public class (-> (Index UTF8) Class) (|>> abstraction)) - (def: .public class_equivalence + (def .public class_equivalence (Equivalence Class) (at equivalence.functor each ..index //index.equivalence)) - (def: class_writer + (def class_writer (Writer Class) (|>> representation //index.writer)) ) @@ -66,10 +66,10 @@ "[1]::[0]" ("static" floatToRawIntBits "manual" [float] int)) -(def: .public float_equivalence +(def .public float_equivalence (Equivalence java/lang/Float) (implementation - (def: (= parameter subject) + (def (= parameter subject) (for @.old ("jvm feq" parameter subject) @@ -85,11 +85,11 @@ (primitive .public (Value kind) kind - (def: .public value + (def .public value (All (_ kind) (-> (Value kind) kind)) (|>> representation)) - (def: .public (value_equivalence Equivalence<kind>) + (def .public (value_equivalence Equivalence<kind>) (All (_ kind) (-> (Equivalence kind) (Equivalence (Value kind)))) @@ -101,7 +101,7 @@ [(type: .public <type> (Value <marker>)) - (def: .public <constructor> + (def .public <constructor> (-> <marker> <type>) (|>> abstraction))] @@ -113,7 +113,7 @@ ) (with_template [<writer_name> <type> <write> <writer>] - [(def: <writer_name> + [(def <writer_name> (Writer <type>) (`` (|>> representation (~~ (template.spliced <write>)) @@ -138,13 +138,13 @@ #name_and_type (Index (Name_And_Type of))])) (with_template [<type> <equivalence> <writer>] - [(def: .public <equivalence> + [(def .public <equivalence> (Equivalence (<type> Any)) (all product.equivalence //index.equivalence //index.equivalence)) - (def: <writer> + (def <writer> (Writer (<type> Any)) (all binaryF.and //index.writer @@ -168,7 +168,7 @@ {#Interface_Method (Reference //category.Method)} {#Name_And_Type (Name_And_Type Any)})) -(def: .public (size constant) +(def .public (size constant) (-> Constant Nat) (case constant (^.or {#Long _} {#Double _}) @@ -177,12 +177,12 @@ _ 1)) -(def: .public equivalence +(def .public equivalence (Equivalence Constant) ... TODO: Delete the explicit "implementation" and use the combinator ... version below as soon as the new format for variants is implemented. (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] (^.with_template [<tag> <equivalence>] [[{<tag> reference} {<tag> sample}] @@ -223,7 +223,7 @@ ... ) ) -(def: .public writer +(def .public writer (Writer Constant) (with_expansions [<constants> (these [#UTF8 /tag.utf8 ..utf8_writer] [#Integer /tag.integer ..integer_writer] diff --git a/stdlib/source/library/lux/target/jvm/constant/pool.lux b/stdlib/source/library/lux/target/jvm/constant/pool.lux index b953600bf..787af5c99 100644 --- a/stdlib/source/library/lux/target/jvm/constant/pool.lux +++ b/stdlib/source/library/lux/target/jvm/constant/pool.lux @@ -35,7 +35,7 @@ (type: .public Pool [Index (Sequence [Index Constant])]) -(def: .public equivalence +(def .public equivalence (Equivalence Pool) (product.equivalence //index.equivalence (sequence.equivalence (product.equivalence //index.equivalence @@ -44,10 +44,10 @@ (type: .public (Resource a) (+State Try Pool a)) -(def: .public functor +(def .public functor (Functor Resource) (implementation - (def: (each $ it) + (def (each $ it) (|>> it (pipe.case {try.#Success [state output]} @@ -57,16 +57,16 @@ failure (as_expected failure)))))) -(def: .public monad +(def .public monad (Monad Resource) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in it) + (def (in it) (function (_ state) {try.#Success [state it]})) - (def: (conjoint it) + (def (conjoint it) (function (_ state) (case (it state) {try.#Success [state' it']} @@ -76,7 +76,7 @@ failure (as_expected failure)))))) -(def: try|each +(def try|each (template (_ <binding> <value> <body>) [(case <value> {try.#Success <binding>} @@ -86,11 +86,11 @@ failure (as_expected failure))])) -(def: try|in +(def try|in (template (_ <it>) [{try.#Success <it>}])) -(def: !add +(def !add (template (_ <state> <tag> <equivalence> <value>) [(let [[current pool] <state> <value>' <value>] @@ -120,12 +120,12 @@ (sequence.suffix [current new] pool)] current]))))))])) -(def: /|do +(def /|do (template (_ <state> <body>) [(function (_ <state>) <body>)])) -(def: /|each +(def /|each (template (_ <state> <binding> <value> <body>) [(case (<value> <state>) {try.#Success [<state> <binding>]} @@ -139,7 +139,7 @@ (-> of (Resource (Index of)))) (with_template [<name> <type> <tag> <equivalence>] - [(def: .public (<name> value) + [(def .public (<name> value) (Adder <type>) (<| (/|do %) (!add % <tag> <equivalence> value)))] @@ -151,21 +151,21 @@ [utf8 UTF8 //.#UTF8 text.equivalence] ) -(def: .public (string value) +(def .public (string value) (-> Text (Resource (Index String))) (<| (/|do %) (/|each % @value (utf8 value)) (let [value (//.string @value)]) (!add % //.#String (//.value_equivalence //index.equivalence) value))) -(def: .public (class name) +(def .public (class name) (-> Internal (Resource (Index Class))) (<| (/|do %) (/|each % @name (utf8 (//name.read name))) (let [value (//.class @name)]) (!add % //.#Class //.class_equivalence value))) -(def: .public (descriptor value) +(def .public (descriptor value) (All (_ kind) (-> (Descriptor kind) (Resource (Index (Descriptor kind))))) @@ -178,7 +178,7 @@ [#name UTF8 #descriptor (Descriptor of)])) -(def: .public (name_and_type [name descriptor]) +(def .public (name_and_type [name descriptor]) (All (_ of) (-> (Member of) (Resource (Index (Name_And_Type of))))) (<| (/|do %) @@ -187,7 +187,7 @@ (!add % //.#Name_And_Type //.name_and_type_equivalence [//.#name @name //.#descriptor @descriptor]))) (with_template [<name> <tag> <of>] - [(def: .public (<name> class member) + [(def .public (<name> class member) (-> External (Member <of>) (Resource (Index (Reference <of>)))) (<| (/|do %) (/|each % @class (..class (//name.internal class))) @@ -199,11 +199,11 @@ [interface_method //.#Interface_Method Method] ) -(def: !index +(def !index (template (_ <index>) [(|> <index> //index.value //unsigned.value)])) -(def: .public writer +(def .public writer (Writer Pool) (function (_ [next pool]) (sequence#mix (function (_ [_index post] pre) @@ -211,7 +211,7 @@ (\\format.bits_16 (!index next)) pool))) -(def: .public empty +(def .public empty Pool [(|> 1 //unsigned.u2 try.trusted //index.index) sequence.empty]) diff --git a/stdlib/source/library/lux/target/jvm/constant/tag.lux b/stdlib/source/library/lux/target/jvm/constant/tag.lux index 2ac10790f..58684f493 100644 --- a/stdlib/source/library/lux/target/jvm/constant/tag.lux +++ b/stdlib/source/library/lux/target/jvm/constant/tag.lux @@ -17,15 +17,15 @@ (primitive .public Tag U1 - (def: .public equivalence + (def .public equivalence (Equivalence Tag) (implementation - (def: (= reference sample) + (def (= reference sample) (u1//= (representation reference) (representation sample))))) (with_template [<code> <name>] - [(def: .public <name> + [(def .public <name> Tag (|> <code> ///unsigned.u1 try.trusted abstraction))] @@ -45,7 +45,7 @@ [18 invoke_dynamic] ) - (def: .public writer + (def .public writer (Writer Tag) (|>> representation ///unsigned.writer/1)) ) diff --git a/stdlib/source/library/lux/target/jvm/encoding/name.lux b/stdlib/source/library/lux/target/jvm/encoding/name.lux index 2a322bace..068c11a36 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/name.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/name.lux @@ -7,8 +7,8 @@ [type [primitive (.except)]]]]) -(def: .public internal_separator "/") -(def: .public external_separator ".") +(def .public internal_separator "/") +(def .public external_separator ".") (type: .public External Text) @@ -16,26 +16,26 @@ (primitive .public Internal Text - (def: .public internal + (def .public internal (-> External Internal) (|>> (text.replaced ..external_separator ..internal_separator) abstraction)) - (def: .public read + (def .public read (-> Internal Text) (|>> representation)) - (def: .public external + (def .public external (-> Internal External) (|>> representation (text.replaced ..internal_separator ..external_separator)))) -(def: .public safe +(def .public safe (-> Text External) (|>> ..internal ..external)) -(def: .public (qualify package class) +(def .public (qualify package class) (-> Text External External) (format (..safe package) ..external_separator class)) diff --git a/stdlib/source/library/lux/target/jvm/encoding/signed.lux b/stdlib/source/library/lux/target/jvm/encoding/signed.lux index 822e420b2..b00ff6ba3 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/signed.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/signed.lux @@ -25,21 +25,21 @@ (primitive .public (Signed brand) Int - (def: .public value + (def .public value (-> (Signed Any) Int) (|>> representation)) - (def: .public equivalence + (def .public equivalence (All (_ brand) (Equivalence (Signed brand))) (implementation - (def: (= reference sample) + (def (= reference sample) (i.= (representation reference) (representation sample))))) - (def: .public order + (def .public order (All (_ brand) (Order (Signed brand))) (implementation - (def: equivalence ..equivalence) - (def: (< reference sample) + (def equivalence ..equivalence) + (def (< reference sample) (i.< (representation reference) (representation sample))))) (exception: .public (value_exceeds_the_scope [value Int @@ -53,18 +53,18 @@ (primitive <raw> Any) (type: .public <name> (Signed <raw>))) - (def: .public <size> <bytes>) + (def .public <size> <bytes>) - (def: .public <maximum> + (def .public <maximum> <name> (|> <bytes> (n.* i64.bits_per_byte) -- i64.mask abstraction)) - (def: .public <minimum> + (def .public <minimum> <name> (let [it (representation <maximum>)] (abstraction (-- (i.- it +0))))) - (def: .public <constructor> + (def .public <constructor> (-> Int (Try <name>)) (let [positive (representation <maximum>) negative (i64.not positive)] @@ -77,7 +77,7 @@ (exception.except ..value_exceeds_the_scope [value <size>]))))) (with_template [<abstract_operation> <concrete_operation>] - [(def: .public (<abstract_operation> parameter subject) + [(def .public (<abstract_operation> parameter subject) (-> <name> <name> (Try <name>)) (<constructor> (<concrete_operation> (representation parameter) @@ -93,7 +93,7 @@ ) (with_template [<name> <from> <to>] - [(def: .public <name> + [(def .public <name> (-> <from> <to>) (|>> transmutation))] @@ -102,7 +102,7 @@ ) (with_template [<writer_name> <type> <writer>] - [(def: .public <writer_name> + [(def .public <writer_name> (Writer <type>) (|>> representation <writer>))] diff --git a/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux b/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux index bdda3b8a5..0d2a16d52 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux @@ -24,22 +24,22 @@ (primitive .public (Unsigned brand) Nat - (def: .public value + (def .public value (-> (Unsigned Any) Nat) (|>> representation)) - (def: .public equivalence + (def .public equivalence (All (_ brand) (Equivalence (Unsigned brand))) (implementation - (def: (= reference sample) + (def (= reference sample) (n.= (representation reference) (representation sample))))) - (def: .public order + (def .public order (All (_ brand) (Order (Unsigned brand))) (implementation - (def: equivalence ..equivalence) - (def: (< reference sample) + (def equivalence ..equivalence) + (def (< reference sample) (n.< (representation reference) (representation sample))))) @@ -65,25 +65,25 @@ (primitive .public <raw> Any) (type: .public <name> (Unsigned <raw>))) - (def: .public <size> <bytes>) + (def .public <size> <bytes>) - (def: .public <maximum> + (def .public <maximum> <name> (|> <bytes> (n.* i64.bits_per_byte) i64.mask abstraction)) - (def: .public (<constructor> value) + (def .public (<constructor> value) (-> Nat (Try <name>)) (if (n.> (representation <maximum>) value) (exception.except ..value_exceeds_the_maximum [(symbol <name>) value <maximum>]) {try.#Success (abstraction value)})) - (def: .public (<+> parameter subject) + (def .public (<+> parameter subject) (-> <name> <name> (Try <name>)) (<constructor> (n.+ (representation parameter) (representation subject)))) - (def: .public (<-> parameter subject) + (def .public (<-> parameter subject) (-> <name> <name> (Try <name>)) (let [parameter' (representation parameter) subject' (representation subject)] @@ -91,7 +91,7 @@ (exception.except ..subtraction_cannot_yield_negative_value [(symbol <name>) parameter subject]) {try.#Success (abstraction (n.- parameter' subject'))}))) - (def: .public (<max> left right) + (def .public (<max> left right) (-> <name> <name> <name>) (abstraction (n.max (representation left) (representation right))))] @@ -102,7 +102,7 @@ ) (with_template [<name> <from> <to>] - [(def: .public <name> + [(def .public <name> (-> <from> <to>) (|>> transmutation))] @@ -111,7 +111,7 @@ ) (with_template [<writer_name> <type> <writer>] - [(def: .public <writer_name> + [(def .public <writer_name> (Writer <type>) (|>> representation <writer>))] diff --git a/stdlib/source/library/lux/target/jvm/field.lux b/stdlib/source/library/lux/target/jvm/field.lux index b41782db2..fa84b191b 100644 --- a/stdlib/source/library/lux/target/jvm/field.lux +++ b/stdlib/source/library/lux/target/jvm/field.lux @@ -41,7 +41,7 @@ ["4000" enum] ) -(def: .public equivalence +(def .public equivalence (Equivalence Field) (all product.equivalence modifier.equivalence @@ -49,7 +49,7 @@ //index.equivalence (sequence.equivalence //attribute.equivalence))) -(def: .public (writer field) +(def .public (writer field) (Writer Field) (`` (all binaryF#composite (~~ (with_template [<writer> <slot>] @@ -61,7 +61,7 @@ [(binaryF.sequence_16 //attribute.writer) #attributes])) ))) -(def: .public (field modifier name with_signature? type attributes) +(def .public (field modifier name with_signature? type attributes) (-> (Modifier Field) UTF8 Bit (Type Value) (Sequence Attribute) (Resource Field)) (do [! //constant/pool.monad] diff --git a/stdlib/source/library/lux/target/jvm/index.lux b/stdlib/source/library/lux/target/jvm/index.lux index e3421fd14..f21318b91 100644 --- a/stdlib/source/library/lux/target/jvm/index.lux +++ b/stdlib/source/library/lux/target/jvm/index.lux @@ -12,27 +12,27 @@ [encoding ["[1][0]" unsigned (.only U2)]]]) -(def: .public length +(def .public length //unsigned.bytes/2) (primitive .public (Index kind) U2 - (def: .public index + (def .public index (All (_ kind) (-> U2 (Index kind))) (|>> abstraction)) - (def: .public value + (def .public value (-> (Index Any) U2) (|>> representation)) - (def: .public equivalence + (def .public equivalence (All (_ kind) (Equivalence (Index kind))) (at equivalence.functor each ..value //unsigned.equivalence)) - (def: .public writer + (def .public writer (All (_ kind) (Writer (Index kind))) (|>> representation //unsigned.writer/2)) ) diff --git a/stdlib/source/library/lux/target/jvm/loader.lux b/stdlib/source/library/lux/target/jvm/loader.lux index ee54b8aef..a16372f06 100644 --- a/stdlib/source/library/lux/target/jvm/loader.lux +++ b/stdlib/source/library/lux/target/jvm/loader.lux @@ -65,7 +65,7 @@ "io" "try" (java/lang/Class java/lang/Object))) (with_expansions [<elemT> (these (java/lang/Class java/lang/Object))] - (def: java/lang/ClassLoader::defineClass + (def java/lang/ClassLoader::defineClass java/lang/reflect/Method (let [signature (|> (ffi.array <elemT> 4) (ffi.write! 0 (as <elemT> @@ -80,7 +80,7 @@ (ffi.class_for java/lang/ClassLoader)) (java/lang/reflect/AccessibleObject::setAccessible true))))) -(def: .public (define class_name bytecode loader) +(def .public (define class_name bytecode loader) (-> Text Binary java/lang/ClassLoader (Try java/lang/Object)) (let [signature (array.of_list (list (as java/lang/Object class_name) @@ -97,11 +97,11 @@ ffi.long_to_int))))] (java/lang/reflect/Method::invoke loader signature java/lang/ClassLoader::defineClass))) -(def: .public (new_library _) +(def .public (new_library _) (-> Any Library) (atom.atom (dictionary.empty text.hash))) -(def: .public (memory library) +(def .public (memory library) (-> Library java/lang/ClassLoader) (with_expansions [<cast> (for @.old (<|) @@ -128,7 +128,7 @@ {.#None} (panic! (exception.error ..unknown [class_name]))))))))) -(def: .public (store name bytecode library) +(def .public (store name bytecode library) (-> Text Binary Library (IO (Try Any))) (do [! io.monad] [library' (atom.read! library)] @@ -138,7 +138,7 @@ [_ (atom.update! (dictionary.has name bytecode) library)] (in {try.#Success []}))))) -(def: .public (load name loader) +(def .public (load name loader) (-> Text java/lang/ClassLoader (IO (Try (java/lang/Class java/lang/Object)))) (java/lang/ClassLoader::loadClass (ffi.as_string name) loader)) diff --git a/stdlib/source/library/lux/target/jvm/magic.lux b/stdlib/source/library/lux/target/jvm/magic.lux index 72f5ef52c..a4064361e 100644 --- a/stdlib/source/library/lux/target/jvm/magic.lux +++ b/stdlib/source/library/lux/target/jvm/magic.lux @@ -12,11 +12,11 @@ (type: .public Magic U4) -(def: .public code +(def .public code Magic (|> (hex "CAFEBABE") //unsigned.u4 try.trusted)) -(def: .public writer +(def .public writer //unsigned.writer/4) diff --git a/stdlib/source/library/lux/target/jvm/method.lux b/stdlib/source/library/lux/target/jvm/method.lux index bdbe58f87..082ede18b 100644 --- a/stdlib/source/library/lux/target/jvm/method.lux +++ b/stdlib/source/library/lux/target/jvm/method.lux @@ -52,7 +52,7 @@ ["1000" synthetic] ) -(def: .public (method modifier name with_signature? type attributes code) +(def .public (method modifier name with_signature? type attributes code) (-> (Modifier Method) UTF8 Bit (Type //category.Method) (List (Resource Attribute)) (Maybe (Bytecode Any)) (Resource Method)) (do [! //pool.monad] @@ -89,7 +89,7 @@ #descriptor @descriptor #attributes attributes]))) -(def: .public equivalence +(def .public equivalence (Equivalence Method) (all product.equivalence //modifier.equivalence @@ -98,7 +98,7 @@ (sequence.equivalence //attribute.equivalence) )) -(def: .public (writer field) +(def .public (writer field) (Writer Method) (`` (all \\format#composite (~~ (with_template [<writer> <slot>] diff --git a/stdlib/source/library/lux/target/jvm/modifier.lux b/stdlib/source/library/lux/target/jvm/modifier.lux index 04db97f3f..1034f5cab 100644 --- a/stdlib/source/library/lux/target/jvm/modifier.lux +++ b/stdlib/source/library/lux/target/jvm/modifier.lux @@ -26,66 +26,66 @@ (primitive .public (Modifier of) //unsigned.U2 - (def: .public code + (def .public code (-> (Modifier Any) //unsigned.U2) (|>> representation)) - (def: .public equivalence + (def .public equivalence (All (_ of) (Equivalence (Modifier of))) (implementation - (def: (= reference sample) + (def (= reference sample) (at //unsigned.equivalence = (representation reference) (representation sample))))) - (def: !wrap + (def !wrap (template (_ value) [(|> value //unsigned.u2 try.trusted abstraction)])) - (def: !unwrap + (def !unwrap (template (_ value) [(|> value representation //unsigned.value)])) - (def: .public (has? sub super) + (def .public (has? sub super) (All (_ of) (-> (Modifier of) (Modifier of) Bit)) (let [sub (!unwrap sub)] (|> (!unwrap super) (i64.and sub) (at i64.equivalence = sub)))) - (def: .public monoid + (def .public monoid (All (_ of) (Monoid (Modifier of))) (implementation - (def: identity + (def identity (!wrap (hex "0000"))) - (def: (composite left right) + (def (composite left right) (!wrap (i64.or (!unwrap left) (!unwrap right)))))) - (def: .public empty + (def .public empty Modifier (at ..monoid identity)) - (def: .public writer + (def .public writer (All (_ of) (Writer (Modifier of))) (|>> representation //unsigned.writer/2)) - (def: modifier + (def modifier (-> Nat Modifier) (|>> !wrap)) ) -(def: .public modifiers +(def .public modifiers (syntax (_ [ofT <code>.any options (<>.many <code>.any)]) (with_symbols [g!modifier g!code] (in (list (` (with_template [(~ g!code) (~ g!modifier)] - [(def: (~' .public) (~ g!modifier) + [(def (~' .public) (~ g!modifier) (..Modifier (~ ofT)) ((~! ..modifier) ((~! number.hex) (~ g!code))))] diff --git a/stdlib/source/library/lux/target/jvm/reflection.lux b/stdlib/source/library/lux/target/jvm/reflection.lux index 8369ce2f0..e09c3d85a 100644 --- a/stdlib/source/library/lux/target/jvm/reflection.lux +++ b/stdlib/source/library/lux/target/jvm/reflection.lux @@ -109,7 +109,7 @@ [cannot_convert_to_a_lux_type] ) -(def: .public (load class_loader name) +(def .public (load class_loader name) (-> java/lang/ClassLoader External (Try (java/lang/Class java/lang/Object))) (case (java/lang/Class::forName name false class_loader) {try.#Failure _} @@ -118,14 +118,14 @@ success success)) -(def: .public (sub? class_loader super sub) +(def .public (sub? class_loader super sub) (-> java/lang/ClassLoader External External (Try Bit)) (do try.monad [super (..load class_loader super) sub (..load class_loader sub)] (in (java/lang/Class::isAssignableFrom sub super)))) -(def: (class' parameter reflection) +(def (class' parameter reflection) (-> (-> java/lang/reflect/Type (Try (/.Type Parameter))) java/lang/reflect/Type (Try (/.Type Class))) @@ -171,7 +171,7 @@ ... else (exception.except ..cannot_convert_to_a_lux_type [reflection]))) -(def: .public (parameter type reflection) +(def .public (parameter type reflection) (-> (-> java/lang/reflect/Type (Try (/.Type Value))) (-> java/lang/reflect/Type (Try (/.Type Parameter)))) (<| (case (ffi.as java/lang/reflect/TypeVariable reflection) @@ -218,7 +218,7 @@ _) (..class' (parameter type) reflection))) -(def: .public (type reflection) +(def .public (type reflection) (-> java/lang/reflect/Type (Try (/.Type Value))) (<| (case (ffi.as java/lang/Class reflection) {.#Some reflection} @@ -245,12 +245,12 @@ ... else (..parameter type reflection))) -(def: .public class +(def .public class (-> java/lang/reflect/Type (Try (/.Type Class))) (..class' (..parameter ..type))) -(def: .public (return reflection) +(def .public (return reflection) (-> java/lang/reflect/Type (Try (/.Type Return))) (with_expansions [<else> (these (..type reflection))] (case (ffi.as java/lang/Class reflection) @@ -286,7 +286,7 @@ (exception.report "Type" (%.type type))) -(def: .public (correspond class type) +(def .public (correspond class type) (-> (java/lang/Class java/lang/Object) Type (Try Mapping)) (case type (pattern {.#Primitive (static array.type_name) (list :member:)}) @@ -346,7 +346,7 @@ [not_a_virtual_field] ) -(def: .public (field field target) +(def .public (field field target) (-> Text (java/lang/Class java/lang/Object) (Try java/lang/reflect/Field)) (case (java/lang/Class::getDeclaredField field target) {try.#Success field} @@ -358,7 +358,7 @@ {try.#Failure _} (exception.except ..unknown_field [field target]))) -(def: .public deprecated? +(def .public deprecated? (-> (array.Array java/lang/annotation/Annotation) Bit) (|>> (array.list {.#None}) (list.all (|>> (ffi.as java/lang/Deprecated))) @@ -366,7 +366,7 @@ not)) (with_template [<name> <exception> <then?> <else?>] - [(def: .public (<name> field class) + [(def .public (<name> field class) (-> Text (java/lang/Class java/lang/Object) (Try [Bit Bit (/.Type Value)])) (do [! try.monad] [fieldJ (..field field class) diff --git a/stdlib/source/library/lux/target/jvm/type.lux b/stdlib/source/library/lux/target/jvm/type.lux index 18c21263c..3734c5e99 100644 --- a/stdlib/source/library/lux/target/jvm/type.lux +++ b/stdlib/source/library/lux/target/jvm/type.lux @@ -43,7 +43,7 @@ #super_interfaces (List (Type Class))])) (with_template [<name> <style>] - [(def: .public (<name> type) + [(def .public (<name> type) (All (_ category) (-> (Type category) (<style> category))) (let [[signature descriptor reflection] (representation type)] <name>))] @@ -52,7 +52,7 @@ [descriptor Descriptor] ) - (def: .public (reflection type) + (def .public (reflection type) (All (_ category) (-> (Type (<| Return' Value' category)) (Reflection (<| Return' Value' category)))) @@ -60,7 +60,7 @@ reflection)) (with_template [<category> <name> <signature> <descriptor> <reflection>] - [(def: .public <name> + [(def .public <name> (Type <category>) (abstraction [<signature> <descriptor> <reflection>]))] @@ -75,28 +75,28 @@ [Primitive char /signature.char /descriptor.char /reflection.char] ) - (def: .public (array type) + (def .public (array type) (-> (Type Value) (Type Array)) (abstraction [(/signature.array (..signature type)) (/descriptor.array (..descriptor type)) (/reflection.array (..reflection type))])) - (def: .public (class name parameters) + (def .public (class name parameters) (-> External (List (Type Parameter)) (Type Class)) (abstraction [(/signature.class name (list#each ..signature parameters)) (/descriptor.class name) (/reflection.class name)])) - (def: .public (declaration name variables) + (def .public (declaration name variables) (-> External (List (Type Var)) (Type Declaration)) (abstraction [(/signature.declaration name (list#each ..signature variables)) (/descriptor.declaration name) (/reflection.declaration name)])) - (def: .public (as_class type) + (def .public (as_class type) (-> (Type Declaration) (Type Class)) (abstraction (let [[signature descriptor reflection] (representation type)] @@ -104,21 +104,21 @@ (/descriptor.as_class descriptor) (/reflection.as_class reflection)]))) - (def: .public wildcard + (def .public wildcard (Type Parameter) (abstraction [/signature.wildcard /descriptor.wildcard /reflection.wildcard])) - (def: .public (var name) + (def .public (var name) (-> Text (Type Var)) (abstraction [(/signature.var name) /descriptor.var /reflection.var])) - (def: .public (lower bound) + (def .public (lower bound) (-> (Type Parameter) (Type Parameter)) (abstraction (let [[signature descriptor reflection] (representation bound)] @@ -126,7 +126,7 @@ (/descriptor.lower descriptor) (/reflection.lower reflection)]))) - (def: .public (upper bound) + (def .public (upper bound) (-> (Type Parameter) (Type Parameter)) (abstraction (let [[signature descriptor reflection] (representation bound)] @@ -134,7 +134,7 @@ (/descriptor.upper descriptor) (/reflection.upper reflection)]))) - (def: .public (method [type_variables inputs output exceptions]) + (def .public (method [type_variables inputs output exceptions]) (-> [(List (Type Var)) (List (Type Value)) (Type Return) @@ -149,21 +149,21 @@ (..descriptor output)]) (as_expected ..void)])) - (def: .public equivalence + (def .public equivalence (All (_ category) (Equivalence (Type category))) (implementation - (def: (= parameter subject) + (def (= parameter subject) (at /signature.equivalence = (..signature parameter) (..signature subject))))) - (def: .public hash + (def .public hash (All (_ category) (Hash (Type category))) (implementation - (def: equivalence ..equivalence) - (def: hash (|>> ..signature (at /signature.hash hash))))) + (def equivalence ..equivalence) + (def hash (|>> ..signature (at /signature.hash hash))))) - (def: .public (primitive? type) + (def .public (primitive? type) (-> (Type Value) (Either (Type Object) (Type Primitive))) (if (`` (or (~~ (with_template [<type>] @@ -180,7 +180,7 @@ (|> type (as (Type Primitive)) {.#Right}) (|> type (as (Type Object)) {.#Left}))) - (def: .public (void? type) + (def .public (void? type) (-> (Type Return) (Either (Type Value) (Type Void))) (if (`` (or (~~ (with_template [<type>] @@ -191,7 +191,7 @@ (|> type (as (Type Value)) {.#Left}))) ) -(def: .public (class? type) +(def .public (class? type) (-> (Type Value) (Maybe External)) (let [repr (|> type ..descriptor /descriptor.descriptor)] (if (and (text.starts_with? /descriptor.class_prefix repr) @@ -206,6 +206,6 @@ (at maybe.monad each (|>> //name.internal //name.external)))) {.#None}))) -(def: .public format +(def .public format (All (_ a) (Format (Type a))) (|>> ..signature /signature.signature)) diff --git a/stdlib/source/library/lux/target/jvm/type/alias.lux b/stdlib/source/library/lux/target/jvm/type/alias.lux index 89e4148c6..0ec86571b 100644 --- a/stdlib/source/library/lux/target/jvm/type/alias.lux +++ b/stdlib/source/library/lux/target/jvm/type/alias.lux @@ -27,11 +27,11 @@ (type: .public Aliasing (Dictionary Text Text)) -(def: .public fresh +(def .public fresh Aliasing (dictionary.empty text.hash)) -(def: (var aliasing) +(def (var aliasing) (-> Aliasing (Parser (Type Var))) (do <>.monad [var //parser.var'] @@ -40,7 +40,7 @@ (maybe.else var) //.var)))) -(def: (class parameter) +(def (class parameter) (-> (Parser (Type Parameter)) (Parser (Type Class))) (|> (do <>.monad [name //parser.class_name @@ -53,7 +53,7 @@ (<>.before (<text>.this //descriptor.class_suffix)))) (with_template [<name> <prefix> <bound> <constructor>] - [(def: <name> + [(def <name> (-> (Parser (Type Class)) (Parser (Type Parameter))) (|>> (<>.after (<text>.this <prefix>)) (at <>.monad each <bound>)))] @@ -62,7 +62,7 @@ [upper //signature.upper_prefix //.upper ..Upper] ) -(def: (parameter aliasing) +(def (parameter aliasing) (-> Aliasing (Parser (Type Parameter))) (<>.rec (function (_ parameter) @@ -75,7 +75,7 @@ class ))))) -(def: (value aliasing) +(def (value aliasing) (-> Aliasing (Parser (Type Value))) (<>.rec (function (_ value) @@ -85,37 +85,37 @@ (//parser.array' value) )))) -(def: (inputs aliasing) +(def (inputs aliasing) (-> Aliasing (Parser (List (Type Value)))) (|> (<>.some (..value aliasing)) (<>.after (<text>.this //signature.arguments_start)) (<>.before (<text>.this //signature.arguments_end)))) -(def: (return aliasing) +(def (return aliasing) (-> Aliasing (Parser (Type Return))) (all <>.either //parser.void (..value aliasing) )) -(def: (exception aliasing) +(def (exception aliasing) (-> Aliasing (Parser (Type Class))) (|> (..class (..parameter aliasing)) (<>.after (<text>.this //signature.exception_prefix)))) -(def: (bound aliasing) +(def (bound aliasing) (-> Aliasing (Parser (Type Class))) (do <>.monad [_ (<text>.this ":")] (..class (..parameter aliasing)))) -(def: (bound_type_var aliasing) +(def (bound_type_var aliasing) (-> Aliasing (Parser (Type Var))) (|> //parser.var_name (at <>.monad each //.var) (<>.before (<>.many (..bound aliasing))))) -(def: .public (method aliasing) +(def .public (method aliasing) (-> Aliasing (-> (Type Method) (Type Method))) (|>> //.signature //signature.signature diff --git a/stdlib/source/library/lux/target/jvm/type/box.lux b/stdlib/source/library/lux/target/jvm/type/box.lux index 08a6e1213..051f45391 100644 --- a/stdlib/source/library/lux/target/jvm/type/box.lux +++ b/stdlib/source/library/lux/target/jvm/type/box.lux @@ -6,7 +6,7 @@ [name (.only External)]]]) (with_template [<name> <box>] - [(def: .public <name> External <box>)] + [(def .public <name> External <box>)] [boolean "java.lang.Boolean"] [byte "java.lang.Byte"] diff --git a/stdlib/source/library/lux/target/jvm/type/descriptor.lux b/stdlib/source/library/lux/target/jvm/type/descriptor.lux index 99b3987d5..3de5b4483 100644 --- a/stdlib/source/library/lux/target/jvm/type/descriptor.lux +++ b/stdlib/source/library/lux/target/jvm/type/descriptor.lux @@ -24,12 +24,12 @@ (primitive .public (Descriptor category) Text - (def: .public descriptor + (def .public descriptor (-> (Descriptor Any) Text) (|>> representation)) (with_template [<sigil> <category> <name>] - [(def: .public <name> + [(def .public <name> (Descriptor <category>) (abstraction <sigil>))] @@ -44,26 +44,26 @@ ["C" Primitive char] ) - (def: .public class_prefix "L") - (def: .public class_suffix ";") + (def .public class_prefix "L") + (def .public class_suffix ";") - (def: .public class + (def .public class (-> External (Descriptor Class)) (|>> ///name.internal ///name.read (text.enclosed [..class_prefix ..class_suffix]) abstraction)) - (def: .public (declaration name) + (def .public (declaration name) (-> External (Descriptor Declaration)) (transmutation (..class name))) - (def: .public as_class + (def .public as_class (-> (Descriptor Declaration) (Descriptor Class)) (|>> transmutation)) (with_template [<name> <category>] - [(def: .public <name> + [(def .public <name> (Descriptor <category>) (transmutation (..class "java.lang.Object")))] @@ -72,24 +72,24 @@ [wildcard Parameter] ) - (def: .public (lower descriptor) + (def .public (lower descriptor) (-> (Descriptor Parameter) (Descriptor Parameter)) ..wildcard) - (def: .public upper + (def .public upper (-> (Descriptor Parameter) (Descriptor Parameter)) (|>> transmutation)) - (def: .public array_prefix "[") + (def .public array_prefix "[") - (def: .public array + (def .public array (-> (Descriptor Value) (Descriptor Array)) (|>> representation (format ..array_prefix) abstraction)) - (def: .public (method [inputs output]) + (def .public (method [inputs output]) (-> [(List (Descriptor Value)) (Descriptor Return)] (Descriptor Method)) @@ -100,13 +100,13 @@ (text.enclosed ["(" ")"])) (representation output)))) - (def: .public equivalence + (def .public equivalence (All (_ category) (Equivalence (Descriptor category))) (implementation - (def: (= parameter subject) + (def (= parameter subject) (text#= (representation parameter) (representation subject))))) - (def: .public class_name + (def .public class_name (-> (Descriptor Object) Internal) (let [prefix_size (text.size ..class_prefix) suffix_size (text.size ..class_suffix)] diff --git a/stdlib/source/library/lux/target/jvm/type/lux.lux b/stdlib/source/library/lux/target/jvm/type/lux.lux index ea7951cee..3490eaed9 100644 --- a/stdlib/source/library/lux/target/jvm/type/lux.lux +++ b/stdlib/source/library/lux/target/jvm/type/lux.lux @@ -38,7 +38,7 @@ (type: .public Mapping (Dictionary Text Type)) -(def: .public fresh +(def .public fresh Mapping (dictionary.empty text.hash)) @@ -46,13 +46,13 @@ (exception.report "Var" (%.text var))) -(def: void +(def void (Parser (Check Type)) (<>.after //parser.void (<>#in (check#in .Any)))) (with_template [<name> <parser> <reflection>] - [(def: <name> + [(def <name> (Parser (Check Type)) (<>.after <parser> (<>#in (check#in {.#Primitive (//reflection.reflection <reflection>) {.#End}}))))] @@ -68,7 +68,7 @@ ) (with_template [<name> <parser> <box>] - [(def: <name> + [(def <name> (Parser (Check Type)) (<>.after <parser> (<>#in (check#in {.#Primitive <box> {.#End}}))))] @@ -83,7 +83,7 @@ [boxed_char //parser.char //box.char] ) -(def: primitive +(def primitive (Parser (Check Type)) (all <>.either ..boolean @@ -96,7 +96,7 @@ ..char )) -(def: boxed_primitive +(def boxed_primitive (Parser (Check Type)) (all <>.either ..boxed_boolean @@ -109,13 +109,13 @@ ..boxed_char )) -(def: wildcard +(def wildcard (Parser (Check Type)) (<>.after //parser.wildcard (<>#in (check#each product.right check.existential)))) -(def: (var mapping) +(def (var mapping) (-> Mapping (Parser (Check Type))) (do <>.monad [var //parser.var'] @@ -126,7 +126,7 @@ {.#Some type} (check#in type))))) -(def: (class' parameter) +(def (class' parameter) (-> (Parser (Check Type)) (Parser (Check Type))) (|> (do <>.monad [name //parser.class_name @@ -141,7 +141,7 @@ (<>.before (<text>.this //descriptor.class_suffix)))) (with_template [<name> <prefix> <constructor>] - [(def: <name> + [(def <name> (-> (Parser (Check Type)) (Parser (Check Type))) (|> (<>.after (<text>.this <prefix>)) ... TODO: Re-enable Lower and Upper, instead of using the simplified limit. @@ -152,7 +152,7 @@ [upper //signature.upper_prefix ..Upper] ) -(def: (parameter mapping) +(def (parameter mapping) (-> Mapping (Parser (Check Type))) (<>.rec (function (_ parameter) @@ -165,11 +165,11 @@ class ))))) -(def: .public class +(def .public class (-> Mapping (Parser (Check Type))) (|>> ..parameter ..class')) -(def: array +(def array (-> (Parser (Check Type)) (Parser (Check Type))) (|>> (<>#each (check#each (function (_ elementT) (case elementT @@ -192,7 +192,7 @@ (|> elementT array.Array .type))))) (<>.after (<text>.this //descriptor.array_prefix)))) -(def: .public (type mapping) +(def .public (type mapping) (-> Mapping (Parser (Check Type))) (<>.rec (function (_ type) @@ -202,7 +202,7 @@ (..array type) )))) -(def: .public (boxed_type mapping) +(def .public (boxed_type mapping) (-> Mapping (Parser (Check Type))) (<>.rec (function (_ type) @@ -212,21 +212,21 @@ (..array type) )))) -(def: .public (return mapping) +(def .public (return mapping) (-> Mapping (Parser (Check Type))) (all <>.either ..void (..type mapping) )) -(def: .public (boxed_return mapping) +(def .public (boxed_return mapping) (-> Mapping (Parser (Check Type))) (all <>.either ..void (..boxed_type mapping) )) -(def: .public (check operation input) +(def .public (check operation input) (All (_ a) (-> (Parser (Check a)) Text (Check a))) (case (<text>.result operation input) {try.#Success check} diff --git a/stdlib/source/library/lux/target/jvm/type/parser.lux b/stdlib/source/library/lux/target/jvm/type/parser.lux index 999cb620f..9eb9db150 100644 --- a/stdlib/source/library/lux/target/jvm/type/parser.lux +++ b/stdlib/source/library/lux/target/jvm/type/parser.lux @@ -23,7 +23,7 @@ ["[1][0]" name (.only External)]]]]) (with_template [<category> <name> <signature> <type>] - [(def: .public <name> + [(def .public <name> (Parser (Type <category>)) (<>.after (<text>.this (//signature.signature <signature>)) (<>#in <type>)))] @@ -40,7 +40,7 @@ [Parameter wildcard //signature.wildcard //.wildcard] ) -(def: .public primitive +(def .public primitive (Parser (Type Primitive)) (all <>.either ..boolean @@ -53,20 +53,20 @@ ..char )) -(def: var/head +(def var/head (format "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "_")) -(def: var/tail +(def var/tail (format var/head "0123456789$")) -(def: class/set +(def class/set (format var/tail //name.internal_separator)) (with_template [<type> <name> <head> <tail> <adapter>] - [(def: .public <name> + [(def .public <name> (Parser <type>) (at <>.functor each <adapter> (<text>.slice (<text>.and! (<text>.one_of! <head>) @@ -76,24 +76,24 @@ [Text var_name var/head var/tail function.identity] ) -(def: .public var' +(def .public var' (Parser Text) (|> ..var_name (<>.after (<text>.this //signature.var_prefix)) (<>.before (<text>.this //descriptor.class_suffix)))) -(def: .public var +(def .public var (Parser (Type Var)) (<>#each //.var ..var')) -(def: .public var? +(def .public var? (-> (Type Value) (Maybe Text)) (|>> //.signature //signature.signature (<text>.result ..var') try.maybe)) -(def: .public name +(def .public name (-> (Type Var) Text) (|>> //.signature //signature.signature @@ -101,7 +101,7 @@ try.trusted)) (with_template [<name> <prefix> <constructor>] - [(def: <name> + [(def <name> (-> (Parser (Type Parameter)) (Parser (Type Parameter))) (|>> (<>.after (<text>.this <prefix>)) (<>#each <constructor>)))] @@ -110,7 +110,7 @@ [upper //signature.upper_prefix //.upper] ) -(def: (class'' parameter) +(def (class'' parameter) (-> (Parser (Type Parameter)) (Parser [External (List (Type Parameter))])) (|> (do <>.monad [name ..class_name @@ -122,17 +122,17 @@ (<>.after (<text>.this //descriptor.class_prefix)) (<>.before (<text>.this //descriptor.class_suffix)))) -(def: class' +(def class' (-> (Parser (Type Parameter)) (Parser (Type Class))) (|>> ..class'' (at <>.monad each (product.uncurried //.class)))) -(def: .public array' +(def .public array' (-> (Parser (Type Value)) (Parser (Type Array))) (|>> (<>.after (<text>.this //descriptor.array_prefix)) (<>#each //.array))) -(def: (parameter' value) +(def (parameter' value) (-> (Parser (Type Value)) (Parser (Type Parameter))) (<>.rec (function (_ parameter) @@ -146,7 +146,7 @@ class ))))) -(def: .public value +(def .public value (Parser (Type Value)) (<>.rec (function (_ value) @@ -155,16 +155,16 @@ (..parameter' value) )))) -(def: .public parameter +(def .public parameter (Parser (Type Parameter)) (..parameter' ..value)) -(def: .public class +(def .public class (Parser (Type Class)) (..class' ..parameter)) (with_template [<name> <prefix> <constructor>] - [(def: .public <name> + [(def .public <name> (-> (Type Value) (Maybe (Type Parameter))) (|>> //.signature //signature.signature @@ -175,39 +175,39 @@ [upper? //signature.upper_prefix //.upper] ) -(def: .public read_class +(def .public read_class (-> (Type Class) [External (List (Type Parameter))]) (|>> //.signature //signature.signature (<text>.result (..class'' ..parameter)) try.trusted)) -(def: .public array +(def .public array (Parser (Type Array)) (..array' ..value)) -(def: .public object +(def .public object (Parser (Type Object)) (all <>.either ..class ..array)) -(def: inputs +(def inputs (|> (<>.some ..value) (<>.after (<text>.this //signature.arguments_start)) (<>.before (<text>.this //signature.arguments_end)))) -(def: .public return +(def .public return (Parser (Type Return)) (<>.either ..void ..value)) -(def: exception +(def exception (Parser (Type Class)) (|> ..class (<>.after (<text>.this //signature.exception_prefix)))) -(def: .public var_declaration +(def .public var_declaration (Parser [(Type Var) (Type Class)]) (do <>.monad [name ..var_name @@ -215,7 +215,7 @@ type ..class] (in [(//.var name) type]))) -(def: .public method +(def .public method (-> (Type Method) [(List (Type Var)) (List (Type Value)) @@ -239,7 +239,7 @@ try.trusted))) (with_template [<name> <category> <parser>] - [(def: .public <name> + [(def .public <name> (-> (Type Value) (Maybe <category>)) (|>> //.signature //signature.signature @@ -259,7 +259,7 @@ [object? (Type Object) ..object] ) -(def: .public declaration' +(def .public declaration' (Parser [External (List (Type Var))]) (|> (<>.and ..class_name (|> (<>.some ..var) @@ -269,7 +269,7 @@ (<>.after (<text>.this //descriptor.class_prefix)) (<>.before (<text>.this //descriptor.class_suffix)))) -(def: .public declaration +(def .public declaration (-> (Type Declaration) [External (List (Type Var))]) (|>> //.signature //signature.signature diff --git a/stdlib/source/library/lux/target/jvm/type/reflection.lux b/stdlib/source/library/lux/target/jvm/type/reflection.lux index 7794fedc3..cfd7be86b 100644 --- a/stdlib/source/library/lux/target/jvm/type/reflection.lux +++ b/stdlib/source/library/lux/target/jvm/type/reflection.lux @@ -18,18 +18,18 @@ (primitive .public (Reflection category) Text - (def: .public reflection + (def .public reflection (-> (Reflection Any) Text) (|>> representation)) - (def: .public equivalence + (def .public equivalence (All (_ category) (Equivalence (Reflection category))) (implementation - (def: (= parameter subject) + (def (= parameter subject) (text#= (representation parameter) (representation subject))))) (with_template [<category> <name> <reflection>] - [(def: .public <name> + [(def .public <name> (Reflection <category>) (abstraction <reflection>))] @@ -44,19 +44,19 @@ [Primitive char "char"] ) - (def: .public class + (def .public class (-> External (Reflection Class)) (|>> abstraction)) - (def: .public (declaration name) + (def .public (declaration name) (-> External (Reflection Declaration)) (transmutation (..class name))) - (def: .public as_class + (def .public as_class (-> (Reflection Declaration) (Reflection Class)) (|>> transmutation)) - (def: .public (array element) + (def .public (array element) (-> (Reflection Value) (Reflection Array)) (let [element' (representation element) elementR (`` (cond (text.starts_with? //descriptor.array_prefix element') @@ -85,7 +85,7 @@ abstraction))) (with_template [<name> <category>] - [(def: .public <name> + [(def .public <name> (Reflection <category>) (transmutation (..class "java.lang.Object")))] @@ -94,11 +94,11 @@ [wildcard Parameter] ) - (def: .public (lower reflection) + (def .public (lower reflection) (-> (Reflection Parameter) (Reflection Parameter)) ..wildcard) - (def: .public upper + (def .public upper (-> (Reflection Parameter) (Reflection Parameter)) (|>> transmutation)) ) diff --git a/stdlib/source/library/lux/target/jvm/type/signature.lux b/stdlib/source/library/lux/target/jvm/type/signature.lux index 610706176..288b0a75e 100644 --- a/stdlib/source/library/lux/target/jvm/type/signature.lux +++ b/stdlib/source/library/lux/target/jvm/type/signature.lux @@ -23,12 +23,12 @@ (primitive .public (Signature category) Text - (def: .public signature + (def .public signature (-> (Signature Any) Text) (|>> representation)) (with_template [<category> <name> <descriptor>] - [(def: .public <name> + [(def .public <name> (Signature <category>) (abstraction (//descriptor.descriptor <descriptor>)))] @@ -43,18 +43,18 @@ [Primitive char //descriptor.char] ) - (def: .public array + (def .public array (-> (Signature Value) (Signature Array)) (|>> representation (format //descriptor.array_prefix) abstraction)) - (def: .public wildcard + (def .public wildcard (Signature Parameter) (abstraction "*")) (with_template [<char> <name>] - [(def: .public <name> <char>)] + [(def .public <name> <char>)] ["T" var_prefix] ["-" lower_prefix] @@ -70,7 +70,7 @@ ) (with_template [<name> <prefix>] - [(def: .public <name> + [(def .public <name> (-> (Signature Parameter) (Signature Parameter)) (|>> representation (format <prefix>) abstraction))] @@ -78,18 +78,18 @@ [upper ..upper_prefix] ) - (def: .public var + (def .public var (-> Text (Signature Var)) (|>> (text.enclosed [..var_prefix //descriptor.class_suffix]) abstraction)) - (def: .public var_name + (def .public var_name (-> (Signature Var) Text) (|>> representation (text.replaced ..var_prefix "") (text.replaced //descriptor.class_suffix ""))) - (def: .public (class name parameters) + (def .public (class name parameters) (-> External (List (Signature Parameter)) (Signature Class)) (abstraction (format //descriptor.class_prefix @@ -106,28 +106,28 @@ ..parameters_end)) //descriptor.class_suffix))) - (def: .public (declaration name variables) + (def .public (declaration name variables) (-> External (List (Signature Var)) (Signature Declaration)) (transmutation (..class name variables))) - (def: class_bound + (def class_bound (|> (..class "java.lang.Object" (list)) ..signature (format ..format_type_parameter_infix))) - (def: var_declaration/1 + (def var_declaration/1 (-> (Signature Var) Text) (|>> ..var_name (text.suffix ..class_bound))) - (def: var_declaration/+ + (def var_declaration/+ (-> (List (Signature Var)) Text) (|>> (list#each ..var_declaration/1) text.together (text.enclosed [..parameters_start ..parameters_end]))) - (def: var_declaration/* + (def var_declaration/* (-> (List (Signature Var)) Text) (|>> (pipe.case {.#End} @@ -136,7 +136,7 @@ it (..var_declaration/+ it)))) - (def: .public (inheritance variables super interfaces) + (def .public (inheritance variables super interfaces) (-> (List (Signature Var)) (Signature Class) (List (Signature Class)) (Signature Inheritance)) (abstraction (format (var_declaration/* variables) @@ -145,11 +145,11 @@ (list#each ..signature) text.together)))) - (def: .public as_class + (def .public as_class (-> (Signature Declaration) (Signature Class)) (|>> transmutation)) - (def: .public (method [type_variables inputs output exceptions]) + (def .public (method [type_variables inputs output exceptions]) (-> [(List (Signature Var)) (List (Signature Value)) (Signature Return) @@ -167,16 +167,16 @@ (list#each (|>> representation (format ..exception_prefix))) text.together)))) - (def: .public equivalence + (def .public equivalence (All (_ category) (Equivalence (Signature category))) (implementation - (def: (= parameter subject) + (def (= parameter subject) (text#= (representation parameter) (representation subject))))) - (def: .public hash + (def .public hash (All (_ category) (Hash (Signature category))) (implementation - (def: equivalence ..equivalence) - (def: hash (|>> representation text#hash)))) + (def equivalence ..equivalence) + (def hash (|>> representation text#hash)))) ) diff --git a/stdlib/source/library/lux/target/jvm/version.lux b/stdlib/source/library/lux/target/jvm/version.lux index 60778c7f7..9b23f8fff 100644 --- a/stdlib/source/library/lux/target/jvm/version.lux +++ b/stdlib/source/library/lux/target/jvm/version.lux @@ -11,14 +11,14 @@ (type: .public Minor Version) (type: .public Major Version) -(def: .public default_minor +(def .public default_minor Minor (|> 0 //unsigned.u2 try.trusted)) (with_template [<number> <name>] - [(def: .public <name> + [(def .public <name> Major (|> <number> //unsigned.u2 @@ -38,5 +38,5 @@ [56 v12] ) -(def: .public writer +(def .public writer //unsigned.writer/2) diff --git a/stdlib/source/library/lux/target/lua.lux b/stdlib/source/library/lux/target/lua.lux index 67986980d..7ac944f82 100644 --- a/stdlib/source/library/lux/target/lua.lux +++ b/stdlib/source/library/lux/target/lua.lux @@ -28,38 +28,38 @@ [primitive (.except)]]]]) ... Added the carriage return for better Windows compatibility. -(def: \n+ +(def \n+ Text (format text.carriage_return text.new_line)) -(def: nested +(def nested (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] (|>> (format \n+) (text.replaced text.new_line nested_new_line)))) -(def: input_separator ", ") +(def input_separator ", ") (primitive .public (Code brand) Text - (def: .public equivalence + (def .public equivalence (All (_ brand) (Equivalence (Code brand))) (implementation - (def: (= reference subject) + (def (= reference subject) (at text.equivalence = (representation reference) (representation subject))))) - (def: .public hash + (def .public hash (All (_ brand) (Hash (Code brand))) (implementation - (def: equivalence ..equivalence) - (def: hash (|>> representation (at text.hash hash))))) + (def equivalence ..equivalence) + (def hash (|>> representation (at text.hash hash))))) - (def: .public manual + (def .public manual (-> Text Code) (|>> abstraction)) - (def: .public code + (def .public code (-> (Code Any) Text) (|>> representation)) @@ -85,18 +85,18 @@ [Label [Code]] ) - (def: .public nil + (def .public nil Literal (abstraction "nil")) - (def: .public boolean + (def .public boolean (-> Bit Literal) (|>> (pipe.case #0 "false" #1 "true") abstraction)) - (def: .public int + (def .public int (-> Int Literal) ... Integers must be turned into hexadecimal to avoid quirks in how Lua parses integers. ... In particular, the number -9223372036854775808 will be incorrectly parsed as a float by Lua. @@ -106,7 +106,7 @@ (format "0x") abstraction))) - (def: .public float + (def .public float (-> Frac Literal) (|>> (pipe.cond [(f.= f.positive_infinity)] [(pipe.new "(1.0/0.0)" [])] @@ -121,7 +121,7 @@ [%.frac (text.replaced "+" "")]) abstraction)) - (def: safe + (def safe (-> Text Text) (`` (|>> (~~ (with_template [<find> <replace>] [(text.replaced <find> <replace>)] @@ -138,24 +138,24 @@ )) ))) - (def: .public string + (def .public string (-> Text Literal) (|>> ..safe (text.enclosed' text.double_quote) abstraction)) - (def: .public multi + (def .public multi (-> (List Expression) Expression) (|>> (list#each ..code) (text.interposed ..input_separator) abstraction)) - (def: .public array + (def .public array (-> (List Expression) Literal) (|>> (list#each ..code) (text.interposed ..input_separator) (text.enclosed ["{" "}"]) abstraction)) - (def: .public table + (def .public table (-> (List [Text Expression]) Literal) (|>> (list#each (.function (_ [key value]) (format key " = " (representation value)))) @@ -163,21 +163,21 @@ (text.enclosed ["({" "})"]) abstraction)) - (def: .public (item idx array) + (def .public (item idx array) (-> Expression Expression Access) (abstraction (format "(" (representation array) ")[" (representation idx) "]"))) - (def: .public (the field table) + (def .public (the field table) (-> Text Expression Access) (abstraction (format (representation table) "." field))) - (def: .public length + (def .public length (-> Expression Computation) (|>> representation (text.enclosed ["#(" ")"]) abstraction)) - (def: .public (apply args func) + (def .public (apply args func) (-> (List Expression) Expression Computation) (|> args (list#each ..code) @@ -186,7 +186,7 @@ (format (representation func)) abstraction)) - (def: .public (do method args table) + (def .public (do method args table) (-> Text (List Expression) Expression Computation) (|> args (list#each ..code) @@ -196,7 +196,7 @@ abstraction)) (with_template [<op> <name>] - [(def: .public (<name> parameter subject) + [(def .public (<name> parameter subject) (-> Expression Expression Expression) (abstraction (format "(" (representation subject) @@ -229,7 +229,7 @@ ) (with_template [<name> <unary>] - [(def: .public (<name> subject) + [(def .public (<name> subject) (-> Expression Expression) (abstraction (format "(" <unary> " " (representation subject) ")")))] @@ -238,7 +238,7 @@ ) (with_template [<name> <type>] - [(def: .public <name> + [(def .public <name> (-> Text <type>) (|>> abstraction))] @@ -246,66 +246,66 @@ [label Label] ) - (def: .public statement + (def .public statement (-> Expression Statement) (|>> representation abstraction)) - (def: .public (then pre! post!) + (def .public (then pre! post!) (-> Statement Statement Statement) (abstraction (format (representation pre!) \n+ (representation post!)))) - (def: locations + (def locations (-> (List Location) Text) (|>> (list#each ..code) (text.interposed ..input_separator))) - (def: .public (local vars) + (def .public (local vars) (-> (List Var) Statement) (abstraction (format "local " (..locations vars)))) - (def: .public (set vars value) + (def .public (set vars value) (-> (List Location) Expression Statement) (abstraction (format (..locations vars) " = " (representation value)))) - (def: .public (let vars value) + (def .public (let vars value) (-> (List Var) Expression Statement) (abstraction (format "local " (..locations vars) " = " (representation value)))) - (def: .public (local/1 var value) + (def .public (local/1 var value) (-> Var Expression Statement) (abstraction (format "local " (representation var) " = " (representation value)))) - (def: .public (if test then! else!) + (def .public (if test then! else!) (-> Expression Statement Statement Statement) (abstraction (format "if " (representation test) \n+ "then" (..nested (representation then!)) \n+ "else" (..nested (representation else!)) \n+ "end"))) - (def: .public (when test then!) + (def .public (when test then!) (-> Expression Statement Statement) (abstraction (format "if " (representation test) \n+ "then" (..nested (representation then!)) \n+ "end"))) - (def: .public (while test body!) + (def .public (while test body!) (-> Expression Statement Statement) (abstraction (format "while " (representation test) " do" (..nested (representation body!)) \n+ "end"))) - (def: .public (repeat until body!) + (def .public (repeat until body!) (-> Expression Statement Statement) (abstraction (format "repeat" (..nested (representation body!)) \n+ "until " (representation until)))) - (def: .public (for_in vars source body!) + (def .public (for_in vars source body!) (-> (List Var) Expression Statement Statement) (abstraction (format "for " (|> vars @@ -315,7 +315,7 @@ (..nested (representation body!)) \n+ "end"))) - (def: .public (for_step var from to step body!) + (def .public (for_step var from to step body!) (-> Var Expression Expression Expression Statement Statement) (abstraction @@ -326,11 +326,11 @@ (..nested (representation body!)) \n+ "end"))) - (def: .public (return value) + (def .public (return value) (-> Expression Statement) (abstraction (format "return " (representation value)))) - (def: .public (closure args body!) + (def .public (closure args body!) (-> (List Var) Statement Expression) (|> (format "function " (|> args ..locations @@ -341,7 +341,7 @@ abstraction)) (with_template [<name> <code> <binding>] - [(def: .public (<name> name args body!) + [(def .public (<name> name args body!) (-> <binding> (List Var) Statement Statement) (abstraction (format <code> " " (representation name) @@ -355,25 +355,25 @@ [local_function "local function" Var] ) - (def: .public break + (def .public break Statement (abstraction "break")) - (def: .public (set_label label) + (def .public (set_label label) (-> Label Statement) (abstraction (format "::" (representation label) "::"))) - (def: .public (go_to label) + (def .public (go_to label) (-> Label Statement) (abstraction (format "goto " (representation label)))) ... https://www.lua.org/pil/1.3.html - (def: .public (comment commentary on) + (def .public (comment commentary on) (All (_ kind) (-> Text (Code kind) (Code kind))) (abstraction (format "-- " commentary \n+ (representation on)))) ) -(def: arity_inputs +(def arity_inputs (syntax (_ [arity <code>.nat]) (in (case arity 0 (.list) @@ -381,7 +381,7 @@ (enum.range n.enum 0) (list#each (|>> %.nat code.local))))))) -(def: arity_types +(def arity_types (syntax (_ [arity <code>.nat]) (in (list.repeated arity (` ..Expression))))) @@ -390,7 +390,7 @@ <types> (arity_types <arity>) <definitions> (template.spliced <function>+)] (with_template [<function>] - [(`` (def: .public ((~~ (template.symbol [<function> "/" <arity>])) <inputs>) + [(`` (def .public ((~~ (template.symbol [<function> "/" <arity>])) <inputs>) (-> <types> Computation) (..apply (.list <inputs>) (..var <function>))))] diff --git a/stdlib/source/library/lux/target/php.lux b/stdlib/source/library/lux/target/php.lux index 892b98a25..c7ec0f9f5 100644 --- a/stdlib/source/library/lux/target/php.lux +++ b/stdlib/source/library/lux/target/php.lux @@ -26,48 +26,48 @@ [type [primitive (.except)]]]]) -(def: input_separator ", ") -(def: statement_suffix ";") +(def input_separator ", ") +(def statement_suffix ";") ... Added the carriage return for better Windows compatibility. -(def: \n+ +(def \n+ Text (format text.carriage_return text.new_line)) -(def: nested +(def nested (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] (|>> (format \n+) (text.replaced text.new_line nested_new_line)))) -(def: block +(def block (-> Text Text) (|>> ..nested (text.enclosed ["{" (format \n+ "}")]))) -(def: group +(def group (-> Text Text) (text.enclosed ["(" ")"])) (primitive .public (Code brand) Text - (def: .public equivalence + (def .public equivalence (All (_ brand) (Equivalence (Code brand))) (implementation - (def: (= reference subject) + (def (= reference subject) (at text.equivalence = (representation reference) (representation subject))))) - (def: .public hash + (def .public hash (All (_ brand) (Hash (Code brand))) (implementation - (def: equivalence ..equivalence) - (def: hash (|>> representation (at text.hash hash))))) + (def equivalence ..equivalence) + (def hash (|>> representation (at text.hash hash))))) - (def: .public manual + (def .public manual (-> Text Code) (|>> abstraction)) - (def: .public code + (def .public code (-> (Code Any) Text) (|>> representation)) @@ -100,18 +100,18 @@ [#reference? Bit #var Var])) - (def: .public ; + (def .public ; (-> Expression Statement) (|>> representation (text.suffix ..statement_suffix) abstraction)) - (def: .public var + (def .public var (-> Text Var) (|>> (format "$") abstraction)) (with_template [<name> <type>] - [(def: .public <name> + [(def .public <name> (-> Text <type>) (|>> abstraction))] @@ -119,27 +119,27 @@ [label Label] ) - (def: .public (set_label label) + (def .public (set_label label) (-> Label Statement) (abstraction (format (representation label) ":"))) - (def: .public (go_to label) + (def .public (go_to label) (-> Label Statement) (abstraction (format "goto " (representation label) ..statement_suffix))) - (def: .public null + (def .public null Literal (abstraction "NULL")) - (def: .public bool + (def .public bool (-> Bit Literal) (|>> (pipe.case #0 "false" #1 "true") abstraction)) - (def: .public int + (def .public int (-> Int Literal) (.let [to_hex (at n.hex encoded)] (|>> .nat @@ -147,7 +147,7 @@ (format "0x") abstraction))) - (def: .public float + (def .public float (-> Frac Literal) (|>> (pipe.cond [(f.= f.positive_infinity)] [(pipe.new "+INF" [])] @@ -162,7 +162,7 @@ [%.frac]) abstraction)) - (def: safe + (def safe (-> Text Text) (`` (|>> (~~ (with_template [<find> <replace>] [(text.replaced <find> <replace>)] @@ -180,27 +180,27 @@ )) ))) - (def: .public string + (def .public string (-> Text Literal) (|>> ..safe (text.enclosed [text.double_quote text.double_quote]) abstraction)) - (def: arguments + (def arguments (-> (List Expression) Text) (|>> (list#each ..code) (text.interposed ..input_separator) ..group)) - (def: .public (apply args func) + (def .public (apply args func) (-> (List Expression) Expression Computation) (|> (format (representation func) (..arguments args)) abstraction)) ... TODO: Remove when no longer using JPHP. - (def: .public (apply' args func) + (def .public (apply' args func) (-> (List Expression) Expression Computation) (apply (list.partial func args) (..constant "call_user_func"))) - (def: parameters + (def parameters (-> (List Argument) Text) (|>> (list#each (function (_ [reference? var]) (.if reference? @@ -210,7 +210,7 @@ ..group)) (with_template [<name> <reference?>] - [(def: .public <name> + [(def .public <name> (-> Var Argument) (|>> [<reference?>]))] @@ -218,7 +218,7 @@ [reference #1] ) - (def: .public (closure uses arguments body!) + (def .public (closure uses arguments body!) (-> (List Argument) (List Argument) Statement Literal) (let [uses (case uses {.#End} @@ -232,7 +232,7 @@ ..group abstraction))) - (def: arity_inputs + (def arity_inputs (syntax (_ [arity <code>.nat]) (in (case arity 0 (.list) @@ -240,7 +240,7 @@ (enum.range n.enum 0) (list#each (|>> %.nat code.local))))))) - (def: arity_types + (def arity_types (syntax (_ [arity <code>.nat]) (in (list.repeated arity (` ..Expression))))) @@ -249,12 +249,12 @@ <inputs> (arity_inputs <arity>) <types> (arity_types <arity>) <definitions> (template.spliced <function>+)] - (def: .public (<apply> function [<inputs>]) + (def .public (<apply> function [<inputs>]) (-> Expression [<types>] Computation) (..apply (.list <inputs>) function)) (with_template [<function>] - [(`` (def: .public (~~ (template.symbol [<function> "/" <arity>])) + [(`` (def .public (~~ (template.symbol [<function> "/" <arity>])) (<apply> (..constant <function>))))] <definitions>))] @@ -309,11 +309,11 @@ ["iconv_substr"] ["substr"]]] ) - (def: .public (key_value key value) + (def .public (key_value key value) (-> Expression Expression Expression) (abstraction (format (representation key) " => " (representation value)))) - (def: .public (array/* values) + (def .public (array/* values) (-> (List Expression) Literal) (|> values (list#each ..code) @@ -322,11 +322,11 @@ (format "array") abstraction)) - (def: .public (array_merge/+ required optionals) + (def .public (array_merge/+ required optionals) (-> Expression (List Expression) Computation) (..apply (list.partial required optionals) (..constant "array_merge"))) - (def: .public (array/** kvs) + (def .public (array/** kvs) (-> (List [Expression Expression]) Literal) (|> kvs (list#each (function (_ [key value]) @@ -336,32 +336,32 @@ (format "array") abstraction)) - (def: .public (new constructor inputs) + (def .public (new constructor inputs) (-> Constant (List Expression) Computation) (|> (format "new " (representation constructor) (arguments inputs)) abstraction)) - (def: .public (the field object) + (def .public (the field object) (-> Text Expression Computation) (|> (format (representation object) "->" field) abstraction)) - (def: .public (do method inputs object) + (def .public (do method inputs object) (-> Text (List Expression) Expression Computation) (|> (format (representation (..the method object)) (..arguments inputs)) abstraction)) - (def: .public (item idx array) + (def .public (item idx array) (-> Expression Expression Access) (|> (format (representation array) "[" (representation idx) "]") abstraction)) - (def: .public (global name) + (def .public (global name) (-> Text Global) (|> (..var "GLOBALS") (..item (..string name)) transmutation)) - (def: .public (? test then else) + (def .public (? test then else) (-> Expression Expression Expression Computation) (|> (format (..group (representation test)) " ? " (..group (representation then)) " : " @@ -370,7 +370,7 @@ abstraction)) (with_template [<name> <op>] - [(def: .public (<name> parameter subject) + [(def .public (<name> parameter subject) (-> Expression Expression Computation) (|> (format (representation subject) " " <op> " " (representation parameter)) ..group @@ -398,7 +398,7 @@ ) (with_template [<unary> <name>] - [(def: .public <name> + [(def .public <name> (-> Computation Computation) (|>> representation (format <unary>) abstraction))] @@ -407,22 +407,22 @@ ["-" opposite] ) - (def: .public (set var value) + (def .public (set var value) (-> Location Expression Computation) (|> (format (representation var) " = " (representation value)) ..group abstraction)) - (def: .public (set! var value) + (def .public (set! var value) (-> Location Expression Statement) (abstraction (format (representation var) " = " (representation value) ";"))) - (def: .public (set? var) + (def .public (set? var) (-> Var Computation) (..apply/1 [var] (..constant "isset"))) (with_template [<name> <modifier>] - [(def: .public <name> + [(def .public <name> (-> Var Statement) (|>> representation (format <modifier> " ") (text.suffix ..statement_suffix) abstraction))] @@ -430,7 +430,7 @@ ) (with_template [<name> <modifier> <location>] - [(def: .public (<name> location value) + [(def .public (<name> location value) (-> <location> Expression Statement) (abstraction (format <modifier> " " (representation location) " = " (representation value) @@ -440,7 +440,7 @@ [define_constant "const" Constant] ) - (def: .public (if test then! else!) + (def .public (if test then! else!) (-> Expression Statement Statement Statement) (abstraction (format "if" (..group (representation test)) " " @@ -448,33 +448,33 @@ " else " (..block (representation else!))))) - (def: .public (when test then!) + (def .public (when test then!) (-> Expression Statement Statement) (abstraction (format "if" (..group (representation test)) " " (..block (representation then!))))) - (def: .public (then pre! post!) + (def .public (then pre! post!) (-> Statement Statement Statement) (abstraction (format (representation pre!) \n+ (representation post!)))) - (def: .public (while test body!) + (def .public (while test body!) (-> Expression Statement Statement) (abstraction (format "while" (..group (representation test)) " " (..block (representation body!))))) - (def: .public (do_while test body!) + (def .public (do_while test body!) (-> Expression Statement Statement) (abstraction (format "do " (..block (representation body!)) " while" (..group (representation test)) ..statement_suffix))) - (def: .public (for_each array value body!) + (def .public (for_each array value body!) (-> Expression Var Statement Statement) (abstraction (format "foreach(" (representation array) @@ -487,14 +487,14 @@ #exception Var #handler Statement])) - (def: (catch except) + (def (catch except) (-> Except Text) (let [declaration (format (representation (.the #class except)) " " (representation (.the #exception except)))] (format "catch" (..group declaration) " " (..block (representation (.the #handler except)))))) - (def: .public (try body! excepts) + (def .public (try body! excepts) (-> Statement (List Except) Statement) (abstraction (format "try " (..block (representation body!)) @@ -504,7 +504,7 @@ (text.interposed \n+))))) (with_template [<name> <keyword>] - [(def: .public <name> + [(def .public <name> (-> Expression Statement) (|>> representation (format <keyword> " ") (text.suffix ..statement_suffix) abstraction))] @@ -513,13 +513,13 @@ [echo "echo"] ) - (def: .public (define name value) + (def .public (define name value) (-> Constant Expression Expression) (..apply/2 (..constant "define") [(|> name representation ..string) value])) - (def: .public (define_function name arguments body!) + (def .public (define_function name arguments body!) (-> Constant (List Argument) Statement Statement) (abstraction (format "function " (representation name) @@ -528,7 +528,7 @@ (..block (representation body!))))) (with_template [<name> <keyword>] - [(def: .public <name> + [(def .public <name> Statement (|> <keyword> (text.suffix ..statement_suffix) @@ -538,18 +538,18 @@ [continue "continue"] ) - (def: .public splat + (def .public splat (-> Expression Expression) (|>> representation (format "...") abstraction)) ) -(def: .public (cond clauses else!) +(def .public (cond clauses else!) (-> (List [Expression Statement]) Statement Statement) (list#mix (function (_ [test then!] next!) (..if test then! next!)) else! (list.reversed clauses))) -(def: .public command_line_arguments +(def .public command_line_arguments Var (..var "argv")) diff --git a/stdlib/source/library/lux/target/python.lux b/stdlib/source/library/lux/target/python.lux index 4e85ea258..54a9dbd9c 100644 --- a/stdlib/source/library/lux/target/python.lux +++ b/stdlib/source/library/lux/target/python.lux @@ -1,6 +1,6 @@ (.using [library - [lux (.except Location Code not or and list if int comment exec try the is) + [lux (.except Location Code not or and list if int comment exec try the is def) ["@" target] ["[0]" ffi] [abstract @@ -27,10 +27,10 @@ [type [primitive (.except)]]]]) -(def: input_separator +(.def input_separator ", ") -(def: expression +(.def expression (-> Text Text) (text.enclosed ["(" ")"])) @@ -43,11 +43,11 @@ (these)) ... Added the carriage return for better Windows compatibility. -(def: \n+ +(.def \n+ Text (format text.carriage_return text.new_line)) -(def: nested +(.def nested (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] (for @.old (|>> (format \n+) @@ -60,23 +60,23 @@ (primitive .public (Code brand) Text - (def: .public equivalence + (.def .public equivalence (All (_ brand) (Equivalence (Code brand))) (implementation - (def: (= reference subject) + (.def (= reference subject) (at text.equivalence = (representation reference) (representation subject))))) - (def: .public hash + (.def .public hash (All (_ brand) (Hash (Code brand))) (implementation - (def: equivalence ..equivalence) - (def: hash (|>> representation (at text.hash hash))))) + (.def equivalence ..equivalence) + (.def hash (|>> representation (at text.hash hash))))) - (def: .public manual + (.def .public manual (-> Text Code) (|>> abstraction)) - (def: .public code + (.def .public code (-> (Code Any) Text) (|>> representation)) @@ -113,12 +113,12 @@ [KVar Keyword] ) - (def: .public var + (.def .public var (-> Text SVar) (|>> abstraction)) (with_template [<name> <brand> <prefix>] - [(def: .public <name> + [(.def .public <name> (-> SVar (Var <brand>)) (|>> representation (format <prefix>) abstraction))] @@ -126,26 +126,26 @@ [keyword Keyword "**"] ) - (def: .public none + (.def .public none Literal (abstraction "None")) - (def: .public bool + (.def .public bool (-> Bit Literal) (|>> (pipe.case #0 "False" #1 "True") abstraction)) - (def: .public int + (.def .public int (-> Int Literal) (|>> %.int abstraction)) - (def: .public (long value) + (.def .public (long value) (-> Int Literal) (abstraction (format (%.int value) "L"))) - (def: .public float + (.def .public float (-> Frac Literal) (`` (|>> (pipe.cond (~~ (with_template [<test> <python>] [[<test>] @@ -160,7 +160,7 @@ [%.frac]) abstraction))) - (def: safe + (.def safe (-> Text Text) (`` (|>> (~~ (with_template [<find> <replace>] [(text.replaced <find> <replace>)] @@ -177,20 +177,20 @@ )) ))) - (def: .public string + (.def .public string (-> Text Literal) (|>> ..safe (text.enclosed [text.double_quote text.double_quote]) abstraction)) - (def: .public unicode + (.def .public unicode (-> Text Literal) (|>> ..string representation (format "u") abstraction)) - (def: (composite_literal left_delimiter right_delimiter entry_serializer) + (.def (composite_literal left_delimiter right_delimiter entry_serializer) (All (_ a) (-> Text Text (-> a Text) (-> (List a) Literal))) @@ -204,7 +204,7 @@ right_delimiter)))) (with_template [<name> <pre> <post>] - [(def: .public <name> + [(.def .public <name> (-> (List (Expression Any)) Literal) (composite_literal <pre> <post> ..code))] @@ -212,23 +212,23 @@ [list "[" "]"] ) - (def: .public (slice from to list) + (.def .public (slice from to list) (-> (Expression Any) (Expression Any) (Expression Any) Access) (<| abstraction ... ..expression (format (representation list) "[" (representation from) ":" (representation to) "]"))) - (def: .public (slice_from from list) + (.def .public (slice_from from list) (-> (Expression Any) (Expression Any) Access) (<| abstraction ... ..expression (format (representation list) "[" (representation from) ":]"))) - (def: .public dict + (.def .public dict (-> (List [(Expression Any) (Expression Any)]) (Computation Any)) (composite_literal "{" "}" (.function (_ [k v]) (format (representation k) " : " (representation v))))) - (def: .public (apply args func) + (.def .public (apply args func) (-> (List (Expression Any)) (Expression Any) (Computation Any)) (<| abstraction ... ..expression @@ -238,7 +238,7 @@ ")"))) (with_template [<name> <brand> <prefix>] - [(def: .public <name> + [(.def .public <name> (-> (Expression Any) (Expression Any)) (|>> representation (format <prefix>) @@ -248,28 +248,28 @@ [splat_keyword Keyword "**"] ) - (def: .public (the name object) + (.def .public (the name object) (-> Text (Expression Any) Access) (abstraction (format (representation object) "." name))) - (def: .public (do method args object) + (.def .public (do method args object) (-> Text (List (Expression Any)) (Expression Any) (Computation Any)) (|> object (..the method) (..apply args))) - (def: .public (item idx array) + (.def .public (item idx array) (-> (Expression Any) (Expression Any) Access) (abstraction (format (representation array) "[" (representation idx) "]"))) - (def: .public (? test then else) + (.def .public (? test then else) (-> (Expression Any) (Expression Any) (Expression Any) (Computation Any)) (<| abstraction ..expression (format (representation then) " if " (representation test) " else " (representation else)))) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(.def .public (<name> param subject) (-> (Expression Any) (Expression Any) (Computation Any)) (<| abstraction ..expression @@ -301,7 +301,7 @@ ) (with_template [<name> <unary>] - [(def: .public (<name> subject) + [(.def .public (<name> subject) (-> (Expression Any) (Computation Any)) (<| abstraction ... ..expression @@ -311,31 +311,31 @@ [opposite "-"] ) - (def: .public (lambda arguments body) + (.def .public (lambda arguments body) (-> (List (Var Any)) (Expression Any) (Computation Any)) (<| abstraction ..expression (format "lambda " (|> arguments (list#each ..code) (text.interposed ..input_separator)) ": " (representation body)))) - (def: .public (set vars value) + (.def .public (set vars value) (-> (List (Location Any)) (Expression Any) (Statement Any)) (abstraction (format (|> vars (list#each ..code) (text.interposed ..input_separator)) " = " (representation value)))) - (def: .public multi + (.def .public multi (-> (List (Expression Any)) (Expression Any)) (|>> (list#each ..code) (text.interposed ..input_separator) abstraction)) - (def: .public (delete where) + (.def .public (delete where) (-> (Location Any) (Statement Any)) (abstraction (format "del " (representation where)))) - (def: .public (if test then! else!) + (.def .public (if test then! else!) (-> (Expression Any) (Statement Any) (Statement Any) (Statement Any)) (abstraction (format "if " (representation test) ":" @@ -343,13 +343,13 @@ \n+ "else:" (..nested (representation else!))))) - (def: .public (when test then!) + (.def .public (when test then!) (-> (Expression Any) (Statement Any) (Statement Any)) (abstraction (format "if " (representation test) ":" (..nested (representation then!))))) - (def: .public (then pre! post!) + (.def .public (then pre! post!) (-> (Statement Any) (Statement Any) (Statement Any)) (abstraction (format (representation pre!) @@ -357,7 +357,7 @@ (representation post!)))) (with_template [<keyword> <0>] - [(def: .public <0> + [(.def .public <0> (Statement Any) (abstraction <keyword>))] @@ -365,7 +365,7 @@ ["continue" continue] ) - (def: .public (while test body! else!) + (.def .public (while test body! else!) (-> (Expression Any) (Statement Any) (Maybe (Statement Any)) Loop) (abstraction (format "while " (representation test) ":" @@ -378,17 +378,17 @@ {.#None} "")))) - (def: .public (for_in var inputs body!) + (.def .public (for_in var inputs body!) (-> SVar (Expression Any) (Statement Any) Loop) (abstraction (format "for " (representation var) " in " (representation inputs) ":" (..nested (representation body!))))) - (def: .public statement + (.def .public statement (-> (Expression Any) (Statement Any)) (|>> transmutation)) - (def: .public pass + (.def .public pass (Statement Any) (abstraction "pass")) @@ -398,7 +398,7 @@ #exception SVar #handler (Statement Any)])) - (def: .public (try body! excepts) + (.def .public (try body! excepts) (-> (Statement Any) (List Except) (Statement Any)) (abstraction (format "try:" @@ -411,7 +411,7 @@ text.together)))) (with_template [<name> <keyword> <pre>] - [(def: .public (<name> value) + [(.def .public (<name> value) (-> (Expression Any) (Statement Any)) (abstraction (format <keyword> (<pre> (representation value)))))] @@ -421,7 +421,7 @@ [print "print" ..expression] ) - (def: .public (exec globals code) + (.def .public (exec globals code) (-> (Maybe (Expression Any)) (Expression Any) (Statement Any)) (let [extra (case globals {.#Some globals} @@ -432,7 +432,7 @@ (abstraction (format "exec" (representation (..tuple (list.partial code extra))))))) - (def: .public (def name args body) + (.def .public (def name args body) (-> SVar (List (Ex (_ k) (Var k))) (Statement Any) (Statement Any)) (abstraction (format "def " (representation name) @@ -441,17 +441,17 @@ "):" (..nested (representation body))))) - (def: .public (import module_name) + (.def .public (import module_name) (-> Text (Statement Any)) (abstraction (format "import " module_name))) - (def: .public (comment commentary on) + (.def .public (comment commentary on) (All (_ brand) (-> Text (Code brand) (Code brand))) (abstraction (format "# " (text.replaced text.\n "\n" commentary) \n+ (representation on)))) ) -(def: arity_inputs +(.def arity_inputs (syntax (_ [arity <code>.nat]) (in (case arity 0 (.list) @@ -459,7 +459,7 @@ (enum.range n.enum 0) (list#each (|>> %.nat code.local))))))) -(def: arity_types +(.def arity_types (syntax (_ [arity <code>.nat]) (in (list.repeated arity (` (Expression Any)))))) @@ -467,7 +467,7 @@ [(with_expansions [<inputs> (arity_inputs <arity>) <definitions> (template.spliced <function>+)] (with_template [<function>] - [(`` (def: .public ((~~ (template.symbol [<function> "/" <arity>])) <inputs>) + [(`` (.def .public ((~~ (template.symbol [<function> "/" <arity>])) <inputs>) (-> (~~ (arity_types <arity>)) (Computation Any)) (..apply (.list <inputs>) (..var <function>))))] diff --git a/stdlib/source/library/lux/target/r.lux b/stdlib/source/library/lux/target/r.lux index 4956df9c0..f31a950fe 100644 --- a/stdlib/source/library/lux/target/r.lux +++ b/stdlib/source/library/lux/target/r.lux @@ -49,45 +49,45 @@ [PVar Poly] ) - (def: .public var + (def .public var (-> Text SVar) (|>> abstraction)) - (def: .public var_args + (def .public var_args PVar (abstraction "...")) - (def: .public manual + (def .public manual (-> Text Code) (|>> abstraction)) - (def: .public code + (def .public code (-> (Code Any) Text) (|>> representation)) - (def: (self_contained code) + (def (self_contained code) (-> Text Expression) (abstraction (format "(" code ")"))) ... Added the carriage return for better Windows compatibility. - (def: \n+ + (def \n+ Text (format text.carriage_return text.new_line)) - (def: nested_new_line + (def nested_new_line (format text.new_line text.tab)) - (def: nested + (def nested (-> Text Text) (|>> (text.replaced text.new_line ..nested_new_line) (format text.carriage_return ..nested_new_line))) - (def: (_block expression) + (def (_block expression) (-> Text Text) (format "{" (nested expression) \n+ "}")) - (def: .public (block expression) + (def .public (block expression) (-> Expression Expression) (abstraction (format "{" @@ -95,7 +95,7 @@ \n+ "}"))) (with_template [<name> <r>] - [(def: .public <name> + [(def .public <name> Expression (abstraction <r>))] @@ -104,25 +104,25 @@ ) (with_template [<name>] - [(def: .public <name> Expression n/a)] + [(def .public <name> Expression n/a)] [not_available] [not_applicable] [no_answer] ) - (def: .public bool + (def .public bool (-> Bit Expression) (|>> (pipe.case #0 "FALSE" #1 "TRUE") abstraction)) - (def: .public int + (def .public int (-> Int Expression) (|>> %.int abstraction)) - (def: .public float + (def .public float (-> Frac Expression) (|>> (pipe.cond [(f.= f.positive_infinity)] [(pipe.new "1.0/0.0" [])] @@ -137,7 +137,7 @@ [%.frac]) ..self_contained)) - (def: safe + (def safe (-> Text Text) (`` (|>> (~~ (with_template [<find> <replace>] [(text.replaced <find> <replace>)] @@ -153,23 +153,23 @@ )) ))) - (def: .public string + (def .public string (-> Text Expression) (|>> ..safe %.text abstraction)) - (def: .public (slice from to list) + (def .public (slice from to list) (-> Expression Expression Expression Expression) (..self_contained (format (representation list) "[" (representation from) ":" (representation to) "]"))) - (def: .public (slice_from from list) + (def .public (slice_from from list) (-> Expression Expression Expression) (..self_contained (format (representation list) "[-1" ":-" (representation from) "]"))) - (def: .public (apply args func) + (def .public (apply args func) (-> (List Expression) Expression Expression) (let [func (representation func) spacing (|> " " @@ -184,7 +184,7 @@ ")")))) (with_template [<name> <function>] - [(def: .public (<name> members) + [(def .public (<name> members) (-> (List Expression) Expression) (..apply members (..var <function>)))] @@ -192,13 +192,13 @@ [list "list"] ) - (def: .public named_list + (def .public named_list (-> (List [Text Expression]) Expression) (|>> (list#each (.function (_ [key value]) (abstraction (format key "=" (representation value))))) ..list)) - (def: .public (apply_kw args kw_args func) + (def .public (apply_kw args kw_args func) (-> (List Expression) (List [Text Expression]) Expression Expression) (..self_contained (format (representation func) @@ -209,7 +209,7 @@ kw_args)) ")")))) - (def: arity_inputs + (def arity_inputs (syntax (_ [arity <code>.nat]) (in (case arity 0 (.list) @@ -217,7 +217,7 @@ list.indices (list#each (|>> %.nat code.local))))))) - (def: arity_types + (def arity_types (syntax (_ [arity <code>.nat]) (in (list.repeated arity (` ..Expression))))) @@ -226,12 +226,12 @@ <inputs> (arity_inputs <arity>) <types> (arity_types <arity>) <definitions> (template.spliced <function>+)] - (def: .public (<apply> function [<inputs>]) + (def .public (<apply> function [<inputs>]) (-> Expression [<types>] Expression) (..apply (.list <inputs>) function)) (with_template [<function>] - [(`` (def: .public (~~ (template.symbol [<function> "/" <arity>])) + [(`` (def .public (~~ (template.symbol [<function> "/" <arity>])) (-> [<types>] Expression) (<apply> (..var <function>))))] @@ -245,30 +245,30 @@ [["paste"]]] ) - (def: .public as::integer + (def .public as::integer (-> Expression Expression) (..apply/1 (..var "as.integer"))) - (def: .public (item idx list) + (def .public (item idx list) (-> Expression Expression Expression) (..self_contained (format (representation list) "[[" (representation idx) "]]"))) - (def: .public (if test then else) + (def .public (if test then else) (-> Expression Expression Expression Expression) (abstraction (format "if(" (representation test) ")" " " (.._block (representation then)) " else " (.._block (representation else))))) - (def: .public (when test then) + (def .public (when test then) (-> Expression Expression Expression) (abstraction (format "if(" (representation test) ") {" (.._block (representation then)) \n+ "}"))) - (def: .public (cond clauses else) + (def .public (cond clauses else) (-> (List [Expression Expression]) Expression Expression) (list#mix (.function (_ [test then] next) (if test then next)) @@ -276,7 +276,7 @@ (list.reversed clauses))) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Expression Expression Expression) (..self_contained (format (representation subject) @@ -299,7 +299,7 @@ ) (with_template [<name> <func>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Expression Expression Expression) (..apply (.list subject param) (..var <func>)))] @@ -310,12 +310,12 @@ [bit_ushr "bitwShiftR"] ) - (def: .public (bit_not subject) + (def .public (bit_not subject) (-> Expression Expression) (..apply (.list subject) (..var "bitwNot"))) (with_template [<name> <op>] - [(def: .public <name> + [(def .public <name> (-> Expression Expression) (|>> representation (format <op>) ..self_contained))] @@ -323,23 +323,23 @@ [negate "-"] ) - (def: .public (length list) + (def .public (length list) (-> Expression Expression) (..apply (.list list) (..var "length"))) - (def: .public (range from to) + (def .public (range from to) (-> Expression Expression Expression) (..self_contained (format (representation from) ":" (representation to)))) - (def: .public (function inputs body) + (def .public (function inputs body) (-> (List (Ex (_ k) (Var k))) Expression Expression) (let [args (|> inputs (list#each ..code) (text.interposed ", "))] (..self_contained (format "function(" args ") " (.._block (representation body)))))) - (def: .public (try body warning error finally) + (def .public (try body warning error finally) (-> Expression (Maybe Expression) (Maybe Expression) (Maybe Expression) Expression) (let [optional (is (-> Text (Maybe Expression) (-> Text Text) Text) (.function (_ parameter value preparation) @@ -354,20 +354,20 @@ (optional "finally" finally .._block) ")")))) - (def: .public (while test body) + (def .public (while test body) (-> Expression Expression Expression) (..self_contained (format "while (" (representation test) ") " (.._block (representation body))))) - (def: .public (for_in var inputs body) + (def .public (for_in var inputs body) (-> SVar Expression Expression Expression) (..self_contained (format "for (" (representation var) " in " (representation inputs) ")" (.._block (representation body))))) (with_template [<name> <keyword>] - [(def: .public (<name> message) + [(def .public (<name> message) (-> Expression Expression) (..apply (.list message) (..var <keyword>)))] @@ -375,17 +375,17 @@ [print "print"] ) - (def: .public (set! var value) + (def .public (set! var value) (-> SVar Expression Expression) (..self_contained (format (representation var) " <- " (representation value)))) - (def: .public (set_item! idx value list) + (def .public (set_item! idx value list) (-> Expression Expression SVar Expression) (..self_contained (format (representation list) "[[" (representation idx) "]] <- " (representation value)))) - (def: .public (then pre post) + (def .public (then pre post) (-> Expression Expression Expression) (abstraction (format (representation pre) diff --git a/stdlib/source/library/lux/target/ruby.lux b/stdlib/source/library/lux/target/ruby.lux index ae928f407..d196e2308 100644 --- a/stdlib/source/library/lux/target/ruby.lux +++ b/stdlib/source/library/lux/target/ruby.lux @@ -26,15 +26,15 @@ [type [primitive (.except)]]]]) -(def: input_separator ", ") -(def: statement_suffix ";") +(def input_separator ", ") +(def statement_suffix ";") ... Added the carriage return for better Windows compatibility. -(def: \n+ +(def \n+ Text (format text.carriage_return text.new_line)) -(def: nested +(def nested (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] (|>> (format \n+) @@ -43,17 +43,17 @@ (primitive .public (Code brand) Text - (def: .public equivalence + (def .public equivalence (All (_ brand) (Equivalence (Code brand))) (implementation - (def: (= reference subject) + (def (= reference subject) (at text.equivalence = (representation reference) (representation subject))))) - (def: .public manual + (def .public manual (-> Text Code) (|>> abstraction)) - (def: .public code + (def .public code (-> (Code Any) Text) (|>> representation)) @@ -86,7 +86,7 @@ ) (with_template [<var> <prefix> <constructor>] - [(def: .public <constructor> + [(def .public <constructor> (-> Text <var>) (|>> (format <prefix>) abstraction))] @@ -99,7 +99,7 @@ (with_template [<var> <prefix> <modifier> <unpacker>] [(with_template [<name> <input> <output>] - [(def: .public <name> + [(def .public <name> (-> <input> <output>) (|>> representation (format <prefix>) abstraction))] @@ -112,7 +112,7 @@ ) (with_template [<ruby_name> <lux_name>] - [(def: .public <lux_name> + [(def .public <lux_name> GVar (..global <ruby_name>))] @@ -134,31 +134,31 @@ ) (with_template [<ruby_name> <lux_name>] - [(def: .public <lux_name> + [(def .public <lux_name> CVar (..manual <ruby_name>))] ["ARGV" command_line_arguments] ) - (def: .public multi + (def .public multi (-> (List Expression) Expression) (|>> (list#each ..code) (text.interposed ..input_separator) abstraction)) - (def: .public nil + (def .public nil Literal (abstraction "nil")) - (def: .public bool + (def .public bool (-> Bit Literal) (|>> (pipe.case #0 "false" #1 "true") abstraction)) - (def: safe + (def safe (-> Text Text) (`` (|>> (~~ (with_template [<find> <replace>] [(text.replaced <find> <replace>)] @@ -176,7 +176,7 @@ ))) (with_template [<format> <name> <type> <prep>] - [(def: .public <name> + [(def .public <name> (-> <type> Literal) (|>> <prep> <format> abstraction))] @@ -185,7 +185,7 @@ [(<|) symbol Text (format ":")] ) - (def: .public float + (def .public float (-> Frac Literal) (|>> (pipe.cond [(f.= f.positive_infinity)] [(pipe.new "(+1.0/0.0)" [])] @@ -200,21 +200,21 @@ [%.frac]) abstraction)) - (def: .public (array_range from to array) + (def .public (array_range from to array) (-> Expression Expression Expression Computation) (|> (format (representation from) ".." (representation to)) (text.enclosed ["[" "]"]) (format (representation array)) abstraction)) - (def: .public array + (def .public array (-> (List Expression) Computation) (|>> (list#each (|>> representation (text.suffix ..input_separator))) text.together (text.enclosed ["[" "]"]) abstraction)) - (def: .public hash + (def .public hash (-> (List [Expression Expression]) Computation) (|>> (list#each (.function (_ [k v]) (format (representation k) " => " (representation v) ..input_separator))) @@ -222,7 +222,7 @@ (text.enclosed ["{" "}"]) abstraction)) - (def: (control_structure content) + (def (control_structure content) (-> Text Text) (format content \n+ "end" ..statement_suffix)) @@ -232,7 +232,7 @@ [#parameters (List Var) #body Statement])) - (def: (block it) + (def (block it) (-> Block Text) (|> (format (|> (.the #parameters it) (list#each (|>> representation)) @@ -241,7 +241,7 @@ (..nested (representation (.the #body it)))) (text.enclosed ["{" "}"]))) - (def: .public (apply arguments block func) + (def .public (apply arguments block func) (-> (List Expression) (Maybe Block) Expression Computation) (let [arguments (|> arguments (list#each (|>> representation)) @@ -263,18 +263,18 @@ (text.enclosed' "|")))))] (abstraction (format (representation func) arguments block)))) - (def: .public (the field object) + (def .public (the field object) (-> Text Expression Access) (abstraction (format (representation object) "." field))) - (def: .public (item idx array) + (def .public (item idx array) (-> Expression Expression Access) (|> (representation idx) (text.enclosed ["[" "]"]) (format (representation array)) abstraction)) - (def: .public (? test then else) + (def .public (? test then else) (-> Expression Expression Expression Computation) (|> (format (representation test) " ? " (representation then) " : " @@ -282,20 +282,20 @@ (text.enclosed ["(" ")"]) abstraction)) - (def: .public statement + (def .public statement (-> Expression Statement) (|>> representation (text.suffix ..statement_suffix) abstraction)) - (def: .public (then pre! post!) + (def .public (then pre! post!) (-> Statement Statement Statement) (abstraction (format (representation pre!) \n+ (representation post!)))) - (def: .public (set vars value) + (def .public (set vars value) (-> (List Location) Expression Statement) (abstraction (format (|> vars @@ -303,7 +303,7 @@ (text.interposed ..input_separator)) " = " (representation value) ..statement_suffix))) - (def: .public (if test then! else!) + (def .public (if test then! else!) (-> Expression Statement Statement Statement) (<| abstraction ..control_structure @@ -313,7 +313,7 @@ (..nested (representation else!))))) (with_template [<name> <control_structure>] - [(def: .public (<name> test then!) + [(def .public (<name> test then!) (-> Expression Statement Statement) (<| abstraction ..control_structure @@ -324,7 +324,7 @@ [while "while"] ) - (def: .public (for_in var array iteration!) + (def .public (for_in var array iteration!) (-> LVar Expression Statement Statement) (<| abstraction ..control_structure @@ -339,7 +339,7 @@ #exception LVar #rescue Statement])) - (def: .public (begin body! rescues) + (def .public (begin body! rescues) (-> Statement (List Rescue) Statement) (<| abstraction ..control_structure @@ -351,22 +351,22 @@ (..nested (representation rescue))))) (text.interposed \n+))))) - (def: .public (catch expectation block) + (def .public (catch expectation block) (-> Expression Block Expression) (<| abstraction (format "catch(" (representation expectation) ") " (..block block)))) - (def: .public (return value) + (def .public (return value) (-> Expression Statement) (abstraction (format "return " (representation value) ..statement_suffix))) - (def: .public (raise message) + (def .public (raise message) (-> Expression Expression) (abstraction (format "raise " (representation message)))) (with_template [<name> <keyword>] - [(def: .public <name> + [(def .public <name> Statement (|> <keyword> (text.suffix ..statement_suffix) @@ -377,11 +377,11 @@ [break "break"] ) - (def: .public initialize + (def .public initialize LVar (..manual "initialize")) - (def: .public (function name args body!) + (def .public (function name args body!) (-> LVar (List LVar) Statement Statement) (<| abstraction ..control_structure @@ -392,7 +392,7 @@ (text.enclosed ["(" ")"])) (..nested (representation body!))))) - (def: .public (lambda name block) + (def .public (lambda name block) (-> (Maybe LVar) Block Literal) (let [proc (format "lambda " (..block block))] (|> (case name @@ -405,7 +405,7 @@ abstraction))) (with_template [<op> <name>] - [(def: .public (<name> parameter subject) + [(def .public (<name> parameter subject) (-> Expression Expression Computation) (abstraction (format "(" (representation subject) " " <op> " " (representation parameter) ")")))] @@ -433,7 +433,7 @@ ) (with_template [<unary> <name>] - [(def: .public (<name> subject) + [(def .public (<name> subject) (-> Expression Computation) (abstraction (format "(" <unary> (representation subject) ")")))] @@ -442,13 +442,13 @@ ["-" opposite] ) - (def: .public (comment commentary on) + (def .public (comment commentary on) (All (_ brand) (-> Text (Code brand) (Code brand))) (abstraction (format "# " (..safe commentary) \n+ (representation on)))) (with_template [<name>] - [(`` (def: .public ((~~ (template.symbol [<name> "/*"])) attributes) + [(`` (def .public ((~~ (template.symbol [<name> "/*"])) attributes) (-> (List Text) Statement) (..statement (..apply (list#each ..string attributes) {.#None} (..manual <name>)))))] @@ -458,30 +458,30 @@ ["attr_accessor"]) ) -(def: .public (do method arguments block object) +(def .public (do method arguments block object) (-> Text (List Expression) (Maybe Block) Expression Computation) (|> object (..the method) (..apply arguments block))) -(def: .public new +(def .public new (-> (List Expression) (Maybe Block) Expression Computation) (..do "new")) -(def: .public (class definition) +(def .public (class definition) (-> Block Computation) (|> (..manual "Class") (..new (list) {.#Some definition}))) -(def: .public (module definition) +(def .public (module definition) (-> Block Computation) (|> (..manual "Module") (..new (list) {.#Some definition}))) -(def: .public (apply_lambda args lambda) +(def .public (apply_lambda args lambda) (-> (List Expression) Expression Computation) (|> lambda (..do "call" args {.#None}))) -(def: arity_inputs +(def arity_inputs (syntax (_ [arity <code>.nat]) (in (case arity 0 (.list) @@ -489,7 +489,7 @@ (enum.range n.enum 0) (list#each (|>> %.nat code.local))))))) -(def: arity_types +(def arity_types (syntax (_ [arity <code>.nat]) (in (list.repeated arity (` ..Expression))))) @@ -499,7 +499,7 @@ <types> (arity_types <arity>) <definitions> (template.spliced <function>+)] (with_template [<function>] - [(`` (def: .public ((~~ (template.symbol [<function> "/" <arity>])) <inputs>) + [(`` (def .public ((~~ (template.symbol [<function> "/" <arity>])) <inputs>) (-> <types> Computation) (..apply (.list <inputs>) {.#None} (..manual <function>))))] @@ -520,18 +520,18 @@ ["alias_method"]]] ) -(def: .public (throw/1 error) +(def .public (throw/1 error) (-> Expression Statement) (..statement (..apply (list error) {.#None} (..manual "throw")))) -(def: .public (throw/2 tag value) +(def .public (throw/2 tag value) (-> Expression Expression Statement) (..statement (..apply (list tag value) {.#None} (..manual "throw")))) -(def: .public (class_variable_set var value object) +(def .public (class_variable_set var value object) (-> SVar Expression Expression Computation) (..do "class_variable_set" (list (..string (..code var)) value) {.#None} object)) -(def: .public (class_variable_get var object) +(def .public (class_variable_get var object) (-> SVar Expression Computation) (..do "class_variable_get" (list (..string (..code var))) {.#None} object)) diff --git a/stdlib/source/library/lux/target/scheme.lux b/stdlib/source/library/lux/target/scheme.lux index c0632b5be..c3d1722b1 100644 --- a/stdlib/source/library/lux/target/scheme.lux +++ b/stdlib/source/library/lux/target/scheme.lux @@ -22,11 +22,11 @@ [primitive (.except)]]]]) ... Added the carriage return for better Windows compatibility. -(def: \n+ +(def \n+ Text (format text.carriage_return text.new_line)) -(def: nested +(def nested (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] (text.replaced text.new_line nested_new_line))) @@ -34,17 +34,17 @@ (primitive .public (Code k) Text - (def: .public equivalence + (def .public equivalence (All (_ brand) (Equivalence (Code brand))) (implementation - (def: (= reference subject) + (def (= reference subject) (at text.equivalence = (representation reference) (representation subject))))) - (def: .public hash + (def .public hash (All (_ brand) (Hash (Code brand))) (implementation - (def: equivalence ..equivalence) - (def: hash (|>> representation (at text.hash hash))))) + (def equivalence ..equivalence) + (def hash (|>> representation (at text.hash hash))))) (with_template [<type> <brand> <super>+] [(primitive .public (<brand> brand) Any) @@ -66,19 +66,19 @@ [#mandatory (List Var) #rest (Maybe Var)])) - (def: .public manual + (def .public manual (-> Text Code) (|>> abstraction)) - (def: .public code + (def .public code (-> (Code Any) Text) (|>> representation)) - (def: .public var + (def .public var (-> Text Var) (|>> abstraction)) - (def: (arguments [mandatory rest]) + (def (arguments [mandatory rest]) (-> Arguments (Code Any)) (case rest {.#Some rest} @@ -101,22 +101,22 @@ (text.enclosed ["(" ")"]) abstraction))) - (def: .public nil + (def .public nil Computation (abstraction "'()")) - (def: .public bool + (def .public bool (-> Bit Computation) (|>> (pipe.case #0 "#f" #1 "#t") abstraction)) - (def: .public int + (def .public int (-> Int Computation) (|>> %.int abstraction)) - (def: .public float + (def .public float (-> Frac Computation) (|>> (pipe.cond [(f.= f.positive_infinity)] [(pipe.new "+inf.0" [])] @@ -131,11 +131,11 @@ [%.frac]) abstraction)) - (def: .public positive_infinity Computation (..float f.positive_infinity)) - (def: .public negative_infinity Computation (..float f.negative_infinity)) - (def: .public not_a_number Computation (..float f.not_a_number)) + (def .public positive_infinity Computation (..float f.positive_infinity)) + (def .public negative_infinity Computation (..float f.negative_infinity)) + (def .public not_a_number Computation (..float f.not_a_number)) - (def: safe + (def safe (-> Text Text) (`` (|>> (~~ (with_template [<find> <replace>] [(text.replaced <find> <replace>)] @@ -151,15 +151,15 @@ )) ))) - (def: .public string + (def .public string (-> Text Computation) (|>> ..safe %.text abstraction)) - (def: .public symbol + (def .public symbol (-> Text Computation) (|>> (format "'") abstraction)) - (def: form + (def form (-> (List (Code Any)) Code) (.let [nested_new_line (format \n+ text.tab)] (|>> (pipe.case @@ -174,12 +174,12 @@ (text.enclosed ["(" ")"]) abstraction))))) - (def: .public (apply args func) + (def .public (apply args func) (-> (List Expression) Expression Computation) (..form {.#Item func args})) (with_template [<name> <function>] - [(def: .public (<name> members) + [(def .public (<name> members) (-> (List Expression) Computation) (..apply members (..var <function>)))] @@ -187,25 +187,25 @@ [list/* "list"] ) - (def: .public apply/0 + (def .public apply/0 (-> Expression Computation) (..apply (list))) (with_template [<lux_name> <scheme_name>] - [(def: .public <lux_name> + [(def .public <lux_name> (apply/0 (..var <scheme_name>)))] [newline/0 "newline"] ) (with_template [<apply> <arg>+ <type>+ <function>+] - [(`` (def: .public (<apply> procedure) + [(`` (def .public (<apply> procedure) (-> Expression (~~ (template.spliced <type>+)) Computation) (function (_ (~~ (template.spliced <arg>+))) (..apply (list (~~ (template.spliced <arg>+))) procedure)))) (`` (with_template [<definition> <function>] - [(def: .public <definition> (<apply> (..var <function>)))] + [(def .public <definition> (<apply> (..var <function>)))] (~~ (template.spliced <function>+))))] @@ -269,12 +269,12 @@ ... 1. To carry on, and then, when it's time to compile the compiler ... itself into Scheme, switch from 'invoke' to normal 'vector-ref'. ... Either way, the 'invoke' needs to go away. - (def: .public (vector_ref/2 vector index) + (def .public (vector_ref/2 vector index) (-> Expression Expression Computation) (..form (list (..var "invoke") vector (..symbol "getRaw") index))) (with_template [<lux_name> <scheme_name>] - [(def: .public (<lux_name> param subject) + [(def .public (<lux_name> param subject) (-> Expression Expression Computation) (..apply/2 (..var <scheme_name>) subject param))] @@ -302,7 +302,7 @@ ) (with_template [<lux_name> <scheme_name>] - [(def: .public <lux_name> + [(def .public <lux_name> (-> (List Expression) Computation) (|>> (list.partial (..var <scheme_name>)) ..form))] @@ -311,7 +311,7 @@ ) (with_template [<lux_name> <scheme_name> <var> <pre>] - [(def: .public (<lux_name> bindings body) + [(def .public (<lux_name> bindings body) (-> (List [<var> Expression]) Expression Computation) (..form (list (..var <scheme_name>) (|> bindings @@ -329,21 +329,21 @@ [letrec_values "letrec-values" Arguments ..arguments] ) - (def: .public (if test then else) + (def .public (if test then else) (-> Expression Expression Expression Computation) (..form (list (..var "if") test then else))) - (def: .public (when test then) + (def .public (when test then) (-> Expression Expression Computation) (..form (list (..var "when") test then))) - (def: .public (lambda arguments body) + (def .public (lambda arguments body) (-> Arguments Expression Computation) (..form (list (..var "lambda") (..arguments arguments) body))) - (def: .public (define_function name arguments body) + (def .public (define_function name arguments body) (-> Var Arguments Expression Computation) (..form (list (..var "define") (|> arguments @@ -351,27 +351,27 @@ ..arguments) body))) - (def: .public (define_constant name value) + (def .public (define_constant name value) (-> Var Expression Computation) (..form (list (..var "define") name value))) - (def: .public begin + (def .public begin (-> (List Expression) Computation) (|>> {.#Item (..var "begin")} ..form)) - (def: .public (set! name value) + (def .public (set! name value) (-> Var Expression Computation) (..form (list (..var "set!") name value))) - (def: .public (with_exception_handler handler body) + (def .public (with_exception_handler handler body) (-> Expression Expression Computation) (..form (list (..var "with-exception-handler") handler body))) - (def: .public (call_with_current_continuation body) + (def .public (call_with_current_continuation body) (-> Expression Computation) (..form (list (..var "call-with-current-continuation") body))) - (def: .public (guard variable clauses else body) + (def .public (guard variable clauses else body) (-> Var (List [Expression Expression]) (Maybe Expression) Expression Computation) (..form (list (..var "guard") (..form (|> (case else diff --git a/stdlib/source/library/lux/test.lux b/stdlib/source/library/lux/test.lux index d0a87c083..071798222 100644 --- a/stdlib/source/library/lux/test.lux +++ b/stdlib/source/library/lux/test.lux @@ -49,7 +49,7 @@ #expected_coverage (Set Symbol) #actual_coverage (Set Symbol)])) -(def: (total parameter subject) +(def (total parameter subject) (-> Tally Tally Tally) [#successes (n.+ (the #successes parameter) (the #successes subject)) #failures (n.+ (the #failures parameter) (the #failures subject)) @@ -58,7 +58,7 @@ #actual_coverage (set.union (the #actual_coverage parameter) (the #actual_coverage subject))]) -(def: start +(def start Tally [#successes 0 #failures 0 @@ -66,7 +66,7 @@ #actual_coverage (set.empty symbol.hash)]) (with_template [<name> <category>] - [(def: <name> + [(def <name> Tally (revised <category> .++ ..start))] @@ -80,10 +80,10 @@ (type: .public Test (Random Assertion)) -(def: separator +(def separator text.new_line) -(def: .public (and' left right) +(def .public (and' left right) (-> Assertion Assertion Assertion) (let [[read! write!] (is [(Async [Tally Text]) (async.Resolver [Tally Text])] @@ -97,13 +97,13 @@ io.run!)] read!)) -(def: .public (and left right) +(def .public (and left right) (-> Test Test Test) (do [! random.monad] [left left] (at ! each (..and' left) right))) -(def: (context' description) +(def (context' description) (-> Text Test Test) (random#each (async#each (function (_ [tally documentation]) [tally (|> documentation @@ -112,61 +112,61 @@ (text.interposed ..separator) (format description ..separator))])))) -(def: .public context +(def .public context (-> Text Test Test) (|>> %.text context')) -(def: failure_prefix "[Failure] ") -(def: success_prefix "[Success] ") +(def failure_prefix "[Failure] ") +(def success_prefix "[Success] ") -(def: .public failure +(def .public failure (-> Text Test) (|>> (format ..failure_prefix) [..failure_tally] async#in random#in)) -(def: .public (assertion message condition) +(def .public (assertion message condition) (-> Text Bit Assertion) (<| async#in (if condition [..success_tally (format ..success_prefix message)] [..failure_tally (format ..failure_prefix message)]))) -(def: .public (property message condition) +(def .public (property message condition) (-> Text Bit Test) (random#in (..assertion (%.text message) condition))) -(def: .public (lifted message random) +(def .public (lifted message random) (-> Text (Random Bit) Test) (random#each (..assertion (%.text message)) random)) -(def: pcg_32_magic_inc +(def pcg_32_magic_inc Nat (hex "FEDCBA9876543210")) (type: .public Seed Nat) -(def: .public (seed value test) +(def .public (seed value test) (-> Seed Test Test) (function (_ prng) (let [[_ result] (random.result (random.pcg_32 [..pcg_32_magic_inc value]) test)] [prng result]))) -(def: failed? +(def failed? (-> Tally Bit) (|>> (the #failures) (n.> 0))) -(def: (times_failure seed documentation) +(def (times_failure seed documentation) (-> Seed Text Text) (format documentation ..separator ..separator "Failed with this seed: " (%.nat seed))) (exception: .public must_try_test_at_least_once) -(def: .public (times amount test) +(def .public (times amount test) (-> Nat Test Test) (case amount 0 (..failure (exception.error ..must_try_test_at_least_once [])) @@ -185,7 +185,7 @@ (random.result prng') product.right))))]))))) -(def: (description duration tally) +(def (description duration tally) (-> Duration Tally Text) (let [successes (the #successes tally) failures (the #failures tally) @@ -235,10 +235,10 @@ "Pending definitions to cover" (report missing) "Unexpected definitions covered" (report unexpected)))) -(def: failure_exit_code +1) -(def: success_exit_code +0) +(def failure_exit_code +1) +(def success_exit_code +0) -(def: .public (run! test) +(def .public (run! test) (-> Test (Async Nothing)) (do async.monad [pre (async.future instant.now) @@ -264,15 +264,15 @@ 0 ..success_exit_code _ ..failure_exit_code))))) -(def: definition_separator " & ") +(def definition_separator " & ") -(def: clean_up_marker (text.of_char (hex "05"))) +(def clean_up_marker (text.of_char (hex "05"))) -(def: coverage_format +(def coverage_format (%.Format Symbol) (|>> %.symbol (format ..clean_up_marker))) -(def: (|coverage'| coverage condition) +(def (|coverage'| coverage condition) (-> (List Symbol) Bit Assertion) (let [message (|> coverage (list#each ..coverage_format) @@ -283,12 +283,12 @@ [(revised #actual_coverage (set.union coverage) tally) documentation]))))) -(def: (|coverage| coverage condition) +(def (|coverage| coverage condition) (-> (List Symbol) Bit Test) (|> (..|coverage'| coverage condition) random#in)) -(def: (|for| coverage test) +(def (|for| coverage test) (-> (List Symbol) Test Test) (let [context (|> coverage (list#each ..coverage_format) @@ -299,22 +299,22 @@ documentation])) (..context' context test)))) -(def: (symbol_code symbol) +(def (symbol_code symbol) (-> Symbol Code) (code.tuple (list (code.text (symbol.module symbol)) (code.text (symbol.short symbol))))) -(def: reference +(def reference (syntax (_ [name <code>.symbol]) (do meta.monad [_ (meta.export name)] (in (list (symbol_code name)))))) -(def: coverage_separator +(def coverage_separator Text (text.of_char 31)) -(def: encoded_coverage +(def encoded_coverage (-> (List Text) Text) (list#mix (function (_ short aggregate) (case aggregate @@ -322,7 +322,7 @@ _ (format aggregate ..coverage_separator short))) "")) -(def: (coverage_definitions module encoding) +(def (coverage_definitions module encoding) (-> Text Text (Set Symbol)) (loop (again [remaining encoding output (set.of_list symbol.hash (list))]) @@ -334,7 +334,7 @@ (set.has [module remaining] output)))) (with_template [<macro> <function>] - [(def: .public <macro> + [(def .public <macro> (syntax (_ [coverage (<code>.tuple (<>.many <code>.any)) condition <code>.any]) (let [coverage (list#each (function (_ definition) @@ -349,7 +349,7 @@ [coverage ..|coverage|] ) -(def: .public for +(def .public for (syntax (_ [coverage (<code>.tuple (<>.many <code>.any)) test <code>.any]) (let [coverage (list#each (function (_ definition) @@ -360,7 +360,7 @@ (.list (~+ coverage))) (~ test)))))))) -(def: (covering' module coverage test) +(def (covering' module coverage test) (-> Text Text Test Test) (let [coverage (..coverage_definitions module coverage)] (|> (..context' module test) @@ -370,7 +370,7 @@ (text.replaced (format ..clean_up_marker module symbol.separator) "") (text.replaced ..clean_up_marker ""))])))))) -(def: .public covering +(def .public covering (syntax (_ [module <code>.symbol test <code>.any]) (do meta.monad @@ -392,7 +392,7 @@ (exception.report "Error" (%.text error))) -(def: .public (in_parallel tests) +(def .public (in_parallel tests) (-> (List Test) Test) (case (list.size tests) 0 diff --git a/stdlib/source/library/lux/time.lux b/stdlib/source/library/lux/time.lux index b977ceba1..f7a4ddee9 100644 --- a/stdlib/source/library/lux/time.lux +++ b/stdlib/source/library/lux/time.lux @@ -24,7 +24,7 @@ ["[0]" duration (.only Duration)]]) (with_template [<name> <singular> <plural>] - [(def: .public <name> + [(def .public <name> Nat (.nat (duration.ticks <singular> <plural>)))] @@ -34,7 +34,7 @@ [hours duration.hour duration.day] ) -(def: limit +(def limit Nat (.nat (duration.millis duration.day))) @@ -43,13 +43,13 @@ "Time (in milli-seconds)" (n#encoded time) "Maximum (in milli-seconds)" (n#encoded (-- limit)))) -(def: separator ":") +(def separator ":") -(def: section_parser +(def section_parser (Parser Nat) (<>.codec n.decimal (<text>.exactly 2 <text>.decimal))) -(def: millis_parser +(def millis_parser (Parser Nat) (<>.either (|> (<text>.at_most 3 <text>.decimal) (<>.codec n.decimal) @@ -63,7 +63,7 @@ "Minimum" (n#encoded 0) "Maximum" (n#encoded (-- <maximum>)))) - (def: <parser> + (def <parser> (Parser Nat) (do <>.monad [value <sub_parser>] @@ -79,43 +79,43 @@ (primitive .public Time Nat - (def: .public midnight + (def .public midnight Time (abstraction 0)) - (def: .public (of_millis milli_seconds) + (def .public (of_millis milli_seconds) (-> Nat (Try Time)) (if (n.< ..limit milli_seconds) {try.#Success (abstraction milli_seconds)} (exception.except ..time_exceeds_a_day [milli_seconds]))) - (def: .public millis + (def .public millis (-> Time Nat) (|>> representation)) - (def: .public equivalence + (def .public equivalence (Equivalence Time) (implementation - (def: (= param subject) + (def (= param subject) (n.= (representation param) (representation subject))))) - (def: .public order + (def .public order (Order Time) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (< param subject) + (def (< param subject) (n.< (representation param) (representation subject))))) - (`` (def: .public enum + (`` (def .public enum (Enum Time) (implementation - (def: order ..order) + (def order ..order) - (def: succ + (def succ (|>> representation ++ (n.% ..limit) abstraction)) - (def: pred + (def pred (|>> representation (pipe.case 0 ..limit @@ -123,7 +123,7 @@ -- abstraction))))) - (def: .public parser + (def .public parser (Parser Time) (let [millis (is (-> Duration Nat) (|>> duration.millis .nat)) @@ -146,19 +146,19 @@ (n.* utc_millis millis))))))) ) -(def: (padded value) +(def (padded value) (-> Nat Text) (if (n.< 10 value) (text#composite "0" (n#encoded value)) (n#encoded value))) -(def: (positive space duration) +(def (positive space duration) (-> Duration Duration Duration) (if (duration.negative? duration) (duration.composite space duration) duration)) -(def: (millis_format millis) +(def (millis_format millis) (-> Nat Text) (cond (n.= 0 millis) "" (n.< 10 millis) (all text#composite ".00" (n#encoded millis)) @@ -173,7 +173,7 @@ #second Nat #milli_second Nat])) -(def: .public (clock time) +(def .public (clock time) (-> Time Clock) (let [time (|> time ..millis .int duration.of_millis) [hours time] [(duration.ticks duration.hour time) (duration.framed duration.hour time)] @@ -187,7 +187,7 @@ duration.millis .nat)])) -(def: .public (time clock) +(def .public (time clock) (-> Clock (Try Time)) (|> (all duration.composite (duration.up (the #hour clock) duration.hour) @@ -198,7 +198,7 @@ .nat ..of_millis)) -(def: (format time) +(def (format time) (-> Time Text) (let [(open "_[0]") (..clock time)] (all text#composite @@ -207,8 +207,8 @@ ..separator (..padded _#second) (..millis_format _#milli_second)))) -(def: .public codec +(def .public codec (Codec Text Time) (implementation - (def: encoded ..format) - (def: decoded (<text>.result ..parser)))) + (def encoded ..format) + (def decoded (<text>.result ..parser)))) diff --git a/stdlib/source/library/lux/time/date.lux b/stdlib/source/library/lux/time/date.lux index f01124fac..5a28fc3a0 100644 --- a/stdlib/source/library/lux/time/date.lux +++ b/stdlib/source/library/lux/time/date.lux @@ -28,23 +28,23 @@ ["[1][0]" year (.only Year)] ["[1][0]" month (.only Month)]]) -(def: month_by_number +(def month_by_number (Dictionary Nat Month) (list#mix (function (_ month mapping) (dictionary.has (//month.number month) month mapping)) (dictionary.empty n.hash) //month.year)) -(def: minimum_day +(def minimum_day 1) -(def: (month_days year month) +(def (month_days year month) (-> Year Month Nat) (if (//year.leap? year) (//month.leap_year_days month) (//month.days month))) -(def: (invalid_day? year month day) +(def (invalid_day? year month day) (-> Year Month Nat Bit) (or (n.< ..minimum_day day) (n.> (..month_days year month) day))) @@ -59,14 +59,14 @@ "Year" (at //year.codec encoded year) "Month" (n#encoded (//month.number month)))) -(def: (padded value) +(def (padded value) (-> Nat Text) (let [digits (n#encoded value)] (if (n.< 10 value) (text#composite "0" digits) digits))) -(def: separator +(def separator "-") (primitive .public Date @@ -75,7 +75,7 @@ #month Month #day Nat]) - (def: .public (date year month day_of_month) + (def .public (date year month day_of_month) (-> Year Month Nat (Try Date)) (if (..invalid_day? year month day_of_month) (exception.except ..invalid_day [year month day_of_month]) @@ -85,7 +85,7 @@ #month month #day day_of_month])})) - (def: .public epoch + (def .public epoch Date (try.trusted (..date //year.epoch @@ -93,7 +93,7 @@ ..minimum_day))) (with_template [<name> <type> <field>] - [(def: .public <name> + [(def .public <name> (-> Date <type>) (|>> representation (the <field>)))] @@ -102,10 +102,10 @@ [day_of_month Nat #day] ) - (def: .public equivalence + (def .public equivalence (Equivalence Date) (implementation - (def: (= reference sample) + (def (= reference sample) (let [reference (representation reference) sample (representation sample)] (and (at //year.equivalence = @@ -117,12 +117,12 @@ (n.= (the #day reference) (the #day sample))))))) - (def: .public order + (def .public order (Order Date) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (< reference sample) + (def (< reference sample) (let [reference (representation reference) sample (representation sample)] (or (at //year.order < @@ -141,11 +141,11 @@ (the #day sample)))))))))) ) -(def: section_parser +(def section_parser (Parser Nat) (<>.codec n.decimal (<text>.exactly 2 <text>.decimal))) -(def: millis_parser +(def millis_parser (Parser Nat) (<>.either (|> (<text>.at_most 3 <text>.decimal) (<>.codec n.decimal) @@ -159,7 +159,7 @@ "Minimum" (n#encoded <minimum>) "Maximum" (n#encoded <maximum>))) - (def: <parser> + (def <parser> (Parser Nat) (do <>.monad [value ..section_parser] @@ -171,7 +171,7 @@ [1 12 month_parser invalid_month] ) -(def: .public parser +(def .public parser (Parser Date) (do <>.monad [utc_year //year.parser @@ -182,25 +182,25 @@ utc_day ..section_parser] (<>.lifted (..date utc_year month utc_day)))) -(def: (format value) +(def (format value) (-> Date Text) (all text#composite (at //year.codec encoded (..year value)) ..separator (..padded (|> value ..month //month.number)) ..separator (..padded (..day_of_month value)))) -(def: .public codec +(def .public codec (Codec Text Date) (implementation - (def: encoded ..format) - (def: decoded (<text>.result ..parser)))) + (def encoded ..format) + (def decoded (<text>.result ..parser)))) -(def: days_per_leap +(def days_per_leap (|> //year.days (n.* 4) (n.+ 1))) -(def: days_per_century +(def days_per_century (let [leaps_per_century (n./ //year.leap //year.century)] (|> //year.century @@ -208,14 +208,14 @@ (n.+ leaps_per_century) (n.- 1)))) -(def: days_per_era +(def days_per_era (let [centuries_per_era (n./ //year.century //year.era)] (|> centuries_per_era (n.* ..days_per_century) (n.+ 1)))) -(def: days_since_epoch +(def days_since_epoch (let [years::70 70 leaps::70 (n./ //year.leap years::70) @@ -235,17 +235,17 @@ ... 1970/03/01 (n.- january_&_february)))) -(def: first_month_of_civil_year 3) +(def first_month_of_civil_year 3) (with_expansions [<pull> +3 <push> +9] - (def: (internal_month civil_month) + (def (internal_month civil_month) (-> Nat Int) (if (n.< ..first_month_of_civil_year civil_month) (i.+ <push> (.int civil_month)) (i.- <pull> (.int civil_month)))) - (def: (civil_month internal_month) + (def (civil_month internal_month) (-> Int Nat) (.nat (if (i.< +10 internal_month) (i.+ <pull> internal_month) @@ -254,27 +254,27 @@ (with_expansions [<up> +153 <translation> +2 <down> +5] - (def: day_of_year_from_month + (def day_of_year_from_month (-> Nat Int) (|>> ..internal_month (i.* <up>) (i.+ <translation>) (i./ <down>))) - (def: month_from_day_of_year + (def month_from_day_of_year (-> Int Nat) (|>> (i.* <down>) (i.+ <translation>) (i./ <up>) ..civil_month))) -(def: last_era_leap_day +(def last_era_leap_day (.int (-- ..days_per_leap))) -(def: last_era_day +(def last_era_day (.int (-- ..days_per_era))) -(def: (civil_year utc_month utc_year) +(def (civil_year utc_month utc_year) (-> Nat Year Int) (let [... Coercing, because the year is already in external form. utc_year (as Int utc_year)] @@ -283,7 +283,7 @@ utc_year))) ... http://howardhinnant.github.io/date_algorithms.html -(def: .public (days date) +(def .public (days date) (-> Date Int) (let [utc_month (|> date ..month //month.number) civil_year (..civil_year utc_month (..year date)) @@ -307,7 +307,7 @@ (i.- (.int ..days_since_epoch))))) ... http://howardhinnant.github.io/date_algorithms.html -(def: .public (of_days days) +(def .public (of_days days) (-> Int Date) (let [days (i.+ (.int ..days_since_epoch) days) era (|> (if (i.< +0 days) @@ -340,13 +340,13 @@ (maybe.trusted (dictionary.value month ..month_by_number)) day)))) -(def: .public enum +(def .public enum (Enum Date) (implementation - (def: order ..order) + (def order ..order) - (def: succ + (def succ (|>> ..days ++ ..of_days)) - (def: pred + (def pred (|>> ..days -- ..of_days)))) diff --git a/stdlib/source/library/lux/time/day.lux b/stdlib/source/library/lux/time/day.lux index 20b526090..e95975e6e 100644 --- a/stdlib/source/library/lux/time/day.lux +++ b/stdlib/source/library/lux/time/day.lux @@ -29,10 +29,10 @@ {#Friday} {#Saturday})) -(def: .public equivalence +(def .public equivalence (Equivalence Day) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] (^.with_template [<tag>] [[{<tag>} {<tag>}] @@ -48,7 +48,7 @@ _ #0)))) -(def: (nat day) +(def (nat day) (-> Day Nat) (case day {#Sunday} 0 @@ -59,20 +59,20 @@ {#Friday} 5 {#Saturday} 6)) -(def: .public order +(def .public order (Order Day) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (< reference sample) + (def (< reference sample) (n.< (..nat reference) (..nat sample))))) -(def: .public enum +(def .public enum (Enum Day) (implementation - (def: order ..order) + (def order ..order) - (def: (succ day) + (def (succ day) (case day {#Sunday} {#Monday} {#Monday} {#Tuesday} @@ -82,7 +82,7 @@ {#Friday} {#Saturday} {#Saturday} {#Sunday})) - (def: (pred day) + (def (pred day) (case day {#Monday} {#Sunday} {#Tuesday} {#Monday} @@ -96,10 +96,10 @@ (exception.report "Value" (text.format value))) -(def: .public codec +(def .public codec (Codec Text Day) (implementation - (def: (encoded value) + (def (encoded value) (case value (^.with_template [<tag>] [{<tag>} @@ -111,7 +111,7 @@ [..#Friday] [..#Saturday] [..#Sunday]))) - (def: (decoded value) + (def (decoded value) (case (text#composite "#" value) (^.with_template [<tag>] [(pattern (template.text [<tag>])) @@ -125,7 +125,7 @@ [..#Sunday]) _ (exception.except ..not_a_day_of_the_week [value]))))) -(def: .public week +(def .public week (List Day) (list {#Sunday} {#Monday} @@ -142,7 +142,7 @@ [05 #Thursday] [06 #Friday] [07 #Saturday])] - (def: .public (number day) + (def .public (number day) (-> Day Nat) (case day (^.with_template [<number> <day>] @@ -158,7 +158,7 @@ " ~ " (at n.decimal encoded (..number {#Saturday}))))) - (def: .public (by_number number) + (def .public (by_number number) (-> Nat (Try Day)) (case number (^.with_template [<number> <day>] @@ -170,11 +170,11 @@ (exception.except ..invalid_day [number]))) ) -(def: .public hash +(def .public hash (Hash Day) (implementation - (def: equivalence ..equivalence) - (def: (hash day) + (def equivalence ..equivalence) + (def (hash day) (case day (^.with_template [<prime> <day>] [{<day>} diff --git a/stdlib/source/library/lux/time/duration.lux b/stdlib/source/library/lux/time/duration.lux index 1b37584bf..020ba0275 100644 --- a/stdlib/source/library/lux/time/duration.lux +++ b/stdlib/source/library/lux/time/duration.lux @@ -26,16 +26,16 @@ (primitive .public Duration Int - (def: .public of_millis + (def .public of_millis (-> Int Duration) (|>> abstraction)) - (def: .public millis + (def .public millis (-> Duration Int) (|>> representation)) (with_template [<op> <name>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Duration Duration Duration) (abstraction (<op> (representation param) (representation subject))))] @@ -44,7 +44,7 @@ ) (with_template [<op> <name>] - [(def: .public (<name> scalar) + [(def .public (<name> scalar) (-> Nat Duration Duration) (|>> representation (<op> (.int scalar)) abstraction))] @@ -52,29 +52,29 @@ [i./ down] ) - (def: .public inverse + (def .public inverse (-> Duration Duration) (|>> representation (i.* -1) abstraction)) - (def: .public (ticks param subject) + (def .public (ticks param subject) (-> Duration Duration Int) (i./ (representation param) (representation subject))) - (def: .public equivalence + (def .public equivalence (Equivalence Duration) (implementation - (def: (= param subject) + (def (= param subject) (i.= (representation param) (representation subject))))) - (def: .public order + (def .public order (Order Duration) (implementation - (def: equivalence ..equivalence) - (def: (< param subject) + (def equivalence ..equivalence) + (def (< param subject) (i.< (representation param) (representation subject))))) (with_template [<op> <name>] - [(def: .public <name> + [(def .public <name> (-> Duration Bit) (|>> representation (<op> +0)))] @@ -84,14 +84,14 @@ ) ) -(def: .public empty +(def .public empty (..of_millis +0)) -(def: .public milli_second +(def .public milli_second (..of_millis +1)) (with_template [<name> <scale> <base>] - [(def: .public <name> + [(def .public <name> (..up <scale> <base>))] [second 1,000 milli_second] @@ -103,17 +103,17 @@ [normal_year //year.days day] ) -(def: .public leap_year +(def .public leap_year (..composite ..day ..normal_year)) -(def: .public monoid +(def .public monoid (Monoid Duration) (implementation - (def: identity ..empty) - (def: composite ..composite))) + (def identity ..empty) + (def composite ..composite))) (with_template [<value> <definition>] - [(def: <definition> <value>)] + [(def <definition> <value>)] ["D" day_suffix] ["h" hour_suffix] @@ -125,7 +125,7 @@ ["-" negative_sign] ) -(def: (encoded duration) +(def (encoded duration) (if (at ..equivalence = ..empty duration) (all text#composite ..positive_sign @@ -152,7 +152,7 @@ (if (i.= +0 millis) "" (text#composite (nat#encoded (.nat millis)) ..milli_second_suffix)) )))) -(def: parser +(def parser (Parser Duration) (let [section (is (-> Text Text (Parser Nat)) (function (_ suffix false_suffix) @@ -181,21 +181,21 @@ {.#Left _} (..inverse span) {.#Right _} span))))) -(def: .public codec +(def .public codec (Codec Text Duration) (implementation - (def: encoded ..encoded) - (def: decoded (<text>.result ..parser)))) + (def encoded ..encoded) + (def decoded (<text>.result ..parser)))) -(def: .public (difference from to) +(def .public (difference from to) (-> Duration Duration Duration) (|> from ..inverse (..composite to))) -(def: .public enum +(def .public enum (Enum Duration) (implementation - (def: order ..order) - (def: succ + (def order ..order) + (def succ (..composite ..milli_second)) - (def: pred + (def pred (..composite (..inverse ..milli_second))))) diff --git a/stdlib/source/library/lux/time/instant.lux b/stdlib/source/library/lux/time/instant.lux index daa4b8c2e..5f11765f0 100644 --- a/stdlib/source/library/lux/time/instant.lux +++ b/stdlib/source/library/lux/time/instant.lux @@ -33,63 +33,63 @@ (primitive .public Instant Int - (def: .public of_millis + (def .public of_millis (-> Int Instant) (|>> abstraction)) - (def: .public millis + (def .public millis (-> Instant Int) (|>> representation)) - (def: .public (span from to) + (def .public (span from to) (-> Instant Instant Duration) (duration.of_millis (i.- (representation from) (representation to)))) - (def: .public (after duration instant) + (def .public (after duration instant) (-> Duration Instant Instant) (abstraction (i.+ (duration.millis duration) (representation instant)))) - (def: .public (relative instant) + (def .public (relative instant) (-> Instant Duration) (|> instant representation duration.of_millis)) - (def: .public (absolute offset) + (def .public (absolute offset) (-> Duration Instant) (|> offset duration.millis abstraction)) - (def: .public equivalence + (def .public equivalence (Equivalence Instant) (implementation - (def: (= param subject) + (def (= param subject) (at i.equivalence = (representation param) (representation subject))))) - (def: .public order + (def .public order (Order Instant) (implementation - (def: equivalence ..equivalence) - (def: (< param subject) + (def equivalence ..equivalence) + (def (< param subject) (at i.order < (representation param) (representation subject))))) - (`` (def: .public enum + (`` (def .public enum (Enum Instant) (implementation - (def: order ..order) + (def order ..order) (~~ (with_template [<name>] - [(def: <name> + [(def <name> (|>> representation (at i.enum <name>) abstraction))] [succ] [pred] ))))) ) -(def: .public epoch +(def .public epoch Instant (..of_millis +0)) -(def: millis_per_day +(def millis_per_day (duration.ticks duration.milli_second duration.day)) -(def: (date_time instant) +(def (date_time instant) (-> Instant [Date Duration]) (let [offset (..millis instant) bce? (i.< +0 offset) @@ -103,13 +103,13 @@ (duration.of_millis day_time)])) (with_template [<value> <definition>] - [(def: <definition> Text <value>)] + [(def <definition> Text <value>)] ["T" date_suffix] ["Z" time_suffix] ) -(def: (clock_time duration) +(def (clock_time duration) (-> Duration Time) (|> (if (at duration.order < duration.empty duration) (duration.composite duration.day duration) @@ -119,7 +119,7 @@ //.of_millis try.trusted)) -(def: (format instant) +(def (format instant) (-> Instant Text) (let [[date time] (..date_time instant) time (..clock_time time)] @@ -127,7 +127,7 @@ (at date.codec encoded date) ..date_suffix (at //.codec encoded time) ..time_suffix))) -(def: parser +(def parser (Parser Instant) (do [! <>.monad] [days (at ! each date.days date.parser) @@ -142,13 +142,13 @@ (duration.composite (duration.up time duration.milli_second)) ..absolute)))) -(def: .public codec +(def .public codec (Codec Text Instant) (implementation - (def: encoded ..format) - (def: decoded (<text>.result ..parser)))) + (def encoded ..format) + (def decoded (<text>.result ..parser)))) -(def: .public now +(def .public now (IO Instant) (io (..of_millis (for @.old ("jvm invokestatic:java.lang.System:currentTimeMillis:") @.jvm (|> ("jvm member invoke static" [] "java.lang.System" "currentTimeMillis" []) @@ -189,7 +189,7 @@ )))) (with_template [<field> <type> <post_processing>] - [(def: .public (<field> instant) + [(def .public (<field> instant) (-> Instant <type>) (let [[date time] (..date_time instant)] (|> <field> <post_processing>)))] @@ -198,7 +198,7 @@ [time Time ..clock_time] ) -(def: .public (day_of_week instant) +(def .public (day_of_week instant) (-> Instant Day) (let [offset (..relative instant) days (duration.ticks duration.day offset) @@ -222,7 +222,7 @@ +6 {day.#Saturday} _ (undefined)))) -(def: .public (of_date_time date time) +(def .public (of_date_time date time) (-> Date Time Instant) (|> (date.days date) (i.* (duration.millis duration.day)) diff --git a/stdlib/source/library/lux/time/month.lux b/stdlib/source/library/lux/time/month.lux index 8dd48ba4d..148da6b30 100644 --- a/stdlib/source/library/lux/time/month.lux +++ b/stdlib/source/library/lux/time/month.lux @@ -34,10 +34,10 @@ {#November} {#December})) -(def: .public equivalence +(def .public equivalence (Equivalence Month) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] (^.with_template [<tag>] [[{<tag>} {<tag>}] @@ -70,7 +70,7 @@ [10 #October] [11 #November] [12 #December])] - (def: .public (number month) + (def .public (number month) (-> Month Nat) (case month (^.with_template [<number> <month>] @@ -86,7 +86,7 @@ " ~ " (at n.decimal encoded (..number {#December}))))) - (def: .public (by_number number) + (def .public (by_number number) (-> Nat (Try Month)) (case number (^.with_template [<number> <month>] @@ -98,11 +98,11 @@ (exception.except ..invalid_month [number]))) ) -(def: .public hash +(def .public hash (Hash Month) (implementation - (def: equivalence ..equivalence) - (def: (hash month) + (def equivalence ..equivalence) + (def (hash month) (case month (^.with_template [<prime> <month>] [{<month>} @@ -120,21 +120,21 @@ [31 #November] [37 #December]))))) -(def: .public order +(def .public order (Order Month) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (< reference sample) + (def (< reference sample) (n.< (..number reference) (..number sample))))) -(def: .public enum +(def .public enum (Enum Month) (implementation - (def: order ..order) + (def order ..order) - (def: (succ month) + (def (succ month) (case month {#January} {#February} {#February} {#March} @@ -149,7 +149,7 @@ {#November} {#December} {#December} {#January})) - (def: (pred month) + (def (pred month) (case month {#February} {#January} {#March} {#February} @@ -164,7 +164,7 @@ {#December} {#November} {#January} {#December})))) -(def: .public (days month) +(def .public (days month) (-> Month Nat) (case month (^.with_template [<days> <month>] @@ -186,13 +186,13 @@ [30 #November] [31 #December]))) -(def: .public (leap_year_days month) +(def .public (leap_year_days month) (-> Month Nat) (case month {#February} (++ (..days month)) _ (..days month))) -(def: .public year +(def .public year (List Month) (list {#January} {#February} @@ -211,10 +211,10 @@ (exception.report "Value" (text.format value))) -(def: .public codec +(def .public codec (Codec Text Month) (implementation - (def: (encoded value) + (def (encoded value) (case value (^.with_template [<tag>] [{<tag>} @@ -231,7 +231,7 @@ [..#October] [..#November] [..#December]))) - (def: (decoded value) + (def (decoded value) (case (text#composite "#" value) (^.with_template [<tag>] [(pattern (template.text [<tag>])) diff --git a/stdlib/source/library/lux/time/year.lux b/stdlib/source/library/lux/time/year.lux index 244c8417f..70e93aa19 100644 --- a/stdlib/source/library/lux/time/year.lux +++ b/stdlib/source/library/lux/time/year.lux @@ -20,13 +20,13 @@ [type [primitive (.except)]]]]) -(def: (internal year) +(def (internal year) (-> Int Int) (if (i.< +0 year) (++ year) year)) -(def: (external year) +(def (external year) (-> Int Int) (if (i.> +0 year) year @@ -38,22 +38,22 @@ (primitive .public Year Int - (def: .public (year value) + (def .public (year value) (-> Int (Try Year)) (case value +0 (exception.except ..there_is_no_year_0 []) _ {try.#Success (abstraction (..internal value))})) - (def: .public value + (def .public value (-> Year Int) (|>> representation ..external)) - (def: .public epoch + (def .public epoch Year (abstraction +1970)) ) -(def: .public days +(def .public days Nat 365) @@ -61,7 +61,7 @@ Nat) (with_template [<period> <name>] - [(def: .public <name> + [(def .public <name> Period <period>)] @@ -70,25 +70,25 @@ [400 era] ) -(def: (divisible? factor input) +(def (divisible? factor input) (-> Int Int Bit) (|> input (i.% factor) (i.= +0))) ... https://en.wikipedia.org/wiki/Leap_year#Algorithm -(def: .public (leap? year) +(def .public (leap? year) (-> Year Bit) (let [year (|> year ..value ..internal)] (and (..divisible? (.int ..leap) year) (or (not (..divisible? (.int ..century) year)) (..divisible? (.int ..era) year))))) -(def: (with_year_0_leap year days) +(def (with_year_0_leap year days) (let [after_year_0? (i.> +0 year)] (if after_year_0? (i.+ +1 days) days))) -(def: .public (leaps year) +(def .public (leaps year) (-> Year Int) (let [year (|> year ..value ..internal) limit (if (i.> +0 year) @@ -104,14 +104,14 @@ )) (..with_year_0_leap year))))) -(def: (encoded year) +(def (encoded year) (-> Year Text) (let [year (..value year)] (if (i.< +0 year) (i#encoded year) (n#encoded (.nat year))))) -(def: .public parser +(def .public parser (Parser Year) (do [! <>.monad] [sign (<>.or (<text>.this "-") (in [])) @@ -121,22 +121,22 @@ {.#Left _} (i.* -1 raw_year) {.#Right _} raw_year))))) -(def: .public codec +(def .public codec (Codec Text Year) (implementation - (def: encoded ..encoded) - (def: decoded (<text>.result ..parser)))) + (def encoded ..encoded) + (def decoded (<text>.result ..parser)))) -(def: .public equivalence +(def .public equivalence (Equivalence Year) (implementation - (def: (= reference subject) + (def (= reference subject) (i.= (..value reference) (..value subject))))) -(def: .public order +(def .public order (Order Year) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (< reference subject) + (def (< reference subject) (i.< (..value reference) (..value subject))))) diff --git a/stdlib/source/library/lux/tool/compiler/arity.lux b/stdlib/source/library/lux/tool/compiler/arity.lux index c1e2796c3..14e73f0c1 100644 --- a/stdlib/source/library/lux/tool/compiler/arity.lux +++ b/stdlib/source/library/lux/tool/compiler/arity.lux @@ -9,7 +9,7 @@ Nat) (with_template [<comparison> <name>] - [(def: .public <name> (-> Arity Bit) (<comparison> 1))] + [(def .public <name> (-> Arity Bit) (<comparison> 1))] [n.< nullary?] [n.= unary?] diff --git a/stdlib/source/library/lux/tool/compiler/default/init.lux b/stdlib/source/library/lux/tool/compiler/default/init.lux index 2f4f943f9..8ad59fc2e 100644 --- a/stdlib/source/library/lux/tool/compiler/default/init.lux +++ b/stdlib/source/library/lux/tool/compiler/default/init.lux @@ -53,7 +53,7 @@ ["[0]" descriptor] ["[0]" document]]]]]]) -(def: .public (state target module configuration expander host_analysis host generate generation_bundle) +(def .public (state target module configuration expander host_analysis host generate generation_bundle) (All (_ anchor expression directive) (-> Target descriptor.Module @@ -77,7 +77,7 @@ ///directive.#generation [///directive.#state generation_state ///directive.#phase generate]]])) -(def: .public (with_default_directives expander host_analysis program anchorT,expressionT,directiveT extender) +(def .public (with_default_directives expander host_analysis program anchorT,expressionT,directiveT extender) (All (_ anchor expression directive) (-> Expander ///analysis.Bundle @@ -94,13 +94,13 @@ (type: Reader (-> Source (Either [Source Text] [Source Code]))) -(def: (reader current_module aliases [location offset source_code]) +(def (reader current_module aliases [location offset source_code]) (-> descriptor.Module Aliases Source (///analysis.Operation Reader)) (function (_ [bundle state]) {try.#Success [[bundle state] (///syntax.parse current_module aliases ("lux text size" source_code))]})) -(def: (read source reader) +(def (read source reader) (-> Source Reader (///analysis.Operation [Source Code])) (function (_ [bundle compiler]) (case (reader source) @@ -122,7 +122,7 @@ [(///generation.Buffer directive) Registry]) -(def: (begin dependencies hash input) +(def (begin dependencies hash input) (-> (List descriptor.Module) Nat ///.Input (All (_ anchor expression directive) (///directive.Operation anchor expression directive @@ -139,7 +139,7 @@ (in [source [///generation.empty_buffer registry.empty]]))))) -(def: (end module) +(def (end module) (-> descriptor.Module (All (_ anchor expression directive) (///directive.Operation anchor expression directive [.Module (Payload directive)]))) @@ -158,7 +158,7 @@ final_registry]]))) ... TODO: Inline ASAP -(def: (get_current_payload _) +(def (get_current_payload _) (All (_ directive) (-> (Payload directive) (All (_ anchor expression) @@ -172,7 +172,7 @@ (in [buffer registry]))) ... TODO: Inline ASAP -(def: (process_directive wrapper archive expander pre_payoad code) +(def (process_directive wrapper archive expander pre_payoad code) (All (_ directive) (-> ///phase.Wrapper Archive Expander (Payload directive) Code (All (_ anchor expression) @@ -189,7 +189,7 @@ post_payload (..get_current_payload pre_payoad)] (in [requirements post_payload]))) -(def: (iteration' wrapper archive expander reader source pre_payload) +(def (iteration' wrapper archive expander reader source pre_payload) (All (_ directive) (-> ///phase.Wrapper Archive Expander Reader Source (Payload directive) (All (_ anchor expression) @@ -201,7 +201,7 @@ [requirements post_payload] (process_directive wrapper archive expander pre_payload code)] (in [source requirements post_payload]))) -(def: (iteration wrapper archive expander module source pre_payload aliases) +(def (iteration wrapper archive expander module source pre_payload aliases) (All (_ directive) (-> ///phase.Wrapper Archive Expander descriptor.Module Source (Payload directive) Aliases (All (_ anchor expression) @@ -220,18 +220,18 @@ {try.#Success [state {.#None}]} (exception.with ///.cannot_compile module {try.#Failure error})))))) -(def: (default_dependencies prelude input) +(def (default_dependencies prelude input) (-> descriptor.Module ///.Input (List descriptor.Module)) (list.partial descriptor.runtime (if (text#= prelude (the ///.#module input)) (list) (list prelude)))) -(def: module_aliases +(def module_aliases (-> .Module Aliases) (|>> (the .#module_aliases) (dictionary.of_list text.hash))) -(def: .public (compiler wrapper expander prelude write_directive) +(def .public (compiler wrapper expander prelude write_directive) (All (_ anchor expression directive) (-> ///phase.Wrapper Expander descriptor.Module (-> directive Binary) (Instancer (///directive.State+ anchor expression directive) .Module))) diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux index e999ae79d..07a7b4c0f 100644 --- a/stdlib/source/library/lux/tool/compiler/default/platform.lux +++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux @@ -87,7 +87,7 @@ (Async (Try a))) ... TODO: Get rid of this - (def: monad + (def monad (as (Monad Action) (try.with async.monad))) @@ -95,7 +95,7 @@ <State+> (these (///directive.State+ <type_vars>)) <Bundle> (these (///generation.Bundle <type_vars>))] - (def: (writer //) + (def (writer //) (All (_ a) (-> (Writer a) (Writer [(module.Module a) Registry]))) @@ -107,7 +107,7 @@ registry.writer )) - (def: (cache_module context platform @module key format entry) + (def (cache_module context platform @module key format entry) (All (_ <type_vars> document) (-> context.Context <Platform> module.ID (Key document) (Writer document) (archive.Entry document) (Async (Try Any)))) @@ -141,20 +141,20 @@ (cache/module.cache! system context @module)))))) ... TODO: Inline ASAP - (def: initialize_buffer! + (def initialize_buffer! (All (_ <type_vars>) (///generation.Operation <type_vars> Any)) (///generation.set_buffer ///generation.empty_buffer)) ... TODO: Inline ASAP - (def: (compile_runtime! platform) + (def (compile_runtime! platform) (All (_ <type_vars>) (-> <Platform> (///generation.Operation <type_vars> [Registry Output]))) (do ///phase.monad [_ ..initialize_buffer!] (the #runtime platform))) - (def: runtime_descriptor + (def runtime_descriptor Descriptor [descriptor.#hash 0 descriptor.#name descriptor.runtime @@ -162,17 +162,17 @@ descriptor.#references (set.empty text.hash) descriptor.#state {.#Compiled}]) - (def: runtime_document + (def runtime_document (Document .Module) (document.document $.key (moduleA.empty 0))) - (def: runtime_module + (def runtime_module (module.Module .Module) [module.#id module.runtime module.#descriptor runtime_descriptor module.#document runtime_document]) - (def: (process_runtime archive platform) + (def (process_runtime archive platform) (All (_ <type_vars>) (-> Archive <Platform> (///directive.Operation <type_vars> @@ -188,7 +188,7 @@ (archive.has descriptor.runtime entry archive))))] (in [archive entry]))) - (def: (initialize_state extender + (def (initialize_state extender [analysers synthesizers generators @@ -222,7 +222,7 @@ (///phase.result' state) (at try.monad each product.left))) - (def: (phase_wrapper archive platform state) + (def (phase_wrapper archive platform state) (All (_ <type_vars>) (-> Archive <Platform> <State+> (Try [<State+> ///phase.Wrapper]))) (|> archive @@ -230,7 +230,7 @@ ///directive.lifted_generation (///phase.result' state))) - (def: (complete_extensions host_directive_bundle phase_wrapper [analysers synthesizers generators directives]) + (def (complete_extensions host_directive_bundle phase_wrapper [analysers synthesizers generators directives]) (All (_ <type_vars>) (-> (-> ///phase.Wrapper (///directive.Bundle <type_vars>)) ///phase.Wrapper @@ -247,7 +247,7 @@ generators (dictionary.composite directives (host_directive_bundle phase_wrapper))]) - (def: .public (initialize context module expander host_analysis platform generation_bundle host_directive_bundle program anchorT,expressionT,directiveT extender + (def .public (initialize context module expander host_analysis platform generation_bundle host_directive_bundle program anchorT,expressionT,directiveT extender import compilation_sources compilation_configuration) (All (_ <type_vars>) (-> context.Context @@ -300,10 +300,10 @@ [phase_wrapper state] (with_missing_extensions platform program state)] (in [state archive phase_wrapper]))))) - (def: compilation_log_separator + (def compilation_log_separator (format text.new_line text.tab)) - (def: (module_compilation_log module) + (def (module_compilation_log module) (All (_ <type_vars>) (-> descriptor.Module <State+> Text)) (|>> (the [extension.#state @@ -315,7 +315,7 @@ (format left ..compilation_log_separator right)) module))) - (def: with_reset_log + (def with_reset_log (All (_ <type_vars>) (-> <State+> <State+>)) (has [extension.#state @@ -325,7 +325,7 @@ ///generation.#log] sequence.empty)) - (def: empty + (def empty (Set descriptor.Module) (set.empty text.hash)) @@ -337,13 +337,13 @@ [#depends_on Mapping #depended_by Mapping])) - (def: independence + (def independence Dependence (let [empty (dictionary.empty text.hash)] [#depends_on empty #depended_by empty])) - (def: (depend module import dependence) + (def (depend module import dependence) (-> descriptor.Module descriptor.Module Dependence Dependence) (let [transitive_dependency (is (-> (-> Dependence Mapping) descriptor.Module (Set descriptor.Module)) (function (_ lens module) @@ -375,7 +375,7 @@ [module transitive_depends_on] [import transitive_depended_by]))))) - (def: (circular_dependency? module import dependence) + (def (circular_dependency? module import dependence) (-> descriptor.Module descriptor.Module Dependence Bit) (let [dependence? (is (-> descriptor.Module (-> Dependence Mapping) descriptor.Module Bit) (function (_ from relationship to) @@ -403,7 +403,7 @@ "Importer" (%.text importer) "Duplicates" (%.list %.text (set.list duplicates)))) - (def: (verify_dependencies importer importee dependence) + (def (verify_dependencies importer importee dependence) (-> descriptor.Module descriptor.Module Dependence (Try Any)) (cond (text#= importer importee) (exception.except ..module_cannot_import_itself [importer]) @@ -418,7 +418,7 @@ (exception.report "Extension" (%.text extension))) - (def: (with_extensions from to) + (def (with_extensions from to) (All (_ state input output) (-> (extension.Bundle state input output) (extension.Bundle state input output) @@ -440,7 +440,7 @@ (dictionary.entries from)))) (with_template [<name> <path>] - [(def: (<name> from state) + [(def (<name> from state) (All (_ <type_vars>) (-> <State+> <State+> (Try <State+>))) (do try.monad @@ -453,7 +453,7 @@ [with_directive_extensions [extension.#bundle]] ) - (def: (with_all_extensions from state) + (def (with_all_extensions from state) (All (_ <type_vars>) (-> <State+> <State+> (Try <State+>))) (do try.monad @@ -490,7 +490,7 @@ Lux_Pending (..Pending <State+>) Lux_Importer (..Importer <State+>) Lux_Compiler (..Compiler <State+>)] - (def: (parallel initial) + (def (parallel initial) (All (_ <type_vars>) (-> Lux_Context (-> Lux_Compiler Lux_Importer))) @@ -582,7 +582,7 @@ return))))) ... TODO: Find a better way, as this only works for the Lux compiler. - (def: (updated_state archive extended_states state) + (def (updated_state archive extended_states state) (All (_ <type_vars>) (-> Archive (List <State+>) <State+> (Try <State+>))) (do [! try.monad] @@ -617,7 +617,7 @@ state (monad.mix ! with_all_extensions state extended_states)] (in (with_modules state)))) - (def: (set_current_module module state) + (def (set_current_module module state) (All (_ <type_vars>) (-> descriptor.Module <State+> <State+>)) (|> (///directive.set_current_module module) @@ -628,7 +628,7 @@ ... TODO: Come up with a less hacky way to prevent duplicate imports. ... This currently assumes that all imports will be specified once in a single .using form. ... This might not be the case in the future. - (def: (with_new_dependencies new_dependencies all_dependencies) + (def (with_new_dependencies new_dependencies all_dependencies) (-> (List descriptor.Module) (Set descriptor.Module) [(Set descriptor.Module) (Set descriptor.Module)]) (let [[all_dependencies duplicates _] (is [(Set descriptor.Module) (Set descriptor.Module) Bit] (list#mix (function (_ new [all duplicates seen_prelude?]) @@ -644,7 +644,7 @@ new_dependencies))] [all_dependencies duplicates])) - (def: (any|after_imports customs import! module duplicates new_dependencies archive) + (def (any|after_imports customs import! module duplicates new_dependencies archive) (All (_ <type_vars> state document object) (-> (List ///.Custom) (..Importer state) descriptor.Module (Set descriptor.Module) (List descriptor.Module) Archive @@ -667,7 +667,7 @@ (list#each product.right archive,state/*)]))) (async#in (exception.except ..cannot_import_twice [module duplicates]))))) - (def: (lux|after_imports customs import! module duplicates new_dependencies [archive state]) + (def (lux|after_imports customs import! module duplicates new_dependencies [archive state]) (All (_ <type_vars>) (-> (List ///.Custom) Lux_Importer descriptor.Module (Set descriptor.Module) (List descriptor.Module) Lux_Context Lux_Return)) (do (try.with async.monad) @@ -679,7 +679,7 @@ {.#Item _} (try.trusted (..updated_state archive state/* state)))]))) - (def: (next_compilation module [archive state] compilation) + (def (next_compilation module [archive state] compilation) (All (_ <type_vars>) (-> descriptor.Module Lux_Context (///.Compilation <State+> .Module Any) (Try [<State+> (Either (///.Compilation <State+> .Module Any) @@ -693,14 +693,14 @@ product.left) archive)) - (def: (compiler phase_wrapper expander platform) + (def (compiler phase_wrapper expander platform) (All (_ <type_vars>) (-> ///phase.Wrapper Expander <Platform> (///.Compiler <State+> .Module Any))) (let [instancer (//init.compiler phase_wrapper expander syntax.prelude (the #write platform))] (instancer $.key (list)))) - (def: (custom_compiler import context platform compilation_sources compiler + (def (custom_compiler import context platform compilation_sources compiler custom_key custom_format custom_compilation) (All (_ <type_vars> state document object) @@ -741,7 +741,7 @@ [_ (cache/archive.cache! (the #file_system platform) context archive)] (async#in {try.#Failure error}))))))) - (def: (lux_compiler import context platform compilation_sources compiler compilation) + (def (lux_compiler import context platform compilation_sources compiler compilation) (All (_ <type_vars>) (-> Import context.Context <Platform> (List _io.Context) (///.Compiler <State+> .Module Any) (///.Compilation <State+> .Module Any) @@ -791,20 +791,20 @@ [_ (cache/archive.cache! (the #file_system platform) context archive)] (async#in {try.#Failure error}))))))) - (for @.old (these (def: Fake_State + (for @.old (these (def Fake_State Type {.#Primitive (%.nat (static.random_nat)) (list)}) - (def: Fake_Document + (def Fake_Document Type {.#Primitive (%.nat (static.random_nat)) (list)}) - (def: Fake_Object + (def Fake_Object Type {.#Primitive (%.nat (static.random_nat)) (list)})) (these)) - (def: (serial_compiler import context platform compilation_sources compiler) + (def (serial_compiler import context platform compilation_sources compiler) (All (_ <type_vars>) (-> Import context.Context <Platform> (List _io.Context) (///.Compiler <State+> .Module Any) Lux_Compiler)) @@ -836,7 +836,7 @@ all_customs importer import! @module [archive custom_state] module)] (in [archive' lux_state])))))))) - (def: .public Custom + (def .public Custom Type (type (-> (List Text) (Try ///.Custom)))) @@ -847,7 +847,7 @@ "Expected Type" (%.type ..Custom) "Actual Type" (%.type type))) - (def: (custom import! it) + (def (custom import! it) (All (_ <type_vars>) (-> Lux_Importer compiler.Compiler (Async (Try [Lux_Context (List Text) Any])))) (let [/#definition (the compiler.#definition it) @@ -868,7 +868,7 @@ {try.#Success [context (the compiler.#parameters it) /#value]} (exception.except ..invalid_custom_compiler [/#definition /#type])))))) - (def: .public (compile lux_compiler phase_wrapper import file_context expander platform compilation context) + (def .public (compile lux_compiler phase_wrapper import file_context expander platform compilation context) (All (_ <type_vars>) (-> (-> Any ..Custom) ///phase.Wrapper Import context.Context Expander <Platform> Compilation Lux_Context Lux_Return)) (let [[host_dependencies libraries compilers sources target module configuration] compilation diff --git a/stdlib/source/library/lux/tool/compiler/language/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux.lux index 084348037..7f601efff 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux.lux @@ -20,7 +20,7 @@ ... TODO: Remove #module_hash, #imports & #module_state ASAP. ... TODO: Not just from this parser, but from the lux.Module type. -(def: .public writer +(def .public writer (Writer .Module) (let [definition (is (Writer Definition) (all _.and _.bit _.type _.any)) @@ -52,7 +52,7 @@ ... #module_state _.any))) -(def: .public parser +(def .public parser (Parser .Module) (let [definition (is (Parser Definition) (all <>.and @@ -98,7 +98,7 @@ ... #module_state (at <>.monad in {.#Cached})))) -(def: .public key +(def .public key (Key .Module) (key.key [signature.#name (symbol ..compiler) signature.#version version.latest] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux index 471431654..0a1b71dab 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux @@ -72,17 +72,17 @@ (type: .public Match (Match' Analysis)) -(def: (branch_equivalence equivalence) +(def (branch_equivalence equivalence) (-> (Equivalence Analysis) (Equivalence Branch)) (implementation - (def: (= [reference_pattern reference_body] [sample_pattern sample_body]) + (def (= [reference_pattern reference_body] [sample_pattern sample_body]) (and (at /pattern.equivalence = reference_pattern sample_pattern) (at equivalence = reference_body sample_body))))) -(def: .public equivalence +(def .public equivalence (Equivalence Analysis) (implementation - (def: (= reference sample) + (def (= reference sample) (.case [reference sample] [{#Simple reference} {#Simple sample}] (at /simple.equivalence = reference sample) @@ -115,19 +115,19 @@ false)))) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [{<tag> content}]))] [case ..#Case] ) -(def: .public unit +(def .public unit (template (unit) [{..#Simple {/simple.#Unit}}])) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> value) [{..#Simple {<tag> value}}]))] @@ -145,7 +145,7 @@ (type: .public (Reification c) [c (List c)]) -(def: .public no_op +(def .public no_op (template (no_op value) [(|> 1 {variable.#Local} @@ -154,14 +154,14 @@ {..#Function (list)} {..#Apply value})])) -(def: .public (reified [abstraction inputs]) +(def .public (reified [abstraction inputs]) (-> (Reification Analysis) Analysis) (list#mix (function (_ input abstraction') {#Apply input abstraction'}) abstraction inputs)) -(def: .public (reification analysis) +(def .public (reification analysis) (-> Analysis (Reification Analysis)) (loop (again [abstraction analysis inputs (is (List Analysis) @@ -174,7 +174,7 @@ [abstraction inputs]))) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (syntax (_ [content <code>.any]) (in (list (` (.<| {..#Reference} <tag> @@ -188,7 +188,7 @@ ) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [(.<| {..#Structure} {<tag>} @@ -198,7 +198,7 @@ [tuple /complex.#Tuple] ) -(def: .public (format analysis) +(def .public (format analysis) (Format Analysis) (.case analysis {#Simple it} @@ -255,7 +255,7 @@ [Bundle extension.Bundle] ) -(def: .public (with_source_code source action) +(def .public (with_source_code source action) (All (_ a) (-> Source (Operation a) (Operation a))) (function (_ [bundle state]) (let [old_source (the .#source state)] @@ -267,13 +267,13 @@ failure failure)))) -(def: .public (with_current_module name) +(def .public (with_current_module name) (All (_ a) (-> Text (Operation a) (Operation a))) (extension.localized (the .#current_module) (has .#current_module) (function.constant {.#Some name}))) -(def: .public (with_location location action) +(def .public (with_location location action) (All (_ a) (-> Location (Operation a) (Operation a))) (if (text#= "" (product.left location)) action @@ -287,17 +287,17 @@ failure failure))))) -(def: (located location error) +(def (located location error) (-> Location Text Text) (%.format (%.location location) text.new_line error)) -(def: .public (failure error) +(def .public (failure error) (-> Text Operation) (function (_ [bundle state]) {try.#Failure (located (the .#location state) error)})) -(def: .public (of_try it) +(def .public (of_try it) (All (_ a) (-> (Try a) (Operation a))) (function (_ [bundle state]) (.case it @@ -307,17 +307,17 @@ {try.#Success it} {try.#Success [[bundle state] it]}))) -(def: .public (except exception parameters) +(def .public (except exception parameters) (All (_ e) (-> (Exception e) e Operation)) (..failure (exception.error exception parameters))) -(def: .public (assertion exception parameters condition) +(def .public (assertion exception parameters condition) (All (_ e) (-> (Exception e) e Bit (Operation Any))) (if condition (at phase.monad in []) (..except exception parameters))) -(def: .public (with_exception exception message action) +(def .public (with_exception exception message action) (All (_ e o) (-> (Exception e) e (Operation o) (Operation o))) (function (_ bundle,state) (.case (exception.with exception message @@ -329,14 +329,14 @@ success success))) -(def: .public (set_state state) +(def .public (set_state state) (-> .Lux (Operation Any)) (function (_ [bundle _]) {try.#Success [[bundle state] []]})) (with_template [<name> <type> <field> <value>] - [(def: .public (<name> value) + [(def .public (<name> value) (-> <type> (Operation Any)) (extension.update (has <field> <value>)))] @@ -345,32 +345,32 @@ [set_location Location .#location value] ) -(def: .public (location file) +(def .public (location file) (-> Text Location) [file 1 0]) -(def: .public (source file code) +(def .public (source file code) (-> Text Text Source) [(location file) 0 code]) -(def: dummy_source +(def dummy_source Source [location.dummy 0 ""]) -(def: type_context +(def type_context Type_Context [.#ex_counter 0 .#var_counter 0 .#var_bindings (list)]) -(def: .public (info version host configuration) +(def .public (info version host configuration) (-> Version Text Configuration Info) [.#target host .#version (version.format version) .#mode {.#Build} .#configuration configuration]) -(def: .public (state info) +(def .public (state info) (-> Info Lux) [.#info info .#source ..dummy_source diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/complex.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/complex.lux index b2dbbbb79..bca0b70e3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/complex.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/complex.lux @@ -31,28 +31,28 @@ (type: .public Tag Nat) -(def: .public (tag right? lefts) +(def .public (tag right? lefts) (-> Bit Nat Tag) (if right? (++ lefts) lefts)) -(def: .public (lefts right? tag) +(def .public (lefts right? tag) (-> Bit Tag Nat) (if right? (-- tag) tag)) -(def: .public (choice multiplicity pick) +(def .public (choice multiplicity pick) (-> Nat Tag [Nat Bit]) (let [right? (n.= (-- multiplicity) pick)] [(..lefts right? pick) right?])) -(def: .public (equivalence (open "/#[0]")) +(def .public (equivalence (open "/#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (Complex a)))) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{#Variant [reference_lefts reference_right? reference_value]} {#Variant [sample_lefts sample_right? sample_value]}] @@ -66,13 +66,13 @@ _ false)))) -(def: .public (hash super) +(def .public (hash super) (All (_ a) (-> (Hash a) (Hash (Complex a)))) (implementation - (def: equivalence + (def equivalence (..equivalence (at super equivalence))) - (def: (hash value) + (def (hash value) (case value {#Variant [lefts right? value]} (all n.* 2 @@ -85,7 +85,7 @@ (at (list.hash super) hash members)) )))) -(def: .public (format %it it) +(def .public (format %it it) (All (_ a) (-> (Format a) (Format (Complex a)))) (case it {#Variant [lefts right? it]} diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/coverage.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/coverage.lux index e37943c08..a54acd867 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/coverage.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/coverage.lux @@ -58,7 +58,7 @@ (type: .public Variant (Variant' Coverage)))) -(def: .public (minimum [max cases]) +(def .public (minimum [max cases]) (-> Variant Nat) (maybe.else (|> cases dictionary.keys @@ -66,11 +66,11 @@ ++) max)) -(def: .public (maximum [max cases]) +(def .public (maximum [max cases]) (-> Variant Nat) (maybe.else n#top max)) -(def: (alternatives coverage) +(def (alternatives coverage) (-> Coverage (List Coverage)) (case coverage {#Alt left right} @@ -79,10 +79,10 @@ _ (list coverage))) -(def: .public equivalence +(def .public equivalence (Equivalence Coverage) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{#Exhaustive} {#Exhaustive}] #1 @@ -120,7 +120,7 @@ (open: "/#[0]" ..equivalence) -(def: .public (format value) +(def .public (format value) (%.Format Coverage) (case value {#Bit it} @@ -162,7 +162,7 @@ "Expected size" ">= 2" "Actual size" (%.nat size))) -(def: .public (coverage pattern) +(def .public (coverage pattern) (-> Pattern (Try Coverage)) (case pattern (^.or {//pattern.#Simple {//simple.#Unit}} @@ -222,7 +222,7 @@ (|> (dictionary.empty n.hash) (dictionary.has idx value_coverage))})))) -(def: (xor left right) +(def (xor left right) (-> Bit Bit Bit) (or (and left (not right)) (and (not left) right))) @@ -245,7 +245,7 @@ "Expected cases" (%.nat expected) "Mismatched cases" (%.nat mismatched))) -(def: .public (exhaustive? coverage) +(def .public (exhaustive? coverage) (-> Coverage Bit) (case coverage {#Exhaustive} @@ -258,7 +258,7 @@ ... necessary to merge them all to figure out if the entire ... pattern-matching expression is exhaustive and whether it contains ... redundant patterns. -(def: .public (composite addition so_far) +(def .public (composite addition so_far) (-> Coverage Coverage (Try Coverage)) (with_expansions [<redundancy> (exception.except ..redundancy [so_far addition]) <alternatively> {try.#Success {#Alt addition so_far}} diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux index 2cc4503d9..69efc223d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux @@ -38,11 +38,11 @@ (type: .public Eval (-> Archive Type Code (Operation Any))) -(def: evals +(def evals (Atom (Dictionary module.ID Nat)) (atom.atom (dictionary.empty n.hash))) -(def: .public (evaluator expander synthesis_state generation_state generate) +(def .public (evaluator expander synthesis_state generation_state generate) (All (_ anchor expression artifact) (-> Expander synthesis.State+ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/inference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/inference.lux index 06489b706..cecf9c460 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/inference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/inference.lux @@ -54,7 +54,7 @@ [invalid_type_application] ) -(def: .public (quantified @var @parameter :it:) +(def .public (quantified @var @parameter :it:) (-> check.Var Nat Type Type) (case :it: {.#Primitive name co_variant} @@ -93,7 +93,7 @@ ... tagged variants). ... But, so long as the type being used for the inference can be treated ... as a function type, this method of inference should work. -(def: (general' vars archive analyse inferT args) +(def (general' vars archive analyse inferT args) (-> (List check.Var) Archive Phase Type (List Code) (Operation [Type_Context (List check.Var) Type (List Analysis)])) (case args {.#End} @@ -154,7 +154,7 @@ (/.except ..cannot_infer [inferT args])) )) -(def: .public (general archive analyse inferT args) +(def .public (general archive analyse inferT args) (-> Archive Phase Type (List Code) (Operation [Type (List Analysis)])) (do [! phase.monad] [[just_before vars :inference: terms] (general' (list) archive analyse inferT args)] @@ -188,7 +188,7 @@ ... (in [:inference: terms]))) )) -(def: (with_recursion @self recursion) +(def (with_recursion @self recursion) (-> Nat Type Type Type) (function (again it) (case it @@ -216,14 +216,14 @@ _ it))) -(def: parameters +(def parameters (-> Nat (List Type)) (|>> list.indices (list#each (|>> (n.* 2) ++ {.#Parameter})) list.reversed)) (with_template [<name> <types> <inputs> <exception> <when> <then>] - [(`` (def: .public (<name> (~~ (template.spliced <inputs>)) complex) + [(`` (def .public (<name> (~~ (template.spliced <inputs>)) complex) (-> (~~ (template.spliced <types>)) Type (Operation Type)) (loop (again [depth 0 it complex]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/macro.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/macro.lux index 7ca7b9158..e66c897e9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/macro.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/macro.lux @@ -32,7 +32,7 @@ (type: .public Expander (-> Macro (List Code) Lux (Try (Try [Lux (List Code)])))) -(def: .public (expansion expander name macro inputs) +(def .public (expansion expander name macro inputs) (-> Expander Symbol Macro (List Code) (Meta (List Code))) (function (_ state) (do try.monad @@ -44,7 +44,7 @@ _ output)))) -(def: .public (single_expansion expander name macro inputs) +(def .public (single_expansion expander name macro inputs) (-> Expander Symbol Macro (List Code) (Meta Code)) (do meta.monad [expansion (..expansion expander name macro inputs)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/module.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/module.lux index 6c325986d..a2f23afd5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/module.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/module.lux @@ -69,7 +69,7 @@ {.#Compiled} "Compiled" {.#Cached} "Cached"))) -(def: .public (empty hash) +(def .public (empty hash) (-> Nat Module) [.#module_hash hash .#module_aliases (list) @@ -77,7 +77,7 @@ .#imports (list) .#module_state {.#Active}]) -(def: .public (import module) +(def .public (import module) (-> Text (Operation Any)) (///extension.lifted (do ///.monad @@ -92,7 +92,7 @@ state) []]})))) -(def: .public (alias alias module) +(def .public (alias alias module) (-> Text Text (Operation Any)) (///extension.lifted (do ///.monad @@ -104,7 +104,7 @@ state) []]})))) -(def: .public (exists? module) +(def .public (exists? module) (-> Text (Operation Bit)) (///extension.lifted (function (_ state) @@ -115,7 +115,7 @@ [state] {try.#Success})))) -(def: .public (define name definition) +(def .public (define name definition) (-> Text Global (Operation Any)) (///extension.lifted (do ///.monad @@ -137,7 +137,7 @@ ((///extension.up (/.except ..cannot_define_more_than_once [[self_name name] already_existing])) state)))))) -(def: .public (create hash name) +(def .public (create hash name) (-> Nat Text (Operation Any)) (///extension.lifted (function (_ state) @@ -146,7 +146,7 @@ state) []]}))) -(def: .public (with hash name action) +(def .public (with hash name action) (All (_ a) (-> Nat Text (Operation a) (Operation [Module a]))) (do ///.monad [_ (..create hash name) @@ -156,7 +156,7 @@ (in [module output]))) (with_template [<setter> <asker> <tag>] - [(def: .public (<setter> module_name) + [(def .public (<setter> module_name) (-> Text (Operation Any)) (///extension.lifted (function (_ state) @@ -177,7 +177,7 @@ ((///extension.up (/.except ..unknown_module module_name)) state))))) - (def: .public (<asker> module_name) + (def .public (<asker> module_name) (-> Text (Operation Bit)) (///extension.lifted (function (_ state) @@ -197,7 +197,7 @@ [set_cached cached? .#Cached] ) -(def: .public (declare_labels record? labels exported? type) +(def .public (declare_labels record? labels exported? type) (-> Bit (List Label) Bit Type (Operation Any)) (do [! ///.monad] [self_name (///extension.lifted meta.current_module_name) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/pattern.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/pattern.lux index ef3350d56..841a39b77 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/pattern.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/pattern.lux @@ -23,10 +23,10 @@ {#Complex (Complex Pattern)} {#Bind Register}))) -(def: .public equivalence +(def .public equivalence (Equivalence Pattern) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{#Simple reference} {#Simple sample}] (at //simple.equivalence = reference sample) @@ -40,7 +40,7 @@ _ false)))) -(def: .public (format it) +(def .public (format it) (%.Format Pattern) (case it {#Simple it} @@ -53,7 +53,7 @@ (//variable.format {//variable.#Local it}))) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [(.<| {..#Complex} <tag> @@ -63,12 +63,12 @@ [tuple {//complex.#Tuple}] ) -(def: .public unit +(def .public unit (template (unit) [{..#Simple {//simple.#Unit}}])) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [{..#Simple {<tag> content}}]))] @@ -80,6 +80,6 @@ [text //simple.#Text] ) -(def: .public bind +(def .public bind (template (bind register) [{..#Bind register}])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/scope.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/scope.lux index 2fa60d94f..7491c9f00 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/scope.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/scope.lux @@ -29,13 +29,13 @@ (type: Foreign (Bindings Text [Type Variable])) -(def: (local? name scope) +(def (local? name scope) (-> Text Scope Bit) (|> scope (the [.#locals .#mappings]) (plist.contains? name))) -(def: (local name scope) +(def (local name scope) (-> Text Scope (Maybe [Type Variable])) (|> scope (the [.#locals .#mappings]) @@ -43,13 +43,13 @@ (maybe#each (function (_ [type value]) [type {variable.#Local value}])))) -(def: (captured? name scope) +(def (captured? name scope) (-> Text Scope Bit) (|> scope (the [.#captured .#mappings]) (plist.contains? name))) -(def: (captured name scope) +(def (captured name scope) (-> Text Scope (Maybe [Type Variable])) (loop (again [idx 0 mappings (the [.#captured .#mappings] scope)]) @@ -62,12 +62,12 @@ {.#End} {.#None}))) -(def: (reference? name scope) +(def (reference? name scope) (-> Text Scope Bit) (or (local? name scope) (captured? name scope))) -(def: (reference name scope) +(def (reference name scope) (-> Text Scope (Maybe [Type Variable])) (case (..local name scope) {.#Some type} @@ -76,7 +76,7 @@ _ (..captured name scope))) -(def: .public (variable name) +(def .public (variable name) (-> Text (Operation (Maybe [Type Variable]))) (extension.lifted (function (_ state) @@ -109,7 +109,7 @@ (exception: .public no_scope) (exception: .public drained) -(def: .public (with_local [name type] action) +(def .public (with_local [name type] action) (All (_ a) (-> [Text Type] (Operation a) (Operation a))) (function (_ [bundle state]) (case (the .#scopes state) @@ -140,7 +140,7 @@ _ (exception.except ..no_scope [])))) -(def: empty +(def empty Scope (let [bindings (is Bindings [.#counter 0 @@ -150,7 +150,7 @@ .#locals bindings .#captured bindings])) -(def: .public (reset action) +(def .public (reset action) (All (_ a) (-> (Operation a) (Operation a))) (function (_ [bundle state]) (case (action [bundle (has .#scopes (list ..empty) state)]) @@ -161,7 +161,7 @@ failure failure))) -(def: .public (with action) +(def .public (with action) (All (_ a) (-> (Operation a) (Operation [Scope a]))) (function (_ [bundle state]) (case (action [bundle (revised .#scopes (|>> {.#Item ..empty}) state)]) @@ -177,7 +177,7 @@ {try.#Failure error} {try.#Failure error}))) -(def: .public next +(def .public next (Operation Register) (extension.lifted (function (_ state) @@ -188,7 +188,7 @@ {.#End} (exception.except ..no_scope []))))) -(def: .public environment +(def .public environment (-> Scope (Environment Variable)) (|>> (the [.#captured .#mappings]) (list#each (function (_ [_ [_ ref]]) ref)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/simple.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/simple.lux index 8a2fbd7d5..25ba7b1bd 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/simple.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/simple.lux @@ -26,10 +26,10 @@ {#Frac Frac} {#Text Text})) -(def: .public equivalence +(def .public equivalence (Equivalence Simple) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{#Unit} {#Unit}] true @@ -47,7 +47,7 @@ _ false)))) -(def: .public (format it) +(def .public (format it) (Format Simple) (case it {#Unit} diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/type.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/type.lux index dba3ad176..007289a0a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/type.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/type.lux @@ -26,7 +26,7 @@ [/// ["[0]" phase]]]]) -(def: .public (check action) +(def .public (check action) (All (_ a) (-> (Check a) (Operation a))) (function (_ (^.let stateE [bundle state])) (case (action (the .#type_context state)) @@ -37,10 +37,10 @@ {try.#Failure error} ((/.failure error) stateE)))) -(def: prefix +(def prefix (format (%.symbol (symbol ..type)) "#")) -(def: .public (existential? type) +(def .public (existential? type) (-> Type Bit) (case type {.#Primitive actual {.#End}} @@ -49,28 +49,28 @@ _ false)) -(def: (existential' module id) +(def (existential' module id) (-> Text Nat Type) {.#Primitive (format ..prefix module "#" (%.nat id)) (list)}) -(def: .public existential +(def .public existential (Operation Type) (do phase.monad [module (extension.lifted meta.current_module_name) id (extension.lifted meta.seed)] (in (..existential' module id)))) -(def: .public (expecting expected) +(def .public (expecting expected) (All (_ a) (-> Type (Operation a) (Operation a))) (extension.localized (the .#expected) (has .#expected) (function.constant {.#Some expected}))) -(def: .public fresh +(def .public fresh (All (_ a) (-> (Operation a) (Operation a))) (extension.localized (the .#type_context) (has .#type_context) (function.constant check.fresh_context))) -(def: .public (inference actualT) +(def .public (inference actualT) (-> Type (Operation Any)) (do phase.monad [module (extension.lifted meta.current_module_name) @@ -112,7 +112,7 @@ ... (in it))) ))) -(def: .public (with_var it) +(def .public (with_var it) (All (_ a) (-> (-> [check.Var Type] (Operation a)) (Operation a))) @@ -123,7 +123,7 @@ _ (..check (check.forget! @it))] (in it))) -(def: .public (inferring action) +(def .public (inferring action) (All (_ a) (-> (Operation a) (Operation [Type a]))) (<| ..with_var (function (_ [@it :it:])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux index afe5c1aa8..2682f80d8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux @@ -45,12 +45,12 @@ [#imports (List Import) #referrals (List Code)])) -(def: .public no_requirements +(def .public no_requirements Requirements [#imports (list) #referrals (list)]) -(def: .public (merge_requirements left right) +(def .public (merge_requirements left right) (-> Requirements Requirements Requirements) [#imports (list#composite (the #imports left) (the #imports right)) #referrals (list#composite (the #referrals left) (the #referrals right))]) @@ -67,7 +67,7 @@ ) (with_template [<name> <component> <phase>] - [(def: .public <name> + [(def .public <name> (All (_ anchor expression directive) (Operation anchor expression directive <phase>)) (function (_ [bundle state]) @@ -79,7 +79,7 @@ ) (with_template [<name> <component> <operation>] - [(def: .public <name> + [(def .public <name> (All (_ anchor expression directive output) (-> (<operation> output) (Operation anchor expression directive output))) @@ -92,7 +92,7 @@ [lifted_generation ..#generation (generation.Operation anchor expression directive)] ) -(def: .public (set_current_module module) +(def .public (set_current_module module) (All (_ anchor expression directive) (-> Module (Operation anchor expression directive Any))) (do phase.monad diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux index a978ccd16..8bc9502fc 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux @@ -96,7 +96,7 @@ [Extender extension.Extender] ) -(def: .public (state host module) +(def .public (state host module) (All (_ anchor expression directive) (-> (Host expression directive) descriptor.Module @@ -112,7 +112,7 @@ #log sequence.empty #interim_artifacts (list)]) -(def: .public empty_buffer +(def .public empty_buffer Buffer sequence.empty) @@ -121,7 +121,7 @@ <set> <get> <get_type> <exception>] [(exception: .public <exception>) - (def: .public <with_declaration> + (def .public <with_declaration> (All (_ anchor expression directive output) <with_type>) (function (_ body) (function (_ [bundle state]) @@ -133,7 +133,7 @@ {try.#Failure error} {try.#Failure error})))) - (def: .public <get> + (def .public <get> (All (_ anchor expression directive) (Operation anchor expression directive <get_type>)) (function (_ (^.let stateE [bundle state])) @@ -144,7 +144,7 @@ {.#None} (exception.except <exception> [])))) - (def: .public (<set> value) + (def .public (<set> value) (All (_ anchor expression directive) (-> <get_type> (Operation anchor expression directive Any))) (function (_ [bundle state]) @@ -166,20 +166,20 @@ set_buffer buffer (Buffer directive) no_active_buffer] ) -(def: .public get_registry +(def .public get_registry (All (_ anchor expression directive) (Operation anchor expression directive Registry)) (function (_ (^.let stateE [bundle state])) {try.#Success [stateE (the #registry state)]})) -(def: .public (set_registry value) +(def .public (set_registry value) (All (_ anchor expression directive) (-> Registry (Operation anchor expression directive Any))) (function (_ [bundle state]) {try.#Success [[bundle (has #registry value state)] []]})) -(def: .public next +(def .public next (All (_ anchor expression directive) (Operation anchor expression directive Nat)) (do phase.monad @@ -187,22 +187,22 @@ _ (extension.update (revised #counter ++))] (in count))) -(def: .public (symbol prefix) +(def .public (symbol prefix) (All (_ anchor expression directive) (-> Text (Operation anchor expression directive Text))) (at phase.monad each (|>> %.nat (format prefix)) ..next)) -(def: .public (enter_module module) +(def .public (enter_module module) (All (_ anchor expression directive) (-> descriptor.Module (Operation anchor expression directive Any))) (extension.update (has #module module))) -(def: .public module +(def .public module (All (_ anchor expression directive) (Operation anchor expression directive descriptor.Module)) (extension.read (the #module))) -(def: .public (evaluate! label code) +(def .public (evaluate! label code) (All (_ anchor expression directive) (-> unit.ID [(Maybe unit.ID) expression] (Operation anchor expression directive Any))) (function (_ (^.let state+ [bundle state])) @@ -213,7 +213,7 @@ {try.#Failure error} (exception.except ..cannot_interpret [error])))) -(def: .public (execute! code) +(def .public (execute! code) (All (_ anchor expression directive) (-> directive (Operation anchor expression directive Any))) (function (_ (^.let state+ [bundle state])) @@ -224,7 +224,7 @@ {try.#Failure error} (exception.except ..cannot_interpret error)))) -(def: .public (define! context custom code) +(def .public (define! context custom code) (All (_ anchor expression directive) (-> unit.ID (Maybe Text) [(Maybe unit.ID) expression] (Operation anchor expression directive [Text Any directive]))) (function (_ (^.let stateE [bundle state])) @@ -235,7 +235,7 @@ {try.#Failure error} (exception.except ..cannot_interpret error)))) -(def: .public (save! artifact_id custom code) +(def .public (save! artifact_id custom code) (All (_ anchor expression directive) (-> artifact.ID (Maybe Text) directive (Operation anchor expression directive Any))) (do [! phase.monad] @@ -251,7 +251,7 @@ (phase.except ..no_buffer_for_saving_code [artifact_id])))) (with_template [<type> <mandatory?> <inputs> <input_types> <name> <artifact>] - [(`` (def: .public (<name> it (~~ (template.spliced <inputs>)) dependencies) + [(`` (def .public (<name> it (~~ (template.spliced <inputs>)) dependencies) (All (_ anchor expression directive) (-> <type> (~~ (template.spliced <input_types>)) (Set unit.ID) (Operation anchor expression directive artifact.ID))) (function (_ (^.let stateE [bundle state])) @@ -274,7 +274,7 @@ "Module" (symbol.module name) "Known Definitions" (exception.listing product.left known_definitions))) -(def: .public (remember archive name) +(def .public (remember archive name) (All (_ anchor expression directive) (-> Archive Symbol (Operation anchor expression directive unit.ID))) (function (_ (^.let stateE [bundle state])) @@ -293,7 +293,7 @@ {.#Some id} {try.#Success [stateE [@module id]]}))))) -(def: .public (definition archive name) +(def .public (definition archive name) (All (_ anchor expression directive) (-> Archive Symbol (Operation anchor expression directive [unit.ID (Maybe category.Definition)]))) (function (_ (^.let stateE [bundle state])) @@ -314,7 +314,7 @@ (exception: .public no_context) -(def: .public (module_id module archive) +(def .public (module_id module archive) (All (_ anchor expression directive) (-> descriptor.Module Archive (Operation anchor expression directive module.ID))) (function (_ (^.let stateE [bundle state])) @@ -322,7 +322,7 @@ [@module (archive.id module archive)] (in [stateE @module])))) -(def: .public (context archive) +(def .public (context archive) (All (_ anchor expression directive) (-> Archive (Operation anchor expression directive unit.ID))) (function (_ (^.let stateE [bundle state])) @@ -335,7 +335,7 @@ [@module (archive.id (the #module state) archive)] (in [stateE [@module id]]))))) -(def: .public (with_context @artifact body) +(def .public (with_context @artifact body) (All (_ anchor expression directive a) (-> artifact.ID (Operation anchor expression directive a) @@ -346,7 +346,7 @@ (in [[bundle' (has #context (the #context state) state')] output])))) -(def: .public (with_registry_shift shift body) +(def .public (with_registry_shift shift body) (All (_ anchor expression directive a) (-> Nat (Operation anchor expression directive a) @@ -357,7 +357,7 @@ (in [[bundle' (has #registry_shift (the #registry_shift state) state')] output])))) -(def: .public (with_new_context archive dependencies body) +(def .public (with_new_context archive dependencies body) (All (_ anchor expression directive a) (-> Archive (Set unit.ID) (Operation anchor expression directive a) (Operation anchor expression directive [unit.ID a]))) @@ -374,7 +374,7 @@ [[@module @artifact] output]]))))) -(def: .public (log! message) +(def .public (log! message) (All (_ anchor expression directive a) (-> Text (Operation anchor expression directive Any))) (function (_ [bundle state]) @@ -382,7 +382,7 @@ (revised #log (sequence.suffix message) state)] []]})) -(def: .public (with_interim_artifacts archive body) +(def .public (with_interim_artifacts archive body) (All (_ anchor expression directive a) (-> Archive (Operation anchor expression directive a) (Operation anchor expression directive [(List unit.ID) a]))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux index 83cf9fb35..1c621d0ff 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux @@ -40,7 +40,7 @@ (exception.report "Syntax" (%.code syntax))) -(def: variant_analysis +(def variant_analysis (template (_ analysis archive tag values) ... (-> Phase Archive Symbol (List Code) (Operation Analysis)) [(case values @@ -50,7 +50,7 @@ _ (/complex.variant analysis tag archive (code.tuple values)))])) -(def: sum_analysis +(def sum_analysis (template (_ analysis archive lefts right? values) ... (-> Phase Archive Nat Bit (List Code) (Operation Analysis)) [(case values @@ -60,7 +60,7 @@ _ (/complex.sum analysis lefts right? archive (code.tuple values)))])) -(def: case_analysis +(def case_analysis (template (_ analysis archive input branches code) ... (-> Phase Archive Code (List Code) Code (Operation Analysis)) [(case (list.pairs branches) @@ -70,7 +70,7 @@ {.#None} (//.except ..invalid [code]))])) -(def: apply_analysis +(def apply_analysis (template (_ expander analysis archive functionC argsC+) ... (-> Expander Phase Archive Code (List Code) (Operation Analysis)) [(do [! //.monad] @@ -92,7 +92,7 @@ _ (/function.apply analysis argsC+ functionT functionA archive functionC)))])) -(def: .public (phase expander) +(def .public (phase expander) (-> Expander Phase) (function (analysis archive code) (<| (let [[location code'] code]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux index a16d7c410..728eb24ec 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux @@ -71,7 +71,7 @@ (exception: .public empty_branches) -(def: (quantified envs baseT) +(def (quantified envs baseT) (-> (List (List Type)) Type Type) (.case envs {.#End} @@ -87,7 +87,7 @@ ... type-variables or quantifications. ... This function makes it easier for "case" analysis to properly ... type-check the input with respect to the patterns. -(def: .public (tuple :it:) +(def .public (tuple :it:) (-> Type (Check [(List check.Var) Type])) (loop (again [envs (is (List (List Type)) (list)) @@ -149,7 +149,7 @@ _ (at check.monad in [(list) (..quantified envs :it:)])))) -(def: (simple_pattern_analysis type :input: location output next) +(def (simple_pattern_analysis type :input: location output next) (All (_ a) (-> Type Type Location Pattern (Operation a) (Operation [Pattern a]))) (/.with_location location (do ///.monad @@ -157,7 +157,7 @@ outputA next] (in [output outputA])))) -(def: (tuple_pattern_analysis pattern_analysis :input: sub_patterns next) +(def (tuple_pattern_analysis pattern_analysis :input: sub_patterns next) (All (_ a) (-> (-> (Maybe Nat) Type Code (Operation a) (Operation [Pattern a])) Type (List Code) (Operation a) (Operation [Pattern a]))) @@ -224,7 +224,7 @@ ... body expressions. ... That is why the body must be analysed in the context of the ... pattern, and not separately. -(def: (pattern_analysis num_tags :input: pattern next) +(def (pattern_analysis num_tags :input: pattern next) (All (_ a) (-> (Maybe Nat) Type Code (Operation a) (Operation [Pattern a]))) (.case pattern [location {.#Symbol ["" name]}] @@ -337,7 +337,7 @@ (/.except ..invalid [pattern]) )) -(def: .public (case analyse branches archive inputC) +(def .public (case analyse branches archive inputC) (-> Phase (List [Code Code]) Phase) (.case branches {.#Item [patternH bodyH] branchesT} diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/complex.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/complex.lux index 231c3e374..e0c2a8b41 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/complex.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/complex.lux @@ -99,7 +99,7 @@ list#conjoint code.tuple)))) -(def: .public (sum analyse lefts right? archive) +(def .public (sum analyse lefts right? archive) (-> Phase Nat Bit Phase) (let [tag (/complex.tag right? lefts)] (function (again valueC) @@ -170,7 +170,7 @@ _ (/.except ..invalid_variant_type [expectedT lefts right? valueC]))))))) -(def: .public (variant analyse tag archive valueC) +(def .public (variant analyse tag archive valueC) (-> Phase Symbol Phase) (do [! ///.monad] [tag (///extension.lifted (meta.normal tag)) @@ -188,7 +188,7 @@ _ (..sum analyse lefts right? archive valueC)))) -(def: (typed_product analyse expectedT archive members) +(def (typed_product analyse expectedT archive members) (-> Phase Type Archive (List Code) (Operation Analysis)) (<| (let [! ///.monad]) (at ! each (|>> /.tuple)) @@ -219,7 +219,7 @@ _ (/.except ..cannot_analyse_tuple [expectedT members]))))) -(def: .public (product analyse archive membersC) +(def .public (product analyse archive membersC) (-> Phase Archive (List Code) (Operation Analysis)) (do [! ///.monad] [expectedT (///extension.lifted meta.expected_type)] @@ -290,7 +290,7 @@ ... records, so they must be normalized for further analysis. ... Normalization just means that all the tags get resolved to their ... canonical form (with their corresponding module identified). -(def: .public (normal pattern_matching? record) +(def .public (normal pattern_matching? record) (-> Bit (List Code) (Operation (Maybe (List [Symbol Code])))) (loop (again [input record output (is (List [Symbol Code]) @@ -314,7 +314,7 @@ _ (///#in {.#None})))) -(def: (local_binding? name) +(def (local_binding? name) (-> Text (Meta Bit)) (at meta.monad each (list.any? (list.any? (|>> product.left (text#= name)))) @@ -323,7 +323,7 @@ ... Lux already possesses the means to analyse tuples, so ... re-implementing the same functionality for records makes no sense. ... Records, thus, get transformed into tuples by ordering the elements. -(def: (order' head_k record) +(def (order' head_k record) (-> Symbol (List [Symbol Code]) (Operation (Maybe [Nat (List Code) Type]))) (do [! ///.monad] [slotH' (///extension.lifted @@ -363,7 +363,7 @@ {try.#Failure error} (in {.#None})))) -(def: .public (order pattern_matching? record) +(def .public (order pattern_matching? record) (-> Bit (List [Symbol Code]) (Operation (Maybe [Nat (List Code) Type]))) (case record ... empty_record = empty_tuple = unit/any = [] @@ -385,7 +385,7 @@ _ (order' head_k record)))) -(def: .public (record analyse archive members) +(def .public (record analyse archive members) (-> Phase Archive (List Code) (Operation Analysis)) (case members (pattern (list)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux index 4cc07333a..3b3a319d3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux @@ -53,7 +53,7 @@ (format (%.nat idx) " " (%.code argC)))) (text.interposed text.new_line)))) -(def: .public (function analyse function_name arg_name archive body) +(def .public (function analyse function_name arg_name archive body) (-> Phase Text Text Phase) (do [! ///.monad] [expectedT (///extension.lifted meta.expected_type)] @@ -134,7 +134,7 @@ (/.failure "") ))))) -(def: .public (apply analyse argsC+ :function: functionA archive functionC) +(def .public (apply analyse argsC+ :function: functionA archive functionC) (-> Phase (List Code) Type Analysis Phase) (|> (/inference.general archive analyse :function: argsC+) (///#each (|>> product.right [functionA] /.reified)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/reference.lux index 232954fff..cb4011c73 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/reference.lux @@ -38,7 +38,7 @@ (exception.report "Label" (%.symbol definition))) -(def: (definition def_name) +(def (definition def_name) (-> Symbol (Operation Analysis)) (with_expansions [<return> (in (|> def_name ///reference.constant {/.#Reference}))] (do [! ///.monad] @@ -83,7 +83,7 @@ {.#Slot _} (/.except ..labels_are_not_definitions [def_name]))))) -(def: (variable var_name) +(def (variable var_name) (-> Text (Operation (Maybe Analysis))) (do [! ///.monad] [?var (/scope.variable var_name)] @@ -96,7 +96,7 @@ {.#None} (in {.#None})))) -(def: .public (reference it) +(def .public (reference it) (-> Symbol (Operation Analysis)) (case it ["" simple_name] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/simple.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/simple.lux index a5e7a9d08..416780c05 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/simple.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/simple.lux @@ -12,7 +12,7 @@ ["[1]" phase]]]]) (with_template [<name> <type> <tag>] - [(def: .public (<name> value) + [(def .public (<name> value) (-> <type> (Operation Analysis)) (do ///.monad [_ (/type.inference <type>)] @@ -26,7 +26,7 @@ [text .Text /simple.#Text] ) -(def: .public unit +(def .public unit (Operation Analysis) (do ///.monad [_ (/type.inference .Any)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux index 41f270408..6669776fa 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux @@ -43,7 +43,7 @@ (type: Eval (-> Type Code (Meta Any))) -(def: (meta_eval archive bundle compiler_eval) +(def (meta_eval archive bundle compiler_eval) (-> Archive ///analysis.Bundle evaluation.Eval Eval) (function (_ type code lux) @@ -54,7 +54,7 @@ {try.#Failure error} {try.#Failure error}))) -(def: (requiring phase archive expansion) +(def (requiring phase archive expansion) (All (_ anchor expression directive) (-> (Phase anchor expression directive) Archive (List Code) (Operation anchor expression directive /.Requirements))) @@ -75,7 +75,7 @@ {try.#Failure error}))))) (with_expansions [<lux_def_module> (these [|form_location| {.#Form (list.partial [|text_location| {.#Text "lux def module"}] annotations)}])] - (def: .public (phase wrapper expander) + (def .public (phase wrapper expander) (-> //.Wrapper Expander Phase) (let [analysis (//analysis.phase expander)] (function (again archive code) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux index f04b95a6e..2f7e4ad0f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux @@ -29,12 +29,12 @@ (type: .public (Extension a) [Name (List a)]) -(def: .public equivalence +(def .public equivalence (All (_ a) (-> (Equivalence a) (Equivalence (Extension a)))) (|>> list.equivalence (product.equivalence text.equivalence))) -(def: .public hash +(def .public hash (All (_ a) (-> (Hash a) (Hash (Extension a)))) (|>> list.hash (product.hash text.hash))) @@ -48,7 +48,7 @@ (type: .public (Bundle s i o) <Bundle>)) -(def: .public empty +(def .public empty Bundle (dictionary.empty text.hash)) @@ -94,7 +94,7 @@ (type: .public (Extender s i o) (-> Any (Handler s i o))) -(def: .public (install extender name handler) +(def .public (install extender name handler) (All (_ s i o) (-> (Extender s i o) Name (Handler s i o) (Operation s i o Any))) (function (_ [bundle state]) @@ -106,7 +106,7 @@ {try.#Failure _} (exception.except ..cannot_overwrite name)))) -(def: .public (with extender extensions) +(def .public (with extender extensions) (All (_ s i o) (-> Extender (Bundle s i o) (Operation s i o Any))) (|> extensions @@ -116,7 +116,7 @@ (..install extender extension handle)) []))) -(def: .public (apply archive phase [name parameters]) +(def .public (apply archive phase [name parameters]) (All (_ s i o) (-> Archive (Phase s i o) (Extension i) (Operation s i o o))) (function (_ (^.let stateE [bundle state])) @@ -128,7 +128,7 @@ {.#None} (exception.except ..unknown [name bundle])))) -(def: .public (localized get set transform) +(def .public (localized get set transform) (All (_ s s' i o v) (-> (-> s s') (-> s' s s) (-> s' s') (-> (Operation s i o v) (Operation s i o v)))) @@ -142,7 +142,7 @@ {try.#Failure error} {try.#Failure error}))))) -(def: .public (temporary transform) +(def .public (temporary transform) (All (_ s i o v) (-> (-> s s) (-> (Operation s i o v) (Operation s i o v)))) @@ -155,24 +155,24 @@ {try.#Failure error} {try.#Failure error})))) -(def: .public (with_state state) +(def .public (with_state state) (All (_ s i o v) (-> s (-> (Operation s i o v) (Operation s i o v)))) (..temporary (function.constant state))) -(def: .public (read get) +(def .public (read get) (All (_ s i o v) (-> (-> s v) (Operation s i o v))) (function (_ [bundle state]) {try.#Success [[bundle state] (get state)]})) -(def: .public (update transform) +(def .public (update transform) (All (_ s i o) (-> (-> s s) (Operation s i o Any))) (function (_ [bundle state]) {try.#Success [[bundle (transform state)] []]})) -(def: .public (lifted action) +(def .public (lifted action) (All (_ s i o v) (-> (//.Operation s v) (Operation s i o v))) (function (_ [bundle state]) @@ -183,7 +183,7 @@ {try.#Failure error} {try.#Failure error}))) -(def: .public (up it) +(def .public (up it) (All (_ s i o v) (-> (Operation s i o v) (//.Operation s v))) (function (_ state) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis.lux index 24f8bc5bf..e11214c8b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis.lux @@ -10,7 +10,7 @@ ["[0]" / ["[1][0]" lux]]) -(def: .public (bundle eval host_specific) +(def .public (bundle eval host_specific) (-> Eval Bundle Bundle) (dictionary.composite host_specific (/lux.bundle eval))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/common_lisp.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/common_lisp.lux index 6ff29f42e..962ad9aea 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/common_lisp.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/common_lisp.lux @@ -28,7 +28,7 @@ [/// ["[0]" phase]]]]]]) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "common_lisp") (|> bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux index 8342ce912..71082e284 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux @@ -26,7 +26,7 @@ [/// ["[0]" phase]]]]]) -(def: array::new +(def array::new Handler (custom [<code>.any @@ -41,7 +41,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list lengthA)}))))])) -(def: array::length +(def array::length Handler (custom [<code>.any @@ -56,7 +56,7 @@ _ (analysis/type.inference Nat)] (in {analysis.#Extension extension (list arrayA)}))))])) -(def: array::read +(def array::read Handler (custom [(<>.and <code>.any <code>.any) @@ -73,7 +73,7 @@ _ (analysis/type.inference :read:)] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: array::write +(def array::write Handler (custom [(all <>.and <code>.any <code>.any <code>.any) @@ -92,7 +92,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list indexA valueA arrayA)}))))])) -(def: array::delete +(def array::delete Handler (custom [(all <>.and <code>.any <code>.any) @@ -109,7 +109,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: bundle::array +(def bundle::array Bundle (<| (bundle.prefix "array") (|> bundle.empty @@ -120,7 +120,7 @@ (bundle.install "delete" array::delete) ))) -(def: object::new +(def object::new Handler (custom [(all <>.and <code>.any (<code>.tuple (<>.some <code>.any))) @@ -132,7 +132,7 @@ _ (analysis/type.inference .Any)] (in {analysis.#Extension extension (list.partial constructorA inputsA)})))])) -(def: object::get +(def object::get Handler (custom [(all <>.and <code>.text <code>.any) @@ -144,7 +144,7 @@ (in {analysis.#Extension extension (list (analysis.text fieldC) objectA)})))])) -(def: object::do +(def object::do Handler (custom [(all <>.and <code>.text <code>.any (<code>.tuple (<>.some <code>.any))) @@ -158,7 +158,7 @@ objectA inputsA)})))])) -(def: bundle::object +(def bundle::object Bundle (<| (bundle.prefix "object") (|> bundle.empty @@ -171,7 +171,7 @@ (bundle.install "undefined?" (/.unary Any Bit)) ))) -(def: js::constant +(def js::constant Handler (custom [<code>.text @@ -180,7 +180,7 @@ [_ (analysis/type.inference Any)] (in {analysis.#Extension extension (list (analysis.text name))})))])) -(def: js::apply +(def js::apply Handler (custom [(all <>.and <code>.any (<code>.tuple (<>.some <code>.any))) @@ -192,7 +192,7 @@ _ (analysis/type.inference Any)] (in {analysis.#Extension extension (list.partial abstractionA inputsA)})))])) -(def: js::type_of +(def js::type_of Handler (custom [<code>.any @@ -203,7 +203,7 @@ _ (analysis/type.inference .Text)] (in {analysis.#Extension extension (list objectA)})))])) -(def: js::function +(def js::function Handler (custom [(all <>.and <code>.nat <code>.any) @@ -217,7 +217,7 @@ (in {analysis.#Extension extension (list (analysis.nat arity) abstractionA)})))])) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "js") (|> bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux index e285ff15a..645d0366c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux @@ -176,7 +176,7 @@ (exception.report "Class" (%.text class))) -(def: (ensure_fresh_class! class_loader name) +(def (ensure_fresh_class! class_loader name) (-> java/lang/ClassLoader External (Operation Any)) (do phase.monad [class (phase.lifted (reflection!.load class_loader name))] @@ -186,20 +186,20 @@ reflection!.deprecated? not)))) -(def: reflection +(def reflection (All (_ category) (-> (Type (<| Return' Value' category)) Text)) (|>> jvm.reflection reflection.reflection)) -(def: signature (|>> jvm.signature signature.signature)) +(def signature (|>> jvm.signature signature.signature)) -(def: object_class +(def object_class External "java.lang.Object") ... TODO: Get rid of this with_template block and use the definition in ... lux/ffi.jvm.lux ASAP (with_template [<name> <class>] - [(def: .public <name> + [(def .public <name> .Type {.#Primitive <class> {.#End}})] @@ -230,7 +230,7 @@ [#class External #member Text])) -(def: member +(def member (Parser Member) (all <>.and <code>.text <code>.text)) @@ -299,7 +299,7 @@ [unknown_type_var] ) -(def: bundle::conversion +(def bundle::conversion Bundle (<| (///bundle.prefix "conversion") (|> ///bundle.empty @@ -329,7 +329,7 @@ ))) (with_template [<name> <prefix> <type>] - [(def: <name> + [(def <name> Bundle (<| (///bundle.prefix (reflection.reflection <prefix>)) (|> ///bundle.empty @@ -353,7 +353,7 @@ ) (with_template [<name> <prefix> <type>] - [(def: <name> + [(def <name> Bundle (<| (///bundle.prefix (reflection.reflection <prefix>)) (|> ///bundle.empty @@ -370,7 +370,7 @@ [bundle::double reflection.double ..double] ) -(def: bundle::char +(def bundle::char Bundle (<| (///bundle.prefix (reflection.reflection reflection.char)) (|> ///bundle.empty @@ -378,7 +378,7 @@ (///bundle.install "<" (//lux.binary ..char ..char Bit)) ))) -(def: .public boxes +(def .public boxes (Dictionary External [External (Type Primitive)]) (|> (list [(reflection.reflection reflection.boolean) [box.boolean jvm.boolean]] [(reflection.reflection reflection.byte) [box.byte jvm.byte]] @@ -390,11 +390,11 @@ [(reflection.reflection reflection.char) [box.char jvm.char]]) (dictionary.of_list text.hash))) -(def: lux_array_type +(def lux_array_type (template (_ :read: :write:) [{.#Primitive (static array.type_name) (list {.#Apply :write: {.#Apply :read: _Mutable}})}])) -(def: (jvm_type luxT) +(def (jvm_type luxT) (-> .Type (Operation (Type Value))) (case luxT {.#Named name anonymousT} @@ -446,7 +446,7 @@ _ (/////analysis.except ..non_jvm_type luxT))) -(def: (jvm_array_type objectT) +(def (jvm_array_type objectT) (-> .Type (Operation (Type Array))) (do phase.monad [objectJ (jvm_type objectT)] @@ -455,7 +455,7 @@ (<text>.result parser.array) phase.lifted))) -(def: (primitive_array_length_handler primitive_type) +(def (primitive_array_length_handler primitive_type) (-> (Type Primitive) Handler) (function (_ extension_name analyse archive args) (case args @@ -471,7 +471,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) -(def: array::length::object +(def array::length::object Handler (function (_ extension_name analyse archive args) (case args @@ -493,7 +493,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) -(def: (new_primitive_array_handler primitive_type) +(def (new_primitive_array_handler primitive_type) (-> (Type Primitive) Handler) (function (_ extension_name analyse archive args) (case args @@ -508,7 +508,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) -(def: array::new::object +(def array::new::object Handler (function (_ extension_name analyse archive args) (case args @@ -530,7 +530,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) -(def: (check_parameter objectT) +(def (check_parameter objectT) (-> .Type (Operation (Type Parameter))) (case objectT (pattern (lux_array_type elementT _)) @@ -591,7 +591,7 @@ _ (/////analysis.except ..non_parameter objectT))) -(def: (check_jvm objectT) +(def (check_jvm objectT) (-> .Type (Operation (Type Value))) (case objectT {.#Primitive name {.#End}} @@ -660,7 +660,7 @@ (check_parameter objectT))) (with_template [<name> <category> <parser>] - [(def: .public (<name> mapping typeJ) + [(def .public (<name> mapping typeJ) (-> Mapping (Type <category>) (Operation .Type)) (case (|> typeJ ..signature (<text>.result (<parser> mapping))) {try.#Success check} @@ -675,7 +675,7 @@ [reflection_return Return luxT.return] ) -(def: (check_object objectT) +(def (check_object objectT) (-> .Type (Operation [External .Type])) (do [! phase.monad] [:object: (check_jvm objectT) @@ -686,13 +686,13 @@ [:object: (reflection_type luxT.fresh :object:)] (phase#in [name :object:]))))) -(def: (check_return type) +(def (check_return type) (-> .Type (Operation (Type Return))) (if (same? .Any type) (phase#in jvm.void) (check_jvm type))) -(def: (read_primitive_array_handler lux_type jvm_type) +(def (read_primitive_array_handler lux_type jvm_type) (-> .Type (Type Primitive) Handler) (function (_ extension_name analyse archive args) (case args @@ -709,7 +709,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) -(def: array::read::object +(def array::read::object Handler (function (_ extension_name analyse archive args) (case args @@ -734,7 +734,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) -(def: (write_primitive_array_handler lux_type jvm_type) +(def (write_primitive_array_handler lux_type jvm_type) (-> .Type (Type Primitive) Handler) (let [array_type {.#Primitive (|> (jvm.array jvm_type) ..reflection) (list)}] @@ -756,7 +756,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 3 (list.size args)]))))) -(def: array::write::object +(def array::write::object Handler (function (_ extension_name analyse archive args) (case args @@ -784,7 +784,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 3 (list.size args)])))) -(def: bundle::array +(def bundle::array Bundle (<| (///bundle.prefix "array") (|> ///bundle.empty @@ -834,7 +834,7 @@ (///bundle.install "object" array::write::object)))) ))) -(def: object::null +(def object::null Handler (function (_ extension_name analyse archive args) (case args @@ -848,7 +848,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 0 (list.size args)])))) -(def: object::null? +(def object::null? Handler (function (_ extension_name analyse archive args) (case args @@ -863,7 +863,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) -(def: object::synchronized +(def object::synchronized Handler (function (_ extension_name analyse archive args) (case args @@ -878,7 +878,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) -(def: (object::throw class_loader) +(def (object::throw class_loader) (-> java/lang/ClassLoader Handler) (function (_ extension_name analyse archive args) (case args @@ -898,7 +898,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) -(def: (object::class class_loader) +(def (object::class class_loader) (-> java/lang/ClassLoader Handler) (function (_ extension_name analyse archive args) (case args @@ -917,7 +917,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) -(def: (object::instance? class_loader) +(def (object::instance? class_loader) (-> java/lang/ClassLoader Handler) (..custom [(all <>.and <code>.text <code>.any) @@ -933,7 +933,7 @@ (in {/////analysis.#Extension extension_name (list (/////analysis.text sub_class) objectA)}) (/////analysis.except cannot_possibly_be_an_instance (format sub_class " !<= " object_class)))))])) -(def: (class_candidate_parents class_loader source_name fromT target_name target_class) +(def (class_candidate_parents class_loader source_name fromT target_name target_class) (-> java/lang/ClassLoader External .Type External (java/lang/Class java/lang/Object) (Operation (List [[Text .Type] Bit]))) (do [! phase.monad] [source_class (phase.lifted (reflection!.load class_loader source_name)) @@ -956,7 +956,7 @@ (array.list {.#None} (java/lang/Class::getGenericInterfaces source_class))} (array.list {.#None} (java/lang/Class::getGenericInterfaces source_class))))))) -(def: (inheritance_candidate_parents class_loader fromT target_class toT fromC) +(def (inheritance_candidate_parents class_loader fromT target_class toT fromC) (-> java/lang/ClassLoader .Type (java/lang/Class java/lang/Object) .Type Code (Operation (List [[Text .Type] Bit]))) (case fromT (pattern {.#Primitive _ (list.partial self_classT super_classT super_interfacesT+)}) @@ -972,7 +972,7 @@ _ (/////analysis.except ..cannot_cast [fromT toT fromC]))) -(def: (object::cast class_loader) +(def (object::cast class_loader) (-> java/lang/ClassLoader Handler) (function (_ extension_name analyse archive args) (case args @@ -1036,7 +1036,7 @@ _ (/////analysis.except ///.invalid_syntax [extension_name %.code args])))) -(def: (bundle::object class_loader) +(def (bundle::object class_loader) (-> java/lang/ClassLoader Bundle) (<| (///bundle.prefix "object") (|> ///bundle.empty @@ -1049,7 +1049,7 @@ (///bundle.install "cast" (object::cast class_loader)) ))) -(def: (get::static class_loader) +(def (get::static class_loader) (-> java/lang/ClassLoader Handler) (..custom [..member @@ -1069,7 +1069,7 @@ (/////analysis.text field) (/////analysis.text (..signature fieldJT)))))))])) -(def: (put::static class_loader) +(def (put::static class_loader) (-> java/lang/ClassLoader Handler) (..custom [(all <>.and ..member <code>.any) @@ -1094,7 +1094,7 @@ (/////analysis.text (..signature fieldJT)) valueA)))))])) -(def: (get::virtual class_loader) +(def (get::virtual class_loader) (-> java/lang/ClassLoader Handler) (..custom [(all <>.and ..member <code>.any) @@ -1119,7 +1119,7 @@ (/////analysis.text (..signature fieldJT)) objectA)))))])) -(def: (put::virtual class_loader) +(def (put::virtual class_loader) (-> java/lang/ClassLoader Handler) (..custom [(all <>.and ..member <code>.any <code>.any) @@ -1157,7 +1157,7 @@ {#Special} {#Interface})) -(def: (de_aliased aliasing) +(def (de_aliased aliasing) (-> Aliasing (Type Value) (Type Value)) (function (again it) (`` (<| (case (parser.var? it) @@ -1185,7 +1185,7 @@ )) it)))) -(def: (check_method aliasing class method_name method_style inputsJT method) +(def (check_method aliasing class method_name method_style inputsJT method) (-> Aliasing (java/lang/Class java/lang/Object) Text Method_Style (List (Type Value)) java/lang/reflect/Method (Operation Bit)) (do phase.monad [parameters (|> (java/lang/reflect/Method::getGenericParameterTypes method) @@ -1219,7 +1219,7 @@ same_special? same_inputs?)))) -(def: (check_constructor aliasing class inputsJT constructor) +(def (check_constructor aliasing class inputsJT constructor) (-> Aliasing (java/lang/Class java/lang/Object) (List (Type Value)) (java/lang/reflect/Constructor java/lang/Object) (Operation Bit)) (do phase.monad [parameters (|> (java/lang/reflect/Constructor::getGenericParameterTypes constructor) @@ -1232,11 +1232,11 @@ (jvm#= expectedJC (de_aliased aliasing actualJC))) (list.zipped_2 parameters inputsJT)))))) -(def: index_parameter +(def index_parameter (-> Nat .Type) (|>> (n.* 2) ++ {.#Parameter})) -(def: (jvm_type_var_mapping owner_tvars method_tvars) +(def (jvm_type_var_mapping owner_tvars method_tvars) (-> (List Text) (List Text) [(List .Type) Mapping]) (let [jvm_tvars (list#composite owner_tvars method_tvars) lux_tvars (|> jvm_tvars @@ -1250,12 +1250,12 @@ mapping (dictionary.of_list text.hash lux_tvars)] [owner_tvarsT mapping])) -(def: (lux_class it) +(def (lux_class it) (-> (java/lang/Class java/lang/Object) (Type Class)) (jvm.class (java/lang/Class::getName it) (list))) (with_template [<name> <type> <params>] - [(`` (def: <name> + [(`` (def <name> (-> (<type> (~~ (template.spliced <params>))) (List (Type Class))) (|>> (~~ (template.symbol [<type> "::getExceptionTypes"])) (array.list {.#None}) @@ -1265,7 +1265,7 @@ [concrete_constructor_exceptions java/lang/reflect/Constructor [java/lang/Object]] ) -(def: (return_type it) +(def (return_type it) (-> java/lang/reflect/Method (Try (Type Return))) (reflection!.return (case (java/lang/reflect/Method::getGenericReturnType it) @@ -1275,7 +1275,7 @@ {.#None} (java/lang/reflect/Method::getReturnType it)))) -(def: (method_signature method_style method) +(def (method_signature method_style method) (-> Method_Style java/lang/reflect/Method (Operation Method_Signature)) (let [owner (java/lang/reflect/Method::getDeclaringClass method) owner_tvars (case method_style @@ -1323,7 +1323,7 @@ concrete_exceptions generic_exceptions)])))) -(def: (constructor_signature constructor) +(def (constructor_signature constructor) (-> (java/lang/reflect/Constructor java/lang/Object) (Operation Method_Signature)) (let [owner (java/lang/reflect/Constructor::getDeclaringClass constructor) owner_tvars (|> (java/lang/Class::getTypeParameters owner) @@ -1362,7 +1362,7 @@ {#Hint Method_Signature})) (with_template [<name> <tag>] - [(def: <name> + [(def <name> (-> Evaluation (Maybe Method_Signature)) (|>> (pipe.case {<tag> output} @@ -1376,7 +1376,7 @@ ) (with_template [<name> <type> <method>] - [(def: <name> + [(def <name> (-> <type> (List (Type Var))) (|>> <method> (array.list {.#None}) @@ -1387,13 +1387,13 @@ [method_type_variables java/lang/reflect/Method java/lang/reflect/Method::getTypeParameters] ) -(def: (aliasing expected actual) +(def (aliasing expected actual) (-> (List (Type Var)) (List (Type Var)) Aliasing) (|> (list.zipped_2 (list#each parser.name actual) (list#each parser.name expected)) (dictionary.of_list text.hash))) -(def: (family_tree' it) +(def (family_tree' it) (-> (java/lang/Class java/lang/Object) (List (java/lang/Class java/lang/Object))) (let [interfaces (array.list {.#None} (java/lang/Class::getInterfaces it)) @@ -1408,7 +1408,7 @@ list#conjoint (list.partial it)))) -(def: family_tree +(def family_tree (-> (java/lang/Class java/lang/Object) (List (java/lang/Class java/lang/Object))) (|>> ..family_tree' @@ -1418,7 +1418,7 @@ (dictionary.empty text.hash)) dictionary.values)) -(def: (all_declared_methods it) +(def (all_declared_methods it) (-> (java/lang/Class java/lang/Object) (List java/lang/reflect/Method)) (|> it @@ -1426,7 +1426,7 @@ (list#each (|>> java/lang/Class::getDeclaredMethods (array.list {.#None}))) list#conjoint)) -(def: (method_candidate allow_inheritance? class_loader actual_class_tvars class_name actual_method_tvars method_name method_style inputsJT) +(def (method_candidate allow_inheritance? class_loader actual_class_tvars class_name actual_method_tvars method_name method_style inputsJT) (-> Bit java/lang/ClassLoader (List (Type Var)) External (List (Type Var)) Text Method_Style (List (Type Value)) (Operation Method_Signature)) (do [! phase.monad] [class (phase.lifted (reflection!.load class_loader class_name)) @@ -1458,10 +1458,10 @@ (in method) (/////analysis.except ..too_many_candidates [actual_class_tvars class_name method_name actual_method_tvars inputsJT (list.partial method alternatives)]))))) -(def: constructor_method +(def constructor_method "<init>") -(def: (constructor_candidate class_loader actual_class_tvars class_name actual_method_tvars inputsJT) +(def (constructor_candidate class_loader actual_class_tvars class_name actual_method_tvars inputsJT) (-> java/lang/ClassLoader (List (Type Var)) External (List (Type Var)) (List (Type Value)) (Operation Method_Signature)) (do [! phase.monad] [class (phase.lifted (reflection!.load class_loader class_name)) @@ -1491,7 +1491,7 @@ (/////analysis.except ..too_many_candidates [actual_class_tvars class_name ..constructor_method actual_method_tvars inputsJT candidates])))) (with_template [<name> <category> <parser>] - [(def: .public <name> + [(def .public <name> (Parser (Type <category>)) (<text>.then <parser> <code>.text))] @@ -1501,21 +1501,21 @@ [return Return parser.return] ) -(def: input +(def input (Parser (Typed Code)) (<code>.tuple (<>.and ..type <code>.any))) -(def: (decorate_inputs typesT inputsA) +(def (decorate_inputs typesT inputsA) (-> (List (Type Value)) (List Analysis) (List Analysis)) (|> inputsA (list.zipped_2 (list#each (|>> ..signature /////analysis.text) typesT)) (list#each (function (_ [type value]) (/////analysis.tuple (list type value)))))) -(def: type_vars +(def type_vars (<code>.tuple (<>.some ..var))) -(def: (invoke::static class_loader) +(def (invoke::static class_loader) (-> java/lang/ClassLoader Handler) (..custom [(all <>.and ..type_vars ..member ..type_vars (<>.some ..input)) @@ -1533,7 +1533,7 @@ (/////analysis.text (..signature outputJT)) (decorate_inputs argsT argsA))})))])) -(def: (invoke::virtual class_loader) +(def (invoke::virtual class_loader) (-> java/lang/ClassLoader Handler) (..custom [(all <>.and ..type_vars ..member ..type_vars <code>.any (<>.some ..input)) @@ -1558,7 +1558,7 @@ objectA (decorate_inputs argsT argsA))})))])) -(def: (invoke::special class_loader) +(def (invoke::special class_loader) (-> java/lang/ClassLoader Handler) (..custom [(all <>.and ..type_vars ..member ..type_vars <code>.any (<>.some ..input)) @@ -1583,7 +1583,7 @@ objectA (decorate_inputs argsT argsA))})))])) -(def: (invoke::interface class_loader) +(def (invoke::interface class_loader) (-> java/lang/ClassLoader Handler) (..custom [(all <>.and ..type_vars ..member ..type_vars <code>.any (<>.some ..input)) @@ -1612,7 +1612,7 @@ objectA (decorate_inputs argsT argsA))})))])) -(def: (invoke::constructor class_loader) +(def (invoke::constructor class_loader) (-> java/lang/ClassLoader Handler) (..custom [(all <>.and ..type_vars <code>.text ..type_vars (<>.some ..input)) @@ -1627,7 +1627,7 @@ (in {/////analysis.#Extension extension_name (list.partial (/////analysis.text (..signature (jvm.class class (list)))) (decorate_inputs argsT argsA))})))])) -(def: (bundle::member class_loader) +(def (bundle::member class_loader) (-> java/lang/ClassLoader Bundle) (<| (///bundle.prefix "member") (|> ///bundle.empty @@ -1652,32 +1652,32 @@ (type: .public (Annotation_Parameter a) [Text a]) -(def: annotation_parameter +(def annotation_parameter (Parser (Annotation_Parameter Code)) (<code>.tuple (<>.and <code>.text <code>.any))) (type: .public (Annotation a) [Text (List (Annotation_Parameter a))]) -(def: .public annotation +(def .public annotation (Parser (Annotation Code)) (<code>.form (<>.and <code>.text (<>.some ..annotation_parameter)))) -(def: .public argument +(def .public argument (Parser Argument) (<code>.tuple (<>.and <code>.text ..type))) -(def: (annotation_parameter_analysis [name value]) +(def (annotation_parameter_analysis [name value]) (-> (Annotation_Parameter Analysis) Analysis) (/////analysis.tuple (list (/////analysis.text name) value))) -(def: (annotation_analysis [name parameters]) +(def (annotation_analysis [name parameters]) (-> (Annotation Analysis) Analysis) (/////analysis.tuple (list.partial (/////analysis.text name) (list#each annotation_parameter_analysis parameters)))) (with_template [<name> <category>] - [(def: <name> + [(def <name> (-> (Type <category>) Analysis) (|>> ..signature /////analysis.text))] @@ -1687,18 +1687,18 @@ [return_analysis Return] ) -(def: (typed_analysis [type term]) +(def (typed_analysis [type term]) (-> (Typed Analysis) Analysis) (/////analysis.tuple (list (value_analysis type) term))) -(def: (argument_analysis [argument argumentJT]) +(def (argument_analysis [argument argumentJT]) (-> Argument Analysis) (/////analysis.tuple (list (/////analysis.text argument) (value_analysis argumentJT)))) (with_template [<name> <only> <methods>] - [(def: (<name> [type class]) + [(def (<name> [type class]) (-> [(Type Class) (java/lang/Class java/lang/Object)] (Try (List [(Type Class) Text (Type Method)]))) (|> class @@ -1734,10 +1734,10 @@ ..all_declared_methods] ) -(def: jvm_package_separator ".") +(def jvm_package_separator ".") (with_template [<name> <methods>] - [(def: (<name> class_loader) + [(def (<name> class_loader) (-> java/lang/ClassLoader (List (Type Class)) (Try (List [(Type Class) Text (Type Method)]))) (|>> (monad.each try.monad (function (_ type) (|> type @@ -1776,12 +1776,12 @@ (type: .public Finality Bit) (type: .public Strictness Bit) -(def: .public public_tag "public") -(def: .public private_tag "private") -(def: .public protected_tag "protected") -(def: .public default_tag "default") +(def .public public_tag "public") +(def .public private_tag "private") +(def .public protected_tag "protected") +(def .public default_tag "default") -(def: .public visibility' +(def .public visibility' (<text>.Parser Visibility) (all <>.or (<text>.this ..public_tag) @@ -1790,11 +1790,11 @@ (<text>.this ..default_tag) )) -(def: .public visibility +(def .public visibility (Parser Visibility) (<text>.then ..visibility' <code>.text)) -(def: .public (visibility_analysis visibility) +(def .public (visibility_analysis visibility) (-> Visibility Analysis) (/////analysis.text (case visibility {#Public} ..public_tag @@ -1805,7 +1805,7 @@ (type: Exception (Type Class)) -(def: .public parameter_types +(def .public parameter_types (-> (List (Type Var)) (Check (List [(Type Var) .Type]))) (monad.each check.monad (function (_ parameterJ) @@ -1822,9 +1822,9 @@ (Type Return) (List Exception)]) -(def: .public abstract_tag "abstract") +(def .public abstract_tag "abstract") -(def: .public abstract_method_definition +(def .public abstract_method_definition (Parser (Abstract_Method Code)) (<| <code>.form (<>.after (<code>.this_text ..abstract_tag)) @@ -1837,7 +1837,7 @@ ..return (<code>.tuple (<>.some ..class))))) -(def: (method_mapping of_class parameters) +(def (method_mapping of_class parameters) (-> Mapping (List (Type Var)) (Check Mapping)) (|> parameters ..parameter_types @@ -1845,11 +1845,11 @@ (dictionary.has (parser.name parameterJ) parameterT mapping)) of_class)))) -(def: class_mapping +(def class_mapping (-> (List (Type Var)) (Check Mapping)) (..method_mapping luxT.fresh)) -(def: .public (analyse_abstract_method analyse archive method) +(def .public (analyse_abstract_method analyse archive method) (-> Phase Archive (Abstract_Method Code) (Operation Analysis)) (let [[method_name visibility annotations vars arguments return exceptions] method] (do [! phase.monad] @@ -1884,9 +1884,9 @@ (List (Typed a)) a]) -(def: .public constructor_tag "init") +(def .public constructor_tag "init") -(def: .public constructor_definition +(def .public constructor_definition (Parser (Constructor Code)) (<| <code>.form (<>.after (<code>.this_text ..constructor_tag)) @@ -1901,7 +1901,7 @@ (<code>.tuple (<>.some ..input)) <code>.any))) -(def: .public (analyse_constructor_method analyse archive selfT mapping method) +(def .public (analyse_constructor_method analyse archive selfT mapping method) (-> Phase Archive .Type Mapping (Constructor Code) (Operation Analysis)) (let [[visibility strict_fp? annotations vars exceptions @@ -1964,9 +1964,9 @@ (List Exception) a]) -(def: .public virtual_tag "virtual") +(def .public virtual_tag "virtual") -(def: .public virtual_method_definition +(def .public virtual_method_definition (Parser (Virtual_Method Code)) (<| <code>.form (<>.after (<code>.this_text ..virtual_tag)) @@ -1992,7 +1992,7 @@ #arguments (List (Type Value)) #return (Type Return)])) -(def: .public method_declaration +(def .public method_declaration (Parser (Method_Declaration Code)) (<code>.form (all <>.and @@ -2004,7 +2004,7 @@ ..return ))) -(def: .public (analyse_virtual_method analyse archive selfT mapping method) +(def .public (analyse_virtual_method analyse archive selfT mapping method) (-> Phase Archive .Type Mapping (Virtual_Method Code) (Operation Analysis)) (let [[method_name visibility final? strict_fp? annotations vars @@ -2062,9 +2062,9 @@ (List Exception) a]) -(def: .public static_tag "static") +(def .public static_tag "static") -(def: .public static_method_definition +(def .public static_method_definition (Parser (Static_Method Code)) (<| <code>.form (<>.after (<code>.this_text ..static_tag)) @@ -2079,7 +2079,7 @@ (<code>.tuple (<>.some ..class)) <code>.any))) -(def: .public (analyse_static_method analyse archive mapping method) +(def .public (analyse_static_method analyse archive mapping method) (-> Phase Archive Mapping (Static_Method Code) (Operation Analysis)) (let [[method_name visibility strict_fp? annotations vars @@ -2136,9 +2136,9 @@ (List (Type Class)) a]) -(def: .public overriden_tag "override") +(def .public overriden_tag "override") -(def: .public overriden_method_definition +(def .public overriden_method_definition (Parser (Overriden_Method Code)) (<| <code>.form (<>.after (<code>.this_text ..overriden_tag)) @@ -2169,7 +2169,7 @@ "Expected" (%.nat expected) "Actual" (%.nat actual))) -(def: (override_mapping mapping supers parent_type) +(def (override_mapping mapping supers parent_type) (-> Mapping (List (Type Class)) (Type Class) (Operation (List [Text .Type]))) (let [[parent_name parent_parameters] (parser.read_class parent_type)] (case (list.one (function (_ super) @@ -2195,7 +2195,7 @@ {.#None} (phase.lifted (exception.except ..unknown_super [parent_name supers]))))) -(def: .public (with_override_mapping supers parent_type mapping) +(def .public (with_override_mapping supers parent_type mapping) (-> (List (Type Class)) (Type Class) Mapping (Operation Mapping)) (do phase.monad [override_mapping (..override_mapping mapping supers parent_type)] @@ -2204,7 +2204,7 @@ mapping override_mapping)))) -(def: .public (hidden_method_body arity bodyA) +(def .public (hidden_method_body arity bodyA) (-> Nat Analysis Analysis) (<| /////analysis.tuple (list (/////analysis.unit)) @@ -2236,7 +2236,7 @@ (/////analysis.tuple (list forced_refencing bodyA))] (list)]})))) -(def: (with_fake_parameter#pattern it) +(def (with_fake_parameter#pattern it) (-> pattern.Pattern pattern.Pattern) (case it {pattern.#Simple _} @@ -2254,7 +2254,7 @@ {pattern.#Bind it} {pattern.#Bind (++ it)})) -(def: (with_fake_parameter it) +(def (with_fake_parameter it) (-> Analysis Analysis) (case it {/////analysis.#Simple _} @@ -2304,7 +2304,7 @@ {/////analysis.#Extension name (list#each with_fake_parameter parameters)})) -(def: .public (analyse_overriden_method analyse archive selfT mapping supers method) +(def .public (analyse_overriden_method analyse archive selfT mapping supers method) (-> Phase Archive .Type Mapping (List (Type Class)) (Overriden_Method Code) (Operation Analysis)) (let [[parent_type method_name strict_fp? annotations vars @@ -2356,13 +2356,13 @@ _ bodyA))} )))))) -(def: (matched? [sub sub_method subJT] [super super_method superJT]) +(def (matched? [sub sub_method subJT] [super super_method superJT]) (-> [(Type Class) Text (Type Method)] [(Type Class) Text (Type Method)] Bit) (and (at descriptor.equivalence = (jvm.descriptor super) (jvm.descriptor sub)) (text#= super_method sub_method) (jvm#= superJT subJT))) -(def: (mismatched_methods super_set sub_set) +(def (mismatched_methods super_set sub_set) (-> (List [(Type Class) Text (Type Method)]) (List [(Type Class) Text (Type Method)]) (List [(Type Class) Text (Type Method)])) @@ -2382,7 +2382,7 @@ "Actual (amount)" (%.nat (list.size actual)) "Actual (parameters)" (exception.listing ..signature actual))) -(def: (super_aliasing class_loader class) +(def (super_aliasing class_loader class) (-> java/lang/ClassLoader (Type Class) (Operation Aliasing)) (do phase.monad [.let [[name actual_parameters] (parser.read_class class)] @@ -2403,13 +2403,13 @@ mapping)) alias.fresh))))) -(def: (anonymous_class_name module id) +(def (anonymous_class_name module id) (-> Module Nat Text) (let [global (text.replaced .module_separator ..jvm_package_separator module) local (format "anonymous-class" (%.nat id))] (format global ..jvm_package_separator local))) -(def: .public (require_complete_method_concretion class_loader supers methods) +(def .public (require_complete_method_concretion class_loader supers methods) (-> java/lang/ClassLoader (List (Type Class)) (List (Overriden_Method Code)) (Operation Any)) (do [! phase.monad] [required_abstract_methods (phase.lifted (all_abstract_methods class_loader supers)) @@ -2457,10 +2457,10 @@ {#Overriden_Method (..Overriden_Method a)} {#Abstract_Method (..Abstract_Method a)})) -(def: class_name +(def class_name (|>> parser.read_class product.left name.internal)) -(def: (mock_class [name parameters] super interfaces fields methods modifier) +(def (mock_class [name parameters] super interfaces fields methods modifier) (-> Declaration (Type Class) (List (Type Class)) (List (Resource field.Field)) (List (Resource method.Method)) (Modifier class.Class) (Try [External Binary])) @@ -2481,7 +2481,7 @@ methods sequence.empty)))) -(def: constant::modifier +(def constant::modifier (Modifier field.Field) (all modifier#composite field.public @@ -2489,7 +2489,7 @@ field.final )) -(def: (field_definition field) +(def (field_definition field) (-> Field (Resource field.Field)) (case field ... TODO: Handle annotations. @@ -2521,7 +2521,7 @@ (field.field (modifier#composite visibility state) name #1 type sequence.empty))) -(def: method_privacy +(def method_privacy (-> ffi.Privacy (Modifier method.Method)) (|>> (pipe.case {ffi.#PublicP} method.public @@ -2529,10 +2529,10 @@ {ffi.#ProtectedP} method.protected {ffi.#DefaultP} modifier.empty))) -(def: constructor_name +(def constructor_name "<init>") -(def: (mock_value valueT) +(def (mock_value valueT) (-> (Type Value) (Bytecode Any)) (case (jvm.primitive? valueT) {.#Left classT} @@ -2551,7 +2551,7 @@ ... jvm.boolean jvm.byte jvm.short jvm.int jvm.char _.iconst_0))) -(def: (mock_return :return:) +(def (mock_return :return:) (-> (Type Return) (Bytecode Any)) (case (jvm.void? :return:) {.#Right :return:} @@ -2577,7 +2577,7 @@ ... jvm.boolean jvm.byte jvm.short jvm.int jvm.char _.ireturn))))) -(def: (mock_method super method) +(def (mock_method super method) (-> (Type Class) (Method_Definition Code) (Resource method.Method)) (case method {#Constructor [privacy strict_floating_point? annotations variables exceptions @@ -2655,7 +2655,7 @@ {.#None}) )) -(def: (mock declaration super interfaces inheritance fields methods) +(def (mock declaration super interfaces inheritance fields methods) (-> Declaration (Type Class) (List (Type Class)) (Modifier class.Class) (List ..Field) (List (Method_Definition Code)) @@ -2665,7 +2665,7 @@ (list#each (..mock_method super) methods) inheritance)) -(def: (class::anonymous class_loader host) +(def (class::anonymous class_loader host) (-> java/lang/ClassLoader runtime.Host Handler) (..custom [(all <>.and @@ -2720,14 +2720,14 @@ (/////analysis.tuple (list#each typed_analysis constructor_argsA+)) (/////analysis.tuple methodsA))})))])) -(def: (bundle::class class_loader host) +(def (bundle::class class_loader host) (-> java/lang/ClassLoader runtime.Host Bundle) (<| (///bundle.prefix "class") (|> ///bundle.empty (///bundle.install "anonymous" (class::anonymous class_loader host)) ))) -(def: .public (bundle class_loader host) +(def .public (bundle class_loader host) (-> java/lang/ClassLoader runtime.Host Bundle) (<| (///bundle.prefix "jvm") (|> ///bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux index fa08d5be0..3b58108c8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux @@ -26,19 +26,19 @@ [/// ["[0]" phase]]]]]) -(def: Nil +(def Nil (for @.lua ffi.Nil Any)) -(def: Object +(def Object (for @.lua (type (ffi.Object Any)) Any)) -(def: Function +(def Function (for @.lua ffi.Function Any)) -(def: array::new +(def array::new Handler (custom [<code>.any @@ -53,7 +53,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list lengthA)}))))])) -(def: array::length +(def array::length Handler (custom [<code>.any @@ -68,7 +68,7 @@ _ (analysis/type.inference Nat)] (in {analysis.#Extension extension (list arrayA)}))))])) -(def: array::read +(def array::read Handler (custom [(<>.and <code>.any <code>.any) @@ -85,7 +85,7 @@ _ (analysis/type.inference :read:)] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: array::write +(def array::write Handler (custom [(all <>.and <code>.any <code>.any <code>.any) @@ -104,7 +104,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list indexA valueA arrayA)}))))])) -(def: array::delete +(def array::delete Handler (custom [(all <>.and <code>.any <code>.any) @@ -121,7 +121,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: bundle::array +(def bundle::array Bundle (<| (bundle.prefix "array") (|> bundle.empty @@ -132,7 +132,7 @@ (bundle.install "delete" array::delete) ))) -(def: object::get +(def object::get Handler (custom [(all <>.and <code>.text <code>.any) @@ -144,7 +144,7 @@ (in {analysis.#Extension extension (list (analysis.text fieldC) objectA)})))])) -(def: object::do +(def object::do Handler (custom [(all <>.and <code>.text <code>.any (<code>.tuple (<>.some <code>.any))) @@ -158,7 +158,7 @@ objectA inputsA)})))])) -(def: bundle::object +(def bundle::object Bundle (<| (bundle.prefix "object") (|> bundle.empty @@ -169,7 +169,7 @@ ))) (with_template [<name> <fromT> <toT>] - [(def: <name> + [(def <name> Handler (custom [<code>.any @@ -184,7 +184,7 @@ [utf8::decode (array.Array (I64 Any)) Text] ) -(def: bundle::utf8 +(def bundle::utf8 Bundle (<| (bundle.prefix "utf8") (|> bundle.empty @@ -192,7 +192,7 @@ (bundle.install "decode" utf8::decode) ))) -(def: lua::constant +(def lua::constant Handler (custom [<code>.text @@ -201,7 +201,7 @@ [_ (analysis/type.inference Any)] (in {analysis.#Extension extension (list (analysis.text name))})))])) -(def: lua::apply +(def lua::apply Handler (custom [(all <>.and <code>.any (<code>.tuple (<>.some <code>.any))) @@ -213,7 +213,7 @@ _ (analysis/type.inference Any)] (in {analysis.#Extension extension (list.partial abstractionA inputsA)})))])) -(def: lua::power +(def lua::power Handler (custom [(all <>.and <code>.any <code>.any) @@ -226,7 +226,7 @@ _ (analysis/type.inference Frac)] (in {analysis.#Extension extension (list powerA baseA)})))])) -(def: lua::import +(def lua::import Handler (custom [<code>.text @@ -235,7 +235,7 @@ [_ (analysis/type.inference ..Object)] (in {analysis.#Extension extension (list (analysis.text name))})))])) -(def: lua::function +(def lua::function Handler (custom [(all <>.and <code>.nat <code>.any) @@ -248,7 +248,7 @@ (in {analysis.#Extension extension (list (analysis.nat arity) abstractionA)})))])) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "lua") (|> bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux index f261cbcad..f201ff72b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux @@ -35,7 +35,7 @@ [meta [archive (.only Archive)]]]]]]) -(def: .public (custom [syntax handler]) +(def .public (custom [syntax handler]) (All (_ s) (-> [(Parser s) (-> Text Phase Archive s (Operation Analysis))] @@ -48,7 +48,7 @@ {try.#Failure _} (////analysis.except ///.invalid_syntax [extension_name %.code args])))) -(def: (simple inputsT+ outputT) +(def (simple inputsT+ outputT) (-> (List Type) Type Handler) (let [num_expected (list.size inputsT+)] (function (_ extension_name analyse archive args) @@ -64,19 +64,19 @@ (in {////analysis.#Extension extension_name argsA})) (////analysis.except ///.incorrect_arity [extension_name num_expected num_actual])))))) -(def: .public (nullary valueT) +(def .public (nullary valueT) (-> Type Handler) (simple (list) valueT)) -(def: .public (unary inputT outputT) +(def .public (unary inputT outputT) (-> Type Type Handler) (simple (list inputT) outputT)) -(def: .public (binary subjectT paramT outputT) +(def .public (binary subjectT paramT outputT) (-> Type Type Type Handler) (simple (list subjectT paramT) outputT)) -(def: .public (trinary subjectT param0T param1T outputT) +(def .public (trinary subjectT param0T param1T outputT) (-> Type Type Type Type Handler) (simple (list subjectT param0T param1T) outputT)) @@ -86,7 +86,7 @@ (exception.report "Text" (%.text text))) - (def: text_char + (def text_char (Parser text.Char) (do <>.monad [raw <code>.text] @@ -94,7 +94,7 @@ 1 (in (|> raw (text.char 0) maybe.trusted)) _ (<>.failure (exception.error ..char_text_must_be_size_1 [raw]))))) - (def: lux::syntax_char_case! + (def lux::syntax_char_case! (..custom [(all <>.and <code>.any @@ -123,7 +123,7 @@ {////analysis.#Extension extension_name}))))]))) ... "lux is" represents reference/pointer equality. -(def: lux::is +(def lux::is Handler (function (_ extension_name analyse archive args) (<| typeA.with_var @@ -133,7 +133,7 @@ ... "lux try" provides a simple way to interact with the host platform's ... error_handling facilities. -(def: lux::try +(def lux::try Handler (function (_ extension_name analyse archive args) (case args @@ -150,7 +150,7 @@ _ (////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) -(def: lux::in_module +(def lux::in_module Handler (function (_ extension_name analyse archive argsC+) (case argsC+ @@ -161,7 +161,7 @@ _ (////analysis.except ///.invalid_syntax [extension_name %.code argsC+])))) -(def: (lux::type::check eval) +(def (lux::type::check eval) (-> Eval Handler) (function (_ extension_name analyse archive args) (case args @@ -176,7 +176,7 @@ _ (////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) -(def: (lux::type::as eval) +(def (lux::type::as eval) (-> Eval Handler) (function (_ extension_name analyse archive args) (case args @@ -192,7 +192,7 @@ _ (////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) -(def: (caster input output) +(def (caster input output) (-> Type Type Handler) (..custom [<code>.any @@ -206,7 +206,7 @@ (exception.report "Symbol" (%.symbol symbol))) -(def: lux::macro +(def lux::macro Handler (..custom [<code>.any @@ -230,7 +230,7 @@ (<| (typeA.expecting input_type) (phase archive valueC))))])) -(def: (bundle::lux eval) +(def (bundle::lux eval) (-> Eval Bundle) (|> ///bundle.empty (///bundle.install "syntax char case!" lux::syntax_char_case!) @@ -242,7 +242,7 @@ (///bundle.install "type check type" (..caster .Type .Type)) (///bundle.install "in-module" lux::in_module))) -(def: bundle::io +(def bundle::io Bundle (<| (///bundle.prefix "io") (|> ///bundle.empty @@ -250,10 +250,10 @@ (///bundle.install "error" (unary Text Nothing)) (///bundle.install "exit" (unary Int Nothing))))) -(def: I64* +(def I64* (type (I64 Any))) -(def: bundle::i64 +(def bundle::i64 Bundle (<| (///bundle.prefix "i64") (|> ///bundle.empty @@ -272,7 +272,7 @@ (///bundle.install "f64" (unary Int Frac)) (///bundle.install "char" (unary Int Text))))) -(def: bundle::f64 +(def bundle::f64 Bundle (<| (///bundle.prefix "f64") (|> ///bundle.empty @@ -287,7 +287,7 @@ (///bundle.install "encode" (unary Frac Text)) (///bundle.install "decode" (unary Text (type (Maybe Frac))))))) -(def: bundle::text +(def bundle::text Bundle (<| (///bundle.prefix "text") (|> ///bundle.empty @@ -300,7 +300,7 @@ (///bundle.install "clip" (trinary Nat Nat Text Text)) ))) -(def: .public (bundle eval) +(def .public (bundle eval) (-> Eval Bundle) (<| (///bundle.prefix "lux") (|> ///bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux index 5512587e7..d2f402d79 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux @@ -28,7 +28,7 @@ [/// ["[0]" phase]]]]]]) -(def: array::new +(def array::new Handler (custom [<c>.any @@ -41,7 +41,7 @@ _ (analysis/type.infer (type (Array :var:)))] (in {analysis.#Extension extension (list lengthA)}))))])) -(def: array::length +(def array::length Handler (custom [<c>.any @@ -54,7 +54,7 @@ _ (analysis/type.infer Nat)] (in {analysis.#Extension extension (list arrayA)}))))])) -(def: array::read +(def array::read Handler (custom [(<>.and <c>.any <c>.any) @@ -69,7 +69,7 @@ _ (analysis/type.infer :var:)] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: array::write +(def array::write Handler (custom [(all <>.and <c>.any <c>.any <c>.any) @@ -86,7 +86,7 @@ _ (analysis/type.infer (type (Array :var:)))] (in {analysis.#Extension extension (list indexA valueA arrayA)}))))])) -(def: array::delete +(def array::delete Handler (custom [(all <>.and <c>.any <c>.any) @@ -101,7 +101,7 @@ _ (analysis/type.infer (type (Array :var:)))] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: bundle::array +(def bundle::array Bundle (<| (bundle.prefix "array") (|> bundle.empty @@ -112,19 +112,19 @@ (bundle.install "delete" array::delete) ))) -(def: Null +(def Null (for @.php ffi.Null Any)) -(def: Object +(def Object (for @.php (type (ffi.Object Any)) Any)) -(def: Function +(def Function (for @.php ffi.Function Any)) -(def: object::new +(def object::new Handler (custom [(all <>.and <c>.text (<>.some <c>.any)) @@ -134,7 +134,7 @@ _ (analysis/type.infer .Any)] (in {analysis.#Extension extension (list.partial (analysis.text constructor) inputsA)})))])) -(def: object::get +(def object::get Handler (custom [(all <>.and <c>.text <c>.any) @@ -146,7 +146,7 @@ (in {analysis.#Extension extension (list (analysis.text fieldC) objectA)})))])) -(def: object::do +(def object::do Handler (custom [(all <>.and <c>.text <c>.any (<>.some <c>.any)) @@ -160,7 +160,7 @@ objectA inputsA)})))])) -(def: bundle::object +(def bundle::object Bundle (<| (bundle.prefix "object") (|> bundle.empty @@ -171,7 +171,7 @@ (bundle.install "null?" (/.unary Any Bit)) ))) -(def: php::constant +(def php::constant Handler (custom [<c>.text @@ -180,7 +180,7 @@ [_ (analysis/type.infer Any)] (in {analysis.#Extension extension (list (analysis.text name))})))])) -(def: php::apply +(def php::apply Handler (custom [(all <>.and <c>.any (<>.some <c>.any)) @@ -192,7 +192,7 @@ _ (analysis/type.infer Any)] (in {analysis.#Extension extension (list.partial abstractionA inputsA)})))])) -(def: php::pack +(def php::pack Handler (custom [(all <>.and <c>.any <c>.any) @@ -205,7 +205,7 @@ _ (analysis/type.infer Text)] (in {analysis.#Extension extension (list formatA dataA)})))])) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "php") (|> bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux index aa2944967..96d175553 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux @@ -26,7 +26,7 @@ [/// ["[0]" phase]]]]]) -(def: array::new +(def array::new Handler (custom [<code>.any @@ -41,7 +41,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list lengthA)}))))])) -(def: array::length +(def array::length Handler (custom [<code>.any @@ -56,7 +56,7 @@ _ (analysis/type.inference Nat)] (in {analysis.#Extension extension (list arrayA)}))))])) -(def: array::read +(def array::read Handler (custom [(<>.and <code>.any <code>.any) @@ -73,7 +73,7 @@ _ (analysis/type.inference :read:)] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: array::write +(def array::write Handler (custom [(all <>.and <code>.any <code>.any <code>.any) @@ -92,7 +92,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list indexA valueA arrayA)}))))])) -(def: array::delete +(def array::delete Handler (custom [(all <>.and <code>.any <code>.any) @@ -109,7 +109,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: bundle::array +(def bundle::array Bundle (<| (bundle.prefix "array") (|> bundle.empty @@ -120,23 +120,23 @@ (bundle.install "delete" array::delete) ))) -(def: None +(def None (for @.python ffi.None Any)) -(def: Object +(def Object (for @.python (type (ffi.Object Any)) Any)) -(def: Function +(def Function (for @.python ffi.Function Any)) -(def: Dict +(def Dict (for @.python ffi.Dict Any)) -(def: object::get +(def object::get Handler (custom [(all <>.and <code>.text <code>.any) @@ -148,7 +148,7 @@ (in {analysis.#Extension extension (list (analysis.text fieldC) objectA)})))])) -(def: object::do +(def object::do Handler (custom [(all <>.and <code>.text <code>.any (<code>.tuple (<>.some <code>.any))) @@ -162,7 +162,7 @@ objectA inputsA)})))])) -(def: bundle::object +(def bundle::object Bundle (<| (bundle.prefix "object") (|> bundle.empty @@ -172,7 +172,7 @@ (bundle.install "none?" (/.unary Any Bit)) ))) -(def: python::constant +(def python::constant Handler (custom [<code>.text @@ -181,7 +181,7 @@ [_ (analysis/type.inference Any)] (in {analysis.#Extension extension (list (analysis.text name))})))])) -(def: python::import +(def python::import Handler (custom [<code>.text @@ -190,7 +190,7 @@ [_ (analysis/type.inference ..Object)] (in {analysis.#Extension extension (list (analysis.text name))})))])) -(def: python::apply +(def python::apply Handler (custom [(all <>.and <code>.any (<code>.tuple (<>.some <code>.any))) @@ -202,7 +202,7 @@ _ (analysis/type.inference Any)] (in {analysis.#Extension extension (list.partial abstractionA inputsA)})))])) -(def: python::function +(def python::function Handler (custom [(all <>.and <code>.nat <code>.any) @@ -215,7 +215,7 @@ (in {analysis.#Extension extension (list (analysis.nat arity) abstractionA)})))])) -(def: python::exec +(def python::exec Handler (custom [(all <>.and <code>.any <code>.any) @@ -228,7 +228,7 @@ _ (analysis/type.inference .Any)] (in {analysis.#Extension extension (list codeA globalsA)})))])) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "python") (|> bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/r.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/r.lux index c9e983ddd..5e2f27c47 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/r.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/r.lux @@ -28,7 +28,7 @@ [/// ["[0]" phase]]]]]]) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "r") (|> bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux index 01895a3e7..c75faf63a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux @@ -26,7 +26,7 @@ [/// ["[0]" phase]]]]]) -(def: array::new +(def array::new Handler (custom [<code>.any @@ -41,7 +41,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list lengthA)}))))])) -(def: array::length +(def array::length Handler (custom [<code>.any @@ -56,7 +56,7 @@ _ (analysis/type.inference Nat)] (in {analysis.#Extension extension (list arrayA)}))))])) -(def: array::read +(def array::read Handler (custom [(<>.and <code>.any <code>.any) @@ -73,7 +73,7 @@ _ (analysis/type.inference :read:)] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: array::write +(def array::write Handler (custom [(all <>.and <code>.any <code>.any <code>.any) @@ -92,7 +92,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list indexA valueA arrayA)}))))])) -(def: array::delete +(def array::delete Handler (custom [(all <>.and <code>.any <code>.any) @@ -109,7 +109,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: bundle::array +(def bundle::array Bundle (<| (bundle.prefix "array") (|> bundle.empty @@ -120,19 +120,19 @@ (bundle.install "delete" array::delete) ))) -(def: Nil +(def Nil (for @.ruby ffi.Nil Any)) -(def: Object +(def Object (for @.ruby (type (ffi.Object Any)) Any)) -(def: Function +(def Function (for @.ruby ffi.Function Any)) -(def: object::get +(def object::get Handler (custom [(all <>.and <code>.text <code>.any) @@ -144,7 +144,7 @@ (in {analysis.#Extension extension (list (analysis.text fieldC) objectA)})))])) -(def: object::do +(def object::do Handler (custom [(all <>.and <code>.text <code>.any (<code>.tuple (<>.some <code>.any))) @@ -158,7 +158,7 @@ objectA inputsA)})))])) -(def: bundle::object +(def bundle::object Bundle (<| (bundle.prefix "object") (|> bundle.empty @@ -168,7 +168,7 @@ (bundle.install "nil?" (/.unary Any Bit)) ))) -(def: ruby::constant +(def ruby::constant Handler (custom [<code>.text @@ -177,7 +177,7 @@ [_ (analysis/type.inference Any)] (in {analysis.#Extension extension (list (analysis.text name))})))])) -(def: ruby::apply +(def ruby::apply Handler (custom [(all <>.and <code>.any (<code>.tuple (<>.some <code>.any))) @@ -189,7 +189,7 @@ _ (analysis/type.inference Any)] (in {analysis.#Extension extension (list.partial abstractionA inputsA)})))])) -(def: ruby::import +(def ruby::import Handler (custom [<code>.text @@ -198,7 +198,7 @@ [_ (analysis/type.inference Bit)] (in {analysis.#Extension extension (list (analysis.text name))})))])) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "ruby") (|> bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux index e0ba7f433..b76766cf7 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux @@ -28,7 +28,7 @@ [/// ["[0]" phase]]]]]]) -(def: array::new +(def array::new Handler (custom [<c>.any @@ -41,7 +41,7 @@ _ (analysis/type.infer (type (Array :var:)))] (in {analysis.#Extension extension (list lengthA)}))))])) -(def: array::length +(def array::length Handler (custom [<c>.any @@ -54,7 +54,7 @@ _ (analysis/type.infer Nat)] (in {analysis.#Extension extension (list arrayA)}))))])) -(def: array::read +(def array::read Handler (custom [(<>.and <c>.any <c>.any) @@ -69,7 +69,7 @@ _ (analysis/type.infer :var:)] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: array::write +(def array::write Handler (custom [(all <>.and <c>.any <c>.any <c>.any) @@ -86,7 +86,7 @@ _ (analysis/type.infer (type (Array :var:)))] (in {analysis.#Extension extension (list indexA valueA arrayA)}))))])) -(def: array::delete +(def array::delete Handler (custom [(all <>.and <c>.any <c>.any) @@ -101,7 +101,7 @@ _ (analysis/type.infer (type (Array :var:)))] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: bundle::array +(def bundle::array Bundle (<| (bundle.prefix "array") (|> bundle.empty @@ -112,15 +112,15 @@ (bundle.install "delete" array::delete) ))) -(def: Nil +(def Nil (for @.scheme ffi.Nil Any)) -(def: Function +(def Function (for @.scheme ffi.Function Any)) -(def: bundle::object +(def bundle::object Bundle (<| (bundle.prefix "object") (|> bundle.empty @@ -128,7 +128,7 @@ (bundle.install "nil?" (/.unary Any Bit)) ))) -(def: scheme::constant +(def scheme::constant Handler (custom [<c>.text @@ -137,7 +137,7 @@ [_ (analysis/type.infer Any)] (in {analysis.#Extension extension (list (analysis.text name))})))])) -(def: scheme::apply +(def scheme::apply Handler (custom [(all <>.and <c>.any (<>.some <c>.any)) @@ -149,7 +149,7 @@ _ (analysis/type.infer Any)] (in {analysis.#Extension extension (list.partial abstractionA inputsA)})))])) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "scheme") (|> bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/bundle.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/bundle.lux index 3510a9f9e..1e2674dc4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/bundle.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/bundle.lux @@ -11,17 +11,17 @@ ["[0]" dictionary (.only Dictionary)]]]]] [// (.only Handler Bundle)]) -(def: .public empty +(def .public empty Bundle (dictionary.empty text.hash)) -(def: .public (install name anonymous) +(def .public (install name anonymous) (All (_ s i o) (-> Text (Handler s i o) (-> (Bundle s i o) (Bundle s i o)))) (dictionary.has name anonymous)) -(def: .public (prefix prefix) +(def .public (prefix prefix) (All (_ s i o) (-> Text (-> (Bundle s i o) (Bundle s i o)))) (|>> dictionary.entries diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux index 41076ca66..960e51493 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux @@ -90,17 +90,17 @@ (type: Operation (directive.Operation Anchor (Bytecode Any) Definition)) -(def: signature (|>> type.signature signature.signature)) -(def: reflection (|>> type.reflection reflection.reflection)) +(def signature (|>> type.signature signature.signature)) +(def reflection (|>> type.reflection reflection.reflection)) (type: Declaration [Text (List (Type Var))]) -(def: declaration +(def declaration (Parser Declaration) (<code>.form (<>.and <code>.text (<>.some jvm.var)))) -(def: method_privacy +(def method_privacy (-> ffi.Privacy (Modifier method.Method)) (|>> (pipe.case {ffi.#PublicP} method.public @@ -108,7 +108,7 @@ {ffi.#ProtectedP} method.protected {ffi.#DefaultP} modifier.empty))) -(def: visibility' +(def visibility' (<text>.Parser (Modifier field.Field)) (`` (all <>.either (~~ (with_template [<label> <modifier>] @@ -119,11 +119,11 @@ ["protected" field.protected] ["default" modifier.empty]))))) -(def: visibility +(def visibility (Parser (Modifier field.Field)) (<text>.then ..visibility' <code>.text)) -(def: inheritance +(def inheritance (Parser (Modifier class.Class)) (`` (all <>.either (~~ (with_template [<label> <modifier>] @@ -133,7 +133,7 @@ ["abstract" class.abstract] ["default" modifier.empty]))))) -(def: state +(def state (Parser (Modifier field.Field)) (`` (all <>.either (~~ (with_template [<label> <modifier>] @@ -145,18 +145,18 @@ (type: Annotation Any) -(def: annotation +(def annotation (Parser Annotation) <code>.any) -(def: field_type +(def field_type (Parser (Type Value)) (<text>.then parser.value <code>.text)) (type: Constant [Text (List Annotation) (Type Value) Code]) -(def: constant +(def constant (Parser Constant) (<| <code>.form (<>.after (<code>.this_text "constant")) @@ -170,7 +170,7 @@ (type: Variable [Text (Modifier field.Field) (Modifier field.Field) Bit (List Annotation) (Type Value)]) -(def: variable +(def variable (Parser Variable) (<| <code>.form (<>.after (<code>.this_text "variable")) @@ -188,7 +188,7 @@ {#Constant Constant} {#Variable Variable})) -(def: field +(def field (Parser Field) (all <>.or ..constant @@ -203,7 +203,7 @@ {#Overriden_Method (jvm.Overriden_Method a)} {#Abstract_Method (jvm.Abstract_Method a)})) -(def: method +(def method (Parser (Method_Definition Code)) (all <>.or jvm.constructor_definition @@ -213,18 +213,18 @@ jvm.abstract_method_definition )) -(def: $Object +(def $Object (Type Class) (type.class "java.lang.Object" (list))) -(def: constant::modifier +(def constant::modifier (Modifier field.Field) (all modifier#composite field.public field.static field.final)) -(def: (field_definition field) +(def (field_definition field) (-> Field (Resource field.Field)) (case field ... TODO: Handle annotations. @@ -261,16 +261,16 @@ state) name #1 type sequence.empty))) -(def: annotation_parameter_synthesis +(def annotation_parameter_synthesis (<synthesis>.Parser (jvm.Annotation_Parameter Synthesis)) (<synthesis>.tuple (<>.and <synthesis>.text <synthesis>.any))) -(def: annotation_synthesis +(def annotation_synthesis (<synthesis>.Parser (jvm.Annotation Synthesis)) (<synthesis>.tuple (<>.and <synthesis>.text (<>.some ..annotation_parameter_synthesis)))) (with_template [<name> <type> <text>] - [(def: <name> + [(def <name> (<synthesis>.Parser (Type <type>)) (<text>.then <text> <synthesis>.text))] @@ -280,15 +280,15 @@ [return_type_synthesis Return parser.return] ) -(def: argument_synthesis +(def argument_synthesis (<synthesis>.Parser Argument) (<synthesis>.tuple (<>.and <synthesis>.text ..value_type_synthesis))) -(def: input_synthesis +(def input_synthesis (<synthesis>.Parser (Typed Synthesis)) (<synthesis>.tuple (<>.and ..value_type_synthesis <synthesis>.any))) -(def: (method_body arity) +(def (method_body arity) (-> Nat (<synthesis>.Parser Synthesis)) (<| (<>#each (function (_ [env offset inits it]) it)) (<synthesis>.function 1) @@ -300,7 +300,7 @@ <synthesis>.any) <synthesis>.any))) -(def: constructor_synthesis +(def constructor_synthesis (<synthesis>.Parser (jvm.Constructor Synthesis)) (<| <synthesis>.tuple (<>.after (<synthesis>.this_text jvm.constructor_tag)) @@ -319,7 +319,7 @@ (..method_body (list.size args)))) ))) -(def: overriden_method_synthesis +(def overriden_method_synthesis (<synthesis>.Parser (jvm.Overriden_Method Synthesis)) (<| <synthesis>.tuple (<>.after (<synthesis>.this_text jvm.overriden_tag)) @@ -339,7 +339,7 @@ (..method_body (list.size args)))) ))) -(def: virtual_method_synthesis +(def virtual_method_synthesis (<synthesis>.Parser (jvm.Virtual_Method Synthesis)) (<| <synthesis>.tuple (<>.after (<synthesis>.this_text jvm.virtual_tag)) @@ -360,7 +360,7 @@ (..method_body (list.size args)))) ))) -(def: static_method_synthesis +(def static_method_synthesis (<synthesis>.Parser (jvm.Static_Method Synthesis)) (<| <synthesis>.tuple (<>.after (<synthesis>.this_text jvm.static_tag)) @@ -379,7 +379,7 @@ (..method_body (list.size args)))) ))) -(def: abstract_method_synthesis +(def abstract_method_synthesis (<synthesis>.Parser (jvm.Abstract_Method Synthesis)) (<| <synthesis>.tuple (<>.after (<synthesis>.this_text jvm.abstract_tag)) @@ -393,7 +393,7 @@ (<synthesis>.tuple (<>.some ..class_type_synthesis)) ))) -(def: method_synthesis +(def method_synthesis (<synthesis>.Parser (Method_Definition Synthesis)) (all <>.or ..constructor_synthesis @@ -403,15 +403,15 @@ ..abstract_method_synthesis )) -(def: composite +(def composite (-> (List (Bytecode Any)) (Bytecode Any)) (|>> list.reversed (list#mix _.composite (_#in [])))) -(def: constructor_name +(def constructor_name "<init>") -(def: (method_argument lux_register argumentT jvm_register) +(def (method_argument lux_register argumentT jvm_register) (-> Register (Type Value) Register [Register (Bytecode Any)]) (case (type.primitive? argumentT) {.#Left argumentT} @@ -444,7 +444,7 @@ ... (at type.equivalence = type.double argumentT) (wrap_primitive 2 _.dload type.double)))))) -(def: .public (method_arguments offset types) +(def .public (method_arguments offset types) (-> Nat (List (Type Value)) (Bytecode Any)) (|> types list.enumeration @@ -454,7 +454,7 @@ (is [Register (Bytecode Any)] [offset (_#in [])])) product.right)) -(def: (constructor_method_generation archive super_class method) +(def (constructor_method_generation archive super_class method) (-> Archive (Type Class) (jvm.Constructor Synthesis) (Operation (Resource Method))) (<| (let [[privacy strict_floating_point? annotations method_tvars exceptions self arguments constructor_argumentsS @@ -489,7 +489,7 @@ _.return )}))))) -(def: (method_return returnT) +(def (method_return returnT) (-> (Type Return) (Bytecode Any)) (case (type.void? returnT) {.#Right returnT} @@ -527,7 +527,7 @@ ... (at type.equivalence = type.double returnT) (unwrap_primitive _.dreturn type.double))))))) -(def: (overriden_method_generation archive method) +(def (overriden_method_generation archive method) (-> Archive (jvm.Overriden_Method Synthesis) (Operation (Resource Method))) (do [! phase.monad] [.let [[super method_name strict_floating_point? annotations @@ -554,7 +554,7 @@ bodyG (method_return returnJ))})))))) -(def: (virtual_method_generation archive method) +(def (virtual_method_generation archive method) (-> Archive (jvm.Virtual_Method Synthesis) (Operation (Resource Method))) (do [! phase.monad] [.let [[method_name privacy final? strict_floating_point? annotations method_tvars @@ -581,7 +581,7 @@ bodyG (method_return returnJ))})))))) -(def: (static_method_generation archive method) +(def (static_method_generation archive method) (-> Archive (jvm.Static_Method Synthesis) (Operation (Resource Method))) (do [! phase.monad] [.let [[method_name privacy strict_floating_point? annotations method_tvars @@ -606,7 +606,7 @@ bodyG (method_return returnJ))})))))) -(def: (abstract_method_generation method) +(def (abstract_method_generation method) (-> (jvm.Abstract_Method Synthesis) (Resource Method)) (let [[name privacy annotations variables arguments return exceptions] method] @@ -618,7 +618,7 @@ (list) {.#None}))) -(def: (method_generation archive super_class method) +(def (method_generation archive super_class method) (-> Archive (Type Class) (Method_Definition Synthesis) (Operation (Resource Method))) (case method {#Constructor method} @@ -636,7 +636,7 @@ {#Abstract_Method method} (at phase.monad in (..abstract_method_generation method)))) -(def: (method_definition archive super interfaces [mapping selfT] [analyse synthesize generate]) +(def (method_definition archive super interfaces [mapping selfT] [analyse synthesize generate]) (-> Archive (Type Class) (List (Type Class)) @@ -676,10 +676,10 @@ methodG (method_generation archive super methodS')] (in [dependencies methodG])))) -(def: class_name +(def class_name (|>> parser.read_class product.left name.internal)) -(def: (mock_class [name parameters] super interfaces fields methods modifier) +(def (mock_class [name parameters] super interfaces fields methods modifier) (-> Declaration (Type Class) (List (Type Class)) (List (Resource field.Field)) (List (Resource method.Method)) (Modifier class.Class) (Try [External Binary])) @@ -700,7 +700,7 @@ methods sequence.empty)))) -(def: (mock_value valueT) +(def (mock_value valueT) (-> (Type Value) (Bytecode Any)) (case (type.primitive? valueT) {.#Left classT} @@ -719,7 +719,7 @@ ... type.boolean type.byte type.short type.int type.char _.iconst_0))) -(def: (mock_return returnT) +(def (mock_return returnT) (-> (Type Return) (Bytecode Any)) (case (type.void? returnT) {.#Right returnT} @@ -745,7 +745,7 @@ ... type.boolean type.byte type.short type.int type.char _.ireturn))))) -(def: (mock_method super method) +(def (mock_method super method) (-> (Type Class) (Method_Definition Code) (Resource method.Method)) (case method {#Constructor [privacy strict_floating_point? annotations variables exceptions @@ -823,7 +823,7 @@ {.#None}) )) -(def: (mock declaration super interfaces inheritance fields methods) +(def (mock declaration super interfaces inheritance fields methods) (-> Declaration (Type Class) (List (Type Class)) (Modifier class.Class) (List ..Field) (List (Method_Definition Code)) @@ -834,7 +834,7 @@ inheritance)) (with_template [<name> <type> <parser>] - [(def: <name> + [(def <name> (Parser <type>) (do [! <>.monad] [raw <code>.text] @@ -843,7 +843,7 @@ [class_declaration [External (List (Type Var))] parser.declaration'] ) -(def: (save_class! name bytecode dependencies) +(def (save_class! name bytecode dependencies) (-> Text Binary (Set unit.ID) (Operation Any)) (directive.lifted_generation (do [! phase.monad] @@ -854,7 +854,7 @@ _ (generation.log! (format "JVM Class " name))] (in [])))) -(def: jvm::class +(def jvm::class (Handler Anchor (Bytecode Any) Definition) (/.custom [(all <>.and @@ -919,7 +919,7 @@ _ (..save_class! name bytecode all_dependencies)] (in directive.no_requirements)))])) -(def: (method_declaration (open "/[0]")) +(def (method_declaration (open "/[0]")) (-> (jvm.Method_Declaration Code) (Resource Method)) (let [type (type.method [/#type_variables /#arguments /#return /#exceptions])] (method.method (all modifier#composite @@ -930,7 +930,7 @@ (list) {.#None}))) -(def: jvm::class::interface +(def jvm::class::interface (Handler Anchor (Bytecode Any) Definition) (/.custom [(all <>.and @@ -968,7 +968,7 @@ (import java/lang/ClassLoader "[1]::[0]") -(def: .public (bundle class_loader extender) +(def .public (bundle class_loader extender) (-> java/lang/ClassLoader Extender (Bundle Anchor (Bytecode Any) Definition)) (<| (bundle.prefix "jvm") (|> bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux index 47b487dea..a8117080a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux @@ -56,7 +56,7 @@ [dependency ["[1]/[0]" artifact]]]]]]]]) -(def: .public (custom [syntax handler]) +(def .public (custom [syntax handler]) (All (_ anchor expression directive s) (-> [(Parser s) (-> Text @@ -73,13 +73,13 @@ {try.#Failure error} (phase.except ///.invalid_syntax [extension_name %.code inputs])))) -(def: (context [@module @artifact]) +(def (context [@module @artifact]) (-> unit.ID unit.ID) ... TODO: Find a better way that doesn't rely on clever tricks. [@module (n.- (++ @artifact) 0)]) ... TODO: Inline "evaluate!'" into "evaluate!" ASAP -(def: (evaluate!' archive generate code//type codeS) +(def (evaluate!' archive generate code//type codeS) (All (_ anchor expression directive) (-> Archive (/////generation.Phase anchor expression directive) @@ -95,7 +95,7 @@ codeV (/////generation.evaluate! (..context [@module id]) [{.#None} codeG])] (in [code//type codeG codeV])))) -(def: .public (evaluate! archive type codeC) +(def .public (evaluate! archive type codeC) (All (_ anchor expression directive) (-> Archive Type Code (Operation anchor expression directive [Type expression Any]))) (do phase.monad @@ -113,7 +113,7 @@ (evaluate!' archive generate type codeS))) ... TODO: Inline "definition'" into "definition" ASAP -(def: (definition' archive generate [module name] code//type codeS) +(def (definition' archive generate [module name] code//type codeS) (All (_ anchor expression directive) (-> Archive (/////generation.Phase anchor expression directive) @@ -140,7 +140,7 @@ _ (/////generation.save! @self {.#None} directive)] (in [code//type codeG value])))) -(def: (definition archive name expected codeC) +(def (definition archive name expected codeC) (All (_ anchor expression directive) (-> Archive Symbol (Maybe Type) Code (Operation anchor expression directive [Type expression Any]))) @@ -171,7 +171,7 @@ (with_template [<full> <partial> <learn>] [... TODO: Inline "<partial>" into "<full>" ASAP - (def: (<partial> archive generate extension codeT codeS) + (def (<partial> archive generate extension codeT codeS) (All (_ anchor expression directive) (-> Archive (/////generation.Phase anchor expression directive) @@ -193,7 +193,7 @@ _ (/////generation.save! @self {.#None} directive)] (in [codeG value]))))) - (def: .public (<full> archive extension codeT codeC) + (def .public (<full> archive extension codeT codeC) (All (_ anchor expression directive) (-> Archive Text Type Code (Operation anchor expression directive [expression Any]))) @@ -218,7 +218,7 @@ ) ... TODO: Get rid of this function ASAP. -(def: (refresh expander host_analysis) +(def (refresh expander host_analysis) (All (_ anchor expression directive) (-> Expander /////analysis.Bundle (Operation anchor expression directive Any))) (do phase.monad @@ -236,13 +236,13 @@ (dictionary.composite (///analysis.bundle eval host_analysis)))])) state)]))) -(def: (announce_definition! short type) +(def (announce_definition! short type) (All (_ anchor expression directive) (-> Text Type (Operation anchor expression directive Any))) (/////directive.lifted_generation (/////generation.log! (format short " : " (%.type type))))) -(def: (lux::def expander host_analysis) +(def (lux::def expander host_analysis) (-> Expander /////analysis.Bundle Handler) (function (_ extension_name phase archive inputsC+) (case inputsC+ @@ -262,7 +262,7 @@ _ (phase.except ///.invalid_syntax [extension_name %.code inputsC+])))) -(def: (announce_labels! labels owner) +(def (announce_labels! labels owner) (All (_ anchor expression directive) (-> (List Text) Type (Operation anchor expression directive (List Any)))) (/////directive.lifted_generation @@ -271,7 +271,7 @@ (/////generation.log! (format tag " : Tag of " (%.type owner)))) labels))) -(def: (def::type_tagged expander host_analysis) +(def (deftype_tagged expander host_analysis) (-> Expander /////analysis.Bundle Handler) (..custom [(all <>.and <code>.local <code>.any @@ -309,13 +309,13 @@ _ (..announce_labels! labels (as Type value))] (in /////directive.no_requirements)))])) -(def: imports +(def imports (Parser (List Import)) (|> (<code>.tuple (<>.and <code>.text <code>.text)) <>.some <code>.tuple)) -(def: def::module +(def defmodule Handler (..custom [..imports @@ -346,7 +346,7 @@ "Alias" (%.symbol local) "Label" (%.symbol foreign))) -(def: (define_alias alias original) +(def (define_alias alias original) (-> Text Symbol (/////analysis.Operation Any)) (do phase.monad [current_module (///.lifted meta.current_module_name) @@ -363,7 +363,7 @@ {.#Slot _}) (phase.except ..cannot_alias_a_label [[current_module alias] original])))) -(def: def::alias +(def defalias Handler (..custom [(all <>.and <code>.local <code>.symbol) @@ -377,7 +377,7 @@ ... TODO: Stop requiring these types and the "swapped" function below to make types line-up. (with_template [<name> <anonymous>] - [(def: <name> + [(def <name> Type (with_expansions [<original> binary.Binary] (let [_ <original>] @@ -388,7 +388,7 @@ [Binary|DEFAULT (type (array.Array (I64 Any)))] ) -(def: (swapped original replacement) +(def (swapped original replacement) (-> Type Type Type Type) (function (again type) (if (type#= original type) @@ -420,7 +420,7 @@ {.#Named name (again anonymous)})))) (with_template [<description> <mame> <def_type> <type> <scope> <definer>] - [(def: (<mame> [anchorT expressionT directiveT] extender) + [(def (<mame> [anchorT expressionT directiveT] extender) (All (_ anchor expression directive) (-> [Type Type Type] Extender (Handler anchor expression directive))) @@ -459,22 +459,22 @@ (phase.except ///.invalid_syntax [extension_name %.code inputsC+]))))] ["Analysis" - def::analysis + defanalysis /////analysis.Handler /////analysis.Handler /////directive.lifted_analysis ..analyser] ["Synthesis" - def::synthesis + defsynthesis /////synthesis.Handler /////synthesis.Handler /////directive.lifted_synthesis ..synthesizer] ["Generation" - def::generation + defgeneration (/////generation.Handler anchorT expressionT directiveT) (/////generation.Handler anchor expression directive) /////directive.lifted_generation ..generator] ["Directive" - def::directive + defdirective (/////directive.Handler anchorT expressionT directiveT) (/////directive.Handler anchor expression directive) (<|) ..directive] @@ -482,8 +482,8 @@ ... TODO; Both "prepare-program" and "define-program" exist only ... because the old compiler couldn't handle a fully-inlined definition -... for "def::program". Inline them ASAP. -(def: (prepare_program archive analyse synthesize programC) +... for "defprogram". Inline them ASAP. +(def (prepare_program archive analyse synthesize programC) (All (_ anchor expression directive output) (-> Archive /////analysis.Phase @@ -499,7 +499,7 @@ (/////directive.lifted_synthesis (synthesize archive programA)))) -(def: (define_program archive @module generate program programS) +(def (define_program archive @module generate program programS) (All (_ anchor expression directive output) (-> Archive module.ID @@ -514,7 +514,7 @@ @self (/////generation.learn [/////program.name {.#None}] true (list#mix set.has dependencies interim_artifacts))] (/////generation.save! @self {.#None} (program [@module @self] programG)))) -(def: (def::program program) +(def (defprogram program) (All (_ anchor expression directive) (-> (Program expression directive) (Handler anchor expression directive))) (function (handler extension_name phase archive inputsC+) @@ -536,7 +536,7 @@ _ (phase.except ///.invalid_syntax [extension_name %.code inputsC+])))) -(def: (bundle::def expander host_analysis program anchorT,expressionT,directiveT extender) +(def (bundle::def expander host_analysis program anchorT,expressionT,directiveT extender) (All (_ anchor expression directive) (-> Expander /////analysis.Bundle @@ -546,17 +546,17 @@ (Bundle anchor expression directive))) (<| (///bundle.prefix "def") (|> ///bundle.empty - (dictionary.has "module" def::module) - (dictionary.has "alias" def::alias) - (dictionary.has "type tagged" (def::type_tagged expander host_analysis)) - (dictionary.has "analysis" (def::analysis anchorT,expressionT,directiveT extender)) - (dictionary.has "synthesis" (def::synthesis anchorT,expressionT,directiveT extender)) - (dictionary.has "generation" (def::generation anchorT,expressionT,directiveT extender)) - (dictionary.has "directive" (def::directive anchorT,expressionT,directiveT extender)) - (dictionary.has "program" (def::program program)) + (dictionary.has "module" defmodule) + (dictionary.has "alias" defalias) + (dictionary.has "type tagged" (deftype_tagged expander host_analysis)) + (dictionary.has "analysis" (defanalysis anchorT,expressionT,directiveT extender)) + (dictionary.has "synthesis" (defsynthesis anchorT,expressionT,directiveT extender)) + (dictionary.has "generation" (defgeneration anchorT,expressionT,directiveT extender)) + (dictionary.has "directive" (defdirective anchorT,expressionT,directiveT extender)) + (dictionary.has "program" (defprogram program)) ))) -(def: .public (bundle expander host_analysis program anchorT,expressionT,directiveT extender) +(def .public (bundle expander host_analysis program anchorT,expressionT,directiveT extender) (All (_ anchor expression directive) (-> Expander /////analysis.Bundle diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp.lux index 7ef89329d..246b7455e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp.lux @@ -12,7 +12,7 @@ [common_lisp [runtime (.only Bundle)]]]]]) -(def: .public bundle +(def .public bundle Bundle (dictionary.composite /common.bundle /host.bundle)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux index c0c04d708..51ed09e66 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux @@ -38,7 +38,7 @@ [/// ["[1]" phase]]]]]) -(def: .public (custom [parser handler]) +(def .public (custom [parser handler]) (All (_ s) (-> [(Parser s) (-> Text (Generator s))] @@ -51,12 +51,12 @@ {try.#Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) -(def: !unary +(def !unary (template (_ function) (|>> list _.apply (|> (_.constant function))))) ... ... TODO: Get rid of this ASAP -... (def: lux::syntax_char_case! +... (def lux::syntax_char_case! ... (..custom [(all <>.and ... <s>.any ... <s>.any @@ -81,7 +81,7 @@ ... elseG ... conditionalsG))))))])) -(def: lux_procs +(def lux_procs Bundle (|> /.empty ... (/.install "syntax char case!" lux::syntax_char_case!) @@ -89,12 +89,12 @@ ... (/.install "try" (unary //runtime.lux//try)) )) -... (def: (capped operation parameter subject) +... (def (capped operation parameter subject) ... (-> (-> Expression Expression Expression) ... (-> Expression Expression Expression)) ... (//runtime.i64//64 (operation parameter subject))) -(def: i64_procs +(def i64_procs Bundle (<| (/.prefix "i64") (|> /.empty @@ -114,7 +114,7 @@ (/.install "char" (unary (|>> _.code_char/1 _.string/1))) ))) -(def: f64_procs +(def f64_procs Bundle (<| (/.prefix "f64") (|> /.empty @@ -130,19 +130,19 @@ ... (/.install "decode" (unary //runtime.f64//decode)) ))) -(def: (text//index [offset sub text]) +(def (text//index [offset sub text]) (Trinary (Expression Any)) (//runtime.text//index offset sub text)) -(def: (text//clip [offset length text]) +(def (text//clip [offset length text]) (Trinary (Expression Any)) (//runtime.text//clip offset length text)) -(def: (text//char [index text]) +(def (text//char [index text]) (Binary (Expression Any)) (_.char_code/1 (_.char/2 [text index]))) -(def: text_procs +(def text_procs Bundle (<| (/.prefix "text") (|> /.empty @@ -156,12 +156,12 @@ (/.install "clip" (trinary ..text//clip)) ))) -(def: (io//log! message) +(def (io//log! message) (Unary (Expression Any)) (_.progn (list (_.write_line/1 message) //runtime.unit))) -(def: io_procs +(def io_procs Bundle (<| (/.prefix "io") (|> /.empty @@ -169,7 +169,7 @@ (/.install "error" (unary _.error/1)) ))) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "lux") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/host.lux index 79e422867..a68ac7532 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/host.lux @@ -8,7 +8,7 @@ [common_lisp [runtime (.only Bundle)]]]]]) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "common_lisp") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js.lux index 5b4f0979a..e3b3165e9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js.lux @@ -12,7 +12,7 @@ [js [runtime (.only Bundle)]]]]]) -(def: .public bundle +(def .public bundle Bundle (dictionary.composite /common.bundle /host.bundle)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux index f83d48372..8f07958c0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux @@ -39,7 +39,7 @@ [/// ["[1]" phase (.open: "[1]#[0]" monad)]]]]]) -(def: .public (custom [parser handler]) +(def .public (custom [parser handler]) (All (_ s) (-> [(Parser s) (-> Text (Generator s))] @@ -55,7 +55,7 @@ ... [Procedures] ... [[Bits]] (with_template [<name> <op>] - [(def: (<name> [paramG subjectG]) + [(def (<name> [paramG subjectG]) (Binary Expression) (<op> subjectG (//runtime.i64::number paramG)))] @@ -64,7 +64,7 @@ ) ... [[Numbers]] -(def: f64//decode +(def f64//decode (Unary Expression) (|>> list (_.apply (_.var "parseFloat")) @@ -72,33 +72,33 @@ (_.closure (list)) //runtime.lux//try)) -(def: i64::char +(def i64::char (Unary Expression) (|>> //runtime.i64::number (list) (_.apply (_.var "String.fromCharCode")))) ... [[Text]] -(def: (text//concat [leftG rightG]) +(def (text//concat [leftG rightG]) (Binary Expression) (|> leftG (_.do "concat" (list rightG)))) -(def: (text//clip [startG endG subjectG]) +(def (text//clip [startG endG subjectG]) (Trinary Expression) (//runtime.text//clip startG endG subjectG)) -(def: (text//index [startG partG subjectG]) +(def (text//index [startG partG subjectG]) (Trinary Expression) (//runtime.text//index startG partG subjectG)) ... [[IO]] -(def: (io//log messageG) +(def (io//log messageG) (Unary Expression) (all _., (//runtime.io//log messageG) //runtime.unit)) -(def: .public (statement expression archive synthesis) +(def .public (statement expression archive synthesis) Phase! (case synthesis ... TODO: Get rid of this ASAP @@ -148,7 +148,7 @@ )) ... TODO: Get rid of this ASAP -(def: lux::syntax_char_case! +(def lux::syntax_char_case! (..custom [(all <>.and <s>.any <s>.any @@ -179,14 +179,14 @@ {.#Some else!})))))])) ... [Bundles] -(def: lux_procs +(def lux_procs Bundle (|> /.empty (/.install "syntax char case!" lux::syntax_char_case!) (/.install "is" (binary (product.uncurried _.=))) (/.install "try" (unary //runtime.lux//try)))) -(def: i64_procs +(def i64_procs Bundle (<| (/.prefix "i64") (|> /.empty @@ -206,7 +206,7 @@ (/.install "char" (unary i64::char)) ))) -(def: f64_procs +(def f64_procs Bundle (<| (/.prefix "f64") (|> /.empty @@ -221,7 +221,7 @@ (/.install "encode" (unary (_.do "toString" (list)))) (/.install "decode" (unary f64//decode))))) -(def: text_procs +(def text_procs Bundle (<| (/.prefix "text") (|> /.empty @@ -234,14 +234,14 @@ (/.install "clip" (trinary text//clip)) ))) -(def: io_procs +(def io_procs Bundle (<| (/.prefix "io") (|> /.empty (/.install "log" (unary io//log)) (/.install "error" (unary //runtime.io//error))))) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "lux") (|> lux_procs diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux index 0c3a868ae..5d15df243 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux @@ -31,28 +31,28 @@ ["//[1]" /// ["[1][0]" phase]]]]]]) -(def: array::new +(def array::new (Unary Expression) (|>> (_.the //runtime.i64_low_field) list (_.new (_.var "Array")))) -(def: array::length +(def array::length (Unary Expression) (|>> (_.the "length") //runtime.i64::of_number)) -(def: (array::read [indexG arrayG]) +(def (array::read [indexG arrayG]) (Binary Expression) (_.at (_.the //runtime.i64_low_field indexG) arrayG)) -(def: (array::write [indexG valueG arrayG]) +(def (array::write [indexG valueG arrayG]) (Trinary Expression) (//runtime.array//write indexG valueG arrayG)) -(def: (array::delete [indexG arrayG]) +(def (array::delete [indexG arrayG]) (Binary Expression) (//runtime.array//delete indexG arrayG)) -(def: array +(def array Bundle (<| (/.prefix "array") (|> /.empty @@ -63,7 +63,7 @@ (/.install "delete" (binary array::delete)) ))) -(def: object::new +(def object::new (custom [(all <>.and <s>.any (<>.some <s>.any)) (function (_ extension phase archive [constructorS inputsS]) @@ -72,7 +72,7 @@ inputsG (monad.each ! (phase archive) inputsS)] (in (_.new constructorG inputsG))))])) -(def: object::get +(def object::get Handler (custom [(all <>.and <s>.text <s>.any) @@ -81,7 +81,7 @@ [objectG (phase archive objectS)] (in (_.the fieldS objectG))))])) -(def: object::do +(def object::do Handler (custom [(all <>.and <s>.text <s>.any (<>.some <s>.any)) @@ -92,14 +92,14 @@ (in (_.do methodS inputsG objectG))))])) (with_template [<!> <?> <unit>] - [(def: <!> (Nullary Expression) (function.constant <unit>)) - (def: <?> (Unary Expression) (_.= <unit>))] + [(def <!> (Nullary Expression) (function.constant <unit>)) + (def <?> (Unary Expression) (_.= <unit>))] [object::null object::null? _.null] [object::undefined object::undefined? _.undefined] ) -(def: object +(def object Bundle (<| (/.prefix "object") (|> /.empty @@ -112,13 +112,13 @@ (/.install "undefined?" (unary object::undefined?)) ))) -(def: js::constant +(def js::constant (custom [<s>.text (function (_ extension phase archive name) (at ////////phase.monad in (_.var name)))])) -(def: js::apply +(def js::apply (custom [(all <>.and <s>.any (<>.some <s>.any)) (function (_ extension phase archive [abstractionS inputsS]) @@ -127,7 +127,7 @@ inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply abstractionG inputsG))))])) -(def: js::function +(def js::function (custom [(all <>.and <s>.i64 <s>.any) (function (_ extension phase archive [arity abstractionS]) @@ -147,7 +147,7 @@ 1 (_.apply g!abstraction g!inputs) _ (_.apply_1 g!abstraction (_.array g!inputs)))))))))])) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "js") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm.lux index f53409c26..8f05447f9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm.lux @@ -12,7 +12,7 @@ [jvm [runtime (.only Bundle)]]]]]) -(def: .public bundle +(def .public bundle Bundle (all dictionary.composite /common.bundle diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux index 44e2b7c41..febd59454 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux @@ -43,7 +43,7 @@ [meta [archive (.only Archive)]]]]]) -(def: .public (custom [parser handler]) +(def .public (custom [parser handler]) (All (_ s) (-> [(Parser s) (-> Text Phase Archive s (Operation (Bytecode Any)))] @@ -56,29 +56,29 @@ {try.#Failure error} (/////.except /////extension.invalid_syntax [extension_name synthesis.%synthesis input])))) -(def: $Boolean (type.class "java.lang.Boolean" (list))) -(def: $Double (type.class "java.lang.Double" (list))) -(def: $Character (type.class "java.lang.Character" (list))) -(def: $String (type.class "java.lang.String" (list))) -(def: $CharSequence (type.class "java.lang.CharSequence" (list))) -(def: $Object (type.class "java.lang.Object" (list))) -(def: $PrintStream (type.class "java.io.PrintStream" (list))) -(def: $System (type.class "java.lang.System" (list))) -(def: $Error (type.class "java.lang.Error" (list))) - -(def: lux_int +(def $Boolean (type.class "java.lang.Boolean" (list))) +(def $Double (type.class "java.lang.Double" (list))) +(def $Character (type.class "java.lang.Character" (list))) +(def $String (type.class "java.lang.String" (list))) +(def $CharSequence (type.class "java.lang.CharSequence" (list))) +(def $Object (type.class "java.lang.Object" (list))) +(def $PrintStream (type.class "java.io.PrintStream" (list))) +(def $System (type.class "java.lang.System" (list))) +(def $Error (type.class "java.lang.Error" (list))) + +(def lux_int (Bytecode Any) (all _.composite _.i2l (///value.wrap type.long))) -(def: jvm_int +(def jvm_int (Bytecode Any) (all _.composite (///value.unwrap type.long) _.l2i)) -(def: (predicate bytecode) +(def (predicate bytecode) (-> (-> Label (Bytecode Any)) (Bytecode Any)) (do _.monad @@ -94,7 +94,7 @@ ))) ... TODO: Get rid of this ASAP -(def: lux::syntax_char_case! +(def lux::syntax_char_case! (..custom [(all <>.and <synthesis>.any <synthesis>.any @@ -138,21 +138,21 @@ (_.set_label @end)) )))))])) -(def: (lux::is [referenceG sampleG]) +(def (lux::is [referenceG sampleG]) (Binary (Bytecode Any)) (all _.composite referenceG sampleG (..predicate _.if_acmpeq))) -(def: (lux::try riskyG) +(def (lux::try riskyG) (Unary (Bytecode Any)) (all _.composite riskyG (_.checkcast ///function.class) ///runtime.try)) -(def: bundle::lux +(def bundle::lux Bundle (|> (is Bundle /////bundle.empty) (/////bundle.install "syntax char case!" ..lux::syntax_char_case!) @@ -160,7 +160,7 @@ (/////bundle.install "try" (unary ..lux::try)))) (with_template [<name> <op>] - [(def: (<name> [maskG inputG]) + [(def (<name> [maskG inputG]) (Binary (Bytecode Any)) (all _.composite inputG (///value.unwrap type.long) @@ -173,7 +173,7 @@ ) (with_template [<name> <op>] - [(def: (<name> [shiftG inputG]) + [(def (<name> [shiftG inputG]) (Binary (Bytecode Any)) (all _.composite inputG (///value.unwrap type.long) @@ -185,7 +185,7 @@ ) (with_template [<name> <type> <op>] - [(def: (<name> [paramG subjectG]) + [(def (<name> [paramG subjectG]) (Binary (Bytecode Any)) (all _.composite subjectG (///value.unwrap <type>) @@ -207,7 +207,7 @@ (with_template [<eq> <lt> <type> <cmp>] [(with_template [<name> <reference>] - [(def: (<name> [paramG subjectG]) + [(def (<name> [paramG subjectG]) (Binary (Bytecode Any)) (all _.composite subjectG (///value.unwrap <type>) @@ -223,12 +223,12 @@ [f64::= f64::< type.double _.dcmpg] ) -(def: (::toString class from) +(def (::toString class from) (-> (Type Class) (Type Primitive) (Bytecode Any)) (_.invokestatic class "toString" (type.method [(list) (list from) ..$String (list)]))) (with_template [<name> <prepare> <transform>] - [(def: (<name> inputG) + [(def (<name> inputG) (Unary (Bytecode Any)) (all _.composite inputG @@ -263,7 +263,7 @@ ///runtime.decode_frac] ) -(def: bundle::i64 +(def bundle::i64 Bundle (<| (/////bundle.prefix "i64") (|> (is Bundle /////bundle.empty) @@ -282,7 +282,7 @@ (/////bundle.install "f64" (unary ..i64::f64)) (/////bundle.install "char" (unary ..i64::char))))) -(def: bundle::f64 +(def bundle::f64 Bundle (<| (/////bundle.prefix "f64") (|> (is Bundle /////bundle.empty) @@ -297,7 +297,7 @@ (/////bundle.install "encode" (unary ..f64::encode)) (/////bundle.install "decode" (unary ..f64::decode))))) -(def: (text::size inputG) +(def (text::size inputG) (Unary (Bytecode Any)) (all _.composite inputG @@ -305,10 +305,10 @@ (_.invokevirtual ..$String "length" (type.method [(list) (list) type.int (list)])) ..lux_int)) -(def: no_op (Bytecode Any) (_#in [])) +(def no_op (Bytecode Any) (_#in [])) (with_template [<name> <pre_subject> <pre_param> <op> <post>] - [(def: (<name> [paramG subjectG]) + [(def (<name> [paramG subjectG]) (Binary (Bytecode Any)) (all _.composite subjectG <pre_subject> @@ -326,14 +326,14 @@ ..lux_int] ) -(def: (text::concat [leftG rightG]) +(def (text::concat [leftG rightG]) (Binary (Bytecode Any)) (all _.composite leftG (_.checkcast $String) rightG (_.checkcast $String) (_.invokevirtual ..$String "concat" (type.method [(list) (list ..$String) ..$String (list)])))) -(def: (text::clip [offset! length! subject!]) +(def (text::clip [offset! length! subject!]) (Trinary (Bytecode Any)) (all _.composite subject! (_.checkcast $String) @@ -343,8 +343,8 @@ _.iadd (_.invokevirtual ..$String "substring" (type.method [(list) (list type.int type.int) ..$String (list)])))) -(def: index_method (type.method [(list) (list ..$String type.int) type.int (list)])) -(def: (text::index [startG partG textG]) +(def index_method (type.method [(list) (list ..$String type.int) type.int (list)])) +(def (text::index [startG partG textG]) (Trinary (Bytecode Any)) (do _.monad [@not_found _.new_label @@ -365,7 +365,7 @@ ///runtime.none_injection (_.set_label @end)))) -(def: bundle::text +(def bundle::text Bundle (<| (/////bundle.prefix "text") (|> (is Bundle /////bundle.empty) @@ -377,8 +377,8 @@ (/////bundle.install "char" (binary ..text::char)) (/////bundle.install "clip" (trinary ..text::clip))))) -(def: string_method (type.method [(list) (list ..$String) type.void (list)])) -(def: (io::log messageG) +(def string_method (type.method [(list) (list ..$String) type.void (list)])) +(def (io::log messageG) (Unary (Bytecode Any)) (all _.composite (_.getstatic ..$System "out" ..$PrintStream) @@ -387,7 +387,7 @@ (_.invokevirtual ..$PrintStream "println" ..string_method) ///runtime.unit)) -(def: (io::error messageG) +(def (io::error messageG) (Unary (Bytecode Any)) (all _.composite (_.new ..$Error) @@ -397,14 +397,14 @@ (_.invokespecial ..$Error "<init>" ..string_method) _.athrow)) -(def: bundle::io +(def bundle::io Bundle (<| (/////bundle.prefix "io") (|> (is Bundle /////bundle.empty) (/////bundle.install "log" (unary ..io::log)) (/////bundle.install "error" (unary ..io::error))))) -(def: .public bundle +(def .public bundle Bundle (<| (/////bundle.prefix "lux") (|> bundle::lux diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux index e08b2aba8..a13cef376 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux @@ -81,7 +81,7 @@ ["[1]/[0]" artifact]]]]]]]]) (with_template [<name> <0>] - [(def: <name> + [(def <name> (Bytecode Any) (all _.composite _.l2i @@ -93,7 +93,7 @@ ) (with_template [<conversion> <name>] - [(def: (<name> inputG) + [(def (<name> inputG) (Unary (Bytecode Any)) (if (same? _.nop <conversion>) inputG @@ -133,7 +133,7 @@ [_.i2l conversion::short_to_long] ) -(def: bundle::conversion +(def bundle::conversion Bundle (<| (/////bundle.prefix "conversion") (|> (is Bundle /////bundle.empty) @@ -170,7 +170,7 @@ ))) (with_template [<name> <op>] - [(def: (<name> [parameter! subject!]) + [(def (<name> [parameter! subject!]) (Binary (Bytecode Any)) (all _.composite subject! @@ -214,12 +214,12 @@ [double::% _.drem] ) -(def: $Boolean (type.class box.boolean (list))) -(def: falseG (_.getstatic ..$Boolean "FALSE" ..$Boolean)) -(def: trueG (_.getstatic ..$Boolean "TRUE" ..$Boolean)) +(def $Boolean (type.class box.boolean (list))) +(def falseG (_.getstatic ..$Boolean "FALSE" ..$Boolean)) +(def trueG (_.getstatic ..$Boolean "TRUE" ..$Boolean)) (with_template [<name> <op>] - [(def: (<name> [reference subject]) + [(def (<name> [reference subject]) (Binary (Bytecode Any)) (do _.monad [@then _.new_label @@ -242,7 +242,7 @@ ) (with_template [<name> <op> <reference>] - [(def: (<name> [reference subject]) + [(def (<name> [reference subject]) (Binary (Bytecode Any)) (do _.monad [@then _.new_label @@ -269,7 +269,7 @@ [double::< _.dcmpg -1] ) -(def: bundle::int +(def bundle::int Bundle (<| (/////bundle.prefix (reflection.reflection reflection.int)) (|> (is Bundle /////bundle.empty) @@ -288,7 +288,7 @@ (/////bundle.install "ushr" (binary int::ushr)) ))) -(def: bundle::long +(def bundle::long Bundle (<| (/////bundle.prefix (reflection.reflection reflection.long)) (|> (is Bundle /////bundle.empty) @@ -307,7 +307,7 @@ (/////bundle.install "ushr" (binary long::ushr)) ))) -(def: bundle::float +(def bundle::float Bundle (<| (/////bundle.prefix (reflection.reflection reflection.float)) (|> (is Bundle /////bundle.empty) @@ -320,7 +320,7 @@ (/////bundle.install "<" (binary float::<)) ))) -(def: bundle::double +(def bundle::double Bundle (<| (/////bundle.prefix (reflection.reflection reflection.double)) (|> (is Bundle /////bundle.empty) @@ -333,7 +333,7 @@ (/////bundle.install "<" (binary double::<)) ))) -(def: bundle::char +(def bundle::char Bundle (<| (/////bundle.prefix (reflection.reflection reflection.char)) (|> (is Bundle /////bundle.empty) @@ -342,7 +342,7 @@ ))) (with_template [<name> <category> <parser>] - [(def: .public <name> + [(def .public <name> (Parser (Type <category>)) (<text>.then <parser> <synthesis>.text))] @@ -353,12 +353,12 @@ [return Return parser.return] ) -(def: reflection +(def reflection (All (_ category) (-> (Type (<| Return' Value' category)) Text)) (|>> type.reflection reflection.reflection)) -(def: signature +(def signature (All (_ category) (-> (Type category) Text)) (|>> type.signature signature.signature)) @@ -367,7 +367,7 @@ (exception.report "JVM Type" (..signature arrayJT))) -(def: .public object_array +(def .public object_array (Parser (Type Object)) (do <>.monad [arrayJT (<text>.then parser.array <synthesis>.text)] @@ -383,7 +383,7 @@ {.#None} (undefined)))) -(def: (primitive_array_length_handler jvm_primitive) +(def (primitive_array_length_handler jvm_primitive) (-> (Type Primitive) Handler) (..custom [<synthesis>.any @@ -395,7 +395,7 @@ (_.checkcast (type.array jvm_primitive)) _.arraylength))))])) -(def: array::length::object +(def array::length::object Handler (..custom [(all <>.and ..object_array <synthesis>.any) @@ -407,7 +407,7 @@ (_.checkcast (type.array elementJT)) _.arraylength))))])) -(def: (new_primitive_array_handler jvm_primitive) +(def (new_primitive_array_handler jvm_primitive) (-> Primitive_Array_Type Handler) (..custom [<synthesis>.any @@ -418,7 +418,7 @@ lengthG (_.newarray jvm_primitive)))))])) -(def: array::new::object +(def array::new::object Handler (..custom [(all <>.and ..object <synthesis>.any) @@ -429,7 +429,7 @@ lengthG (_.anewarray objectJT)))))])) -(def: (read_primitive_array_handler jvm_primitive loadG) +(def (read_primitive_array_handler jvm_primitive loadG) (-> (Type Primitive) (Bytecode Any) Handler) (..custom [(all <>.and <synthesis>.any <synthesis>.any) @@ -443,7 +443,7 @@ idxG loadG))))])) -(def: array::read::object +(def array::read::object Handler (..custom [(all <>.and ..object_array <synthesis>.any <synthesis>.any) @@ -457,7 +457,7 @@ idxG _.aaload))))])) -(def: (write_primitive_array_handler jvm_primitive storeG) +(def (write_primitive_array_handler jvm_primitive storeG) (-> (Type Primitive) (Bytecode Any) Handler) (..custom [(all <>.and <synthesis>.any <synthesis>.any <synthesis>.any) @@ -474,7 +474,7 @@ valueG storeG))))])) -(def: array::write::object +(def array::write::object Handler (..custom [(all <>.and ..object_array <synthesis>.any <synthesis>.any <synthesis>.any) @@ -491,7 +491,7 @@ valueG _.aastore))))])) -(def: bundle::array +(def bundle::array Bundle (<| (/////bundle.prefix "array") (|> /////bundle.empty @@ -541,11 +541,11 @@ (/////bundle.install "object" array::write::object)))) ))) -(def: (object::null _) +(def (object::null _) (Nullary (Bytecode Any)) _.aconst_null) -(def: (object::null? objectG) +(def (object::null? objectG) (Unary (Bytecode Any)) (do _.monad [@then _.new_label @@ -559,7 +559,7 @@ ..trueG (_.set_label @end)))) -(def: (object::synchronized [monitorG exprG]) +(def (object::synchronized [monitorG exprG]) (Binary (Bytecode Any)) (all _.composite monitorG @@ -569,16 +569,16 @@ _.swap _.monitorexit)) -(def: (object::throw exceptionG) +(def (object::throw exceptionG) (Unary (Bytecode Any)) (all _.composite exceptionG _.athrow)) -(def: $Class (type.class "java.lang.Class" (list))) -(def: $String (type.class "java.lang.String" (list))) +(def $Class (type.class "java.lang.Class" (list))) +(def $String (type.class "java.lang.String" (list))) -(def: object::class +(def object::class Handler (..custom [<synthesis>.text @@ -589,7 +589,7 @@ (_.string class) (_.invokestatic ..$Class "forName" (type.method [(list) (list ..$String) ..$Class (list)]))))))])) -(def: object::instance? +(def object::instance? Handler (..custom [(all <>.and <synthesis>.text <synthesis>.any) @@ -601,7 +601,7 @@ (_.instanceof (type.class class (list))) (///value.wrap type.boolean)))))])) -(def: object::cast +(def object::cast Handler (..custom [(all <>.and <synthesis>.text <synthesis>.text <synthesis>.any) @@ -632,7 +632,7 @@ ... else valueG)))))])) -(def: bundle::object +(def bundle::object Bundle (<| (/////bundle.prefix "object") (|> (is Bundle /////bundle.empty) @@ -645,17 +645,17 @@ (/////bundle.install "cast" object::cast) ))) -(def: get::static +(def get::static Handler (..custom [(all <>.and <synthesis>.text <synthesis>.text ..value) (function (_ extension_name generate archive [class field :unboxed:]) (at //////.monad in (_.getstatic (type.class class (list)) field :unboxed:)))])) -(def: unitG +(def unitG (_.string synthesis.unit)) -(def: put::static +(def put::static Handler (..custom [(all <>.and <synthesis>.text <synthesis>.text ..value <synthesis>.any) @@ -673,7 +673,7 @@ (_.putstatic (type.class class (list)) field :unboxed:) ..unitG))))])) -(def: get::virtual +(def get::virtual Handler (..custom [(all <>.and <synthesis>.text <synthesis>.text ..value <synthesis>.any) @@ -687,7 +687,7 @@ (_.checkcast :class:) getG))))])) -(def: put::virtual +(def put::virtual Handler (..custom [(all <>.and <synthesis>.text <synthesis>.text ..value <synthesis>.any <synthesis>.any) @@ -714,11 +714,11 @@ (type: Input (Typed Synthesis)) -(def: input +(def input (Parser Input) (<synthesis>.tuple (<>.and ..value <synthesis>.any))) -(def: (generate_input generate archive [valueT valueS]) +(def (generate_input generate archive [valueT valueS]) (-> Phase Archive Input (Operation (Typed (Bytecode Any)))) (do //////.monad [valueG (generate archive valueS)] @@ -731,7 +731,7 @@ valueG (_.checkcast valueT))])))) -(def: (prepare_output outputT) +(def (prepare_output outputT) (-> (Type Return) (Bytecode Any)) (case (type.void? outputT) {.#Right outputT} @@ -740,7 +740,7 @@ {.#Left outputT} (_#in []))) -(def: invoke::static +(def invoke::static Handler (..custom [(all <>.and ..class <synthesis>.text ..return (<>.some ..input)) @@ -753,7 +753,7 @@ (prepare_output outputT)))))])) (with_template [<check_cast?> <name> <invoke>] - [(def: <name> + [(def <name> Handler (..custom [(all <>.and ..class <synthesis>.text ..return <synthesis>.any (<>.some ..input)) @@ -775,7 +775,7 @@ [#1 invoke::interface _.invokeinterface] ) -(def: invoke::constructor +(def invoke::constructor Handler (..custom [(all <>.and ..class (<>.some ..input)) @@ -788,7 +788,7 @@ (monad.each _.monad product.right inputsTG) (_.invokespecial class "<init>" (type.method [(list) (list#each product.left inputsTG) type.void (list)]))))))])) -(def: bundle::member +(def bundle::member Bundle (<| (/////bundle.prefix "member") (|> (is Bundle /////bundle.empty) @@ -809,19 +809,19 @@ (/////bundle.install "constructor" invoke::constructor)))) ))) -(def: annotation_parameter +(def annotation_parameter (Parser (/.Annotation_Parameter Synthesis)) (<synthesis>.tuple (<>.and <synthesis>.text <synthesis>.any))) -(def: annotation +(def annotation (Parser (/.Annotation Synthesis)) (<synthesis>.tuple (<>.and <synthesis>.text (<>.some ..annotation_parameter)))) -(def: argument +(def argument (Parser Argument) (<synthesis>.tuple (<>.and <synthesis>.text ..value))) -(def: .public (hidden_method_body arity body) +(def .public (hidden_method_body arity body) (-> Nat Synthesis Synthesis) (with_expansions [<oops> (panic! (%.format (%.nat arity) " " (synthesis.%synthesis body)))] (case [arity body] @@ -847,7 +847,7 @@ _ <oops>))) -(def: (without_fake_parameter#path without_fake_parameter) +(def (without_fake_parameter#path without_fake_parameter) (-> (-> Synthesis Synthesis) (-> Path Path)) (function (again it) @@ -881,7 +881,7 @@ {synthesis.#Then it} {synthesis.#Then (without_fake_parameter it)}))) -(def: .public (without_fake_parameter it) +(def .public (without_fake_parameter it) (-> Synthesis Synthesis) (case it {synthesis.#Simple _} @@ -970,7 +970,7 @@ {synthesis.#Extension name parameters} {synthesis.#Extension name (list#each without_fake_parameter parameters)})) -(def: overriden_method_definition +(def overriden_method_definition (Parser [(Environment Synthesis) (/.Overriden_Method Synthesis)]) (<synthesis>.tuple (do <>.monad [_ (<synthesis>.this_text /.overriden_tag) @@ -998,7 +998,7 @@ 0 (without_fake_parameter body) _ body))]])))) -(def: (normalize_path normalize) +(def (normalize_path normalize) (-> (-> Synthesis Synthesis) (-> Path Path)) (function (again path) @@ -1035,7 +1035,7 @@ (type: Mapping (Dictionary Synthesis Variable)) -(def: (normalize_method_body mapping) +(def (normalize_method_body mapping) (-> Mapping Synthesis Synthesis) (function (again body) (case body @@ -1099,17 +1099,17 @@ {synthesis.#Extension [name inputsS+]} {synthesis.#Extension [name (list#each again inputsS+)]}))) -(def: $Object +(def $Object (type.class "java.lang.Object" (list))) -(def: (anonymous_init_method env inputsTI) +(def (anonymous_init_method env inputsTI) (-> (Environment Synthesis) (List (Typed (Bytecode Any))) (Type category.Method)) (type.method [(list) (list.repeated (n.+ (list.size inputsTI) (list.size env)) ..$Object) type.void (list)])) -(def: (with_anonymous_init class env super_class inputsTG) +(def (with_anonymous_init class env super_class inputsTG) (-> (Type category.Class) (Environment Synthesis) (Type category.Class) (List (Typed (Bytecode Any))) (Resource Method)) (let [inputs_offset (list.size inputsTG) inputs! (|> inputsTG @@ -1144,7 +1144,7 @@ store_captured! _.return)}))) -(def: (anonymous_instance generate archive class env inputsTI) +(def (anonymous_instance generate archive class env inputsTI) (-> Phase Archive (Type category.Class) (Environment Synthesis) (List (Typed (Bytecode Any))) (Operation (Bytecode Any))) (do [! //////.monad] [captureG+ (monad.each ! (generate archive) env)] @@ -1158,7 +1158,7 @@ (monad.all _.monad captureG+) (_.invokespecial class "<init>" (anonymous_init_method env inputsTI)))))) -(def: (returnG returnT) +(def (returnG returnT) (-> (Type Return) (Bytecode Any)) (case (type.void? returnT) {.#Right returnT} @@ -1196,14 +1196,14 @@ ... (at type.equivalence = type.double returnT) (unwrap_primitive _.dreturn type.double))))))) -(def: (method_dependencies archive method) +(def (method_dependencies archive method) (-> Archive (/.Overriden_Method Synthesis) (Operation (Set unit.ID))) (let [[_super _name _strict_fp? _annotations _t_vars _this _arguments _return _exceptions bodyS] method] (cache/artifact.dependencies archive bodyS))) -(def: (anonymous_dependencies archive inputsTS overriden_methods) +(def (anonymous_dependencies archive inputsTS overriden_methods) (-> Archive (List Input) (List [(Environment Synthesis) (/.Overriden_Method Synthesis)]) (Operation (Set unit.ID))) (do [! //////.monad] @@ -1218,7 +1218,7 @@ all_closure_dependencies all_method_dependencies))))) -(def: (prepare_argument lux_register argumentT jvm_register) +(def (prepare_argument lux_register argumentT jvm_register) (-> Register (Type Value) Register [Register (Bytecode Any)]) (case (type.primitive? argumentT) {.#Left argumentT} @@ -1251,7 +1251,7 @@ ... (at type.equivalence = type.double argumentT) (wrap_primitive 2 _.dload type.double)))))) -(def: .public (prepare_arguments offset types) +(def .public (prepare_arguments offset types) (-> Nat (List (Type Value)) (Bytecode Any)) (|> types list.enumeration @@ -1266,7 +1266,7 @@ (_#in [])])) product.right)) -(def: (normalized_method global_mapping [environment method]) +(def (normalized_method global_mapping [environment method]) (-> Mapping [(Environment Synthesis) (/.Overriden_Method Synthesis)] (/.Overriden_Method Synthesis)) (let [[ownerT name strict_fp? annotations vars self_name arguments returnT exceptionsT body] method @@ -1283,7 +1283,7 @@ self_name arguments returnT exceptionsT (normalize_method_body local_mapping body)])) -(def: (total_environment overriden_methods) +(def (total_environment overriden_methods) (-> (List [(Environment Synthesis) (/.Overriden_Method Synthesis)]) (List Synthesis)) (|> overriden_methods @@ -1295,7 +1295,7 @@ (set.of_list synthesis.hash) set.list)) -(def: (global_mapping total_environment) +(def (global_mapping total_environment) (-> (List Synthesis) Mapping) (|> total_environment ... Give them names as "foreign" variables. @@ -1304,7 +1304,7 @@ [capture {//////variable.#Foreign id}])) (dictionary.of_list synthesis.hash))) -(def: (method_definition phase archive artifact_id method) +(def (method_definition phase archive artifact_id method) (-> Phase Archive artifact.ID (/.Overriden_Method Synthesis) (Operation (Resource Method))) (let [[ownerT name strict_fp? annotations vars self_name arguments returnT exceptionsT bodyS] method] (do //////.monad @@ -1326,7 +1326,7 @@ bodyG (returnG returnT))}))))) -(def: class::anonymous +(def class::anonymous Handler (..custom [(all <>.and @@ -1366,14 +1366,14 @@ _ (//////generation.save! artifact_id {.#None} artifact)] (anonymous_instance generate archive class total_environment inputsTI)))])) -(def: bundle::class +(def bundle::class Bundle (<| (/////bundle.prefix "class") (|> (is Bundle /////bundle.empty) (/////bundle.install "anonymous" class::anonymous) ))) -(def: .public bundle +(def .public bundle Bundle (<| (/////bundle.prefix "jvm") (|> ..bundle::conversion diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua.lux index bae90fe1b..8860a5568 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua.lux @@ -12,7 +12,7 @@ [lua [runtime (.only Bundle)]]]]]) -(def: .public bundle +(def .public bundle Bundle (dictionary.composite /common.bundle /host.bundle)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux index c454fc422..14c293e39 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux @@ -43,7 +43,7 @@ [/// ["[1]" phase (.open: "[1]#[0]" monad)]]]]]) -(def: .public (custom [parser handler]) +(def .public (custom [parser handler]) (All (_ s) (-> [(Parser s) (-> Text (Generator s))] @@ -56,11 +56,11 @@ {try.#Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) -(def: !unary +(def !unary (template (_ function) [(|>> list _.apply (|> (_.var function)))])) -(def: .public (statement expression archive synthesis) +(def .public (statement expression archive synthesis) Phase! (case synthesis ... TODO: Get rid of this ASAP @@ -112,7 +112,7 @@ )) ... TODO: Get rid of this ASAP -(def: lux::syntax_char_case! +(def lux::syntax_char_case! (..custom [(all <>.and <s>.any <s>.any @@ -141,14 +141,14 @@ (//case.case! statement phase archive) (at /////.monad each (|>> (as Expression)))))])) -(def: lux_procs +(def lux_procs Bundle (|> /.empty (/.install "syntax char case!" lux::syntax_char_case!) (/.install "is" (binary (product.uncurried _.=))) (/.install "try" (unary //runtime.lux//try)))) -(def: i64_procs +(def i64_procs Bundle (<| (/.prefix "i64") (|> /.empty @@ -168,11 +168,11 @@ (/.install "char" (unary (function (_ it) (_.apply (list it) (_.var "utf8.char"))))) ))) -(def: f64//decode +(def f64//decode (Unary Expression) (|>> list _.apply (|> (_.var "tonumber")) _.return (_.closure (list)) //runtime.lux//try)) -(def: f64_procs +(def f64_procs Bundle (<| (/.prefix "f64") (|> /.empty @@ -187,19 +187,19 @@ (/.install "encode" (unary (function (_ it) (_.apply (list (_.string "%.17g") it) (_.var "string.format"))))) (/.install "decode" (unary ..f64//decode))))) -(def: (text//char [paramO subjectO]) +(def (text//char [paramO subjectO]) (Binary Expression) (//runtime.text//char (_.+ (_.int +1) paramO) subjectO)) -(def: (text//clip [paramO extraO subjectO]) +(def (text//clip [paramO extraO subjectO]) (Trinary Expression) (//runtime.text//clip subjectO paramO extraO)) -(def: (text//index [startO partO textO]) +(def (text//index [startO partO textO]) (Trinary Expression) (//runtime.text//index textO partO startO)) -(def: text_procs +(def text_procs Bundle (<| (/.prefix "text") (|> /.empty @@ -215,19 +215,19 @@ (/.install "clip" (trinary ..text//clip)) ))) -(def: (io//log! messageO) +(def (io//log! messageO) (Unary Expression) (|> (_.apply (list messageO) (_.var "print")) (_.or //runtime.unit))) -(def: io_procs +(def io_procs Bundle (<| (/.prefix "io") (|> /.empty (/.install "log" (unary ..io//log!)) (/.install "error" (unary (!unary "error")))))) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "lux") (|> lux_procs diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux index 4ed8013ca..6d8a3bf73 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux @@ -34,27 +34,27 @@ ["//[1]" /// ["[1][0]" phase]]]]]]) -(def: array::new +(def array::new (Unary Expression) (|>> ["n"] list _.table)) -(def: array::length +(def array::length (Unary Expression) (_.the "n")) -(def: (array::read [indexG arrayG]) +(def (array::read [indexG arrayG]) (Binary Expression) (_.item (_.+ (_.int +1) indexG) arrayG)) -(def: (array::write [indexG valueG arrayG]) +(def (array::write [indexG valueG arrayG]) (Trinary Expression) (//runtime.array//write indexG valueG arrayG)) -(def: (array::delete [indexG arrayG]) +(def (array::delete [indexG arrayG]) (Binary Expression) (//runtime.array//write indexG _.nil arrayG)) -(def: array +(def array Bundle (<| (/.prefix "array") (|> /.empty @@ -65,7 +65,7 @@ (/.install "delete" (binary array::delete)) ))) -(def: object::get +(def object::get Handler (custom [(all <>.and <s>.text <s>.any) @@ -74,7 +74,7 @@ [objectG (phase archive objectS)] (in (_.the fieldS objectG))))])) -(def: object::do +(def object::do Handler (custom [(all <>.and <s>.text <s>.any (<>.some <s>.any)) @@ -85,13 +85,13 @@ (in (_.do methodS inputsG objectG))))])) (with_template [<!> <?> <unit>] - [(def: <!> (Nullary Expression) (function.constant <unit>)) - (def: <?> (Unary Expression) (_.= <unit>))] + [(def <!> (Nullary Expression) (function.constant <unit>)) + (def <?> (Unary Expression) (_.= <unit>))] [object::nil object::nil? _.nil] ) -(def: object +(def object Bundle (<| (/.prefix "object") (|> /.empty @@ -101,10 +101,10 @@ (/.install "nil?" (unary object::nil?)) ))) -(def: $input +(def $input (_.var "input")) -(def: utf8::encode +(def utf8::encode (custom [<s>.any (function (_ extension phase archive inputS) @@ -116,7 +116,7 @@ (_.var "string.byte"))) (_.var "table.pack")))))))])) -(def: utf8::decode +(def utf8::decode (custom [<s>.any (function (_ extension phase archive inputS) @@ -126,7 +126,7 @@ (_.var "table.unpack"))) (_.var "string.char")))))])) -(def: utf8 +(def utf8 Bundle (<| (/.prefix "utf8") (|> /.empty @@ -134,13 +134,13 @@ (/.install "decode" utf8::decode) ))) -(def: lua::constant +(def lua::constant (custom [<s>.text (function (_ extension phase archive name) (at ////////phase.monad in (_.var name)))])) -(def: lua::apply +(def lua::apply (custom [(all <>.and <s>.any (<>.some <s>.any)) (function (_ extension phase archive [abstractionS inputsS]) @@ -149,7 +149,7 @@ inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply inputsG abstractionG))))])) -(def: lua::power +(def lua::power (custom [(all <>.and <s>.any <s>.any) (function (_ extension phase archive [powerS baseS]) @@ -158,14 +158,14 @@ baseG (phase archive baseS)] (in (_.^ powerG baseG))))])) -(def: lua::import +(def lua::import (custom [<s>.text (function (_ extension phase archive module) (at ////////phase.monad in (_.require/1 (_.string module))))])) -(def: lua::function +(def lua::function (custom [(all <>.and <s>.i64 <s>.any) (function (_ extension phase archive [arity abstractionS]) @@ -184,7 +184,7 @@ 1 (_.apply g!inputs abstractionG) _ (_.apply (list (_.array g!inputs)) abstractionG))))))])) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "lua") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php.lux index d36dc5557..4d9c8ab95 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php.lux @@ -12,7 +12,7 @@ [php [runtime (.only Bundle)]]]]]) -(def: .public bundle +(def .public bundle Bundle (dictionary.composite /common.bundle /host.bundle)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux index 384736271..02ecee4d4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux @@ -38,7 +38,7 @@ [/// ["[1]" phase]]]]]) -(def: .public (custom [parser handler]) +(def .public (custom [parser handler]) (All (_ s) (-> [(Parser s) (-> Text (Generator s))] @@ -51,12 +51,12 @@ {try.#Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) -(def: !unary +(def !unary (template (_ function) (|>> list _.apply (|> (_.constant function))))) ... TODO: Get rid of this ASAP -(def: lux::syntax_char_case! +(def lux::syntax_char_case! (..custom [(all <>.and <s>.any <s>.any @@ -98,7 +98,7 @@ _ (generation.save! context_artifact directive)] (in (_.apply (list.partial inputG foreigns) @expression))))])) -(def: lux_procs +(def lux_procs Bundle (|> /.empty (/.install "syntax char case!" lux::syntax_char_case!) @@ -106,11 +106,11 @@ (/.install "try" (unary //runtime.lux//try)) )) -(def: (left_shifted [parameter subject]) +(def (left_shifted [parameter subject]) (Binary Expression) (_.bit_shl (_.% (_.int +64) parameter) subject)) -(def: i64_procs +(def i64_procs Bundle (<| (/.prefix "i64") (|> /.empty @@ -131,15 +131,15 @@ (/.install "char" (unary //runtime.i64//char)) ))) -(def: (f64//% [parameter subject]) +(def (f64//% [parameter subject]) (Binary Expression) (_.fmod/2 [subject parameter])) -(def: (f64//encode subject) +(def (f64//encode subject) (Unary Expression) (_.number_format/2 [subject (_.int +17)])) -(def: f64_procs +(def f64_procs Bundle (<| (/.prefix "f64") (|> /.empty @@ -154,15 +154,15 @@ (/.install "encode" (unary ..f64//encode)) (/.install "decode" (unary //runtime.f64//decode))))) -(def: (text//clip [paramO extraO subjectO]) +(def (text//clip [paramO extraO subjectO]) (Trinary Expression) (//runtime.text//clip paramO extraO subjectO)) -(def: (text//index [startO partO textO]) +(def (text//index [startO partO textO]) (Trinary Expression) (//runtime.text//index textO partO startO)) -(def: text_procs +(def text_procs Bundle (<| (/.prefix "text") (|> /.empty @@ -175,14 +175,14 @@ (/.install "clip" (trinary ..text//clip)) ))) -(def: io_procs +(def io_procs Bundle (<| (/.prefix "io") (|> /.empty (/.install "log" (unary //runtime.io//log!)) (/.install "error" (unary //runtime.io//throw!))))) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "lux") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/host.lux index 535f01072..d63c2c626 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/host.lux @@ -34,23 +34,23 @@ ["//[1]" /// ["[1][0]" phase]]]]]]) -(def: (array::new size) +(def (array::new size) (Unary Expression) (//runtime.tuple//make size (_.array_fill/3 [(_.int +0) size _.null]))) -(def: (array::read [indexG arrayG]) +(def (array::read [indexG arrayG]) (Binary Expression) (_.item indexG arrayG)) -(def: (array::write [indexG valueG arrayG]) +(def (array::write [indexG valueG arrayG]) (Trinary Expression) (//runtime.array//write indexG valueG arrayG)) -(def: (array::delete [indexG arrayG]) +(def (array::delete [indexG arrayG]) (Binary Expression) (//runtime.array//write indexG _.null arrayG)) -(def: array +(def array Bundle (<| (/.prefix "array") (|> /.empty @@ -61,7 +61,7 @@ (/.install "delete" (binary array::delete)) ))) -(def: object::new +(def object::new (custom [(all <>.and <s>.text (<>.some <s>.any)) (function (_ extension phase archive [constructor inputsS]) @@ -69,7 +69,7 @@ [inputsG (monad.each ! (phase archive) inputsS)] (in (_.new (_.constant constructor) inputsG))))])) -(def: object::get +(def object::get Handler (custom [(all <>.and <s>.text <s>.any) @@ -78,7 +78,7 @@ [objectG (phase archive objectS)] (in (_.the fieldS objectG))))])) -(def: object::do +(def object::do Handler (custom [(all <>.and <s>.text <s>.any (<>.some <s>.any)) @@ -89,13 +89,13 @@ (in (_.do methodS inputsG objectG))))])) (with_template [<!> <?> <unit>] - [(def: <!> (Nullary Expression) (function.constant <unit>)) - (def: <?> (Unary Expression) (_.=== <unit>))] + [(def <!> (Nullary Expression) (function.constant <unit>)) + (def <?> (Unary Expression) (_.=== <unit>))] [object::null object::null? _.null] ) -(def: object +(def object Bundle (<| (/.prefix "object") (|> /.empty @@ -106,13 +106,13 @@ (/.install "null?" (unary object::null?)) ))) -(def: php::constant +(def php::constant (custom [<s>.text (function (_ extension phase archive name) (at ////////phase.monad in (_.constant name)))])) -(def: php::apply +(def php::apply (custom [(all <>.and <s>.any (<>.some <s>.any)) (function (_ extension phase archive [abstractionS inputsS]) @@ -121,7 +121,7 @@ inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply inputsG abstractionG))))])) -(def: php::pack +(def php::pack (custom [(all <>.and <s>.any <s>.any) (function (_ extension phase archive [formatS dataS]) @@ -130,7 +130,7 @@ dataG (phase archive dataS)] (in (_.pack/2 [formatG (_.splat dataG)]))))])) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "php") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python.lux index 7b0c7cc9b..bb9e2638d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python.lux @@ -12,7 +12,7 @@ [python [runtime (.only Bundle)]]]]]) -(def: .public bundle +(def .public bundle Bundle (dictionary.composite /common.bundle /host.bundle)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux index ef6d301bc..3335bf992 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux @@ -45,7 +45,7 @@ [/// ["[1]" phase (.open: "[1]#[0]" monad)]]]]]) -(def: .public (statement expression archive synthesis) +(def .public (statement expression archive synthesis) Phase! (case synthesis ... TODO: Get rid of this ASAP @@ -88,7 +88,7 @@ (/////#each _.return (//function.function statement expression archive abstraction)) )) -(def: .public (custom [parser handler]) +(def .public (custom [parser handler]) (All (_ s) (-> [(Parser s) (-> Text (Generator s))] @@ -102,7 +102,7 @@ (/////.except extension.invalid_syntax [extension_name %synthesis input])))) ... TODO: Get rid of this ASAP -(def: lux::syntax_char_case! +(def lux::syntax_char_case! (..custom [(all <>.and <synthesis>.any <synthesis>.any @@ -156,19 +156,19 @@ else! conditionals!))))))])) -(def: lux_procs +(def lux_procs Bundle (|> /.empty (/.install "syntax char case!" lux::syntax_char_case!) (/.install "is" (binary (product.uncurried _.is))) (/.install "try" (unary //runtime.lux::try)))) -(def: (capped operation parameter subject) +(def (capped operation parameter subject) (-> (-> (Expression Any) (Expression Any) (Expression Any)) (-> (Expression Any) (Expression Any) (Expression Any))) (//runtime.i64::64 (operation parameter subject))) -(def: i64_procs +(def i64_procs Bundle (<| (/.prefix "i64") (|> /.empty @@ -189,7 +189,7 @@ (/.install "char" (unary //runtime.i64::char)) ))) -(def: f64_procs +(def f64_procs Bundle (<| (/.prefix "f64") (|> /.empty @@ -206,15 +206,15 @@ (/.install "encode" (unary _.repr/1)) (/.install "decode" (unary //runtime.f64::decode))))) -(def: (text::clip [paramO extraO subjectO]) +(def (text::clip [paramO extraO subjectO]) (Trinary (Expression Any)) (//runtime.text::clip paramO extraO subjectO)) -(def: (text::index [startO partO textO]) +(def (text::index [startO partO textO]) (Trinary (Expression Any)) (//runtime.text::index startO partO textO)) -(def: text_procs +(def text_procs Bundle (<| (/.prefix "text") (|> /.empty @@ -227,14 +227,14 @@ (/.install "clip" (trinary ..text::clip)) ))) -(def: io_procs +(def io_procs Bundle (<| (/.prefix "io") (|> /.empty (/.install "log" (unary //runtime.io::log!)) (/.install "error" (unary //runtime.io::throw!))))) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "lux") (|> lux_procs diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/host.lux index 7ec9d1083..1c1f170ce 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/host.lux @@ -33,29 +33,29 @@ ["//[1]" /// ["[1][0]" phase]]]]]]) -(def: (array::new size) +(def (array::new size) (Unary (Expression Any)) (|> (list _.none) _.list (_.* size))) -(def: array::length +(def array::length (Unary (Expression Any)) (|>> _.len/1 //runtime.i64::64)) -(def: (array::read [indexG arrayG]) +(def (array::read [indexG arrayG]) (Binary (Expression Any)) (_.item indexG arrayG)) -(def: (array::write [indexG valueG arrayG]) +(def (array::write [indexG valueG arrayG]) (Trinary (Expression Any)) (//runtime.array::write indexG valueG arrayG)) -(def: (array::delete [indexG arrayG]) +(def (array::delete [indexG arrayG]) (Binary (Expression Any)) (//runtime.array::write indexG _.none arrayG)) -(def: array +(def array Bundle (<| (/.prefix "array") (|> /.empty @@ -66,7 +66,7 @@ (/.install "delete" (binary array::delete)) ))) -(def: object::get +(def object::get Handler (custom [(all <>.and <s>.text <s>.any) @@ -75,7 +75,7 @@ [objectG (phase archive objectS)] (in (_.the fieldS objectG))))])) -(def: object::do +(def object::do Handler (custom [(all <>.and <s>.text <s>.any (<>.some <s>.any)) @@ -86,13 +86,13 @@ (in (_.do methodS inputsG objectG))))])) (with_template [<!> <?> <unit>] - [(def: <!> (Nullary (Expression Any)) (function.constant <unit>)) - (def: <?> (Unary (Expression Any)) (_.= <unit>))] + [(def <!> (Nullary (Expression Any)) (function.constant <unit>)) + (def <?> (Unary (Expression Any)) (_.= <unit>))] [object::none object::none? _.none] ) -(def: object +(def object Bundle (<| (/.prefix "object") (|> /.empty @@ -102,7 +102,7 @@ (/.install "none?" (unary object::none?)) ))) -(def: python::constant +(def python::constant (custom [<s>.text (function (_ extension phase archive name) @@ -110,7 +110,7 @@ [] (in (_.var name))))])) -(def: python::import +(def python::import (custom [<s>.text (function (_ extension phase archive module) @@ -118,7 +118,7 @@ [] (in (_.apply (list (_.string module)) (_.var "__import__")))))])) -(def: python::apply +(def python::apply (custom [(all <>.and <s>.any (<>.some <s>.any)) (function (_ extension phase archive [abstractionS inputsS]) @@ -127,7 +127,7 @@ inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply inputsG abstractionG))))])) -(def: python::function +(def python::function (custom [(all <>.and <s>.i64 <s>.any) (function (_ extension phase archive [arity abstractionS]) @@ -144,7 +144,7 @@ 1 (_.apply g!inputs abstractionG) _ (_.apply (list (_.list g!inputs)) abstractionG))))))])) -(def: python::exec +(def python::exec (custom [(all <>.and <s>.any <s>.any) (function (_ extension phase archive [codeS globalsS]) @@ -153,7 +153,7 @@ globalsG (phase archive globalsS)] (in (//runtime.lux::exec codeG globalsG))))])) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "python") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r.lux index 1fbf60948..487b9958b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r.lux @@ -12,7 +12,7 @@ [r [runtime (.only Bundle)]]]]]) -(def: .public bundle +(def .public bundle Bundle (dictionary.composite /common.bundle /host.bundle)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux index facbc2e58..cdcfb555b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux @@ -38,7 +38,7 @@ [/// ["[1]" phase]]]]]) -(def: .public (custom [parser handler]) +(def .public (custom [parser handler]) (All (_ s) (-> [(Parser s) (-> Text (Generator s))] @@ -51,12 +51,12 @@ {try.#Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) -... (def: !unary +... (def !unary ... (template (_ function) ... (|>> list _.apply (|> (_.constant function))))) ... ... ... TODO: Get rid of this ASAP -... ... (def: lux::syntax_char_case! +... ... (def lux::syntax_char_case! ... ... (..custom [(all <>.and ... ... <s>.any ... ... <s>.any @@ -81,7 +81,7 @@ ... ... elseG ... ... conditionalsG))))))])) -... (def: lux_procs +... (def lux_procs ... Bundle ... (|> /.empty ... ... (/.install "syntax char case!" lux::syntax_char_case!) @@ -89,12 +89,12 @@ ... ... (/.install "try" (unary //runtime.lux//try)) ... )) -... ... (def: (capped operation parameter subject) +... ... (def (capped operation parameter subject) ... ... (-> (-> Expression Expression Expression) ... ... (-> Expression Expression Expression)) ... ... (//runtime.i64//64 (operation parameter subject))) -(def: i64_procs +(def i64_procs Bundle (<| (/.prefix "i64") (|> /.empty @@ -114,7 +114,7 @@ (/.install "char" (unary (|>> //runtime.i64_low _.intToUtf8/1))) ))) -... (def: f64_procs +... (def f64_procs ... Bundle ... (<| (/.prefix "f64") ... (|> /.empty @@ -130,19 +130,19 @@ ... ... (/.install "decode" (unary //runtime.f64//decode)) ... ))) -... (def: (text//index [offset sub text]) +... (def (text//index [offset sub text]) ... (Trinary (Expression Any)) ... (//runtime.text//index offset sub text)) -... (def: (text//clip [offset length text]) +... (def (text//clip [offset length text]) ... (Trinary (Expression Any)) ... (//runtime.text//clip offset length text)) -... (def: (text//char [index text]) +... (def (text//char [index text]) ... (Binary (Expression Any)) ... (_.char_code/1 (_.char/2 [text index]))) -(def: text_procs +(def text_procs Bundle (<| (/.prefix "text") (|> /.empty @@ -155,12 +155,12 @@ ... (/.install "clip" (trinary ..text//clip)) ))) -... (def: (io//log! message) +... (def (io//log! message) ... (Unary (Expression Any)) ... (_.progn (list (_.write_line/1 message) ... //runtime.unit))) -... (def: io_procs +... (def io_procs ... Bundle ... (<| (/.prefix "io") ... (|> /.empty @@ -168,7 +168,7 @@ ... (/.install "error" (unary _.error/1)) ... ))) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "lux") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/host.lux index 8facd6a1a..3fa89672c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/host.lux @@ -34,7 +34,7 @@ ["//[1]" /// ["[1][0]" phase]]]]]]) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "r") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby.lux index aa8f8e7b3..180444525 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby.lux @@ -12,7 +12,7 @@ [ruby [runtime (.only Bundle)]]]]]) -(def: .public bundle +(def .public bundle Bundle (dictionary.composite /common.bundle /host.bundle)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux index 6cdacfa40..0537a3539 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux @@ -43,7 +43,7 @@ [/// ["[1]" phase (.open: "[1]#[0]" monad)]]]]]) -(def: .public (custom [parser handler]) +(def .public (custom [parser handler]) (All (_ s) (-> [(Parser s) (-> Text (Generator s))] @@ -56,7 +56,7 @@ {try.#Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) -(def: .public (statement expression archive synthesis) +(def .public (statement expression archive synthesis) Phase! (case synthesis ... TODO: Get rid of this ASAP @@ -101,7 +101,7 @@ )) ... TODO: Get rid of this ASAP -(def: lux::syntax_char_case! +(def lux::syntax_char_case! (..custom [(all <>.and <s>.any <s>.any @@ -142,7 +142,7 @@ else! conditionals!))))))])) -(def: lux_procs +(def lux_procs Bundle (|> /.empty (/.install "syntax char case!" lux::syntax_char_case!) @@ -150,7 +150,7 @@ (_.do "equal?" (list reference) {.#None} subject)))) (/.install "try" (unary //runtime.lux//try)))) -(def: i64_procs +(def i64_procs Bundle (<| (/.prefix "i64") (|> /.empty @@ -173,7 +173,7 @@ (/.install "char" (unary //runtime.i64::char)) ))) -(def: f64_procs +(def f64_procs Bundle (<| (/.prefix "f64") (|> /.empty @@ -189,19 +189,19 @@ (/.install "encode" (unary (_.do "to_s" (list) {.#None}))) (/.install "decode" (unary //runtime.f64//decode))))) -(def: (text//char [subjectO paramO]) +(def (text//char [subjectO paramO]) (Binary Expression) (//runtime.text//char subjectO paramO)) -(def: (text//clip [paramO extraO subjectO]) +(def (text//clip [paramO extraO subjectO]) (Trinary Expression) (//runtime.text//clip paramO extraO subjectO)) -(def: (text//index [startO partO textO]) +(def (text//index [startO partO textO]) (Trinary Expression) (//runtime.text//index textO partO startO)) -(def: text_procs +(def text_procs Bundle (<| (/.prefix "text") (|> /.empty @@ -214,16 +214,16 @@ (/.install "clip" (trinary text//clip)) ))) -(def: (io//log! messageG) +(def (io//log! messageG) (Unary Expression) (|> (_.print/2 messageG (_.string text.new_line)) (_.or //runtime.unit))) -(def: io//error! +(def io//error! (Unary Expression) _.raise) -(def: io_procs +(def io_procs Bundle (<| (/.prefix "io") (|> /.empty @@ -231,7 +231,7 @@ (/.install "error" (unary ..io//error!)) ))) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "lux") (|> lux_procs diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux index 89638f972..ce451a263 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux @@ -34,27 +34,27 @@ ["//[1]" /// ["[1][0]" phase]]]]]]) -(def: (array::new [size]) +(def (array::new [size]) (Unary Expression) (_.do "new" (list size) {.#None} (is _.CVar (_.manual "Array")))) -(def: array::length +(def array::length (Unary Expression) (_.the "size")) -(def: (array::read [indexG arrayG]) +(def (array::read [indexG arrayG]) (Binary Expression) (_.item indexG arrayG)) -(def: (array::write [indexG valueG arrayG]) +(def (array::write [indexG valueG arrayG]) (Trinary Expression) (//runtime.array//write indexG valueG arrayG)) -(def: (array::delete [indexG arrayG]) +(def (array::delete [indexG arrayG]) (Binary Expression) (//runtime.array//write indexG _.nil arrayG)) -(def: array +(def array Bundle (<| (/.prefix "array") (|> /.empty @@ -65,7 +65,7 @@ (/.install "delete" (binary array::delete)) ))) -(def: object::get +(def object::get Handler (custom [(all <>.and <s>.text <s>.any) @@ -74,7 +74,7 @@ [objectG (phase archive objectS)] (in (_.the fieldS objectG))))])) -(def: object::do +(def object::do Handler (custom [(all <>.and <s>.text <s>.any (<>.some <s>.any)) @@ -85,13 +85,13 @@ (in (_.do methodS inputsG {.#None} objectG))))])) (with_template [<!> <?> <unit>] - [(def: <!> (Nullary Expression) (function.constant <unit>)) - (def: <?> (Unary Expression) (_.= <unit>))] + [(def <!> (Nullary Expression) (function.constant <unit>)) + (def <?> (Unary Expression) (_.= <unit>))] [object::nil object::nil? _.nil] ) -(def: object +(def object Bundle (<| (/.prefix "object") (|> /.empty @@ -101,13 +101,13 @@ (/.install "nil?" (unary object::nil?)) ))) -(def: ruby::constant +(def ruby::constant (custom [<s>.text (function (_ extension phase archive name) (at ////////phase.monad in (is _.CVar (_.manual name))))])) -(def: ruby::apply +(def ruby::apply (custom [(all <>.and <s>.any (<>.some <s>.any)) (function (_ extension phase archive [abstractionS inputsS]) @@ -116,14 +116,14 @@ inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply inputsG {.#None} abstractionG))))])) -(def: ruby::import +(def ruby::import (custom [<s>.text (function (_ extension phase archive module) (at ////////phase.monad in (_.require/1 (_.string module))))])) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "ruby") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme.lux index 7bca45f93..fdca305d2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme.lux @@ -12,7 +12,7 @@ [scheme [runtime (.only Bundle)]]]]]) -(def: .public bundle +(def .public bundle Bundle (dictionary.composite /common.bundle /host.bundle)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux index 5d4801be1..20d9da33e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux @@ -38,7 +38,7 @@ [/// ["[1]" phase]]]]]) -(def: .public (custom [parser handler]) +(def .public (custom [parser handler]) (All (_ s) (-> [(Parser s) (-> Text (Generator s))] @@ -51,12 +51,12 @@ {try.#Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) -(def: !unary +(def !unary (template (_ function) (|>> list _.apply (|> (_.constant function))))) ... TODO: Get rid of this ASAP -(def: lux::syntax_char_case! +(def lux::syntax_char_case! (..custom [(all <>.and <s>.any <s>.any @@ -81,7 +81,7 @@ elseG conditionalsG)))))])) -(def: lux_procs +(def lux_procs Bundle (|> /.empty (/.install "syntax char case!" lux::syntax_char_case!) @@ -89,12 +89,12 @@ (/.install "try" (unary //runtime.lux//try)) )) -(def: (capped operation parameter subject) +(def (capped operation parameter subject) (-> (-> Expression Expression Expression) (-> Expression Expression Expression)) (//runtime.i64//64 (operation parameter subject))) -(def: i64_procs +(def i64_procs Bundle (<| (/.prefix "i64") (|> /.empty @@ -114,7 +114,7 @@ (/.install "char" (unary (|>> _.integer->char/1 (_.make_string/2 (_.int +1))))) ))) -(def: f64_procs +(def f64_procs Bundle (<| (/.prefix "f64") (|> /.empty @@ -129,15 +129,15 @@ (/.install "encode" (unary _.number->string/1)) (/.install "decode" (unary //runtime.f64//decode))))) -(def: (text//index [offset sub text]) +(def (text//index [offset sub text]) (Trinary Expression) (//runtime.text//index offset sub text)) -(def: (text//clip [paramO extraO subjectO]) +(def (text//clip [paramO extraO subjectO]) (Trinary Expression) (//runtime.text//clip paramO extraO subjectO)) -(def: text_procs +(def text_procs Bundle (<| (/.prefix "text") (|> /.empty @@ -150,13 +150,13 @@ (/.install "clip" (trinary ..text//clip)) ))) -(def: (io//log! message) +(def (io//log! message) (Unary Expression) (_.begin (list (_.display/1 message) (_.display/1 (_.string text.new_line)) //runtime.unit))) -(def: io_procs +(def io_procs Bundle (<| (/.prefix "io") (|> /.empty @@ -164,7 +164,7 @@ (/.install "error" (unary _.raise/1)) ))) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "lux") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/host.lux index 862df2607..a3989de9f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/host.lux @@ -34,27 +34,27 @@ ["//[1]" /// ["[1][0]" phase]]]]]]) -(def: (array::new size) +(def (array::new size) (Unary Expression) (_.make_vector/2 size _.nil)) -(def: array::length +(def array::length (Unary Expression) _.vector_length/1) -(def: (array::read [indexG arrayG]) +(def (array::read [indexG arrayG]) (Binary Expression) (_.vector_ref/2 arrayG indexG)) -(def: (array::write [indexG valueG arrayG]) +(def (array::write [indexG valueG arrayG]) (Trinary Expression) (//runtime.array//write indexG valueG arrayG)) -(def: (array::delete [indexG arrayG]) +(def (array::delete [indexG arrayG]) (Binary Expression) (//runtime.array//write indexG _.nil arrayG)) -(def: array +(def array Bundle (<| (/.prefix "array") (|> /.empty @@ -66,13 +66,13 @@ ))) (with_template [<!> <?> <unit>] - [(def: <!> (Nullary Expression) (function.constant <unit>)) - (def: <?> (Unary Expression) (_.eq?/2 <unit>))] + [(def <!> (Nullary Expression) (function.constant <unit>)) + (def <?> (Unary Expression) (_.eq?/2 <unit>))] [object::nil object::nil? _.nil] ) -(def: object +(def object Bundle (<| (/.prefix "object") (|> /.empty @@ -80,7 +80,7 @@ (/.install "nil?" (unary object::nil?)) ))) -(def: scheme::constant +(def scheme::constant (custom [<s>.text (function (_ extension phase archive name) @@ -88,7 +88,7 @@ [] (in (_.var name))))])) -(def: scheme::apply +(def scheme::apply (custom [(all <>.and <s>.any (<>.some <s>.any)) (function (_ extension phase archive [abstractionS inputsS]) @@ -97,7 +97,7 @@ inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply inputsG abstractionG))))])) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "scheme") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/synthesis.lux index dbaa7282b..fcfa9b7ea 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/synthesis.lux @@ -6,6 +6,6 @@ [/// [synthesis (.only Bundle)]]]) -(def: .public bundle +(def .public bundle Bundle bundle.empty) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp.lux index e016f9109..e31b13851 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp.lux @@ -25,7 +25,7 @@ [reference (.only) [variable (.only)]]]]]]]) -(def: .public (generate archive synthesis) +(def .public (generate archive synthesis) Phase (case synthesis (^.with_template [<tag> <generator>] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux index 553bb6734..671b46045 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux @@ -37,15 +37,15 @@ [meta [archive (.only Archive)]]]]]]]) -(def: .public register +(def .public register (-> Register Var/1) (|>> (///reference.local //reference.system) as_expected)) -(def: .public capture +(def .public capture (-> Register Var/1) (|>> (///reference.foreign //reference.system) as_expected)) -(def: .public (let expression archive [valueS register bodyS]) +(def .public (let expression archive [valueS register bodyS]) (Generator [Synthesis Register Synthesis]) (do ///////phase.monad [valueG (expression archive valueS) @@ -53,7 +53,7 @@ (in (_.let (list [(..register register) valueG]) (list bodyG))))) -(def: .public (if expression archive [testS thenS elseS]) +(def .public (if expression archive [testS thenS elseS]) (Generator [Synthesis Synthesis Synthesis]) (do ///////phase.monad [testG (expression archive testS) @@ -61,7 +61,7 @@ elseG (expression archive elseS)] (in (_.if testG thenG elseG)))) -(def: .public (get expression archive [pathP valueS]) +(def .public (get expression archive [pathP valueS]) (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueG (expression archive valueS)] @@ -76,38 +76,38 @@ valueG pathP)))) -(def: @savepoint (_.var "lux_pm_savepoint")) -(def: @cursor (_.var "lux_pm_cursor")) -(def: @temp (_.var "lux_pm_temp")) -(def: @variant (_.var "lux_pm_variant")) +(def @savepoint (_.var "lux_pm_savepoint")) +(def @cursor (_.var "lux_pm_cursor")) +(def @temp (_.var "lux_pm_temp")) +(def @variant (_.var "lux_pm_variant")) -(def: (push! value) +(def (push! value) (-> (Expression Any) (Expression Any)) (_.setq @cursor (_.cons/2 [value @cursor]))) -(def: pop! +(def pop! (Expression Any) (_.setq @cursor (_.cdr/1 @cursor))) -(def: peek +(def peek (Expression Any) (_.car/1 @cursor)) -(def: save! +(def save! (Expression Any) (_.setq @savepoint (_.cons/2 [@cursor @savepoint]))) -(def: restore! +(def restore! (List (Expression Any)) (list (_.setq @cursor (_.car/1 @savepoint)) (_.setq @savepoint (_.cdr/1 @savepoint)))) -(def: (multi_pop! pops) +(def (multi_pop! pops) (-> Nat (Expression Any)) (_.setq @cursor (_.nthcdr/2 [(_.int (.int pops)) @cursor]))) (with_template [<name> <flag> <prep>] - [(def: (<name> @fail simple? idx next!) + [(def (<name> @fail simple? idx next!) (-> _.Tag Bit Nat (Maybe (Expression Any)) (Expression Any)) (.let [<failure_condition> (_.eq/2 [@variant @temp])] (_.let (list [@variant ..peek]) @@ -129,7 +129,7 @@ [right_choice (_.string "") ++] ) -(def: (alternation @otherwise pre! post!) +(def (alternation @otherwise pre! post!) (-> _.Tag (Expression Any) (Expression Any) (Expression Any)) (_.tagbody (all list#composite (list ..save! @@ -138,7 +138,7 @@ ..restore! (list post!)))) -(def: (pattern_matching' expression archive) +(def (pattern_matching' expression archive) (Generator [Var/1 _.Tag _.Tag Path]) (function (again [$output @done @fail pathP]) (.case pathP @@ -230,7 +230,7 @@ post! (again [$output @done @fail postP])] (in (_.progn (list pre! post!))))))) -(def: (pattern_matching $output expression archive pathP) +(def (pattern_matching $output expression archive pathP) (-> Var/1 (Generator Path)) (do [! ///////phase.monad] [@done (at ! each (|>> %.nat (format "lux_case_done") _.tag) /////generation.next) @@ -242,7 +242,7 @@ (_.error/1 (_.string ////synthesis/case.pattern_matching_error)) @done))))) -(def: .public (case expression archive [valueS pathP]) +(def .public (case expression archive [valueS pathP]) (Generator [Synthesis Path]) (do [! ///////phase.monad] [initG (expression archive valueS) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension.lux index 90acc3cef..eac649c9c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension.lux @@ -9,6 +9,6 @@ [/ ["[0]" common]]) -(def: .public bundle +(def .public bundle Bundle common.bundle) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux index 36e3a4a95..e0e2a756d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux @@ -23,26 +23,26 @@ [extension ["[0]" bundle]]]]]) -(def: lux_procs +(def lux_procs Bundle (|> bundle.empty (bundle.install "is" (binary (product.uncurried _.eq))) (bundle.install "try" (unary ///runtime.lux//try)))) -(def: (i64//left_shifted [paramG subjectG]) +(def (i64//left_shifted [paramG subjectG]) (Binary (Expression Any)) (_.ash (_.rem (_.int +64) paramG) subjectG)) -(def: (i64//arithmetic_right_shifted [paramG subjectG]) +(def (i64//arithmetic_right_shifted [paramG subjectG]) (Binary (Expression Any)) (_.ash (|> paramG (_.rem (_.int +64)) (_.* (_.int -1))) subjectG)) -(def: (i64//logic_right_shifted [paramG subjectG]) +(def (i64//logic_right_shifted [paramG subjectG]) (Binary (Expression Any)) (///runtime.i64//logic_right_shifted (_.rem (_.int +64) paramG) subjectG)) -(def: i64_procs +(def i64_procs Bundle (<| (bundle.prefix "i64") (|> bundle.empty @@ -64,7 +64,7 @@ (bundle.install "char" (unary (|>> _.code_char/1 _.string/1))) ))) -(def: f64_procs +(def f64_procs Bundle (<| (bundle.prefix "f64") (|> bundle.empty @@ -85,21 +85,21 @@ (///runtime.some @temp) ///runtime.none))))))))) -(def: (text//< [paramG subjectG]) +(def (text//< [paramG subjectG]) (Binary (Expression Any)) (|> (_.string< paramG subjectG) _.null/1 _.not/1)) -(def: (text//clip [paramO extraO subjectO]) +(def (text//clip [paramO extraO subjectO]) (Trinary (Expression Any)) (///runtime.text//clip subjectO paramO extraO)) -(def: (text//index [startO partO textO]) +(def (text//index [startO partO textO]) (Trinary (Expression Any)) (///runtime.text//index textO partO startO)) -(def: text_procs +(def text_procs Bundle (<| (bundle.prefix "text") (|> bundle.empty @@ -112,13 +112,13 @@ (bundle.install "clip" (trinary text//clip)) ))) -(def: (void code) +(def (void code) (-> (Expression Any) (Expression Any)) (all _.progn code ///runtime.unit)) -(def: io_procs +(def io_procs Bundle (<| (bundle.prefix "io") (|> bundle.empty @@ -126,7 +126,7 @@ (bundle.install "error" (unary _.error/1)) ))) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "lux") (|> lux_procs diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux index 29ed270dd..9029be0ed 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux @@ -29,18 +29,18 @@ [reference [variable (.only Register Variable)]]]]]]) -(def: .public (apply expression archive [functionS argsS+]) +(def .public (apply expression archive [functionS argsS+]) (Generator (Application Synthesis)) (do [! ///////phase.monad] [functionG (expression archive functionS) argsG+ (monad.each ! (expression archive) argsS+)] (in (_.funcall/+ [functionG argsG+])))) -(def: capture +(def capture (-> Register Var/1) (|>> (///reference.foreign //reference.system) as_expected)) -(def: (with_closure inits function_definition) +(def (with_closure inits function_definition) (-> (List (Expression Any)) (Expression Any) (Operation (Expression Any))) (case inits {.#End} @@ -55,10 +55,10 @@ function_definition]]) (_.funcall/+ [(_.function/1 @closure) inits])))))) -(def: input +(def input (|>> ++ //case.register)) -(def: .public (function expression archive [environment arity bodyS]) +(def .public (function expression archive [environment arity bodyS]) (Generator (Abstraction Synthesis)) (do [! ///////phase.monad] [@scope (at ! each (|>> %.nat (format "function_scope") _.tag) /////generation.next) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux index 7d6e7a6e7..f71d3e18b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux @@ -32,7 +32,7 @@ [reference [variable (.only Register)]]]]]]]) -(def: .public (scope expression archive [start initsS+ bodyS]) +(def .public (scope expression archive [start initsS+ bodyS]) (Generator (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop @@ -58,7 +58,7 @@ (_.setq @output bodyG))) @output)))))) -(def: .public (again expression archive argsS+) +(def .public (again expression archive argsS+) (Generator (List Synthesis)) (do [! ///////phase.monad] [[tag offset] /////generation.anchor diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/primitive.lux index 43a98c287..419179137 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/primitive.lux @@ -4,18 +4,18 @@ [target ["_" common_lisp (.only Expression)]]]]) -(def: .public bit +(def .public bit (-> Bit (Expression Any)) _.bool) -(def: .public i64 +(def .public i64 (-> (I64 Any) (Expression Any)) (|>> .int _.int)) -(def: .public f64 +(def .public f64 (-> Frac (Expression Any)) _.double) -(def: .public text +(def .public text (-> Text (Expression Any)) _.string) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/reference.lux index b64f9ecbb..7b2dcab79 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(def: .public system +(def .public system (System (Expression Any)) (implementation - (def: constant _.var) - (def: variable _.var))) + (def constant _.var) + (def variable _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux index e5b54688c..a924fbe8f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux @@ -38,7 +38,7 @@ [archive (.only Output Archive) ["[0]" artifact (.only Registry)]]]]]]) -(def: module_id +(def module_id 0) (with_template [<name> <base>] @@ -54,40 +54,40 @@ (type: .public (Generator i) (-> Phase Archive i (Operation (Expression Any)))) -(def: .public unit +(def .public unit (_.string /////synthesis.unit)) -(def: (flag value) +(def (flag value) (-> Bit Literal) (if value (_.string "") _.nil)) -(def: (variant' tag last? value) +(def (variant' tag last? value) (-> (Expression Any) (Expression Any) (Expression Any) (Computation Any)) (_.list/* (list tag last? value))) -(def: .public (variant [lefts right? value]) +(def .public (variant [lefts right? value]) (-> (Variant (Expression Any)) (Computation Any)) (variant' (_.int (.int lefts)) (flag right?) value)) -(def: .public none +(def .public none (Computation Any) (|> ..unit [0 #0] ..variant)) -(def: .public some +(def .public some (-> (Expression Any) (Computation Any)) (|>> [1 #1] ..variant)) -(def: .public left +(def .public left (-> (Expression Any) (Computation Any)) (|>> [0 #0] ..variant)) -(def: .public right +(def .public right (-> (Expression Any) (Computation Any)) (|>> [1 #1] ..variant)) -(def: .public with_vars +(def .public with_vars (syntax (_ [vars (<code>.tuple (<>.some <code>.local)) body <code>.any]) (do [! meta.monad] @@ -100,7 +100,7 @@ list.together))] (~ body)))))))) -(def: runtime: +(def runtime: (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -114,11 +114,11 @@ {.#Left name} (let [g!name (code.local name) code_nameC (code.local (format "@" name))] - (in (list (` (def: .public (~ g!name) + (in (list (` (def .public (~ g!name) _.Var/1 (~ runtime_name))) - (` (def: (~ code_nameC) + (` (def (~ code_nameC) (_.Expression Any) (_.defparameter (~ runtime_name) (~ code))))))) @@ -129,11 +129,11 @@ inputsC (list#each code.local inputs) inputs_typesC (list#each (function.constant (` (_.Expression Any))) inputs)] - (in (list (` (def: .public ((~ g!name) (~+ inputsC)) + (in (list (` (def .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) (_.Computation Any)) (_.call/* (~ runtime_name) (list (~+ inputsC))))) - (` (def: (~ code_nameC) + (` (def (~ code_nameC) (_.Expression Any) (..with_vars [(~+ inputsC)] (_.defun (~ runtime_name) (_.args (list (~+ inputsC))) @@ -159,18 +159,18 @@ (list (_.reverse/1 inputs) ..none)])))) -(def: runtime//lux +(def runtime//lux (List (Expression Any)) (list @lux//try @lux//program_args)) -(def: last_index +(def last_index (|>> _.length/1 [(_.int +1)] _.-/2)) (with_expansions [<recur> (these (all _.then (_.; (_.set lefts (_.-/2 [last_index_right lefts]))) (_.; (_.set tuple (_.nth last_index_right tuple)))))] - (def: !recur + (def !recur (template (_ <side>) (<side> (_.-/2 [last_index_right lefts]) (_.elt/2 [tuple last_index_right])))) @@ -223,7 +223,7 @@ no_match!))))))) -(def: runtime//adt +(def runtime//adt (List (Expression Any)) (list @tuple//left @tuple//right @@ -240,7 +240,7 @@ [(_.*/2 [(_.int -1) shift])] _.ash/2 [mask] _.logand/2)))) -(def: runtime//i64 +(def runtime//i64 (List (Expression Any)) (list @i64//right_shifted)) @@ -254,7 +254,7 @@ (..some index) ..none))))) -(def: runtime//text +(def runtime//text (List (Expression Any)) (list @text//index @text//clip)) @@ -270,11 +270,11 @@ (_.call/* (_.var "excl:exit") (list code))) (_.call/* (_.var "cl-user::quit") (list code))))) -(def: runtime//io +(def runtime//io (List (Expression Any)) (list @io//exit)) -(def: runtime +(def runtime (_.progn (all list#composite runtime//adt runtime//lux @@ -282,7 +282,7 @@ runtime//text runtime//io))) -(def: .public generate +(def .public generate (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux index b14e852b1..05ed5efea 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux @@ -14,7 +14,7 @@ ["//[1]" /// ["[1][0]" phase (.open: "[1]#[0]" monad)]]]]) -(def: .public (tuple expression archive elemsS+) +(def .public (tuple expression archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ {.#End} @@ -28,7 +28,7 @@ (monad.each ///////phase.monad (expression archive)) (///////phase#each _.vector/*)))) -(def: .public (variant expression archive [lefts right? valueS]) +(def .public (variant expression archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux index 78d2d4295..680957008 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux @@ -21,17 +21,17 @@ [/// ["[1]" phase]]]]) -(def: Vector +(def Vector (syntax (_ [size <code>.nat elemT <code>.any]) (in (list (` [(~+ (list.repeated size elemT))]))))) -(def: Arity +(def Arity (template (_ arity) [(All (_ of) (-> (Vector arity of) of))])) -(def: arity +(def arity (syntax (_ [arity <code>.nat]) (with_symbols [g!_ g!extension g!name g!phase g!archive g!inputs g!anchor g!expression g!directive] (do [! meta.monad] @@ -58,7 +58,7 @@ (with_template [<arity> <type> <term>] [(type: .public <type> (Arity <arity>)) - (def: .public <term> (arity <arity>))] + (def .public <term> (arity <arity>))] [0 Nullary nullary] [1 Unary unary] @@ -69,7 +69,7 @@ (type: .public (Variadic of) (-> (List of) of)) -(def: .public (variadic extension) +(def .public (variadic extension) (All (_ anchor expression directive) (-> (Variadic expression) (generation.Handler anchor expression directive))) (function (_ extension_name) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux index a5471f9b6..5d6b92824 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux @@ -34,7 +34,7 @@ (exception: .public cannot_recur_as_an_expression) -(def: (expression archive synthesis) +(def (expression archive synthesis) Phase (case synthesis (^.with_template [<tag> <generator>] @@ -84,6 +84,6 @@ {synthesis.#Extension extension} (///extension.apply archive expression extension))) -(def: .public generate +(def .public generate Phase ..expression) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux index aa18b4348..2e48dea7c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux @@ -36,11 +36,11 @@ [meta [archive (.only Archive)]]]]]]]) -(def: .public register +(def .public register (-> Register Var) (|>> (///reference.local //reference.system) as_expected)) -(def: .public (exec expression archive [this that]) +(def .public (exec expression archive [this that]) (Generator [Synthesis Synthesis]) (do ///////phase.monad [this (expression archive this) @@ -48,7 +48,7 @@ (in (|> (_.array (list this that)) (_.at (_.int +1)))))) -(def: .public (exec! statement expression archive [this that]) +(def .public (exec! statement expression archive [this that]) (Generator! [Synthesis Synthesis]) (do ///////phase.monad [this (expression archive this) @@ -57,7 +57,7 @@ (_.statement this) that)))) -(def: .public (let expression archive [valueS register bodyS]) +(def .public (let expression archive [valueS register bodyS]) (Generator [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -67,7 +67,7 @@ (_.return bodyO)) (list valueO))))) -(def: .public (let! statement expression archive [valueS register bodyS]) +(def .public (let! statement expression archive [valueS register bodyS]) (Generator! [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -76,7 +76,7 @@ (_.define (..register register) valueO) bodyO)))) -(def: .public (if expression archive [testS thenS elseS]) +(def .public (if expression archive [testS thenS elseS]) (Generator [Synthesis Synthesis Synthesis]) (do ///////phase.monad [testO (expression archive testS) @@ -84,7 +84,7 @@ elseO (expression archive elseS)] (in (_.? testO thenO elseO)))) -(def: .public (if! statement expression archive [testS thenS elseS]) +(def .public (if! statement expression archive [testS thenS elseS]) (Generator! [Synthesis Synthesis Synthesis]) (do ///////phase.monad [testO (expression archive testS) @@ -94,7 +94,7 @@ thenO elseO)))) -(def: .public (get expression archive [pathP valueS]) +(def .public (get expression archive [pathP valueS]) (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueO (expression archive valueS)] @@ -106,51 +106,51 @@ valueO (list.reversed pathP))))) -(def: @savepoint (_.var "lux_pm_cursor_savepoint")) -(def: @cursor (_.var "lux_pm_cursor")) -(def: @temp (_.var "lux_pm_temp")) +(def @savepoint (_.var "lux_pm_cursor_savepoint")) +(def @cursor (_.var "lux_pm_cursor")) +(def @temp (_.var "lux_pm_temp")) -(def: (push_cursor! value) +(def (push_cursor! value) (-> Expression Statement) (_.statement (|> @cursor (_.do "push" (list value))))) -(def: peek_and_pop_cursor +(def peek_and_pop_cursor Expression (|> @cursor (_.do "pop" (list)))) -(def: pop_cursor! +(def pop_cursor! Statement (_.statement ..peek_and_pop_cursor)) -(def: length +(def length (|>> (_.the "length"))) -(def: last_index +(def last_index (|>> ..length (_.- (_.i32 +1)))) -(def: peek_cursor +(def peek_cursor Expression (|> @cursor (_.at (last_index @cursor)))) -(def: save_cursor! +(def save_cursor! Statement (.let [cursor (|> @cursor (_.do "slice" (list)))] (_.statement (|> @savepoint (_.do "push" (list cursor)))))) -(def: restore_cursor! +(def restore_cursor! Statement (_.set @cursor (|> @savepoint (_.do "pop" (list))))) -(def: fail_pm! _.break) +(def fail_pm! _.break) -(def: (multi_pop_cursor! pops) +(def (multi_pop_cursor! pops) (-> Nat Statement) (.let [popsJS (_.i32 (.int pops))] (_.statement (|> @cursor (_.do "splice" (list (|> @cursor ..length (_.- popsJS)) popsJS)))))) (with_template [<name> <flag>] - [(def: (<name> simple? idx) + [(def (<name> simple? idx) (-> Bit Nat Statement) (all _.then (_.set @temp (//runtime.sum//get ..peek_cursor <flag> @@ -166,7 +166,7 @@ [right_choice //runtime.unit] ) -(def: (alternation pre! post!) +(def (alternation pre! post!) (-> Statement Statement Statement) (all _.then (_.do_while (_.boolean false) @@ -177,7 +177,7 @@ ..restore_cursor! post!))) -(def: (optimized_pattern_matching again pathP) +(def (optimized_pattern_matching again pathP) (-> (-> Path (Operation Statement)) (-> Path (Operation (Maybe Statement)))) (.case pathP @@ -233,7 +233,7 @@ _ (///////phase#in {.#None}))) -(def: (pattern_matching' statement expression archive) +(def (pattern_matching' statement expression archive) (-> Phase! Phase Archive (-> Path (Operation Statement))) (function (again pathP) @@ -318,7 +318,7 @@ ([/////synthesis.path/seq _.then] [/////synthesis.path/alt ..alternation])))))) -(def: (pattern_matching statement expression archive pathP) +(def (pattern_matching statement expression archive pathP) (-> Phase! Phase Archive Path (Operation Statement)) (do ///////phase.monad [pattern_matching! (pattern_matching' statement expression archive pathP)] @@ -327,7 +327,7 @@ pattern_matching!) (_.throw (_.string ////synthesis/case.pattern_matching_error)))))) -(def: .public (case! statement expression archive [valueS pathP]) +(def .public (case! statement expression archive [valueS pathP]) (Generator! [Synthesis Path]) (do ///////phase.monad [stack_init (expression archive valueS) @@ -338,7 +338,7 @@ (_.define @savepoint (_.array (list))) pattern_matching!)))) -(def: .public (case statement expression archive [valueS pathP]) +(def .public (case statement expression archive [valueS pathP]) (-> Phase! (Generator [Synthesis Path])) (do ///////phase.monad [pattern_matching! (..case! statement expression archive [valueS pathP])] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux index 58b0e104a..c7c5226ac 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux @@ -33,18 +33,18 @@ [dependency ["[1]" artifact]]]]]]]]) -(def: .public (apply expression archive [functionS argsS+]) +(def .public (apply expression archive [functionS argsS+]) (Generator (Reification Synthesis)) (do [! ///////phase.monad] [functionO (expression archive functionS) argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply functionO argsO+)))) -(def: capture +(def capture (-> Register Var) (|>> (///reference.foreign //reference.system) as_expected)) -(def: (with_closure @self inits body!) +(def (with_closure @self inits body!) (-> Var (List Expression) Statement [Statement Expression]) (case inits {.#End} @@ -58,20 +58,20 @@ (_.return (_.function @self (list) body!))) (_.apply @self inits)])) -(def: @curried +(def @curried (_.var "curried")) -(def: input +(def input (|>> ++ //case.register)) -(def: @@arguments +(def @@arguments (_.var "arguments")) -(def: (@scope function_name) +(def (@scope function_name) (-> unit.ID Text) (format (///reference.artifact function_name) "_scope")) -(def: .public (function statement expression archive [environment arity bodyS]) +(def .public (function statement expression archive [environment arity bodyS]) (-> Phase! (Generator (Abstraction Synthesis))) (do [! ///////phase.monad] [dependencies (cache.dependencies archive bodyS) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux index de5ee0616..eb9d60063 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux @@ -25,15 +25,15 @@ [reference [variable (.only Register)]]]]]) -(def: @scope +(def @scope (-> Nat Text) (|>> %.nat (format "scope"))) -(def: $iteration +(def $iteration (-> Nat Var) (|>> %.nat (format "iteration") _.var)) -(def: (setup $iteration initial? offset bindings body) +(def (setup $iteration initial? offset bindings body) (-> Var Bit Register (List Expression) Statement Statement) (case bindings (pattern (list)) @@ -60,7 +60,7 @@ (list#mix _.then body) (_.then (_.define $iteration (_.array bindings)))))) -(def: .public (scope! statement expression archive [start initsS+ bodyS]) +(def .public (scope! statement expression archive [start initsS+ bodyS]) (Generator! (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop @@ -82,7 +82,7 @@ (_.do_while (_.boolean true) body!))))))) -(def: .public (scope statement expression archive [start initsS+ bodyS]) +(def .public (scope statement expression archive [start initsS+ bodyS]) (-> Phase! (Generator (Scope Synthesis))) (case initsS+ ... function/false/non-independent loop @@ -95,10 +95,10 @@ [loop! (scope! statement expression archive [start initsS+ bodyS])] (in (_.apply (_.closure (list) loop!) (list)))))) -(def: @temp +(def @temp (_.var "lux_again_values")) -(def: .public (again! statement expression archive argsS+) +(def .public (again! statement expression archive argsS+) (Generator! (List Synthesis)) (do [! ///////phase.monad] [[offset @scope] /////generation.anchor diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/primitive.lux index aa45d7b64..19dd18af2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/primitive.lux @@ -6,16 +6,16 @@ ["[0]" // ["[1][0]" runtime]]) -(def: .public bit +(def .public bit _.boolean) -(def: .public (i64 value) +(def .public (i64 value) (-> (I64 Any) Computation) (//runtime.i64 (|> value //runtime.high .int _.i32) (|> value //runtime.low .int _.i32))) -(def: .public f64 +(def .public f64 _.number) -(def: .public text +(def .public text _.string) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/reference.lux index 8a042db48..6cca81aeb 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(def: .public system +(def .public system (System Expression) (implementation - (def: constant' _.var) - (def: variable' _.var))) + (def constant' _.var) + (def variable' _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux index 0bda3304e..41da758da 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux @@ -58,30 +58,30 @@ (type: .public (Generator! i) (-> Phase! Phase Archive i (Operation Statement))) -(def: .public high +(def .public high (-> (I64 Any) (I64 Any)) (i64.right_shifted 32)) -(def: .public low +(def .public low (-> (I64 Any) (I64 Any)) (let [mask (-- (i64.left_shifted 32 1))] (|>> (i64.and mask)))) -(def: .public unit +(def .public unit Computation (_.string /////synthesis.unit)) -(def: .public (flag value) +(def .public (flag value) (-> Bit Computation) (if value (_.string "") _.null)) -(def: (feature name definition) +(def (feature name definition) (-> Var (-> Var Expression) Statement) (_.define name (definition name))) -(def: .public with_vars +(def .public with_vars (syntax (_ [vars (<code>.tuple (<>.some <code>.local)) body <code>.any]) (do [! meta.monad] @@ -94,7 +94,7 @@ list.together))] (~ body)))))))) -(def: runtime: +(def runtime: (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -104,11 +104,11 @@ (case declaration {.#Left name} (let [g!name (code.local name)] - (in (list (` (def: .public (~ g!name) + (in (list (` (def .public (~ g!name) Var (~ runtime_name))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) Statement (..feature (~ runtime_name) (function ((~ g!_) (~ g!name)) @@ -118,11 +118,11 @@ (let [g!name (code.local name) inputsC (list#each code.local inputs) inputs_typesC (list#each (function.constant (` _.Expression)) inputs)] - (in (list (` (def: .public ((~ g!name) (~+ inputsC)) + (in (list (` (def .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) Computation) (_.apply (~ runtime_name) (list (~+ inputsC))))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) Statement (..feature (~ runtime_name) (function ((~ g!_) (~ g!_)) @@ -130,15 +130,15 @@ (_.function (~ g!_) (list (~+ inputsC)) (~ code))))))))))))))) -(def: length +(def length (-> Expression Computation) (_.the "length")) -(def: last_index +(def last_index (-> Expression Computation) (|>> ..length (_.- (_.i32 +1)))) -(def: (last_element tuple) +(def (last_element tuple) (_.at (..last_index tuple) tuple)) @@ -170,9 +170,9 @@ (_.return (_.do "slice" (list right_index) tuple))) ))))) -(def: .public variant_tag_field "_lux_tag") -(def: .public variant_flag_field "_lux_flag") -(def: .public variant_value_field "_lux_value") +(def .public variant_tag_field "_lux_tag") +(def .public variant_flag_field "_lux_flag") +(def .public variant_value_field "_lux_value") (runtime: variant//new (let [@this (_.var "this")] @@ -184,7 +184,7 @@ (_.set (_.the ..variant_value_field @this) value) ))))) -(def: .public (variant tag last? value) +(def .public (variant tag last? value) (-> Expression Expression Expression Computation) (_.new ..variant//new (list tag last? value))) @@ -216,23 +216,23 @@ actual::value))) mismatch!))) -(def: left +(def left (-> Expression Computation) (..variant (_.i32 +0) (flag #0))) -(def: right +(def right (-> Expression Computation) (..variant (_.i32 +0) (flag #1))) -(def: none +(def none Computation (..left ..unit)) -(def: some +(def some (-> Expression Computation) ..right) -(def: runtime//structure +(def runtime//structure Statement (all _.then @tuple//left @@ -258,15 +258,15 @@ output))))) (_.return output)))) -(def: runtime//lux +(def runtime//lux Statement (all _.then @lux//try @lux//program_args )) -(def: .public i64_low_field Text "_lux_low") -(def: .public i64_high_field Text "_lux_high") +(def .public i64_low_field Text "_lux_low") +(def .public i64_high_field Text "_lux_high") (runtime: i64::new (let [@this (_.var "this")] @@ -277,7 +277,7 @@ (_.set (_.the ..i64_low_field @this) low) ))))) -(def: .public (i64 high low) +(def .public (i64 high low) (-> Expression Expression Computation) (_.new ..i64::new (list high low))) @@ -297,16 +297,16 @@ (_.return (..i64 (_.bit_not (_.the ..i64_high_field value)) (_.bit_not (_.the ..i64_low_field value))))) -(def: (cap_shift! shift) +(def (cap_shift! shift) (-> Var Statement) (_.set shift (|> shift (_.bit_and (_.i32 +63))))) -(def: (no_shift! shift input) +(def (no_shift! shift input) (-> Var Var (-> Expression Expression)) (_.? (|> shift (_.= (_.i32 +0))) input)) -(def: small_shift? +(def small_shift? (-> Var Expression) (|>> (_.< (_.i32 +32)))) @@ -352,7 +352,7 @@ (..i64 (_.i32 +0) (|> input (_.the ..i64_high_field) (_.logic_right_shift (_.- (_.i32 +32) shift)))))))) -(def: runtime//bit +(def runtime//bit Statement (all _.then @i64::and @@ -536,12 +536,12 @@ (negative? (i64::- parameter subject)))) )))) -(def: (i64::<= param subject) +(def (i64::<= param subject) (-> Expression Expression Expression) (|> (i64::< param subject) (_.or (i64::= param subject)))) -(def: negative? +(def negative? (i64::< i64::zero)) (runtime: (i64::/ parameter subject) @@ -626,7 +626,7 @@ (i64::* parameter))] (_.return (i64::- flat subject)))) -(def: runtime//i64 +(def runtime//i64 Statement (all _.then ..runtime//bit @@ -675,7 +675,7 @@ (_.throw (_.string "[Lux Error] Cannot get char from text.")) (_.return (i64::of_number result)))))) -(def: runtime//text +(def runtime//text Statement (all _.then @text//index @@ -704,7 +704,7 @@ (runtime: (io//error message) (_.throw message)) -(def: runtime//io +(def runtime//io Statement (all _.then @io//log @@ -729,7 +729,7 @@ (_.statement (_.delete (_.at field object))) (_.return object))) -(def: runtime//js +(def runtime//js Statement (all _.then @js//get @@ -747,14 +747,14 @@ (_.statement (_.delete (_.at (_.the ..i64_low_field idx) array))) (_.return array))) -(def: runtime//array +(def runtime//array Statement (all _.then @array//write @array//delete )) -(def: runtime +(def runtime Statement (all _.then runtime//structure @@ -766,10 +766,10 @@ runtime//lux )) -(def: module_id +(def module_id 0) -(def: .public generate +(def .public generate (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux index 14e911912..9fdbc4592 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux @@ -15,7 +15,7 @@ ["//[1]" /// (.only) ["[1][0]" phase (.open: "[1]#[0]" monad)]]]]) -(def: .public (tuple generate archive elemsS+) +(def .public (tuple generate archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ {.#End} @@ -29,7 +29,7 @@ [elemsT+ (monad.each ! (generate archive) elemsS+)] (in (_.array elemsT+))))) -(def: .public (variant generate archive [lefts right? valueS]) +(def .public (variant generate archive [lefts right? valueS]) (Generator (Variant Synthesis)) (///////phase#each (//runtime.variant (_.i32 (.int lefts)) (//runtime.flag right?)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm.lux index a23f31e36..0a8c1c026 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm.lux @@ -21,7 +21,7 @@ ["[0]" reference] ["[1]" phase (.open: "[1]#[0]" monad)]]]]]) -(def: .public (generate archive synthesis) +(def .public (generate archive synthesis) Phase (case synthesis (^.with_template [<tag> <generator>] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux index 73ec8260e..0ae4da146 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux @@ -39,7 +39,7 @@ [reference [variable (.only Register)]]]]]) -(def: (pop_alt stack_depth) +(def (pop_alt stack_depth) (-> Nat (Bytecode Any)) (.case stack_depth 0 (_#in []) @@ -50,27 +50,27 @@ _.pop2 (pop_alt (n.- 2 stack_depth))))) -(def: int +(def int (-> (I64 Any) (Bytecode Any)) (|>> .i64 i32.i32 _.int)) -(def: long +(def long (-> (I64 Any) (Bytecode Any)) (|>> .int _.long)) -(def: peek +(def peek (Bytecode Any) (all _.composite _.dup (//runtime.get //runtime.stack_head))) -(def: pop +(def pop (Bytecode Any) (all _.composite (//runtime.get //runtime.stack_tail) (_.checkcast //type.stack))) -(def: (left_projection lefts) +(def (left_projection lefts) (-> Nat (Bytecode Any)) (all _.composite (_.checkcast //type.tuple) @@ -82,25 +82,25 @@ lefts //runtime.left_projection))) -(def: (right_projection lefts) +(def (right_projection lefts) (-> Nat (Bytecode Any)) (all _.composite (_.checkcast //type.tuple) (..int lefts) //runtime.right_projection)) -(def: equals@Object +(def equals@Object (.let [class (type.class "java.lang.Object" (list)) method (type.method [(list) (list //type.value) type.boolean (list)])] (_.invokevirtual class "equals" method))) -(def: (path|bind register) +(def (path|bind register) (-> Register (Operation (Bytecode Any))) (operation#in (all _.composite ..peek (_.astore register)))) -(def: (path|bit_fork again @else [when thenP elseP]) +(def (path|bit_fork again @else [when thenP elseP]) (-> (-> Path (Operation (Bytecode Any))) Label [Bit Path (Maybe Path)] (Operation (Bytecode Any))) @@ -124,7 +124,7 @@ else!))))) (with_template [<name> <type> <unwrap> <dup> <pop> <test> <comparison> <if>] - [(def: (<name> again @else cons) + [(def (<name> again @else cons) (-> (-> Path (Operation (Bytecode Any))) Label (Fork <type> Path) (Operation (Bytecode Any))) @@ -157,7 +157,7 @@ [path|text_fork Text (at _.monad in []) _.dup _.pop _.string ..equals@Object _.ifeq] ) -(def: (path' stack_depth @else @end phase archive) +(def (path' stack_depth @else @end phase archive) (-> Nat Label Label (Generator Path)) (function (again path) (.case path @@ -242,7 +242,7 @@ right!))) ))) -(def: (path @end phase archive path) +(def (path @end phase archive path) (-> Label (Generator Path)) (do phase.monad [@else //runtime.forge_label @@ -257,7 +257,7 @@ )) )))) -(def: .public (if phase archive [testS thenS elseS]) +(def .public (if phase archive [testS thenS elseS]) (Generator [Synthesis Synthesis Synthesis]) (do phase.monad [test! (phase archive testS) @@ -277,7 +277,7 @@ (<| (_.when_acknowledged @end) (_.set_label @end))))))) -(def: .public (exec phase archive [this that]) +(def .public (exec phase archive [this that]) (Generator [Synthesis Synthesis]) (do phase.monad [this! (phase archive this) @@ -287,7 +287,7 @@ _.pop that!)))) -(def: .public (let phase archive [inputS register bodyS]) +(def .public (let phase archive [inputS register bodyS]) (Generator [Synthesis Register Synthesis]) (do phase.monad [input! (phase archive inputS) @@ -297,7 +297,7 @@ (_.astore register) body!)))) -(def: .public (get phase archive [path recordS]) +(def .public (get phase archive [path recordS]) (Generator [(List Member) Synthesis]) (do phase.monad [record! (phase archive recordS)] @@ -311,7 +311,7 @@ record! (list.reversed path))))) -(def: .public (case phase archive [valueS path]) +(def .public (case phase archive [valueS path]) (Generator [Synthesis Path]) (do phase.monad [@end //runtime.forge_label diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/debug.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/debug.lux index f86e61b14..5f07e5300 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/debug.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/debug.lux @@ -13,9 +13,9 @@ [world ["[0]" file (.only File)]]]]) -(def: extension ".class") +(def extension ".class") -(def: .public (write_class! name bytecode) +(def .public (write_class! name bytecode) (-> Text Binary (IO Text)) (let [file_path (format name ..extension)] (do io.monad diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux index a87be42cc..a4147be81 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux @@ -67,7 +67,7 @@ [reference [variable (.only Register)]]]]]]) -(def: .public (with generate archive @begin class environment arity body) +(def .public (with generate archive @begin class environment arity body) (-> Phase Archive Label External (Environment Synthesis) Arity (Bytecode Any) (Operation [(List (Resource Field)) (List (Resource Method)) @@ -90,21 +90,21 @@ [instance (/new.instance generate archive classT environment arity)] (in [fields methods instance])))) -(def: modifier +(def modifier (Modifier Class) (all modifier#composite class.public class.final)) -(def: this_offset 1) +(def this_offset 1) -(def: internal +(def internal (All (_ category) (-> (Type (<| Return' Value' category)) Internal)) (|>> type.reflection reflection.reflection name.internal)) -(def: .public (abstraction generate archive [environment arity bodyS]) +(def .public (abstraction generate archive [environment arity bodyS]) (Generator Abstraction) (do phase.monad [dependencies (cache/artifact.dependencies archive bodyS) @@ -127,7 +127,7 @@ _ (generation.save! (product.right function_context) {.#None} bytecode)] (in instance))) -(def: (apply/?' generate archive [abstractionG inputsS]) +(def (apply/?' generate archive [abstractionG inputsS]) (Generator [(Bytecode Any) (List Synthesis)]) (do [! phase.monad] [inputsG (monad.each ! (generate archive) inputsS)] @@ -144,13 +144,13 @@ )))) )))) -(def: (apply/? generate archive [abstractionS inputsS]) +(def (apply/? generate archive [abstractionS inputsS]) (Generator Apply) (do [! phase.monad] [abstractionG (generate archive abstractionS)] (apply/?' generate archive [abstractionG inputsS]))) -(def: (apply/= generate archive [$abstraction @abstraction arity inputsS]) +(def (apply/= generate archive [$abstraction @abstraction arity inputsS]) (Generator [Symbol unit.ID Arity (List Synthesis)]) (do [! phase.monad] [.let [:abstraction: (type.class (//runtime.class_name @abstraction) (list))] @@ -162,13 +162,13 @@ (/implementation.call :abstraction: arity) )))) -(def: (apply/> generate archive [$abstraction @abstraction arity inputsS]) +(def (apply/> generate archive [$abstraction @abstraction arity inputsS]) (Generator [Symbol unit.ID Arity (List Synthesis)]) (do [! phase.monad] [=G (apply/= generate archive [$abstraction @abstraction arity (list.first arity inputsS)])] (apply/?' generate archive [=G (list.after arity inputsS)]))) -(def: .public (apply generate archive [abstractionS inputsS]) +(def .public (apply generate archive [abstractionS inputsS]) (Generator Apply) (case abstractionS (pattern (synthesis.constant $abstraction)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/abstract.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/abstract.lux index feebb5be2..cf462455e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/abstract.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/abstract.lux @@ -13,13 +13,13 @@ [constant ["[0]" arity]]]]) -... (def: .public artifact_id +... (def .public artifact_id ... 1) -(def: .public class +(def .public class ... (type.class (%.nat artifact_id) (list)) (type.class "library.lux.Function" (list))) -(def: .public init +(def .public init (Type Method) (type.method [(list) (list arity.type) type.void (list)])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux index 4aea4dc4f..dcbaef747 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux @@ -13,7 +13,7 @@ [constant [pool (.only Resource)]]]]]]) -(def: modifier +(def modifier (Modifier Field) (all modifier#composite field.public @@ -21,6 +21,6 @@ field.final )) -(def: .public (constant name type) +(def .public (constant name type) (-> Text (Type Value) (Resource Field)) (field.field ..modifier name #0 type (sequence.sequence))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant/arity.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant/arity.lux index 1edd1ce40..3892b9ef0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant/arity.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant/arity.lux @@ -10,7 +10,7 @@ [///////// [arity (.only Arity)]]]) -(def: .public minimum Arity 1) -(def: .public maximum Arity 8) +(def .public minimum Arity 1) +(def .public maximum Arity 8) -(def: .public type type.int) +(def .public type type.int) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux index 737c6ac4b..0ae3854a7 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux @@ -21,34 +21,34 @@ [reference [variable (.only Register)]]]]) -(def: .public type ////type.value) +(def .public type ////type.value) -(def: .public (get class name) +(def .public (get class name) (-> (Type Class) Text (Bytecode Any)) (all _.composite ////reference.this (_.getfield class name ..type) )) -(def: .public (put naming class register value) +(def .public (put naming class register value) (-> (-> Register Text) (Type Class) Register (Bytecode Any) (Bytecode Any)) (all _.composite ////reference.this value (_.putfield class (naming register) ..type))) -(def: modifier +(def modifier (Modifier Field) (all modifier#composite field.private field.final )) -(def: .public (variable name type) +(def .public (variable name type) (-> Text (Type Value) (Resource Field)) (field.field ..modifier name #0 type (sequence.sequence))) -(def: .public (variables naming amount) +(def .public (variables naming amount) (-> (-> Register Text) Nat (List (Resource Field))) (|> amount list.indices diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/count.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/count.lux index 90f8426d7..e84776579 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/count.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/count.lux @@ -13,20 +13,20 @@ ["[0]" //// ["[1][0]" abstract]]) -(def: .public field "partials") -(def: .public type type.int) +(def .public field "partials") +(def .public type type.int) -(def: .public initial +(def .public initial (Bytecode Any) (|> +0 signed.s1 try.trusted _.bipush)) -(def: this +(def this _.aload_0) -(def: .public value +(def .public value (Bytecode Any) (all _.composite ..this diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/foreign.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/foreign.lux index 545cf8396..f403f723c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/foreign.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/foreign.lux @@ -22,18 +22,18 @@ [reference [variable (.only Register)]]]]]]) -(def: .public (closure environment) +(def .public (closure environment) (-> (Environment Synthesis) (List (Type Value))) (list.repeated (list.size environment) //.type)) -(def: .public (get class register) +(def .public (get class register) (-> (Type Class) Register (Bytecode Any)) (//.get class (/////reference.foreign_name register))) -(def: .public (put class register value) +(def .public (put class register value) (-> (Type Class) Register (Bytecode Any) (Bytecode Any)) (//.put /////reference.foreign_name class register value)) -(def: .public variables +(def .public variables (-> (Environment Synthesis) (List (Resource Field))) (|>> list.size (//.variables /////reference.foreign_name))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial.lux index 1684e6f8c..36d83b0f1 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial.lux @@ -29,7 +29,7 @@ [reference [variable (.only Register)]]]]]]) -(def: .public (initial amount) +(def .public (initial amount) (-> Nat (Bytecode Any)) (all _.composite (|> _.aconst_null @@ -37,19 +37,19 @@ (monad.all _.monad)) (_#in []))) -(def: .public (get class register) +(def .public (get class register) (-> (Type Class) Register (Bytecode Any)) (//.get class (/////reference.partial_name register))) -(def: .public (put class register value) +(def .public (put class register value) (-> (Type Class) Register (Bytecode Any) (Bytecode Any)) (//.put /////reference.partial_name class register value)) -(def: .public variables +(def .public variables (-> Arity (List (Resource Field))) (|>> (n.- ///arity.minimum) (//.variables /////reference.partial_name))) -(def: .public (new arity) +(def .public (new arity) (-> Arity (Bytecode Any)) (if (arity.multiary? arity) (all _.composite diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method.lux index 1301e055c..3e8e0e065 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method.lux @@ -6,7 +6,7 @@ ["[0]" modifier (.only Modifier) (.open: "[1]#[0]" monoid)] ["[0]" method (.only Method)]]]]]) -(def: .public modifier +(def .public modifier (Modifier Method) (all modifier#composite method.public diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux index 69e7d5332..8b03c7ae8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux @@ -48,13 +48,13 @@ [reference [variable (.only Register)]]]]]]]) -(def: (increment by) +(def (increment by) (-> Nat (Bytecode Any)) (all _.composite (<| _.int .i64 by) _.iadd)) -(def: (inputs offset amount) +(def (inputs offset amount) (-> Register Nat (Bytecode Any)) (all _.composite (|> amount @@ -63,7 +63,7 @@ (_#in []) )) -(def: (apply offset amount) +(def (apply offset amount) (-> Register Nat (Bytecode Any)) (let [arity (n.min amount ///arity.maximum)] (all _.composite @@ -76,9 +76,9 @@ (_#in [])) ))) -(def: this_offset 1) +(def this_offset 1) -(def: .public (method class environment function_arity @begin body apply_arity) +(def .public (method class environment function_arity @begin body apply_arity) (-> (Type Class) (Environment Synthesis) Arity Label (Bytecode Any) Arity (Resource Method)) (let [num_partials (-- function_arity) over_extent (i.- (.int apply_arity) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux index 5554117e6..84ad5a397 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux @@ -26,22 +26,22 @@ [archive ["[0]" unit]]]]]]) -(def: .public name "impl") +(def .public name "impl") -(def: .public (type :it: arity) +(def .public (type :it: arity) (-> (Type Class) Arity (Type category.Method)) (type.method [(list) (list.partial :it: (list.repeated arity ////type.value)) ////type.value (list)])) -(def: modifier +(def modifier (all modifier#composite method.static //.modifier )) -(def: .public (method :it: arity @begin body) +(def .public (method :it: arity @begin body) (-> (Type Class) Arity Label (Bytecode Any) (Resource Method)) (method.method ..modifier ..name @@ -53,6 +53,6 @@ (_.when_continuous _.areturn) )})) -(def: .public (call :it: arity) +(def .public (call :it: arity) (-> (Type Class) Arity (Bytecode Any)) (_.invokestatic :it: ..name (..type :it: arity))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux index c3cea9bf2..934e7c561 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux @@ -42,13 +42,13 @@ [reference [variable (.only Register)]]]]]]]) -(def: .public name "<init>") +(def .public name "<init>") -(def: (partials arity) +(def (partials arity) (-> Arity (List (Type Value))) (list.repeated (-- arity) ////type.value)) -(def: .public (type environment arity) +(def .public (type environment arity) (-> (Environment Synthesis) Arity (Type category.Method)) (type.method [(list) (list#composite (///foreign.closure environment) @@ -58,13 +58,13 @@ type.void (list)])) -(def: no_partials +(def no_partials (|> +0 signed.s1 try.trusted _.bipush)) -(def: .public (super environment_size arity) +(def .public (super environment_size arity) (-> Nat Arity (Bytecode Any)) (let [arity_register (++ environment_size)] (all _.composite @@ -73,7 +73,7 @@ (_.iload arity_register)) (_.invokespecial ///abstract.class ..name ///abstract.init)))) -(def: (store_all amount put offset) +(def (store_all amount put offset) (-> Nat (-> Register (Bytecode Any) (Bytecode Any)) (-> Register Register) @@ -84,7 +84,7 @@ (_.aload (offset register))))) (monad.all _.monad))) -(def: .public (method class environment arity) +(def .public (method class environment arity) (-> (Type Class) (Environment Synthesis) Arity (Resource Method)) (let [environment_size (list.size environment) offset_foreign (is (-> Register Register) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux index b9b1e99a8..7cfe7943e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux @@ -43,7 +43,7 @@ ["[0]" arity (.only Arity)] ["[0]" phase]]]]]]) -(def: .public (instance' foreign_setup class environment arity) +(def .public (instance' foreign_setup class environment arity) (-> (List (Bytecode Any)) (Type Class) (Environment Synthesis) Arity (Bytecode Any)) (all _.composite (_.new class) @@ -52,13 +52,13 @@ (///partial.new arity) (_.invokespecial class //init.name (//init.type environment arity)))) -(def: .public (instance generate archive class environment arity) +(def .public (instance generate archive class environment arity) (-> Phase Archive (Type Class) (Environment Synthesis) Arity (Operation (Bytecode Any))) (do [! phase.monad] [foreign* (monad.each ! (generate archive) environment)] (in (instance' foreign* class environment arity)))) -(def: .public (method class environment arity) +(def .public (method class environment arity) (-> (Type Class) (Environment Synthesis) Arity (Resource Method)) (let [after_this (is (-> Nat Nat) (n.+ 1)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux index 51ceaf844..16909a692 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux @@ -26,19 +26,19 @@ [/// ["[0]" arity (.only Arity)]]]]]]) -(def: .public name "reset") +(def .public name "reset") -(def: .public (type class) +(def .public (type class) (-> (Type Class) (Type category.Method)) (type.method [(list) (list) class (list)])) -(def: (current_environment class) +(def (current_environment class) (-> (Type Class) (Environment Synthesis) (List (Bytecode Any))) (|>> list.size list.indices (list#each (///foreign.get class)))) -(def: .public (method class environment arity) +(def .public (method class environment arity) (-> (Type Class) (Environment Synthesis) Arity (Resource Method)) (method.method //.modifier ..name #0 (..type class) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux index eb8478a41..2196d5c3e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux @@ -61,10 +61,10 @@ (import java/lang/ClassLoader "[1]::[0]") -(def: value::modifier (all modifier#composite field.public field.final field.static)) +(def value::modifier (all modifier#composite field.public field.final field.static)) -(def: init::type (type.method [(list) (list) type.void (list)])) -(def: init::modifier (all modifier#composite method.public method.static method.strict)) +(def init::type (type.method [(list) (list) type.void (list)])) +(def init::modifier (all modifier#composite method.public method.static method.strict)) (exception: .public (cannot_load [class Text error Text]) @@ -84,7 +84,7 @@ (exception.report "Class" class)) -(def: (class_value class_name class) +(def (class_value class_name class) (-> Text (java/lang/Class java/lang/Object) (Try Any)) (case (java/lang/Class::getField //value.field class) {try.#Success field} @@ -103,10 +103,10 @@ {try.#Failure error} (exception.except ..invalid_field [class_name //value.field error]))) -(def: class_path_separator +(def class_path_separator ".") -(def: (evaluate! library loader eval_class [@it valueG]) +(def (evaluate! library loader eval_class [@it valueG]) (-> Library java/lang/ClassLoader Text [(Maybe unit.ID) (Bytecode Any)] (Try [Any Definition])) (let [bytecode_name (text.replaced class_path_separator .module_separator eval_class) :value: (case @it @@ -139,7 +139,7 @@ (in [value [eval_class bytecode]]))))) -(def: (execute! library loader [class_name class_bytecode]) +(def (execute! library loader [class_name class_bytecode]) (-> Library java/lang/ClassLoader Definition (Try Any)) (io.run! (do (try.with io.monad) [existing_class? (|> (atom.read! library) @@ -152,7 +152,7 @@ (loader.store class_name class_bytecode library))] (loader.load class_name loader)))) -(def: (define! library loader context custom @it,valueG) +(def (define! library loader context custom @it,valueG) (-> Library java/lang/ClassLoader unit.ID (Maybe Text) [(Maybe unit.ID) (Bytecode Any)] (Try [Text Any Definition])) (let [class_name (maybe.else (//runtime.class_name context) custom)] @@ -160,30 +160,30 @@ [[value definition] (evaluate! library loader class_name @it,valueG)] (in [class_name value definition])))) -(def: .public host +(def .public host (IO [java/lang/ClassLoader //runtime.Host]) (io (let [library (loader.new_library []) loader (loader.memory library)] [loader (is //runtime.Host (implementation - (def: (evaluate context @it,valueG) + (def (evaluate context @it,valueG) (at try.monad each product.left (..evaluate! library loader (format "E" (//runtime.class_name context)) @it,valueG))) - (def: execute + (def execute (..execute! library loader)) - (def: define + (def define (..define! library loader)) - (def: (ingest context bytecode) + (def (ingest context bytecode) [(//runtime.class_name context) bytecode]) - (def: (re_learn context custom [_ bytecode]) + (def (re_learn context custom [_ bytecode]) (io.run! (loader.store (maybe.else (//runtime.class_name context) custom) bytecode library))) - (def: (re_load context custom [directive_name bytecode]) + (def (re_load context custom [directive_name bytecode]) (io.run! (do (try.with io.monad) [.let [class_name (maybe.else (//runtime.class_name context) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux index f06d37da3..741098438 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux @@ -26,7 +26,7 @@ [reference [variable (.only Register)]]]]]) -(def: (invariant? register changeS) +(def (invariant? register changeS) (-> Register Synthesis Bit) (case changeS (pattern (synthesis.variable/local var)) @@ -35,10 +35,10 @@ _ false)) -(def: no_op +(def no_op (_#in [])) -(def: .public (again translate archive updatesS) +(def .public (again translate archive updatesS) (Generator (List Synthesis)) (do [! phase.monad] [[@begin offset] generation.anchor @@ -72,7 +72,7 @@ (monad.all _.monad)) (_.goto @begin))))) -(def: .public (scope translate archive [offset initsS+ iterationS]) +(def .public (scope translate archive [offset initsS+ iterationS]) (Generator [Nat (List Synthesis) Synthesis]) (do [! phase.monad] [@begin //runtime.forge_label diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux index 90c3044ae..772482ec8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux @@ -20,18 +20,18 @@ ["[0]" // ["[1][0]" runtime]]) -(def: $Boolean (type.class "java.lang.Boolean" (list))) -(def: $Long (type.class "java.lang.Long" (list))) -(def: $Double (type.class "java.lang.Double" (list))) +(def $Boolean (type.class "java.lang.Boolean" (list))) +(def $Long (type.class "java.lang.Long" (list))) +(def $Double (type.class "java.lang.Double" (list))) -(def: .public (bit value) +(def .public (bit value) (-> Bit (Bytecode Any)) (_.getstatic $Boolean (if value "TRUE" "FALSE") $Boolean)) -(def: wrap_i64 +(def wrap_i64 (_.invokestatic $Long "valueOf" (type.method [(list) (list type.long) $Long (list)]))) -(def: .public (i64 value) +(def .public (i64 value) (-> (I64 Any) (Bytecode Any)) (case (.int value) (^.with_template [<int> <instruction>] @@ -77,18 +77,18 @@ [_ (_.long value)] ..wrap_i64))))) -(def: wrap_f64 +(def wrap_f64 (_.invokestatic $Double "valueOf" (type.method [(list) (list type.double) $Double (list)]))) (import java/lang/Double "[1]::[0]" ("static" doubleToRawLongBits "manual" [double] int)) -(def: d0_bits +(def d0_bits Int (java/lang/Double::doubleToRawLongBits +0.0)) -(def: .public (f64 value) +(def .public (f64 value) (-> Frac (Bytecode Any)) (case value (^.with_template [<int> <instruction>] @@ -129,5 +129,5 @@ [_ constantI] ..wrap_f64)))) -(def: .public text +(def .public text _.string) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux index a81896178..8a374a859 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux @@ -33,19 +33,19 @@ ["[1][0]" runtime (.only Definition)] ["[1][0]" function/abstract]]) -(def: ^Object +(def ^Object (type.class "java.lang.Object" (list))) -(def: ^String +(def ^String (type.class "java.lang.String" (list))) -(def: ^Args +(def ^Args (type.array ^String)) -(def: main::type +(def main::type (type.method [(list) (list ..^Args) type.void (list)])) -(def: main::modifier +(def main::modifier (Modifier Method) (all modifier#composite method.public @@ -53,29 +53,29 @@ method.strict )) -(def: program::modifier +(def program::modifier (Modifier Class) (all modifier#composite class.public class.final )) -(def: list:end +(def list:end //runtime.none_injection) -(def: amount_of_inputs +(def amount_of_inputs (Bytecode Any) (all _.composite _.aload_0 _.arraylength)) -(def: decrease +(def decrease (Bytecode Any) (all _.composite _.iconst_1 _.isub)) -(def: head +(def head (Bytecode Any) (all _.composite _.dup @@ -86,7 +86,7 @@ _.dup_x2 _.pop)) -(def: pair +(def pair (Bytecode Any) (let [empty_pair (all _.composite _.iconst_2 @@ -109,9 +109,9 @@ (set_side! _.iconst_1) ... P ))) -(def: list:item //runtime.right_injection) +(def list:item //runtime.right_injection) -(def: input_list +(def input_list (Bytecode Any) (do _.monad [@loop _.new_label @@ -131,17 +131,17 @@ (_.set_label @end) _.pop))) -(def: feed_inputs +(def feed_inputs //runtime.apply) -(def: run_io +(def run_io (Bytecode Any) (all _.composite (_.checkcast //function/abstract.class) //runtime.unit //runtime.apply)) -(def: .public (program artifact_name context program) +(def .public (program artifact_name context program) (-> (-> unit.ID Text) (Program (Bytecode Any) Definition)) (let [super_class (|> ..^Object type.reflection reflection.reflection name.internal) main (method.method ..main::modifier "main" diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux index b2c6f47ba..fe905d1bc 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux @@ -26,12 +26,12 @@ [meta [archive (.only Archive)]]]]]]) -(def: .public this +(def .public this (Bytecode Any) _.aload_0) (with_template [<name> <prefix>] - [(def: .public <name> + [(def .public <name> (-> Register Text) (|>> %.nat (format <prefix>)))] @@ -39,7 +39,7 @@ [partial_name "p"] ) -(def: (foreign archive variable) +(def (foreign archive variable) (-> Archive Register (Operation (Bytecode Any))) (do [! ////.monad] [bytecode_name (at ! each //runtime.class_name @@ -50,7 +50,7 @@ (..foreign_name variable) //type.value))))) -(def: .public (variable archive variable) +(def .public (variable archive variable) (-> Archive Variable (Operation (Bytecode Any))) (case variable {variable.#Local variable} @@ -59,7 +59,7 @@ {variable.#Foreign variable} (..foreign archive variable))) -(def: .public (constant archive name) +(def .public (constant archive name) (-> Archive Symbol (Operation (Bytecode Any))) (do ////.monad [[@definition |abstraction|] (generation.definition archive name) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux index 6331379f2..b52d18de3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux @@ -89,24 +89,24 @@ (type: .public Host (generation.Host (Bytecode Any) Definition)) -(def: .public (class_name [module id]) +(def .public (class_name [module id]) (-> unit.ID Text) (format lux_context "." (%.nat version.latest) "." (%.nat module) "." (%.nat id))) -(def: artifact_id +(def artifact_id 0) -(def: .public class +(def .public class (type.class (class_name [0 ..artifact_id]) (list))) -(def: procedure +(def procedure (-> Text (Type category.Method) (Bytecode Any)) (_.invokestatic ..class)) -(def: modifier +(def modifier (Modifier Method) (all modifier#composite method.public @@ -114,17 +114,17 @@ method.strict )) -(def: this +(def this (Bytecode Any) _.aload_0) -(def: .public (get index) +(def .public (get index) (-> (Bytecode Any) (Bytecode Any)) (all _.composite index _.aaload)) -(def: (set! index value) +(def (set! index value) (-> (Bytecode Any) (Bytecode Any) (Bytecode Any)) (all _.composite ... A @@ -134,17 +134,17 @@ _.aastore ... A )) -(def: .public unit (_.string synthesis.unit)) +(def .public unit (_.string synthesis.unit)) -(def: variant::name "variant") -(def: variant::type (type.method [(list) (list //type.lefts //type.right? //type.value) //type.variant (list)])) -(def: .public variant (..procedure ..variant::name ..variant::type)) +(def variant::name "variant") +(def variant::type (type.method [(list) (list //type.lefts //type.right? //type.value) //type.variant (list)])) +(def .public variant (..procedure ..variant::name ..variant::type)) -(def: variant_lefts _.iconst_0) -(def: variant_right? _.iconst_1) -(def: variant_value _.iconst_2) +(def variant_lefts _.iconst_0) +(def variant_right? _.iconst_1) +(def variant_value _.iconst_2) -(def: variant::method +(def variant::method (let [new_variant (all _.composite _.iconst_3 (_.anewarray //type.value)) @@ -163,10 +163,10 @@ (..set! ..variant_value $value) ... A[3] _.areturn)}))) -(def: .public left_right? _.aconst_null) -(def: .public right_right? ..unit) +(def .public left_right? _.aconst_null) +(def .public right_right? ..unit) -(def: .public left_injection +(def .public left_injection (Bytecode Any) (all _.composite _.iconst_0 @@ -175,7 +175,7 @@ _.pop2 ..variant)) -(def: .public right_injection +(def .public right_injection (Bytecode Any) (all _.composite _.iconst_0 @@ -184,9 +184,9 @@ _.pop2 ..variant)) -(def: .public some_injection ..right_injection) +(def .public some_injection ..right_injection) -(def: .public none_injection +(def .public none_injection (Bytecode Any) (all _.composite _.iconst_0 @@ -194,7 +194,7 @@ ..unit ..variant)) -(def: (risky $unsafe) +(def (risky $unsafe) (-> (Bytecode Any) (Bytecode Any)) (do _.monad [@try _.new_label @@ -210,11 +210,11 @@ _.areturn ))) -(def: decode_frac::name "decode_frac") -(def: decode_frac::type (type.method [(list) (list //type.text) //type.variant (list)])) -(def: .public decode_frac (..procedure ..decode_frac::name ..decode_frac::type)) +(def decode_frac::name "decode_frac") +(def decode_frac::type (type.method [(list) (list //type.text) //type.variant (list)])) +(def .public decode_frac (..procedure ..decode_frac::name ..decode_frac::type)) -(def: decode_frac::method +(def decode_frac::method (method.method ..modifier ..decode_frac::name #0 ..decode_frac::type (list) @@ -226,7 +226,7 @@ (//value.wrap type.double) ))})) -(def: .public log! +(def .public log! (Bytecode Any) (let [^PrintStream (type.class "java.io.PrintStream" (list)) ^System (type.class "java.lang.System" (list)) @@ -237,8 +237,8 @@ out (_.string "LUX LOG: ") (print! "print") out _.swap (print! "println")))) -(def: exception_constructor (type.method [(list) (list //type.text) type.void (list)])) -(def: (illegal_state_exception message) +(def exception_constructor (type.method [(list) (list //type.text) type.void (list)])) +(def (illegal_state_exception message) (-> Text (Bytecode Any)) (let [^IllegalStateException (type.class "java.lang.IllegalStateException" (list))] (all _.composite @@ -247,10 +247,10 @@ (_.string message) (_.invokespecial ^IllegalStateException "<init>" ..exception_constructor)))) -(def: failure::type +(def failure::type (type.method [(list) (list) type.void (list)])) -(def: (failure name message) +(def (failure name message) (-> Text Text (Resource Method)) (method.method ..modifier name #0 ..failure::type @@ -260,20 +260,20 @@ (..illegal_state_exception message) _.athrow)})) -(def: pm_failure::name "pm_failure") -(def: .public pm_failure (..procedure ..pm_failure::name ..failure::type)) +(def pm_failure::name "pm_failure") +(def .public pm_failure (..procedure ..pm_failure::name ..failure::type)) -(def: pm_failure::method +(def pm_failure::method (..failure ..pm_failure::name "Invalid expression for pattern-matching.")) -(def: .public stack_head _.iconst_0) -(def: .public stack_tail _.iconst_1) +(def .public stack_head _.iconst_0) +(def .public stack_tail _.iconst_1) -(def: push::name "push") -(def: push::type (type.method [(list) (list //type.stack //type.value) //type.stack (list)])) -(def: .public push (..procedure ..push::name ..push::type)) +(def push::name "push") +(def push::type (type.method [(list) (list //type.stack //type.value) //type.stack (list)])) +(def .public push (..procedure ..push::name ..push::type)) -(def: push::method +(def push::method (method.method ..modifier ..push::name #0 ..push::type (list) @@ -289,11 +289,11 @@ (..set! ..stack_tail $tail) _.areturn))})) -(def: case::name "case") -(def: case::type (type.method [(list) (list //type.variant //type.lefts //type.right?) //type.value (list)])) -(def: .public case (..procedure ..case::name ..case::type)) +(def case::name "case") +(def case::type (type.method [(list) (list //type.variant //type.lefts //type.right?) //type.value (list)])) +(def .public case (..procedure ..case::name ..case::type)) -(def: case::method +(def case::method (method.method ..modifier ..case::name #0 ..case::type (list) @@ -370,15 +370,15 @@ _.areturn ))})) -(def: projection_type (type.method [(list) (list //type.tuple //type.offset) //type.value (list)])) +(def projection_type (type.method [(list) (list //type.tuple //type.offset) //type.value (list)])) -(def: left_projection::name "left") -(def: .public left_projection (..procedure ..left_projection::name ..projection_type)) +(def left_projection::name "left") +(def .public left_projection (..procedure ..left_projection::name ..projection_type)) -(def: right_projection::name "right") -(def: .public right_projection (..procedure ..right_projection::name ..projection_type)) +(def right_projection::name "right") +(def .public right_projection (..procedure ..right_projection::name ..projection_type)) -(def: projection::method2 +(def projection::method2 [(Resource Method) (Resource Method)] (let [$tuple _.aload_0 $tuple::size (all _.composite @@ -465,23 +465,23 @@ [left_projection::method right_projection::method])) -(def: .public apply::name "apply") +(def .public apply::name "apply") -(def: .public (apply::type arity) +(def .public (apply::type arity) (-> Arity (Type category.Method)) (type.method [(list) (list.repeated arity //type.value) //type.value (list)])) -(def: .public apply +(def .public apply (_.invokevirtual //function.class ..apply::name (..apply::type 1))) -(def: try::name "try") -(def: try::type (type.method [(list) (list //function.class) //type.variant (list)])) -(def: .public try (..procedure ..try::name ..try::type)) +(def try::name "try") +(def try::type (type.method [(list) (list //function.class) //type.variant (list)])) +(def .public try (..procedure ..try::name ..try::type)) -(def: false _.iconst_0) -(def: true _.iconst_1) +(def false _.iconst_0) +(def true _.iconst_1) -(def: try::method +(def try::method (method.method ..modifier ..try::name #0 ..try::type (list) @@ -531,14 +531,14 @@ _.areturn ))})) -(def: reflection +(def reflection (All (_ category) (-> (Type (<| Return' Value' category)) Text)) (|>> type.reflection reflection.reflection)) -(def: ^Object (type.class "java.lang.Object" (list))) +(def ^Object (type.class "java.lang.Object" (list))) -(def: generate_runtime +(def generate_runtime (Operation [artifact.ID (Maybe Text) Binary]) (let [class (..reflection ..class) modifier (is (Modifier Class) @@ -571,7 +571,7 @@ _ (generation.save! ..artifact_id {.#None} [class bytecode])] (in [..artifact_id {.#None} bytecode])))) -(def: generate_function +(def generate_function (Operation Any) (let [apply::method+ (|> (enum.range n.enum (++ //function/arity.minimum) @@ -634,7 +634,7 @@ ] (in [])))) -(def: .public generate +(def .public generate (Operation [Registry Output]) (do ////.monad [runtime_payload ..generate_runtime @@ -650,7 +650,7 @@ ... function_payload )]))) -(def: .public forge_label +(def .public forge_label (Operation Label) (let [shift (n./ 4 i64.width)] ... This shift is done to avoid the possibility of forged labels diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux index f4b885825..ec2c60d9f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux @@ -28,7 +28,7 @@ [/// ["[0]" phase]]]]) -(def: .public (tuple phase archive membersS) +(def .public (tuple phase archive membersS) (Generator (Tuple Synthesis)) (case membersS {.#End} @@ -54,7 +54,7 @@ _ (_.anewarray //type.value)] (monad.all ! membersI)))))) -(def: .public (lefts lefts) +(def .public (lefts lefts) (-> Nat (Bytecode Any)) (case lefts 0 _.iconst_0 @@ -75,13 +75,13 @@ {try.#Failure _} (_.int (.i64 lefts)))))) -(def: .public (right? right?) +(def .public (right? right?) (-> Bit (Bytecode Any)) (if right? //runtime.right_right? //runtime.left_right?)) -(def: .public (variant phase archive [lefts right? valueS]) +(def .public (variant phase archive [lefts right? valueS]) (Generator (Variant Synthesis)) (do phase.monad [valueI (phase archive valueS)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/type.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/type.lux index 2cf2cfe5e..974fa4925 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/type.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/type.lux @@ -5,19 +5,19 @@ [jvm ["[0]" type]]]]]) -(def: .public frac (type.class "java.lang.Double" (list))) -(def: .public text (type.class "java.lang.String" (list))) +(def .public frac (type.class "java.lang.Double" (list))) +(def .public text (type.class "java.lang.String" (list))) -(def: .public value (type.class "java.lang.Object" (list))) +(def .public value (type.class "java.lang.Object" (list))) -(def: .public lefts type.int) -(def: .public right? ..value) -(def: .public variant (type.array ..value)) +(def .public lefts type.int) +(def .public right? ..value) +(def .public variant (type.array ..value)) -(def: .public offset type.int) -(def: .public index ..offset) -(def: .public tuple (type.array ..value)) +(def .public offset type.int) +(def .public index ..offset) +(def .public tuple (type.array ..value)) -(def: .public stack (type.array ..value)) +(def .public stack (type.array ..value)) -(def: .public error (type.class "java.lang.Throwable" (list))) +(def .public error (type.class "java.lang.Throwable" (list))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/value.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/value.lux index 9cd5f6d93..d4f8b9a93 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/value.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/value.lux @@ -8,10 +8,10 @@ [category (.only Primitive)] ["[0]" box]]]]]]) -(def: .public field "value") +(def .public field "value") (with_template [<name> <boolean> <byte> <short> <int> <long> <float> <double> <char>] - [(def: (<name> type) + [(def (<name> type) (-> (Type Primitive) Text) (`` (cond (~~ (with_template [<type> <output>] [(type#= <type> type) <output>] @@ -35,13 +35,13 @@ "longValue" "floatValue" "doubleValue" "charValue"] ) -(def: .public (wrap type) +(def .public (wrap type) (-> (Type Primitive) (Bytecode Any)) (let [wrapper (type.class (primitive_wrapper type) (list))] (_.invokestatic wrapper "valueOf" (type.method [(list) (list type) wrapper (list)])))) -(def: .public (unwrap type) +(def .public (unwrap type) (-> (Type Primitive) (Bytecode Any)) (let [wrapper (type.class (primitive_wrapper type) (list))] (all _.composite diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux index 669e1667b..f0965920a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux @@ -34,7 +34,7 @@ (exception: .public cannot_recur_as_an_expression) -(def: (expression archive synthesis) +(def (expression archive synthesis) Phase (case synthesis (^.with_template [<tag> <generator>] @@ -84,6 +84,6 @@ {synthesis.#Extension extension} (///extension.apply archive expression extension))) -(def: .public generate +(def .public generate Phase ..expression) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux index 7ade9486a..418694f74 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux @@ -34,15 +34,15 @@ [meta [archive (.only Archive)]]]]]]]) -(def: .public register +(def .public register (-> Register Var) (|>> (///reference.local //reference.system) as_expected)) -(def: .public capture +(def .public capture (-> Register Var) (|>> (///reference.foreign //reference.system) as_expected)) -(def: .public (exec expression archive [this that]) +(def .public (exec expression archive [this that]) (Generator [Synthesis Synthesis]) (do ///////phase.monad [this (expression archive this) @@ -50,7 +50,7 @@ (in (|> (_.array (list this that)) (_.item (_.int +2)))))) -(def: .public (exec! statement expression archive [this that]) +(def .public (exec! statement expression archive [this that]) (Generator! [Synthesis Synthesis]) (do [! ///////phase.monad] [this (expression archive this) @@ -60,7 +60,7 @@ (_.set (list $dummy) this) that)))) -(def: .public (let expression archive [valueS register bodyS]) +(def .public (let expression archive [valueS register bodyS]) (Generator [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -71,7 +71,7 @@ (_.closure (list (..register register))) (_.apply (list valueO)))))) -(def: .public (let! statement expression archive [valueS register bodyS]) +(def .public (let! statement expression archive [valueS register bodyS]) (Generator! [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -80,7 +80,7 @@ (_.local/1 (..register register) valueO) bodyO)))) -(def: .public (get expression archive [pathP valueS]) +(def .public (get expression archive [pathP valueS]) (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueO (expression archive valueS)] @@ -92,7 +92,7 @@ valueO (list.reversed pathP))))) -(def: .public (if expression archive [testS thenS elseS]) +(def .public (if expression archive [testS thenS elseS]) (Generator [Synthesis Synthesis Synthesis]) (do ///////phase.monad [testO (expression archive testS) @@ -104,7 +104,7 @@ (_.closure (list)) (_.apply (list)))))) -(def: .public (if! statement expression archive [testS thenS elseS]) +(def .public (if! statement expression archive [testS thenS elseS]) (Generator! [Synthesis Synthesis Synthesis]) (do ///////phase.monad [testO (expression archive testS) @@ -114,27 +114,27 @@ thenO elseO)))) -(def: @savepoint (_.var "lux_pm_savepoint")) -(def: @cursor (_.var "lux_pm_cursor")) -(def: @temp (_.var "lux_pm_temp")) +(def @savepoint (_.var "lux_pm_savepoint")) +(def @cursor (_.var "lux_pm_cursor")) +(def @temp (_.var "lux_pm_temp")) -(def: (push! value) +(def (push! value) (-> Expression Statement) (_.statement (|> (_.var "table.insert") (_.apply (list @cursor value))))) -(def: peek_and_pop +(def peek_and_pop Expression (|> (_.var "table.remove") (_.apply (list @cursor)))) -(def: pop! +(def pop! Statement (_.statement ..peek_and_pop)) -(def: peek +(def peek Expression (_.item (_.length @cursor) @cursor)) -(def: save! +(def save! Statement (_.statement (|> (_.var "table.insert") (_.apply (list @savepoint @@ -145,14 +145,14 @@ (_.table (list))) (_.var "table.move"))))))) -(def: restore! +(def restore! Statement (_.set (list @cursor) (|> (_.var "table.remove") (_.apply (list @savepoint))))) -(def: fail! _.break) +(def fail! _.break) (with_template [<name> <flag>] - [(def: (<name> simple? idx) + [(def (<name> simple? idx) (-> Bit Nat Statement) (all _.then (_.set (list @temp) (//runtime.sum//get ..peek <flag> @@ -168,7 +168,7 @@ [right_choice //runtime.unit] ) -(def: (alternation pre! post!) +(def (alternation pre! post!) (-> Statement Statement Statement) (all _.then (_.while (_.boolean true) @@ -179,7 +179,7 @@ ..restore! post!))) -(def: (pattern_matching' statement expression archive) +(def (pattern_matching' statement expression archive) (-> Phase! Phase Archive Path (Operation Statement)) (function (again pathP) (.case pathP @@ -261,7 +261,7 @@ ([/////synthesis.path/seq _.then] [/////synthesis.path/alt ..alternation])))) -(def: (pattern_matching statement expression archive pathP) +(def (pattern_matching statement expression archive pathP) (-> Phase! Phase Archive Path (Operation Statement)) (do ///////phase.monad [pattern_matching! (pattern_matching' statement expression archive pathP)] @@ -270,7 +270,7 @@ pattern_matching!) (_.statement (|> (_.var "error") (_.apply (list (_.string ////synthesis/case.pattern_matching_error))))))))) -(def: .public dependencies +(def .public dependencies (-> Path (List Var)) (|>> ////synthesis/case.storage (the ////synthesis/case.#dependencies) @@ -283,7 +283,7 @@ {///////variable.#Foreign register} (..capture register)))))) -(def: .public (case! statement expression archive [valueS pathP]) +(def .public (case! statement expression archive [valueS pathP]) (Generator! [Synthesis Path]) (do ///////phase.monad [stack_init (expression archive valueS) @@ -294,7 +294,7 @@ (_.local/1 @savepoint (_.array (list))) pattern_matching!)))) -(def: .public (case statement expression archive [valueS pathP]) +(def .public (case statement expression archive [valueS pathP]) (-> Phase! (Generator [Synthesis Path])) (|> [valueS pathP] (..case! statement expression archive) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux index 79bba0796..3454cfe52 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux @@ -33,18 +33,18 @@ [reference [variable (.only Register Variable)]]]]]]) -(def: .public (apply expression archive [functionS argsS+]) +(def .public (apply expression archive [functionS argsS+]) (Generator (Reification Synthesis)) (do [! ///////phase.monad] [functionO (expression archive functionS) argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply argsO+ functionO)))) -(def: capture +(def capture (-> Register Var) (|>> (///reference.foreign //reference.system) as_expected)) -(def: (with_closure inits @self @args body!) +(def (with_closure inits @self @args body!) (-> (List Expression) Var (List Var) Statement [Statement Expression]) (case inits {.#End} @@ -60,14 +60,14 @@ (_.return @self))) (_.apply inits @self)]))) -(def: input +(def input (|>> ++ //case.register)) -(def: (@scope function_name) +(def (@scope function_name) (-> unit.ID Label) (_.label (format (///reference.artifact function_name) "_scope"))) -(def: .public (function statement expression archive [environment arity bodyS]) +(def .public (function statement expression archive [environment arity bodyS]) (-> Phase! (Generator (Abstraction Synthesis))) (do [! ///////phase.monad] [dependencies (cache.dependencies archive bodyS) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux index 71654a483..4878f0b72 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux @@ -33,11 +33,11 @@ [reference [variable (.only Register)]]]]]]) -(def: @scope +(def @scope (-> Nat Label) (|>> %.nat (format "scope") _.label)) -(def: (setup initial? offset bindings as_expression? body) +(def (setup initial? offset bindings as_expression? body) (-> Bit Register (List Expression) Bit Statement Statement) (let [variables (|> bindings list.enumeration @@ -50,7 +50,7 @@ (_.set variables (_.multi bindings))) body)))) -(def: .public (scope! statement expression archive as_expression? [start initsS+ bodyS]) +(def .public (scope! statement expression archive as_expression? [start initsS+ bodyS]) ... (Generator! (Scope Synthesis)) (-> Phase! Phase Archive Bit (Scope Synthesis) (Operation [(List Expression) Statement])) @@ -74,7 +74,7 @@ (_.set_label @scope) body!))])))) -(def: .public (scope statement expression archive [start initsS+ bodyS]) +(def .public (scope statement expression archive [start initsS+ bodyS]) (-> Phase! (Generator (Scope Synthesis))) (case initsS+ ... function/false/non-independent loop @@ -115,7 +115,7 @@ _ (/////generation.save! artifact_id {.#None} directive)] (in (_.apply initsO+ instantiation))))) -(def: .public (again! statement expression archive argsS+) +(def .public (again! statement expression archive argsS+) (Generator! (List Synthesis)) (do [! ///////phase.monad] [[offset @scope] /////generation.anchor diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/primitive.lux index ff40f0f26..d6104a879 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/primitive.lux @@ -5,7 +5,7 @@ ["_" lua (.only Literal)]]]]) (with_template [<name> <type> <implementation>] - [(def: .public <name> + [(def .public <name> (-> <type> Literal) <implementation>)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/reference.lux index d98a16050..47df3bed5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(def: .public system +(def .public system (System Expression) (implementation - (def: constant' _.var) - (def: variable' _.var))) + (def constant' _.var) + (def variable' _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux index b97413f9b..a287bf380 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux @@ -58,52 +58,52 @@ (type: .public (Generator! i) (-> Phase! Phase Archive i (Operation Statement))) -(def: .public unit +(def .public unit (_.string /////synthesis.unit)) -(def: (flag value) +(def (flag value) (-> Bit Literal) (if value ..unit _.nil)) -(def: .public variant_tag_field "_lux_tag") -(def: .public variant_flag_field "_lux_flag") -(def: .public variant_value_field "_lux_value") +(def .public variant_tag_field "_lux_tag") +(def .public variant_flag_field "_lux_flag") +(def .public variant_value_field "_lux_value") -(def: (variant' tag last? value) +(def (variant' tag last? value) (-> Expression Expression Expression Literal) (_.table (list [..variant_tag_field tag] [..variant_flag_field last?] [..variant_value_field value]))) -(def: .public (variant tag last? value) +(def .public (variant tag last? value) (-> Nat Bit Expression Literal) (variant' (_.int (.int tag)) (flag last?) value)) -(def: .public left +(def .public left (-> Expression Literal) (..variant 0 #0)) -(def: .public right +(def .public right (-> Expression Literal) (..variant 0 #1)) -(def: .public none +(def .public none Literal (..left ..unit)) -(def: .public some +(def .public some (-> Expression Literal) ..right) -(def: (feature name definition) +(def (feature name definition) (-> Var (-> Var Statement) Statement) (definition name)) -(def: .public with_vars +(def .public with_vars (syntax (_ [vars (<code>.tuple (<>.some <code>.local)) body <code>.any]) (do [! meta.monad] @@ -116,10 +116,10 @@ list.together))] (~ body)))))))) -(def: module_id +(def module_id 0) -(def: runtime: +(def runtime: (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -133,11 +133,11 @@ {.#Left name} (macro.with_symbols [g!_] (let [g!name (code.local name)] - (in (list (` (def: .public (~ g!name) + (in (list (` (def .public (~ g!name) Var (~ runtime_name))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) Statement (..feature (~ runtime_name) (function ((~ g!_) (~ g!name)) @@ -149,11 +149,11 @@ inputsC (list#each code.local inputs) inputs_typesC (list#each (function.constant (` _.Expression)) inputs)] - (in (list (` (def: .public ((~ g!name) (~+ inputsC)) + (in (list (` (def .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) Computation) (_.apply (list (~+ inputsC)) (~ runtime_name)))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) Statement (..feature (~ runtime_name) (function ((~ g!_) (~ g!_)) @@ -161,11 +161,11 @@ (_.function (~ g!_) (list (~+ inputsC)) (~ code))))))))))))))))) -(def: (item index table) +(def (item index table) (-> Expression Expression Location) (_.item (_.+ (_.int +1) index) table)) -(def: last_index +(def last_index (|>> _.length (_.- (_.int +1)))) (with_expansions [<recur> (these (all _.then @@ -228,7 +228,7 @@ actual::value))) mismatch!))) -(def: runtime//adt +(def runtime//adt Statement (all _.then @tuple//left @@ -255,14 +255,14 @@ tail))))) (_.return tail)))) -(def: runtime//lux +(def runtime//lux Statement (all _.then @lux//try @lux//program_args )) -(def: cap_shift +(def cap_shift (_.% (_.int +64))) (runtime: (i64//left_shifted param subject) @@ -296,7 +296,7 @@ (_.return (_.- (|> subject (..i64//division param) (_.* param)) subject))) -(def: runtime//i64 +(def runtime//i64 Statement (all _.then @i64//left_shifted @@ -305,26 +305,26 @@ @i64//remainder )) -(def: (find_byte_index subject param start) +(def (find_byte_index subject param start) (-> Expression Expression Expression Expression) (_.apply (list subject param start (_.boolean #1)) (_.var "string.find"))) -(def: (char_index subject byte_index) +(def (char_index subject byte_index) (-> Expression Expression Expression) (_.apply (list subject (_.int +1) byte_index) (_.var "utf8.len"))) -(def: (byte_index subject char_index) +(def (byte_index subject char_index) (-> Expression Expression Expression) (_.apply (list subject (_.+ (_.int +1) char_index)) (_.var "utf8.offset"))) -(def: lux_index +(def lux_index (-> Expression Expression) (_.- (_.int +1))) ... TODO: Remove this once the Lua compiler becomes self-hosted. -(def: on_rembulan? +(def on_rembulan? (_.= (_.string "Lua 5.3") (_.var "_VERSION"))) @@ -393,7 +393,7 @@ <rembulan> <normal>)))) -(def: runtime//text +(def runtime//text Statement (all _.then @text//index @@ -407,13 +407,13 @@ (_.set (list (..item idx array)) value) (_.return array))) -(def: runtime//array +(def runtime//array Statement (all _.then @array//write )) -(def: runtime +(def runtime Statement (all _.then ..runtime//adt @@ -423,7 +423,7 @@ ..runtime//array )) -(def: .public generate +(def .public generate (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux index 65ed33699..128bedbbe 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux @@ -15,7 +15,7 @@ ["//[1]" /// ["[1][0]" phase (.open: "[1]#[0]" monad)]]]]) -(def: .public (tuple phase archive elemsS+) +(def .public (tuple phase archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ {.#End} @@ -29,7 +29,7 @@ (monad.each ///////phase.monad (phase archive)) (///////phase#each _.array)))) -(def: .public (variant phase archive [lefts right? valueS]) +(def .public (variant phase archive [lefts right? valueS]) (Generator (Variant Synthesis)) (///////phase#each (//runtime.variant lefts right?) (phase archive valueS))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux index dea69708f..5a1e5294c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux @@ -29,7 +29,7 @@ [reference (.only) [variable (.only)]]]]]]]) -(def: (statement expression archive synthesis) +(def (statement expression archive synthesis) Phase! (case synthesis (^.with_template [<tag>] @@ -67,7 +67,7 @@ (exception: .public cannot_recur_as_an_expression) -(def: .public (expression archive synthesis) +(def .public (expression archive synthesis) Phase (case synthesis (^.with_template [<tag> <generator>] @@ -104,6 +104,6 @@ {////synthesis.#Extension extension} (///extension.apply archive expression extension))) -(def: .public generate +(def .public generate Phase ..expression) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux index f9ea165c8..da294881a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux @@ -36,15 +36,15 @@ [meta [archive (.only Archive)]]]]]]]) -(def: .public register +(def .public register (-> Register Var) (|>> (///reference.local //reference.system) as_expected)) -(def: .public capture +(def .public capture (-> Register Var) (|>> (///reference.foreign //reference.system) as_expected)) -(def: .public (let expression archive [valueS register bodyS]) +(def .public (let expression archive [valueS register bodyS]) (Generator [Synthesis Register Synthesis]) (do ///////phase.monad [valueG (expression archive valueS) @@ -54,7 +54,7 @@ _.array/* (_.item (_.int +1)))))) -(def: .public (let! statement expression archive [valueS register bodyS]) +(def .public (let! statement expression archive [valueS register bodyS]) (Generator! [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -63,7 +63,7 @@ (_.set! (..register register) valueO) body!)))) -(def: .public (if expression archive [testS thenS elseS]) +(def .public (if expression archive [testS thenS elseS]) (Generator [Synthesis Synthesis Synthesis]) (do ///////phase.monad [testG (expression archive testS) @@ -71,7 +71,7 @@ elseG (expression archive elseS)] (in (_.? testG thenG elseG)))) -(def: .public (if! statement expression archive [testS thenS elseS]) +(def .public (if! statement expression archive [testS thenS elseS]) (Generator! [Synthesis Synthesis Synthesis]) (do ///////phase.monad [test! (expression archive testS) @@ -81,7 +81,7 @@ then! else!)))) -(def: .public (get expression archive [pathP valueS]) +(def .public (get expression archive [pathP valueS]) (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueG (expression archive valueS)] @@ -96,46 +96,46 @@ valueG (list.reversed pathP))))) -(def: @savepoint (_.var "lux_pm_savepoint")) -(def: @cursor (_.var "lux_pm_cursor")) -(def: @temp (_.var "lux_pm_temp")) +(def @savepoint (_.var "lux_pm_savepoint")) +(def @cursor (_.var "lux_pm_cursor")) +(def @temp (_.var "lux_pm_temp")) -(def: (push! value) +(def (push! value) (-> Expression Statement) (_.; (_.array_push/2 [@cursor value]))) -(def: peek_and_pop +(def peek_and_pop Expression (_.array_pop/1 @cursor)) -(def: pop! +(def pop! Statement (_.; ..peek_and_pop)) -(def: peek +(def peek Expression (_.item (|> @cursor _.count/1 (_.- (_.int +1))) @cursor)) -(def: save! +(def save! Statement (.let [cursor (_.array_slice/2 [@cursor (_.int +0)])] (_.; (_.array_push/2 [@savepoint cursor])))) -(def: restore! +(def restore! Statement (_.set! @cursor (_.array_pop/1 @savepoint))) -(def: fail! _.break) +(def fail! _.break) -(def: (multi_pop! pops) +(def (multi_pop! pops) (-> Nat Statement) (_.; (_.array_splice/3 [@cursor (_.int +0) (_.int (i.* -1 (.int pops)))]))) (with_template [<name> <flag> <prep>] - [(def: (<name> simple? idx) + [(def (<name> simple? idx) (-> Bit Nat Statement) (all _.then (_.set! @temp (|> idx <prep> .int _.int (//runtime.sum//get ..peek <flag>))) @@ -150,7 +150,7 @@ [right_choice (_.string "") ++] ) -(def: (alternation pre! post!) +(def (alternation pre! post!) (-> Statement Statement Statement) (all _.then (_.do_while (_.bool false) @@ -161,7 +161,7 @@ ..restore! post!))) -(def: (pattern_matching' statement expression archive) +(def (pattern_matching' statement expression archive) (Generator! Path) (function (again pathP) (.case pathP @@ -250,7 +250,7 @@ ([/////synthesis.path/seq _.then] [/////synthesis.path/alt ..alternation])))) -(def: (pattern_matching statement expression archive pathP) +(def (pattern_matching statement expression archive pathP) (Generator! Path) (do ///////phase.monad [iteration! (pattern_matching' statement expression archive pathP)] @@ -259,7 +259,7 @@ iteration!) (_.throw (_.new (_.constant "Exception") (list (_.string ////synthesis/case.pattern_matching_error)))))))) -(def: .public dependencies +(def .public dependencies (-> Path (List Var)) (|>> ////synthesis/case.storage (the ////synthesis/case.#dependencies) @@ -272,7 +272,7 @@ {///////variable.#Foreign register} (..capture register)))))) -(def: .public (case! statement expression archive [valueS pathP]) +(def .public (case! statement expression archive [valueS pathP]) (Generator! [Synthesis Path]) (do ///////phase.monad [stack_init (expression archive valueS) @@ -282,7 +282,7 @@ (_.set! @savepoint (_.array/* (list))) pattern_matching!)))) -(def: .public (case statement expression archive [valueS pathP]) +(def .public (case statement expression archive [valueS pathP]) (-> Phase! (Generator [Synthesis Path])) (do [! ///////phase.monad] [[[case_module case_artifact] case!] (/////generation.with_new_context archive diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension.lux index 90acc3cef..eac649c9c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension.lux @@ -9,6 +9,6 @@ [/ ["[0]" common]]) -(def: .public bundle +(def .public bundle Bundle common.bundle) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux index e569c80b2..fd5202409 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux @@ -24,13 +24,13 @@ [extension ["[0]" bundle]]]]]) -(def: lux_procs +(def lux_procs Bundle (|> bundle.empty (bundle.install "is" (binary (product.uncurried _.=))) (bundle.install "try" (unary ///runtime.lux//try)))) -(def: i64_procs +(def i64_procs Bundle (<| (bundle.prefix "i64") (|> bundle.empty @@ -45,7 +45,7 @@ (bundle.install "-" (binary (product.uncurried _.-))) ))) -(def: int_procs +(def int_procs Bundle (<| (bundle.prefix "int") (|> bundle.empty @@ -56,7 +56,7 @@ (bundle.install "frac" (unary _.floatval/1)) (bundle.install "char" (unary _.chr/1))))) -(def: frac_procs +(def frac_procs Bundle (<| (bundle.prefix "frac") (|> bundle.empty @@ -72,11 +72,11 @@ (bundle.install "decode" (unary (|>> _.floatval/1 ///runtime.some))) ))) -(def: (text//index [startO partO textO]) +(def (text//index [startO partO textO]) (Trinary (Expression Any)) (///runtime.text//index textO partO startO)) -(def: text_procs +(def text_procs Bundle (<| (bundle.prefix "text") (|> bundle.empty @@ -91,7 +91,7 @@ (_.substr/3 [text from (_.- from to)])))) ))) -(def: io_procs +(def io_procs Bundle (<| (bundle.prefix "io") (|> bundle.empty @@ -100,7 +100,7 @@ (bundle.install "exit" (unary _.exit/1)) (bundle.install "current-time" (nullary (|>> _.time/0 (_.* (_.int +1,000)))))))) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "lux") (|> lux_procs diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux index b0c6a19a0..5a07d5032 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux @@ -29,25 +29,25 @@ [reference [variable (.only Register Variable)]]]]]]) -(def: .public (apply expression archive [functionS argsS+]) +(def .public (apply expression archive [functionS argsS+]) (Generator (Application Synthesis)) (do [! ///////phase.monad] [functionG (expression archive functionS) argsG+ (monad.each ! (expression archive) argsS+)] (in (_.apply' argsG+ functionG)))) -(def: capture +(def capture (-> Register Var) (|>> (///reference.foreign //reference.system) as_expected)) -(def: input +(def input (|>> ++ //case.register)) -(def: (@scope function_name) +(def (@scope function_name) (-> Context Label) (_.label (format (///reference.artifact function_name) "_scope"))) -(def: (with_closure inits @selfG @selfL body!) +(def (with_closure inits @selfG @selfL body!) (-> (List Expression) Global Var Statement [Statement Expression]) (case inits {.#End} @@ -67,7 +67,7 @@ (_.return @selfL)))) (_.apply inits @selfG)]))) -(def: .public (function statement expression archive [environment arity bodyS]) +(def .public (function statement expression archive [environment arity bodyS]) (-> Phase! (Generator (Abstraction Synthesis))) (do [! ///////phase.monad] [[function_name body!] (/////generation.with_new_context archive diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux index f9798f4e6..c495d5a12 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux @@ -33,11 +33,11 @@ [reference [variable (.only Register)]]]]]]]) -(def: @scope +(def @scope (-> Nat Label) (|>> %.nat (format "scope") _.label)) -(def: (setup offset bindings body) +(def (setup offset bindings body) (-> Register (List Expression) Statement Statement) ... TODO: There is a bug in the way the variables are updated. Do it like it's done in either JS or Lua. (|> bindings @@ -48,7 +48,7 @@ list.reversed (list#mix _.then body))) -(def: .public (scope! statement expression archive [start initsS+ bodyS]) +(def .public (scope! statement expression archive [start initsS+ bodyS]) (Generator! (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop @@ -67,7 +67,7 @@ (_.set_label @scope) body!)))))) -(def: .public (scope statement expression archive [start initsS+ bodyS]) +(def .public (scope statement expression archive [start initsS+ bodyS]) (-> Phase! (Generator (Scope Synthesis))) (case initsS+ ... function/false/non-independent loop @@ -106,10 +106,10 @@ (in (_.apply (list) instantiation))))) ... TODO: Stop using a constant hard-coded variable. Generate a new one each time. -(def: @temp +(def @temp (_.var "lux_again_values")) -(def: .public (again! statement expression archive argsS+) +(def .public (again! statement expression archive argsS+) (Generator! (List Synthesis)) (do [! ///////phase.monad] [[offset @scope] /////generation.anchor diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/primitive.lux index df2ae080f..b88e520c8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/primitive.lux @@ -9,11 +9,11 @@ ["[0]" // ["[1][0]" runtime]]) -(def: .public bit +(def .public bit (-> Bit Literal) _.bool) -(def: .public (i64 value) +(def .public (i64 value) (-> (I64 Any) Expression) (let [h32 (|> value //runtime.high .int _.int) l32 (|> value //runtime.low .int _.int)] @@ -21,10 +21,10 @@ (_.bit_shl (_.int +32)) (_.bit_or l32)))) -(def: .public f64 +(def .public f64 (-> Frac Literal) _.float) -(def: .public text +(def .public text (-> Text Literal) _.string) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/reference.lux index 1fb4ce3e2..8d723c451 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(def: .public system +(def .public system (System Expression) (implementation - (def: constant _.global) - (def: variable _.var))) + (def constant _.global) + (def variable _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux index a8a1229dd..425dee836 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux @@ -57,20 +57,20 @@ (type: .public (Generator! i) (-> Phase! Phase Archive i (Operation Statement))) -(def: .public unit +(def .public unit (_.string /////synthesis.unit)) -(def: (flag value) +(def (flag value) (-> Bit Literal) (if value ..unit _.null)) -(def: (feature name definition) +(def (feature name definition) (-> Constant (-> Constant Statement) Statement) (definition name)) -(def: .public with_vars +(def .public with_vars (syntax (_ [vars (<code>.tuple (<>.some <code>.local)) body <code>.any]) (do [! meta.monad] @@ -83,10 +83,10 @@ list.together))] (~ body)))))))) -(def: module_id +(def module_id 0) -(def: runtime: +(def runtime: (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -100,11 +100,11 @@ {.#Left name} (macro.with_symbols [g!_] (let [g!name (code.local name)] - (in (list (` (def: .public (~ g!name) + (in (list (` (def .public (~ g!name) Var (~ runtime_name))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) Statement (..feature (~ runtime_name) (function ((~ g!_) (~ g!name)) @@ -116,11 +116,11 @@ inputsC (list#each code.local inputs) inputs_typesC (list#each (function.constant (` _.Expression)) inputs)] - (in (list (` (def: .public ((~ g!name) (~+ inputsC)) + (in (list (` (def .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) Computation) (_.apply (list (~+ inputsC)) (~ runtime_name)))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) Statement (..feature (~ runtime_name) (function ((~ g!_) (~ g!_)) @@ -140,20 +140,20 @@ (_.throw (_.new (_.constant "Exception") (list message))) (_.return ..unit))) -(def: runtime//io +(def runtime//io Statement (all _.then @io//log! @io//throw! )) -(def: .public tuple_size_field +(def .public tuple_size_field "_lux_size") -(def: tuple_size +(def tuple_size (_.item (_.string ..tuple_size_field))) -(def: jphp? +(def jphp? (_.=== (_.string "5.6.99") (_.phpversion/0 []))) (runtime: (array//length array) @@ -167,17 +167,17 @@ (_.set! (_.item idx array) value) (_.return array))) -(def: runtime//array +(def runtime//array Statement (all _.then @array//length @array//write )) -(def: jphp_last_index +(def jphp_last_index (|>> ..tuple_size (_.- (_.int +1)))) -(def: normal_last_index +(def normal_last_index (|>> _.count/1 (_.- (_.int +1)))) (with_expansions [<recur> (these (all _.then @@ -243,34 +243,34 @@ (_.array_slice/2 [(_.do "getArrayCopy" (list) tuple) right_index]))))) ))))) -(def: .public variant_tag_field "_lux_tag") -(def: .public variant_flag_field "_lux_flag") -(def: .public variant_value_field "_lux_value") +(def .public variant_tag_field "_lux_tag") +(def .public variant_flag_field "_lux_flag") +(def .public variant_value_field "_lux_value") (runtime: (sum//make tag last? value) (_.return (_.array/** (list [(_.string ..variant_tag_field) tag] [(_.string ..variant_flag_field) last?] [(_.string ..variant_value_field) value])))) -(def: .public (variant tag last? value) +(def .public (variant tag last? value) (-> Nat Bit Expression Computation) (sum//make (_.int (.int tag)) (..flag last?) value)) -(def: .public none +(def .public none Computation (..variant 0 #0 ..unit)) -(def: .public some +(def .public some (-> Expression Computation) (..variant 1 #1)) -(def: .public left +(def .public left (-> Expression Computation) (..variant 0 #0)) -(def: .public right +(def .public right (-> Expression Computation) (..variant 1 #1)) @@ -302,7 +302,7 @@ (_.return (sum//make (_.- wantedTag sum_tag) sum_flag sum_value))]) no_match!)))) -(def: runtime//adt +(def runtime//adt Statement (all _.then @tuple//make @@ -331,18 +331,18 @@ (_.set! tail (..some (_.array/* (list head tail))))) (_.return tail)))) -(def: runtime//lux +(def runtime//lux Statement (all _.then @lux//try @lux//program_args )) -(def: .public high +(def .public high (-> (I64 Any) (I64 Any)) (i64.right_shifted 32)) -(def: .public low +(def .public low (-> (I64 Any) (I64 Any)) (let [mask (-- (i64.left_shifted 32 1))] (|>> (i64.and mask)))) @@ -491,7 +491,7 @@ (_.bit_or low32)))) )))) -(def: runtime//i64 +(def runtime//i64 Statement (all _.then @i64//right_shifted @@ -523,7 +523,7 @@ (_.return ..none) (_.return (..some idx)))))))) -(def: (within? top value) +(def (within? top value) (-> Expression Expression Computation) (_.and (|> value (_.>= (_.int +0))) (|> value (_.< top)))) @@ -545,7 +545,7 @@ (_.item (_.int +1))))) (_.throw (_.new (_.constant "Exception") (list (_.string "[Lux Error] Cannot get char from text.")))))) -(def: runtime//text +(def runtime//text Statement (all _.then @text//size @@ -571,13 +571,13 @@ (_.return (..some output))) ))) -(def: runtime//f64 +(def runtime//f64 Statement (all _.then @f64//decode )) -(def: check_necessary_conditions! +(def check_necessary_conditions! Statement (let [i64_support? (_.=== (_.int +8) (_.constant "PHP_INT_SIZE")) i64_error (_.string (format "Cannot run program!" text.new_line @@ -585,7 +585,7 @@ (_.when (_.not i64_support?) (_.throw (_.new (_.constant "Exception") (list i64_error)))))) -(def: runtime +(def runtime Statement (all _.then check_necessary_conditions! @@ -598,7 +598,7 @@ runtime//io )) -(def: .public generate +(def .public generate (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux index d7a945e58..2cc580fe5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux @@ -17,7 +17,7 @@ ["//[1]" /// ["[1][0]" phase (.open: "[1]#[0]" monad)]]]]) -(def: .public (tuple expression archive elemsS+) +(def .public (tuple expression archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ {.#End} @@ -33,7 +33,7 @@ (///////phase#each (|>> _.array/* (//runtime.tuple//make size))))))) -(def: .public (variant expression archive [lefts right? valueS]) +(def .public (variant expression archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux index a0c15f71e..f51b79f96 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux @@ -34,7 +34,7 @@ (exception: .public cannot_recur_as_an_expression) -(def: .public (expression archive synthesis) +(def .public (expression archive synthesis) Phase (case synthesis (^.with_template [<tag> <generator>] @@ -74,6 +74,6 @@ {////synthesis.#Extension extension} (///extension.apply archive expression extension))) -(def: .public generate +(def .public generate Phase ..expression) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux index 6b7d425f9..48ab895d4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux @@ -41,20 +41,20 @@ [dependency ["[1]" artifact]]]]]]]]]) -(def: .public (symbol prefix) +(def .public (symbol prefix) (-> Text (Operation SVar)) (///////phase#each (|>> %.nat (format prefix) _.var) /////generation.next)) -(def: .public register +(def .public register (-> Register SVar) (|>> (///reference.local //reference.system) as_expected)) -(def: .public capture +(def .public capture (-> Register SVar) (|>> (///reference.foreign //reference.system) as_expected)) -(def: .public (let expression archive [valueS register bodyS]) +(def .public (let expression archive [valueS register bodyS]) (Generator [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -64,7 +64,7 @@ (_.lambda (list (..register register)) bodyO))))) -(def: .public (let! statement expression archive [valueS register bodyS]) +(def .public (let! statement expression archive [valueS register bodyS]) (Generator! [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -73,14 +73,14 @@ (_.set (list (..register register)) valueO) bodyO)))) -(def: .public (exec expression archive [pre post]) +(def .public (exec expression archive [pre post]) (Generator [Synthesis Synthesis]) (do ///////phase.monad [pre (expression archive pre) post (expression archive post)] (in (_.item (_.int +1) (_.tuple (list pre post)))))) -(def: .public (exec! statement expression archive [pre post]) +(def .public (exec! statement expression archive [pre post]) (Generator! [Synthesis Synthesis]) (do ///////phase.monad [pre (expression archive pre) @@ -89,7 +89,7 @@ (_.statement pre) post)))) -(def: .public (if expression archive [testS thenS elseS]) +(def .public (if expression archive [testS thenS elseS]) (Generator [Synthesis Synthesis Synthesis]) (do ///////phase.monad [testO (expression archive testS) @@ -97,7 +97,7 @@ elseO (expression archive elseS)] (in (_.? testO thenO elseO)))) -(def: .public (if! statement expression archive [testS thenS elseS]) +(def .public (if! statement expression archive [testS thenS elseS]) (Generator! [Synthesis Synthesis Synthesis]) (do ///////phase.monad [test! (expression archive testS) @@ -107,7 +107,7 @@ then! else!)))) -(def: .public (get expression archive [pathP valueS]) +(def .public (get expression archive [pathP valueS]) (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueO (expression archive valueS)] @@ -120,43 +120,43 @@ valueO (list.reversed pathP))))) -(def: @savepoint (_.var "lux_pm_savepoint")) -(def: @cursor (_.var "lux_pm_cursor")) -(def: @temp (_.var "lux_pm_temp")) +(def @savepoint (_.var "lux_pm_savepoint")) +(def @cursor (_.var "lux_pm_cursor")) +(def @temp (_.var "lux_pm_temp")) -(def: (push! value) +(def (push! value) (-> (Expression Any) (Statement Any)) (_.statement (|> @cursor (_.do "append" (list value))))) -(def: peek_and_pop +(def peek_and_pop (Expression Any) (|> @cursor (_.do "pop" (list)))) -(def: pop! +(def pop! (Statement Any) (_.statement ..peek_and_pop)) -(def: peek +(def peek (Expression Any) (_.item (_.int -1) @cursor)) -(def: save! +(def save! (Statement Any) (.let [cursor (_.slice_from (_.int +0) @cursor)] (_.statement (|> @savepoint (_.do "append" (list cursor)))))) -(def: restore! +(def restore! (Statement Any) (_.set (list @cursor) (|> @savepoint (_.do "pop" (list))))) -(def: fail_pm! _.break) +(def fail_pm! _.break) -(def: (multi_pop! pops) +(def (multi_pop! pops) (-> Nat (Statement Any)) (_.delete (_.slice_from (_.int (i.* -1 (.int pops))) @cursor))) (with_template [<name> <flag>] - [(def: (<name> simple? idx) + [(def (<name> simple? idx) (-> Bit Nat (Statement Any)) (all _.then (_.set (list @temp) (//runtime.sum::get ..peek <flag> @@ -173,7 +173,7 @@ [right_choice //runtime.unit] ) -(def: (with_looping in_closure? g!once body!) +(def (with_looping in_closure? g!once body!) (-> Bit SVar (Statement Any) (Statement Any)) (.if in_closure? (_.while (_.bool true) @@ -187,7 +187,7 @@ body!) {.#Some _.continue})))) -(def: (alternation in_closure? g!once pre! post!) +(def (alternation in_closure? g!once pre! post!) (-> Bit SVar (Statement Any) (Statement Any) (Statement Any)) (all _.then (..with_looping in_closure? g!once @@ -197,7 +197,7 @@ ..restore! post!)) -(def: (primitive_pattern_matching again pathP) +(def (primitive_pattern_matching again pathP) (-> (-> Path (Operation (Statement Any))) (-> Path (Operation (Maybe (Statement Any))))) (.case pathP @@ -238,7 +238,7 @@ _ (at ///////phase.monad in {.#None}))) -(def: (pattern_matching' in_closure? statement expression archive) +(def (pattern_matching' in_closure? statement expression archive) (-> Bit Phase! Phase Archive Path (Operation (Statement Any))) (function (again pathP) (do [! ///////phase.monad] @@ -309,7 +309,7 @@ _ (undefined)))))) -(def: (pattern_matching in_closure? statement expression archive pathP) +(def (pattern_matching in_closure? statement expression archive pathP) (-> Bit Phase! Phase Archive Path (Operation (Statement Any))) (do ///////phase.monad [pattern_matching! (pattern_matching' in_closure? statement expression archive pathP) @@ -319,7 +319,7 @@ pattern_matching!) (_.raise (_.Exception/1 (_.string case.pattern_matching_error))))))) -(def: .public dependencies +(def .public dependencies (-> Path (List SVar)) (|>> case.storage (the case.#dependencies) @@ -332,7 +332,7 @@ {///////variable.#Foreign register} (..capture register)))))) -(def: .public (case! in_closure? statement expression archive [valueS pathP]) +(def .public (case! in_closure? statement expression archive [valueS pathP]) (-> Bit (Generator! [Synthesis Path])) (do ///////phase.monad [stack_init (expression archive valueS) @@ -343,7 +343,7 @@ pattern_matching! )))) -(def: .public (case statement expression archive [valueS pathP]) +(def .public (case statement expression archive [valueS pathP]) (-> Phase! (Generator [Synthesis Path])) (do ///////phase.monad [dependencies (cache.path_dependencies archive pathP) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux index abcc258a4..ca93b78d7 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux @@ -34,18 +34,18 @@ [dependency ["[1]" artifact]]]]]]]]) -(def: .public (apply expression archive [functionS argsS+]) +(def .public (apply expression archive [functionS argsS+]) (Generator (Reification Synthesis)) (do [! ///////phase.monad] [functionO (expression archive functionS) argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply argsO+ functionO)))) -(def: .public capture +(def .public capture (-> Register SVar) (|>> (///reference.foreign //reference.system) as_expected)) -(def: (with_closure function_id @function inits function_definition) +(def (with_closure function_id @function inits function_definition) (-> artifact.ID SVar (List (Expression Any)) (Statement Any) (Operation (Expression Any))) (case inits {.#End} @@ -66,10 +66,10 @@ _ (/////generation.save! function_id {.#None} directive)] (in (_.apply inits @function))))) -(def: input +(def input (|>> ++ //case.register)) -(def: .public (function statement expression archive [environment arity bodyS]) +(def .public (function statement expression archive [environment arity bodyS]) (-> Phase! (Generator (Abstraction Synthesis))) (do [! ///////phase.monad] [dependencies (cache.dependencies archive bodyS) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux index 9dc509654..def965231 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux @@ -35,7 +35,7 @@ [reference ["[1][0]" variable (.only Register)]]]]]]]) -(def: (setup offset bindings body) +(def (setup offset bindings body) (-> Register (List (Expression Any)) (Statement Any) (Statement Any)) (let [variables (|> bindings list.enumeration @@ -44,13 +44,13 @@ (_.set variables (_.multi bindings)) body))) -(def: .public (set_scope body!) +(def .public (set_scope body!) (-> (Statement Any) (Statement Any)) (_.while (_.bool true) body! {.#None})) -(def: .public (scope! statement expression archive [start initsS+ bodyS]) +(def .public (scope! statement expression archive [start initsS+ bodyS]) (Generator! (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop @@ -67,7 +67,7 @@ ..set_scope body!))))) -(def: .public (scope statement expression archive [start initsS+ bodyS]) +(def .public (scope statement expression archive [start initsS+ bodyS]) (-> Phase! (Generator (Scope Synthesis))) (case initsS+ ... function/false/non-independent loop @@ -110,7 +110,7 @@ _ (/////generation.save! loop_artifact {.#None} directive)] (in (_.apply initsO+ instantiation))))) -(def: .public (again! statement expression archive argsS+) +(def .public (again! statement expression archive argsS+) (Generator! (List Synthesis)) (do [! ///////phase.monad] [offset /////generation.anchor diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/primitive.lux index 7afebeba8..7e565f3fe 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/primitive.lux @@ -7,7 +7,7 @@ ["[1][0]" runtime]]) (with_template [<type> <name> <implementation>] - [(def: .public <name> + [(def .public <name> (-> <type> (Expression Any)) <implementation>)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/reference.lux index 47b64cd94..8786e5309 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(def: .public system +(def .public system (System (Expression Any)) (implementation - (def: constant' _.var) - (def: variable' _.var))) + (def constant' _.var) + (def variable' _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux index 194f641ee..5c984981b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux @@ -60,56 +60,56 @@ (type: .public (Generator i) (-> Phase Archive i (Operation (Expression Any)))) -(def: prefix +(def prefix "LuxRuntime") -(def: .public unit +(def .public unit (_.unicode /////synthesis.unit)) -(def: (flag value) +(def (flag value) (-> Bit Literal) (if value ..unit _.none)) -(def: (variant' tag last? value) +(def (variant' tag last? value) (-> (Expression Any) (Expression Any) (Expression Any) Literal) (_.tuple (list tag last? value))) -(def: .public (variant tag last? value) +(def .public (variant tag last? value) (-> Nat Bit (Expression Any) Literal) (variant' (_.int (.int tag)) (flag last?) value)) -(def: .public left +(def .public left (-> (Expression Any) Literal) (..variant 0 #0)) -(def: .public right +(def .public right (-> (Expression Any) Literal) (..variant 0 #1)) -(def: .public none +(def .public none Literal (..left ..unit)) -(def: .public some +(def .public some (-> (Expression Any) Literal) ..right) -(def: (runtime_name name) +(def (runtime_name name) (-> Text SVar) (let [symbol (format ..prefix "_" (%.nat version.latest) "_" (%.nat (text#hash name)))] (_.var symbol))) -(def: (feature name definition) +(def (feature name definition) (-> SVar (-> SVar (Statement Any)) (Statement Any)) (definition name)) -(def: .public with_vars +(def .public with_vars (syntax (_ [vars (<code>.tuple (<>.some <code>.local)) body <code>.any]) (do [! meta.monad] @@ -122,7 +122,7 @@ list.together))] (~ body)))))))) -(def: runtime: +(def runtime: (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -133,8 +133,8 @@ (let [nameC (code.local name) code_nameC (code.local (format "@" name)) runtime_nameC (` (runtime_name (~ (code.text name))))] - (in (list (` (def: .public (~ nameC) SVar (~ runtime_nameC))) - (` (def: (~ code_nameC) + (in (list (` (def .public (~ nameC) SVar (~ runtime_nameC))) + (` (def (~ code_nameC) (Statement Any) (..feature (~ runtime_nameC) (function ((~ g!_) (~ g!_)) @@ -148,10 +148,10 @@ inputsC (list#each code.local inputs) inputs_typesC (list#each (function.constant (` (_.Expression Any))) inputs)] - (in (list (` (def: .public ((~ nameC) (~+ inputsC)) + (in (list (` (def .public ((~ nameC) (~+ inputsC)) (-> (~+ inputs_typesC) (Computation Any)) (_.apply (list (~+ inputsC)) (~ runtime_nameC)))) - (` (def: (~ code_nameC) + (` (def (~ code_nameC) (Statement Any) (..feature (~ runtime_nameC) (function ((~ g!_) (~ g!_)) @@ -179,7 +179,7 @@ (_.exec {.#Some globals} code) (_.return ..unit))) -(def: runtime::lux +(def runtime::lux (Statement Any) (all _.then @lux::try @@ -199,14 +199,14 @@ (runtime: (io::throw! message) (_.raise (_.Exception/1 message))) -(def: runtime::io +(def runtime::io (Statement Any) (all _.then @io::log! @io::throw! )) -(def: last_index +(def last_index (|>> _.len/1 (_.- (_.int +1)))) (with_expansions [<recur> (these (all _.then @@ -266,7 +266,7 @@ mismatch!) {.#None}))) -(def: runtime::adt +(def runtime::adt (Statement Any) (all _.then @tuple::left @@ -274,12 +274,12 @@ @sum::get )) -(def: i64::+limit (_.manual "+0x7FFFFFFFFFFFFFFF")) -(def: i64::-limit (_.manual "-0x8000000000000000")) -(def: i64::+iteration (_.manual "+0x10000000000000000")) -(def: i64::-iteration (_.manual "-0x10000000000000000")) -(def: i64::+cap (_.manual "+0x8000000000000000")) -(def: i64::-cap (_.manual "-0x8000000000000001")) +(def i64::+limit (_.manual "+0x7FFFFFFFFFFFFFFF")) +(def i64::-limit (_.manual "-0x8000000000000000")) +(def i64::+iteration (_.manual "+0x10000000000000000")) +(def i64::-iteration (_.manual "-0x10000000000000000")) +(def i64::+cap (_.manual "+0x8000000000000000")) +(def i64::-cap (_.manual "-0x8000000000000001")) (runtime: (i64::64 input) (with_vars [temp] @@ -298,7 +298,7 @@ ... This +- is only necessary to guarantee that values within the limits are always longs in Python 2 (|> input (_.+ ..i64::+limit) (_.- ..i64::+limit)))))))) -(def: as_nat +(def as_nat (_.% ..i64::+iteration)) (runtime: (i64::left_shifted param subject) @@ -345,7 +345,7 @@ [i64::xor _.bit_xor] ) -(def: python_version +(def python_version (Expression Any) (|> (_.__import__/1 (_.unicode "sys")) (_.the "version_info") @@ -356,7 +356,7 @@ (_.chr/1 value) (_.unichr/1 value)))) -(def: runtime::i64 +(def runtime::i64 (Statement Any) (all _.then @i64::64 @@ -385,7 +385,7 @@ (list [(list "Exception") ex (_.return ..none)])))) -(def: runtime::f64 +(def runtime::f64 (Statement Any) (all _.then @f64::/ @@ -400,10 +400,10 @@ ..none (..some (..i64::64 idx))))))) -(def: ++ +(def ++ (|>> (_.+ (_.int +1)))) -(def: (within? top value) +(def (within? top value) (-> (Expression Any) (Expression Any) (Computation Any)) (_.and (|> value (_.>= (_.int +0))) (|> value (_.< top)))) @@ -416,7 +416,7 @@ (_.return (|> text (_.slice idx (..++ idx)) _.ord/1 ..i64::64)) (_.raise (_.Exception/1 (_.unicode "[Lux Error] Cannot get char from text."))))) -(def: runtime::text +(def runtime::text (Statement Any) (all _.then @text::index @@ -429,13 +429,13 @@ (_.set (list (_.item idx array)) value) (_.return array))) -(def: runtime::array +(def runtime::array (Statement Any) (all _.then @array::write )) -(def: runtime +(def runtime (Statement Any) (all _.then runtime::lux @@ -447,10 +447,10 @@ runtime::array )) -(def: module_id +(def module_id 0) -(def: .public generate +(def .public generate (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux index 560fb1c49..cd9fe5bee 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux @@ -15,7 +15,7 @@ ["//[1]" /// ["[1][0]" phase (.open: "[1]#[0]" monad)]]]]) -(def: .public (tuple generate archive elemsS+) +(def .public (tuple generate archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ {.#End} @@ -29,7 +29,7 @@ (monad.each ///////phase.monad (generate archive)) (///////phase#each _.list)))) -(def: .public (variant generate archive [lefts right? valueS]) +(def .public (variant generate archive [lefts right? valueS]) (Generator (Variant Synthesis)) (///////phase#each (//runtime.variant lefts right?) (generate archive valueS))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r.lux index 582d8dd42..b73d54264 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r.lux @@ -27,7 +27,7 @@ [reference (.only) [variable (.only)]]]]]]]) -(def: .public (generate archive synthesis) +(def .public (generate archive synthesis) Phase (case synthesis (^.with_template [<tag> <generator>] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux index 6f41454c2..ff52e460e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux @@ -37,15 +37,15 @@ [meta [archive (.only Archive)]]]]]]]) -(def: .public register +(def .public register (-> Register SVar) (|>> (///reference.local //reference.system) as_expected)) -(def: .public capture +(def .public capture (-> Register SVar) (|>> (///reference.foreign //reference.system) as_expected)) -(def: .public (let expression archive [valueS register bodyS]) +(def .public (let expression archive [valueS register bodyS]) (Generator [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -55,7 +55,7 @@ (_.set! (..register register) valueO) bodyO))))) -(def: .public (if expression archive [testS thenS elseS]) +(def .public (if expression archive [testS thenS elseS]) (Generator [Synthesis Synthesis Synthesis]) (do ///////phase.monad [testO (expression archive testS) @@ -63,7 +63,7 @@ elseO (expression archive elseS)] (in (_.if testO thenO elseO)))) -(def: .public (get expression archive [pathP valueS]) +(def .public (get expression archive [pathP valueS]) (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueO (expression archive valueS)] @@ -78,61 +78,61 @@ valueO (list.reversed pathP))))) -(def: $savepoint (_.var "lux_pm_cursor_savepoint")) -(def: $cursor (_.var "lux_pm_cursor")) -(def: $temp (_.var "lux_pm_temp")) -(def: $alt_error (_.var "alt_error")) +(def $savepoint (_.var "lux_pm_cursor_savepoint")) +(def $cursor (_.var "lux_pm_cursor")) +(def $temp (_.var "lux_pm_temp")) +(def $alt_error (_.var "alt_error")) -(def: top +(def top _.length) -(def: next +(def next (|>> _.length (_.+ (_.int +1)))) -(def: (push! value var) +(def (push! value var) (-> Expression SVar Expression) (_.set_item! (next var) value var)) -(def: (pop! var) +(def (pop! var) (-> SVar Expression) (_.set_item! (top var) _.null var)) -(def: (push_cursor! value) +(def (push_cursor! value) (-> Expression Expression) (push! value $cursor)) -(def: save_cursor! +(def save_cursor! Expression (push! (_.slice (_.float +1.0) (_.length $cursor) $cursor) $savepoint)) -(def: restore_cursor! +(def restore_cursor! Expression (_.set! $cursor (_.item (top $savepoint) $savepoint))) -(def: peek +(def peek Expression (|> $cursor (_.item (top $cursor)))) -(def: pop_cursor! +(def pop_cursor! Expression (pop! $cursor)) -(def: error +(def error (_.string (template.with_locals [error] (template.text [error])))) -(def: fail! +(def fail! (_.stop ..error)) -(def: (catch handler) +(def (catch handler) (-> Expression Expression) (_.function (list $alt_error) (_.if (|> $alt_error (_.= ..error)) handler (_.stop $alt_error)))) -(def: (pattern_matching' expression archive) +(def (pattern_matching' expression archive) (Generator Path) (function (again pathP) (.case pathP @@ -221,7 +221,7 @@ {.#None}))) ))) -(def: (pattern_matching expression archive pathP) +(def (pattern_matching expression archive pathP) (Generator Path) (do ///////phase.monad [pattern_matching! (pattern_matching' expression archive pathP)] @@ -230,7 +230,7 @@ {.#Some (..catch (_.stop (_.string "Invalid expression for pattern-matching.")))} {.#None})))) -(def: .public (case expression archive [valueS pathP]) +(def .public (case expression archive [valueS pathP]) (Generator [Synthesis Path]) (do [! ///////phase.monad] [valueO (expression archive valueS)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux index af38457a9..d0933505c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux @@ -32,14 +32,14 @@ [archive ["[0]" artifact]]]]]]]) -(def: .public (apply expression archive [functionS argsS+]) +(def .public (apply expression archive [functionS argsS+]) (Generator (Application Synthesis)) (do [! ///////phase.monad] [functionO (expression archive functionS) argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply argsO+ functionO)))) -(def: (with_closure function_id $function inits function_definition) +(def (with_closure function_id $function inits function_definition) (-> artifact.ID SVar (List Expression) Expression (Operation Expression)) (case inits {.#End} @@ -63,15 +63,15 @@ _ (/////generation.save! (%.nat function_id) closure_definition)] (in (_.apply inits $function))))) -(def: $curried (_.var "curried")) -(def: $missing (_.var "missing")) +(def $curried (_.var "curried")) +(def $missing (_.var "missing")) -(def: (input_declaration register) +(def (input_declaration register) (-> Register Expression) (_.set! (|> register ++ //case.register) (|> $curried (_.item (|> register ++ .int _.int))))) -(def: .public (function expression archive [environment arity bodyS]) +(def .public (function expression archive [environment arity bodyS]) (Generator (Abstraction Synthesis)) (do [! ///////phase.monad] [[[function_module function_artifact] bodyO] (/////generation.with_new_context archive diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux index 9c0a9cfa1..a3b660bd8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux @@ -33,7 +33,7 @@ [reference [variable (.only Register)]]]]]]]) -(def: .public (scope expression archive [offset initsS+ bodyS]) +(def .public (scope expression archive [offset initsS+ bodyS]) (Generator (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop @@ -57,7 +57,7 @@ bodyO)) (_.apply initsO+ $scope))))))) -(def: .public (again expression archive argsS+) +(def .public (again expression archive argsS+) (Generator (List Synthesis)) (do [! ///////phase.monad] [$scope /////generation.anchor diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/primitive.lux index ca30d7b84..1bbd9332c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/primitive.lux @@ -7,7 +7,7 @@ ["[1][0]" runtime]]) (with_template [<name> <type> <code>] - [(def: .public <name> + [(def .public <name> (-> <type> Expression) <code>)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux index 23f19d400..62d2f235b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux @@ -35,12 +35,12 @@ (Dict Text Proc)) ... [Utils] -(def: .public (install name unnamed) +(def .public (install name unnamed) (-> Text (-> Text Proc) (-> Bundle Bundle)) (dict.has name (unnamed name))) -(def: .public (prefix prefix bundle) +(def .public (prefix prefix bundle) (-> Text Bundle Bundle) (|> bundle dict.entries @@ -49,28 +49,28 @@ ... [Procedures] ... [[Lux]] -(def: (lux//is [leftO rightO]) +(def (lux//is [leftO rightO]) Binary (r.apply (list leftO rightO) (r.global "identical"))) -(def: (lux//if [testO thenO elseO]) +(def (lux//if [testO thenO elseO]) Trinary (caseT.translate_if testO thenO elseO)) -(def: (lux//try riskyO) +(def (lux//try riskyO) Unary (runtimeT.lux//try riskyO)) (exception: .public (Wrong_Syntax [message Text]) message) -(def: .public (wrong_syntax procedure args) +(def .public (wrong_syntax procedure args) (-> Text (List ls.Synthesis) Text) (format "Procedure: " procedure "\n" "Arguments: " (%code (code.tuple args)))) -(def: lux//loop +(def lux//loop (-> Text Proc) (function (_ proc_name) (function (_ translate inputsS) @@ -82,13 +82,13 @@ (&.throw Wrong_Syntax (wrong_syntax proc_name inputsS))) ))) -(def: lux//again +(def lux//again (-> Text Proc) (function (_ proc_name) (function (_ translate inputsS) (loopT.translate_again translate inputsS)))) -(def: lux_procs +(def lux_procs Bundle (|> (dict.empty text.Hash<Text>) (install "is" (binary lux//is)) @@ -100,7 +100,7 @@ ... [[Bits]] (with_template [<name> <op>] - [(def: (<name> [subjectO paramO]) + [(def (<name> [subjectO paramO]) Binary (<op> paramO subjectO))] @@ -110,7 +110,7 @@ ) (with_template [<name> <op>] - [(def: (<name> [subjectO paramO]) + [(def (<name> [subjectO paramO]) Binary (<op> (runtimeT.int64_low paramO) subjectO))] @@ -119,7 +119,7 @@ [bit//logical_right_shifted runtimeT.bit//logical_right_shifted] ) -(def: bit_procs +(def bit_procs Bundle (<| (prefix "bit") (|> (dict.empty text.Hash<Text>) @@ -137,7 +137,7 @@ ("static" MAX_VALUE Double)) (with_template [<name> <const> <encode>] - [(def: (<name> _) + [(def (<name> _) Nullary (<encode> <const>))] @@ -147,7 +147,7 @@ ) (with_template [<name> <op>] - [(def: (<name> [subjectO paramO]) + [(def (<name> [subjectO paramO]) Binary (|> subjectO (<op> paramO)))] @@ -159,7 +159,7 @@ ) (with_template [<name> <op>] - [(def: (<name> [subjectO paramO]) + [(def (<name> [subjectO paramO]) Binary (<op> paramO subjectO))] @@ -176,7 +176,7 @@ ) (with_template [<name> <cmp>] - [(def: (<name> [subjectO paramO]) + [(def (<name> [subjectO paramO]) Binary (<cmp> paramO subjectO))] @@ -184,14 +184,14 @@ [int//< runtimeT.int//<] ) -(def: (apply1 func) +(def (apply1 func) (-> Expression (-> Expression Expression)) (function (_ value) (r.apply (list value) func))) -(def: int//char (|>> runtimeT.int64_low (apply1 (r.global "intToUtf8")))) +(def int//char (|>> runtimeT.int64_low (apply1 (r.global "intToUtf8")))) -(def: int_procs +(def int_procs Bundle (<| (prefix "int") (|> (dict.empty text.Hash<Text>) @@ -205,11 +205,11 @@ (install "to-frac" (unary runtimeT.int//float)) (install "char" (unary int//char))))) -(def: (frac//encode value) +(def (frac//encode value) (-> Expression Expression) (r.apply (list (r.string "%f") value) (r.global "sprintf"))) -(def: frac_procs +(def frac_procs Bundle (<| (prefix "frac") (|> (dict.empty text.Hash<Text>) @@ -228,23 +228,23 @@ (install "decode" (unary runtimeT.frac//decode))))) ... [[Text]] -(def: (text//concat [subjectO paramO]) +(def (text//concat [subjectO paramO]) Binary (r.apply (list subjectO paramO) (r.global "paste0"))) -(def: (text//char [subjectO paramO]) +(def (text//char [subjectO paramO]) Binary (runtimeT.text//char subjectO paramO)) -(def: (text//clip [subjectO paramO extraO]) +(def (text//clip [subjectO paramO extraO]) Trinary (runtimeT.text//clip subjectO paramO extraO)) -(def: (text//index [textO partO startO]) +(def (text//index [textO partO startO]) Trinary (runtimeT.text//index textO partO startO)) -(def: text_procs +(def text_procs Bundle (<| (prefix "text") (|> (dict.empty text.Hash<Text>) @@ -258,17 +258,17 @@ ))) ... [[IO]] -(def: (io//exit input) +(def (io//exit input) Unary (r.apply_kw (list) (list ["status" (runtimeT.int//float input)]) (r.global "quit"))) -(def: (void code) +(def (void code) (-> Expression Expression) (r.block (r.then code runtimeT.unit))) -(def: io_procs +(def io_procs Bundle (<| (prefix "io") (|> (dict.empty text.Hash<Text>) @@ -279,7 +279,7 @@ (runtimeT.io//current_time! runtimeT.unit))))))) ... [Bundles] -(def: .public procedures +(def .public procedures Bundle (<| (prefix "lux") (|> lux_procs diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux index d8f9eae7c..fcc48447c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux @@ -16,13 +16,13 @@ (// ["@" common])) ... (with_template [<name> <lua>] -... [(def: (<name> _) @.Nullary <lua>)] +... [(def (<name> _) @.Nullary <lua>)] ... [lua//nil "nil"] ... [lua//table "{}"] ... ) -... (def: (lua//global proc translate inputs) +... (def (lua//global proc translate inputs) ... (-> Text @.Proc) ... (case inputs ... (pattern (list [_ {.#Text name}])) @@ -33,7 +33,7 @@ ... _ ... (&.throw @.Wrong_Syntax (@.wrong_syntax proc inputs)))) -... (def: (lua//call proc translate inputs) +... (def (lua//call proc translate inputs) ... (-> Text @.Proc) ... (case inputs ... (pattern (list.partial functionS argsS+)) @@ -45,7 +45,7 @@ ... _ ... (&.throw @.Wrong_Syntax (@.wrong_syntax proc inputs)))) -... (def: lua_procs +... (def lua_procs ... @.Bundle ... (|> (dict.empty text.Hash<Text>) ... (@.install "nil" (@.nullary lua//nil)) @@ -53,7 +53,7 @@ ... (@.install "global" lua//global) ... (@.install "call" lua//call))) -... (def: (table//call proc translate inputs) +... (def (table//call proc translate inputs) ... (-> Text @.Proc) ... (case inputs ... (pattern (list.partial tableS [_ {.#Text field}] argsS+)) @@ -65,15 +65,15 @@ ... _ ... (&.throw @.Wrong_Syntax (@.wrong_syntax proc inputs)))) -... (def: (table//get [fieldO tableO]) +... (def (table//get [fieldO tableO]) ... @.Binary ... (runtimeT.lua//get tableO fieldO)) -... (def: (table//set [fieldO valueO tableO]) +... (def (table//set [fieldO valueO tableO]) ... @.Trinary ... (runtimeT.lua//set tableO fieldO valueO)) -... (def: table_procs +... (def table_procs ... @.Bundle ... (<| (@.prefix "table") ... (|> (dict.empty text.Hash<Text>) @@ -81,7 +81,7 @@ ... (@.install "get" (@.binary table//get)) ... (@.install "set" (@.trinary table//set))))) -(def: .public procedures +(def .public procedures @.Bundle (<| (@.prefix "lua") (dict.empty text.Hash<Text>) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/reference.lux index 5a37d97b7..4cc1f49ba 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(def: .public system +(def .public system (System Expression) (implementation - (def: constant _.var) - (def: variable _.var))) + (def constant _.var) + (def variable _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux index 20d9475a1..ff87c9113 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux @@ -41,7 +41,7 @@ [archive (.only Output Archive) ["[0]" artifact (.only Registry)]]]]]]) -(def: module_id +(def module_id 0) (with_template [<name> <base>] @@ -57,15 +57,15 @@ (type: .public (Generator i) (-> Phase Archive i (Operation Expression))) -(def: .public unit +(def .public unit Expression (_.string /////synthesis.unit)) -(def: full_32 (hex "FFFFFFFF")) -(def: half_32 (hex "7FFFFFFF")) -(def: post_32 (hex "100000000")) +(def full_32 (hex "FFFFFFFF")) +(def half_32 (hex "7FFFFFFF")) +(def post_32 (hex "100000000")) -(def: (cap_32 input) +(def (cap_32 input) (-> Nat Int) (cond (n.> full_32 input) (|> input (i64.and full_32) cap_32) @@ -76,7 +76,7 @@ ... else (.int input))) -(def: .public with_vars +(def .public with_vars (syntax (_ [vars (<code>.tuple (<>.some <code>.local)) body <code>.any]) (do [! meta.monad] @@ -89,7 +89,7 @@ list.together))] (~ body)))))))) -(def: runtime: +(def runtime: (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -102,11 +102,11 @@ (case declaration {.#Left name} (let [g!name (code.local name)] - (in (list (` (def: .public (~ g!name) + (in (list (` (def .public (~ g!name) _.SVar (~ runtime_name))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) _.Expression (_.set! (~ runtime_name) (~ code))))))) @@ -115,22 +115,22 @@ inputsC (list#each code.local inputs) inputs_typesC (list#each (function.constant (` _.Expression)) inputs)] - (in (list (` (def: .public ((~ g!name) (~+ inputsC)) + (in (list (` (def .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) _.Expression) (_.apply (list (~+ inputsC)) (~ runtime_name)))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) _.Expression (..with_vars [(~+ inputsC)] (_.set! (~ runtime_name) (_.function (list (~+ inputsC)) (~ code))))))))))))))) -(def: .public variant_tag_field "luxVT") -(def: .public variant_flag_field "luxVF") -(def: .public variant_value_field "luxVV") +(def .public variant_tag_field "luxVT") +(def .public variant_flag_field "luxVF") +(def .public variant_value_field "luxVV") -(def: .public (flag value) +(def .public (flag value) (-> Bit Expression) (if value (_.string "") @@ -141,29 +141,29 @@ [..variant_flag_field last?] [..variant_value_field value]))) -(def: .public (variant tag last? value) +(def .public (variant tag last? value) (-> Nat Bit Expression Expression) (adt::variant (_.int (.int tag)) (flag last?) value)) -(def: .public none +(def .public none Expression (variant 0 #0 ..unit)) -(def: .public some +(def .public some (-> Expression Expression) (variant 1 #1)) -(def: .public left +(def .public left (-> Expression Expression) (variant 0 #0)) -(def: .public right +(def .public right (-> Expression Expression) (variant 1 #1)) -(def: high_shift (_.bit_shl (_.int +32))) +(def high_shift (_.bit_shl (_.int +32))) (with_template [<name> <power>] [(runtime: <name> (|> (_.as::integer (_.int +2)) (_.** (_.as::integer (_.int <power>)))))] @@ -172,12 +172,12 @@ [f2^63 +63] ) -(def: (as_double value) +(def (as_double value) (-> Expression Expression) (_.apply (list value) (_.var "as.double"))) -(def: .public i64_high_field "luxIH") -(def: .public i64_low_field "luxIL") +(def .public i64_high_field "luxIH") +(def .public i64_low_field "luxIL") (runtime: (i64::unsigned_low input) (with_vars [low] @@ -199,21 +199,21 @@ (_.named_list (list [..i64_high_field (_.as::integer high)] [..i64_low_field (_.as::integer low)]))) -(def: high_32 +(def high_32 (-> Nat Nat) (i64.right_shifted 32)) -(def: low_32 +(def low_32 (-> Nat Nat) (|>> (i64.and (hex "FFFFFFFF")))) -(def: .public (i64 value) +(def .public (i64 value) (-> Int Expression) (let [value (.nat value)] (i64::new (|> value ..high_32 ..cap_32 _.int) (|> value ..low_32 ..cap_32 _.int)))) -(def: .public (lux_i64 high low) +(def .public (lux_i64 high low) (-> Int Int Int) (|> high (i64.left_shifted 32) @@ -229,8 +229,8 @@ [i64::max i#top] ) -(def: .public i64_high (_.item (_.string ..i64_high_field))) -(def: .public i64_low (_.item (_.string ..i64_low_field))) +(def .public i64_high (_.item (_.string ..i64_high_field))) +(def .public i64_low (_.item (_.string ..i64_low_field))) (runtime: (i64::not input) (i64::new (|> input i64_high _.bit_not) @@ -380,11 +380,11 @@ (new_half x16 x00))))) ))))))) -(def: (limit_shift! shift) +(def (limit_shift! shift) (-> SVar Expression) (_.set! shift (|> shift (_.bit_and (_.as::integer (_.int +63)))))) -(def: (no_shift_clause shift input) +(def (no_shift_clause shift input) (-> SVar SVar [Expression Expression]) [(|> shift (_.= (_.int +0))) input]) @@ -539,14 +539,14 @@ (_.set! inputs (..some (_.list (list value inputs))))) inputs))) -(def: runtime::lux +(def runtime::lux Expression (all _.then @lux::try @lux::program_args )) -(def: current_time_float +(def current_time_float Expression (let [raw_time (_.apply (list) (_.var "Sys.time"))] (_.apply (list raw_time) (_.var "as.numeric")))) @@ -556,25 +556,25 @@ (_.* (_.float +1,000.0)) i64::of_float)) -(def: runtime::io +(def runtime::io Expression (all _.then @io::current_time! )) -(def: minimum_index_length +(def minimum_index_length (-> SVar Expression) (|>> (_.+ (_.int +1)))) -(def: (product_element product index) +(def (product_element product index) (-> Expression Expression Expression) (|> product (_.item (|> index (_.+ (_.int +1)))))) -(def: (product_tail product) +(def (product_tail product) (-> SVar Expression) (|> product (_.item (_.length product)))) -(def: (updated_index min_length product) +(def (updated_index min_length product) (-> Expression Expression Expression) (|> min_length (_.- (_.length product)))) @@ -629,7 +629,7 @@ no_match))) -(def: runtime::adt +(def runtime::adt Expression (all _.then @tuple::left @@ -672,7 +672,7 @@ (let [low (|> (i64_high input) (_.bit_ushr (|> shift (_.- (_.int +32)))))] (i64::new (_.int +0) low))))) -(def: runtime::i64 +(def runtime::i64 Expression (all _.then @f2^32 @@ -715,22 +715,22 @@ ..none (..some output))))) -(def: runtime::frac +(def runtime::frac Expression (all _.then @frac::decode )) -(def: ++ +(def ++ (-> Expression Expression) (|>> (_.+ (_.int +1)))) -(def: (text_clip start end text) +(def (text_clip start end text) (-> Expression Expression Expression Expression) (_.apply (list text start end) (_.var "substr"))) -(def: (text_length text) +(def (text_length text) (-> Expression Expression) (_.apply (list text) (_.var "nchar"))) @@ -763,7 +763,7 @@ (..some (text_clip (++ minimum) (++ to) text)) ..none)))) -(def: (char_at idx text) +(def (char_at idx text) (-> Expression Expression Expression) (_.apply (list (text_clip idx idx text)) (_.var "utf8ToInt"))) @@ -775,7 +775,7 @@ (..some (i64::of_float (char_at idx text)))) ..none)) -(def: runtime::text +(def runtime::text Expression (all _.then @text::index @@ -783,7 +783,7 @@ @text::char )) -(def: (check_index_out_of_bounds array idx body) +(def (check_index_out_of_bounds array idx body) (-> Expression Expression Expression Expression) (_.if (_.> (_.length array) idx) (_.stop (_.string "Array index out of bounds!")) @@ -813,7 +813,7 @@ (_.set_item! (_.+ (_.int +1) idx) value array) array))) -(def: runtime::array +(def runtime::array Expression (all _.then @array::new @@ -821,7 +821,7 @@ @array::put )) -(def: runtime +(def runtime Expression (all _.then runtime::lux @@ -833,7 +833,7 @@ runtime::io )) -(def: .public generate +(def .public generate (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux index f41b3268d..5e376dd1f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux @@ -17,7 +17,7 @@ ["//[1]" /// ["[1][0]" phase (.open: "[1]#[0]" monad)]]]]) -(def: .public (tuple expression archive elemsS+) +(def .public (tuple expression archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ {.#End} @@ -31,7 +31,7 @@ (monad.each ///////phase.monad (expression archive)) (///////phase#each _.list)))) -(def: .public (variant expression archive [lefts right? valueS]) +(def .public (variant expression archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux index 93183d209..5ee5957eb 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux @@ -19,7 +19,7 @@ ... This universe constant is for languages where one can't just turn all compiled definitions ... into the local variables of some scoping function. -(def: .public universe +(def .public universe (for @.lua ... In the case of Lua, there is a limit of 200 locals in a function's scope. (not ("lua script universe")) @@ -37,7 +37,7 @@ (not ("scheme script universe")) #0)) -(def: universe_label +(def universe_label Text (with_expansions [<label> (format "u" (%.nat (if ..universe 1 0)))] (for @.lua <label> @@ -46,7 +46,7 @@ @.scheme <label> ""))) -(def: .public (artifact [module artifact]) +(def .public (artifact [module artifact]) (-> unit.ID Text) (format "l" (%.nat version.latest) ..universe_label @@ -60,7 +60,7 @@ (is (-> Text expression) variable'))) -(def: .public (constant system archive name) +(def .public (constant system archive name) (All (_ anchor expression directive) (-> (System expression) Archive Symbol (////generation.Operation anchor expression directive expression))) @@ -68,7 +68,7 @@ (////generation.remember archive name))) (with_template [<sigil> <name>] - [(def: .public (<name> system) + [(def .public (<name> system) (All (_ expression) (-> (System expression) (-> Register expression))) @@ -78,7 +78,7 @@ ["l" local] ) -(def: .public (variable system variable) +(def .public (variable system variable) (All (_ expression) (-> (System expression) Variable expression)) (case variable @@ -88,7 +88,7 @@ {variable.#Foreign register} (..foreign system register))) -(def: .public (reference system archive reference) +(def .public (reference system archive reference) (All (_ anchor expression directive) (-> (System expression) Archive Reference (////generation.Operation anchor expression directive expression))) (case reference diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux index 6a11d8996..8cc7466cc 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux @@ -34,7 +34,7 @@ (exception: .public cannot_recur_as_an_expression) -(def: (expression archive synthesis) +(def (expression archive synthesis) Phase (case synthesis (^.with_template [<tag> <generator>] @@ -74,6 +74,6 @@ {////synthesis.#Extension extension} (///extension.apply archive expression extension))) -(def: .public generate +(def .public generate Phase ..expression) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux index 3ddd687e1..bd9e27049 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux @@ -40,19 +40,19 @@ [meta [archive (.only Archive)]]]]]]]) -(def: .public (symbol prefix) +(def .public (symbol prefix) (-> Text (Operation LVar)) (///////phase#each (|>> %.nat (format prefix) _.local) /////generation.next)) -(def: .public register +(def .public register (-> Register LVar) (|>> (///reference.local //reference.system) as_expected)) -(def: .public capture +(def .public capture (-> Register LVar) (|>> (///reference.foreign //reference.system) as_expected)) -(def: .public (exec expression archive [this that]) +(def .public (exec expression archive [this that]) (Generator [Synthesis Synthesis]) (do ///////phase.monad [this (expression archive this) @@ -60,7 +60,7 @@ (in (|> (_.array (list this that)) (_.item (_.int +1)))))) -(def: .public (exec! statement expression archive [this that]) +(def .public (exec! statement expression archive [this that]) (Generator! [Synthesis Synthesis]) (do ///////phase.monad [this (expression archive this) @@ -70,7 +70,7 @@ that )))) -(def: .public (let expression archive [valueS register bodyS]) +(def .public (let expression archive [valueS register bodyS]) (Generator [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -81,7 +81,7 @@ [(list (..register register))] (_.lambda {.#None}) (_.apply_lambda (list valueO)))))) -(def: .public (let! statement expression archive [valueS register bodyS]) +(def .public (let! statement expression archive [valueS register bodyS]) (Generator! [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -90,7 +90,7 @@ (_.set (list (..register register)) valueO) bodyO)))) -(def: .public (if expression archive [testS thenS elseS]) +(def .public (if expression archive [testS thenS elseS]) (Generator [Synthesis Synthesis Synthesis]) (do ///////phase.monad [testO (expression archive testS) @@ -98,7 +98,7 @@ elseO (expression archive elseS)] (in (_.? testO thenO elseO)))) -(def: .public (if! statement expression archive [testS thenS elseS]) +(def .public (if! statement expression archive [testS thenS elseS]) (Generator! [Synthesis Synthesis Synthesis]) (do ///////phase.monad [test! (expression archive testS) @@ -108,7 +108,7 @@ then! else!)))) -(def: .public (get expression archive [pathP valueS]) +(def .public (get expression archive [pathP valueS]) (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueO (expression archive valueS)] @@ -120,38 +120,38 @@ valueO (list.reversed pathP))))) -(def: @savepoint (_.local "lux_pm_savepoint")) -(def: @cursor (_.local "lux_pm_cursor")) -(def: @temp (_.local "lux_pm_temp")) +(def @savepoint (_.local "lux_pm_savepoint")) +(def @cursor (_.local "lux_pm_cursor")) +(def @temp (_.local "lux_pm_temp")) -(def: (push! value) +(def (push! value) (-> Expression Statement) (_.statement (|> @cursor (_.do "push" (list value) {.#None})))) -(def: peek_and_pop +(def peek_and_pop Expression (|> @cursor (_.do "pop" (list) {.#None}))) -(def: pop! +(def pop! Statement (_.statement ..peek_and_pop)) -(def: peek +(def peek Expression (_.item (_.int -1) @cursor)) -(def: save! +(def save! Statement (.let [cursor (_.array_range (_.int +0) (_.int -1) @cursor)] (_.statement (|> @savepoint (_.do "push" (list cursor) {.#None}))))) -(def: restore! +(def restore! Statement (_.set (list @cursor) (|> @savepoint (_.do "pop" (list) {.#None})))) -(def: fail! _.break) +(def fail! _.break) -(def: (multi_pop! pops) +(def (multi_pop! pops) (-> Nat Statement) (_.statement (_.do "slice!" (list (_.int (i.* -1 (.int pops))) @@ -160,7 +160,7 @@ @cursor))) (with_template [<name> <flag>] - [(def: (<name> simple? idx) + [(def (<name> simple? idx) (-> Bit Nat Statement) (all _.then (_.set (list @temp) (//runtime.sum//get ..peek <flag> @@ -176,7 +176,7 @@ [right_choice //runtime.unit] ) -(def: (with_looping in_closure? g!once g!continue? body!) +(def (with_looping in_closure? g!once g!continue? body!) (-> Bit LVar LVar Statement Statement) (.if in_closure? (all _.then @@ -196,7 +196,7 @@ (_.when g!continue? _.next)))) -(def: (alternation in_closure? g!once g!continue? pre! post!) +(def (alternation in_closure? g!once g!continue? pre! post!) (-> Bit LVar LVar Statement Statement Statement) (all _.then (with_looping in_closure? g!once g!continue? @@ -206,7 +206,7 @@ ..restore! post!)) -(def: (primitive_pattern_matching again pathP) +(def (primitive_pattern_matching again pathP) (-> (-> Path (Operation Statement)) (-> Path (Operation (Maybe Statement)))) (.case pathP @@ -247,7 +247,7 @@ _ (at ///////phase.monad in {.#None}))) -(def: (pattern_matching' in_closure? statement expression archive) +(def (pattern_matching' in_closure? statement expression archive) (-> Bit (Generator! Path)) (function (again pathP) (do ///////phase.monad @@ -352,7 +352,7 @@ g!continue? (..symbol "continue")] (in (..alternation in_closure? g!once g!continue? pre! post!)))))))) -(def: (pattern_matching in_closure? statement expression archive pathP) +(def (pattern_matching in_closure? statement expression archive pathP) (-> Bit (Generator! Path)) (do ///////phase.monad [pattern_matching! (pattern_matching' in_closure? statement expression archive pathP) @@ -363,7 +363,7 @@ pattern_matching!) (_.statement (_.raise (_.string case.pattern_matching_error))))))) -(def: .public (case! in_closure? statement expression archive [valueS pathP]) +(def .public (case! in_closure? statement expression archive [valueS pathP]) (-> Bit (Generator! [Synthesis Path])) (do ///////phase.monad [stack_init (expression archive valueS) @@ -374,7 +374,7 @@ pattern_matching! )))) -(def: .public (case statement expression archive case) +(def .public (case statement expression archive case) (-> Phase! (Generator [Synthesis Path])) (|> case (case! true statement expression archive) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux index 2ebe8edbb..67fd28d7b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux @@ -32,18 +32,18 @@ [dependency ["[1]/[0]" artifact]]]]]]]]) -(def: .public (apply expression archive [functionS argsS+]) +(def .public (apply expression archive [functionS argsS+]) (Generator (Reification Synthesis)) (do [! ///////phase.monad] [functionO (expression archive functionS) argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply_lambda argsO+ functionO)))) -(def: .public capture +(def .public capture (-> Register LVar) (|>> (///reference.foreign //reference.system) as_expected)) -(def: (with_closure inits self function_definition) +(def (with_closure inits self function_definition) (-> (List Expression) Text Expression [Statement Expression]) (let [@self (_.global self)] (case inits @@ -61,10 +61,10 @@ (_.return @self)))])) (_.apply_lambda inits @self)]))) -(def: input +(def input (|>> ++ //case.register)) -(def: .public (function statement expression archive [environment arity bodyS]) +(def .public (function statement expression archive [environment arity bodyS]) (-> Phase! (Generator (Abstraction Synthesis))) (do [! ///////phase.monad] [dependencies (cache/artifact.dependencies archive bodyS) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux index 930206963..693f5a46d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux @@ -31,7 +31,7 @@ [reference ["[1][0]" variable (.only Register)]]]]]]]) -(def: (setup offset bindings body) +(def (setup offset bindings body) (-> Register (List Expression) Statement Statement) (let [variables (|> bindings list.enumeration @@ -40,14 +40,14 @@ (_.set variables (_.multi bindings)) body))) -(def: symbol +(def symbol (_.symbol "lux_continue")) -(def: .public with_scope +(def .public with_scope (-> Statement Statement) (_.while (_.bool true))) -(def: .public (scope! statement expression archive [start initsS+ bodyS]) +(def .public (scope! statement expression archive [start initsS+ bodyS]) (Generator! (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop @@ -64,7 +64,7 @@ ..with_scope body!))))) -(def: .public (scope statement expression archive [start initsS+ bodyS]) +(def .public (scope statement expression archive [start initsS+ bodyS]) (-> Phase! (Generator (Scope Synthesis))) (case initsS+ ... function/false/non-independent loop @@ -79,7 +79,7 @@ [(list)] (_.lambda {.#None}) (_.apply_lambda (list))))))) -(def: .public (again! statement expression archive argsS+) +(def .public (again! statement expression archive argsS+) (Generator! (List Synthesis)) (do [! ///////phase.monad] [offset /////generation.anchor diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/primitive.lux index 162936972..eebaa01d5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/primitive.lux @@ -5,7 +5,7 @@ ["_" ruby (.only Literal)]]]]) (with_template [<type> <name> <implementation>] - [(def: .public <name> + [(def .public <name> (-> <type> Literal) <implementation>)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/reference.lux index b464719fc..b29560a21 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(def: .public system +(def .public system (System Expression) (implementation - (def: constant' _.global) - (def: variable' _.local))) + (def constant' _.global) + (def variable' _.local))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux index 9552d15ac..7d5b9d6b4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux @@ -59,16 +59,16 @@ (type: .public (Generator! i) (-> Phase! Phase Archive i (Operation Statement))) -(def: .public unit +(def .public unit (_.string /////synthesis.unit)) -(def: (flag value) +(def (flag value) (-> Bit Literal) (if value ..unit _.nil)) -(def: .public with_vars +(def .public with_vars (syntax (_ [vars (<code>.tuple (<>.some <code>.local)) body <code>.any]) (do [! meta.monad] @@ -81,14 +81,14 @@ list.together))] (~ body)))))))) -(def: module_id +(def module_id 0) -(def: $Numeric +(def $Numeric _.CVar (_.manual "Numeric")) -(def: mruby? +(def mruby? _.Expression (_.and (|> $Numeric (_.do "method_defined?" (list (_.string "remainder")) {.#None}) @@ -96,14 +96,14 @@ (|> $Numeric (_.do "method_defined?" (list (_.string "remainder_of_divide")) {.#None})))) -(def: normal_ruby? +(def normal_ruby? _.Expression (_.not ..mruby?) ... (|> (_.local "Object") ... (_.do "const_defined?" (list (_.string "Encoding")) {.#None})) ) -(def: runtime: +(def runtime: (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -118,8 +118,8 @@ (let [runtime (code.local (///reference.artifact [..module_id runtime_id])) runtime_name (` (_.constant (~ (code.text (%.code runtime))))) g!name (code.local name)] - (in (list (` (def: .public (~ g!name) _.CVar (~ runtime_name))) - (` (def: (~ (code.local (format "@" name))) + (in (list (` (def .public (~ g!name) _.CVar (~ runtime_name))) + (` (def (~ (code.local (format "@" name))) Statement (~ (list#mix (function (_ [when then] else) (` (_.if (~ when) @@ -136,12 +136,12 @@ inputsC (list#each code.local inputs) inputs_typesC (list#each (function.constant (` _.Expression)) inputs)] - (in (list (` (def: .public ((~ g!name) (~+ inputsC)) + (in (list (` (def .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) Computation) (_.apply (list (~+ inputsC)) {.#None} (~ runtime_name)))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) Statement (..with_vars [(~+ inputsC)] (~ (list#mix (function (_ [when then] else) @@ -153,10 +153,10 @@ (~ default_implementation))) conditional_implementations)))))))))))))) -(def: tuple_size +(def tuple_size (_.the "length")) -(def: last_index +(def last_index (|>> ..tuple_size (_.- (_.int +1)))) (with_expansions [<recur> (these (all _.then @@ -187,32 +187,32 @@ (_.return (_.array_range right_index (..tuple_size tuple) tuple))) ))))) -(def: .public variant_tag_field "_lux_tag") -(def: .public variant_flag_field "_lux_flag") -(def: .public variant_value_field "_lux_value") +(def .public variant_tag_field "_lux_tag") +(def .public variant_flag_field "_lux_flag") +(def .public variant_value_field "_lux_value") (runtime: (sum//make tag last? value) (_.return (_.hash (list [(_.string ..variant_tag_field) tag] [(_.string ..variant_flag_field) last?] [(_.string ..variant_value_field) value])))) -(def: .public (variant tag last? value) +(def .public (variant tag last? value) (-> Nat Bit Expression Computation) (sum//make (_.int (.int tag)) (..flag last?) value)) -(def: .public left +(def .public left (-> Expression Computation) (..variant 0 #0)) -(def: .public right +(def .public right (-> Expression Computation) (..variant 0 #1)) -(def: .public none +(def .public none Computation (..left ..unit)) -(def: .public some +(def .public some (-> Expression Computation) ..right) @@ -243,7 +243,7 @@ actual::value))) mismatch!))) -(def: runtime//adt +(def runtime//adt Statement (all _.then @tuple//left @@ -268,17 +268,17 @@ (_.set (list tail) (..some (_.array (list head tail))))) (_.return tail)))) -(def: runtime//lux +(def runtime//lux Statement (all _.then @lux//try @lux//program_args )) -(def: i64::+limit (_.manual "+0x7FFFFFFFFFFFFFFF")) -(def: i64::-limit (_.manual "-0x8000000000000000")) -(def: i64::+cap (_.manual "+0x8000000000000000")) -(def: i64::-cap (_.manual "-0x8000000000000001")) +(def i64::+limit (_.manual "+0x7FFFFFFFFFFFFFFF")) +(def i64::-limit (_.manual "-0x8000000000000000")) +(def i64::+cap (_.manual "+0x8000000000000000")) +(def i64::-cap (_.manual "-0x8000000000000001")) (runtime: i64::+iteration (_.manual "(+1<<64)")) (runtime: i64::-iteration (_.manual "(-1<<64)")) @@ -299,21 +299,21 @@ )) (_.return input))))) -(def: i32::low +(def i32::low (|>> (_.bit_and (_.manual "+0xFFFFFFFF")))) -(def: i32::high +(def i32::high (|>> (_.bit_shr (_.int +32)) ..i32::low)) -(def: i32::positive? +(def i32::positive? (|>> (_.bit_and (_.manual "+0x80000000")) (_.= (_.int +0)))) -(def: i32::up +(def i32::up (_.bit_shl (_.int +32))) -(def: i64 +(def i64 (template (_ @high @low) [(|> (_.? (i32::positive? @high) @high @@ -323,7 +323,7 @@ i32::up (_.bit_or @low))])) -(def: as_nat +(def as_nat (_.% ..i64::+iteration)) (with_template [<runtime> <host>] @@ -340,16 +340,16 @@ [i64::xor _.bit_xor] ) -(def: (cap_shift! shift) +(def (cap_shift! shift) (-> LVar Statement) (_.set (list shift) (|> shift (_.bit_and (_.int +63))))) -(def: (handle_no_shift! shift input) +(def (handle_no_shift! shift input) (-> LVar LVar (-> Statement Statement)) (_.if (|> shift (_.= (_.int +0))) (_.return input))) -(def: small_shift? +(def small_shift? (-> LVar Expression) (|>> (_.< (_.int +32)))) @@ -419,10 +419,10 @@ (_.return (..i64 high (i32::low low))) ))) -(def: i64::min +(def i64::min (_.manual "-0x8000000000000000")) -(def: (i64::opposite value) +(def (i64::opposite value) (_.? (_.= i64::min value) i64::min (i64::+ (_.int +1) (_.bit_not value)))) @@ -431,13 +431,13 @@ [..normal_ruby? (_.return (i64::i64 (_.- parameter subject)))] (_.return (i64::+ (i64::opposite parameter) subject))) -(def: i16::high +(def i16::high (_.bit_shr (_.int +16))) -(def: i16::low +(def i16::low (_.bit_and (_.manual "+0xFFFF"))) -(def: i16::up +(def i16::up (_.bit_shl (_.int +16))) (runtime: (i64::* parameter subject) @@ -494,7 +494,7 @@ [..mruby? (_.return (_.do "chr" (list) {.#None} subject))] (_.return (_.do "chr" (list (_.string "UTF-8")) {.#None} subject))) -(def: runtime//i64 +(def runtime//i64 Statement (all _.then @i64::+iteration @@ -525,7 +525,7 @@ (_.return (..some @temp)) (_.return ..none))))) -(def: runtime//f64 +(def runtime//f64 Statement (all _.then @f64//decode @@ -539,7 +539,7 @@ (_.return ..none) (_.return (..some idx)))))) -(def: (within? top value) +(def (within? top value) (-> Expression Expression Computation) (_.and (|> value (_.>= (_.int +0))) (|> value (_.< top)))) @@ -554,7 +554,7 @@ (_.return (|> text (_.array_range idx idx) (_.do "ord" (list) {.#None}))) (_.statement (_.raise (_.string "[Lux Error] Cannot get char from text."))))) -(def: runtime//text +(def runtime//text Statement (all _.then @text//index @@ -567,13 +567,13 @@ (_.set (list (_.item idx array)) value) (_.return array))) -(def: runtime//array +(def runtime//array Statement (all _.then @array//write )) -(def: runtime +(def runtime Statement (all _.then (_.when ..mruby? @@ -592,7 +592,7 @@ runtime//array )) -(def: .public generate +(def .public generate (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux index 791f06d76..3cdbd9591 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux @@ -15,7 +15,7 @@ ["//[1]" /// ["[1][0]" phase (.open: "[1]#[0]" monad)]]]]) -(def: .public (tuple generate archive elemsS+) +(def .public (tuple generate archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ {.#End} @@ -29,7 +29,7 @@ (monad.each ///////phase.monad (generate archive)) (///////phase#each _.array)))) -(def: .public (variant generate archive [lefts right? valueS]) +(def .public (variant generate archive [lefts right? valueS]) (Generator (Variant Synthesis)) (///////phase#each (//runtime.variant lefts right?) (generate archive valueS))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme.lux index 2702efa5e..b6a3a5842 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme.lux @@ -27,7 +27,7 @@ [reference (.only) [variable (.only)]]]]]]]) -(def: .public (generate archive synthesis) +(def .public (generate archive synthesis) Phase (case synthesis (^.with_template [<tag> <generator>] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux index 7cbfc7bfe..f492d94df 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux @@ -37,15 +37,15 @@ [meta [archive (.only Archive)]]]]]]]) -(def: .public register +(def .public register (-> Register Var) (|>> (///reference.local //reference.system) as_expected)) -(def: .public capture +(def .public capture (-> Register Var) (|>> (///reference.foreign //reference.system) as_expected)) -(def: .public (let expression archive [valueS register bodyS]) +(def .public (let expression archive [valueS register bodyS]) (Generator [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -53,7 +53,7 @@ (in (_.let (list [(..register register) valueO]) bodyO)))) -(def: .public (if expression archive [testS thenS elseS]) +(def .public (if expression archive [testS thenS elseS]) (Generator [Synthesis Synthesis Synthesis]) (do ///////phase.monad [testO (expression archive testS) @@ -61,7 +61,7 @@ elseO (expression archive elseS)] (in (_.if testO thenO elseO)))) -(def: .public (get expression archive [pathP valueS]) +(def .public (get expression archive [pathP valueS]) (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueO (expression archive valueS)] @@ -76,48 +76,48 @@ valueO (list.reversed pathP))))) -(def: @savepoint (_.var "lux_pm_cursor_savepoint")) -(def: @cursor (_.var "lux_pm_cursor")) -(def: @temp (_.var "lux_pm_temp")) -(def: @alt_error (_.var "alt_error")) +(def @savepoint (_.var "lux_pm_cursor_savepoint")) +(def @cursor (_.var "lux_pm_cursor")) +(def @temp (_.var "lux_pm_temp")) +(def @alt_error (_.var "alt_error")) -(def: (push! value var) +(def (push! value var) (-> Expression Var Computation) (_.set! var (_.cons/2 value var))) -(def: (push_cursor! value) +(def (push_cursor! value) (-> Expression Computation) (push! value @cursor)) -(def: (pop! var) +(def (pop! var) (-> Var Computation) (_.set! var (_.cdr/1 var))) -(def: save_cursor! +(def save_cursor! Computation (push! @cursor @savepoint)) -(def: restore_cursor! +(def restore_cursor! Computation (_.begin (list (_.set! @cursor (_.car/1 @savepoint)) (_.set! @savepoint (_.cdr/1 @savepoint))))) -(def: peek +(def peek Computation (_.car/1 @cursor)) -(def: pop_cursor! +(def pop_cursor! Computation (pop! @cursor)) -(def: pm_error +(def pm_error (_.string (template.with_locals [pm_error] (template.text [pm_error])))) -(def: fail! +(def fail! (_.raise/1 pm_error)) -(def: (try_pm on_failure happy_path) +(def (try_pm on_failure happy_path) (-> Expression Expression Computation) (_.guard @alt_error (list [(_.and (list (_.string?/1 @alt_error) @@ -126,7 +126,7 @@ {.#None} happy_path)) -(def: (pattern_matching' expression archive) +(def (pattern_matching' expression archive) (Generator Path) (function (again pathP) (.case pathP @@ -209,13 +209,13 @@ leftO))))) ))) -(def: (pattern_matching expression archive pathP) +(def (pattern_matching expression archive pathP) (Generator Path) (at ///////phase.monad each (try_pm (_.raise/1 (_.string "Invalid expression for pattern-matching."))) (pattern_matching' expression archive pathP))) -(def: .public (case expression archive [valueS pathP]) +(def .public (case expression archive [valueS pathP]) (Generator [Synthesis Path]) (do [! ///////phase.monad] [valueO (expression archive valueS)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension.lux index 90acc3cef..eac649c9c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension.lux @@ -9,6 +9,6 @@ [/ ["[0]" common]]) -(def: .public bundle +(def .public bundle Bundle common.bundle) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux index 2ed9653b5..815a712b3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux @@ -28,14 +28,14 @@ ["[1]/" // ["[1][0]" synthesis (.only Synthesis)]]]]) -(def: bundle::lux +(def bundle::lux Bundle (|> bundle.empty (bundle.install "is?" (binary (product.uncurried _.eq?/2))) (bundle.install "try" (unary ///runtime.lux//try)))) (with_template [<name> <op>] - [(def: (<name> [subjectO paramO]) + [(def (<name> [subjectO paramO]) Binary (<op> paramO subjectO))] @@ -44,22 +44,22 @@ [i64::xor _.bit_xor/2] ) -(def: (i64::left_shifted [subjectO paramO]) +(def (i64::left_shifted [subjectO paramO]) Binary (_.arithmetic_shift/2 (_.remainder/2 (_.int +64) paramO) subjectO)) -(def: (i64::arithmetic_right_shifted [subjectO paramO]) +(def (i64::arithmetic_right_shifted [subjectO paramO]) Binary (_.arithmetic_shift/2 (|> paramO (_.remainder/2 (_.int +64)) (_.*/2 (_.int -1))) subjectO)) -(def: (i64::logical_right_shifted [subjectO paramO]) +(def (i64::logical_right_shifted [subjectO paramO]) Binary (///runtime.i64//logical_right_shifted (_.remainder/2 (_.int +64) paramO) subjectO)) (with_template [<name> <op>] - [(def: (<name> [subjectO paramO]) + [(def (<name> [subjectO paramO]) Binary (|> subjectO (<op> paramO)))] @@ -71,7 +71,7 @@ ) (with_template [<name> <op>] - [(def: (<name> [subjectO paramO]) + [(def (<name> [subjectO paramO]) Binary (<op> paramO subjectO))] @@ -88,7 +88,7 @@ ) (with_template [<name> <cmp>] - [(def: (<name> [subjectO paramO]) + [(def (<name> [subjectO paramO]) Binary (<cmp> paramO subjectO))] @@ -96,9 +96,9 @@ [i64::< _.</2] ) -(def: i64::char (|>> _.integer->char/1 _.string/1)) +(def i64::char (|>> _.integer->char/1 _.string/1)) -(def: bundle::i64 +(def bundle::i64 Bundle (<| (bundle.prefix "i64") (|> bundle.empty @@ -118,7 +118,7 @@ (bundle.install "f64" (unary (|>> (_.//2 (_.float +1.0))))) (bundle.install "char" (unary i64::char))))) -(def: bundle::f64 +(def bundle::f64 Bundle (<| (bundle.prefix "f64") (|> bundle.empty @@ -133,15 +133,15 @@ (bundle.install "encode" (unary _.number->string/1)) (bundle.install "decode" (unary ///runtime.frac//decode))))) -(def: (text::char [subjectO paramO]) +(def (text::char [subjectO paramO]) Binary (_.string/1 (_.string_ref/2 subjectO paramO))) -(def: (text::clip [subjectO startO endO]) +(def (text::clip [subjectO startO endO]) Trinary (_.substring/3 subjectO startO endO)) -(def: bundle::text +(def bundle::text Bundle (<| (bundle.prefix "text") (|> bundle.empty @@ -152,16 +152,16 @@ (bundle.install "char" (binary text::char)) (bundle.install "clip" (trinary text::clip))))) -(def: (io::log input) +(def (io::log input) Unary (_.begin (list (_.display/1 input) _.newline/0))) -(def: (void code) +(def (void code) (-> Expression Computation) (_.begin (list code (_.string //////synthesis.unit)))) -(def: bundle::io +(def bundle::io Bundle (<| (bundle.prefix "io") (|> bundle.empty @@ -170,7 +170,7 @@ (bundle.install "exit" (unary _.exit/1)) (bundle.install "current-time" (nullary (function (_ _) (///runtime.io//current_time (_.string //////synthesis.unit)))))))) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "lux") (|> bundle::lux diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux index 47297cb47..8f07bec50 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux @@ -29,18 +29,18 @@ [reference [variable (.only Register Variable)]]]]]]) -(def: .public (apply expression archive [functionS argsS+]) +(def .public (apply expression archive [functionS argsS+]) (Generator (Application Synthesis)) (do [! ///////phase.monad] [functionO (expression archive functionS) argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply argsO+ functionO)))) -(def: capture +(def capture (-> Register Var) (|>> (///reference.foreign //reference.system) as_expected)) -(def: (with_closure inits function_definition) +(def (with_closure inits function_definition) (-> (List Expression) Computation (Operation Computation)) (///////phase#in (case inits @@ -54,13 +54,13 @@ {.#None}]) (_.apply inits))))) -(def: @curried (_.var "curried")) -(def: @missing (_.var "missing")) +(def @curried (_.var "curried")) +(def @missing (_.var "missing")) -(def: input +(def input (|>> ++ //case.register)) -(def: .public (function expression archive [environment arity bodyS]) +(def .public (function expression archive [environment arity bodyS]) (Generator (Abstraction Synthesis)) (do [! ///////phase.monad] [[function_name bodyO] (/////generation.with_new_context archive diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux index 8ca9af784..cd2ebc5af 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux @@ -33,10 +33,10 @@ [reference [variable (.only Register)]]]]]]]) -(def: @scope +(def @scope (_.var "scope")) -(def: .public (scope expression archive [start initsS+ bodyS]) +(def .public (scope expression archive [start initsS+ bodyS]) (Generator (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop @@ -56,7 +56,7 @@ bodyO)]) (_.apply initsO+ @scope)))))) -(def: .public (again expression archive argsS+) +(def .public (again expression archive argsS+) (Generator (List Synthesis)) (do [! ///////phase.monad] [@scope /////generation.anchor diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/primitive.lux index 0772c64bc..cba7e79d6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/primitive.lux @@ -5,7 +5,7 @@ ["_" scheme (.only Expression)]]]]) (with_template [<name> <type> <code>] - [(def: .public <name> + [(def .public <name> (-> <type> Expression) <code>)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/reference.lux index 7e0b61970..cef4fe09f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(def: .public system +(def .public system (System Expression) (implementation - (def: constant _.var) - (def: variable _.var))) + (def constant _.var) + (def variable _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux index ecac319c2..8d145794e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux @@ -39,7 +39,7 @@ [archive (.only Output Archive) ["[0]" artifact (.only Registry)]]]]]]) -(def: module_id +(def module_id 0) (with_template [<name> <base>] @@ -55,10 +55,10 @@ (type: .public (Generator i) (-> Phase Archive i (Operation Expression))) -(def: .public unit +(def .public unit (_.string /////synthesis.unit)) -(def: .public with_vars +(def .public with_vars (syntax (_ [vars (<code>.tuple (<>.some <code>.local)) body <code>.any]) (do [! meta.monad] @@ -71,7 +71,7 @@ list.together))] (~ body)))))))) -(def: runtime: +(def runtime: (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -84,11 +84,11 @@ (case declaration {.#Left name} (let [g!name (code.local name)] - (in (list (` (def: .public (~ g!name) + (in (list (` (def .public (~ g!name) Var (~ runtime_name))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) _.Computation (_.define_constant (~ runtime_name) (~ code))))))) @@ -97,17 +97,17 @@ inputsC (list#each code.local inputs) inputs_typesC (list#each (function.constant (` _.Expression)) inputs)] - (in (list (` (def: .public ((~ g!name) (~+ inputsC)) + (in (list (` (def .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) _.Computation) (_.apply (list (~+ inputsC)) (~ runtime_name)))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) _.Computation (..with_vars [(~+ inputsC)] (_.define_function (~ runtime_name) [(list (~+ inputsC)) {.#None}] (~ code)))))))))))))) -(def: last_index +(def last_index (-> Expression Computation) (|>> _.length/1 (_.-/2 (_.int +1)))) @@ -139,7 +139,7 @@ @slice)))) ))) -(def: (variant' tag last? value) +(def (variant' tag last? value) (-> Expression Expression Expression Computation) (all _.cons/2 tag @@ -149,7 +149,7 @@ (runtime: (sum//make tag last? value) (variant' tag last? value)) -(def: .public (variant [lefts right? value]) +(def .public (variant [lefts right? value]) (-> (Variant Expression) Computation) (..sum//make (_.int (.int lefts)) (_.bool right?) value)) @@ -176,26 +176,26 @@ (variant' (|> sum_tag (_.-/2 wanted_tag)) sum_flag sum_value)) no_match)))) -(def: runtime//adt +(def runtime//adt Computation (_.begin (list @tuple//left @tuple//right @sum//get @sum//make))) -(def: .public none +(def .public none Computation (|> ..unit [0 #0] variant)) -(def: .public some +(def .public some (-> Expression Computation) (|>> [1 #1] ..variant)) -(def: .public left +(def .public left (-> Expression Computation) (|>> [0 #0] ..variant)) -(def: .public right +(def .public right (-> Expression Computation) (|>> [1 #1] ..variant)) @@ -229,27 +229,27 @@ (_.apply/2 @loop (_.cdr/1 @input) (..some (_.vector/* (list (_.car/1 @input) @output))))))]) (_.apply/2 @loop (_.reverse/1 program_args) ..none)))) -(def: runtime//lux +(def runtime//lux Computation (_.begin (list @lux//try @lux//program_args))) -(def: i64//+limit (_.manual "+9223372036854775807" +(def i64//+limit (_.manual "+9223372036854775807" ... "+0x7FFFFFFFFFFFFFFF" )) -(def: i64//-limit (_.manual "-9223372036854775808" +(def i64//-limit (_.manual "-9223372036854775808" ... "-0x8000000000000000" )) -(def: i64//+iteration (_.manual "+18446744073709551616" +(def i64//+iteration (_.manual "+18446744073709551616" ... "+0x10000000000000000" )) -(def: i64//-iteration (_.manual "-18446744073709551616" +(def i64//-iteration (_.manual "-18446744073709551616" ... "-0x10000000000000000" )) -(def: i64//+cap (_.manual "+9223372036854775808" +(def i64//+cap (_.manual "+9223372036854775808" ... "+0x8000000000000000" )) -(def: i64//-cap (_.manual "-9223372036854775809" +(def i64//-cap (_.manual "-9223372036854775809" ... "-0x8000000000000001" )) @@ -272,7 +272,7 @@ (_.arithmetic_shift/2 (_.remainder/2 (_.int +64) param)) ..i64//64)) -(def: as_nat +(def as_nat (_.remainder/2 ..i64//+iteration)) (runtime: (i64//right_shifted shift subject) @@ -295,7 +295,7 @@ (runtime: (i64//division param subject) (|> subject (_.//2 param) _.truncate/1 ..i64//64)) -(def: runtime//i64 +(def runtime//i64 Computation (_.begin (list @i64//64 @i64//left_shifted @@ -315,7 +315,7 @@ ..none (..some @output)))))) -(def: runtime//f64 +(def runtime//f64 Computation (_.begin (list @f64//decode))) @@ -332,7 +332,7 @@ (runtime: (text//char index text) (_.char->integer/1 (_.string_ref/2 text index))) -(def: runtime//text +(def runtime//text (_.begin (list @text//index @text//clip @text//char))) @@ -341,13 +341,13 @@ (_.begin (list (_.vector_set!/3 array idx value) array))) -(def: runtime//array +(def runtime//array Computation (all _.then @array//write )) -(def: runtime +(def runtime Computation (_.begin (list @slice runtime//lux @@ -358,7 +358,7 @@ runtime//array ))) -(def: .public generate +(def .public generate (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux index ec1611ddf..fec696893 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux @@ -17,7 +17,7 @@ ["//[1]" /// ["[1][0]" phase (.open: "[1]#[0]" monad)]]]]) -(def: .public (tuple expression archive elemsS+) +(def .public (tuple expression archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ {.#End} @@ -31,7 +31,7 @@ (monad.each ///////phase.monad (expression archive)) (///////phase#each _.vector/*)))) -(def: .public (variant expression archive [lefts right? valueS]) +(def .public (variant expression archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux index de5d4c9e4..3e7102696 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux @@ -29,7 +29,7 @@ [reference (.only) [variable (.only)]]]]]]) -(def: (simple analysis) +(def (simple analysis) (-> ///simple.Simple /simple.Simple) (case analysis {///simple.#Unit} @@ -49,7 +49,7 @@ [///simple.#Int /simple.#I64] [///simple.#Rev /simple.#I64]))) -(def: (optimization archive) +(def (optimization archive) Phase (function (optimization' analysis) (case analysis @@ -102,7 +102,7 @@ (phase.result' state)))))) ))) -(def: .public (phase archive analysis) +(def .public (phase archive analysis) Phase (do phase.monad [synthesis (..optimization archive analysis)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux index 218ece022..4f772b16c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux @@ -37,11 +37,11 @@ [meta [archive (.only Archive)]]]]]) -(def: clean_up +(def clean_up (-> Path Path) (|>> {/.#Seq {/.#Pop}})) -(def: (path' pattern end? thenC) +(def (path' pattern end? thenC) (-> Pattern Bit (Operation Path) (Operation Path)) (case pattern {///pattern.#Simple simple} @@ -98,11 +98,11 @@ (list.reversed (list.enumeration tuple)))) )) -(def: (path archive synthesize pattern bodyA) +(def (path archive synthesize pattern bodyA) (-> Archive Phase Pattern Analysis (Operation Path)) (path' pattern true (///#each (|>> {/.#Then}) (synthesize archive bodyA)))) -(def: (weave_branch weave equivalence [new_test new_then] [[old_test old_then] old_tail]) +(def (weave_branch weave equivalence [new_test new_then] [[old_test old_then] old_tail]) (All (_ a) (-> (-> Path Path Path) (Equivalence a) [a Path] (/.Fork a Path) (/.Fork a Path))) @@ -116,13 +116,13 @@ {.#Item old_item} {.#Item (weave_branch weave equivalence [new_test new_then] old_item)})])) -(def: (weave_fork weave equivalence new_fork old_fork) +(def (weave_fork weave equivalence new_fork old_fork) (All (_ a) (-> (-> Path Path Path) (Equivalence a) (/.Fork a Path) (/.Fork a Path) (/.Fork a Path))) (list#mix (..weave_branch weave equivalence) old_fork {.#Item new_fork})) -(def: (weave new old) +(def (weave new old) (-> Path Path Path) (with_expansions [<default> (these {/.#Alt old new})] (case [new old] @@ -199,7 +199,7 @@ _ <default>))) -(def: (get patterns @selection) +(def (get patterns @selection) (-> (///complex.Tuple Pattern) Register (List Member)) (loop (again [lefts 0 patterns patterns]) @@ -236,52 +236,52 @@ _ <failure>))))) -(def: .public (synthesize_case synthesize archive input [[headP headA] tailPA+]) +(def .public (synthesize_case synthesize archive input [[headP headA] tailPA+]) (-> Phase Archive Synthesis Match (Operation Synthesis)) (do [! ///.monad] [headSP (path archive synthesize headP headA) tailSP+ (monad.each ! (product.uncurried (path archive synthesize)) tailPA+)] (in (/.branch/case [input (list#mix weave headSP tailSP+)])))) -(def: !masking +(def !masking (template (_ <variable> <output>) [[[{///pattern.#Bind <variable>} {///analysis.#Reference (///reference.local <output>)}] (list)]])) -(def: .public (synthesize_exec synthesize archive before after) +(def .public (synthesize_exec synthesize archive before after) (-> Phase Archive Synthesis Analysis (Operation Synthesis)) (do ///.monad [after (synthesize archive after)] (in (/.branch/exec [before after])))) -(def: .public (synthesize_let synthesize archive input @variable body) +(def .public (synthesize_let synthesize archive input @variable body) (-> Phase Archive Synthesis Register Analysis (Operation Synthesis)) (do ///.monad [body (/.with_new_local (synthesize archive body))] (in (/.branch/let [input @variable body])))) -(def: .public (synthesize_masking synthesize archive input @variable @output) +(def .public (synthesize_masking synthesize archive input @variable @output) (-> Phase Archive Synthesis Register Register (Operation Synthesis)) (if (n.= @variable @output) (///#in input) (..synthesize_let synthesize archive input @variable {///analysis.#Reference (///reference.local @output)}))) -(def: .public (synthesize_if synthesize archive test then else) +(def .public (synthesize_if synthesize archive test then else) (-> Phase Archive Synthesis Analysis Analysis (Operation Synthesis)) (do ///.monad [then (synthesize archive then) else (synthesize archive else)] (in (/.branch/if [test then else])))) -(def: !get +(def !get (template (_ <patterns> <output>) [[[(///pattern.tuple <patterns>) {///analysis.#Reference (///reference.local <output>)}] (.list)]])) -(def: .public (synthesize_get synthesize archive input patterns @member) +(def .public (synthesize_get synthesize archive input patterns @member) (-> Phase Archive Synthesis (///complex.Tuple Pattern) Register (Operation Synthesis)) (case (..get patterns @member) {.#End} @@ -295,7 +295,7 @@ _ (///#in (/.branch/get [path input]))))) -(def: .public (synthesize synthesize^ [headB tailB+] archive inputA) +(def .public (synthesize synthesize^ [headB tailB+] archive inputA) (-> Phase Match Phase) (do [! ///.monad] [inputS (synthesize^ archive inputA)] @@ -335,7 +335,7 @@ match (..synthesize_case synthesize^ archive inputS match)))) -(def: .public (count_pops path) +(def .public (count_pops path) (-> Path [Nat Path]) (case path (pattern (/.path/seq {/.#Pop} path')) @@ -345,7 +345,7 @@ _ [0 path])) -(def: .public pattern_matching_error +(def .public pattern_matching_error "Invalid expression for pattern-matching.") (type: .public Storage @@ -353,7 +353,7 @@ [#bindings (Set Register) #dependencies (Set Variable)])) -(def: empty +(def empty Storage [#bindings (set.empty n.hash) #dependencies (set.empty ///reference/variable.hash)]) @@ -364,7 +364,7 @@ ... since the variable will exist beforehand, so no closure will need ... to be created for it. ... Apply this trick to JS, Python et al. -(def: .public (storage path) +(def .public (storage path) (-> Path Storage) (loop (for_path [path path path_storage ..empty]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux index 8f29f5d0b..89af418b6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux @@ -36,21 +36,21 @@ "Foreign" (%.nat foreign) "Environment" (exception.listing /.%synthesis environment))) -(def: arity_arguments +(def arity_arguments (-> Arity (List Synthesis)) (|>> -- (enum.range n.enum 1) (list#each (|>> /.variable/local)))) -(def: .public self_reference +(def .public self_reference (template (self_reference) [(/.variable/local 0)])) -(def: (expanded_nested_self_reference arity) +(def (expanded_nested_self_reference arity) (-> Arity Synthesis) (/.function/apply [(..self_reference) (arity_arguments arity)])) -(def: .public (apply phase) +(def .public (apply phase) (-> Phase Phase) (function (_ archive exprA) (let [[funcA argsA] (////analysis.reification exprA)] @@ -86,7 +86,7 @@ _ (in <apply>))))))) -(def: (find_foreign environment register) +(def (find_foreign environment register) (-> (Environment Synthesis) Register (Operation Synthesis)) (case (list.item register environment) {.#Some aliased} @@ -95,7 +95,7 @@ {.#None} (phase.except ..cannot_find_foreign_variable_in_environment [register environment]))) -(def: (grow_path grow path) +(def (grow_path grow path) (-> (-> Synthesis (Operation Synthesis)) Path (Operation Path)) (case path {/.#Bind register} @@ -142,7 +142,7 @@ _ (phase#in path))) -(def: (grow environment expression) +(def (grow environment expression) (-> (Environment Synthesis) Synthesis (Operation Synthesis)) (case expression {/.#Structure structure} @@ -255,7 +255,7 @@ {/.#Simple _} (phase#in expression))) -(def: .public (abstraction phase environment archive bodyA) +(def .public (abstraction phase environment archive bodyA) (-> Phase (Environment Analysis) Phase) (do [! phase.monad] [environment (monad.each ! (phase archive) environment) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux index 778ba2900..f3c5fb252 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux @@ -25,11 +25,11 @@ (type: .public (Transform a) (-> a (Maybe a))) -(def: .public (register_optimization offset) +(def .public (register_optimization offset) (-> Register (-> Register Register)) (|>> -- (n.+ offset))) -(def: (path_optimization body_optimization offset) +(def (path_optimization body_optimization offset) (-> (Transform Synthesis) Register (Transform Path)) (function (again path) (case path @@ -77,7 +77,7 @@ _ {.#Some path}))) -(def: (body_optimization true_loop? offset scope_environment arity expr) +(def (body_optimization true_loop? offset scope_environment arity expr) (-> Bit Register (Environment Synthesis) Arity (Transform Synthesis)) (loop (again [return? true expr expr]) @@ -211,7 +211,7 @@ (monad.each maybe.monad (again false)) (maybe#each (|>> [name] {/.#Extension})))))) -(def: .public (optimization true_loop? offset inits functionS) +(def .public (optimization true_loop? offset inits functionS) (-> Bit Register (List Synthesis) Abstraction (Maybe [Register (List Synthesis) Synthesis])) (|> (the /.#body functionS) (body_optimization true_loop? offset (the /.#environment functionS) (the /.#arity functionS)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux index 51de85771..1ca58edd0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux @@ -30,7 +30,7 @@ ["[0]" reference (.only) ["[0]" variable (.only Register Variable)]]]]) -(def: (prune redundant register) +(def (prune redundant register) (-> Register Register Register) (if (n.> redundant register) (-- register) @@ -39,7 +39,7 @@ (type: (Remover a) (-> Register (-> a a))) -(def: (remove_local_from_path remove_local redundant) +(def (remove_local_from_path remove_local redundant) (-> (Remover Synthesis) (Remover Path)) (function (again path) (case path @@ -98,7 +98,7 @@ {/.#Then (remove_local redundant then)} ))) -(def: (remove_local_from_variable redundant variable) +(def (remove_local_from_variable redundant variable) (Remover Variable) (case variable {variable.#Local register} @@ -107,7 +107,7 @@ {variable.#Foreign register} variable)) -(def: (remove_local redundant) +(def (remove_local redundant) (Remover Synthesis) (function (again synthesis) (case synthesis @@ -178,14 +178,14 @@ (type: Redundancy (Dictionary Register Bit)) -(def: initial +(def initial Redundancy (dictionary.empty n.hash)) -(def: redundant! true) -(def: necessary! false) +(def redundant! true) +(def necessary! false) -(def: (extended offset amount redundancy) +(def (extended offset amount redundancy) (-> Register Nat Redundancy [(List Register) Redundancy]) (let [extension (|> amount list.indices (list#each (n.+ offset)))] [extension @@ -194,14 +194,14 @@ redundancy extension)])) -(def: (default arity) +(def (default arity) (-> Arity Redundancy) (product.right (..extended 0 (++ arity) ..initial))) (type: (Optimization a) (-> [Redundancy a] (Try [Redundancy a]))) -(def: (list_optimization optimization) +(def (list_optimization optimization) (All (_ a) (-> (Optimization a) (Optimization (List a)))) (function (again [redundancy values]) (case values @@ -225,7 +225,7 @@ [unknown_register] ) -(def: (declare register redundancy) +(def (declare register redundancy) (-> Register Redundancy (Try Redundancy)) (case (dictionary.value register redundancy) {.#None} @@ -234,7 +234,7 @@ {.#Some _} (exception.except ..redundant_declaration [register]))) -(def: (observe register redundancy) +(def (observe register redundancy) (-> Register Redundancy (Try Redundancy)) (case (dictionary.value register redundancy) {.#None} @@ -243,7 +243,7 @@ {.#Some _} {try.#Success (dictionary.has register ..necessary! redundancy)})) -(def: (format redundancy) +(def (format redundancy) (%.Format Redundancy) (|> redundancy dictionary.entries @@ -251,7 +251,7 @@ (%.format (%.nat register) ": " (%.bit redundant?)))) (text.interposed ", "))) -(def: (path_optimization optimization) +(def (path_optimization optimization) (-> (Optimization Synthesis) (Optimization Path)) (function (again [redundancy path]) (case path @@ -329,7 +329,7 @@ (in [redundancy {/.#Then then}])) ))) -(def: (optimization' [redundancy synthesis]) +(def (optimization' [redundancy synthesis]) (Optimization Synthesis) (with_expansions [<no_op> (these {try.#Success [redundancy synthesis]})] @@ -449,7 +449,7 @@ (in [redundancy {/.#Extension name inputs}]))))) -(def: .public optimization +(def .public optimization (-> Synthesis (Try Synthesis)) (|>> [..initial] optimization' diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/program.lux b/stdlib/source/library/lux/tool/compiler/language/lux/program.lux index fcf6e4cdc..625448c47 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/program.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/program.lux @@ -24,7 +24,7 @@ (type: .public (Program expression directive) (-> unit.ID expression directive)) -(def: .public name +(def .public name Text "") @@ -32,7 +32,7 @@ (exception.report "Modules" (exception.listing %.text modules))) -(def: .public (context archive) +(def .public (context archive) (-> Archive (Try unit.ID)) (do [! try.monad] [registries (|> archive diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux index 3dcd579c9..054c8eeb2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux @@ -54,16 +54,16 @@ ["[0]" rev] ["[0]" frac]]]]]) -(def: declaration_name +(def declaration_name (syntax (_ [[name parameters] (<code>.form (<>.and <code>.any (<>.some <code>.any)))]) (in (list name)))) -(def: inline: +(def inlined (template (_ <declaration> <type> <body>) - [(for @.python (def: <declaration> <type> <body>) + [(for @.python (def <declaration> <type> <body>) ... TODO: No longer skip inlining Lua after Rembulan isn't being used anymore. - @.lua (def: <declaration> <type> <body>) - (`` (def: (~~ (..declaration_name <declaration>)) + @.lua (def <declaration> <type> <body>) + (`` (def (~~ (..declaration_name <declaration>)) (template <declaration> [<body>]))))])) @@ -84,7 +84,7 @@ Nat) (with_template [<extension> <diff> <name>] - [(def: <name> + [(def <name> (template (_ value) [(<extension> <diff> value)]))] @@ -93,12 +93,12 @@ ["lux i64 -" 1 !--] ) -(def: !clip +(def !clip (template (_ from to text) [("lux text clip" from (n.- from to) text)])) (with_template [<name> <extension>] - [(def: <name> + [(def <name> (template (_ reference subject) [(<extension> reference subject)]))] @@ -107,7 +107,7 @@ ) (with_template [<name> <extension>] - [(def: <name> + [(def <name> (template (_ param subject) [(<extension> param subject)]))] @@ -118,17 +118,17 @@ (type: .public Aliases (Dictionary Text Text)) -(def: .public no_aliases +(def .public no_aliases Aliases (dictionary.empty text.hash)) -(def: .public prelude +(def .public prelude .prelude) -(def: .public text_delimiter text.double_quote) +(def .public text_delimiter text.double_quote) (with_template [<char> <definition>] - [(def: .public <definition> <char>)] + [(def .public <definition> <char>)] ... Form delimiters ["(" open_form] @@ -165,9 +165,9 @@ (exception.report "Module" (%.text module))) -(def: amount_of_input_shown 64) +(def amount_of_input_shown 64) -(inline: (input_at start input) +(inlined (input_at start input) (-> Offset Text Text) (let [end (|> start (!n/+ amount_of_input_shown) (n.min ("lux text size" input)))] (!clip start end input))) @@ -187,12 +187,12 @@ (exception.report "Text" (%.text text))) -(def: !failure +(def !failure (template (_ parser where offset source_code) [{.#Left [[where offset source_code] (exception.error ..unrecognized_input [where (%.symbol (symbol parser)) source_code offset])]}])) -(def: !end_of_file +(def !end_of_file (template (_ where offset source_code current_module) [{.#Left [[where offset source_code] (exception.error ..end_of_file current_module)]}])) @@ -200,7 +200,7 @@ (type: (Parser a) (-> Source (Either [Source Text] [Source a]))) -(def: !with_char+ +(def !with_char+ (template (_ @source_code_size @source_code @offset @char @else @body) [(if (!i/< (as Int @source_code_size) (as Int @offset)) @@ -208,11 +208,11 @@ @body) @else)])) -(def: !with_char +(def !with_char (template (_ @source_code @offset @char @else @body) [(!with_char+ ("lux text size" @source_code) @source_code @offset @char @else @body)])) -(def: !letE +(def !letE (template (_ <binding> <computation> <body>) [(case <computation> {.#Right <binding>} @@ -222,30 +222,30 @@ <<otherwise>> (as_expected <<otherwise>>))])) -(def: !horizontal +(def !horizontal (template (_ where offset source_code) [[(revised .#column ++ where) (!++ offset) source_code]])) -(inline: (!new_line where) +(inlined (!new_line where) (-> Location Location) (let [[where::file where::line where::column] where] [where::file (!++ where::line) 0])) -(inline: (!forward length where) +(inlined (!forward length where) (-> Nat Location Location) (let [[where::file where::line where::column] where] [where::file where::line (!n/+ length where::column)])) -(def: !vertical +(def !vertical (template (_ where offset source_code) [[(!new_line where) (!++ offset) source_code]])) (with_template [<name> <close> <tag>] - [(inline: (<name> parse where offset source_code) + [(inlined (<name> parse where offset source_code) (-> (Parser Code) Location Offset Text (Either [Source Text] [Source Code])) (loop (again [source (is Source [(!forward 1 where) offset source_code]) @@ -268,7 +268,7 @@ [tuple_parser ..close_tuple .#Tuple] ) -(def: !guarantee_no_new_lines +(def !guarantee_no_new_lines (template (_ where offset source_code content body) [(case ("lux text index" 0 (static text.new_line) content) {.#None} @@ -278,7 +278,7 @@ {.#Left [[where offset source_code] (exception.error ..text_cannot_contain_new_lines content)]})])) -(def: (text_parser where offset source_code) +(def (text_parser where offset source_code) (-> Location Offset Text (Either [Source Text] [Source Code])) (case ("lux text index" offset (static ..text_delimiter) source_code) {.#Some g!end} @@ -306,7 +306,7 @@ [..open_tuple] [..close_tuple] [..text_delimiter]) <digit_separator> (static ..digit_separator)] - (def: !if_digit? + (def !if_digit? (template (_ @char @then @else) [("lux syntax char case!" @char [[<digits>] @@ -315,7 +315,7 @@ ... else @else)])) - (def: !if_digit?+ + (def !if_digit?+ (template (_ @char @then @else_options @else) [(`` ("lux syntax char case!" @char [[<digits> <digit_separator>] @@ -326,7 +326,7 @@ ... else @else))])) - (`` (def: !if_symbol_char?|tail + (`` (def !if_symbol_char?|tail (template (_ @char @then @else) [("lux syntax char case!" @char [[<non_symbol_chars>] @@ -335,7 +335,7 @@ ... else @then)]))) - (`` (def: !if_symbol_char?|head + (`` (def !if_symbol_char?|head (template (_ @char @then @else) [("lux syntax char case!" @char [[<non_symbol_chars> <digits>] @@ -345,7 +345,7 @@ @then)]))) ) -(def: !number_output +(def !number_output (template (_ <source_code> <start> <end> <codec> <tag>) [(case (|> <source_code> (!clip <start> <end>) @@ -362,7 +362,7 @@ {.#Left [[where <start> <source_code>] error]})])) -(def: no_exponent +(def no_exponent Offset 0) @@ -375,7 +375,7 @@ [..positive_sign] [..negative_sign])] - (inline: (frac_parser source_code//size start where offset source_code) + (inlined (frac_parser source_code//size start where offset source_code) (-> Nat Nat Location Offset Text (Either [Source Text] [Source Code])) (loop (again [end offset @@ -400,7 +400,7 @@ <frac_output>)))) - (inline: (signed_parser source_code//size start where offset source_code) + (inlined (signed_parser source_code//size start where offset source_code) (-> Nat Nat Location Offset Text (Either [Source Text] [Source Code])) (loop (again [end offset]) @@ -415,7 +415,7 @@ ) (with_template [<parser> <codec> <tag>] - [(inline: (<parser> source_code//size start where offset source_code) + [(inlined (<parser> source_code//size start where offset source_code) (-> Nat Nat Location Offset Text (Either [Source Text] [Source Code])) (loop (again [g!end offset]) @@ -429,7 +429,7 @@ [rev_parser rev.decimal .#Rev] ) -(def: !signed_parser +(def !signed_parser (template (_ source_code//size offset where source_code @aliases @end) [(<| (let [g!offset/1 (!++ offset)]) (!with_char+ source_code//size source_code g!offset/1 g!char/1 @end) @@ -441,7 +441,7 @@ end source_code] (!clip start end source_code)]}] - (inline: (symbol_part_parser start where offset source_code) + (inlined (symbol_part_parser start where offset source_code) (-> Nat Location Offset Text (Either [Source Text] [Source Text])) (let [source_code//size ("lux text size" source_code)] @@ -451,14 +451,14 @@ (again (!++ end)) <output>)))))) -(def: !half_symbol_parser +(def !half_symbol_parser (template (_ @offset @char @module) [(!if_symbol_char?|head @char (!letE [source' symbol] (..symbol_part_parser @offset (!forward 1 where) (!++ @offset) source_code) {.#Right [source' [@module symbol]]}) (!failure ..!half_symbol_parser where @offset source_code))])) -(`` (def: (short_symbol_parser source_code//size current_module [where offset/0 source_code]) +(`` (def (short_symbol_parser source_code//size current_module [where offset/0 source_code]) (-> Nat Text (Parser Symbol)) (<| (!with_char+ source_code//size source_code offset/0 char/0 (!end_of_file where offset/0 source_code current_module)) @@ -469,13 +469,13 @@ (!half_symbol_parser offset/1 char/1 current_module)) (!half_symbol_parser offset/0 char/0 (static ..prelude)))))) -(def: !short_symbol_parser +(def !short_symbol_parser (template (_ source_code//size @current_module @source @where @tag) [(!letE [source' symbol] (..short_symbol_parser source_code//size @current_module @source) {.#Right [source' [@where {@tag symbol}]]})])) (with_expansions [<simple> (these {.#Right [source' ["" simple]]})] - (`` (def: (full_symbol_parser aliases start source) + (`` (def (full_symbol_parser aliases start source) (-> Aliases Offset (Parser Symbol)) (<| (!letE [source' simple] (let [[where offset source_code] source] (..symbol_part_parser start where offset source_code))) @@ -493,13 +493,13 @@ complex]]})) <simple>))))) -(def: !full_symbol_parser +(def !full_symbol_parser (template (_ @offset @source @where @aliases @tag) [(!letE [source' full_symbol] (..full_symbol_parser @aliases @offset @source) {.#Right [source' [@where {@tag full_symbol}]]})])) ... TODO: Grammar macro for specifying syntax. -... (def: lux_grammar +... (def lux_grammar ... (grammar [expression "..."] ... [form "(" [#* expression] ")"])) @@ -508,18 +508,18 @@ <move_2> (these [(!forward 1 where) (!++/2 offset/0) source_code]) <again> (these (parse current_module aliases source_code//size))] - (def: !close + (def !close (template (_ closer) [{.#Left [<move_1> closer]}])) - (def: (bit_syntax value [where offset/0 source_code]) + (def (bit_syntax value [where offset/0 source_code]) (-> Bit (Parser Code)) {.#Right [[(revised .#column (|>> !++/2) where) (!++/2 offset/0) source_code] [where {.#Bit value}]]}) - (def: .public (parse current_module aliases source_code//size) + (def .public (parse current_module aliases source_code//size) (-> Text Aliases Nat (Parser Code)) ... The "exec []" is only there to avoid function fusion. ... This is to preserve the loop as much as possible and keep it tight. diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux index c4a772695..722029eb2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux @@ -50,11 +50,11 @@ ... https://en.wikipedia.org/wiki/Currying #currying? Bit])) -(def: .public fresh_resolver +(def .public fresh_resolver Resolver (dictionary.empty variable.hash)) -(def: .public init +(def .public init State [#locals 0 #currying? false]) @@ -145,12 +145,12 @@ (type: .public Path (Path' Synthesis)) -(def: .public path/pop +(def .public path/pop Path {#Pop}) (with_template [<name> <kind>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [(.<| {..#Access} {<kind>} @@ -161,7 +161,7 @@ ) (with_template [<name> <access> <lefts> <right?>] - [(def: .public <name> + [(def .public <name> (template (<name> lefts right?) [(.<| {..#Access} {<access>} @@ -173,7 +173,7 @@ ) (with_template [<access> <side> <name>] - [(def: .public <name> + [(def .public <name> (template (<name> lefts) [(<access> lefts <side>)]))] @@ -185,7 +185,7 @@ ) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [{<tag> content}]))] @@ -194,7 +194,7 @@ ) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> left right) [{<tag> left right}]))] @@ -208,16 +208,16 @@ (type: .public Apply (Apply' Synthesis)) -(def: .public unit +(def .public unit Text "") (with_template [<with> <query> <tag> <type>] - [(def: .public (<with> value) + [(def .public (<with> value) (-> <type> (All (_ a) (-> (Operation a) (Operation a)))) (extension.temporary (has <tag> value))) - (def: .public <query> + (def .public <query> (Operation <type>) (extension.read (the <tag>)))] @@ -225,14 +225,14 @@ [with_currying? currying? #currying? Bit] ) -(def: .public with_new_local +(def .public with_new_local (All (_ a) (-> (Operation a) (Operation a))) (<<| (do phase.monad [locals ..locals]) (..with_locals (++ locals)))) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [{..#Simple {<tag> content}}]))] @@ -243,7 +243,7 @@ ) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [(.<| {..#Structure} {<tag>} @@ -254,7 +254,7 @@ ) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [(.<| {..#Reference} <tag> @@ -267,7 +267,7 @@ ) (with_template [<name> <family> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [(.<| {..#Control} {<family>} @@ -287,7 +287,7 @@ [function/apply ..#Function ..#Apply] ) -(def: .public (%path' %then value) +(def .public (%path' %then value) (All (_ a) (-> (Format a) (Format (Path' a)))) (case value {#Pop} @@ -331,7 +331,7 @@ (|> (%then then) (text.enclosed ["(! " ")"])))) -(def: .public (%synthesis value) +(def .public (%synthesis value) (Format Synthesis) (case value {#Simple it} @@ -419,14 +419,14 @@ (format (%.text name) " ") (text.enclosed ["(" ")"])))) -(def: .public %path +(def .public %path (Format Path) (%path' %synthesis)) -(def: .public (path'_equivalence equivalence) +(def .public (path'_equivalence equivalence) (All (_ a) (-> (Equivalence a) (Equivalence (Path' a)))) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{#Pop} {#Pop}] true @@ -466,13 +466,13 @@ _ false)))) -(def: (path'_hash super) +(def (path'_hash super) (All (_ a) (-> (Hash a) (Hash (Path' a)))) (implementation - (def: equivalence + (def equivalence (..path'_equivalence (at super equivalence))) - (def: (hash value) + (def (hash value) (case value {#Pop} 2 @@ -511,10 +511,10 @@ (n.* 29 (at super hash body)) )))) -(def: (branch_equivalence (open "#[0]")) +(def (branch_equivalence (open "#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (Branch a)))) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{#Let [reference_input reference_register reference_body]} {#Let [sample_input sample_register sample_body]}] @@ -541,13 +541,13 @@ _ false)))) -(def: (branch_hash super) +(def (branch_hash super) (All (_ a) (-> (Hash a) (Hash (Branch a)))) (implementation - (def: equivalence + (def equivalence (..branch_equivalence (at super equivalence))) - (def: (hash value) + (def (hash value) (case value {#Exec this that} (all n.* 2 @@ -577,10 +577,10 @@ (at (..path'_hash super) hash path)) )))) -(def: (loop_equivalence (open "/#[0]")) +(def (loop_equivalence (open "/#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (Loop a)))) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{#Scope [reference_start reference_inits reference_iteration]} {#Scope [sample_start sample_inits sample_iteration]}] @@ -594,13 +594,13 @@ _ false)))) -(def: (loop_hash super) +(def (loop_hash super) (All (_ a) (-> (Hash a) (Hash (Loop a)))) (implementation - (def: equivalence + (def equivalence (..loop_equivalence (at super equivalence))) - (def: (hash value) + (def (hash value) (case value {#Scope [start inits iteration]} (all n.* 2 @@ -613,10 +613,10 @@ (at (list.hash super) hash resets)) )))) -(def: (function_equivalence (open "#[0]")) +(def (function_equivalence (open "#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (Function a)))) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{#Abstraction [reference_environment reference_arity reference_body]} {#Abstraction [sample_environment sample_arity sample_body]}] @@ -632,13 +632,13 @@ _ false)))) -(def: (function_hash super) +(def (function_hash super) (All (_ a) (-> (Hash a) (Hash (Function a)))) (implementation - (def: equivalence + (def equivalence (..function_equivalence (at super equivalence))) - (def: (hash value) + (def (hash value) (case value {#Abstraction [environment arity body]} (all n.* 2 @@ -652,10 +652,10 @@ (at (list.hash super) hash arguments)) )))) -(def: (control_equivalence (open "#[0]")) +(def (control_equivalence (open "#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (Control a)))) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] (^.with_template [<tag> <equivalence>] [[{<tag> reference} {<tag> sample}] @@ -667,13 +667,13 @@ _ false)))) -(def: (control_hash super) +(def (control_hash super) (All (_ a) (-> (Hash a) (Hash (Control a)))) (implementation - (def: equivalence + (def equivalence (..control_equivalence (at super equivalence))) - (def: (hash value) + (def (hash value) (case value (^.with_template [<factor> <tag> <hash>] [{<tag> value} @@ -683,10 +683,10 @@ [5 #Function ..function_hash]) )))) -(def: .public equivalence +(def .public equivalence (Equivalence Synthesis) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] (^.with_template [<tag> <equivalence>] [[{<tag> reference'} {<tag> sample'}] @@ -700,16 +700,16 @@ _ false)))) -(def: .public path_equivalence +(def .public path_equivalence (Equivalence Path) (path'_equivalence equivalence)) -(def: .public hash +(def .public hash (Hash Synthesis) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (hash value) + (def (hash value) (let [again_hash [..equivalence hash]] (case value (^.with_template [<tag> <hash>] @@ -721,14 +721,14 @@ [#Control (..control_hash again_hash)] [#Extension (extension.hash again_hash)])))))) -(def: .public !bind_top +(def .public !bind_top (template (!bind_top register thenP) [(all ..path/seq {..#Bind register} {..#Pop} thenP)])) -(def: .public !multi_pop +(def .public !multi_pop (template (!multi_pop nextP) [(all ..path/seq {..#Pop} @@ -743,7 +743,7 @@ ... pattern-optimizations again, since a lot of BINDs will become POPs ... and thus will result in useless code being generated. (with_template [<name> <side>] - [(def: .public <name> + [(def .public <name> (template (<name> idx nextP) [(all ..path/seq (<side> idx) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access.lux index dba26b8af..76c9a0400 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access.lux @@ -17,7 +17,7 @@ {#Side Side} {#Member Member})) -(def: .public (format it) +(def .public (format it) (Format Access) (case it {#Side it} @@ -26,13 +26,13 @@ {#Member it} (/member.format it))) -(def: .public hash +(def .public hash (Hash Access) (all sum.hash /side.hash /member.hash )) -(def: .public equivalence +(def .public equivalence (Equivalence Access) (at ..hash equivalence)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access/member.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access/member.lux index 24482862a..ec159b99a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access/member.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access/member.lux @@ -18,17 +18,17 @@ [#lefts Nat #right? Bit])) -(def: .public (format it) +(def .public (format it) (%.Format Member) (%.format "[" (%.nat (the #lefts it)) " " (%.bit (the #right? it)) "]")) -(def: .public hash +(def .public hash (Hash Member) (all product.hash nat.hash bit.hash )) -(def: .public equivalence +(def .public equivalence (Equivalence Member) (at ..hash equivalence)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access/side.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access/side.lux index 89dd5e86a..df1bda351 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access/side.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access/side.lux @@ -18,17 +18,17 @@ [#lefts Nat #right? Bit])) -(def: .public (format it) +(def .public (format it) (%.Format Side) (%.format "{" (%.nat (the #lefts it)) " " (%.bit (the #right? it)) "}")) -(def: .public hash +(def .public hash (Hash Side) (all product.hash nat.hash bit.hash )) -(def: .public equivalence +(def .public equivalence (Equivalence Side) (at ..hash equivalence)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/simple.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/simple.lux index 343619a25..3774c0319 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/simple.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/simple.lux @@ -26,7 +26,7 @@ {#F64 Frac} {#Text Text})) -(def: .public (format it) +(def .public (format it) (%.Format Simple) (case it (^.with_template [<pattern> <format>] @@ -39,10 +39,10 @@ {#I64 value} (%.int (.int value)))) -(def: .public equivalence +(def .public equivalence (Equivalence Simple) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] (^.with_template [<tag> <eq> <format>] [[{<tag> reference'} {<tag> sample'}] @@ -57,12 +57,12 @@ _ false)))) -(def: .public hash +(def .public hash (Hash Simple) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: hash + (def hash (|>> (pipe.case (^.with_template [<factor> <tag> <hash>] [{<tag> value'} diff --git a/stdlib/source/library/lux/tool/compiler/meta.lux b/stdlib/source/library/lux/tool/compiler/meta.lux index 4034a23c8..ef6e71986 100644 --- a/stdlib/source/library/lux/tool/compiler/meta.lux +++ b/stdlib/source/library/lux/tool/compiler/meta.lux @@ -4,6 +4,6 @@ [// [version (.only Version)]]) -(def: .public version +(def .public version Version 00,02,00) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/archive.lux index bdb87cb95..b3b213099 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive.lux @@ -76,16 +76,16 @@ [#next module.ID #resolver (Dictionary descriptor.Module [module.ID (Maybe (Entry Any))])]) - (def: next + (def next (-> Archive module.ID) (|>> representation (the #next))) - (def: .public empty + (def .public empty Archive (abstraction [#next 0 #resolver (dictionary.empty text.hash)])) - (def: .public (id module archive) + (def .public (id module archive) (-> descriptor.Module Archive (Try module.ID)) (let [(open "/[0]") (representation archive)] (case (dictionary.value module /#resolver) @@ -96,7 +96,7 @@ (exception.except ..unknown_document [module (dictionary.keys /#resolver)])))) - (def: .public (reserve module archive) + (def .public (reserve module archive) (-> descriptor.Module Archive (Try [module.ID Archive])) (let [(open "/[0]") (representation archive)] (case (dictionary.value module /#resolver) @@ -111,7 +111,7 @@ (revised #next ++) abstraction)]}))) - (def: .public (has module entry archive) + (def .public (has module entry archive) (-> descriptor.Module (Entry Any) Archive (Try Archive)) (let [(open "/[0]") (representation archive)] (case (dictionary.value module /#resolver) @@ -131,7 +131,7 @@ {.#None} (exception.except ..module_must_be_reserved_before_it_can_be_added [module])))) - (def: .public entries + (def .public entries (-> Archive (List [descriptor.Module [module.ID (Entry Any)]])) (|>> representation (the #resolver) @@ -139,7 +139,7 @@ (list.all (function (_ [module [module_id entry]]) (at maybe.monad each (|>> [module_id] [module]) entry))))) - (def: .public (find module archive) + (def .public (find module archive) (-> descriptor.Module Archive (Try (Entry Any))) (let [(open "/[0]") (representation archive)] (case (dictionary.value module /#resolver) @@ -152,7 +152,7 @@ {.#None} (exception.except ..unknown_document [module (dictionary.keys /#resolver)])))) - (def: .public (archived? archive module) + (def .public (archived? archive module) (-> Archive descriptor.Module Bit) (case (..find module archive) {try.#Success _} @@ -161,7 +161,7 @@ {try.#Failure _} false)) - (def: .public archived + (def .public archived (-> Archive (List descriptor.Module)) (|>> representation (the #resolver) @@ -171,7 +171,7 @@ {.#Some _} {.#Some module} {.#None} {.#None}))))) - (def: .public (reserved? archive module) + (def .public (reserved? archive module) (-> Archive descriptor.Module Bit) (let [(open "/[0]") (representation archive)] (case (dictionary.value module /#resolver) @@ -181,13 +181,13 @@ {.#None} false))) - (def: .public reserved + (def .public reserved (-> Archive (List descriptor.Module)) (|>> representation (the #resolver) dictionary.keys)) - (def: .public reservations + (def .public reservations (-> Archive (List [descriptor.Module module.ID])) (|>> representation (the #resolver) @@ -195,7 +195,7 @@ (list#each (function (_ [module [id _]]) [module id])))) - (def: .public (composite additions archive) + (def .public (composite additions archive) (-> Archive Archive Archive) (let [[+next +resolver] (representation additions)] (|> archive @@ -219,21 +219,21 @@ (type: Frozen [Version module.ID (List Reservation)]) - (def: reader + (def reader (Parser ..Frozen) (all <>.and <binary>.nat <binary>.nat (<binary>.list (<>.and <binary>.text <binary>.nat)))) - (def: writer + (def writer (Writer ..Frozen) (all \\format.and \\format.nat \\format.nat (\\format.list (\\format.and \\format.text \\format.nat)))) - (def: .public (export version archive) + (def .public (export version archive) (-> Version Archive Binary) (let [(open "/[0]") (representation archive)] (|> /#resolver @@ -251,7 +251,7 @@ "Expected" (%.nat expected) "Actual" (%.nat actual))) - (def: .public (import expected binary) + (def .public (import expected binary) (-> Version Binary (Try Archive)) (do try.monad [[actual next reservations] (<binary>.result ..reader binary) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux index f66a0a42f..252776c37 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux @@ -23,7 +23,7 @@ #category Category #mandatory? Bit])) -(def: .public equivalence +(def .public equivalence (Equivalence Artifact) (all product.equivalence nat.equivalence diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact/category.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact/category.lux index 9e00a5b51..d9801694c 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact/category.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact/category.lux @@ -19,7 +19,7 @@ (type: .public Definition [Text (Maybe [Arity [Nat Nat]])]) -(def: .public definition_equivalence +(def .public definition_equivalence (Equivalence Definition) (all product.equivalence text.equivalence @@ -40,10 +40,10 @@ {#Directive Text} {#Custom Text})) -(def: .public equivalence +(def .public equivalence (Equivalence Category) (implementation - (def: (= left right) + (def (= left right) (case [left right] [{#Anonymous} {#Anonymous}] true diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/key.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/key.lux index 445e44c72..0e35d6528 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/key.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/key.lux @@ -9,11 +9,11 @@ (primitive .public (Key k) Signature - (def: .public signature + (def .public signature (All (_ ?) (-> (Key ?) Signature)) (|>> representation)) - (def: .public (key signature sample) + (def .public (key signature sample) (All (_ d) (-> Signature d (Key d))) (abstraction signature)) ) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/module.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/module.lux index 868009871..4e2757bb8 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/module.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/module.lux @@ -8,7 +8,7 @@ (type: .public ID Nat) -(def: .public runtime +(def .public runtime ID 0) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/module/descriptor.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/module/descriptor.lux index b661a1587..92e8dcc60 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/module/descriptor.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/module/descriptor.lux @@ -24,7 +24,7 @@ (type: .public Module Text) -(def: .public runtime +(def .public runtime Module "") @@ -36,10 +36,10 @@ #state Module_State #references (Set Module)])) -(def: module_state_equivalence +(def module_state_equivalence (Equivalence Module_State) (implementation - (def: (= left right) + (def (= left right) (case [left right] (^.with_template [<tag>] [[{<tag>} {<tag>}] @@ -51,7 +51,7 @@ _ false)))) -(def: .public equivalence +(def .public equivalence (Equivalence Descriptor) (all product.equivalence text.equivalence @@ -61,7 +61,7 @@ set.equivalence )) -(def: .public writer +(def .public writer (Writer Descriptor) (all \\format.and \\format.text @@ -71,7 +71,7 @@ (\\format.set \\format.text) )) -(def: .public parser +(def .public parser (Parser Descriptor) (all <>.and <binary>.text diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/module/document.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/module/document.lux index 56dd787be..fe4977e8d 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/module/document.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/module/document.lux @@ -30,7 +30,7 @@ [#signature Signature #content d]) - (def: .public (content key document) + (def .public (content key document) (All (_ d) (-> (Key d) (Document Any) (Try d))) (let [[document//signature document//content] (representation document)] (if (at signature.equivalence = @@ -44,29 +44,29 @@ (exception.except ..invalid_signature [(key.signature key) document//signature])))) - (def: .public (document key content) + (def .public (document key content) (All (_ d) (-> (Key d) d (Document d))) (abstraction [#signature (key.signature key) #content content])) - (def: .public (marked? key document) + (def .public (marked? key document) (All (_ d) (-> (Key d) (Document Any) (Try (Document d)))) (do try.monad [_ (..content key document)] (in (as_expected document)))) - (def: .public signature + (def .public signature (-> (Document Any) Signature) (|>> representation (the #signature))) - (def: .public (writer content) + (def .public (writer content) (All (_ d) (-> (Writer d) (Writer (Document d)))) (let [writer (all binary.and signature.writer content)] (|>> representation writer))) - (def: .public (parser key it) + (def .public (parser key it) (All (_ d) (-> (Key d) (Parser d) (Parser (Document d)))) (do <>.monad [actual signature.parser diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/registry.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/registry.lux index 09cfc1190..9f23cad2e 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/registry.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/registry.lux @@ -34,20 +34,20 @@ [#artifacts (Sequence [Artifact (Set unit.ID)]) #resolver (Dictionary Text [ID (Maybe //category.Definition)])]) - (def: .public empty + (def .public empty Registry (abstraction [#artifacts sequence.empty #resolver (dictionary.empty text.hash)])) - (def: .public artifacts + (def .public artifacts (-> Registry (Sequence [Artifact (Set unit.ID)])) (|>> representation (the #artifacts))) - (def: next + (def next (-> Registry ID) (|>> ..artifacts sequence.size)) - (def: .public (resource mandatory? dependencies registry) + (def .public (resource mandatory? dependencies registry) (-> Bit (Set unit.ID) Registry [ID Registry]) (let [id (..next registry)] [id @@ -60,7 +60,7 @@ abstraction)])) (with_template [<tag> <create> <fetch> <type> <name> <+resolver>] - [(def: .public (<create> it mandatory? dependencies registry) + [(def .public (<create> it mandatory? dependencies registry) (-> <type> Bit (Set unit.ID) Registry [ID Registry]) (let [id (..next registry)] [id @@ -73,7 +73,7 @@ (revised #resolver (dictionary.has (<name> it) [id (is (Maybe //category.Definition) <+resolver>)])) abstraction)])) - (def: .public (<fetch> registry) + (def .public (<fetch> registry) (-> Registry (List <type>)) (|> registry representation @@ -94,17 +94,17 @@ [//category.#Custom custom customs Text |> {.#None}] ) - (def: .public (find_definition name registry) + (def .public (find_definition name registry) (-> Text Registry (Maybe [ID (Maybe //category.Definition)])) (|> (representation registry) (the #resolver) (dictionary.value name))) - (def: .public (id name registry) + (def .public (id name registry) (-> Text Registry (Maybe ID)) (maybe#each product.left (find_definition name registry))) - (def: .public writer + (def .public writer (Writer Registry) (let [definition (is (Writer //category.Definition) (all binary.and @@ -148,7 +148,7 @@ (exception.report "Tag" (%.nat tag))) - (def: .public parser + (def .public parser (Parser Registry) (let [definition (is (Parser //category.Definition) (all <>.and diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux index ac6a22c49..075e12c77 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux @@ -25,23 +25,23 @@ [#name Symbol #version Version])) -(def: .public equivalence +(def .public equivalence (Equivalence Signature) (all product.equivalence symbol.equivalence nat.equivalence)) -(def: .public (description signature) +(def .public (description signature) (-> Signature Text) (format (%.symbol (the #name signature)) " " (version.format (the #version signature)))) -(def: .public writer +(def .public writer (Writer Signature) (all binary.and (binary.and binary.text binary.text) binary.nat)) -(def: .public parser +(def .public parser (Parser Signature) (all <>.and (<>.and <binary>.text <binary>.text) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/unit.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/unit.lux index 9ce35e1b5..937f87043 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/unit.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/unit.lux @@ -22,21 +22,21 @@ [#module module.ID #artifact artifact.ID])) -(def: .public hash +(def .public hash (Hash ID) (all product.hash nat.hash nat.hash)) -(def: .public equivalence +(def .public equivalence (Equivalence ID) (at ..hash equivalence)) -(def: .public none +(def .public none (Set ID) (set.empty ..hash)) -(def: .public (format it) +(def .public (format it) (%.Format ID) (%.format (%.nat (the #module it)) "." diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache.lux b/stdlib/source/library/lux/tool/compiler/meta/cache.lux index 15cdef528..0ebd1e7d5 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache.lux @@ -15,18 +15,18 @@ [// ["[0]" version]]]) -(def: .public (path fs context) +(def .public (path fs context) (All (_ !) (-> (file.System !) Context file.Path)) (let [/ (at fs separator)] (format (the context.#target context) / (the context.#host context) / (version.format //.version)))) -(def: .public (enabled? fs context) +(def .public (enabled? fs context) (All (_ !) (-> (file.System !) Context (! Bit))) (at fs directory? (..path fs context))) -(def: .public (enable! ! fs context) +(def .public (enable! ! fs context) (All (_ !) (-> (Monad !) (file.System !) Context (! (Try Any)))) (do ! [? (..enabled? fs context)] diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/archive.lux index 4710ce851..8876e3e77 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/archive.lux @@ -13,12 +13,12 @@ [context (.only Context)] ["[0]" archive (.only Archive)]]]) -(def: .public (descriptor fs context) +(def .public (descriptor fs context) (All (_ !) (-> (file.System !) Context file.Path)) (%.format (//.path fs context) (at fs separator) "descriptor")) -(def: .public (cache! fs context it) +(def .public (cache! fs context it) (All (_ !) (-> (file.System !) Context Archive (! (Try Any)))) (at fs write (..descriptor fs context) (archive.export ///.version it))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/artifact.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/artifact.lux index 8494dba2c..69c131082 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/artifact.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/artifact.lux @@ -20,7 +20,7 @@ ["[0]" module] ["[0]" artifact]]]]) -(def: .public (path fs context @module @artifact) +(def .public (path fs context @module @artifact) (All (_ !) (-> (file.System !) Context module.ID artifact.ID file.Path)) (format (//module.path fs context @module) @@ -28,12 +28,12 @@ (%.nat @artifact) (the context.#artifact_extension context))) -(def: .public (cache fs context @module @artifact) +(def .public (cache fs context @module @artifact) (All (_ !) (-> (file.System !) Context module.ID artifact.ID (! (Try Binary)))) (at fs read (..path fs context @module @artifact))) -(def: .public (cache! fs context @module @artifact content) +(def .public (cache! fs context @module @artifact content) (All (_ !) (-> (file.System !) Context module.ID artifact.ID Binary (! (Try Any)))) (at fs write (..path fs context @module @artifact) content)) diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/artifact.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/artifact.lux index 373696de2..5640bdd7e 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/artifact.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/artifact.lux @@ -35,7 +35,7 @@ ["[0]" registry (.only Registry)] ["[0]" unit]]]]]]]) -(def: (path_references references) +(def (path_references references) (-> (-> Synthesis (List Constant)) (-> Path (List Constant))) (function (again path) @@ -75,7 +75,7 @@ {synthesis.#Then then} (references then)))) -(def: (references value) +(def (references value) (-> Synthesis (List Constant)) (case value {synthesis.#Simple value} @@ -162,7 +162,7 @@ (list#each references) list#conjoint))) -(def: .public (dependencies archive value) +(def .public (dependencies archive value) (All (_ anchor expression directive) (-> Archive Synthesis (Operation anchor expression directive (Set unit.ID)))) (let [! phase.monad] @@ -173,7 +173,7 @@ (monad.each ! (generation.remember archive)) (at ! each (set.of_list unit.hash))))) -(def: .public (path_dependencies archive value) +(def .public (path_dependencies archive value) (All (_ anchor expression directive) (-> Archive Path (Operation anchor expression directive (Set unit.ID)))) (let [! phase.monad] @@ -184,12 +184,12 @@ (monad.each ! (generation.remember archive)) (at ! each (set.of_list unit.hash))))) -(def: .public all +(def .public all (-> (List (Set unit.ID)) (Set unit.ID)) (list#mix set.union unit.none)) -(def: (immediate_dependencies archive) +(def (immediate_dependencies archive) (-> Archive [(List unit.ID) (Dictionary unit.ID (Set unit.ID))]) (|> archive @@ -213,7 +213,7 @@ [(list) (dictionary.empty unit.hash)]))) -(def: .public (necessary_dependencies archive) +(def .public (necessary_dependencies archive) (-> Archive (Set unit.ID)) (let [[mandatory immediate] (immediate_dependencies archive)] (loop (again [pending mandatory diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/module.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/module.lux index 5cad8e963..bdb09274d 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/module.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/module.lux @@ -26,18 +26,18 @@ (type: .public Ancestry (Set descriptor.Module)) -(def: fresh +(def fresh Ancestry (set.empty text.hash)) (type: .public Graph (Dictionary descriptor.Module Ancestry)) -(def: empty +(def empty Graph (dictionary.empty text.hash)) -(def: .public modules +(def .public modules (-> Graph (List descriptor.Module)) dictionary.keys) @@ -46,13 +46,13 @@ [#module descriptor.Module #imports Ancestry])) -(def: .public graph +(def .public graph (-> (List Dependency) Graph) (list#mix (function (_ [module imports] graph) (dictionary.has module imports graph)) ..empty)) -(def: (ancestry archive) +(def (ancestry archive) (-> Archive Graph) (let [memo (is (Memo descriptor.Module Ancestry) (function (_ again module) @@ -74,7 +74,7 @@ ..empty (archive.archived archive)))) -(def: (dependency? ancestry target source) +(def (dependency? ancestry target source) (-> Graph descriptor.Module descriptor.Module Bit) (let [target_ancestry (|> ancestry (dictionary.value target) @@ -84,7 +84,7 @@ (type: .public (Order a) (List [descriptor.Module [module.ID (archive.Entry a)]])) -(def: .public (load_order key archive) +(def .public (load_order key archive) (All (_ a) (-> (Key a) Archive (Try (Order a)))) (let [ancestry (..ancestry archive)] (|> ancestry diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/module.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/module.lux index 59c7f5b50..ea6c1a660 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/module.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/module.lux @@ -32,17 +32,17 @@ "Module ID" (%.nat @module) "Error" error)) -(def: .public (path fs context @module) +(def .public (path fs context @module) (All (_ !) (-> (file.System !) Context module.ID file.Path)) (format (//.path fs context) (at fs separator) (%.nat @module))) -(def: .public (enabled? fs context @module) +(def .public (enabled? fs context @module) (All (_ !) (-> (file.System !) Context module.ID (! Bit))) (at fs directory? (..path fs context @module))) -(def: .public (enable! ! fs context @module) +(def .public (enable! ! fs context @module) (All (_ !) (-> (Monad !) (file.System !) Context module.ID (! (Try Any)))) (do ! [.let [path (..path fs context @module)] @@ -68,25 +68,25 @@ success success)))))))))) -(def: file +(def file file.Path "descriptor") -(def: .public (descriptor fs context @module) +(def .public (descriptor fs context @module) (All (_ !) (-> (file.System !) Context module.ID file.Path)) (format (..path fs context @module) (at fs separator) ..file)) -(def: .public (cache! fs context @module content) +(def .public (cache! fs context @module content) (All (_ !) (-> (file.System !) Context module.ID Binary (! (Try Any)))) (at fs write (..descriptor fs context @module) content)) -(def: .public (cache fs context @module) +(def .public (cache fs context @module) (All (_ !) (-> (file.System !) Context module.ID (! (Try Binary)))) (at fs read (..descriptor fs context @module))) -(def: .public (artifacts ! fs context @module) +(def .public (artifacts ! fs context @module) (All (_ !) (-> (Monad !) (file.System !) Context module.ID (! (Try (Dictionary Text Binary))))) (do [! (try.with !)] [files (at fs directory_files (..path fs context @module)) diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/purge.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/purge.lux index addb97821..d538861e6 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/purge.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/purge.lux @@ -38,7 +38,7 @@ (Dictionary descriptor.Module module.ID)) ... TODO: Make the monad parameterizable. -(def: .public (purge! fs context @module) +(def .public (purge! fs context @module) (-> (file.System Async) Context module.ID (Async (Try Any))) (do [! (try.with async.monad)] [.let [cache (//module.path fs context @module)] @@ -48,7 +48,7 @@ (at ! conjoint))] (at fs delete cache))) -(def: .public (valid? expected actual) +(def .public (valid? expected actual) (-> Descriptor Input Bit) (and (text#= (the descriptor.#name expected) (the ////.#module actual)) @@ -57,7 +57,7 @@ (n.= (the descriptor.#hash expected) (the ////.#hash actual)))) -(def: initial +(def initial (-> (List Cache) Purge) (|>> (list.all (function (_ [valid? module_name @module _]) (if valid? @@ -65,7 +65,7 @@ {.#Some [module_name @module]}))) (dictionary.of_list text.hash))) -(def: .public (purge caches load_order) +(def .public (purge caches load_order) (-> (List Cache) (dependency.Order Any) Purge) (list#mix (function (_ [module_name [@module entry]] purge) (let [purged? (is (Predicate descriptor.Module) diff --git a/stdlib/source/library/lux/tool/compiler/meta/cli.lux b/stdlib/source/library/lux/tool/compiler/meta/cli.lux index ea10958bd..76c30f475 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cli.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cli.lux @@ -71,7 +71,7 @@ {#Export Export})) (with_template [<name> <long> <type> <parser>] - [(def: <name> + [(def <name> (Parser <type>) (<cli>.named <long> <parser>))] @@ -84,7 +84,7 @@ [configuration_parser "--configuration" Configuration (<text>.then configuration.parser <cli>.any)] ) -(def: .public service +(def .public service (Parser Service) (let [compilation (is (Parser Compilation) (all <>.and @@ -106,7 +106,7 @@ ..target_parser)) ))) -(def: .public target +(def .public target (-> Service Target) (|>> (pipe.case (^.or {#Compilation [host_dependencies libraries compilers sources target module]} diff --git a/stdlib/source/library/lux/tool/compiler/meta/cli/compiler.lux b/stdlib/source/library/lux/tool/compiler/meta/cli/compiler.lux index 40ee7afe4..e8c4196dd 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cli/compiler.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cli/compiler.lux @@ -23,7 +23,7 @@ [#definition Symbol #parameters (List Text)])) -(def: .public equivalence +(def .public equivalence (Equivalence Compiler) (all product.equivalence symbol.equivalence @@ -31,7 +31,7 @@ )) (with_template [<ascii> <name>] - [(def: <name> + [(def <name> Text (text.of_char (hex <ascii>)))] @@ -39,16 +39,16 @@ ["03" end] ) -(def: parameter +(def parameter (-> Text Text) (text.enclosed [..start ..end])) -(def: .public (format [[module short] parameters]) +(def .public (format [[module short] parameters]) (%.Format Compiler) (%.format (..parameter module) (..parameter short) (text.together (list#each ..parameter parameters)))) -(def: .public parser +(def .public parser (Parser Compiler) (let [parameter (is (Parser Text) (<| (<>.after (<text>.this ..start)) diff --git a/stdlib/source/library/lux/tool/compiler/meta/context.lux b/stdlib/source/library/lux/tool/compiler/meta/context.lux index cfacb3fe9..a2126c773 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/context.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/context.lux @@ -16,7 +16,7 @@ #artifact_extension Extension])) (with_template [<name> <host> <host_module_extension> <artifact_extension>] - [(def: .public (<name> target) + [(def .public (<name> target) (-> Path Context) [#host <host> #host_module_extension <host_module_extension> diff --git a/stdlib/source/library/lux/tool/compiler/meta/export.lux b/stdlib/source/library/lux/tool/compiler/meta/export.lux index 2871ecf8e..aab3dae55 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/export.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/export.lux @@ -28,16 +28,16 @@ [world ["[0]" file]]]]) -(def: .public file +(def .public file "library.tar") -(def: .public mode +(def .public mode (all tar.and tar.read_by_owner tar.write_by_owner tar.read_by_group tar.write_by_group tar.read_by_other)) -(def: .public ownership +(def .public ownership tar.Ownership (let [commons (is tar.Owner [tar.#name tar.anonymous @@ -45,7 +45,7 @@ [tar.#user commons tar.#group commons])) -(def: .public (library fs sources) +(def .public (library fs sources) (-> (file.System Async) (List Source) (Async (Try tar.Tar))) (|> sources (io.listing fs) @@ -65,7 +65,7 @@ (try#each sequence.of_list))) try#conjoint)))) -(def: .public (export fs [sources target]) +(def .public (export fs [sources target]) (-> (file.System Async) Export (Async (Try Any))) (do [! (try.with async.monad)] [tar (|> sources diff --git a/stdlib/source/library/lux/tool/compiler/meta/import.lux b/stdlib/source/library/lux/tool/compiler/meta/import.lux index dec6dde3b..d653afbac 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/import.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/import.lux @@ -26,7 +26,7 @@ [world ["[0]" file]]]]) -(def: Action +(def Action (type (All (_ a) (Async (Try a))))) (exception: .public useless_tar_entry) @@ -40,7 +40,7 @@ (type: .public Import (Dictionary file.Path Binary)) -(def: (import_library system library import) +(def (import_library system library import) (-> (file.System Async) Library Import (Action Import)) (let [! async.monad] (|> library @@ -65,7 +65,7 @@ import))) (at ! conjoint))))))) -(def: .public (import system libraries) +(def .public (import system libraries) (-> (file.System Async) (List Library) (Action Import)) (monad.mix (is (Monad Action) (try.with async.monad)) diff --git a/stdlib/source/library/lux/tool/compiler/meta/io.lux b/stdlib/source/library/lux/tool/compiler/meta/io.lux index efbdb599d..374e71ef3 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io.lux @@ -12,10 +12,10 @@ (type: .public Code Text) -(def: .public (safe system) +(def .public (safe system) (All (_ m) (-> (System m) Text Text)) (text.replaced "/" (at system separator))) -(def: .public lux_context +(def .public lux_context Context "lux") diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux index a192cf58a..2cef8ada4 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux @@ -56,7 +56,7 @@ ["[0]" directive] ["[1]/[0]" program]]]]]]) -(def: (module_parser key parser) +(def (module_parser key parser) (All (_ document) (-> (Key document) (Parser document) (Parser (module.Module document)))) (all <>.and @@ -64,18 +64,18 @@ descriptor.parser (document.parser key parser))) -(def: (parser key parser) +(def (parser key parser) (All (_ document) (-> (Key document) (Parser document) (Parser [(module.Module document) Registry]))) (all <>.and (..module_parser key parser) registry.parser)) -(def: (fresh_analysis_state host configuration) +(def (fresh_analysis_state host configuration) (-> Target Configuration .Lux) (analysis.state (analysis.info version.latest host configuration))) -(def: (analysis_state host configuration archive) +(def (analysis_state host configuration archive) (-> Target Configuration Archive (Try .Lux)) (do [! try.monad] [modules (is (Try (List [descriptor.Module .Module])) @@ -101,14 +101,14 @@ Generators Directives]) -(def: empty_bundles +(def empty_bundles Bundles [(dictionary.empty text.hash) (dictionary.empty text.hash) (dictionary.empty text.hash) (dictionary.empty text.hash)]) -(def: (loaded_document extension host @module expected actual document) +(def (loaded_document extension host @module expected actual document) (All (_ expression directive) (-> Text (generation.Host expression directive) module.ID (Sequence [Artifact (Set unit.ID)]) (Dictionary Text Binary) (Document .Module) (Try [(Document .Module) Bundles Output]))) @@ -246,7 +246,7 @@ (in [(document.document $.key (has .#definitions definitions content)) bundles]))) -(def: (load_definitions fs context @module host_environment entry) +(def (load_definitions fs context @module host_environment entry) (All (_ expression directive) (-> (file.System Async) Context module.ID (generation.Host expression directive) (archive.Entry .Module) @@ -263,11 +263,11 @@ (has archive.#output output)) bundles]))) -(def: pseudo_module +(def pseudo_module Text "(Lux Caching System)") -(def: (cache_parser customs) +(def (cache_parser customs) (-> (List Custom) (Parser [(module.Module Any) Registry])) (case (for @.old (as (List (Custom Any Any Any)) customs) @@ -281,7 +281,7 @@ (cache_parser tail) ))) -(def: (valid_cache customs fs context import contexts [module_name @module]) +(def (valid_cache customs fs context import contexts [module_name @module]) (-> (List Custom) (file.System Async) Context Import (List //.Context) [descriptor.Module module.ID] (Async (Try Cache))) @@ -296,7 +296,7 @@ [input (//context.read fs ..pseudo_module import contexts (the context.#host_module_extension context) module_name)] (in [(cache/purge.valid? (the module.#descriptor module) input) <cache>])))))) -(def: (pre_loaded_caches customs fs context import contexts archive) +(def (pre_loaded_caches customs fs context import contexts archive) (-> (List Custom) (file.System Async) Context Import (List //.Context) Archive (Async (Try (List Cache)))) (do [! (try.with async.monad)] @@ -306,7 +306,7 @@ (monad.each ! (..valid_cache customs fs context import contexts)))] (in it))) -(def: (load_order archive pre_loaded_caches) +(def (load_order archive pre_loaded_caches) (-> Archive (List Cache) (Try (dependency.Order .Module))) (|> pre_loaded_caches @@ -321,7 +321,7 @@ (at try.monad each (dependency.load_order $.key)) (at try.monad conjoint))) -(def: (loaded_caches host_environment fs context purge load_order) +(def (loaded_caches host_environment fs context purge load_order) (All (_ expression directive) (-> (generation.Host expression directive) (file.System Async) Context Purge (dependency.Order .Module) @@ -343,7 +343,7 @@ <it>)))))))] (in it))) -(def: (load_every_reserved_module customs configuration host_environment fs context import contexts archive) +(def (load_every_reserved_module customs configuration host_environment fs context import contexts archive) (All (_ expression directive) (-> (List Custom) Configuration (generation.Host expression directive) (file.System Async) Context Import (List //.Context) Archive (Async (Try [Archive .Lux Bundles])))) @@ -374,7 +374,7 @@ ..empty_bundles loaded_caches)]))))) -(def: .public (thaw customs configuration host_environment fs context import contexts) +(def .public (thaw customs configuration host_environment fs context import contexts) (All (_ expression directive) (-> (List Custom) Configuration (generation.Host expression directive) (file.System Async) Context Import (List //.Context) (Async (Try [Archive .Lux Bundles])))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux index 6845f5cce..e79b60e7b 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux @@ -43,17 +43,17 @@ (type: .public Extension Text) -(def: .public lux_extension +(def .public lux_extension Extension ".lux") -(def: .public (path fs context module) +(def .public (path fs context module) (All (_ m) (-> (file.System m) Context Module file.Path)) (|> module (//.safe fs) (format context (at fs separator)))) -(def: (find_source_file fs importer contexts module extension) +(def (find_source_file fs importer contexts module extension) (-> (file.System Async) Module (List Context) Module Extension (Async (Try file.Path))) (case contexts @@ -68,11 +68,11 @@ (in {try.#Success path}) (find_source_file fs importer contexts' module extension)))))) -(def: (full_host_extension partial_host_extension) +(def (full_host_extension partial_host_extension) (-> Extension Extension) (format partial_host_extension ..lux_extension)) -(def: (find_local_source_file fs importer import contexts partial_host_extension module) +(def (find_local_source_file fs importer import contexts partial_host_extension module) (-> (file.System Async) Module Import (List Context) Extension Module (Async (Try [file.Path Binary]))) ... Preference is explicitly being given to Lux files that have a host extension. @@ -92,7 +92,7 @@ (at fs read) (at ! each (|>> [path]))))))) -(def: (find_library_source_file importer import partial_host_extension module) +(def (find_library_source_file importer import partial_host_extension module) (-> Module Import Extension Module (Try [file.Path Binary])) (let [path (format module (..full_host_extension partial_host_extension))] (case (dictionary.value path import) @@ -108,7 +108,7 @@ {.#None} (exception.except ..cannot_find_module [importer module])))))) -(def: (find_any_source_file fs importer import contexts partial_host_extension module) +(def (find_any_source_file fs importer import contexts partial_host_extension module) (-> (file.System Async) Module Import (List Context) Extension Module (Async (Try [file.Path Binary]))) ... Preference is explicitly being given to Lux files that have a host extension. @@ -122,7 +122,7 @@ {try.#Failure _} (in (..find_library_source_file importer import partial_host_extension module))))) -(def: .public (read fs importer import contexts partial_host_extension module) +(def .public (read fs importer import contexts partial_host_extension module) (-> (file.System Async) Module Import (List Context) Extension Module (Async (Try Input))) (do (try.with async.monad) @@ -140,7 +140,7 @@ (type: .public Enumeration (Dictionary file.Path Binary)) -(def: (context_listing fs context directory enumeration) +(def (context_listing fs context directory enumeration) (-> (file.System Async) Context file.Path Enumeration (Async (Try Enumeration))) (do [! (try.with async.monad)] [enumeration (|> directory @@ -158,10 +158,10 @@ (at ! each (monad.mix ! (context_listing fs context) enumeration)) (at ! conjoint)))) -(def: Action +(def Action (type (All (_ a) (Async (Try a))))) -(def: (canonical fs context) +(def (canonical fs context) (-> (file.System Async) Context (Action Context)) (do (try.with async.monad) [subs (at fs sub_directories context)] @@ -171,7 +171,7 @@ (file.parent fs) (maybe.else context))))) -(def: .public (listing fs contexts) +(def .public (listing fs contexts) (-> (file.System Async) (List Context) (Action Enumeration)) (let [! (is (Monad Action) (try.with async.monad))] diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager.lux b/stdlib/source/library/lux/tool/compiler/meta/packager.lux index 1543e082f..759cb26a5 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager.lux @@ -33,7 +33,7 @@ (type: .public Order (List [module.ID (List artifact.ID)])) -(def: .public order +(def .public order (-> (cache/module.Order Any) Order) (list#each (function (_ [module [module_id entry]]) (|> entry diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux index 47fb81088..ddc522426 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux @@ -118,21 +118,21 @@ (new [java/io/InputStream]) (getNextJarEntry [] "try" "?" java/util/jar/JarEntry)) -(def: byte +(def byte 1) ... https://en.wikipedia.org/wiki/Kibibyte -(def: kibi_byte +(def kibi_byte (n.* 1,024 byte)) ... https://en.wikipedia.org/wiki/Mebibyte -(def: mebi_byte +(def mebi_byte (n.* 1,024 kibi_byte)) -(def: manifest_version +(def manifest_version "1.0") -(def: (manifest program) +(def (manifest program) (-> (Maybe unit.ID) java/util/jar/Manifest) (let [manifest (java/util/jar/Manifest::new) attrs (do_to (java/util/jar/Manifest::getMainAttributes manifest) @@ -153,7 +153,7 @@ attrs) manifest))) -(def: (write_class static module artifact custom content sink) +(def (write_class static module artifact custom content sink) (-> Context module.ID artifact.ID (Maybe Text) Binary java/util/jar/JarOutputStream (Try java/util/jar/JarOutputStream)) (let [class_path (|> custom @@ -169,7 +169,7 @@ (java/io/Flushable::flush) (java/util/zip/ZipOutputStream::closeEntry)))))) -(def: (write_module static necessary_dependencies [module output] sink) +(def (write_module static necessary_dependencies [module output] sink) (-> Context (Set unit.ID) [module.ID Output] java/util/jar/JarOutputStream (Try java/util/jar/JarOutputStream)) (let [! try.monad] @@ -181,7 +181,7 @@ sink (sequence.list output)))) -(def: (read_jar_entry_with_unknown_size input) +(def (read_jar_entry_with_unknown_size input) (-> java/util/jar/JarInputStream [Nat Binary]) (let [chunk (binary.empty ..mebi_byte) chunk_size (.int ..mebi_byte) @@ -197,7 +197,7 @@ (java/io/OutputStream::write chunk (ffi.as_int +0) (ffi.as_int bytes_read) buffer) (again (|> bytes_read .nat (n.+ so_far)))))))) -(def: (read_jar_entry_with_known_size expected_size input) +(def (read_jar_entry_with_known_size expected_size input) (-> Nat java/util/jar/JarInputStream [Nat Binary]) (let [buffer (binary.empty expected_size)] (loop (again [so_far 0]) @@ -210,7 +210,7 @@ [expected_size buffer] (again so_far')))))) -(def: (read_jar_entry entry input) +(def (read_jar_entry entry input) (-> java/util/jar/JarEntry java/util/jar/JarInputStream [Nat Binary]) (case (ffi.of_long (java/util/zip/ZipEntry::getSize entry)) -1 @@ -219,7 +219,7 @@ entry_size (..read_jar_entry_with_known_size (.nat entry_size) input))) -(def: (write_host_dependency jar [entries duplicates sink]) +(def (write_host_dependency jar [entries duplicates sink]) (-> Binary [(Set file.Path) (Set file.Path) java/util/jar/JarOutputStream] (Try [(Set file.Path) (Set file.Path) java/util/jar/JarOutputStream])) @@ -267,7 +267,7 @@ duplicates sink)))))))) -(def: .public (package static) +(def .public (package static) (-> Context Packager) (function (_ host_dependencies archive program) (do [! try.monad] diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux index 0937615cc..cc5938094 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux @@ -44,7 +44,7 @@ [language ["$" lux]]]]]) -(def: (bundle_module module module_id necessary_dependencies output) +(def (bundle_module module module_id necessary_dependencies output) (-> descriptor.Module module.ID (Set unit.ID) Output (Try (Maybe _.Statement))) (do [! try.monad] [] @@ -73,11 +73,11 @@ artifacts)] (in {.#Some bundle}))))) -(def: module_file +(def module_file (-> module.ID file.Path) (|>> %.nat (text.suffix ".rb"))) -(def: (write_module mapping necessary_dependencies [module [module_id entry]] sink) +(def (write_module mapping necessary_dependencies [module [module_id entry]] sink) (-> (Dictionary descriptor.Module module.ID) (Set unit.ID) [descriptor.Module [module.ID (archive.Entry .Module)]] (List [module.ID [Text Binary]]) @@ -98,21 +98,21 @@ (in (list.partial [module_id [(..module_file module_id) entry_content]] sink)))))) -(def: .public main_file +(def .public main_file "main.rb") -(def: module_id_mapping +(def module_id_mapping (-> (Order .Module) (Dictionary descriptor.Module module.ID)) (|>> (list#each (function (_ [module [module_id entry]]) [module module_id])) (dictionary.of_list text.hash))) -(def: included_modules +(def included_modules (All (_ a) (-> (List [module.ID a]) (Set module.ID))) (|>> (list#each product.left) (list#mix set.has (set.empty nat.hash)))) -(def: .public (package host_dependencies archive program) +(def .public (package host_dependencies archive program) Packager (do [! try.monad] [.let [necessary_dependencies (cache/artifact.necessary_dependencies archive)] diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux index 1fed07990..70f595ff4 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux @@ -48,13 +48,13 @@ (type: (Action ! a) (! (Try a))) -(def: (then pre post) +(def (then pre post) (-> _.Expression _.Expression _.Expression) (_.manual (format (_.code pre) text.new_line (_.code post)))) -(def: bundle_module +(def bundle_module (-> Output (Try _.Expression)) (|>> sequence.list (list#each product.right) @@ -71,11 +71,11 @@ (..then so_far))))) (is _.Expression (_.manual ""))))) -(def: module_file +(def module_file (-> archive.ID file.Path) (|>> %.nat (text.suffix ".scm"))) -(def: mode +(def mode tar.Mode (all tar.and tar.read_by_group @@ -85,16 +85,16 @@ tar.write_by_group tar.write_by_owner)) -(def: owner +(def owner tar.Owner [tar.#name tar.anonymous tar.#id tar.no_id]) -(def: ownership +(def ownership [tar.#user ..owner tar.#group ..owner]) -(def: (write_module now mapping [module [module_id [descriptor document output]]]) +(def (write_module now mapping [module [module_id [descriptor document output]]]) (-> Instant (Dictionary Module archive.ID) [Module [archive.ID [Descriptor (Document .Module) Output]]] (Try tar.Entry)) @@ -115,7 +115,7 @@ module_file (tar.path (..module_file module_id))] (in {tar.#Normal [module_file now ..mode ..ownership entry_content]}))) -(def: .public (package now) +(def .public (package now) (-> Instant Packager) (function (package host_dependencies archive program) (do [! try.monad] diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux index 382536417..d68c344e5 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux @@ -34,7 +34,7 @@ [language ["$" lux]]]]]) -(def: (write_module necessary_dependencies sequence [module_id output] so_far) +(def (write_module necessary_dependencies sequence [module_id output] so_far) (All (_ directive) (-> (Set unit.ID) (-> directive directive directive) [module.ID Output] directive (Try directive))) @@ -57,7 +57,7 @@ (sequence so_far))))) so_far))) -(def: .public (package header code sequence scope) +(def .public (package header code sequence scope) (All (_ directive) (-> directive (-> directive Text) diff --git a/stdlib/source/library/lux/tool/compiler/phase.lux b/stdlib/source/library/lux/tool/compiler/phase.lux index 97eb3944c..c2aa03feb 100644 --- a/stdlib/source/library/lux/tool/compiler/phase.lux +++ b/stdlib/source/library/lux/tool/compiler/phase.lux @@ -23,10 +23,10 @@ (type: .public (Operation s o) (state.+State Try s o)) -(def: .public functor +(def .public functor (All (_ s) (Functor (Operation s))) (implementation - (def: (each f it) + (def (each f it) (function (_ state) (case (it state) {try.#Success [state' output]} @@ -35,16 +35,16 @@ {try.#Failure error} {try.#Failure error}))))) -(def: .public monad +(def .public monad (All (_ s) (Monad (Operation s))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in it) + (def (in it) (function (_ state) {try.#Success [state it]})) - (def: (conjoint it) + (def (conjoint it) (function (_ state) (case (it state) {try.#Success [state' it']} @@ -59,31 +59,31 @@ (type: .public Wrapper (All (_ s i o) (-> (Phase s i o) Any))) -(def: .public (result' state operation) +(def .public (result' state operation) (All (_ s o) (-> s (Operation s o) (Try [s o]))) (operation state)) -(def: .public (result state operation) +(def .public (result state operation) (All (_ s o) (-> s (Operation s o) (Try o))) (|> state operation (at try.monad each product.right))) -(def: .public state +(def .public state (All (_ s o) (Operation s s)) (function (_ state) {try.#Success [state state]})) -(def: .public (with state) +(def .public (with state) (All (_ s o) (-> s (Operation s Any))) (function (_ _) {try.#Success [state []]})) -(def: .public (sub [get set] operation) +(def .public (sub [get set] operation) (All (_ s s' o) (-> [(-> s s') (-> s' s s)] (Operation s' o) @@ -93,31 +93,31 @@ [[state' output] (operation (get state))] (in [(set state' state) output])))) -(def: .public failure +(def .public failure (-> Text Operation) (|>> {try.#Failure} (state.lifted try.monad))) -(def: .public (except exception parameters) +(def .public (except exception parameters) (All (_ e) (-> (Exception e) e Operation)) (..failure (exception.error exception parameters))) -(def: .public (lifted error) +(def .public (lifted error) (All (_ s a) (-> (Try a) (Operation s a))) (function (_ state) (try#each (|>> [state]) error))) -(def: .public assertion +(def .public assertion (template (assertion exception message test) [(if test (at ..monad in []) (..except exception message))])) -(def: .public identity +(def .public identity (All (_ s a) (Phase s a a)) (function (_ archive input state) {try.#Success [state input]})) -(def: .public (composite pre post) +(def .public (composite pre post) (All (_ s0 s1 i t o) (-> (Phase s0 i t) (Phase s1 t o) diff --git a/stdlib/source/library/lux/tool/compiler/reference.lux b/stdlib/source/library/lux/tool/compiler/reference.lux index 78539332c..9701fbf11 100644 --- a/stdlib/source/library/lux/tool/compiler/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/reference.lux @@ -27,10 +27,10 @@ {#Variable Variable} {#Constant Constant})) -(def: .public equivalence +(def .public equivalence (Equivalence Reference) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] (^.with_template [<tag> <equivalence>] [[{<tag> reference} {<tag> sample}] @@ -41,13 +41,13 @@ _ false)))) -(def: .public hash +(def .public hash (Hash Reference) (implementation - (def: equivalence + (def equivalence ..equivalence) - (def: (hash value) + (def (hash value) (case value (^.with_template [<factor> <tag> <hash>] [{<tag> value} @@ -59,7 +59,7 @@ )))) (with_template [<name> <family> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [(<| {<family>} {<tag>} @@ -70,7 +70,7 @@ ) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [(<| {<tag>} content)]))] @@ -79,11 +79,11 @@ [constant ..#Constant] ) -(`` (def: .public self +(`` (def .public self (template (self) [(..variable (~~ (/variable.self)))]))) -(def: .public format +(def .public format (Format Reference) (|>> (pipe.case {#Variable variable} diff --git a/stdlib/source/library/lux/tool/compiler/reference/variable.lux b/stdlib/source/library/lux/tool/compiler/reference/variable.lux index 8dea1368a..7dd3cdc4c 100644 --- a/stdlib/source/library/lux/tool/compiler/reference/variable.lux +++ b/stdlib/source/library/lux/tool/compiler/reference/variable.lux @@ -24,10 +24,10 @@ {#Local Register} {#Foreign Register})) -(def: .public equivalence +(def .public equivalence (Equivalence Variable) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] (^.with_template [<tag>] [[{<tag> reference'} {<tag> sample'}] @@ -37,13 +37,13 @@ _ #0)))) -(def: .public hash +(def .public hash (Hash Variable) (implementation - (def: equivalence + (def equivalence ..equivalence) - (def: hash + (def hash (|>> (pipe.case (^.with_template [<factor> <tag>] [{<tag> register} @@ -53,11 +53,11 @@ ([2 #Local] [3 #Foreign])))))) -(def: .public self +(def .public self (template (self) [{..#Local 0}])) -(def: .public self? +(def .public self? (-> Variable Bit) (|>> (pipe.case (pattern (..self)) @@ -66,7 +66,7 @@ _ false))) -(def: .public format +(def .public format (Format Variable) (|>> (pipe.case {#Local local} diff --git a/stdlib/source/library/lux/tool/compiler/version.lux b/stdlib/source/library/lux/tool/compiler/version.lux index 67fe69189..1c8b12785 100644 --- a/stdlib/source/library/lux/tool/compiler/version.lux +++ b/stdlib/source/library/lux/tool/compiler/version.lux @@ -11,36 +11,36 @@ (type: .public Version Nat) -(def: range +(def range 100) -(def: level +(def level (n.% ..range)) -(def: next +(def next (n./ ..range)) -(def: .public patch +(def .public patch (-> Version Nat) (|>> ..level)) -(def: .public minor +(def .public minor (-> Version Nat) (|>> ..next ..level)) -(def: .public major +(def .public major (-> Version Nat) (|>> ..next ..next ..level)) -(def: separator ".") +(def separator ".") -(def: (padded value) +(def (padded value) (-> Nat Text) (if (n.< 10 value) (%.format "0" (%.nat value)) (%.nat value))) -(def: .public (format version) +(def .public (format version) (%.Format Version) (%.format (%.nat (..major version)) ..separator diff --git a/stdlib/source/library/lux/tool/interpreter.lux b/stdlib/source/library/lux/tool/interpreter.lux index f54f0ae59..da8c16991 100644 --- a/stdlib/source/library/lux/tool/interpreter.lux +++ b/stdlib/source/library/lux/tool/interpreter.lux @@ -32,32 +32,32 @@ (exception: .public (error [message Text]) message) -(def: .public module "<INTERPRETER>") +(def .public module "<INTERPRETER>") -(def: fresh_source +(def fresh_source Source [[..module 1 0] 0 ""]) -(def: (add_line line [where offset input]) +(def (add_line line [where offset input]) (-> Text Source Source) [where offset (format input text.new_line line)]) -(def: exit_command +(def exit_command Text "exit") -(def: welcome_message +(def welcome_message Text (format text.new_line "Welcome to the interpreter!" text.new_line "Type '" ..exit_command "' to leave." text.new_line text.new_line)) -(def: farewell_message +(def farewell_message Text "Till next time...") -(def: enter_module +(def enter_module (All (_ anchor expression directive) (Operation anchor expression directive Any)) (directive.lifted_analysis @@ -65,7 +65,7 @@ [_ (module.create 0 ..module)] (analysis.set_current_module ..module)))) -(def: (initialize Monad<!> Console<!> platform configuration generation_bundle) +(def (initialize Monad<!> Console<!> platform configuration generation_bundle) (All (_ ! anchor expression directive) (-> (Monad !) (Console !) (Platform ! anchor expression directive) @@ -89,7 +89,7 @@ (with_expansions [<Interpretation> (these (Operation anchor expression directive [Type Any]))] - (def: (interpret_directive code) + (def (interpret_directive code) (All (_ anchor expression directive) (-> Code <Interpretation>)) (do phase.monad @@ -97,7 +97,7 @@ _ init.refresh] (in [Any []]))) - (def: (interpret_expression code) + (def (interpret_expression code) (All (_ anchor expression directive) (-> Code <Interpretation>)) (do [! phase.monad] @@ -124,7 +124,7 @@ codeV (generation.evaluate! (format "interpretation_" (%.nat count)) codeH)] (in [codeT codeV])))))) - (def: (interpret configuration code) + (def (interpret configuration code) (All (_ anchor expression directive) (-> Configuration Code <Interpretation>)) (function (_ state) @@ -148,7 +148,7 @@ {try.#Failure error})))) ) -(def: (execute configuration code) +(def (execute configuration code) (All (_ anchor expression directive) (-> Configuration Code (Operation anchor expression directive Text))) (do phase.monad @@ -168,7 +168,7 @@ #source Source])) (with_expansions [<Context> (these (Context anchor expression directive))] - (def: (read_eval_print context) + (def (read_eval_print context) (All (_ anchor expression directive) (-> <Context> (Try [<Context> Text]))) (do try.monad @@ -192,7 +192,7 @@ (has #source source')) representation])))) -(def: .public (run! Monad<!> Console<!> platform configuration generation_bundle) +(def .public (run! Monad<!> Console<!> platform configuration generation_bundle) (All (_ ! anchor expression directive) (-> (Monad !) (Console !) (Platform ! anchor expression directive) diff --git a/stdlib/source/library/lux/type.lux b/stdlib/source/library/lux/type.lux index 52c70ada9..933d0e03c 100644 --- a/stdlib/source/library/lux/type.lux +++ b/stdlib/source/library/lux/type.lux @@ -29,7 +29,7 @@ ["[0]" symbol (.open: "[1]#[0]" equivalence codec)]]]]) (with_template [<name> <tag>] - [(def: .public (<name> type) + [(def .public (<name> type) (-> Type [Nat Type]) (loop (again [num_args 0 type type]) @@ -44,7 +44,7 @@ [flat_ex_q .#ExQ] ) -(def: .public (flat_function type) +(def .public (flat_function type) (-> Type [(List Type) Type]) (case type {.#Function in out'} @@ -54,7 +54,7 @@ _ [(list) type])) -(def: .public (flat_application type) +(def .public (flat_application type) (-> Type [Type (List Type)]) (case type {.#Apply arg func'} @@ -65,7 +65,7 @@ [type (list)])) (with_template [<name> <tag>] - [(def: .public (<name> type) + [(def .public (<name> type) (-> Type (List Type)) (case type {<tag> left right} @@ -78,7 +78,7 @@ [flat_tuple .#Product] ) -(def: .public (format type) +(def .public (format type) (-> Type Text) (case type {.#Primitive name params} @@ -136,7 +136,7 @@ )) ... https://en.wikipedia.org/wiki/Lambda_calculus#%CE%B2-reduction -(def: (reduced env type) +(def (reduced env type) (-> (List Type) Type Type) (case type {.#Primitive name params} @@ -176,10 +176,10 @@ type )) -(def: .public equivalence +(def .public equivalence (Equivalence Type) (implementation - (def: (= x y) + (def (= x y) (or (for @.php ... TODO: Remove this once JPHP is gone. false @@ -223,7 +223,7 @@ #0 ))))) -(def: .public (applied params func) +(def .public (applied params func) (-> (List Type) Type (Maybe Type)) (case params {.#End} @@ -247,7 +247,7 @@ _ {.#None}))) -(def: .public (code type) +(def .public (code type) (-> Type Code) (case type {.#Primitive name params} @@ -275,7 +275,7 @@ ([.#UnivQ] [.#ExQ]) )) -(def: .public (de_aliased type) +(def .public (de_aliased type) (-> Type Type) (case type {.#Named _ {.#Named name type'}} @@ -284,7 +284,7 @@ _ type)) -(def: .public (anonymous type) +(def .public (anonymous type) (-> Type Type) (case type {.#Named name type'} @@ -294,7 +294,7 @@ type)) (with_template [<name> <base> <ctor>] - [(def: .public (<name> types) + [(def .public (<name> types) (-> (List Type) Type) (case types {.#End} @@ -310,7 +310,7 @@ [tuple Any .#Product] ) -(def: .public (function inputs output) +(def .public (function inputs output) (-> (List Type) Type Type) (case inputs {.#End} @@ -319,7 +319,7 @@ {.#Item input inputs'} {.#Function input (function inputs' output)})) -(def: .public (application params quant) +(def .public (application params quant) (-> (List Type) Type Type) (case params {.#End} @@ -329,7 +329,7 @@ (application params' {.#Apply param quant}))) (with_template [<name> <tag>] - [(def: .public (<name> size body) + [(def .public (<name> size body) (-> Nat Type Type) (case size 0 body @@ -339,7 +339,7 @@ [ex_q .#ExQ] ) -(def: .public (quantified? type) +(def .public (quantified? type) (-> Type Bit) (case type {.#Named [module name] _type} @@ -356,7 +356,7 @@ _ #0)) -(def: .public (array depth element_type) +(def .public (array depth element_type) (-> Nat Type Type) (case depth 0 element_type @@ -365,7 +365,7 @@ (list) {.#Primitive array.type_name}))) -(def: .public (flat_array type) +(def .public (flat_array type) (-> Type [Nat Type]) (case type (^.multi (pattern {.#Primitive name (list element_type)}) @@ -376,21 +376,21 @@ _ [0 type])) -(def: .public array? +(def .public array? (-> Type Bit) (|>> ..flat_array product.left (n.> 0))) -(def: new_secret_marker +(def new_secret_marker (syntax (_ []) (macro.with_symbols [g!_secret_marker_] (in (list g!_secret_marker_))))) -(def: secret_marker +(def secret_marker (`` (symbol (~~ (new_secret_marker))))) -(def: .public log! +(def .public log! (syntax (_ [input (<>.or (<>.and <code>.symbol (<>.maybe (<>.after (<code>.this_symbol ..secret_marker) <code>.any))) <code>.any)]) @@ -417,11 +417,11 @@ (in (list (` (.let [(~ g!value) (~ valueC)] (..log! (~ valueC) (~ (code.symbol ..secret_marker)) (~ g!value)))))))))) -(def: type_parameters +(def type_parameters (Parser (List Text)) (<code>.tuple (<>.some <code>.local))) -(def: .public as +(def .public as (syntax (_ [type_vars type_parameters input <code>.any output <code>.any @@ -442,7 +442,7 @@ [#type Code #expression Code])) -(def: (typed lux) +(def (typed lux) (-> Lux (Parser Typed)) (do <>.monad [it <code>.any @@ -453,7 +453,7 @@ (<>.and <code>.any <code>.any)))) ... TODO: Make sure the generated code always gets optimized away. -(def: .public sharing +(def .public sharing (syntax (_ lux [type_vars ..type_parameters exemplar (..typed lux) computation (..typed lux)]) @@ -466,7 +466,7 @@ (~ (the #expression computation)))))] (in (list (` ((~ shareC) (~ (the #expression exemplar)))))))))) -(def: .public by_example +(def .public by_example (syntax (_ lux [type_vars ..type_parameters exemplar (..typed lux) extraction <code>.any]) @@ -477,7 +477,7 @@ ... The value of this expression will never be relevant, so it doesn't matter what it is. (.as .Nothing []))))))))) -(def: .public (replaced before after) +(def .public (replaced before after) (-> Type Type Type Type) (.function (again it) (if (at ..equivalence = before it) @@ -506,7 +506,7 @@ {.#Named _}) it)))) -(def: .public let +(def .public let (syntax (_ [bindings (<code>.tuple (<>.some (<>.and <code>.any <code>.any))) bodyT <code>.any]) (in (list (` (..with_expansions [(~+ (|> bindings diff --git a/stdlib/source/library/lux/type/check.lux b/stdlib/source/library/lux/type/check.lux index 6b42b2d03..7241146ec 100644 --- a/stdlib/source/library/lux/type/check.lux +++ b/stdlib/source/library/lux/type/check.lux @@ -23,11 +23,11 @@ ["n" nat (.open: "[1]#[0]" decimal)]]]]] ["[0]" // (.open: "[1]#[0]" equivalence)]) -(def: !n#= +(def !n#= (template (_ reference subject) [("lux i64 =" reference subject)])) -(def: !text#= +(def !text#= (template (_ reference subject) [("lux text =" reference subject)])) @@ -74,10 +74,10 @@ (type: Type_Vars (List [Var (Maybe Type)])) -(def: .public functor +(def .public functor (Functor Check) (implementation - (def: (each f fa) + (def (each f fa) (function (_ context) (case (fa context) {try.#Success [context' output]} @@ -86,12 +86,12 @@ {try.#Failure error} {try.#Failure error}))))) -(def: .public apply +(def .public apply (Apply Check) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (function (_ context) (case (ff context) {try.#Success [context' f]} @@ -107,16 +107,16 @@ ))) )) -(def: .public monad +(def .public monad (Monad Check) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in x) + (def (in x) (function (_ context) {try.#Success [context x]})) - (def: (conjoint ffa) + (def (conjoint ffa) (function (_ context) (case (ffa context) {try.#Success [context' fa]} @@ -134,11 +134,11 @@ (open: "check#[0]" ..monad) -(def: (var::new id plist) +(def (var::new id plist) (-> Var Type_Vars Type_Vars) {.#Item [id {.#None}] plist}) -(def: (var::get id plist) +(def (var::get id plist) (-> Var Type_Vars (Maybe (Maybe Type))) (case plist {.#Item [var_id var_type] @@ -150,7 +150,7 @@ {.#End} {.#None})) -(def: (var::put id value plist) +(def (var::put id value plist) (-> Var (Maybe Type) Type_Vars Type_Vars) (case plist {.#End} @@ -164,7 +164,7 @@ {.#Item [var_id var_type] (var::put id value plist')}))) -(def: .public (result context proc) +(def .public (result context proc) (All (_ a) (-> Type_Context (Check a) (Try a))) (case (proc context) {try.#Success [context' output]} @@ -173,23 +173,23 @@ {try.#Failure error} {try.#Failure error})) -(def: .public (failure message) +(def .public (failure message) (All (_ a) (-> Text (Check a))) (function (_ context) {try.#Failure message})) -(def: .public (assertion message test) +(def .public (assertion message test) (-> Text Bit (Check Any)) (function (_ context) (if test {try.#Success [context []]} {try.#Failure message}))) -(def: .public (except exception message) +(def .public (except exception message) (All (_ e a) (-> (Exception e) e (Check a))) (..failure (exception.error exception message))) -(def: .public existential +(def .public existential (Check [Nat Type]) (function (_ context) (let [id (the .#ex_counter context)] @@ -197,7 +197,7 @@ [id {.#Ex id}]]}))) (with_template [<name> <outputT> <fail> <succeed>] - [(def: .public (<name> id) + [(def .public (<name> id) (-> Var (Check <outputT>)) (function (_ context) (case (|> context (the .#var_bindings) (var::get id)) @@ -215,7 +215,7 @@ [peek (Maybe Type) {.#None} {.#Some bound}] ) -(def: .public (read id) +(def .public (read id) (-> Var (Check Type)) (do ..monad [?type (peek id)] @@ -226,7 +226,7 @@ {.#None} (..except ..unbound_type_var id)))) -(def: (bound id) +(def (bound id) (-> Var (Check Type)) (function (_ context) (case (|> context (the .#var_bindings) (var::get id)) @@ -239,7 +239,7 @@ _ (exception.except ..unknown_type_var id)))) -(def: .public (bind type id) +(def .public (bind type id) (-> Type Var (Check Any)) (function (_ context) (case (|> context (the .#var_bindings) (var::get id)) @@ -253,7 +253,7 @@ _ (exception.except ..unknown_type_var id)))) -(def: (re_bind' ?type id) +(def (re_bind' ?type id) (-> (Maybe Type) Var (Check Any)) (function (_ context) (case (|> context (the .#var_bindings) (var::get id)) @@ -264,11 +264,11 @@ _ (exception.except ..unknown_type_var id)))) -(def: (re_bind type id) +(def (re_bind type id) (-> Type Var (Check Any)) (re_bind' {.#Some type} id)) -(def: .public var +(def .public var (Check [Var Type]) (function (_ context) (let [id (the .#var_counter context)] @@ -277,7 +277,7 @@ (revised .#var_bindings (var::new id))) [id {.#Var id}]]}))) -(def: (on argT funcT) +(def (on argT funcT) (-> Type Type (Check Type)) (case funcT {.#Var func_id} @@ -303,7 +303,7 @@ _ (except ..invalid_type_application [funcT argT])))) -(def: .public (ring' start) +(def .public (ring' start) (-> Var (Check (List Var))) (function (_ context) (loop (again [current start @@ -326,12 +326,12 @@ (exception.except ..unknown_type_var current))))) ... TODO: Optimize this by not using sets anymore. -(def: ring +(def ring (-> Var (Check (Set Var))) (|>> ..ring' (check#each (set.of_list n.hash)))) -(def: .public (linked? @0 @1) +(def .public (linked? @0 @1) (-> Var Var (Check Bit)) (check#each (function (_ it) (set.member? it @1)) @@ -341,7 +341,7 @@ (exception.report "Var" (n#encoded var))) -(def: .public (identity aliases @) +(def .public (identity aliases @) (-> (List Var) Var (Check Type)) (do [! ..monad] [:bound: (..peek @)] @@ -364,7 +364,7 @@ {.#None} (..except ..cannot_identify [@])))))))) -(def: (erase! @) +(def (erase! @) (-> Var (Check Any)) (function (_ context) {try.#Success [(revised .#var_bindings @@ -382,7 +382,7 @@ context) []]})) -(def: .public (forget! @) +(def .public (forget! @) (-> Var (Check Any)) (do [! ..monad] [ring (..ring' @)] @@ -409,7 +409,7 @@ _ (undefined))))) -(def: .public (try it) +(def .public (try it) (All (_ a) (-> (Check a) (Check (Try a)))) (function (_ context) (case (it context) @@ -419,13 +419,13 @@ {try.#Failure error} {try.#Success [context {try.#Failure error}]}))) -(def: .public fresh_context +(def .public fresh_context Type_Context [.#var_counter 0 .#ex_counter 0 .#var_bindings (list)]) -(def: (either left right) +(def (either left right) (All (_ a) (-> (Check a) (Check a) (Check a))) (function (_ context) (case (left context) @@ -435,7 +435,7 @@ output output))) -(def: (assumed? [e a] assumptions) +(def (assumed? [e a] assumptions) (-> Assumption (List Assumption) Bit) (list.any? (function (_ [e' a']) (and (//#= e e') @@ -443,7 +443,7 @@ assumptions)) ... TODO: "if_can_bind" can be optimized... -(def: (if_can_bind id type then else) +(def (if_can_bind id type then else) (All (_ a) (-> Var Type (Check a) (-> Type (Check a)) (Check a))) @@ -461,21 +461,21 @@ (else (maybe.else {.#Var id} ?bound))))) ... TODO: "link/2" can be optimized... -(def: (link/2 left right) +(def (link/2 left right) (-> Var Var (Check Any)) (do ..monad [_ (..bind {.#Var right} left)] (..bind {.#Var left} right))) ... TODO: "link/3" can be optimized... -(def: (link/3 interpose to from) +(def (link/3 interpose to from) (-> Var Var Var (Check Any)) (do ..monad [_ (re_bind {.#Var interpose} from)] (re_bind {.#Var to} interpose))) ... TODO: "check_vars" can be optimized... -(def: (check_vars check' assumptions idE idA) +(def (check_vars check' assumptions idE idA) (-> (Checker Type) (Checker Var)) (if (!n#= idE idA) (check#in assumptions) @@ -541,12 +541,12 @@ _ (check' assumptions etype atype)))))) -(def: silent_failure! +(def silent_failure! (All (_ a) (Check a)) (..failure "")) ... TODO: "check_apply" can be optimized... -(def: (check_apply check' assumptions expected actual) +(def (check_apply check' assumptions expected actual) (-> (Checker Type) (Checker [Type Type])) (let [[expected_input expected_function] expected [actual_input actual_function] actual] @@ -632,14 +632,14 @@ _ ..silent_failure!))) -(def: (with_exception exception parameter check) +(def (with_exception exception parameter check) (All (_ e a) (-> (Exception e) e (Check a) (Check a))) (|>> check (exception.with exception parameter))) ... TODO: "check'" can be optimized... ... Type-check to ensure that the 'expected' type subsumes the 'actual' type. -(def: (check' assumptions expected actual) +(def (check' assumptions expected actual) (Checker Type) (if (for @.php ... TODO: Remove this once JPHP is gone. @@ -749,11 +749,11 @@ _ ..silent_failure!)))) -(def: .public (check expected actual) +(def .public (check expected actual) (-> Type Type (Check Any)) (check' (list) expected actual)) -(def: .public (subsumes? expected actual) +(def .public (subsumes? expected actual) (-> Type Type Bit) (case (..result ..fresh_context (..check expected actual)) @@ -763,17 +763,17 @@ {try.#Success _} true)) -(def: .public context +(def .public context (Check Type_Context) (function (_ context) {try.#Success [context context]})) -(def: .public (with context) +(def .public (with context) (-> Type_Context (Check Any)) (function (_ _) {try.#Success [context []]})) -(def: .public (clean aliases inputT) +(def .public (clean aliases inputT) (-> (List Var) Type (Check Type)) (case inputT {.#Primitive name paramsT+} diff --git a/stdlib/source/library/lux/type/dynamic.lux b/stdlib/source/library/lux/type/dynamic.lux index 3797e528c..169e16464 100644 --- a/stdlib/source/library/lux/type/dynamic.lux +++ b/stdlib/source/library/lux/type/dynamic.lux @@ -24,21 +24,21 @@ (primitive .public Dynamic [Type Any] - (def: abstraction + (def abstraction (-> [Type Any] Dynamic) (|>> primitive.abstraction)) - (def: representation + (def representation (-> Dynamic [Type Any]) (|>> primitive.representation)) - (def: .public dynamic + (def .public dynamic (syntax (_ [value <code>.any]) (with_symbols [g!value] (in (list (` (.let [(~ g!value) (~ value)] ((~! ..abstraction) [(.type_of (~ g!value)) (~ g!value)])))))))) - (def: .public static + (def .public static (syntax (_ [type <code>.any value <code>.any]) (with_symbols [g!type g!value] @@ -49,7 +49,7 @@ {try.#Success (.as (~ type) (~ g!value))} ((~! exception.except) ..wrong_type [(.type (~ type)) (~ g!type)])))))))))) - (def: .public (format value) + (def .public (format value) (-> Dynamic (Try Text)) (let [[type value] (primitive.representation value)] (debug.representation type value))) diff --git a/stdlib/source/library/lux/type/implicit.lux b/stdlib/source/library/lux/type/implicit.lux index 13b1d4c90..fb06527c8 100644 --- a/stdlib/source/library/lux/type/implicit.lux +++ b/stdlib/source/library/lux/type/implicit.lux @@ -26,7 +26,7 @@ ["[0]" type (.open: "[1]#[0]" equivalence) ["[0]" check (.only Check)]]]]) -(def: (type_var id env) +(def (type_var id env) (-> Nat Type_Context (Meta Type)) (case (list.example (|>> product.left (n.= id)) (the .#var_bindings env)) @@ -45,7 +45,7 @@ (meta.failure (format "Unknown type-var " (%.nat id))) )) -(def: (implicit_type var_name) +(def (implicit_type var_name) (-> Symbol (Meta Type)) (do meta.monad [raw_type (meta.type var_name) @@ -57,7 +57,7 @@ _ (in raw_type)))) -(def: (member_type idx sig_type) +(def (member_type idx sig_type) (-> Nat Type (Check Type)) (case sig_type {.#Named _ sig_type'} @@ -81,7 +81,7 @@ (at check.monad in sig_type) (check.failure (format "Cannot find member type " (%.nat idx) " for " (%.type sig_type)))))) -(def: (member_name member) +(def (member_name member) (-> Symbol (Meta Symbol)) (case member ["" simple_name] @@ -109,14 +109,14 @@ _ (at meta.monad in member))) -(def: (implicit_member member) +(def (implicit_member member) (-> Symbol (Meta [Nat Type])) (do meta.monad [member (member_name member) [idx tag_list sig_type] (meta.slot member)] (in [idx sig_type]))) -(def: (compatible_type? interface candidate) +(def (compatible_type? interface candidate) (-> Type Type Bit) (with_expansions [<found?> (type#= interface candidate)] (<| (or <found?>) @@ -133,7 +133,7 @@ (let [candidate (type.de_aliased candidate)]) <found?>))) -(def: (available_definitions sig_type source_module target_module constants aggregate) +(def (available_definitions sig_type source_module target_module constants aggregate) (-> Type Text Text (List [Text Definition]) (-> (List [Symbol Type]) (List [Symbol Type]))) (list#mix (function (_ [name [exported? def_type def_value]] aggregate) (if (and (or (text#= target_module source_module) @@ -144,7 +144,7 @@ aggregate constants)) -(def: (local_env sig_type) +(def (local_env sig_type) (-> Type (Meta (List [Symbol Type]))) (do meta.monad [local_batches meta.locals @@ -160,14 +160,14 @@ {.#Some [["" name] type]} {.#None}))))))) -(def: (local_structs sig_type) +(def (local_structs sig_type) (-> Type (Meta (List [Symbol Type]))) (do [! meta.monad] [this_module_name meta.current_module_name definitions (meta.definitions this_module_name)] (in (available_definitions sig_type this_module_name this_module_name definitions {.#End})))) -(def: (imported_structs sig_type) +(def (imported_structs sig_type) (-> Type (Meta (List [Symbol Type]))) (do [! meta.monad] [this_module_name meta.current_module_name @@ -178,7 +178,7 @@ {.#End} (list.zipped_2 imported_modules accessible_definitions))))) -(def: (on_argument arg func) +(def (on_argument arg func) (-> Type Type (Check Type)) (case func {.#Named _ func'} @@ -200,7 +200,7 @@ _ (check.failure (format "Invalid function type: " (%.type func))))) -(def: (concrete_type type) +(def (concrete_type type) (-> Type (Check [(List Nat) Type])) (case type {.#UnivQ _} @@ -213,7 +213,7 @@ _ (at check.monad in [(list) type]))) -(def: (ensure_function_application! member_type input_types expected_output) +(def (ensure_function_application! member_type input_types expected_output) (-> Type (List Type) Type (Check [])) (do check.monad [actual_output (monad.mix check.monad ..on_argument member_type input_types)] @@ -225,7 +225,7 @@ [#constructor Symbol #dependencies (List Instance)]))) -(def: (candidate_provision provision context dep alts) +(def (candidate_provision provision context dep alts) (-> (-> Lux Type_Context Type (Check Instance)) Type_Context Type (List [Symbol Type]) (Meta (List Instance))) @@ -253,7 +253,7 @@ found (in found)))) -(def: (provision sig_type compiler context dep) +(def (provision sig_type compiler context dep) (-> Type Lux Type_Context Type (Check Instance)) (case (meta.result compiler (all meta.either @@ -275,7 +275,7 @@ (check.failure (format "Too many candidates for provisioning: " (%.type dep) " --- " (%.list (|>> product.left %.symbol) candidates)))) )) -(def: (candidate_alternatives sig_type member_idx input_types output_type alts) +(def (candidate_alternatives sig_type member_idx input_types output_type alts) (-> Type Nat (List Type) Type (List [Symbol Type]) (Meta (List Instance))) (do meta.monad [compiler meta.compiler_state @@ -304,7 +304,7 @@ found (in found)))) -(def: (alternatives sig_type member_idx input_types output_type) +(def (alternatives sig_type member_idx input_types output_type) (-> Type Nat (List Type) Type (Meta (List Instance))) (let [test (candidate_alternatives sig_type member_idx input_types output_type)] (all meta.either @@ -312,7 +312,7 @@ (do meta.monad [alts (..local_structs sig_type)] (test alts)) (do meta.monad [alts (..imported_structs sig_type)] (test alts))))) -(def: (var? input) +(def (var? input) (-> Code Bit) (case input [_ {.#Symbol _}] @@ -321,11 +321,11 @@ _ #0)) -(def: (pair_list [l r]) +(def (pair_list [l r]) (All (_ a) (-> [a a] (List a))) (list l r)) -(def: (instance$ [constructor dependencies]) +(def (instance$ [constructor dependencies]) (-> Instance Code) (case dependencies {.#End} @@ -334,7 +334,7 @@ _ (` ((~ (code.symbol constructor)) (~+ (list#each instance$ dependencies)))))) -(def: .public a/an +(def .public a/an (syntax (_ [member <code>.symbol args (<>.or (<>.and (<>.some <code>.symbol) <code>.end) (<>.and (<>.some <code>.any) <code>.end))]) @@ -370,16 +370,16 @@ (..a/an (~ (code.symbol member)) (~+ labels))))))) ))) -(def: .public a ..a/an) -(def: .public an ..a/an) +(def .public a ..a/an) +(def .public an ..a/an) -(def: (implicit_bindings amount) +(def (implicit_bindings amount) (-> Nat (Meta (List Code))) (|> (macro.symbol "g!implicit") (list.repeated amount) (monad.all meta.monad))) -(def: .public with +(def .public with (syntax (_ [implementations (<code>.tuple (<>.many <code>.any)) body <code>.any]) (do meta.monad @@ -390,11 +390,11 @@ list#conjoint))] (~ body)))))))) -(def: .public implicitly +(def .public implicitly (syntax (_ [implementations (<>.many <code>.any)]) (do meta.monad [g!implicit+ (implicit_bindings (list.size implementations))] (in (|> (list.zipped_2 g!implicit+ implementations) (list#each (function (_ [g!implicit implementation]) - (` (def: .private (~ g!implicit) + (` (def .private (~ g!implicit) (~ implementation)))))))))) diff --git a/stdlib/source/library/lux/type/poly.lux b/stdlib/source/library/lux/type/poly.lux index aeb27188b..997c7b65f 100644 --- a/stdlib/source/library/lux/type/poly.lux +++ b/stdlib/source/library/lux/type/poly.lux @@ -24,7 +24,7 @@ [number ["n" nat]]]]]) -(def: .public polytypic +(def .public polytypic (syntax (_ [name <code>.local body <code>.any]) (with_symbols [g!_ g!type g!output] @@ -43,7 +43,7 @@ {.#Left (~ g!output)} ((~! meta.failure) (~ g!output)))))))))))) -(def: .public (code env type) +(def .public (code env type) (-> Env Type Code) (case type {.#Primitive name params} diff --git a/stdlib/source/library/lux/type/primitive.lux b/stdlib/source/library/lux/type/primitive.lux index 53202405e..274e07b32 100644 --- a/stdlib/source/library/lux/type/primitive.lux +++ b/stdlib/source/library/lux/type/primitive.lux @@ -24,15 +24,15 @@ (type: Stack List) -(def: peek +(def peek (All (_ a) (-> (Stack a) (Maybe a))) list.head) -(def: (push value stack) +(def (push value stack) (All (_ a) (-> a (Stack a) (Stack a))) {.#Item value stack}) -(def: pop +(def pop (All (_ a) (-> (Stack a) (Maybe (Stack a)))) list.tail) @@ -43,11 +43,11 @@ #abstraction Code #representation Code])) -(def: frames +(def frames (Stack Frame) {.#End}) -(def: !peek +(def !peek (template (_ <source> <reference> <then>) [(loop (again [entries <source>]) (case entries @@ -59,7 +59,7 @@ {.#End} (undefined)))])) -(def: (peek_frames_definition reference source) +(def (peek_frames_definition reference source) (-> Text (List [Text Global]) (Stack Frame)) (!peek source reference (case head @@ -72,14 +72,14 @@ {.#Slot _}) (undefined)))) -(def: (peek_frames reference definition_reference source) +(def (peek_frames reference definition_reference source) (-> Text Text (List [Text Module]) (Stack Frame)) (!peek source reference (peek_frames_definition definition_reference (the .#definitions head)))) (exception: .public no_active_frames) -(def: (peek! frame) +(def (peek! frame) (-> (Maybe Text) (Meta Frame)) (function (_ compiler) (let [[reference definition_reference] (symbol ..frames) @@ -98,15 +98,15 @@ {.#None} (exception.except ..no_active_frames []))))) -(def: .public current +(def .public current (Meta Frame) (..peek! {.#None})) -(def: .public (specific name) +(def .public (specific name) (-> Text (Meta Frame)) (..peek! {.#Some name})) -(def: !push +(def !push (template (_ <source> <reference> <then>) [(loop (again [entries <source>]) (case entries @@ -120,7 +120,7 @@ {.#End} (undefined)))])) -(def: (push_frame_definition reference frame source) +(def (push_frame_definition reference frame source) (-> Text Frame (List [Text Global]) (List [Text Global])) (!push source reference (case head @@ -135,12 +135,12 @@ {.#Slot _}) (undefined)))) -(def: (push_frame [module_reference definition_reference] frame source) +(def (push_frame [module_reference definition_reference] frame source) (-> Symbol Frame (List [Text Module]) (List [Text Module])) (!push source module_reference (revised .#definitions (push_frame_definition definition_reference frame) head))) -(def: (push! frame) +(def (push! frame) (-> Frame (Meta Any)) (function (_ compiler) {.#Right [(revised .#modules @@ -148,7 +148,7 @@ compiler) []]})) -(def: (pop_frame_definition reference source) +(def (pop_frame_definition reference source) (-> Text (List [Text Global]) (List [Text Global])) (!push source reference (case head @@ -169,12 +169,12 @@ {.#Slot _}) (undefined)))) -(def: (pop_frame [module_reference definition_reference] source) +(def (pop_frame [module_reference definition_reference] source) (-> Symbol (List [Text Module]) (List [Text Module])) (!push source module_reference (|> head (revised .#definitions (pop_frame_definition definition_reference))))) -(def: pop! +(def pop! (syntax (_ []) (function (_ compiler) {.#Right [(revised .#modules @@ -182,13 +182,13 @@ compiler) (list)]}))) -(def: cast +(def cast (Parser [(Maybe Text) Code]) (<>.either (<>.and (<>.maybe <code>.local) <code>.any) (<>.and (<>#in {.#None}) <code>.any))) (with_template [<name> <from> <to>] - [(def: .public <name> + [(def .public <name> (syntax (_ [[frame value] ..cast]) (do meta.monad [[name type_vars abstraction representation] (peek! frame)] @@ -199,22 +199,22 @@ [representation abstraction representation] ) -(def: abstraction_type_name +(def abstraction_type_name (-> Symbol Text) symbol#encoded) -(def: representation_definition_name +(def representation_definition_name (-> Text Text) (|>> (all text#composite (symbol#encoded (symbol ..#Representation)) " "))) -(def: declaration +(def declaration (Parser [Text (List Text)]) (<>.either (<code>.form (<>.and <code>.local (<>.some <code>.local))) (<>.and <code>.local (at <>.monad in (list))))) -(def: abstract +(def abstract (Parser [Code [Text (List Text)] Code (List Code)]) (|export|.parser (all <>.and @@ -225,7 +225,7 @@ ... TODO: Make sure the generated code always gets optimized away. ... (This applies to uses of "abstraction" and "representation") -(def: .public primitive +(def .public primitive (syntax (_ [[export_policy [name type_vars] representation_type primitives] ..abstract]) (do meta.monad @@ -252,12 +252,12 @@ {#Specific Code a} {#Current a})) -(def: (selection parser) +(def (selection parser) (All (_ a) (-> (Parser a) (Parser (Selection a)))) (<>.or (<>.and <code>.any parser) parser)) -(def: .public transmutation +(def .public transmutation (syntax (_ [selection (..selection <code>.any)]) (case selection {#Specific specific value} diff --git a/stdlib/source/library/lux/type/quotient.lux b/stdlib/source/library/lux/type/quotient.lux index da7c38025..355e14d0e 100644 --- a/stdlib/source/library/lux/type/quotient.lux +++ b/stdlib/source/library/lux/type/quotient.lux @@ -14,7 +14,7 @@ (primitive .public (Class t c %) (-> t c) - (def: .public class + (def .public class (All (_ t c) (Ex (_ %) (-> (-> t c) (Class t c %)))) @@ -25,7 +25,7 @@ [#value t #label c]) - (def: .public (quotient class value) + (def .public (quotient class value) (All (_ t c %) (-> (Class t c %) t (Quotient t c %))) @@ -33,7 +33,7 @@ #label ((representation Class class) value)])) (with_template [<name> <output> <slot>] - [(def: .public <name> + [(def .public <name> (All (_ t c %) (-> (Quotient t c %) <output>)) (|>> representation (the <slot>)))] @@ -43,7 +43,7 @@ ) ) -(def: .public type +(def .public type (syntax (_ [class <code>.any]) ... TODO: Switch to the cleaner approach ASAP. (with_symbols [g!t g!c g!% g!_ g!:quotient:] @@ -63,8 +63,8 @@ ... (..Quotient (~ g!t) (~ g!c) (~ g!%)))) ))))) -(def: .public (equivalence super) +(def .public (equivalence super) (All (_ t c %) (-> (Equivalence c) (Equivalence (..Quotient t c %)))) (implementation - (def: (= reference sample) + (def (= reference sample) (at super = (..label reference) (..label sample))))) diff --git a/stdlib/source/library/lux/type/refinement.lux b/stdlib/source/library/lux/type/refinement.lux index 0fb387039..5b1cec8db 100644 --- a/stdlib/source/library/lux/type/refinement.lux +++ b/stdlib/source/library/lux/type/refinement.lux @@ -19,7 +19,7 @@ (type: .public (Refiner t %) (-> t (Maybe (Refined t %)))) - (def: .public (refiner predicate) + (def .public (refiner predicate) (All (_ t) (Ex (_ %) (-> (Predicate t) (Refiner t %)))) @@ -30,7 +30,7 @@ {.#None}))) (with_template [<name> <output> <slot>] - [(def: .public <name> + [(def .public <name> (All (_ t %) (-> (Refined t %) <output>)) (|>> representation (the <slot>)))] @@ -38,7 +38,7 @@ [predicate (Predicate t) #predicate] ) - (def: .public (lifted transform) + (def .public (lifted transform) (All (_ t %) (-> (-> t t) (-> (Refined t %) (Maybe (Refined t %))))) @@ -51,7 +51,7 @@ {.#None})))) ) -(def: .public (only refiner values) +(def .public (only refiner values) (All (_ t %) (-> (Refiner t %) (List t) (List (Refined t %)))) (case values @@ -66,7 +66,7 @@ {.#None} (only refiner tail)))) -(def: .public (partition refiner values) +(def .public (partition refiner values) (All (_ t %) (-> (Refiner t %) (List t) [(List (Refined t %)) (List t)])) (case values @@ -84,7 +84,7 @@ [yes {.#Item head no}])))) -(def: .public type +(def .public type (syntax (_ [refiner <code>.any]) ... TODO: Switch to the cleaner approach ASAP. (macro.with_symbols [g!t g!% g!_ g!:refiner:] diff --git a/stdlib/source/library/lux/type/resource.lux b/stdlib/source/library/lux/type/resource.lux index 0827dde1e..c906fc13e 100644 --- a/stdlib/source/library/lux/type/resource.lux +++ b/stdlib/source/library/lux/type/resource.lux @@ -40,26 +40,26 @@ (All (_ keys) (Procedure monad [permissions keys] keys value))) -(def: .public (monad monad) +(def .public (monad monad) (All (_ !) (-> (Monad !) (IxMonad (Procedure !)))) (implementation - (def: (in value) + (def (in value) (function (_ keys) (at monad in [keys value]))) - (def: (then f input) + (def (then f input) (function (_ keysI) (do monad [[keysT value] (input keysI)] ((f value) keysT)))))) -(def: .public (run! monad procedure) +(def .public (run! monad procedure) (All (_ ! v) (-> (Monad !) (Linear ! v) (! v))) (do monad [[_ output] (procedure [])] (in output))) -(def: .public (lifted monad procedure) +(def .public (lifted monad procedure) (All (_ ! v) (-> (Monad !) (! v) (Linear ! v))) (function (_ keys) (do monad @@ -73,7 +73,7 @@ Any (with_template [<name> <mode>] - [(def: <name> + [(def <name> (Ex (_ k) (-> Any (Key <mode> k))) (|>> abstraction))] @@ -85,7 +85,7 @@ value (with_template [<name> <mode> <key>] - [(def: .public (<name> monad value) + [(def .public (<name> monad value) (All (_ ! v) (Ex (_ k) (-> (Monad !) v (Affine ! (Key <mode> k) (Res k v))))) (function (_ keys) (at monad in [[(<key> []) keys] (abstraction value)])))] @@ -94,7 +94,7 @@ [commutative Commutative ..commutative_key] ) - (def: .public (read monad resource) + (def .public (read monad resource) (All (_ ! v k m) (-> (Monad !) (Res k v) (Relevant ! (Key m k) v))) (function (_ [key keys]) @@ -107,7 +107,7 @@ (exception: .public amount_cannot_be_zero) -(def: indices +(def indices (Parser (List Nat)) (<code>.tuple (loop (again [seen (set.empty n.hash)]) (do [! <>.monad] @@ -121,12 +121,12 @@ tail (again (set.has head seen))] (in (list.partial head tail)))))))) -(def: (no_op monad) +(def (no_op monad) (All (_ m) (-> (Monad m) (Linear m Any))) (function (_ context) (at monad in [context []]))) -(def: .public exchange +(def .public exchange (syntax (_ [swaps ..indices]) (macro.with_symbols [g!_ g!context g!!] (case swaps @@ -157,7 +157,7 @@ (function ((~ g!_) (~ g!!) [(~+ g!inputs) (~ g!context)]) (at (~ g!!) (~' in) [[(~+ g!outputs) (~ g!context)] []]))))))))))) -(def: amount +(def amount (Parser Nat) (do <>.monad [raw <code>.nat @@ -166,7 +166,7 @@ (in raw))) (with_template [<name> <from> <to>] - [(def: .public <name> + [(def .public <name> (syntax (_ [amount ..amount]) (macro.with_symbols [g!_ g!context g!!] (do [! meta.monad] diff --git a/stdlib/source/library/lux/type/unit.lux b/stdlib/source/library/lux/type/unit.lux index 9a84487e4..ba76121f0 100644 --- a/stdlib/source/library/lux/type/unit.lux +++ b/stdlib/source/library/lux/type/unit.lux @@ -19,37 +19,37 @@ (primitive .public (Qty scale unit) Int - (def: .public quantity + (def .public quantity (All (_ scale unit) (-> Int (Qty scale unit))) (|>> abstraction)) - (def: .public number + (def .public number (All (_ scale unit) (-> (Qty scale unit) Int)) (|>> representation)) - (def: .public equivalence + (def .public equivalence (All (_ scale unit) (Equivalence (Qty scale unit))) (implementation - (def: (= reference sample) + (def (= reference sample) (i.= (representation reference) (representation sample))))) - (def: .public order + (def .public order (All (_ scale unit) (Order (Qty scale unit))) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (< reference sample) + (def (< reference sample) (i.< (representation reference) (representation sample))))) - (def: .public enum + (def .public enum (All (_ scale unit) (Enum (Qty scale unit))) (implementation - (def: order ..order) - (def: succ (|>> representation ++ abstraction)) - (def: pred (|>> representation -- abstraction)))) + (def order ..order) + (def succ (|>> representation ++ abstraction)) + (def pred (|>> representation -- abstraction)))) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (All (_ scale unit) (-> (Qty scale unit) (Qty scale unit) (Qty scale unit))) (abstraction (<op> (representation param) (representation subject))))] @@ -59,7 +59,7 @@ ) (with_template [<name> <op> <p> <s> <p*s>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (All (_ scale p s) (-> (Qty scale <p>) (Qty scale <s>) (Qty scale <p*s>))) (abstraction (<op> (representation param) (representation subject))))] @@ -75,14 +75,14 @@ (is (-> (Qty Any a) Int) out))) - (def: .public (unit _) + (def .public (unit _) (Ex (_ a) (-> Any (Unit a))) (implementation - (def: in ..quantity) - (def: out ..number))) + (def in ..quantity) + (def out ..number))) ) -(def: .public type +(def .public type (syntax (_ [it <code>.any]) (macro.with_symbols [g!a] (in (list (` ((~! //.by_example) [(~ g!a)] @@ -91,7 +91,7 @@ (~ g!a)))))))) (with_template [<unit> <type>] - [(def: .public <unit> + [(def .public <unit> (..unit [])) (type: .public <type> diff --git a/stdlib/source/library/lux/type/unit/scale.lux b/stdlib/source/library/lux/type/unit/scale.lux index fe2d020bf..efca489a0 100644 --- a/stdlib/source/library/lux/type/unit/scale.lux +++ b/stdlib/source/library/lux/type/unit/scale.lux @@ -22,24 +22,24 @@ (is Ratio ratio))) -(def: .public (scale ratio) +(def .public (scale ratio) (Ex (_ s) (-> Ratio (Scale s))) (let [(open "/[0]") ratio] (implementation - (def: up + (def up (|>> //.number (i.* (.int /#numerator)) (i./ (.int /#denominator)) //.quantity)) - (def: down + (def down (|>> //.number (i.* (.int /#denominator)) (i./ (.int /#numerator)) //.quantity)) - (def: ratio + (def ratio ratio)))) -(def: .public (re_scaled from to quantity) +(def .public (re_scaled from to quantity) (All (_ si so u) (-> (Scale si) (Scale so) (//.Qty si u) (//.Qty so u))) (let [(open "/[0]") (ratio./ (at from ratio) (at to ratio))] @@ -49,7 +49,7 @@ (i./ (.int /#denominator)) //.quantity))) -(def: .public type +(def .public type (syntax (_ [it <code>.any]) (macro.with_symbols [g!a] (in (list (` ((~! ///.by_example) [(~ g!a)] @@ -58,14 +58,14 @@ (~ g!a)))))))) (with_template [<order_of_magnitude> <up> <up_type> <down> <down_type>] - [(def: .public <up> + [(def .public <up> (scale [ratio.#numerator <order_of_magnitude> ratio.#denominator 1])) (type: .public <up_type> (~ (..type <up>))) - (def: .public <down> + (def .public <down> (scale [ratio.#numerator 1 ratio.#denominator <order_of_magnitude>])) diff --git a/stdlib/source/library/lux/type/variance.lux b/stdlib/source/library/lux/type/variance.lux index 49563c465..53797fc61 100644 --- a/stdlib/source/library/lux/type/variance.lux +++ b/stdlib/source/library/lux/type/variance.lux @@ -17,7 +17,7 @@ (Primitive "#Mutable" [(-> w r)])) (with_template [<name> <type>] - [(def: .public <name> + [(def .public <name> (template (<name> it) [((.is (.All (_ r w) <type>) (.|>> .as_expected)) @@ -34,7 +34,7 @@ (Mutable Any a)) (with_template [<name> <type>] - [(def: .public <name> + [(def .public <name> (template (<name> it) [((.is (.All (_ r w) <type>) (.|>>)) diff --git a/stdlib/source/library/lux/world/console.lux b/stdlib/source/library/lux/world/console.lux index 4112af8f4..b5cc2db91 100644 --- a/stdlib/source/library/lux/world/console.lux +++ b/stdlib/source/library/lux/world/console.lux @@ -28,11 +28,11 @@ (is (-> [] (! (Try Any))) close))) -(def: .public (async console) +(def .public (async console) (-> (Console IO) (Console Async)) (`` (implementation (~~ (with_template [<capability>] - [(def: <capability> + [(def <capability> (|>> (at console <capability>) async.future))] [read] @@ -65,7 +65,7 @@ (exception: .public cannot_open) - (def: .public default + (def .public default (IO (Try (Console IO))) (do io.monad [?jvm_console (java/lang/System::console)] @@ -80,19 +80,19 @@ {try.#Success} (is (Console IO)) ... TODO: Remove ASAP (implementation - (def: (read _) + (def (read _) (|> jvm_input java/io/InputStream::read (at (try.with io.monad) each (|>> ffi.of_int .nat)))) - (def: (read_line _) + (def (read_line _) (io#each (try#each (|>> ffi.of_string)) (java/io/Console::readLine jvm_console))) - (def: (write message) + (def (write message) (java/io/PrintStream::print (ffi.as_string message) jvm_output)) - (def: close + (def close (|>> (exception.except ..cannot_close) in)))))))))] (for @.old (these <jvm>) @.jvm (these <jvm>) @@ -118,7 +118,7 @@ (exception: .public cannot_read) - (def: !read + (def !read (template (_ <type> <query>) [(let [it (process::stdin)] (case (Readable_Stream::read it) @@ -139,20 +139,20 @@ {.#None} (async#in (exception.except ..cannot_read []))))])) - (def: .public default + (def .public default (Maybe (Console Async)) (if ffi.on_node_js? {.#Some (implementation - (def: (read _) + (def (read _) (!read Char (do maybe.monad [head (text.char 0 input) [_ tail] (text.split_at 1 input)] (in [head tail])))) - (def: (read_line _) + (def (read_line _) (!read Text (text.split_by text.\n input))) - (def: (write it) + (def (write it) (let [[read! write!] (is [(async.Async (Try [])) (async.Resolver (Try []))] (async.async []))] (exec @@ -160,12 +160,12 @@ (process::stdout)) read!))) - (def: close + (def close (|>> (exception.except ..cannot_close) async#in)))} {.#None}))) (these))) -(def: .public (write_line message console) +(def .public (write_line message console) (All (_ !) (-> Text (Console !) (! (Try Any)))) (at console write (format message text.new_line))) @@ -180,12 +180,12 @@ (is (-> s (Try s)) on_close))) -(def: .public (mock mock init) +(def .public (mock mock init) (All (_ s) (-> (Mock s) s (Console IO))) (let [state (atom.atom init)] (`` (implementation (~~ (with_template [<method> <mock>] - [(def: (<method> _) + [(def (<method> _) (do [! io.monad] [|state| (atom.read! state)] (case (at mock <mock> |state|) @@ -201,7 +201,7 @@ [read_line on_read_line] )) - (def: (write input) + (def (write input) (do [! io.monad] [|state| (atom.read! state)] (case (at mock on_write input |state|) @@ -213,7 +213,7 @@ {try.#Failure error} (in {try.#Failure error})))) - (def: (close _) + (def (close _) (do [! io.monad] [|state| (atom.read! state)] (case (at mock on_close |state|) diff --git a/stdlib/source/library/lux/world/db/jdbc.lux b/stdlib/source/library/lux/world/db/jdbc.lux index d19e53c47..243ced2bf 100644 --- a/stdlib/source/library/lux/world/db/jdbc.lux +++ b/stdlib/source/library/lux/world/db/jdbc.lux @@ -90,7 +90,7 @@ (is (Can_Close !) close))) -(def: (with_statement statement conn action) +(def (with_statement statement conn action) (All (_ i a) (-> (Statement i) java/sql/Connection (-> java/sql/PreparedStatement (IO (Try a))) @@ -104,18 +104,18 @@ _ (java/sql/Statement::close prepared)] (in result))) -(def: .public (async db) +(def .public (async db) (-> (DB IO) (DB Async)) (`` (implementation (~~ (with_template [<name> <forge>] - [(def: <name> (<forge> (|>> (!.use (at db <name>)) async.future)))] + [(def <name> (<forge> (|>> (!.use (at db <name>)) async.future)))] [execute can_execute] [insert can_insert] [close can_close] [query can_query]))))) -(def: .public (connect creds) +(def .public (connect creds) (-> Credentials (IO (Try (DB IO)))) (do (try.with io.monad) [connection (java/sql/DriverManager::getConnection (the #url creds) @@ -123,7 +123,7 @@ (the #password creds))] (in (is (DB IO) (implementation - (def: execute + (def execute (..can_execute (function (execute statement) (with_statement statement connection @@ -132,7 +132,7 @@ [row_count (java/sql/PreparedStatement::executeUpdate prepared)] (in (.nat row_count)))))))) - (def: insert + (def insert (..can_insert (function (insert statement) (with_statement statement connection @@ -142,12 +142,12 @@ result_set (io.io (java/sql/Statement::getGeneratedKeys prepared))] (/output.rows /output.long result_set))))))) - (def: close + (def close (..can_close (function (close _) (java/sql/Connection::close connection)))) - (def: query + (def query (..can_query (function (query [statement output]) (with_statement statement connection @@ -157,7 +157,7 @@ (/output.rows output result_set))))))) ))))) -(def: .public (with_db creds action) +(def .public (with_db creds action) (All (_ a) (-> Credentials (-> (DB IO) (IO (Try a))) @@ -168,7 +168,7 @@ _ (!.use (at db close) [])] (in result))) -(def: .public (with_async_db creds action) +(def .public (with_async_db creds action) (All (_ a) (-> Credentials (-> (DB Async) (Async (Try a))) diff --git a/stdlib/source/library/lux/world/db/jdbc/input.lux b/stdlib/source/library/lux/world/db/jdbc/input.lux index 7a8c47899..c0e48dec4 100644 --- a/stdlib/source/library/lux/world/db/jdbc/input.lux +++ b/stdlib/source/library/lux/world/db/jdbc/input.lux @@ -47,32 +47,32 @@ (-> a [Nat java/sql/PreparedStatement] (Try [Nat java/sql/PreparedStatement]))) -(def: .public contravariant +(def .public contravariant (Contravariant Input) (implementation - (def: (each f fb) + (def (each f fb) (function (fa value circumstance) (fb (f value) circumstance))))) -(def: .public (and pre post) +(def .public (and pre post) (All (_ l r) (-> (Input l) (Input r) (Input [l r]))) (function (_ [left right] context) (do try.monad [context (pre left context)] (post right context)))) -(def: .public (fail error) +(def .public (fail error) (All (_ a) (-> Text (Input a))) (function (_ value [idx context]) {try.#Failure error})) -(def: .public empty +(def .public empty (Input Any) (function (_ value context) {try.#Success context})) (with_template [<function> <type> <setter>] - [(def: .public <function> + [(def .public <function> (Input <type>) (function (_ value [idx statement]) (do try.monad @@ -94,7 +94,7 @@ ) (with_template [<function> <setter> <constructor>] - [(def: .public <function> + [(def .public <function> (Input Instant) (function (_ value [idx statement]) (do try.monad diff --git a/stdlib/source/library/lux/world/db/jdbc/output.lux b/stdlib/source/library/lux/world/db/jdbc/output.lux index 3035cff80..a844ac78a 100644 --- a/stdlib/source/library/lux/world/db/jdbc/output.lux +++ b/stdlib/source/library/lux/world/db/jdbc/output.lux @@ -50,10 +50,10 @@ (type: .public (Output a) (-> [Nat java/sql/ResultSet] (Try [Nat a]))) -(def: .public functor +(def .public functor (Functor Output) (implementation - (def: (each f fa) + (def (each f fa) (function (_ idx+rs) (case (fa idx+rs) {try.#Failure error} @@ -62,12 +62,12 @@ {try.#Success [idx' value]} {try.#Success [idx' (f value)]}))))) -(def: .public apply +(def .public apply (Apply Output) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (apply ff fa) + (def (apply ff fa) (function (_ [idx rs]) (case (ff [idx rs]) {try.#Success [idx' f]} @@ -81,16 +81,16 @@ {try.#Failure msg} {try.#Failure msg}))))) -(def: .public monad +(def .public monad (Monad Output) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in a) + (def (in a) (function (_ [idx rs]) {.#Some [idx a]})) - (def: (conjoint mma) + (def (conjoint mma) (function (_ [idx rs]) (case (mma [idx rs]) {try.#Failure error} @@ -99,12 +99,12 @@ {try.#Success [idx' ma]} (ma [idx' rs])))))) -(def: .public (fail error) +(def .public (fail error) (All (_ a) (-> Text (Output a))) (function (_ [idx result_set]) {try.#Failure error})) -(def: .public (and left right) +(def .public (and left right) (All (_ a b) (-> (Output a) (Output b) (Output [a b]))) (do ..monad @@ -113,7 +113,7 @@ (in [=left =right]))) (with_template [<func_name> <method_name> <type>] - [(def: .public <func_name> + [(def .public <func_name> (Output <type>) (function (_ [idx result_set]) (case (<method_name> [(.int idx)] result_set) @@ -138,7 +138,7 @@ ) (with_template [<func_name> <method_name>] - [(def: .public <func_name> + [(def .public <func_name> (Output Instant) (function (_ [idx result_set]) (case (<method_name> [(.int idx)] result_set) @@ -154,7 +154,7 @@ [time_stamp java/sql/ResultSet::getTimestamp] ) -(def: .public (rows output results) +(def .public (rows output results) (All (_ a) (-> (Output a) java/sql/ResultSet (IO (Try (List a))))) (case (java/sql/ResultSet::next results) {try.#Success has_next?} diff --git a/stdlib/source/library/lux/world/db/sql.lux b/stdlib/source/library/lux/world/db/sql.lux index 5c9fedc94..5dd75c61e 100644 --- a/stdlib/source/library/lux/world/db/sql.lux +++ b/stdlib/source/library/lux/world/db/sql.lux @@ -15,7 +15,7 @@ [type [primitive (.except)]]]]) -(def: parenthesize +(def parenthesize (-> Text Text) (text.enclosed ["(" ")"])) @@ -60,7 +60,7 @@ (type: .public Alias Text) -(def: .public no_alias Alias "") +(def .public no_alias Alias "") (primitive .public (SQL kind) Text @@ -97,51 +97,51 @@ [Statement (Statement' Any)] ) - (def: Base_Query (.type (Query No_Where No_Having No_Order No_Group No_Limit No_Offset))) - (def: Any_Query (.type (Query Any Any Any Any Any Any))) + (def Base_Query (.type (Query No_Where No_Having No_Order No_Group No_Limit No_Offset))) + (def Any_Query (.type (Query Any Any Any Any Any Any))) ... Only use this function for debugging purposes. ... Do not use this function to actually execute SQL code. - (def: .public read + (def .public read (-> (SQL Any) Text) (|>> representation)) - (def: .public (sql action) + (def .public (sql action) (-> Statement Text) (format (representation action) ";")) - (def: listing + (def listing (-> (List (SQL Any)) Text) (|>> (list#each (|>> representation)) (text.interposed ", "))) ... Value - (def: .public ? Placeholder (abstraction "?")) + (def .public ? Placeholder (abstraction "?")) - (def: literal + (def literal (-> Text Literal) (|>> abstraction)) - (def: .public null Literal (..literal "NULL")) + (def .public null Literal (..literal "NULL")) - (def: .public (int value) + (def .public (int value) (-> Int Literal) (..literal (if (i.< +0 value) (%.int value) (%.nat (.nat value))))) - (def: .public function + (def .public function (-> Text Function) (|>> abstraction)) - (def: .public (call function parameters) + (def .public (call function parameters) (-> Function (List Value) Value) (abstraction (format (representation function) (..parenthesize (..listing parameters))))) ... Condition (with_template [<name> <sql_op>] - [(def: .public (<name> reference sample) + [(def .public (<name> reference sample) (-> Value Value Condition) (abstraction (..parenthesize @@ -160,7 +160,7 @@ [ilike? "ILIKE"] ) - (def: .public (between from to sample) + (def .public (between from to sample) (-> Value Value Value Condition) (abstraction (..parenthesize @@ -168,7 +168,7 @@ " BETWEEN " (representation from) " AND " (representation to))))) - (def: .public (in options value) + (def .public (in options value) (-> (List Value) Value Condition) (abstraction (format (representation value) @@ -176,7 +176,7 @@ (..parenthesize (listing options))))) (with_template [<func_name> <sql_op>] - [(def: .public (<func_name> left right) + [(def .public (<func_name> left right) (-> Condition Condition Condition) (abstraction (format (..parenthesize (representation left)) @@ -188,7 +188,7 @@ ) (with_template [<name> <type> <sql>] - [(def: .public <name> + [(def .public <name> (-> <type> Condition) (|>> representation ..parenthesize (format <sql> " ") abstraction))] @@ -198,7 +198,7 @@ ... Query (with_template [<name> <type> <decoration>] - [(def: .public <name> + [(def .public <name> (-> <type> Source) (|>> representation <decoration> abstraction))] @@ -208,7 +208,7 @@ ) (with_template [<func_name> <op>] - [(def: .public (<func_name> columns source) + [(def .public (<func_name> columns source) (-> (List [Column Alias]) Source Base_Query) (abstraction (format <op> @@ -232,7 +232,7 @@ ) (with_template [<name> <join_text>] - [(def: .public (<name> table condition prev) + [(def .public (<name> table condition prev) (-> Table Condition Base_Query Base_Query) (abstraction (format (representation prev) @@ -247,7 +247,7 @@ ) (with_template [<function> <sql_op>] - [(def: .public (<function> left right) + [(def .public (<function> left right) (-> Any_Query Any_Query (Query Without_Where Without_Having No_Order No_Group No_Limit No_Offset)) (abstraction (format (representation left) @@ -260,7 +260,7 @@ ) (with_template [<name> <sql> <variables> <input> <output>] - [(`` (def: .public (<name> value query) + [(`` (def .public (<name> value query) (All (_ (~~ (template.spliced <variables>))) (-> Nat <input> <output>)) (abstraction @@ -278,7 +278,7 @@ ) (with_template [<name> <sql>] - [(def: .public <name> + [(def .public <name> Order (abstraction <sql>))] @@ -286,7 +286,7 @@ [descending "DESC"] ) - (def: .public (order_by pairs query) + (def .public (order_by pairs query) (All (_ where having group limit offset) (-> (List [Value Order]) (Query where having No_Order group limit offset) @@ -304,7 +304,7 @@ (format (representation value) " " (representation order)))) (text.interposed ", ")))))) - (def: .public (group_by pairs query) + (def .public (group_by pairs query) (All (_ where having order limit offset) (-> (List Value) (Query where having order No_Group limit offset) @@ -320,7 +320,7 @@ (..listing pairs))))) ... Command - (def: .public (insert table columns rows) + (def .public (insert table columns rows) (-> Table (List Column) (List (List Value)) (Command Without_Where Without_Having)) (abstraction (format "INSERT INTO " (representation table) " " @@ -331,7 +331,7 @@ (text.interposed ", ")) ))) - (def: .public (update table pairs) + (def .public (update table pairs) (-> Table (List [Column Value]) (Command No_Where No_Having)) (abstraction (format "UPDATE " (representation table) (case pairs @@ -344,12 +344,12 @@ (format (representation column) "=" (representation value)))) (text.interposed ", "))))))) - (def: .public delete + (def .public delete (-> Table (Command No_Where No_Having)) (|>> representation (format "DELETE FROM ") abstraction)) ... Action - (def: .public (where condition prev) + (def .public (where condition prev) (All (_ kind having) (-> Condition (Action No_Where having kind) (Action With_Where having kind))) (abstraction @@ -357,7 +357,7 @@ " WHERE " (representation condition)))) - (def: .public (having condition prev) + (def .public (having condition prev) (All (_ where kind) (-> Condition (Action where No_Having kind) (Action where With_Having kind))) (abstraction @@ -366,12 +366,12 @@ (representation condition)))) ... Schema - (def: .public type + (def .public type (-> Text (Schema Value)) (|>> abstraction)) (with_template [<name> <attr>] - [(def: .public (<name> attr) + [(def .public (<name> attr) (-> (Schema Value) (Schema Value)) (abstraction (format (representation attr) " " <attr>)))] @@ -381,22 +381,22 @@ [stored "STORED"] ) - (def: .public (default value attr) + (def .public (default value attr) (-> Value (Schema Value) (Schema Value)) (abstraction (format (representation attr) " DEFAULT " (representation value)))) - (def: .public (define_column name type) + (def .public (define_column name type) (-> Column (Schema Value) (Schema Column)) (abstraction (format (representation name) " " (representation type)))) - (def: .public (auto_increment offset column) + (def .public (auto_increment offset column) (-> Int (Schema Column) (Schema Column)) (abstraction (format (representation column) " AUTO_INCREMENT=" (representation (..int offset))))) - (def: .public (create_table or_replace? table columns) + (def .public (create_table or_replace? table columns) (-> Bit Table (List (Schema Column)) Definition) (let [command (if or_replace? "CREATE OR REPLACE TABLE" @@ -405,13 +405,13 @@ (format command " " (representation table) (..parenthesize (..listing columns)))))) - (def: .public (create_table_as table query) + (def .public (create_table_as table query) (-> Table Any_Query Definition) (abstraction (format "CREATE TABLE " (representation table) " AS " (representation query)))) (with_template [<name> <sql>] - [(def: .public (<name> table) + [(def .public (<name> table) (-> Table Definition) (abstraction (format <sql> " TABLE " (representation table))))] @@ -420,18 +420,18 @@ [truncate "TRUNCATE"] ) - (def: .public (add_column table column) + (def .public (add_column table column) (-> Table (Schema Column) Definition) (abstraction (format "ALTER TABLE " (representation table) " ADD " (representation column)))) - (def: .public (drop_column table column) + (def .public (drop_column table column) (-> Table Column Definition) (abstraction (format "ALTER TABLE " (representation table) " DROP COLUMN " (representation column)))) (with_template [<name> <type>] - [(def: .public (<name> name) + [(def .public (<name> name) (-> Text <type>) (abstraction name))] @@ -443,7 +443,7 @@ ) (with_template [<name> <type> <sql>] - [(def: .public <name> + [(def .public <name> (-> <type> Definition) (|>> representation (format <sql> " ") abstraction))] @@ -453,7 +453,7 @@ ) (with_template [<name> <sql>] - [(def: .public (<name> view query) + [(def .public (<name> view query) (-> View Any_Query Definition) (abstraction (format <sql> " " (representation view) " AS " (representation query))))] @@ -462,13 +462,13 @@ [create_or_replace_view "CREATE OR REPLACE VIEW"] ) - (def: .public (create_index index table unique? columns) + (def .public (create_index index table unique? columns) (-> Index Table Bit (List Column) Definition) (abstraction (format "CREATE " (if unique? "UNIQUE" "") " INDEX " (representation index) " ON " (representation table) " " (..parenthesize (..listing columns))))) - (def: .public (with alias query body) + (def .public (with alias query body) (All (_ where having order group limit offset) (-> Table Any_Query (Query where having order group limit offset) diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux index 0e5dc9440..17bc128e1 100644 --- a/stdlib/source/library/lux/world/file.lux +++ b/stdlib/source/library/lux/world/file.lux @@ -80,7 +80,7 @@ ))) )) -(def: (un_rooted fs path) +(def (un_rooted fs path) (All (_ !) (-> (System !) Path (Maybe [Path Text]))) (let [/ (at fs separator)] (case (text.last_index / path) @@ -93,27 +93,27 @@ [_ child] (text.split_at (text.size /) temp)] (in [parent child]))))) -(def: .public (parent fs path) +(def .public (parent fs path) (All (_ !) (-> (System !) Path (Maybe Path))) (|> path (..un_rooted fs) (maybe#each product.left))) -(def: .public (name fs path) +(def .public (name fs path) (All (_ !) (-> (System !) Path Text)) (|> path (..un_rooted fs) (maybe#each product.right) (maybe.else path))) -(def: .public (async fs) +(def .public (async fs) (-> (System IO) (System Async)) (`` (implementation - (def: separator + (def separator (at fs separator)) (~~ (with_template [<name>] - [(def: <name> + [(def <name> (|>> (at fs <name>) async.future))] @@ -131,7 +131,7 @@ [delete])) (~~ (with_template [<name>] - [(def: (<name> path input) + [(def (<name> path input) (async.future (at fs <name> path input)))] [modify] @@ -140,7 +140,7 @@ [move])) ))) -(def: .public (rooted fs parent child) +(def .public (rooted fs parent child) (All (_ !) (-> (System !) Path Text Path)) (format parent (at fs separator) child)) @@ -200,14 +200,14 @@ "[1]::[0]" (new [java/io/File] "io" "try")) - (`` (def: .public default + (`` (def .public default (System IO) (implementation - (def: separator + (def separator (ffi.of_string (java/io/File::separator))) (~~ (with_template [<name> <method>] - [(def: <name> + [(def <name> (|>> ffi.as_string java/io/File::new <method> @@ -217,13 +217,13 @@ [directory? java/io/File::isDirectory] )) - (def: make_directory + (def make_directory (|>> ffi.as_string java/io/File::new java/io/File::mkdir)) (~~ (with_template [<name> <method>] - [(def: (<name> path) + [(def (<name> path) (do [! (try.with io.monad)] [?children (java/io/File::listFiles (java/io/File::new (ffi.as_string path)))] (case ?children @@ -241,25 +241,25 @@ [sub_directories java/io/File::isDirectory] )) - (def: file_size + (def file_size (|>> ffi.as_string java/io/File::new java/io/File::length (at (try.with io.monad) each (|>> ffi.of_long .nat)))) - (def: last_modified + (def last_modified (|>> ffi.as_string java/io/File::new (java/io/File::lastModified) (at (try.with io.monad) each (|>> ffi.of_long duration.of_millis instant.absolute)))) - (def: can_execute? + (def can_execute? (|>> ffi.as_string java/io/File::new java/io/File::canExecute (io#each (try#each (|>> ffi.of_boolean))))) - (def: (read path) + (def (read path) (do (try.with io.monad) [.let [file (java/io/File::new (ffi.as_string path))] size (java/io/File::length file) @@ -269,20 +269,20 @@ _ (java/lang/AutoCloseable::close stream)] (in data))) - (def: (delete path) + (def (delete path) (|> path ffi.as_string java/io/File::new java/io/File::delete)) - (def: (modify path time_stamp) + (def (modify path time_stamp) (|> path ffi.as_string java/io/File::new (java/io/File::setLastModified (|> time_stamp instant.relative duration.millis ffi.as_long)))) (~~ (with_template [<flag> <name>] - [(def: (<name> path data) + [(def (<name> path data) (do (try.with io.monad) [stream (java/io/FileOutputStream::new (java/io/File::new (ffi.as_string path)) (ffi.as_boolean <flag>)) _ (java/io/OutputStream::write data stream) @@ -293,7 +293,7 @@ [#1 append] )) - (def: (move origin destination) + (def (move origin destination) (|> origin ffi.as_string java/io/File::new @@ -328,7 +328,7 @@ "[1]::[0]" (toString [] ffi.String)) - (def: with_async + (def with_async (template (_ <write> <type> <body>) [(template.with_locals [<read>] (let [[<read> <write>] (is [(Async <type>) (async.Resolver <type>)] @@ -352,7 +352,7 @@ (unlink [ffi.String ffi.Function] Any) (rmdir [ffi.String ffi.Function] Any)) - (def: (any_callback write!) + (def (any_callback write!) (-> (async.Resolver (Try Any)) ffi.Function) (<| (ffi.function (_ [error Error]) Any) io.run! @@ -361,7 +361,7 @@ {try.#Success []} {try.#Failure (Error::toString error)}))) - (def: (value_callback write!) + (def (value_callback write!) (All (_ a) (-> (async.Resolver (Try a)) ffi.Function)) (<| (ffi.function (_ [error Error datum Any]) Any) io.run! @@ -374,7 +374,7 @@ "[1]::[0]" (sep ffi.String)) - (def: .public default + (def .public default (Maybe (System Async)) (do maybe.monad [node_fs (node_js.require "fs") @@ -385,11 +385,11 @@ "/")]] (in (is (System Async) (`` (implementation - (def: separator + (def separator js_separator) (~~ (with_template [<name> <method>] - [(def: (<name> path) + [(def (<name> path) (do async.monad [?stats (with_async write! (Try Stats) (Fs::stat path (..value_callback write!) @@ -405,7 +405,7 @@ [directory? Stats::isDirectory] )) - (def: (make_directory path) + (def (make_directory path) (do async.monad [outcome (with_async write! (Try Any) (Fs::access path @@ -421,7 +421,7 @@ (Fs::mkdir path (..any_callback write!) node_fs))))) (~~ (with_template [<name> <method>] - [(def: (<name> path) + [(def (<name> path) (do [! (try.with async.monad)] [subs (with_async write! (Try (Array ffi.String)) (Fs::readdir path (..value_callback write!) node_fs))] @@ -439,7 +439,7 @@ [sub_directories Stats::isDirectory] )) - (def: (file_size path) + (def (file_size path) (do (try.with async.monad) [stats (with_async write! (Try Stats) (Fs::stat path (..value_callback write!) @@ -448,7 +448,7 @@ Stats::size f.nat)))) - (def: (last_modified path) + (def (last_modified path) (do (try.with async.monad) [stats (with_async write! (Try Stats) (Fs::stat path (..value_callback write!) @@ -459,7 +459,7 @@ duration.of_millis instant.absolute)))) - (def: (can_execute? path) + (def (can_execute? path) (at async.monad each (|>> (pipe.case {try.#Success _} @@ -474,12 +474,12 @@ (..any_callback write!) node_fs)))) - (def: (read path) + (def (read path) (with_async write! (Try Binary) (Fs::readFile path (..value_callback write!) node_fs))) - (def: (delete path) + (def (delete path) (do (try.with async.monad) [stats (with_async write! (Try Stats) (Fs::stat path (..value_callback write!) node_fs))] @@ -488,14 +488,14 @@ (Fs::unlink path (..any_callback write!) node_fs) (Fs::rmdir path (..any_callback write!) node_fs))))) - (def: (modify path time_stamp) + (def (modify path time_stamp) (with_async write! (Try Any) (let [when (|> time_stamp instant.relative duration.millis i.frac)] (Fs::utimes path when when (..any_callback write!) node_fs)))) (~~ (with_template [<name> <method>] - [(def: (<name> path data) + [(def (<name> path data) (with_async write! (Try Any) (<method> path (Buffer::from data) (..any_callback write!) node_fs)))] @@ -504,7 +504,7 @@ [append Fs::appendFile] )) - (def: (move origin destination) + (def (move origin destination) (with_async write! (Try Any) (Fs::rename origin destination (..any_callback write!) node_fs)))))))))) @@ -545,17 +545,17 @@ ("static" getsize [ffi.String] "io" "try" ffi.Integer) ("static" getmtime [ffi.String] "io" "try" ffi.Float)) - (def: python_separator + (def python_separator (os/path::sep)) - (`` (def: .public default + (`` (def .public default (System IO) (implementation - (def: separator + (def separator ..python_separator) (~~ (with_template [<name> <method>] - [(def: <name> + [(def <name> (|>> <method> (io#each (|>> (try.else false)))))] @@ -563,11 +563,11 @@ [directory? os/path::isdir] )) - (def: make_directory + (def make_directory os::mkdir) (~~ (with_template [<name> <method>] - [(def: (<name> path) + [(def (<name> path) (let [! (try.with io.monad)] (|> path os::listdir @@ -583,40 +583,40 @@ [sub_directories os/path::isdir] )) - (def: file_size + (def file_size (|>> os/path::getsize (at (try.with io.monad) each (|>> .nat)))) - (def: last_modified + (def last_modified (|>> os/path::getmtime (at (try.with io.monad) each (|>> f.int (i.* +1,000) duration.of_millis instant.absolute)))) - (def: (can_execute? path) + (def (can_execute? path) (os::access path (os::X_OK))) - (def: (read path) + (def (read path) (do (try.with io.monad) [file (..open path "rb") data (PyFile::read file) _ (PyFile::close file)] (in data))) - (def: (delete path) + (def (delete path) (do (try.with io.monad) [? (os/path::isfile path)] (if ? (os::remove path) (os::rmdir path)))) - (def: (modify path time_stamp) + (def (modify path time_stamp) (let [when (|> time_stamp instant.relative duration.millis (i./ +1,000))] (os::utime path (..tuple [when when])))) (~~ (with_template [<name> <mode>] - [(def: (<name> path data) + [(def (<name> path data) (do (try.with io.monad) [file (..open path <mode>) _ (PyFile::write data file)] @@ -626,7 +626,7 @@ [append "ab"] )) - (def: (move origin destination) + (def (move origin destination) (os::rename origin destination)) )))) @@ -670,18 +670,18 @@ ("static" rmdir [Path] "io" "try" "?" Any) ("static" mkdir [Path] "io" "try" "?" Any)) - (def: ruby_separator + (def ruby_separator Text (..RubyFile::SEPARATOR)) - (`` (def: .public default + (`` (def .public default (System IO) (implementation - (def: separator + (def separator ..ruby_separator) (~~ (with_template [<name> <test>] - [(def: <name> + [(def <name> (|>> <test> (io#each (|>> (try.else false)))))] @@ -689,11 +689,11 @@ [directory? RubyFile::directory?] )) - (def: make_directory + (def make_directory FileUtils::mkdir) (~~ (with_template [<name> <test>] - [(def: (<name> path) + [(def (<name> path) (do [! (try.with io.monad)] [self (Dir::open path) children (Dir::children self) @@ -720,7 +720,7 @@ )) (~~ (with_template [<name> <pipeline>] - [(def: <name> + [(def <name> (let [! (try.with io.monad)] (|>> RubyFile::stat (at ! each (`` (|>> (~~ (template.spliced <pipeline>))))))))] @@ -735,21 +735,21 @@ [can_execute? [Stat::executable?]] )) - (def: (read path) + (def (read path) (do (try.with io.monad) [file (RubyFile::open path "rb") data (RubyFile::read file) _ (RubyFile::close file)] (in data))) - (def: (delete path) + (def (delete path) (do (try.with io.monad) [? (RubyFile::file? path)] (if ? (RubyFile::delete path) (FileUtils::rmdir path)))) - (def: (modify path moment) + (def (modify path moment) (let [moment (|> moment instant.relative duration.millis @@ -759,7 +759,7 @@ (RubyFile::utime moment moment path))) (~~ (with_template [<mode> <name>] - [(def: (<name> path data) + [(def (<name> path data) (do [! (try.with io.monad)] [file (RubyFile::open path <mode>) data (RubyFile::write data file) @@ -771,7 +771,7 @@ ["ab" append] )) - (def: (move origin destination) + (def (move origin destination) (do (try.with io.monad) [_ (FileUtils::move origin destination)] (in []))) @@ -807,8 +807,8 @@ ... ... https://www.php.net/manual/en/function.mkdir.php ... (ffi.import (mkdir [Path] "io" "try" ffi.Boolean)) - ... (def: byte_array_format "C*") - ... (def: default_separator (..DIRECTORY_SEPARATOR)) + ... (def byte_array_format "C*") + ... (def default_separator (..DIRECTORY_SEPARATOR)) ... (with_template [<name>] ... [(exception: .public (<name> [file Path]) @@ -818,11 +818,11 @@ ... [cannot_write_to_file] ... ) - ... (`` (def: (file path) + ... (`` (def (file path) ... (-> Path (File IO)) ... (implementation ... (~~ (with_template [<name> <mode>] - ... [(def: (<name> data) + ... [(def (<name> data) ... (do [! (try.with io.monad)] ... [outcome (..file_put_contents [path ("php pack" ..byte_array_format data) <mode>])] ... (if (bit#= false (as Bit outcome)) @@ -833,18 +833,18 @@ ... [append (..FILE_APPEND)] ... )) - ... (def: (content _) + ... (def (content _) ... (do [! (try.with io.monad)] ... [data (..file_get_contents [path])] ... (if (bit#= false (as Bit data)) ... (at io.monad in (exception.except ..cannot_find_file [path])) ... (in (..unpack [..byte_array_format data]))))) - ... (def: path + ... (def path ... path) ... (~~ (with_template [<name> <ffi> <pipeline>] - ... [(def: (<name> _) + ... [(def (<name> _) ... (do [! (try.with io.monad)] ... [value (<ffi> [path])] ... (if (bit#= false (as Bit value)) @@ -855,24 +855,24 @@ ... [last_modified ..filemtime [(i.* +1,000) duration.of_millis instant.absolute]] ... )) - ... (def: (can_execute? _) + ... (def (can_execute? _) ... (..is_executable [path])) - ... (def: (modify moment) + ... (def (modify moment) ... (do [! (try.with io.monad)] ... [verdict (..touch [path (|> moment instant.relative duration.millis (i./ +1,000))])] ... (if (bit#= false (as Bit verdict)) ... (at io.monad in (exception.except ..cannot_find_file [path])) ... (in [])))) - ... (def: (move destination) + ... (def (move destination) ... (do [! (try.with io.monad)] ... [verdict (..rename [path destination])] ... (if (bit#= false (as Bit verdict)) ... (at io.monad in (exception.except ..cannot_find_file [path])) ... (in (file destination))))) - ... (def: (delete _) + ... (def (delete _) ... (do (try.with io.monad) ... [verdict (..unlink [path])] ... (if (bit#= false (as Bit verdict)) @@ -880,14 +880,14 @@ ... (in [])))) ... ))) - ... (`` (def: (directory path) + ... (`` (def (directory path) ... (-> Path (Directory IO)) ... (implementation - ... (def: scope + ... (def scope ... path) ... (~~ (with_template [<name> <test> <constructor> <capability>] - ... [(def: (<name> _) + ... [(def (<name> _) ... (do [! (try.with io.monad)] ... [children (..scandir [path])] ... (loop (again [input (|> children @@ -912,7 +912,7 @@ ... [directories ..is_dir directory Directory] ... )) - ... (def: (discard _) + ... (def (discard _) ... (do (try.with io.monad) ... [verdict (..rmdir [path])] ... (if (bit#= false (as Bit verdict)) @@ -920,11 +920,11 @@ ... (in [])))) ... ))) - ... (`` (def: .public default + ... (`` (def .public default ... (System IO) ... (implementation ... (~~ (with_template [<name> <test> <constructor> <exception>] - ... [(def: (<name> path) + ... [(def (<name> path) ... (do [! (try.with io.monad)] ... [verdict (<test> path)] ... (at io.monad in @@ -936,7 +936,7 @@ ... [directory ..is_dir ..directory ..cannot_find_directory] ... )) - ... (def: (make_file path) + ... (def (make_file path) ... (do [! (try.with io.monad)] ... [verdict (..touch [path (|> instant.now io.run! instant.relative duration.millis (i./ +1,000))])] ... (at io.monad in @@ -944,7 +944,7 @@ ... {try.#Success (..file path)} ... (exception.except ..cannot_make_file [path]))))) - ... (def: (make_directory path) + ... (def (make_directory path) ... (do [! (try.with io.monad)] ... [verdict (..mkdir path)] ... (at io.monad in @@ -952,14 +952,14 @@ ... {try.#Success (..directory path)} ... (exception.except ..cannot_make_directory [path]))))) - ... (def: separator + ... (def separator ... ..default_separator) ... ))) ... ) (these))) -(def: .public (exists? monad fs path) +(def .public (exists? monad fs path) (All (_ !) (-> (Monad !) (System !) Path (! Bit))) (do monad [verdict (at fs file? path)] @@ -977,11 +977,11 @@ (Rec Mock (Dictionary Text (Either Mock_File Mock)))) -(def: empty_mock +(def empty_mock Mock (dictionary.empty text.hash)) -(def: (retrieve_mock_file! separator path mock) +(def (retrieve_mock_file! separator path mock) (-> Text Path Mock (Try [Text Mock_File])) (loop (again [directory mock trail (text.all_split_by separator path)]) @@ -1005,7 +1005,7 @@ {.#End} (exception.except ..cannot_find_file [path])))) -(def: (update_mock_file! / path now content mock) +(def (update_mock_file! / path now content mock) (-> Text Path Instant Binary Mock (Try Mock)) (loop (again [directory mock trail (text.all_split_by / path)]) @@ -1044,7 +1044,7 @@ {.#End} (exception.except ..cannot_find_file [path])))) -(def: (delete_mock_node! / path mock) +(def (delete_mock_node! / path mock) (-> Text Path Mock (Try Mock)) (loop (again [directory mock trail (text.all_split_by / path)]) @@ -1079,7 +1079,7 @@ {.#End} (exception.except ..cannot_delete [path])))) -(def: (attempt! transform var) +(def (attempt! transform var) (All (_ a) (-> (-> a (Try a)) (Var a) (STM (Try Any)))) (do [! stm.monad] [|var| (stm.read var)] @@ -1092,7 +1092,7 @@ {try.#Failure error} (in {try.#Failure error})))) -(def: (make_mock_directory! / path mock) +(def (make_mock_directory! / path mock) (-> Text Path Mock (Try Mock)) (loop (again [directory mock trail (text.all_split_by / path)]) @@ -1120,7 +1120,7 @@ {.#End} (exception.except ..cannot_make_directory [path])))) -(def: (retrieve_mock_directory! / path mock) +(def (retrieve_mock_directory! / path mock) (-> Text Path Mock (Try Mock)) (loop (again [directory mock trail (text.all_split_by / path)]) @@ -1146,15 +1146,15 @@ {.#Item _} (again sub_directory tail))))))) -(def: .public (mock separator) +(def .public (mock separator) (-> Text (System Async)) (let [store (stm.var ..empty_mock)] (`` (implementation - (def: separator + (def separator separator) (~~ (with_template [<method> <retrieve>] - [(def: (<method> path) + [(def (<method> path) (|> store stm.read (at stm.monad each @@ -1166,7 +1166,7 @@ [file? ..retrieve_mock_file!] [directory? ..retrieve_mock_directory!])) - (def: (make_directory path) + (def (make_directory path) (stm.commit! (do [! stm.monad] [|store| (stm.read store)] @@ -1180,7 +1180,7 @@ (in {try.#Failure error}))))) (~~ (with_template [<method> <tag>] - [(def: (<method> path) + [(def (<method> path) (stm.commit! (do stm.monad [|store| (stm.read store)] @@ -1200,7 +1200,7 @@ [sub_directories .#Right] )) - (def: (file_size path) + (def (file_size path) (stm.commit! (do stm.monad [|store| (stm.read store)] @@ -1210,7 +1210,7 @@ (the #mock_content) binary.size))))))) - (def: (last_modified path) + (def (last_modified path) (stm.commit! (do stm.monad [|store| (stm.read store)] @@ -1219,7 +1219,7 @@ (try#each (|>> product.right (the #mock_last_modified)))))))) - (def: (can_execute? path) + (def (can_execute? path) (stm.commit! (do stm.monad [|store| (stm.read store)] @@ -1228,7 +1228,7 @@ (try#each (|>> product.right (the #mock_can_execute)))))))) - (def: (read path) + (def (read path) (stm.commit! (do stm.monad [|store| (stm.read store)] @@ -1237,11 +1237,11 @@ (try#each (|>> product.right (the #mock_content)))))))) - (def: (delete path) + (def (delete path) (stm.commit! (..attempt! (..delete_mock_node! separator path) store))) - (def: (modify path now) + (def (modify path now) (stm.commit! (..attempt! (function (_ |store|) (do try.monad @@ -1249,13 +1249,13 @@ (..update_mock_file! separator path now (the #mock_content file) |store|))) store))) - (def: (write path content) + (def (write path content) (do async.monad [now (async.future instant.now)] (stm.commit! (..attempt! (..update_mock_file! separator path now content) store)))) - (def: (append path content) + (def (append path content) (do async.monad [now (async.future instant.now)] (stm.commit! @@ -1269,7 +1269,7 @@ |store|))) store)))) - (def: (move origin destination) + (def (move origin destination) (stm.commit! (do [! stm.monad] [|store| (stm.read store)] @@ -1286,7 +1286,7 @@ (in {try.#Failure error}))))) )))) -(def: (check_or_make_directory monad fs path) +(def (check_or_make_directory monad fs path) (All (_ !) (-> (Monad !) (System !) Path (! (Try Any)))) (do monad [? (at fs directory? path)] @@ -1294,7 +1294,7 @@ (in {try.#Success []}) (at fs make_directory path)))) -(def: .public (make_directories monad fs path) +(def .public (make_directories monad fs path) (All (_ !) (-> (Monad !) (System !) Path (! (Try Any)))) (let [rooted? (text.starts_with? (at fs separator) path) segments (text.all_split_by (at fs separator) path)] @@ -1326,7 +1326,7 @@ {try.#Failure error} (in {try.#Failure error})))))))) -(def: .public (make_file monad fs content path) +(def .public (make_file monad fs content path) (All (_ !) (-> (Monad !) (System !) Binary Path (! (Try Any)))) (do monad [? (at fs file? path)] diff --git a/stdlib/source/library/lux/world/file/watch.lux b/stdlib/source/library/lux/world/file/watch.lux index dc890fa54..d756ed11c 100644 --- a/stdlib/source/library/lux/world/file/watch.lux +++ b/stdlib/source/library/lux/world/file/watch.lux @@ -38,7 +38,7 @@ #modification Bit #deletion Bit]) - (def: none + (def none Concern (abstraction [#creation false @@ -46,14 +46,14 @@ #deletion false])) (with_template [<concern> <predicate> <event> <create> <modify> <delete>] - [(def: .public <concern> + [(def .public <concern> Concern (abstraction [#creation <create> #modification <modify> #deletion <delete>])) - (def: .public <predicate> + (def .public <predicate> (Predicate Concern) (|>> representation (the <event>)))] @@ -65,14 +65,14 @@ false false true] ) - (def: .public (also left right) + (def .public (also left right) (-> Concern Concern Concern) (abstraction [#creation (or (..creation? left) (..creation? right)) #modification (or (..modification? left) (..modification? right)) #deletion (or (..deletion? left) (..deletion? right))])) - (def: .public all + (def .public all Concern (.all ..also ..creation @@ -107,7 +107,7 @@ (type: Directory_Tracker (Dictionary //.Path [Concern File_Tracker])) -(def: (update_watch! new_concern path tracker) +(def (update_watch! new_concern path tracker) (-> Concern //.Path (Var Directory_Tracker) (STM Bit)) (do [! stm.monad] [@tracker (stm.read tracker)] @@ -120,7 +120,7 @@ {.#None} (in false)))) -(def: (file_tracker fs directory) +(def (file_tracker fs directory) (-> (//.System Async) //.Path (Async (Try File_Tracker))) (do [! (try.with async.monad)] [files (at fs directory_files directory)] @@ -133,7 +133,7 @@ (dictionary.empty text.hash)) files))) -(def: (available_files fs directory) +(def (available_files fs directory) (-> (//.System Async) //.Path (Async (Try (List [//.Path Instant])))) (do [! (try.with async.monad)] [files (at fs directory_files directory)] @@ -143,7 +143,7 @@ (at ! each (|>> [file])))) files))) -(def: (available_directory_changes fs [directory [the_concern file_tracker]]) +(def (available_directory_changes fs [directory [the_concern file_tracker]]) (-> (//.System Async) [//.Path [Concern File_Tracker]] (Async (Try [[//.Path [Concern File_Tracker]] [(List [//.Path Instant]) @@ -184,12 +184,12 @@ modifications deletions]]))) -(def: .public (polling fs) +(def .public (polling fs) (-> (//.System Async) (Watcher Async)) (let [tracker (is (Var Directory_Tracker) (stm.var (dictionary.empty text.hash)))] (implementation - (def: (start new_concern path) + (def (start new_concern path) (do [! async.monad] [exists? (at fs directory? path)] (if exists? @@ -203,7 +203,7 @@ [_ (stm.commit! (stm.update (dictionary.has path [new_concern file_tracker]) tracker))] (in {try.#Success []}))))) (in (exception.except ..cannot_poll_a_non_existent_directory [path]))))) - (def: (concern path) + (def (concern path) (stm.commit! (do stm.monad [@tracker (stm.read tracker)] @@ -213,7 +213,7 @@ {.#None} (exception.except ..not_being_watched [path])))))) - (def: (stop path) + (def (stop path) (stm.commit! (do [! stm.monad] [@tracker (stm.read tracker)] @@ -225,7 +225,7 @@ {.#None} (in (exception.except ..not_being_watched [path])))))) - (def: (poll _) + (def (poll _) (do async.monad [@tracker (stm.commit! (stm.read tracker))] (do [! (try.with async.monad)] @@ -256,7 +256,7 @@ ))))) ))) -(def: .public (mock separator) +(def .public (mock separator) (-> Text [(//.System Async) (Watcher Async)]) (let [fs (//.mock separator)] [fs @@ -273,7 +273,7 @@ (size [] int) (get [int] a)) - (def: (default_list list) + (def (default_list list) (All (_ a) (-> (java/util/List a) (List a))) (let [size (.nat (ffi.of_int (java/util/List::size list)))] (loop (again [idx 0 @@ -305,7 +305,7 @@ ("read_only" "static" ENTRY_MODIFY (java/nio/file/WatchEvent$Kind java/nio/file/Path)) ("read_only" "static" ENTRY_DELETE (java/nio/file/WatchEvent$Kind java/nio/file/Path))) - (def: (default_event_concern event) + (def (default_event_concern event) (All (_ a) (-> (java/nio/file/WatchEvent a) Concern)) (let [kind (as (java/nio/file/WatchEvent$Kind java/nio/file/Path) @@ -333,7 +333,7 @@ (watchable [] java/nio/file/Watchable) (pollEvents [] "io" (java/util/List (java/nio/file/WatchEvent ?)))) - (def: default_key_concern + (def default_key_concern (-> java/nio/file/WatchKey (IO Concern)) (|>> java/nio/file/WatchKey::pollEvents (at io.monad each (|>> ..default_list @@ -360,7 +360,7 @@ (type: Watch_Event (java/nio/file/WatchEvent$Kind java/lang/Object)) - (def: (default_start watch_events watcher path) + (def (default_start watch_events watcher path) (-> (List Watch_Event) java/nio/file/WatchService //.Path (Async (Try java/nio/file/WatchKey))) (let [watch_events' (list#mix (function (_ [index watch_event] watch_events') (ffi.write! index watch_event watch_events')) @@ -372,7 +372,7 @@ watch_events' (|> path ffi.as_string java/io/File::new java/io/File::toPath))))) - (def: (default_poll watcher) + (def (default_poll watcher) (-> java/nio/file/WatchService (IO (Try (List [Concern //.Path])))) (loop (again [output (is (List [Concern //.Path]) (list))]) @@ -398,7 +398,7 @@ {.#None} (in output))))) - (def: (watch_events concern) + (def (watch_events concern) (-> Concern (List Watch_Event)) (.all list#composite (if (..creation? concern) @@ -412,7 +412,7 @@ (list)) )) - (def: .public default + (def .public default (IO (Try (Watcher Async))) (do (try.with io.monad) [watcher (java/nio/file/FileSystem::newWatchService @@ -436,7 +436,7 @@ (in (exception.except ..not_being_watched [path]))))))]] (in (is (Watcher Async) (implementation - (def: (start the_concern path) + (def (start the_concern path) (do async.monad [?concern (stop path)] (do (try.with async.monad) @@ -447,7 +447,7 @@ (do async.monad [_ (stm.commit! (stm.update (dictionary.has path [the_concern key]) tracker))] (in {try.#Success []}))))) - (def: (concern path) + (def (concern path) (do async.monad [@tracker (stm.commit! (stm.read tracker))] (case (dictionary.value path @tracker) @@ -456,8 +456,8 @@ {.#None} (in (exception.except ..not_being_watched [path]))))) - (def: stop stop) - (def: (poll _) + (def stop stop) + (def (poll _) (async.future (..default_poll watcher))) ))))) )] diff --git a/stdlib/source/library/lux/world/input/keyboard.lux b/stdlib/source/library/lux/world/input/keyboard.lux index 79685c797..baaac2289 100644 --- a/stdlib/source/library/lux/world/input/keyboard.lux +++ b/stdlib/source/library/lux/world/input/keyboard.lux @@ -6,7 +6,7 @@ Nat) (with_template [<code> <name>] - [(def: .public <name> Key <code>)] + [(def .public <name> Key <code>)] [00008 back_space] [00010 enter] @@ -103,7 +103,7 @@ #input Key])) (with_template [<bit> <name>] - [(def: .public (<name> key) + [(def .public (<name> key) (-> Key Press) [#pressed? <bit> #input key])] diff --git a/stdlib/source/library/lux/world/net/http.lux b/stdlib/source/library/lux/world/net/http.lux index bfbcf4926..a39c3d371 100644 --- a/stdlib/source/library/lux/world/net/http.lux +++ b/stdlib/source/library/lux/world/net/http.lux @@ -36,7 +36,7 @@ (type: .public Headers Environment) -(def: .public empty +(def .public empty Headers environment.empty) diff --git a/stdlib/source/library/lux/world/net/http/client.lux b/stdlib/source/library/lux/world/net/http/client.lux index 2decbe412..c23b58b95 100644 --- a/stdlib/source/library/lux/world/net/http/client.lux +++ b/stdlib/source/library/lux/world/net/http/client.lux @@ -36,13 +36,13 @@ (! (Try (//.Response !)))) request))) -(def: method_function +(def method_function (syntax (_ [[_ name] <code>.symbol]) (in (list (code.local (text.replaced "#" "" (text.lower_cased name))))))) (with_template [<method>] [(with_expansions [<name> (method_function <method>)] - (def: .public (<name> url headers data client) + (def .public (<name> url headers data client) (All (_ !) (-> URL //.Headers (Maybe Binary) (Client !) (! (Try (//.Response !))))) @@ -59,14 +59,14 @@ [//.#Trace] ) -(def: default_buffer_size +(def default_buffer_size (n.* 1,024 1,024)) -(def: empty_body +(def empty_body [Nat Binary] [0 (binary.empty 0)]) -(def: (body_of data) +(def (body_of data) (-> Binary [Nat Binary]) [(binary.size data) data]) @@ -109,7 +109,7 @@ (new [java/io/InputStream]) (read [[byte] int int] "io" "try" int)) - (def: jvm_method + (def jvm_method (-> //.Method Text) (|>> (pipe.case {//.#Post} "POST" @@ -122,7 +122,7 @@ {//.#Options} "OPTIONS" {//.#Trace} "TRACE"))) - (def: (default_body input) + (def (default_body input) (-> java/io/BufferedInputStream (//.Body IO)) (|>> (maybe#each (|>> [true])) (maybe.else [false ..default_buffer_size]) @@ -172,7 +172,7 @@ (again (i.+ bytes_read so_far) output)))))))))) - (def: (default_headers connection) + (def (default_headers connection) (-> java/net/HttpURLConnection (IO (Try //.Headers))) (loop (again [index +0 headers //.empty]) @@ -188,10 +188,10 @@ {.#None} (in headers))))) - (def: .public default + (def .public default (Client IO) (implementation - (def: (request method url headers data) + (def (request method url headers data) (is (IO (Try (//.Response IO))) (do [! (try.with io.monad)] [connection (|> url ffi.as_string java/net/URL::new java/net/URL::openConnection) @@ -224,10 +224,10 @@ @.jvm (these <jvm>) (these))) -(def: .public (async client) +(def .public (async client) (-> (Client IO) (Client Async)) (implementation - (def: (request method url headers data) + (def (request method url headers data) (|> (at client request method url headers data) async.future (at async.monad each @@ -241,6 +241,6 @@ {try.#Failure error} {try.#Failure error}))))))) -(def: .public headers +(def .public headers (-> (List [Text Text]) //.Headers) (dictionary.of_list text.hash)) diff --git a/stdlib/source/library/lux/world/net/http/cookie.lux b/stdlib/source/library/lux/world/net/http/cookie.lux index dd17d428e..26ef5688a 100644 --- a/stdlib/source/library/lux/world/net/http/cookie.lux +++ b/stdlib/source/library/lux/world/net/http/cookie.lux @@ -23,16 +23,16 @@ (type: .public Directive (-> Text Text)) -(def: (directive extension) +(def (directive extension) (-> Text Directive) (function (_ so_far) (format so_far "; " extension))) -(def: .public (set name value) +(def .public (set name value) (-> Text Text Header) (header.has "Set-Cookie" (format name "=" value))) -(def: .public (max_age duration) +(def .public (max_age duration) (-> Duration Directive) (let [seconds (duration.ticks duration.second duration)] (..directive (format "Max-Age=" (if (i.< +0 seconds) @@ -40,7 +40,7 @@ (%.nat (.nat seconds))))))) (with_template [<name> <prefix>] - [(def: .public (<name> value) + [(def .public (<name> value) (-> Text Directive) (..directive (format <prefix> "=" value)))] @@ -49,7 +49,7 @@ ) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> Directive (..directive <tag>))] @@ -62,13 +62,13 @@ {#Strict} {#Lax})) -(def: .public (same_site policy) +(def .public (same_site policy) (-> CSRF_Policy Directive) (..directive (format "SameSite=" (case policy {#Strict} "Strict" {#Lax} "Lax")))) -(def: (cookie context) +(def (cookie context) (-> Context (Parser Context)) (do p.monad [key (l.slice (l.many! (l.none_of! "="))) @@ -76,7 +76,7 @@ value (l.slice (l.many! (l.none_of! ";")))] (in (dictionary.has key value context)))) -(def: (cookies context) +(def (cookies context) (-> Context (Parser Context)) (all p.either (do p.monad @@ -85,6 +85,6 @@ (cookies context')) (p#in context))) -(def: .public (get header) +(def .public (get header) (-> Text (Try Context)) (l.result header (..cookies context.empty))) diff --git a/stdlib/source/library/lux/world/net/http/header.lux b/stdlib/source/library/lux/world/net/http/header.lux index 95fd9713c..a8bc408a0 100644 --- a/stdlib/source/library/lux/world/net/http/header.lux +++ b/stdlib/source/library/lux/world/net/http/header.lux @@ -12,7 +12,7 @@ ["[0]" mime (.only MIME)] [// (.only URL)]]) -(def: .public (has name value) +(def .public (has name value) (-> Text Text Header) (dictionary.revised' name "" (|>> (pipe.case @@ -22,14 +22,14 @@ previous (format previous "," value))))) -(def: .public content_length +(def .public content_length (-> Nat Header) (|>> %.nat (..has "Content-Length"))) -(def: .public content_type +(def .public content_type (-> MIME Header) (|>> mime.name (..has "Content-Type"))) -(def: .public location +(def .public location (-> URL Header) (..has "Location")) diff --git a/stdlib/source/library/lux/world/net/http/mime.lux b/stdlib/source/library/lux/world/net/http/mime.lux index 36a5bae3d..ff449a568 100644 --- a/stdlib/source/library/lux/world/net/http/mime.lux +++ b/stdlib/source/library/lux/world/net/http/mime.lux @@ -11,18 +11,18 @@ (primitive .public MIME Text - (def: .public mime + (def .public mime (-> Text MIME) (|>> abstraction)) - (def: .public name + (def .public name (-> MIME Text) (|>> representation)) ) ... https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types (with_template [<name> <type>] - [(def: .public <name> MIME (..mime <type>))] + [(def .public <name> MIME (..mime <type>))] [aac_audio "audio/aac"] [abiword "application/x-abiword"] @@ -91,10 +91,10 @@ [!7z "application/x-7z-compressed"] ) -(def: .public (text encoding) +(def .public (text encoding) (-> Encoding MIME) (..mime (format "text/plain; charset=" text.double_quote (encoding.name encoding) text.double_quote))) -(def: .public utf_8 +(def .public utf_8 MIME (..text encoding.utf_8)) diff --git a/stdlib/source/library/lux/world/net/http/query.lux b/stdlib/source/library/lux/world/net/http/query.lux index 3409734a7..72f5c345d 100644 --- a/stdlib/source/library/lux/world/net/http/query.lux +++ b/stdlib/source/library/lux/world/net/http/query.lux @@ -17,7 +17,7 @@ [collection ["[0]" dictionary]]]]]) -(def: component +(def component (Parser Text) (p.rec (function (_ component) @@ -39,7 +39,7 @@ tail component] (in (format head code tail)))))))) -(def: (form context) +(def (form context) (-> Context (Parser Context)) (all p.either (do p.monad @@ -60,6 +60,6 @@ ... if invalid form data, just stop parsing... (at p.monad in context))) -(def: .public (parameters raw) +(def .public (parameters raw) (-> Text (Try Context)) (l.result raw (..form context.empty))) diff --git a/stdlib/source/library/lux/world/net/http/request.lux b/stdlib/source/library/lux/world/net/http/request.lux index 36f0498ea..d3a970d14 100644 --- a/stdlib/source/library/lux/world/net/http/request.lux +++ b/stdlib/source/library/lux/world/net/http/request.lux @@ -31,7 +31,7 @@ ["[1][0]" query] ["[1][0]" cookie]]) -(def: (merge inputs) +(def (merge inputs) (-> (List Binary) Binary) (let [[_ output] (try.trusted (monad.mix try.monad @@ -46,15 +46,15 @@ inputs))] output)) -(def: (read_text_body body) +(def (read_text_body body) (-> Body (Async (Try Text))) (do async.monad [blobs (frp.list body)] (in (at encoding.utf8 decoded (merge blobs))))) -(def: failure (//response.bad_request "")) +(def failure (//response.bad_request "")) -(def: .public (json reader server) +(def .public (json reader server) (All (_ a) (-> (<json>.Reader a) (-> a Server) Server)) (function (_ (^.let request [identification protocol resource message])) (do async.monad @@ -69,7 +69,7 @@ {try.#Failure error} (async.resolved ..failure))))) -(def: .public (text server) +(def .public (text server) (-> (-> Text Server) Server) (function (_ (^.let request [identification protocol resource message])) (do async.monad @@ -81,7 +81,7 @@ {try.#Failure error} (async.resolved ..failure))))) -(def: .public (query property server) +(def .public (query property server) (All (_ a) (-> (Property a) (-> a Server) Server)) (function (_ [identification protocol resource message]) (let [full (the //.#uri resource) @@ -99,7 +99,7 @@ {try.#Failure error} (async.resolved ..failure))))) -(def: .public (form property server) +(def .public (form property server) (All (_ a) (-> (Property a) (-> a Server) Server)) (function (_ (^.let request [identification protocol resource message])) (do async.monad @@ -114,7 +114,7 @@ {try.#Failure error} (async.resolved ..failure))))) -(def: .public (cookies property server) +(def .public (cookies property server) (All (_ a) (-> (Property a) (-> a Server) Server)) (function (_ (^.let request [identification protocol resource message])) (case (do try.monad diff --git a/stdlib/source/library/lux/world/net/http/response.lux b/stdlib/source/library/lux/world/net/http/response.lux index db54411cc..277f21202 100644 --- a/stdlib/source/library/lux/world/net/http/response.lux +++ b/stdlib/source/library/lux/world/net/http/response.lux @@ -22,12 +22,12 @@ ["[0]" header] [// (.only URL)]]) -(def: .public (static response) +(def .public (static response) (-> Response Server) (function (_ request) (async.resolved response))) -(def: .public empty +(def .public empty (-> Status Response) (let [body (frp#in (at encoding.utf8 encoded ""))] (function (_ status) @@ -37,16 +37,16 @@ (header.content_type mime.utf_8)) //.#body body]]))) -(def: .public (temporary_redirect to) +(def .public (temporary_redirect to) (-> URL Response) (let [[status message] (..empty status.temporary_redirect)] [status (revised //.#headers (header.location to) message)])) -(def: .public not_found +(def .public not_found Response (..empty status.not_found)) -(def: .public (content status type data) +(def .public (content status type data) (-> Status MIME Binary Response) [status [//.#headers (|> context.empty @@ -54,16 +54,16 @@ (header.content_type type)) //.#body (frp#in data)]]) -(def: .public bad_request +(def .public bad_request (-> Text Response) (|>> (at encoding.utf8 encoded) (content status.bad_request mime.utf_8))) -(def: .public ok +(def .public ok (-> MIME Binary Response) (content status.ok)) (with_template [<name> <type> <mime> <pre>] - [(def: .public <name> + [(def .public <name> (-> <type> Response) (|>> <pre> (at encoding.utf8 encoded) (..ok <mime>)))] diff --git a/stdlib/source/library/lux/world/net/http/route.lux b/stdlib/source/library/lux/world/net/http/route.lux index b4f31b525..d9f63d9ad 100644 --- a/stdlib/source/library/lux/world/net/http/route.lux +++ b/stdlib/source/library/lux/world/net/http/route.lux @@ -17,7 +17,7 @@ ["[1][0]" response]]) (with_template [<scheme> <name>] - [(def: .public (<name> server) + [(def .public (<name> server) (-> Server Server) (function (_ (^.let request [identification protocol resource message])) (case (the //.#scheme protocol) @@ -32,7 +32,7 @@ ) (with_template [<method> <name>] - [(def: .public (<name> server) + [(def .public (<name> server) (-> Server Server) (function (_ (^.let request [identification protocol resource message])) (case (the //.#method resource) @@ -53,7 +53,7 @@ [//.#Trace trace] ) -(def: .public (uri path server) +(def .public (uri path server) (-> URI Server Server) (function (_ [identification protocol resource message]) (if (text.starts_with? path (the //.#uri resource)) @@ -65,7 +65,7 @@ message]) (async.resolved //response.not_found)))) -(def: .public (or primary alternative) +(def .public (or primary alternative) (-> Server Server Server) (function (_ request) (do async.monad diff --git a/stdlib/source/library/lux/world/net/http/status.lux b/stdlib/source/library/lux/world/net/http/status.lux index 2752b8651..dc2ff105f 100644 --- a/stdlib/source/library/lux/world/net/http/status.lux +++ b/stdlib/source/library/lux/world/net/http/status.lux @@ -5,7 +5,7 @@ ... https://en.wikipedia.org/wiki/List_of_HTTP_status_codes (with_template [<status> <name>] - [(def: .public <name> + [(def .public <name> Status <status>)] diff --git a/stdlib/source/library/lux/world/net/http/version.lux b/stdlib/source/library/lux/world/net/http/version.lux index b56ddf052..0cb62b627 100644 --- a/stdlib/source/library/lux/world/net/http/version.lux +++ b/stdlib/source/library/lux/world/net/http/version.lux @@ -4,7 +4,7 @@ [// (.only Version)]) (with_template [<name> <version>] - [(def: .public <name> Version <version>)] + [(def .public <name> Version <version>)] [v0_9 "0.9"] [v1_0 "1.0"] diff --git a/stdlib/source/library/lux/world/net/uri.lux b/stdlib/source/library/lux/world/net/uri.lux index 253550d6e..ec7c8b984 100644 --- a/stdlib/source/library/lux/world/net/uri.lux +++ b/stdlib/source/library/lux/world/net/uri.lux @@ -6,5 +6,5 @@ (type: .public URI Text) -(def: .public separator +(def .public separator "/") diff --git a/stdlib/source/library/lux/world/output/video/resolution.lux b/stdlib/source/library/lux/world/output/video/resolution.lux index fd6a1a9de..ebe60cf6d 100644 --- a/stdlib/source/library/lux/world/output/video/resolution.lux +++ b/stdlib/source/library/lux/world/output/video/resolution.lux @@ -15,17 +15,17 @@ [#width Nat #height Nat])) -(def: .public hash +(def .public hash (Hash Resolution) (product.hash nat.hash nat.hash)) -(def: .public equivalence +(def .public equivalence (Equivalence Resolution) (at ..hash equivalence)) ... https://en.wikipedia.org/wiki/Display_resolution#Common_display_resolutions (with_template [<name> <width> <height>] - [(def: .public <name> + [(def .public <name> Resolution [#width <width> #height <height>])] diff --git a/stdlib/source/library/lux/world/program.lux b/stdlib/source/library/lux/world/program.lux index b0df93d8b..f45930389 100644 --- a/stdlib/source/library/lux/world/program.lux +++ b/stdlib/source/library/lux/world/program.lux @@ -53,7 +53,7 @@ (is (-> Exit (! Nothing)) exit))) -(def: .public (environment monad program) +(def .public (environment monad program) (All (_ !) (-> (Monad !) (Program !) (! Environment))) (do [! monad] [variables (at program available_variables []) @@ -70,11 +70,11 @@ {.#None}))) (dictionary.of_list text.hash))))) -(`` (def: .public (async program) +(`` (def .public (async program) (-> (Program IO) (Program Async)) (implementation (~~ (with_template [<method>] - [(def: <method> + [(def <method> (at program <method>))] [home] @@ -82,7 +82,7 @@ )) (~~ (with_template [<method>] - [(def: <method> + [(def <method> (|>> (at program <method>) async.future))] [available_variables] @@ -90,24 +90,24 @@ [exit] ))))) -(def: .public (mock environment home directory) +(def .public (mock environment home directory) (-> Environment Path Path (Program IO)) (let [@dead? (atom.atom false)] (implementation - (def: available_variables + (def available_variables (function.constant (io.io (dictionary.keys environment)))) - (def: (variable name) + (def (variable name) (io.io (case (dictionary.value name environment) {.#Some value} {try.#Success value} {.#None} (exception.except ..unknown_environment_variable [name])))) - (def: home + (def home home) - (def: directory + (def directory directory) - (def: exit + (def exit (|>> %.int panic! io.io))))) ... Do not trust the values of environment variables @@ -136,7 +136,7 @@ ("static" getProperty [java/lang/String] "?" java/lang/String) ("static" exit [int] "io" void)) - (def: (jvm::consume iterator) + (def (jvm::consume iterator) (All (_ a) (-> (java/util/Iterator a) (List a))) (if (ffi.of_boolean (java/util/Iterator::hasNext iterator)) {.#Item (java/util/Iterator::next iterator) @@ -145,7 +145,7 @@ )] (for @.old (these <jvm>) @.jvm (these <jvm>) - @.js (these (def: default_exit! + @.js (these (def default_exit! (-> Exit (IO Nothing)) (|>> %.int panic! io.io)) @@ -154,7 +154,7 @@ (exit [ffi.Number] "io" Nothing) (cwd [] "io" Path)) - (def: (exit_node_js! code) + (def (exit_node_js! code) (-> Exit (IO Nothing)) (case (ffi.global ..NodeJs_Process [process]) {.#Some process} @@ -171,7 +171,7 @@ "[1]::[0]" (reload [] Nothing)) - (def: (exit_browser! code) + (def (exit_browser! code) (-> Exit (IO Nothing)) (case [(ffi.global ..Browser_Window [window]) (ffi.global ..Browser_Location [location])] @@ -223,7 +223,7 @@ (ffi.import (os/getenv [ffi.String] "io" "?" ffi.String)) (ffi.import (os/exit [ffi.Integer] "io" Nothing)) - (def: (run_command default command) + (def (run_command default command) (-> Text Text (IO Text)) (do [! io.monad] [outcome (io/popen [command])] @@ -283,10 +283,10 @@ (these))) -(def: .public default +(def .public default (Program IO) (implementation - (def: (available_variables _) + (def (available_variables _) (with_expansions [<jvm> (|> (java/lang/System::getenv) java/util/Map::keySet java/util/Set::iterator @@ -328,7 +328,7 @@ ... (dictionary.has (..car entry) (..cdr entry) output)))))) ))) - (def: (variable name) + (def (variable name) (template.let [(!fetch <method> <post>) [(do io.monad [value (|> name <method>)] @@ -357,7 +357,7 @@ @.ruby (!fetch Env::fetch |>) )))) - (def: home + (def home (io.run! (with_expansions [<default> (io.io "~") <jvm> (|> (java/lang/System::getProperty (ffi.as_string "user.home")) @@ -384,7 +384,7 @@ ... TODO: Replace dummy implementation. <default>)))) - (def: directory + (def directory (io.run! (with_expansions [<default> "." <jvm> (|> (java/lang/System::getProperty (ffi.as_string "user.dir")) @@ -418,7 +418,7 @@ ... TODO: Replace dummy implementation. (io.io <default>))))) - (def: (exit code) + (def (exit code) (with_expansions [<jvm> (do io.monad [_ (java/lang/System::exit (ffi.as_int code))] (in (undefined)))] diff --git a/stdlib/source/library/lux/world/shell.lux b/stdlib/source/library/lux/world/shell.lux index 79fc635a9..22ef8464b 100644 --- a/stdlib/source/library/lux/world/shell.lux +++ b/stdlib/source/library/lux/world/shell.lux @@ -37,7 +37,7 @@ Int) (with_template [<code> <name>] - [(def: .public <name> + [(def .public <name> Exit <code>)] @@ -58,11 +58,11 @@ (is (-> [] (! (Try Exit))) await))) -(def: (async_process process) +(def (async_process process) (-> (Process IO) (Process Async)) (`` (implementation (~~ (with_template [<method>] - [(def: <method> + [(def <method> (|>> (at process <method>) async.future))] @@ -84,10 +84,10 @@ (is (-> [Environment Path Command (List Argument)] (! (Try (Process !)))) execute))) -(def: .public (async shell) +(def .public (async shell) (-> (Shell IO) (Shell Async)) (implementation - (def: (execute input) + (def (execute input) (async.future (do (try.with io.monad) [process (at shell execute input)] @@ -109,11 +109,11 @@ (type: Replacer (-> Text Text)) -(def: (replaced bad replacer) +(def (replaced bad replacer) (-> Text Replacer (-> Text Text)) (text.replaced bad (replacer bad))) -(def: safe_common_command +(def safe_common_command (-> Replacer (Sanitizer Command)) (let [x0A (text.of_char (hex "0A")) xFF (text.of_char (hex "FF"))] @@ -136,17 +136,17 @@ (..replaced "[" replacer) (..replaced "]" replacer) (..replaced "{" replacer) (..replaced "}" replacer))))) -(def: (policy safe_command safe_argument) +(def (policy safe_command safe_argument) (Ex (_ ?) (-> (Sanitizer Command) (Sanitizer Argument) (Policy ?))) (?.with_policy (is (Context Safety Policy) (function (_ (open "?[0]")) (implementation - (def: command (|>> safe_command ?#can_upgrade)) - (def: argument (|>> safe_argument ?#can_upgrade)) - (def: value ?#can_downgrade)))))) + (def command (|>> safe_command ?#can_upgrade)) + (def argument (|>> safe_argument ?#can_upgrade)) + (def value ?#can_downgrade)))))) -(def: unix_policy +(def unix_policy (let [replacer (is Replacer (|>> (format "\"))) safe_command (is (Sanitizer Command) @@ -156,7 +156,7 @@ (text.enclosed' "'")))] (..policy safe_command safe_argument))) -(def: windows_policy +(def windows_policy (let [replacer (is Replacer (function.constant " ")) safe_command (is (Sanitizer Command) @@ -174,7 +174,7 @@ "[1]::[0]" (toLowerCase [] java/lang/String)) - (def: (jvm::arguments_array arguments) + (def (jvm::arguments_array arguments) (-> (List Argument) (Array java/lang/String)) (product.right (list#mix (function (_ argument [idx output]) @@ -188,7 +188,7 @@ "[1]::[0]" (put [k v] v)) - (def: (jvm::load_environment input target) + (def (jvm::load_environment input target) (-> Environment (java/util/Map java/lang/String java/lang/String) (java/util/Map java/lang/String java/lang/String)) @@ -231,7 +231,7 @@ (exception: .public no_more_output) - (def: (default_process process) + (def (default_process process) (-> java/lang/Process (IO (Try (Process IO)))) (do [! (try.with io.monad)] [jvm_input (java/lang/Process::getInputStream process) @@ -246,7 +246,7 @@ (in (is (Process IO) (`` (implementation (~~ (with_template [<name> <stream>] - [(def: (<name> _) + [(def (<name> _) (do ! [output (java/io/BufferedReader::readLine <stream>)] (case output @@ -259,10 +259,10 @@ [read jvm_input] [fail jvm_error] )) - (def: (write message) + (def (write message) (java/io/OutputStream::write (at utf8.codec encoded message) jvm_output)) (~~ (with_template [<name> <method>] - [(def: (<name> _) + [(def (<name> _) (|> process <method>))] [destroy java/lang/Process::destroy] @@ -285,16 +285,16 @@ ("static" getProperty [java/lang/String] "io" "try" java/lang/String)) ... https://en.wikipedia.org/wiki/Code_injection#Shell_injection - (def: windows? + (def windows? (IO (Try Bit)) (at (try.with io.monad) each (|>> java/lang/String::toLowerCase ffi.of_string (text.starts_with? "windows")) (java/lang/System::getProperty (ffi.as_string "os.name")))) - (def: .public default + (def .public default (Shell IO) (implementation - (def: (execute [environment working_directory the_command arguments]) + (def (execute [environment working_directory the_command arguments]) (do [! (try.with io.monad)] [.let [builder (|> (list.partial the_command arguments) ..jvm::arguments_array @@ -324,11 +324,11 @@ (is (-> s (Try [s Exit])) on_await))) -(`` (def: (mock_process state mock) +(`` (def (mock_process state mock) (All (_ s) (-> (Atom s) (Mock s) (Process IO))) (implementation (~~ (with_template [<name> <mock>] - [(def: (<name> _) + [(def (<name> _) (do [! io.monad] [|state| (atom.read! state)] (case (at mock <mock> |state|) @@ -344,7 +344,7 @@ [fail on_fail] [await on_await] )) - (def: (write message) + (def (write message) (do [! io.monad] [|state| (atom.read! state)] (case (at mock on_write message |state|) @@ -355,7 +355,7 @@ {try.#Failure error} (in {try.#Failure error})))) - (def: (destroy _) + (def (destroy _) (do [! io.monad] [|state| (atom.read! state)] (case (at mock on_destroy |state|) @@ -367,14 +367,14 @@ {try.#Failure error} (in {try.#Failure error}))))))) -(def: .public (mock mock init) +(def .public (mock mock init) (All (_ s) (-> (-> [Environment Path Command (List Argument)] (Try (Mock s))) s (Shell IO))) (implementation - (def: execute + (def execute (|>> mock (at try.monad each (..mock_process (atom.atom init))) io.io)))) |