<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="293483" data-post-id="293483">
  <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>I have read a lot of text about function type definitions, though what I am missing here is, will there be a way to deal with variable types?</p>
<p>I like to have variables in my functions, that collect the result of the type and I want to be able to “declare” them a <code>Conn.t()</code> or <code>pos_interger()</code> early, rather than relying on a type error when I pass it to the next function.</p>
<p>This is especially helpful if you have many intermediate results.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir"># imaginary syntax, the final result, if at all, will probably not be "inline"
seven $ int = 5 + 2.0

six = dec(seven)
</code></pre>
<p>This code should show me an error at assigning <code>seven</code>, not when calling <code>dec/1</code>.</p>
<hr>
<p>Also, is there a branch/PR/issue we can track on GitHub for progress or playing around?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="293483" 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/type-system-updates-moving-from-research-into-development/56827/66">Post #65</a>
	                </div>
	            </div>
              <div id="likers-container-293483" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="293483"
                     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 #65"></div>
  </section>
</div>
    <div class="postbit" id="293484" data-post-id="293484">
  <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
                    <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 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="zacky1972" data-post="64" data-topic="56827">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zacky1972/48/8278_2.png" class="avatar"> zacky1972:</div>
<blockquote>
<p>Please let me translate this article into Japanese.</p>
</blockquote>
</aside>
<p>Please go ahead. <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="293484" 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/type-system-updates-moving-from-research-into-development/56827/67">Post #66</a>
	                </div>
	            </div>
              <div id="likers-container-293484" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="293484"
                     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 #66"></div>
  </section>
</div>
    <div class="postbit" id="293485" data-post-id="293485">
  <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
                    <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 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="NobbZ" data-post="66" data-topic="56827">
<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>I have read a lot of text about function type definitions, though what I am missing here is, will there be a way to deal with variable types?</p>
</blockquote>
</aside>
<p>There are no plans to do so at the moment, although we will eventually discuss how to assert types for intermediate values.</p>
<aside class="quote no-group" data-username="NobbZ" data-post="66" data-topic="56827">
<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>Also, is there a branch/PR/issue we can track on GitHub for progress or playing around?</p>
</blockquote>
</aside>
<p>Not at the moment. This will become clearer ahead as well. As per the blog post, development has just begun and we want to get the foundation in place before putting it under the spotlight. <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"> Also note that there won’t be any changes to the language (so no user facing changes) for a good chunk of time.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="293485" 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/type-system-updates-moving-from-research-into-development/56827/68">Post #67</a>
	                </div>
	            </div>
              <div id="likers-container-293485" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="293485"
                     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 #67"></div>
  </section>
</div>
    <div class="postbit" id="293492" data-post-id="293492">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’ve done. Thanks!</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://qiita.com/zacky1972/items/33fd39ef2a1dcdbb8b73">
  <header class="source">
      <img src="https://cdn.qiita.com/assets/favicons/public/production-c620d3e403342b1022967ba5e3db1aaa.ico" class="site-icon" alt="" width="120" height="120">

      <a href="https://qiita.com/zacky1972/items/33fd39ef2a1dcdbb8b73" target="_blank" rel="noopener nofollow ugc">Qiita</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/362;"><img src="https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-user-contents.imgix.net%2Fhttps%253A%252F%252Fcdn.qiita.com%252Fassets%252Fpublic%252Farticle-ogp-background-afbab5eb44e0b055cce1258705637a91.png%3Fixlib%3Drb-4.1.1%26w%3D1200%26blend64%3DaHR0cHM6Ly9xaWl0YS11c2VyLXByb2ZpbGUtaW1hZ2VzLmltZ2l4Lm5ldC9odHRwcyUzQSUyRiUyRnFpaXRhLWltYWdlLXN0b3JlLnMzLmFwLW5vcnRoZWFzdC0xLmFtYXpvbmF3cy5jb20lMkYwJTJGNTUyMjMlMkZwcm9maWxlLWltYWdlcyUyRjE3MTczNjg2MTY_aXhsaWI9cmItNC4xLjEmYXI9MSUzQTEmZml0PWNyb3AmbWFzaz1lbGxpcHNlJmJnPUZGRkZGRiZmbT1wbmczMiZzPTUzZWViM2E1MjRlNTVjYjU3MWU1NmFkMDczNjVjNzMz%26blend-x%3D120%26blend-y%3D462%26blend-w%3D90%26blend-h%3D90%26blend-mode%3Dnormal%26mark64%3DaHR0cHM6Ly9xaWl0YS1vcmdhbml6YXRpb24taW1hZ2VzLmltZ2l4Lm5ldC9odHRwcyUzQSUyRiUyRnMzLWFwLW5vcnRoZWFzdC0xLmFtYXpvbmF3cy5jb20lMkZxaWl0YS1vcmdhbml6YXRpb24taW1hZ2UlMkY4ODk3Mzg1MDU4ZDRkM2Q3MjNiMmVkYTQ5YzFlMGI3ODRmMDdmNmNiJTJGb3JpZ2luYWwuanBnJTNGMTUzMjY1Mjg3Mj9peGxpYj1yYi00LjEuMSZ3PTQ0Jmg9NDQmZml0PWNyb3AmbWFzaz1jb3JuZXJzJmNvcm5lci1yYWRpdXM9OCZiZz1GRkZGRkYmYm9yZGVyPTIlMkNGRkZGRkYmZm09cG5nMzImcz04MDhkZTViZTU5MjliNzY4ZmY3ZDQ5NGU0N2QzN2RjOA%26mark-x%3D186%26mark-y%3D515%26mark-w%3D40%26mark-h%3D40%26s%3Df8d3d1e33fcb3c3269b2479b1a13ff85?ixlib=rb-4.1.1&amp;w=1200&amp;fm=jpg&amp;mark64=aHR0cHM6Ly9xaWl0YS11c2VyLWNvbnRlbnRzLmltZ2l4Lm5ldC9-dGV4dD9peGxpYj1yYi00LjEuMSZ3PTk2MCZoPTMyNCZ0eHQ9JUU1JTlFJThCJUUzJTgyJUI3JUUzJTgyJUI5JUUzJTgzJTg2JUUzJTgzJUEwJUUzJTgxJUFFJUUzJTgyJUEyJUUzJTgzJTgzJUUzJTgzJTk3JUUzJTgzJTg3JUUzJTgzJUJDJUUzJTgzJTg4JTNBJTIwJUU3JUEwJTk0JUU3JUE5JUI2JUUzJTgxJThCJUUzJTgyJTg5JUU5JTk2JThCJUU3JTk5JUJBJUUzJTgxJUI4JUUzJTgxJUFFJUU3JUE3JUJCJUU4JUExJThDJTIwYnklMjBKb3MlQzMlQTklMjBWYWxpbSZ0eHQtYWxpZ249bGVmdCUyQ3RvcCZ0eHQtY29sb3I9JTIzMUUyMTIxJnR4dC1mb250PUhpcmFnaW5vJTIwU2FucyUyMFc2JnR4dC1zaXplPTU2JnR4dC1wYWQ9MCZzPWE3ZDFjMzFmNTVmZTFlZDBmZDI2MzM4NGM1YmJhNmYw&amp;mark-x=120&amp;mark-y=112&amp;blend64=aHR0cHM6Ly9xaWl0YS11c2VyLWNvbnRlbnRzLmltZ2l4Lm5ldC9-dGV4dD9peGxpYj1yYi00LjEuMSZ3PTgzOCZoPTU4JnR4dD0lNDB6YWNreTE5NzImdHh0LWNvbG9yPSUyMzFFMjEyMSZ0eHQtZm9udD1IaXJhZ2lubyUyMFNhbnMlMjBXNiZ0eHQtc2l6ZT0zNiZ0eHQtcGFkPTAmcz0yZGVjNTM4ZmRiNjQwMTRiM2NmNjNiOTE2YzljNjM4Mg&amp;blend-x=242&amp;blend-y=454&amp;blend-w=838&amp;blend-h=46&amp;blend-fit=crop&amp;blend-crop=left%2Cbottom&amp;blend-mode=normal&amp;txt64=ZnVrdW9rYS5leO-8muemj-WyoUVsaXhpcuOCs-ODn-ODpQ&amp;txt-x=242&amp;txt-y=539&amp;txt-width=838&amp;txt-clip=end%2Cellipsis&amp;txt-color=%231E2121&amp;txt-font=Hiragino%20Sans%20W6&amp;txt-size=28&amp;s=fd393e28946545ebb4ca4c763f3c9846" class="thumbnail" alt="" width="690" height="362"></div>

<h3><a href="https://qiita.com/zacky1972/items/33fd39ef2a1dcdbb8b73" target="_blank" rel="noopener nofollow ugc">型システムのアップデート: 研究から開発への移行 by José Valim - Qiita</a></h3>

  <p>原文: https://elixir-lang.org/blog/2023/06/22/type-system-updates-research-dev/ 1年前のElixirConf EU 2022で，私たちはElixirの型システムを研究開発する取り組みを発表しました．...</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>
 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="293492" data-batch-url="/posts/batch_likers">
                        12
                      </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/type-system-updates-moving-from-research-into-development/56827/69">Post #68</a>
	                </div>
	            </div>
              <div id="likers-container-293492" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="293492"
                     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 #68"></div>
  </section>
</div>
    <div class="postbit" id="293501" data-post-id="293501">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>also tried to write imaginary syntax, as it would be great if…  <img src="https://forum.elixirforum.com/images/emoji/apple/blush.png?v=15" title=":blush:" class="emoji" alt=":blush:" loading="lazy" width="20" height="20"></p>
<pre data-code-wrap="Eixir"><code class="lang-Eixir"># check in compiletime
int_var1 ! MyIntegerType = do_something()

# check in runtime
# below variable int_var1 may be undefined
# if someone uses undefined variable it raises an error 'variable 'var' is undefined '
int_var1 ? MyIntegerType = do_something()

# check in runtime
if int_var1 ? MyIntegerType,
  do: square(int_var1),
  else: square(42)

# check in runtime
case var do
  var1 ? OperationResult -&gt;
  var2 ? Error -&gt;
end

# check in compiletime
case var do
  var1 ! OperationResult -&gt;
  var2 ! Error -&gt;
end

# compile time check of arg passed into square(..).
# square(..) may be from some libs we do not have access to
# this way we are checkin the type of arg of square(..) from "user side of view"
square(MyIntegerType ! int_var1)

# runtime of check, if it will be undefined it will not be called
square(MyIntegerType ? var)

# multiple types check
number ! MyIntegerType ! MyDoubleType = do_something()

# check the types in func definition
def foo(arg ! MyType1, {el1, el2 ! MyType2, arg}, %{key: value ! MyType3}) do
  ...
end

def foo(arg ! MyType1 | MyType2 | MyType3) do
  ...
end

deftype Age do
  basetype integer() do
    runtimetimecheck do
      valid? age do
        age &gt;= 0 and age &lt;= 200
      end
    end
  end
end

deftype Error do
  @result binary() | atom() | SomeType

  basetype Tuple.t do
    compiletimecheck do
      isof {:error, @result}
    end

    runtimetimecheck do
      valid? {:error, :system_error} ! arg do
        true
      end

      valid? {:error, reason ? binary} ! arg do
        reason in ["file_not_found"]
      end

      valid? {:error, arg ? SomeType} do
        not is_nil arg.reason
      end
    end
  end
end
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="293501" 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/type-system-updates-moving-from-research-into-development/56827/70">Post #69</a>
	                </div>
	            </div>
              <div id="likers-container-293501" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="293501"
                     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 #69"></div>
  </section>
</div>
    <div class="postbit" id="293614" data-post-id="293614">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<blockquote>
<p>We have <code>any()</code> and <code>term()</code> which should be more than enough as replacement for <code>dynamic()</code> .</p>
</blockquote>
<p>The typespec syntax might actually be extended with a builtin <code>dynamic()</code> type to support gradual typecheckers, so there might not even be a need to replace it with <code>any()</code> or <code>term()</code> anymore: <a href="https://www.erlang.org/eeps/eep-0061.html" class="inline-onebox" rel="nofollow">Eep 0061 - Erlang/OTP</a></p>
<p>The replacement path is the one Gradualizer / Gradient took, but it leads to some confusion, since both <code>any()</code> and <code>term()</code> are used in existing code, but have somewhat different semantics.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="293614" 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/type-system-updates-moving-from-research-into-development/56827/71">Post #70</a>
	                </div>
	            </div>
              <div id="likers-container-293614" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="293614"
                     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 #70"></div>
  </section>
</div>
    <div class="postbit" id="293635" data-post-id="293635">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>You can already play with exhaustive pattern matching in Elixir thanks to <a href="https://github.com/esl/gradient" rel="noopener nofollow ugc">Gradient</a>:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Allergen do

  @type t() :: :eggs
             | :chocolate
             | :pollen
             | :cats

  @spec score(t()) :: integer()
  def score(allergen) do
    case allergen do
      :eggs -&gt; 1
      :chocolate -&gt; 32
      :pollen -&gt; 64
    end
  end

end
</code></pre>
<p>The above code will lead to a typechecking error:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">$ ./gradient allergen.ex
Typechecking files...
allergen.ex: Nonexhaustive patterns on line 11
Example values which are not covered:
	:cats
Total errors: 1
</code></pre>
<p>One way to solve it is to add:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">    _ -&gt; raise "unexpected allergen"
</code></pre>
<p>but this moves the check to runtime. Another is to define a narrower type than the original <code>t()</code> which doesn’t list <code>:cats</code> as one of the alternatives. Set-theoretic types would even allow for <code>t() \ :cats</code> (i.e. <code>t()</code> without <code>:cats</code>), but the current typespec syntax doesn’t allow for that and Gradient strives to stick to it.</p>
<p>In principle, there’s nothing preventing a typechecker to raise a warning for a <code>case</code> expression like above, but silence it when we’re doing an intentional assignment, like:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">{:ok, contents} = File.read("...")
</code></pre>
<p>It’s a design decision - do we want to trade type safety for expressiveness?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="293635" 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/type-system-updates-moving-from-research-into-development/56827/72">Post #71</a>
	                </div>
	            </div>
              <div id="likers-container-293635" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="293635"
                     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 #71"></div>
  </section>
</div>
    <div class="postbit" id="293650" data-post-id="293650">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="dimitarvp" data-post="50" data-topic="56827">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/48/38664_2.png" class="avatar"> dimitarvp:</div>
<blockquote>
<p>Well, I still think <code>case!</code> can be replaced with a compiler switch or <code>mix</code> config option.</p>
</blockquote>
</aside>
<p>What about rather than having a clause-level opt-in with <code>case!</code> or an application-level opt-in with <code>mix</code> configs, there were module level opt-ins with something like <code>defmodule!</code> that at least initially would mean any external module importing from a <code>module!</code> would have to also be a <code>module!</code>? If you need to allow integration with legacy code, you can add a plain module within the same library/application that provides the public API to the <code>module!</code>. I kind of like that over having to remember <code>case/case!</code> in each invocation.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="293650" 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/type-system-updates-moving-from-research-into-development/56827/73">Post #72</a>
	                </div>
	            </div>
              <div id="likers-container-293650" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="293650"
                     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 #72"></div>
  </section>
</div>
    <div class="postbit" id="293668" data-post-id="293668">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>The problem here is that both exhaustive and non-exhaustive matching are useful and people will want to use both not just in the same project, but even within the same module.</p>
<p>I quite like the <code>case</code> and <code>case!</code> idea, with the exception that, as stated above, their behaviour would have to be the opposite of what people would expect based on the rest of the language.</p>
<p>I’m not sure how to deal with matching in function heads, though. <code>def</code> and <code>def!</code> seem like the obvious choice, but I really think the exhaustive/non-exhaustive decision should be made at the call site, not in the function definition.</p>
<p>This ties in back to Jose’s earlier example:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def foo_or_bar(:foo), do: ...
def foo_or_bar(:bar), do: ...
</code></pre>
<p>Most of the time, we probably want the type checker to be strict and allow only the two valid atoms, but maybe in the situation Jose described - <code>foo_or_bar(String.to_existing_atom(string))</code> - we would rather tell the compiler to trust us (and let the runtime raise if the input is invalid) than explicitly check the value and raise manually in order to satisfy the strict checker.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="293668" 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/type-system-updates-moving-from-research-into-development/56827/74">Post #73</a>
	                </div>
	            </div>
              <div id="likers-container-293668" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="293668"
                     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 #73"></div>
  </section>
</div>
    <div class="postbit" id="293687" data-post-id="293687">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="Sorc96" data-post="74" data-topic="56827">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sorc96/48/28361_2.png" class="avatar"> Sorc96:</div>
<blockquote>
<p>foo_or_bar(String.to_existing_atom(string))</p>
</blockquote>
</aside>
<p>To stretch this example further, you can still enforce that before this call site i.e. you can do:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def call_foo_or_bar("foo"), do: foo_or_bar(:foo)
def call_foo_or_bar("bar"), do: foo_or_bar(:bar)
def call_foo_or_bar(other) do
  Rollbax.report_message(:error, "unexpected input", %{input: other}
  {:error, :invalid_input}
end
</code></pre>
<p>No trust from the compiler is required. Of course that circles back to the argument that not everyone wants to write exhaustive pattern matches which is a valid stance to take but I am fearful that this will prompt the team to try and please everyone – which IMO has never worked and has a high potential to introduce a solution that neither side is happy with.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="293687" 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/type-system-updates-moving-from-research-into-development/56827/75">Post #74</a>
	                </div>
	            </div>
              <div id="likers-container-293687" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="293687"
                     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 #74"></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/56827/load_more?page=8">Load more posts (94 remaining)</a>
</div></template></turbo-stream>