Fork me on GitHub
#meander
<
2021-01-13
>
chucklehead03:01:55

would appreciate any suggestions on simplifying or otherwise improving this rewrite, first time really trying to do anything with cata and memory variables: https://github.com/casselc/dmarc/blob/4ce96be48367381d8983b2082174213ebf848725/src/casselc/dmarc.clj#L30

Jimmy Miller04:01:12

Overall things look pretty good. Are there any things you are running into trouble with? A couple things I’d change from my quick glance. 1. Instead of (m/app merge map1 (m/cata !record)) you can do {:my-keys :my-vals & (m/cata !record)} 2. Sprinkle in some (m/some). Meander doesn’t actually check that keys exist in maps by default.

(m/rewrite {:a 2}
  {:record _ :as !record}
  [!record ...])

;; => [{:a 2}]

(m/rewrite {:a 2}
  {:record (m/some) :as !record}
  [!record ...])
;; =>  nil
If there is anything that isn’t working how you expect, definitely let us know and we can help.

chucklehead05:01:43

thanks, the merge was making my eye twitch a little:slightly_smiling_face: - as best I can tell it's working correctly at the moment, although it took longer than I care to admit to get to this point. I mostly wanted to make sure I wasn't overly complicating anything or doing something boneheaded (like you pointed out with some )

chucklehead06:01:10

I think missing m/some may have been why I couldn't get the {:spf}pattern variants to work as memory variables instead of using cata when I tried previously.

chucklehead06:01:30

Also adding some uncovered an issue where some providers are sending fields in a different order than the schema specifies and I was just silently ignoring some of the data, so thanks again.