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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="adw632" data-post="50" data-topic="58307">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/9d8465/48.png" class="avatar"> adw632:</div>
<blockquote>
<p>Has there been any thought on how annotations and guards can replace one OR the other? (i.e. NOT both)</p>
</blockquote>
</aside>
<p>This is not an immediate goal but we may add some guards based on types in the future.</p>
<aside class="quote no-group" data-username="adw632" data-post="50" data-topic="58307">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/9d8465/48.png" class="avatar"> adw632:</div>
<blockquote>
<p><code>def identity(arg) returning number() when is_number(arg), do: arg</code></p>
</blockquote>
</aside>
<p>This doesn’t work because types are more expressive than guards. So associating the two will generate impedance because you will either have weak types (limited to guards semantics) or you will have fake guards (which says something is a list of structs but it is incapable of checking if they are indeed the same).</p>
<p>Also, I think the duplication is obvious (and annoying) only on extremely short functions as above. In the majority of functions, I doubt they would feel redundant. It is too early and we have too few examples to start optimizing for “duplication”.</p>
<p>Furthermore, Elixir already allows pattern matching, guards, and default arguments in function signatures. Adding more complexity to it is the wrong way to go imo. <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" 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="302176" 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/full-static-type-inference-of-set-theoretic-types/58307/52">Post #51</a>
	                </div>
	            </div>
              <div id="likers-container-302176" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="302176"
                     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 #51"></div>
  </section>
</div>
    <div class="postbit" id="302181" data-post-id="302181">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks Jose.</p>
<aside class="quote group-livebook_core_team" data-username="josevalim" data-post="52" data-topic="58307">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/josevalim/48/1787_2.png" class="avatar"> josevalim:</div>
<blockquote>
<p>So associating the two will generate impedance because you will either have weak types (limited to guards semantics) or you will have fake guards (which says something is a list of structs but it is incapable of checking if they are indeed the same).</p>
</blockquote>
</aside>
<p>So does this mean that the compiler may at some point consider the pattern matching clauses as the domain of the type? i.e. not just the base language types but constrained to the value domain of the pattern matching clauses as well?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="302181" data-batch-url="/posts/batch_likers">
                        0
                      </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/full-static-type-inference-of-set-theoretic-types/58307/53">Post #52</a>
	                </div>
	            </div>
              <div id="likers-container-302181" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="302181"
                     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 #52"></div>
  </section>
</div>
    <div class="postbit" id="302189" data-post-id="302189">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>That sounds bit like Typed Strings in Bosque programming language where strings are typed with Regex.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="302189" data-batch-url="/posts/batch_likers">
                        0
                      </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/full-static-type-inference-of-set-theoretic-types/58307/54">Post #53</a>
	                </div>
	            </div>
              <div id="likers-container-302189" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="302189"
                     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 #53"></div>
  </section>
</div>
    <div class="postbit" id="302194" data-post-id="302194">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="adw632" data-post="53" data-topic="58307">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/9d8465/48.png" class="avatar"> adw632:</div>
<blockquote>
<p>So does this mean that the compiler may at some point consider the pattern matching clauses as the domain of the type?</p>
</blockquote>
</aside>
<p>This is something the type system supports already but it is yet to be decided if we will add it to Elixir. We can allow 0, 1, 2, etc as types, but doing so means we often have to “prove” more to the type system and that may also make it slower. It is something we can explore further down the road.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="302194" 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/full-static-type-inference-of-set-theoretic-types/58307/55">Post #54</a>
	                </div>
	            </div>
              <div id="likers-container-302194" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="302194"
                     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 #54"></div>
  </section>
</div>
    <div class="postbit" id="302282" data-post-id="302282">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I was wondering about this too - would you explore e.g. with guards such as</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">when is_integer(x) and x &gt; 10
</code></pre>
<p>the compiler inferring the set of “all integers above 10” (rather than just <code>integer()</code>)?<br>
I imagine it could be hard to make performant but would be pretty amazing if it worked.</p>
<p>Also (on a slightly unrelated note) out of interest why do all the types have parentheses?<br>
I keep thinking</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">$  (integer -&gt; integer) and (boolean -&gt; boolean)
</code></pre>
<p>would feel a lot cleaner to me than</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">$  (integer() -&gt; integer()) and (boolean() -&gt; boolean())
</code></pre>
<p>and even more so when the signature gets more complex</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="302282" data-batch-url="/posts/batch_likers">
                        5
                      </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/full-static-type-inference-of-set-theoretic-types/58307/56">Post #55</a>
	                </div>
	            </div>
              <div id="likers-container-302282" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="302282"
                     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 #55"></div>
  </section>
</div>
    <div class="postbit" id="316044" data-post-id="316044">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote group-livebook_core_team" data-username="josevalim" data-post="55" data-topic="58307">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/josevalim/48/1787_2.png" class="avatar"> josevalim:</div>
<blockquote>
<p>This is something the type system supports already but it is yet to be decided if we will add it to Elixir.</p>
</blockquote>
</aside>
<p>Hello Jose, getting back to what you wrote, couple of months ago.</p>
<ul>
<li>I am curious if situation somehow evolved, clarified; how do you see it today, are you still considering it for inclusion into Elixir?</li>
<li>Just to make sure I got it right: is it about <a href="https://en.wikipedia.org/wiki/Dependent_type" rel="noopener nofollow ugc">dependent types</a>?</li>
</ul>
<p>Thanks!<br>
Filip</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="316044" data-batch-url="/posts/batch_likers">
                        0
                      </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/full-static-type-inference-of-set-theoretic-types/58307/57">Post #56</a>
	                </div>
	            </div>
              <div id="likers-container-316044" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="316044"
                     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 #56"></div>
  </section>
</div>
    <div class="postbit" id="316054" data-post-id="316054">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="fmn" data-post="57" data-topic="58307">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fmn/48/26825_2.png" class="avatar"> fmn:</div>
<blockquote>
<p>I am curious if situation somehow evolved, clarified; how do you see it today, are you still considering it for inclusion into Elixir?</p>
</blockquote>
</aside>
<p>We are only going to know for sure once the type system is in place and already running in user code. In other words, it is a matter of a year or two, and not months.</p>
<aside class="quote no-group" data-username="fmn" data-post="57" data-topic="58307">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fmn/48/26825_2.png" class="avatar"> fmn:</div>
<blockquote>
<p>Just to make sure I got it right: is it about <a href="https://en.wikipedia.org/wiki/Dependent_type" rel="nofollow">dependent types </a>?</p>
</blockquote>
</aside>
<p>No, it is about singleton types. I had the same confusion though. Singleton types are types that represent a single value, like 42, while dependent types are types that depend on values, for example, you can have the dependent type LengthList, where for every integer n, LengthList n is the type of lists of size n.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="316054" data-batch-url="/posts/batch_likers">
                        4
                      </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/full-static-type-inference-of-set-theoretic-types/58307/58">Post #57</a>
	                </div>
	            </div>
              <div id="likers-container-316054" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="316054"
                     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>