Thank you for the swift response and great tip!
I have opened a PR to add this to the documentation: 
https://github.com/elixir-lang/elixir/pull/11224

~Marten/Qqwy

On Saturday, September 4, 2021 at 6:54:21 PM UTC+2 José Valim wrote:

> Zip uses suspension, so zipping it with any other enumerable will help 
> test those scenarios. Use Stream.zip + Enum.take to test the combination of 
> both suspension + halt.
>
> Improvements to the enumerable docs are welcome. :)
>
> On Sat, Sep 4, 2021 at 6:47 PM w...@resilia.nl <w...@resilia.nl> wrote:
>
>>
>> Hi all!
>>
>> I was recently building a datastructure 
>> <https://github.com/Qqwy/elixir-arrays> for which I wanted to implement 
>> Enumerable.
>> The basic implementation is very straightforward, because of the very 
>> helpful documentation in the `Enum` and `Enumerable` modules. Chapeau 😊!
>>
>> I then used a code coverage tool to try to make sure that all edge cases 
>> were exercised by the testing suite. And this is where I found out that 
>> triggering one part of the `Enumerable.reduce`-interface is rather hard, as 
>> there is nearly no information to find out how to thoroughly write/test it: 
>> The usage of `:suspend`/`:suspended`.
>>
>> I think it is a very nice feature to be able to work with continuations 
>> when dealing with enumerables. However, currently neither the Elixir 
>> standard library, nor (to my knowledge) any libraries on Hex.PM out there 
>> make use of it.
>> The resources I was able to find are:
>> - The blog post introducing suspensions 
>> <https://elixir-lang.org/blog/2013/12/11/elixir-s-new-continuable-enumerators/>,
>>  
>> with `interleave` as single example. (2013)
>> - A bug report <https://github.com/elixir-lang/elixir/issues/3751> of 
>> the suspension system, with one example that was then added as a regression 
>> test. (2015)
>> - The Elixir core has many places 
>> <https://github.com/elixir-lang/elixir/search?q=suspend> where 
>> `:suspend`/ `:suspended` are used, but to my knowledge only ever to handle 
>> a function that could return `:suspend` (never itself defining a function 
>> doing so).
>>
>> Neither the `interleave` example nor the `regression test` are examples 
>> that give much confidence that a particular Enumerable implementation now 
>> handles suspensions correctly.
>>
>> So my proposal would be to add some kind of small example definition to 
>> e.g. the documentation of `t Enumerable.result`.
>> Would this be a good idea? Or is another place better suited?
>> Also: Does anyone know of other resources/examples where suspensions are 
>> currently used?
>>
>> Thank you for your consideration,
>>
>> ~Marten/Qqwy
>>
>> -- 
>> 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 elixir-lang-co...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/elixir-lang-core/4e3e3f2f-09c8-4f13-9b5c-7a986d98b734n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/elixir-lang-core/4e3e3f2f-09c8-4f13-9b5c-7a986d98b734n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/b3a61b42-2439-48ff-89e1-15eed2882d7en%40googlegroups.com.

Reply via email to