Re: [elixir-core:9744] Feature: Add Map.rename_key/3 and/or Map.rename_keys/3

2020-10-12 Thread jonar...@gmail.com
> Maybe if you want to keep the other keys as is, then "rename_key" can be handy This is the use case I had in mind. Let's say I have a map with 100 keys, but only need to rename one of them. In that event, today I would write something like this: {val, new_map} = Map.pop(original_map, :origin

[elixir-core:9790] [Proposal] String.chunk_by/2

2020-12-01 Thread jonar...@gmail.com
This is a generalization of the existing (and oddly specific) String.chunk/2 function that takes a string and a single-argument predicate function, returning a list of strings. e.g. String.chunk_by(" foo bar ", &(&1 =~ ~r/\w/)) # => [" ", "foo", " ", "bar", " "] The above example makes pro

[elixir-core:9792] Re: [Proposal] String.chunk_by/2

2020-12-02 Thread jonar...@gmail.com
ving whitespace*" cannot be easily solved this way. On Wednesday, December 2, 2020 at 1:52:12 PM UTC-5 shanes...@gmail.com wrote: > Are there use-cases that you see for this feature that don't fall under > String.split/3 with a regex argument? > > https://hexdocs.pm/elixir/String.ht

[elixir-core:9940] [Proposal] Surface Erlang's maps:map function

2021-01-12 Thread jonar...@gmail.com
A common task is to iterate over a map performing some operation thereby producing a new map. There are some ways to do this in Elixir presently, the simplest probably being for...into: for {key, val} <- map, into: %{} do {key, val * 2} end Enum.reduce/3 is also an option. However, Erlang pro

Re: [elixir-core:9946] [Proposal] Surface Erlang's maps:map function

2021-01-12 Thread jonar...@gmail.com
> > That said, `maps:map/2` is available: > > `:maps.map(fn _k, v -> v * 2 end, %{x: 1, y: 2, z: 3})` > > It might be worth exploring whether `Map.map` would be useful/efficient > enough to add for piping purposes. > > -a > > On Tue, Jan 12, 2021 at 4:51 PM jonar.

Re: [elixir-core:9974] [Proposal] Surface Erlang's maps:map function

2021-01-14 Thread jonar...@gmail.com
ble to Elixir users like myself? I don’t care that the >> > arguments are “backwards” from the pipeline, because `maps:map/2` is >> > _incredibly_ useful and will improve some code that I have in >> > production. >> > >> > -a >> > >>

[elixir-core:10214] [Proposal] Support steps in typespecs

2021-04-13 Thread jonar...@gmail.com
While working with the v1.12.0 rc0 release, I wrote the following typespec: @spec my_fun(1..10//2) :: boolean() which resulted in the following error: == Compilation error in file lib/foobar.ex == ** (CompileError) lib/foobar.ex:6: type ..///3 undefined (no such type in Foobar) My confusion st

[elixir-core:10379] [Proposal] Use different exit codes for compilation errors versus test failures

2021-07-13 Thread jonar...@gmail.com
In our CI environment, we run our tests with this command: mix test --warnings-as-errors This is intended to fail when someone has created a warning within a test file in addition to when the tests themselves fail. We have an earlier check (MIX_ENV=test mix compile --force --warnings-as-errors