aboutsummaryrefslogtreecommitdiff
path: root/stdlib
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
parentee0c268d2e7922ce4d1b1b11291e6858977cce74 (diff)
No longer relying on "signature:"'s and "structure:"'s internal macro-expansion to handle the "do-template"s inside.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/source/lux/control/functor.lux1
-rw-r--r--stdlib/source/lux/control/number.lux19
-rw-r--r--stdlib/source/lux/control/order.lux22
-rw-r--r--stdlib/source/lux/data/collection/array.lux3
-rw-r--r--stdlib/source/lux/data/collection/row.lux12
-rw-r--r--stdlib/source/lux/data/number.lux1
-rw-r--r--stdlib/source/lux/macro/poly/json.lux1
-rw-r--r--stdlib/source/lux/time/date.lux45
-rw-r--r--stdlib/source/lux/time/duration.lux22
-rw-r--r--stdlib/source/lux/time/instant.lux34
-rw-r--r--stdlib/source/lux/type/unit.lux22
-rw-r--r--stdlib/source/lux/world/file.lux122
12 files changed, 150 insertions, 154 deletions
diff --git a/stdlib/source/lux/control/functor.lux b/stdlib/source/lux/control/functor.lux
index 8fcb40c55..b8ad0b159 100644
--- a/stdlib/source/lux/control/functor.lux
+++ b/stdlib/source/lux/control/functor.lux
@@ -21,5 +21,6 @@
(structure: #export (compose Functor<F> Functor<G>)
{#.doc "Functor composition."}
(All [F G] (-> (Functor F) (Functor G) (Functor (All [a] (F (G a))))))
+
(def: (map f fga)
(:: Functor<F> map (:: Functor<G> map f) fga)))
diff --git a/stdlib/source/lux/control/number.lux b/stdlib/source/lux/control/number.lux
index bf8e41194..3fc8faabf 100644
--- a/stdlib/source/lux/control/number.lux
+++ b/stdlib/source/lux/control/number.lux
@@ -1,15 +1,14 @@
(.module:
lux)
-## [Signatures]
-(signature: #export (Number n)
- {#.doc "Everything that should be expected of a number type."}
+(`` (signature: #export (Number n)
+ {#.doc "Everything that should be expected of a number type."}
- (do-template [<name>]
- [(: (-> n n n) <name>)]
- [+] [-] [*] [/] [%])
+ (~~ (do-template [<name>]
+ [(: (-> n n n) <name>)]
+ [+] [-] [*] [/] [%]))
- (do-template [<name>]
- [(: (-> n n) <name>)]
- [negate] [signum] [abs])
- )
+ (~~ (do-template [<name>]
+ [(: (-> n n) <name>)]
+ [negate] [signum] [abs]))
+ ))
diff --git a/stdlib/source/lux/control/order.lux b/stdlib/source/lux/control/order.lux
index ef9030c2d..30618b317 100644
--- a/stdlib/source/lux/control/order.lux
+++ b/stdlib/source/lux/control/order.lux
@@ -4,18 +4,18 @@
[// [equivalence (#+ Equivalence)]])
## [Signatures]
-(signature: #export (Order a)
- {#.doc "A signature for types that possess some sense of ordering among their elements."}
-
- (: (Equivalence a)
- eq)
-
- (do-template [<name>]
- [(: (-> a a Bit) <name>)]
+(`` (signature: #export (Order a)
+ {#.doc "A signature for types that possess some sense of ordering among their elements."}
+
+ (: (Equivalence a)
+ eq)
+
+ (~~ (do-template [<name>]
+ [(: (-> a a Bit) <name>)]
- [<] [<=] [>] [>=]
- )
- )
+ [<] [<=] [>] [>=]
+ ))
+ ))
## [Values]
(def: #export (order eq <)
diff --git a/stdlib/source/lux/data/collection/array.lux b/stdlib/source/lux/data/collection/array.lux
index c38ae1371..6bd59d7b5 100644
--- a/stdlib/source/lux/data/collection/array.lux
+++ b/stdlib/source/lux/data/collection/array.lux
@@ -229,8 +229,7 @@
_
#0)))
#1
- (list.indices sxs))))
- ))
+ (list.indices sxs))))))
(structure: #export Monoid<Array> (All [a] (Monoid (Array a)))
(def: identity (new 0))
diff --git a/stdlib/source/lux/data/collection/row.lux b/stdlib/source/lux/data/collection/row.lux
index 668e49b6c..d388d6ede 100644
--- a/stdlib/source/lux/data/collection/row.lux
+++ b/stdlib/source/lux/data/collection/row.lux
@@ -377,8 +377,7 @@
(#Hierarchy hierarchy)
(array/fold (function (_ node init') (fold f init' node))
init
- hierarchy))
- ))
+ hierarchy))))
(structure: #export _ (Fold Row)
(def: (fold f init xs)
@@ -387,8 +386,7 @@
(fold f
init
(#Hierarchy (get@ #root xs)))
- (#Base (get@ #tail xs))))
- ))
+ (#Base (get@ #tail xs))))))
(structure: #export Monoid<Row> (All [a] (Monoid (Row a)))
(def: identity empty)
@@ -402,16 +400,14 @@
(#Base (array/map f base))
(#Hierarchy hierarchy)
- (#Hierarchy (array/map (map f) hierarchy)))
- ))
+ (#Hierarchy (array/map (map f) hierarchy)))))
(structure: #export _ (Functor Row)
(def: (map f xs)
{#level (get@ #level xs)
#size (get@ #size xs)
#root (|> xs (get@ #root) (array/map (:: Functor<Node> map f)))
- #tail (|> xs (get@ #tail) (array/map f))
- }))
+ #tail (|> xs (get@ #tail) (array/map f))}))
(structure: #export _ (Apply Row)
(def: functor Functor<Row>)
diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux
index b133e905f..e745d542a 100644
--- a/stdlib/source/lux/data/number.lux
+++ b/stdlib/source/lux/data/number.lux
@@ -1022,7 +1022,6 @@
(structure: #export _ (Hash Frac)
(def: eq Equivalence<Frac>)
-
(def: hash frac-to-bits))
(structure: #export _ (Hash Rev)
diff --git a/stdlib/source/lux/macro/poly/json.lux b/stdlib/source/lux/macro/poly/json.lux
index 96c647c6b..6ef9b249e 100644
--- a/stdlib/source/lux/macro/poly/json.lux
+++ b/stdlib/source/lux/macro/poly/json.lux
@@ -77,6 +77,7 @@
(structure: Codec<JSON,Qty>
(All [unit] (Codec JSON (unit.Qty unit)))
+
(def: encode
(|>> unit.out (:: Codec<JSON,Int> encode)))
(def: decode
diff --git a/stdlib/source/lux/time/date.lux b/stdlib/source/lux/time/date.lux
index 71dd1003d..59bfc5c0e 100644
--- a/stdlib/source/lux/time/date.lux
+++ b/stdlib/source/lux/time/date.lux
@@ -70,17 +70,17 @@
#November 10
#December 11))
-(structure: #export _ (Order Month)
- (def: eq Equivalence<Month>)
- (do-template [<name> <comp>]
- [(def: (<name> reference sample)
- (<comp> (month-to-nat reference) (month-to-nat sample)))]
+(`` (structure: #export _ (Order Month)
+ (def: eq Equivalence<Month>)
+ (~~ (do-template [<name> <comp>]
+ [(def: (<name> reference sample)
+ (<comp> (month-to-nat reference) (month-to-nat sample)))]
- [< n/<]
- [<= n/<=]
- [> n/>]
- [>= n/>=]
- ))
+ [< n/<]
+ [<= n/<=]
+ [> n/>]
+ [>= n/>=]
+ ))))
(structure: #export _ (Enum Month)
(def: order Order<Month>)
@@ -150,17 +150,17 @@
#Friday 5
#Saturday 6))
-(structure: #export _ (Order Day)
- (def: eq Equivalence<Day>)
- (do-template [<name> <comp>]
- [(def: (<name> reference sample)
- (<comp> (day-to-nat reference) (day-to-nat sample)))]
+(`` (structure: #export _ (Order Day)
+ (def: eq Equivalence<Day>)
+ (~~ (do-template [<name> <comp>]
+ [(def: (<name> reference sample)
+ (<comp> (day-to-nat reference) (day-to-nat sample)))]
- [< n/<]
- [<= n/<=]
- [> n/>]
- [>= n/>=]
- ))
+ [< n/<]
+ [<= n/<=]
+ [> n/>]
+ [>= n/>=]
+ ))))
(structure: #export _ (Enum Day)
(def: order Order<Day>)
@@ -321,5 +321,6 @@
{#.doc (doc "Based on ISO 8601."
"For example: 2017-01-15")}
(Codec Text Date)
- (def: encode encode)
- (def: decode decode))
+
+ (def: encode ..encode)
+ (def: decode ..decode))
diff --git a/stdlib/source/lux/time/duration.lux b/stdlib/source/lux/time/duration.lux
index 699abe31d..9821bc33d 100644
--- a/stdlib/source/lux/time/duration.lux
+++ b/stdlib/source/lux/time/duration.lux
@@ -61,17 +61,17 @@
(def: (= param subject)
(i/= (:representation param) (:representation subject))))
- (structure: #export _ (Order Duration)
- (def: eq Equivalence<Duration>)
- (do-template [<name> <op>]
- [(def: (<name> param subject)
- (<op> (:representation param) (:representation subject)))]
-
- [< i/<]
- [<= i/<=]
- [> i/>]
- [>= i/>=]
- ))
+ (`` (structure: #export _ (Order Duration)
+ (def: eq Equivalence<Duration>)
+ (~~ (do-template [<name> <op>]
+ [(def: (<name> param subject)
+ (<op> (:representation param) (:representation subject)))]
+
+ [< i/<]
+ [<= i/<=]
+ [> i/>]
+ [>= i/>=]
+ ))))
(open: "duration/." Order<Duration>)
diff --git a/stdlib/source/lux/time/instant.lux b/stdlib/source/lux/time/instant.lux
index 8c61abe5c..d8fb0fe98 100644
--- a/stdlib/source/lux/time/instant.lux
+++ b/stdlib/source/lux/time/instant.lux
@@ -55,23 +55,23 @@
(def: (= param subject)
(:: number.Equivalence<Int> = (:representation param) (:representation subject))))
- (structure: #export _ (Order Instant)
- (def: eq Equivalence<Instant>)
- (do-template [<name>]
- [(def: (<name> param subject)
- (:: number.Order<Int> <name> (:representation param) (:representation subject)))]
-
- [<] [<=] [>] [>=]
- ))
-
- (structure: #export _ (Enum Instant)
- (def: order Order<Instant>)
- (do-template [<name>]
- [(def: <name>
- (|>> :representation (:: number.Enum<Int> <name>) :abstraction))]
-
- [succ] [pred]
- ))
+ (`` (structure: #export _ (Order Instant)
+ (def: eq Equivalence<Instant>)
+ (~~ (do-template [<name>]
+ [(def: (<name> param subject)
+ (:: number.Order<Int> <name> (:representation param) (:representation subject)))]
+
+ [<] [<=] [>] [>=]
+ ))))
+
+ (`` (structure: #export _ (Enum Instant)
+ (def: order Order<Instant>)
+ (~~ (do-template [<name>]
+ [(def: <name>
+ (|>> :representation (:: number.Enum<Int> <name>) :abstraction))]
+
+ [succ] [pred]
+ ))))
)
(def: #export epoch
diff --git a/stdlib/source/lux/type/unit.lux b/stdlib/source/lux/type/unit.lux
index 96584a989..6f38a02d0 100644
--- a/stdlib/source/lux/type/unit.lux
+++ b/stdlib/source/lux/type/unit.lux
@@ -167,17 +167,17 @@
(def: (= reference sample)
(i/= (out reference) (out sample))))
-(structure: #export Order<Unit> (All [unit] (Order (Qty unit)))
- (def: eq Equivalence<Unit>)
-
- (do-template [<name> <func>]
- [(def: (<name> reference sample)
- (<func> (out reference) (out sample)))]
-
- [< i/<]
- [<= i/<=]
- [> i/>]
- [>= i/>=]))
+(`` (structure: #export Order<Unit> (All [unit] (Order (Qty unit)))
+ (def: eq Equivalence<Unit>)
+
+ (~~ (do-template [<name> <func>]
+ [(def: (<name> reference sample)
+ (<func> (out reference) (out sample)))]
+
+ [< i/<]
+ [<= i/<=]
+ [> i/>]
+ [>= i/>=]))))
(structure: #export Enum<Unit> (All [unit] (Enum (Qty unit)))
(def: order Order<Unit>)
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))
))