robertluo / fun-map

a map blurs the line between identity, state and function

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

defrecord+

robertluo opened this issue · comments

fun-map can become an implementation of defrecord+, provide accessor pattern to it.

(defrecord+ FooType [a b]
   (accessors
      :foo/sum [a b] (+ a b))
      :foo/average [:foo/sum] (/ sum 2))
   
   ProtocolA
   (foo [{:keys [:foo/sum]} other]
      (+ sum b other)))

need more thought.