samvv

samvv

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.

Regards,
Sam

Showing Posts 1 to 3

OvermindDL1

OvermindDL1

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

Few notes:

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

s/ormap/andmap/

first(enum)
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:

rest(enum)
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.

is_keyword_element(val)
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)
  end

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. ^.^

samvv

samvv OP

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:

Regards,
Sam

samvv

samvv OP

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:

— All posts loaded —

Where Next? Top

Trending in Announcing Top

bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
387 15136 120
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 11030 135
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
shahryarjb
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly. One of i...
New
woylie
Phoenix components for pagination, sortable tables and filter forms with Flop and (optionally) Ecto. pagination cursor pagination sorta...
New
kip
Please say hi to a new lib, Astro that aims to deliver easy-to-consume astronomy calculations of practical use. For now it only calculat...
New

Other Trending Topics Top

akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
mudasobwa
I am seeing a lot of aplications of Argumentum ad Vericundiam in software discussions. They do link some piece of writing and point us to...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews