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