diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/program.lux | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/stdlib/source/lux/program.lux b/stdlib/source/lux/program.lux deleted file mode 100644 index 475bd7322..000000000 --- a/stdlib/source/lux/program.lux +++ /dev/null @@ -1,82 +0,0 @@ -(.module: - [lux #* - ["@" target] - [abstract - [monad (#+ do)]] - [control - ["." io] - [concurrency - ["." thread]] - ["<>" parser - ["<.>" code] - ["<.>" cli]]] - [data - ["." text] - [collection - ["." list ("#\." monad)]]] - [macro (#+ with_gensyms) - [syntax (#+ syntax:)] - ["." code]]]) - -(type: Arguments - (#Raw Text) - (#Parsed (List [Code Code]))) - -(def: arguments^ - (<code>.Parser Arguments) - (<>.or <code>.local_identifier - (<code>.tuple (<>.some (<>.either (do <>.monad - [name <code>.local_identifier] - (wrap [(code.identifier ["" name]) (` (~! <cli>.any))])) - (<code>.record (<>.and <code>.any <code>.any))))))) - -(syntax: #export (program: - {args ..arguments^} - body) - {#.doc (doc "Defines the entry-point to a program (similar to the 'main' function/method in other programming languages)." - "Can take a list of all the input parameters to the program." - "Or, can destructure them using CLI-option combinators from the lux/control/parser/cli module." - (program: all_args - (do io.monad - [foo init_program - bar (do_something all_args)] - (wrap []))) - - (program: [name] - (io (log! (\ text.monoid compose "Hello, " name)))) - - (program: [{config configuration_parser}] - (do io.monad - [data (init_program config)] - (do_something data))))} - (with_gensyms [g!program g!args g!_ g!output g!message] - (let [initialization+event_loop - (` ((~! do) (~! io.monad) - [(~ g!output) (~ body) - (~+ (for {@.old (list) - @.jvm (list) - @.js (list) - @.python (list)} - (list g!_ (` (~! thread.run!)))))] - ((~' wrap) (~ g!output))))] - (wrap (list (` ("lux def program" - (~ (case args - (#Raw args) - (` (.function ((~ g!program) (~ (code.identifier ["" args]))) - (~ initialization+event_loop))) - - (#Parsed args) - (` (.function ((~ g!program) (~ g!args)) - (case ((~! <cli>.run) (: (~! (<cli>.Parser (io.IO .Any))) - ((~! do) (~! <>.monad) - [(~+ (|> args - (list\map (function (_ [binding parser]) - (list binding parser))) - list\join))] - ((~' wrap) (~ initialization+event_loop)))) - (~ g!args)) - (#.Right (~ g!output)) - (~ g!output) - - (#.Left (~ g!message)) - (.error! (~ g!message)))))))))))))) |