(.using [library [lux (.except) [abstract [functor (.only Functor)] comonad] [type implicit]]]) (type: .public (Store 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))) [#cursor (the #cursor wa) #peek (function (_ s) (f (has #cursor s wa)))]) (def .public functor (All (_ s) (Functor (Store s))) (implementation (def (each f fa) (extend (function (_ store) (f (at store peek (at store cursor)))) fa)))) (def .public comonad (All (_ s) (CoMonad (Store s))) (implementation (def functor ..functor) (def (out wa) (a/an peek (a/an cursor))) (def disjoint (extend id)))) (def .public (peeks trans store) (All (_ s a) (-> (-> s s) (Store s a) a)) (|> (a/an cursor) trans (a/an peek))) (def .public (seek cursor store) (All (_ s a) (-> s (Store s a) (Store s a))) (at (a/an disjoint store) peek cursor)) (def .public (seeks change store) (All (_ s a) (-> (-> s s) (Store s a) (Store s a))) (|> store (a/an disjoint) (peeks change))) (def .public (experiment Functor change store) (All (_ f s a) (-> (Functor f) (-> s (f s)) (Store s a) (f a))) (at Functor each (a/an peek) (change (a/an cursor))))