aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/data/store.lux
diff options
context:
space:
mode:
authorEduardo Julian2021-08-24 05:23:45 -0400
committerEduardo Julian2021-08-24 05:23:45 -0400
commit36303d6cb2ce3ab9e36d045b9516c997bd461862 (patch)
treeb9d2f1495143054d61d9af129f36833624db9dac /stdlib/source/library/lux/data/store.lux
parentec1f31b5a1492d5e0ab260397291d4449483bbd9 (diff)
Outsourced the syntax for labelled type definitions to macros.
Diffstat (limited to 'stdlib/source/library/lux/data/store.lux')
-rw-r--r--stdlib/source/library/lux/data/store.lux22
1 files changed, 13 insertions, 9 deletions
diff --git a/stdlib/source/library/lux/data/store.lux b/stdlib/source/library/lux/data/store.lux
index a25331cd4..5fc594957 100644
--- a/stdlib/source/library/lux/data/store.lux
+++ b/stdlib/source/library/lux/data/store.lux
@@ -8,8 +8,9 @@
implicit]]])
(type: .public (Store s a)
- {#cursor s
- #peek (-> s a)})
+ (Record
+ {#cursor s
+ #peek (-> s a)}))
(def: (extend f wa)
(All [s a b] (-> (-> (Store s a) b) (Store s a) (Store s b)))
@@ -19,7 +20,7 @@
(implementation: .public functor
(All [s] (Functor (Store s)))
- (def: (map f fa)
+ (def: (each f fa)
(extend (function (_ store)
(f (\ store peek (\ store cursor))))
fa)))
@@ -27,11 +28,14 @@
(implementation: .public comonad
(All [s] (CoMonad (Store s)))
- (def: &functor ..functor)
+ (def: &functor
+ ..functor)
- (def: (out wa) (\\ peek (\\ cursor)))
+ (def: (out wa)
+ (\\ peek (\\ cursor)))
- (def: split (extend id)))
+ (def: disjoint
+ (extend id)))
(def: .public (peeks trans store)
(All [s a] (-> (-> s s) (Store s a) a))
@@ -39,12 +43,12 @@
(def: .public (seek cursor store)
(All [s a] (-> s (Store s a) (Store s a)))
- (\ (\\ split store) peek cursor))
+ (\ (\\ disjoint store) peek cursor))
(def: .public (seeks change store)
(All [s a] (-> (-> s s) (Store s a) (Store s a)))
- (|> store (\\ split) (peeks change)))
+ (|> store (\\ disjoint) (peeks change)))
(def: .public (experiment Functor<f> change store)
(All [f s a] (-> (Functor f) (-> s (f s)) (Store s a) (f a)))
- (\ Functor<f> map (\\ peek) (change (\\ cursor))))
+ (\ Functor<f> each (\\ peek) (change (\\ cursor))))