<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="301420" data-post-id="301420">
  <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">
								<aside class="quote no-group" data-username="D4no0" data-post="1" 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/d4no0/48/33624_2.png" class="avatar"> D4no0:</div>
<blockquote>
<p><strong>full static type inferrence on set theoretic types is very expensive</strong></p>
</blockquote>
</aside>
<p>This means that each function and each variable will have a type assigned. And this type might be a complex expression, like <code>or</code> consisting of N clauses. To check that a type inferred from function body is a subtype of a type specified in the type spec of a function, compiler must compare these two expressions which is a turing-complete operation and can (and will) consume a lot of time.</p>
<p>Therefore compilers use different approaches like speculative complexity reduction (for example in dialyzer type expression <code>@type enum() :: :x1 | :x2 | :x3 | :x4 | :x5 | :x6</code> is reduced to <code>@type enum() :: atom()</code>).</p>
<p>And in my honest opinion, this type precision aim taken by type system team will create a lot of complex types, and type-checking would either consume a lot of time or will make developers handle situations which are not going to happen, caused by complexity-reduction approach. This is the problem caused by “paper first” approach taken, where theoretical ideas were developed before the actual implementation.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="301420" 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/32">Post #31</a>
	                </div>
	            </div>
              <div id="likers-container-301420" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="301420"
                     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 #31"></div>
  </section>
</div>
    <div class="postbit" id="301421" data-post-id="301421">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="D4no0" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/D4no0/120/33624_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  D4no0
                    <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="hst337" data-post="32" 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/h/41988e/48.png" class="avatar"> hst337:</div>
<blockquote>
<p>Therefore compilers use different approaches like speculative complexity reduction (for example in dialyzer type expression <code>@type enum() :: :x1 | :x2 | :x3 | :x4 | :x5 | :x6</code> is reduced to <code>@type enum() :: atom()</code>).</p>
</blockquote>
</aside>
<p>This optimization is sacrificing the precision a lot, moreover I am not sure that is what happens actually, because if that were the case this kind of syntax is just misleading and causes more harm than good.</p>
<aside class="quote no-group" data-username="hst337" data-post="32" 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/h/41988e/48.png" class="avatar"> hst337:</div>
<blockquote>
<p>And in my honest opinion, this type precision aim taken by type system team will create a lot of complex types, and type-checking would either consume a lot of time or will make developers handle situations which are not going to happen, caused by complexity-reduction approach.</p>
</blockquote>
</aside>
<p>I think the approach with the paper is correct, the aim of the paper is not to prove that this can be <strong>implemented efficiently</strong>, however it proves <strong>that it is possible</strong>, a preliminary step that proves mathematically that the idea makes sense, as this seems a topic that is both very complex and doesn’t have a lot of practical information in the wild.</p>
<p>This approach also works in full favor of the developer, just by saying “we want this experience for our developers” and not by going from a performant implementation backwards. I think in the development world there two opposing philosophies:</p>
<ol>
<li>Make the language highly optimized, by introducing a lot of syntactic complexity. People seem to praise languages like Rust a lot these days, however in the field that I work, mainly development of applications for businesses and end-users, this language offers some tradeoffs I am not interested in, the development time and complexity is much more important to me than that performance gain.</li>
<li>Tailor the language to be developer friendly, witch seems the direction that elixir and erlang took, a simple example would be how constrained is the message passing between processes and mailboxes, that makes them easy to reason about in more complex applications for humans, but there is a clear performance penalty.</li>
</ol> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="301421" data-batch-url="/posts/batch_likers">
                        3
                      </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/33">Post #32</a>
	                </div>
	            </div>
              <div id="likers-container-301421" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="301421"
                     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 #32"></div>
  </section>
</div>
    <div class="postbit" id="301424" data-post-id="301424">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a class="mention" href="/u/josevalim" rel="nofollow">@josevalim</a> In the talk you present options 1, 2 and 3, and then explain what strong arrows are, but that Elixir will fallback to one of the options when it can’t work. But you don’t tell which one. Is it still undecided ?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="301424" 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/34">Post #33</a>
	                </div>
	            </div>
              <div id="likers-container-301424" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="301424"
                     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 #33"></div>
  </section>
</div>
    <div class="postbit" id="301429" data-post-id="301429">
  <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">
								<aside class="quote no-group" data-username="D4no0" data-post="33" 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/d4no0/48/33624_2.png" class="avatar"> D4no0:</div>
<blockquote>
<p>This optimization is sacrificing the precision a lot, moreover I am not sure that is what happens actually, because if that were the case this kind of syntax is just misleading and causes more harm than good.</p>
</blockquote>
</aside>
<p>This is unfortunately <a href="https://stackoverflow.com/questions/73381151/dialyzer-simplifies-long-union-types" rel="noopener nofollow ugc">how dialyzer currently works</a> with union types, although the actual limit seems to be 14 and not 6.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="301429" data-batch-url="/posts/batch_likers">
                        3
                      </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/35">Post #34</a>
	                </div>
	            </div>
              <div id="likers-container-301429" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="301429"
                     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 #34"></div>
  </section>
</div>
    <div class="postbit" id="301430" data-post-id="301430">
  <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>Seems like a memory efficient <a href="https://en.wikipedia.org/wiki/Bloom_filter" rel="noopener nofollow ugc">bloom filter</a> would be a better approach to union and intersection of sets than a complete generalization.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="301430" 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/36">Post #35</a>
	                </div>
	            </div>
              <div id="likers-container-301430" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="301430"
                     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 #35"></div>
  </section>
</div>
    <div class="postbit" id="301432" data-post-id="301432">
  <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="D4no0" data-post="31" 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/d4no0/48/33624_2.png" class="avatar"> D4no0:</div>
<blockquote>
<p>I am wondering, will you still be able to run applications that would yield type errors or it will throw a compilation error?</p>
</blockquote>
</aside>
<p>Type errors will initially be emitted as warnings (and potentially for quite some time).</p>
<aside class="quote no-group" data-username="hst337" data-post="32" 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/h/41988e/48.png" class="avatar"> hst337:</div>
<blockquote>
<p>This is the problem caused by “paper first” approach taken, where theoretical ideas were developed before the actual implementation.</p>
</blockquote>
</aside>
<p>There is an implementation of set-theoretic types in the CDuce programming language, which already employs many optimization techniques we can lift from (<a href="https://www.irif.fr/~gc/papers/covcon-again.pdf" rel="nofollow">some discussed in this paper</a>). Given we took a “paper first” approach, I recommend reading the existing literature if you want to speculate on the implementation details. The literature exists precisely so we don’t have to rely solely on opinions.</p>
<p>I also don’t rule out the possibility of implementing the data types of the type system in a native programming language, such as Rust. Again, it is not my first option, I would prefer Elixir, but the type system is powered by different types of sets which define union/intersection/negation, which we could implement in a native language with the ultimate goal of performance. The traversal of AST and the application of the typing rules would still be done in Elixir.</p>
<p>In any case, it is either we do the paper-first, and then later find out it is too complex to implement, or we do implementation-first, and then find out the implementation is incorrect. If it fails, both end-up in the same place: we don’t have a type system up to our requirements. I already tried the implementation first approach back in 2018 and I know exactly where it ends: with you wondering if what you are doing is, by any chance, correct.</p>
<aside class="quote no-group" data-username="lud" data-post="34" data-topic="58307" 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/lud/48/14382_2.png" class="avatar"> lud:</div>
<blockquote>
<p><a class="mention" href="/u/josevalim" rel="nofollow">@josevalim</a> In the talk you present options 1, 2 and 3, and then explain what strong arrows are, but that Elixir will fallback to one of the options when it can’t work. But you don’t tell which one. Is it still undecided ?</p>
</blockquote>
</aside>
<p>Excellent question, I was waiting for someone to ask it. <img src="https://forum.elixirforum.com/images/emoji/apple/smiley.png?v=15" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20"> We will start with option 1: we will fallback to dynamic. However, I can see us also doing option 3 in the future, if we can measure places where introducing the runtime checks will not decrease or will potentially improve performance.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="301432" data-batch-url="/posts/batch_likers">
                        10
                      </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/37">Post #36</a>
	                </div>
	            </div>
              <div id="likers-container-301432" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="301432"
                     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 #36"></div>
  </section>
</div>
    <div class="postbit" id="301441" data-post-id="301441">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks! I guess it has been suggested already but that would be cool if the compiler could emit a notice in such cases and suggest guards to add.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="301441" 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/38">Post #37</a>
	                </div>
	            </div>
              <div id="likers-container-301441" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="301441"
                     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 #37"></div>
  </section>
</div>
    <div class="postbit" id="301459" data-post-id="301459">
  <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 criticism is based on experience of existing implementations of type systems. Gradualizer, dialyzer and eqwalizer didn’t suffer from inexpressive type system (IMO they were expressive enough), but they’ve suffered from complexity of type inference and subtype checks. Dialyzer and gradualizer reduce complexity and eqwalizer is just slow (though it is written in Scala, not in Elixir). And original paper of typing in Elixir states nothing about optimizations of type checking. Approaches suggested in <a href="https://www.irif.fr/~gc/papers/covcon-again.pdf" rel="noopener nofollow ugc">the paper</a> work only in certain cases.</p>
<p>Generally speaking existing type-checkers have suffered from a problems caused by complexity explosion. For example, this code <code>Enum.random(for x &lt;- 1..n, y &lt;- 1..n, when x != y, do: {x, y})</code> will have a <code>n * n - n</code> values with naive type inference. And I don’t see how this can be expressed in set-theoretic type system without enumerating all available values. Complexity reduction to <code>{x :: 1..n, y :: 1..n}</code> will create a false positive in <code>1 / (x - y)</code>. Dialyzer took a “no false-positive” approach, so this won’t be raised as a type error.</p>
<p>And this “no false-negative” approach is a problem leading to community split, where some people will refuse to use working dynamic code with false-positives, and some people won’t use statically typed code with unnecessary runtime checks.</p>
<p>If I were to take the paper-first approach, I would address problems related to the performance of type-checker and complexity of algorithms first, and only once they’re solved, I would incrementally add features to the expressiveness of the type system. Especially, since this type-system takes the “no false-negative” approach</p>
<p>Anyway, I would like to participate in the development of the type system, but I have absolutely no free time. But I will definitely read the code of the type system development branch (if there will be one)</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="301459" 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/39">Post #38</a>
	                </div>
	            </div>
              <div id="likers-container-301459" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="301459"
                     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 #38"></div>
  </section>
</div>
    <div class="postbit" id="301462" data-post-id="301462">
  <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 quote-modified" data-username="hst337" data-post="39" 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/h/41988e/48.png" class="avatar"> hst337:</div>
<blockquote>
<p>My criticism is based on experience of existing implementations of type systems. Gradualizer, dialyzer and eqwalizer […]</p>
</blockquote>
</aside>
<p>Sure, and by mentioning CDuce and the paper, I hope they can now be used as additional examples to expand your experience. There are also many smaller trade-offs each of those implementations make that directly impact performance (inference vs non-inference, local vs global analysis, etc).</p>
<aside class="quote no-group" data-username="hst337" data-post="39" 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/h/41988e/48.png" class="avatar"> hst337:</div>
<blockquote>
<p>Approaches suggested in <a href="https://www.irif.fr/~gc/papers/covcon-again.pdf" rel="nofollow">the paper</a> work only in certain cases.</p>
</blockquote>
</aside>
<p>Which cases? Can you please elaborate? Because the paper is about set-theoretic types and implementation of set-theoretic types, so I would be surprised if the suggestions listed there do not apply to the set-theoretic type system we are implementing.</p>
<aside class="quote no-group" data-username="hst337" data-post="39" 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/h/41988e/48.png" class="avatar"> hst337:</div>
<blockquote>
<p>For example, this code <code>Enum.random(for x &lt;- 1..n, y &lt;- 1..n, when x != y, do: {x, y})</code> will have a <code>n * n - n</code> values with naive type inference.</p>
</blockquote>
</aside>
<p>Correct, but it is yet not decided that integers will be singleton values in our type system. Dialyzer chose singletons because it aligns with their trade-offs but it is unclear if this choice would be beneficial to us (for both performance and false positive reasons). We may choose between <code>integer()</code>, <code>pos_integer() or zero() or neg_integer()</code>, or each integer as a type.</p>
<p>My point is: sure, the type system can still be slow at the end, but extrapolating from X, Y, and Z, to draw conclusions is still just a guess. So let’s be aware of pitfalls, do the work, and then make decisions.</p>
<aside class="quote no-group" data-username="hst337" data-post="39" 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/h/41988e/48.png" class="avatar"> hst337:</div>
<blockquote>
<p>If I were to take the paper-first approach, I would address problems related to the performance of type-checker and complexity of algorithms first, and only once they’re solved, I would incrementally add features to the expressiveness of the type system. Especially, since this type-system takes the “no false-negative” approach</p>
</blockquote>
</aside>
<p>Again, there is no point in trying to optimizing something if we are not sure it is going to fully suit the language. I understand if you’d prefer that, but it is not my preference.</p>
<p>In any case, you are more than welcome to try a different direction! I’m looking forward to insights you might have and challenges that may arise when implementing the existing algorithms and optimizations on the Erlang VM. <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="301462" 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/full-static-type-inference-of-set-theoretic-types/58307/40">Post #39</a>
	                </div>
	            </div>
              <div id="likers-container-301462" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="301462"
                     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 #39"></div>
  </section>
</div>
    <div class="postbit" id="301466" data-post-id="301466">
  <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">
								<aside class="quote group-livebook_core_team" data-username="josevalim" data-post="40" 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>Correct, but it is yet not decided that integers will be singleton values in our type system</p>
</blockquote>
</aside>
<p>I’ve expected this response. You can translate this example to <code>Enum.random(for x &lt;- 1..n, y &lt;- 1..n, when x != y, do: {Tuple.duplicate(nil, x), Tuple.duplicate(nil, y)})</code>. And the false positive to <code>1 / (tuple_size(x) - tuple_size(y))</code></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="301466" 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/41">Post #40</a>
	                </div>
	            </div>
              <div id="likers-container-301466" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="301466"
                     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 #40"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/58307/load_more?page=5">Load more posts (17 remaining)</a>
</div></template></turbo-stream>