aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/control/writer.lux (renamed from stdlib/source/lux/data/log.lux)30
-rw-r--r--stdlib/test/test/lux/control/writer.lux (renamed from stdlib/test/test/lux/data/log.lux)22
-rw-r--r--stdlib/test/tests.lux2
3 files changed, 27 insertions, 27 deletions
diff --git a/stdlib/source/lux/data/log.lux b/stdlib/source/lux/control/writer.lux
index 19753199f..6a82df77c 100644
--- a/stdlib/source/lux/data/log.lux
+++ b/stdlib/source/lux/control/writer.lux
@@ -5,20 +5,20 @@
functor
[monad #+ do Monad]))
-(type: #export (Log l a)
+(type: #export (Writer l a)
{#;doc "Represents a value with an associated 'log' value to record arbitrary information."}
{#log l
#value a})
-(struct: #export Functor<Log> (All [l]
- (Functor (Log l)))
+(struct: #export Functor<Writer> (All [l]
+ (Functor (Writer l)))
(def: (map f fa)
(let [[log datum] fa]
[log (f datum)])))
-(struct: #export (Applicative<Log> mon) (All [l]
- (-> (Monoid l) (Applicative (Log l))))
- (def: functor Functor<Log>)
+(struct: #export (Applicative<Writer> mon) (All [l]
+ (-> (Monoid l) (Applicative (Writer l))))
+ (def: functor Functor<Writer>)
(def: (wrap x)
[(:: mon unit) x])
@@ -28,9 +28,9 @@
[log2 a] fa]
[(:: mon append log1 log2) (f a)])))
-(struct: #export (Monad<Log> mon) (All [l]
- (-> (Monoid l) (Monad (Log l))))
- (def: applicative (Applicative<Log> mon))
+(struct: #export (Monad<Writer> mon) (All [l]
+ (-> (Monoid l) (Monad (Writer l))))
+ (def: applicative (Applicative<Writer> mon))
(def: (join mma)
(let [[log1 [log2 a]] mma]
@@ -38,21 +38,21 @@
(def: #export (log l)
{#;doc "Set the log to a particular value."}
- (All [l] (-> l (Log l Unit)))
+ (All [l] (-> l (Writer l Unit)))
[l []])
-(struct: #export (LogT Monoid<l> Monad<M>)
- (All [l M] (-> (Monoid l) (Monad M) (Monad (All [a] (M (Log l a))))))
- (def: applicative (A;compA (get@ #monad;applicative Monad<M>) (Applicative<Log> Monoid<l>)))
+(struct: #export (WriterT Monoid<l> Monad<M>)
+ (All [l M] (-> (Monoid l) (Monad M) (Monad (All [a] (M (Writer l a))))))
+ (def: applicative (A;compA (get@ #monad;applicative Monad<M>) (Applicative<Writer> Monoid<l>)))
(def: (join MlMla)
(do Monad<M>
- [[l1 Mla] (: (($ +1) (Log ($ +0) (($ +1) (Log ($ +0) ($ +2)))))
+ [[l1 Mla] (: (($ +1) (Writer ($ +0) (($ +1) (Writer ($ +0) ($ +2)))))
MlMla)
[l2 a] Mla]
(wrap [(:: Monoid<l> append l1 l2) a]))))
(def: #export (lift Monoid<l> Monad<M>)
- (All [l M a] (-> (Monoid l) (Monad M) (-> (M a) (M (Log l a)))))
+ (All [l M a] (-> (Monoid l) (Monad M) (-> (M a) (M (Writer l a)))))
(function [ma]
(do Monad<M>
[a ma]
diff --git a/stdlib/test/test/lux/data/log.lux b/stdlib/test/test/lux/control/writer.lux
index bcd3a1a56..8c9e1c676 100644
--- a/stdlib/test/test/lux/data/log.lux
+++ b/stdlib/test/test/lux/control/writer.lux
@@ -2,25 +2,25 @@
lux
(lux [io]
(control ["M" monad #+ do Monad]
- pipe)
- (data ["&" log]
- [text "Text/" Monoid<Text> Eq<Text>]
+ pipe
+ ["&" writer])
+ (data [text "Text/" Monoid<Text> Eq<Text>]
[number]
[product]))
lux/test)
-(context: "Logs"
- (let [(^open "&/") (&;Monad<Log> text;Monoid<Text>)]
+(context: "Writer."
+ (let [(^open "&/") (&;Monad<Writer> text;Monoid<Text>)]
($_ seq
- (test "Functor respects Log."
+ (test "Functor respects Writer."
(i.= 11 (product;right (&/map i.inc ["" 10]))))
- (test "Applicative respects Log."
+ (test "Applicative respects Writer."
(and (i.= 20 (product;right (&/wrap 20)))
(i.= 30 (product;right (&/apply (&/wrap (i.+ 10)) (&/wrap 20))))))
- (test "Monad respects Log."
- (i.= 30 (product;right (do (&;Monad<Log> text;Monoid<Text>)
+ (test "Monad respects Writer."
+ (i.= 30 (product;right (do (&;Monad<Writer> text;Monoid<Text>)
[f (wrap i.+)
a (wrap 10)
b (wrap 20)]
@@ -33,8 +33,8 @@
(context: "Monad transformer"
(let [lift (&;lift text;Monoid<Text> io;Monad<IO>)
(^open "io/") io;Monad<IO>]
- (test "Can add log functionality to any monad."
- (|> (io;run (do (&;LogT text;Monoid<Text> io;Monad<IO>)
+ (test "Can add writer functionality to any monad."
+ (|> (io;run (do (&;WriterT text;Monoid<Text> io;Monad<IO>)
[a (lift (io/wrap 123))
b (wrap 456)]
(wrap (i.+ a b))))
diff --git a/stdlib/test/tests.lux b/stdlib/test/tests.lux
index fffe409c4..9b0f8ff11 100644
--- a/stdlib/test/tests.lux
+++ b/stdlib/test/tests.lux
@@ -23,6 +23,7 @@
["_;" pipe]
["_;" cont]
["_;" reader]
+ ["_;" writer]
["_;" state]
["_;" parser])
(data ["_;" bit]
@@ -30,7 +31,6 @@
["_;" result]
["_;" ident]
["_;" identity]
- ["_;" log]
["_;" maybe]
["_;" number]
["_;" product]