aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/world/file.lux
diff options
context:
space:
mode:
authorEduardo Julian2018-12-15 19:05:19 -0400
committerEduardo Julian2018-12-15 19:05:19 -0400
commitde728c05f0c7fbc47b0d0d9db02d141d734eb755 (patch)
treeafce90f3922aaed9779c38df6a18117f9b1a2b40 /stdlib/source/lux/world/file.lux
parentee0c268d2e7922ce4d1b1b11291e6858977cce74 (diff)
No longer relying on "signature:"'s and "structure:"'s internal macro-expansion to handle the "do-template"s inside.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/world/file.lux122
1 files changed, 61 insertions, 61 deletions
diff --git a/stdlib/source/lux/world/file.lux b/stdlib/source/lux/world/file.lux
index 343d2f7aa..df90ba842 100644
--- a/stdlib/source/lux/world/file.lux
+++ b/stdlib/source/lux/world/file.lux
@@ -47,15 +47,15 @@
(Capability [i] (! (Error Any))))
(signature: #export (File !)
- (do-template [<name> <output>]
- [(: (Can-Query ! <output>)
- <name>)]
+ (~~ (do-template [<name> <output>]
+ [(: (Can-Query ! <output>)
+ <name>)]
- [size Nat]
- [last-modified Instant]
- [can-execute? Bit]
- [content (Dirty Binary)]
- )
+ [size Nat]
+ [last-modified Instant]
+ [can-execute? Bit]
+ [content (Dirty Binary)]
+ ))
(: (Can-Open ! File)
move)
@@ -86,15 +86,15 @@
discard))
(signature: #export (System !)
- (do-template [<name> <capability>]
- [(: (Can-Open ! <capability>)
- <name>)]
+ (~~ (do-template [<name> <capability>]
+ [(: (Can-Open ! <capability>)
+ <name>)]
- [file File]
- [create-file File]
- [directory Directory]
- [create-directory Directory]
- )
+ [file File]
+ [create-file File]
+ [directory Directory]
+ [create-directory Directory]
+ ))
(: Text
separator)
@@ -225,17 +225,17 @@
(structure: (File<IO> path)
(-> Path (File IO))
- (do-template [<name> <flag>]
- [(def: (<name> data)
- (do io.Monad<Process>
- [stream (FileOutputStream::new (java/io/File::new path) <flag>)
- _ (OutputStream::write data stream)
- _ (OutputStream::flush stream)]
- (AutoCloseable::close stream)))]
+ (~~ (do-template [<name> <flag>]
+ [(def: (<name> data)
+ (do io.Monad<Process>
+ [stream (FileOutputStream::new (java/io/File::new path) <flag>)
+ _ (OutputStream::write data stream)
+ _ (OutputStream::flush stream)]
+ (AutoCloseable::close stream)))]
- [over-write #0]
- [append #1]
- )
+ [over-write #0]
+ [append #1]
+ ))
(def: (content _)
(do io.Monad<Process>
@@ -294,46 +294,46 @@
(structure: (Directory<IO> path)
(-> Path (Directory IO))
- (do-template [<name> <method> <capability>]
- [(def: (<name> _)
- (do io.Monad<Process>
- [?children (java/io/File::listFiles (java/io/File::new path))]
- (case ?children
- (#.Some children)
- (|> children
- array.to-list
- (monad.filter @ (|>> <method>))
- (:: @ map (monad.map @ (|>> java/io/File::getAbsolutePath (:: @ map <capability>))))
- (:: @ join))
-
- #.None
- (io.throw not-a-directory [path]))))]
-
- [files java/io/File::isFile File<IO>]
- [directories java/io/File::isDirectory Directory<IO>]
- )
+ (~~ (do-template [<name> <method> <capability>]
+ [(def: (<name> _)
+ (do io.Monad<Process>
+ [?children (java/io/File::listFiles (java/io/File::new path))]
+ (case ?children
+ (#.Some children)
+ (|> children
+ array.to-list
+ (monad.filter @ (|>> <method>))
+ (:: @ map (monad.map @ (|>> java/io/File::getAbsolutePath (:: @ map <capability>))))
+ (:: @ join))
+
+ #.None
+ (io.throw not-a-directory [path]))))]
+
+ [files java/io/File::isFile File<IO>]
+ [directories java/io/File::isDirectory Directory<IO>]
+ ))
(def: (discard _)
(!delete path cannot-discard-directory)))
(structure: #export _ (System IO)
- (do-template [<name> <method> <capability> <exception>]
- [(def: (<name> path)
- (do io.Monad<IO>
- [#let [file (java/io/File::new path)]
- outcome (<method> file)]
- (case outcome
- (#error.Success #1)
- (wrap (#error.Success (<capability> path)))
-
- _
- (wrap (ex.throw <exception> [path])))))]
-
- [file java/io/File::isFile ..File<IO> cannot-find-file]
- [create-file java/io/File::createNewFile ..File<IO> cannot-create-file]
- [directory java/io/File::isDirectory ..Directory<IO> cannot-find-directory]
- [create-directory java/io/File::mkdir ..Directory<IO> cannot-create-directory]
- )
+ (~~ (do-template [<name> <method> <capability> <exception>]
+ [(def: (<name> path)
+ (do io.Monad<IO>
+ [#let [file (java/io/File::new path)]
+ outcome (<method> file)]
+ (case outcome
+ (#error.Success #1)
+ (wrap (#error.Success (<capability> path)))
+
+ _
+ (wrap (ex.throw <exception> [path])))))]
+
+ [file java/io/File::isFile ..File<IO> cannot-find-file]
+ [create-file java/io/File::createNewFile ..File<IO> cannot-create-file]
+ [directory java/io/File::isDirectory ..Directory<IO> cannot-find-directory]
+ [create-directory java/io/File::mkdir ..Directory<IO> cannot-create-directory]
+ ))
(def: separator (java/io/File::separator))
))