My concern is that Collectable.empty cannot be implemented by all structs. For example, what does it mean to call empty() on a IO.stream? Perhaps it would make sense as a separate protocol?
Also, can you please expand on how Repo.preload could use Scrivener.Page in detail? Thanks! *José Valim* www.plataformatec.com.br Skype: jv.ptec Founder and Director of R&D On Tue, May 21, 2019 at 5:46 PM Benjamin Milde <[email protected]> wrote: > I've had quite often needs for doing some computation (mapping) on ecto > result, but having a flexible function similar to `Repo.preload` currently > needs a whole bunch of boilerplate in terms of differenciating collections > from single items and especially returning the same type afterwards (e.g. > keep it a collection or single item). I know that Enumerable and > Collectable were split consciously, but it would be great to have something > like `Collectable.empty/1`, so one could do some work using `Enum` > functions and in the end do: `Enum.into(changed, > Collectable.empty(initial))` and it would empty the collectable and fill it > up again using the changed data. This way the `Repo.preload` could e.g. > additionally support custom enumerable and collectable collections as first > argument like e.g. `%Scrivener.Page{}`. > > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/19c24b83-fc2a-4af3-950e-eba7f767db14%40googlegroups.com > <https://groups.google.com/d/msgid/elixir-lang-core/19c24b83-fc2a-4af3-950e-eba7f767db14%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4JOTSk-sJ2fitUhOxkRLq4H9WR-Tm%2By_K%3D_jBFf8WdcMg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
