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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="NobbZ" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/NobbZ/120/27235_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  NobbZ
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><code>nil</code>   <strong>is</strong>  just an atom, specialcased by the parser to be able to leave off the colon.</p>
<p>In my opinion having marker or value is deemed to fail anyway. What if is I want to insert exactly the value you use as marker?</p>
<p>Please use a tagged tuple or at least provide an API similar to <code>Map</code> get/fetch/fetch! to be able to differentiate when necessary.</p>
<p>Also when you say, it’s collectable and enumerable, in which direction? Is there a way to collect/enumerate in the opposite direction?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="176397" data-batch-url="/posts/batch_likers">
                        2
                      </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/yaq-an-enumerable-queue-for-elixir/31684/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-176397" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="176397"
                     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 #11"></div>
  </section>
</div>
    <div class="postbit" id="176414" data-post-id="176414">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Oh I haven’t noticed that Yaq is not a wrapper around :queue, that’s interesting. Speaking of efficiency, do you plan to do some benchmarks? Would be nice to see how it performs compared to :queue.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="176414" 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/yaq-an-enumerable-queue-for-elixir/31684/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-176414" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="176414"
                     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 #12"></div>
  </section>
</div>
    <div class="postbit" id="176453" data-post-id="176453">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="NullOranje" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/NullOranje/120/16471_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  NullOranje
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="NobbZ" data-post="12" data-topic="31684" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nobbz/48/27235_2.png" class="avatar"> NobbZ:</div>
<blockquote>
<p><code>nil</code>   <strong>is</strong>  just an atom, specialcased by the parser to be able to leave off the colon.</p>
<p>In my opinion having marker or value is deemed to fail anyway. What if is I want to insert exactly the value you use as marker?</p>
<p>Please use a tagged tuple or at least provide an API similar to <code>Map</code> get/fetch/fetch! to be able to differentiate when necessary.</p>
</blockquote>
</aside>
<p>I’ve had this same though about using atoms as markers.  It’s a pretty common pattern in Erlang/OTP from what I can see, but the scenario you describe seems likely, especially when using common atoms like <code>:ok</code> (or <code>nil</code>).</p>
<p>I liked your suggestion about following the get/fetch/fetch! paradigm in Map and elsewhere, so I added a couple functions to the API:</p>
<ul>
<li><code>fetch/1</code> and <code>fetch_r/1</code> will return the tuple <code>{value, updated_queue}</code> if there are elements on the front or back of the queue, respectively, or <code>:error</code> otherwise</li>
<li><code>fetch!/1</code> and <code>fetch_r!/1</code> will return the tuple <code>{value, updated_queue}</code> if there are elements on the front or back of the queue, respectively, or raise <code>Yaq.EmptyQueueError</code> otherwise</li>
</ul>
<p>I also added a default value specification for <code>dequeue/2</code> and <code>dequeue_r/2</code> to follow the pattern from get.</p>
<aside class="quote no-group">
<blockquote>
<p>Also when you say, it’s collectable and enumerable, in which direction? Is there a way to collect/enumerate in the opposite direction?</p>
</blockquote>
</aside>
<p>You can only enumerate and collect from front to back, but you can reverse the queue in constant time with <code>Yak.reverse/1</code>, so I think it is a fair compromise.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="176453" data-batch-url="/posts/batch_likers">
                        2
                      </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/yaq-an-enumerable-queue-for-elixir/31684/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-176453" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="176453"
                     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>