Single-line import of core, lenses, and combinator
zachallaun opened this issue · comments
Pathex is super neat, but the ergonomics are hampered by having to import 2-3 different modules for even relatively simple uses. This example on the forum, for instance: https://elixirforum.com/t/find-a-specific-string-in-an-unstructured-and-nested-list/53918/10?u=zachallaun
I’d propose that use Pathex
should be updated to import a much larger set of primitives, including those from combinator, lenses, etc.
Alternatively: Lenses and Combinator could become private modules, with their functions being re-exported by the Pathex module. This means the behavior of use Pathex would not need to change and documentation would be consolidated.
Updated the title to something that better represents the desired outcome.
Yeah, I've thought about this and I came up with different approaches for this
-
Leave it all as it is. It is simple, explicit and it reflects how people use the library.
For 90% use cases, you justimport Pathex
. For 9% of use cases you alsoimport Pathex.Lenses
. And only for 1% of use casesimport Pathex.Combinator
. And even in most cases, one could just call functions fromPathex.Lenses
orPathex.Combinator
directly -
Move everything to
Pathex
and suggest usingimport Pathex
.
This would add a lot of complex functions with very generic names. Usingonly
option would be even more verbose -
Move everything to
use Pathex
has the same problem as above -
use Pathex, lenses: true, combinator: true
. Nice, but this saves only a few characters and is less explicit