From 7a69373e2dc7343145f815c8dc1081a1bfc233bb Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 26 Dec 2018 17:39:20 -0400 Subject: Utility functions for getting files and directories. --- stdlib/source/lux/world/file.lux | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/stdlib/source/lux/world/file.lux b/stdlib/source/lux/world/file.lux index f959e1af3..f0269e52c 100644 --- a/stdlib/source/lux/world/file.lux +++ b/stdlib/source/lux/world/file.lux @@ -339,6 +339,24 @@ )) })) +(do-template [ ] + [(def: #export ( Monad System path) + (All [!] (-> (Monad !) (System !) Path (! (Error ( !))))) + (do Monad + [outcome (:: System path)] + (case outcome + (#error.Success file) + (wrap (#error.Success file)) + + (#error.Failure error) + (if (ex.match? error) + (:: System path) + (wrap (#error.Failure error))))))] + + [get-file File create-file file ..cannot-create-file] + [get-directory Directory create-directory directory ..cannot-create-directory] + ) + (def: #export (exists? Monad System path) (All [!] (-> (Monad !) (System !) Path (! Bit))) (do Monad -- cgit v1.2.3