Introducing Toolbelt, your useful little utility companion

Hi there, this is my first post :grin:

I wanted to let you all know of a new library I am creating, called toolbelt. You can find the source here and the docs here.

Toolbelt extends native Elixir modules with extra functionality. A simple use Toolbelt will make those extra functions accessible, while you can still use everything just as usual. Some of the functions it provides: Keyword.is_keyword, Keyword.is_keyword_element, Map.map_deep, Map.map_keys, Map.map_values, Enum.andmap, Enum.ormap, Enum.first, Enum.last, …

The basic aim of this library is to extend the standard Elixir library with some less common but still highly useful functions. The best example is an implementation of Map.map_deep, which allows you to transform all pairs in an arbitrarily-nested map.

It would be really great if you could help with this library, as I am fairly new to Elixir and don’t (yet) know all of the standard ways of doing things. Above that, I might forget of a few useful functions.

There’s still a lot of work on it so if you have any comments or feedback, please let me know.



Looks cool, your extension style is interesting. :wink:

Few notes:

andmap(enum, callback)
Performs a classical ormap on the given enumerable


Takes the first element from the enumerable

There is no ‘first’ element in some enumerables, maybe this should be called pop to pop one off (since enumerables may not have a specified order, like a large map). Or perhaps called one or so?

ormap(enum, callback)
Performs a classical ormap on the given enumerable

Really should document what a classical ormap is, with examples, same with the andmap. :slight_smile:

Takes the first element from the enumerable

Definitely not the first, and like the first call this wording makes no sense with many types of enumerables, such a pop function should probably return a tuple of one random and whatever is left over. Or maybe call it after_one?

When documenting should probably take the opportunity to write examples, while also making them doctests.

Determines if the given value kan be used as a keyword list element

kan is not a word. ^.^
Also it does not detail what properties can make a value a keyword list element, examples would fix this too.
For note:

  def is_keyword_element(val) do
    is_tuple(val) and tuple_size(val)

is wrong. ^.^ For an Elixir style keyword list the spec of a keyword element is {atom(), any()}, for an Erlang style keyword list the spec is any tuple of size 1 or high filled with any() types.

The extra functions on Map look useful, however they sorely need documentation, examples, and doctests. It’s likely possible to reduce the number of these functions to be a bit more generic as well.

MapLike.is_maplike/1 and MapLike.put/3 have no documentation at all. The rest have no examples or doctests.

Good start though, still weary about the extension method done, but eh, need to futz with it to see. ^.^


Hi OvermindDL1,

Thank you so much for your reply :smiley: I didn’t notice the mistakes, will fix them immediately.

No 7 I just discovered myself while implementing some more functions :stuck_out_tongue:



Just for the record: I’ve dealt with most of the issues, and added some new niceties as well. When reaching 1.0.0, the code should become much more stable and it should be easier to fork :wink:

1 Like