Finally managed to find some (Claude’s) time to complete the long planned and postponed feature set for the :extructure library. I’m aware this probably matters far less now than it did while we still used to actually code but I still prefer using :extructure even though it’s Claude writing most of the code now, because in my view it’s more compact and readable (e.g. for reviews) than the vanilla Elixir’s Map.get/fetch, Keyword.get/fetch, etc.
So, in addition to the existing loose (& rigid) destructuring based on the <~/2 operator, there is now a match based destructuring for the likes of function headers and case statements:
-%{ a} = %{ a: 1, b: 2} # for atom keys
-@%{ a} = %{ "a" => 1} # for string keys
The analog syntax with keyword lists and tuple keypairs is also supported.
Also added something I’ve long liked about JS (and been missing in Elixir) - the structuring shorthand:
a = 1
b = 2
+%{ a, b} # %{ a: 1, b: 2}
+@%{ a, b} # %{ "a" => 1, "b" => 2}
Same for keywords or listed string keypairs and tuple atom and string keypairs.
Here’s the whole thing again with the examples and all: extructure | Hex






















