From 2b909032e7a0bd10cd7db52067d2fb701bfa95e5 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 6 Jul 2021 21:34:21 -0400 Subject: Simplified the API for file-system operations. --- stdlib/source/program/compositor.lux | 50 ++++++++---------------------------- 1 file changed, 10 insertions(+), 40 deletions(-) (limited to 'stdlib/source/program/compositor.lux') diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux index f443301db..8b577ec09 100644 --- a/stdlib/source/program/compositor.lux +++ b/stdlib/source/program/compositor.lux @@ -2,7 +2,6 @@ [lux (#- Module) [type (#+ :share)] ["." debug] - ["@" target] [abstract [monad (#+ Monad do)]] [control @@ -21,7 +20,7 @@ [time ["." instant]] ["." world #_ - ["." file (#+ File Path)] + ["." file] ["#/." program] ## ["." console] ] @@ -83,43 +82,14 @@ (format "Duration: ")))]] (wrap output))) -(def: (package! monad file_system [packager package] static archive context) - (All [!] (-> (Monad !) (file.System !) [Packager Path] Static Archive Context (! (Try Any)))) - (for {@.old - (case (packager archive context) - (#try.Success content) - (do (try.with monad) - [package (:share [!] - (Monad !) - monad - - (! (Try (File !))) - (:assume (file.get_file monad file_system package)))] - (\ (:share [!] - (Monad !) - monad - - (File !) - (:assume package)) - over_write - content)) - - (#try.Failure error) - (\ monad wrap (#try.Failure error)))} - ## TODO: Fix whatever type_checker bug is forcing me into this compromise... - (:assume - (: (Promise (Try Any)) - (let [monad (:coerce (Monad Promise) monad) - file_system (:coerce (file.System Promise) file_system)] - (case (packager archive context) - (#try.Success content) - (do (try.with monad) - [package (: (Promise (Try (File Promise))) - (file.get_file monad file_system package))] - (\ (: (File Promise) package) over_write content)) - - (#try.Failure error) - (\ monad wrap (#try.Failure error)))))))) +(def: (package! monad fs [packager package] static archive context) + (All [!] (-> (Monad !) (file.System !) [Packager file.Path] Static Archive Context (! (Try Any)))) + (case (packager archive context) + (#try.Success content) + (\ fs write content package) + + (#try.Failure error) + (\ monad wrap (#try.Failure error)))) (with_expansions [ (as_is anchor expression artifact)] (def: #export (compiler static @@ -137,7 +107,7 @@ [Type Type Type] Extender Service - [Packager Path] + [Packager file.Path] (Promise Any))) (do {! promise.monad} [platform (promise.future platform)] -- cgit v1.2.3