Monday, November 04, 2019

watched a talk about a clojure library: noprompt/meander: Tools for transparent data transformation

"Meander: Declarative Explorations at the Limits of FP" by Jimmy Miller

the hello world example is quite interesting:

transform

{:name "Jimmy"
 :address
 {:address1 "123 street ave"
  :address2 "apt 2"
  :city "Townville"
  :state "IN"
  :zip "46203"}}

to this structure:

{:name "Jimmy"
 :address {:line1 "123 street ave"
           :line2 "apt 2"}
 :city-info {:city "Townville"
             :state "IN"
             :zipcode "46203"}}

it's simple and also readable:

(m/match person
         {:name ?name
          :address
          {:address1 ?address1
           :address2 ?address2
           :city ?city
           :state ?state
           :zip ?zip}}

         {:name ?name
          :address {:line1 ?address1
                    :line2 ?address2}
          :city-info {:city ?city
                      :state ?state
                      :zipcode ?zip}})

Blog Archives

Search Blog: