Fork me on GitHub
#pathom
<
2022-12-30
>
caleb.macdonaldblack05:12:49

How is everyone finding the smart-map in Pathom3? I find myself reaching for p.eql/process mostly. The smart-map just seems kinda gimmicky. Would love to hear from people that use it more.

wilkerlucio12:01:41

hello Caleb, I personally haven't used it much either

wilkerlucio12:01:08

I can imagine some interesting usages when interfacing with things that require maps

wilkerlucio12:01:16

one idea I have for instance, is for a compatibility layer between Pathom 2 and 3, where a Pathom 2 plugin for instance can receive an env that's a smart map, that can respond to Pathom 2 env keys, translating to Pathom 3 keys

caleb.macdonaldblack14:01:48

Ah that’s interesting. For smaller things it could be useful. One project I’m working on isn’t using Pathom at all. We have a data structure that we’ve began refactoring by renaming some keys with improved namespaces & names. Also small structure changes. All new keywords however to avoid breaking changes. What we will essentially have is the old and new data structures merged together. I could wrap the data structure in a smart map with resolvers providing bidirectional conversion for old keywords to new keywords. It’s a very cool solution to this compatibility problem. However, there may be situations where transformative code might take the smart map and return a regular map. Also when sending smart maps through legacy code, developers reading the code won’t have any idea they’re dealing a smart map unless they know before hand.

wilkerlucio14:01:39

yup, all you said is correct, I add one caveat to the "However, there may be situations where transformative code might take the smart map and return a regular map.", this is a config on smart maps, by default, any map (or sequence of maps, including sets) will get automatically wrapped to become a smart map too (check: https://github.com/wilkerlucio/pathom3/blob/98098d2827fa3f14aab6ee5e7c265cb3db4c94bb/src/main/com/wsscode/pathom3/interface/smart_map.cljc#L79-L101)

wilkerlucio14:01:58

you can set ::psm/wrap-nested? false (in env) to disable this behavior

Eric Dvorsak17:01:14

I haven't been using them at all