From 7db42ab1b9d3c764772ca63c74bf44bb2b8b8325 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 9 Jul 2022 14:35:38 -0400 Subject: First-class programs instead of having a "lux program" extension. --- licentia/source/program/licentia.lux | 49 ++++++++++++++++++------------------ licentia/source/test/licentia.lux | 13 +++++----- 2 files changed, 32 insertions(+), 30 deletions(-) (limited to 'licentia') diff --git a/licentia/source/program/licentia.lux b/licentia/source/program/licentia.lux index d3218ec64..d4478b885 100644 --- a/licentia/source/program/licentia.lux +++ b/licentia/source/program/licentia.lux @@ -34,7 +34,7 @@ [format ["[0]" json (.only) ["<[1]>" \\parser (.only Parser)]]]] - ["[0]" program (.only program:) + ["[0]" program (.only program) ["<[1]>" \\parser]] [world ["[0]" file]]]] @@ -57,27 +57,28 @@ (format "Your license has been made!" text.new_line "Check the file " output ".")) -(program: [input (<| (.named "--input") - .any) - output (<| (parser.default ..default_output_file) - (.named "--output") - .any)] - (do io.monad - [?done (is (IO (Try Any)) - (do (try.with io.monad) - [blob (at file.default read input) - document (io#wrap (do [! try.monad] - [raw_json (at utf8.codec decoded blob) - json (|> raw_json - java/lang/String::trim - (at json.codec decoded))] - (|> json - (.result /input.license) - (at ! each /output.license))))] - (at file.default write (at utf8.codec encoded document) output)))] - (wrap (debug.log! (case ?done - {try.#Success _} - (success_message output) +(def _ + (program [input (<| (.named "--input") + .any) + output (<| (parser.default ..default_output_file) + (.named "--output") + .any)] + (do io.monad + [?done (is (IO (Try Any)) + (do (try.with io.monad) + [blob (at file.default read input) + document (io#wrap (do [! try.monad] + [raw_json (at utf8.codec decoded blob) + json (|> raw_json + java/lang/String::trim + (at json.codec decoded))] + (|> json + (.result /input.license) + (at ! each /output.license))))] + (at file.default write (at utf8.codec encoded document) output)))] + (wrap (debug.log! (case ?done + {try.#Success _} + (success_message output) - {try.#Failure message} - message))))) + {try.#Failure message} + message)))))) diff --git a/licentia/source/test/licentia.lux b/licentia/source/test/licentia.lux index 8d7bdc120..fe5829e74 100644 --- a/licentia/source/test/licentia.lux +++ b/licentia/source/test/licentia.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except) - [program (.only program:)] + [program (.only program)] ["_" test (.only Test)] [abstract [monad (.only do)]] @@ -363,8 +363,9 @@ (present? notice.end_of_license)) ))) -(program: args - (<| io.io - _.run! - (_.times 100) - ..test)) +(def _ + (program args + (<| io.io + _.run! + (_.times 100) + ..test))) -- cgit v1.2.3