diff options
Diffstat (limited to 'stdlib/source/library/lux/target/r.lux')
-rw-r--r-- | stdlib/source/library/lux/target/r.lux | 92 |
1 files changed, 46 insertions, 46 deletions
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) |