deft/notes/deep_merge_exploration.org
Yann Esposito (Yogsototh) c1d2459d0c
save
2024-08-14 11:35:42 +02:00

1.4 KiB

Deep Merge exploration

tags
clojure blog
source

One common task in software coding is to manipulate deeply nested structures. Depending on the programming language you use, you have a different set of root structures.

But in most languages you have roughly the same concepts. Base types, like chars, numbers, often strings Storage types, typically, arrays, list, associative array (map, hash-map).

So let's restrict ourselves to this common denominator of data structure. Say, base types could be: char, number, string Construction types could be map (associative array) or arrays. Sounds simple enough.

So a common task is to "merge" such structure. A typical common example, is to have an application that read from a configuration file.

As the application becomes more and more complex, the configuration file also grow in complexity. At first, this is just a list of properties, but it is frequent to use json, yaml (dhall if you are in this kind of thing).

And a common usage would be to provide default values for the configuration. Instead of putting the default value manually in your code a nice alternative is to "merge" the user config with a default config.