Fork me on GitHub
#yada
<
2017-11-01
>
grav21:11:42

The way yada uses Records (and maybe all uses of Records) seems magical to me. When calling a response fn, it wraps the ctx in a Response record, and if you merge the correct way (or assoc), you get to control status code, etc. If you don’t merge the correct way, you get a hashmap as the body. Is this idiomatic Clojure?

malcolmsparks21:11:11

It's a tradeoff. The problem in Liberator was in determining if the user was returning a map or actually a Ring response. Namespaced keys might be a better approach.

malcolmsparks21:11:43

I agree, the approach in yada isn't idiomatic

malcolmsparks21:11:52

But records are useful

malcolmsparks21:11:11

They have Rich's seal of approval 😊

dominicm21:11:45

@grav what's the incorrect way to merge?

grav21:11:15

(defrecord Foo [])
(instance? Foo (merge (Foo.) {})) ;; => true
(instance? Foo (merge {} (Foo.))) ;; => false

grav21:11:19

@malcolmsparks Haha, yes they have. Since 1.2 as I read it. Maybe he’s changed his mind since then 😉

grav21:11:45

But I certainly see the dilemma wrt map vs Ring response