Skip to content

Latest commit

 

History

History
45 lines (35 loc) · 1.57 KB

notes.org

File metadata and controls

45 lines (35 loc) · 1.57 KB

Notes

Inbox

lenses

For now clojure functions implement lens in a trivial way. Beside being quite handy, it do not feels particularly right. Given the definition of lenses of the docs: “A lens a well know abstraction that is used to get a certain view of a datastructure and potentially update this view, repercuting back the changes to the original datastructure.” The repercution part is not handled by the the default function impl. As an example, let’s look at the `next` lens:

(in-ns 'monk.core)

(let [L (lens/mk
         c/next
         ;; The update function is taking care of preserving the head of the given seq.
         (fn [s f] (send s (> c/next f (f_ (c/cons (c/first s) _))))))]

  (upd (c/range 10)
       L
       ($ c/inc)))

nil and false

The old question of false Should it be considered truthy? Booleans are valuable data that should be decoupled from control flow ? For now false is not allowed and short-circuits the execution. This was originally intended to ease clojure integration but do not seems to still be necessary. The wrapping of clojure predicates into guards now occurs in monk.core.

first try

created false-is-a-value branch

[:use monk.core]

Currently monk is intended to be ‘used’. It is not a common practice in the clojure community for good reasons. It conflicts with many tools and is not clojurescript friendly.

keep and kick

the upd implementation of those lenses is very discutable and certainly incorrect. the upd method expects a item level update, it should take a collection update.