<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="270945" data-post-id="270945">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="hst337" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  hst337
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>My compiler analyzes the body of <code>fn</code> and checks if it can call any impure function. Right now, this analyzer is primitive, because I lack graph coloring algorithm (or tree coloring, to be precise).</p>
<p>This kind of optimization removes vanilla hot-swap, but other hot-swaps will still be possible, I just need infrastructure for this.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="270945" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/enum-fusion/36193/42">Post #41</a>
	                </div>
	            </div>
              <div id="likers-container-270945" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="270945"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #41"></div>
  </section>
</div>
    <div class="postbit" id="272790" data-post-id="272790">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sabiwara" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sabiwara/120/18612_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sabiwara
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Elixir Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hi all!</p>
<p>It’s been a while since I shared <code>Enumancer</code> as an early proof of concept of “Enum fusion”, and I’ve been thinking about this topic since, especially regarding how to make it practical to use.</p>
<p>I am glad to announce the release of a new library, <code>Iter</code>, which should be closer to the original idea described in this thread. I hope it can offer a compelling, fast and easy-to-use alternative to the <code>Enum</code> and <code>Stream</code> modules.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex&gt; 1..5 |&gt; Iter.filter(&amp; rem(&amp;1, 2) == 1) |&gt; Iter.map(&amp; &amp;1 ** 2) |&gt; Iter.reverse()
[25, 9, 1]
</code></pre>
<p>Unlike the same pipeline written with <code>Enum</code>, it won’t build any intermediate list, therefore saving memory and CPU cycles.</p>
<p>You can think of <code>Iter</code> as compile-time streams, or as comprehensions on steroids. It should be highly efficient compared to the same pipeline written with <code>Stream</code>, since it does most of the work at compile time without any runtime overhead. And while it actually works very similarly to <code>for/1</code> under the hood and basically emits the same code, it offers a much more flexible, composable and extensive API.</p>
<p><a href="https://github.com/sabiwara/iter" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/sabiwara/iter</a></p>
<p>As previously pointed out by Jose, there is one limitation: breaking the pipeline will remove the opportunity for <code>Iter</code> to merge steps, in which case the performance will simply be the same as good old <code>Enum</code>. This seems like a reasonable trade-off though.</p>
<p>I’m looking forward to hearing your thoughts!</p>
<p>PS: even if you don’t plan to use <code>Iter</code>, you might still be interested in this <a href="https://hexdocs.pm/iter/enum.html" rel="noopener nofollow ugc"><code>Enum</code> cheatsheet</a> <img src="https://forum.elixirforum.com/images/emoji/apple/slightly_smiling_face.png?v=15" title=":slightly_smiling_face:" class="emoji" alt=":slightly_smiling_face:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="272790" data-batch-url="/posts/batch_likers">
                        8
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/enum-fusion/36193/43">Post #42</a>
	                </div>
	            </div>
              <div id="likers-container-272790" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="272790"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #42"></div>
  </section>
</div>
    <div class="postbit" id="274368" data-post-id="274368">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="hst337" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  hst337
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>If you’re interested, we can collaborate on enum optimizations in optimizing compiler I am writing.</p>
<p>Some optimizations are just not possible with regular approach and they require proper call stack analysis for purity and safeness of some calls. For example,</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">list
|&gt; Enum.map(f1)
|&gt; Enum.map(f2)
</code></pre>
<p>Can be joined into one <code>Enum.map</code> only when <code>f1</code> is pure.</p>
<p>Plus some <code>Stream</code> calls can be translated to <code>Enum</code> calls, and <code>Enum</code> calls can be translated to <code>:lists</code> calls, which can then be inlined.</p>
<p>PM me if you’re interested</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="274368" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/enum-fusion/36193/44">Post #43</a>
	                </div>
	            </div>
              <div id="likers-container-274368" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="274368"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>