funcool

A channel for discussing and asking questions about Funcool libraries https://github.com/funcool/
martinklepsch 2016-10-20T21:37:03.000149Z

Question about struct

(def identical-to
  {:message "does not match"
   :optional true
   :state true
   :validate (fn [state v ref]
               (let [prev (get state ref)]
                 (= prev v)))})
some validators like the one above can be parameterized. Why are these not functions returning the map containing :message and so on and instead to this, slightly odd, argument passing via grouping in vectors?

niwinz 2016-10-20T22:14:34.000150Z

@martinklepsch you can define identical-to like a function that return a validator map if you want

niwinz 2016-10-20T22:14:42.000151Z

no one stops you to do so 😄

martinklepsch 2016-10-20T22:18:00.000152Z

@niwinz right, I can totally do that, I'm just wondering why it's done in a different way in the library

martinklepsch 2016-10-20T22:18:33.000153Z

Like I perceive the validator-args-via-vector thing as more complex than functions but I guess there's a reason for it so I'm curious to understand

niwinz 2016-10-20T22:26:17.000155Z

Is just a cosmetic feature, that makes reading the scheme more uniform

niwinz 2016-10-20T22:29:06.000156Z

But is just a preference, nothing more

niwinz 2016-10-20T22:29:13.000157Z

there are no good rationale for this

martinklepsch 2016-10-20T22:39:30.000158Z

ok, cool 👍

martinklepsch 2016-10-20T22:39:32.000159Z

🙂