Minor project structure improvement.

This commit is contained in:
Andrey Antukh 2015-12-17 16:43:58 +02:00
parent a2c313dfc0
commit b317ee4904
17 changed files with 106 additions and 115 deletions

View file

@ -0,0 +1,28 @@
(ns uxbox.util.lens
(:refer-clojure :exclude [derive])
(:require [cats.labs.lens :as l]))
(defn dep-in
[where link]
{:pre [(vector? where) (vector? link)]}
(l/lens
(fn [s]
(let [value (get-in s link)
path (conj where value)]
(get-in s path)))
(fn [s f]
(throw (ex-info "Not implemented" {})))))
(defn getter
[f]
(l/lens f #(throw (ex-info "Not implemented" {}))))
(defn derive
[a path]
(l/focus-atom (l/in path) a))
(defn focus
([state]
(l/focus-atom l/id state))
([lens state]
(l/focus-atom lens state)))