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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="OvermindDL1" data-post="11" data-topic="13854" 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/overminddl1/48/2677_2.png" class="avatar"> OvermindDL1:</div>
<blockquote>
<p>Alpaca has promise, but it is more ‘pure’ in typing, like having OCaml compile to Javascript.  It doesn’t have great integrations with Elixir and macro’s just don’t work at all, in addition it can’t use the types that the rest of the Beam more focuses on, as well as it doesn’t black box PID’s but instead tries to ‘type’ them (which seems inherently faulty on a BEAM language to me), etc…  It is good as a more pure language, but not as something to interact with Elixir libraries.</p>
</blockquote>
</aside>
<p>Yes, I think the difficult problem is not to design and implement a decent strictly typed language on top of the BEAM/Erlang/OTP but to interface it with the outside world. Outside in the sense of everything else running in the same Erlang node.</p>
<p>There is no safe way to really protect yourself from bad calls and messages being sent to you. You could handle it the Erlang way and let it crash but that assumes you have an infrastructure around which knows what to do when you crash. And generally you only crash small bits. You would then have to be able to structure your language/system in such way so that if (when) something goes down you don’t take it all down. I don’t know how this could be done in such languages.</p>
<aside class="quote no-group">
<blockquote>
<aside class="quote no-group" data-username="stefanchrobot" data-post="6" data-topic="13854">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/stefanchrobot/48/7657_2.png" class="avatar"> stefanchrobot:</div>
<blockquote>
<p>I’d rather have this in Elixir 2.x. The downside of a new language is the fragmentation of the community. What’s the point of a new language if you can’t get hired to work in it? It’s still tough to find a job in Elixir.</p>
</blockquote>
</aside>
</blockquote>
</aside>
<p>One serious issue with doing an Elixir 2.0 which is radically changed is backwards compatibility. People tend to get really worked up when their old code doesn’t work. <img src="https://forum.elixirforum.com/images/emoji/apple/wink.png?v=15" title=":wink:" class="emoji" alt=":wink:" loading="lazy" width="20" height="20"> Look at the problems with migrating from Python 2 to 3.</p>
<aside class="quote no-group">
<blockquote>
<aside class="quote no-group" data-username="gon782" data-post="7" data-topic="13854">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/g/eada6e/48.png" class="avatar"> gon782:</div>
<blockquote>
<p>I work with both Erlang and Elixir, i.e. I work with the BEAM. Would I have issues trying to convince project leaders to let me use LFE? Yeah, but the value proposition of something like LFE isn’t as obvious as a statically typed language that could allow for far less cognitive load. The value of a language like that would be self-evident at some point and it’s a much easier comparison than external statically typed languages vs. Elixir as well.</p>
</blockquote>
</aside>
<p>It actually <em>would</em> be possible to make an LFE library that can make and consume Elixir macro’s though, unlike Alpaca.  <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>
</blockquote>
</aside>
<p>LFE can consume Erlang macros and record definitions and transpose those to LFE macros and use them. It works on most macros but some macros just aren’t transformable to lisp macros. It would probably be possible with Elixir macros as well but transforming the Elixir code to LFE is probably more difficult.</p>
<p>One problem I have with the Elixir compiler is that is doesn’t feel very open, for example I don’t know of any well-defined way to get the resultant Elixir code after all macros have been expanded. Yes, there are ways of doing it but not in the same easy way as with the Erlang compile where you just give it an option (‘P’) and out comes a file with the expanded code. This would help a lot when writing macros and when trying to understand other macros.</p>
<aside class="quote no-group">
<blockquote>
<p>You could type LFE as well via a library for it.</p>
</blockquote>
</aside>
<p>LFE is already typed in the same way in the same way as Erlang and Elixir so you can run dialyzer on it. And get the same results as running dialyzer on Erlang and Elixir. <img src="https://forum.elixirforum.com/images/emoji/apple/smile.png?v=15" title=":smile:" class="emoji" alt=":smile:" loading="lazy" width="20" height="20"></p>
<aside class="quote no-group">
<blockquote>
<aside class="quote no-group" data-username="gon782" data-post="7" data-topic="13854">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/g/eada6e/48.png" class="avatar"> gon782:</div>
<blockquote>
<p>because all the important things in Elixir are the important things for the BEAM in general.</p>
</blockquote>
</aside>
</blockquote>
</aside>
<p>Not surprising as that it why Elixir is implemented on top of BEAM/Erlang/OTP, to get access to all those features  more or less for free. <img src="https://forum.elixirforum.com/images/emoji/apple/smile.png?v=15" title=":smile:" class="emoji" alt=":smile:" loading="lazy" width="20" height="20"></p>
<aside class="quote no-group">
<blockquote>
<p>Except Macro’s, Parse Transforms are indeed as powerful in erlang but just not as easy to use.  Macro’s are where Elixir gets its power (a proper macro system in erlang would make choosing elixir over erlang far far harder with only the library ecosystem (because of elixir macros) being the deciding choice, I wish elixir was more erlang/beam compatible instead of making custom/new formats somehow…).</p>
</blockquote>
</aside>
<p>While doing macros on top of Erlang is not really that difficult you have probably insurmountable problem and that is the syntax. Basically the macros transform function calls into other syntactic constructions. The problem is that function calls in Erlang really look like function calls so there is no real way to define new syntax. And parse transforms are about as powerful as you can get seeing you work on the whole module, but you can’t do anything about the syntax.</p>
<p>It is easier in Elixir because even though you are still transforming function calls the syntax is more lax and allows you to write things which are function calls syntactically but don’t look like it. The trivial example is of course <code>def</code> so</p>
<p><code>def foo(n) do something(n) end</code></p>
<p>is a call to the macro <code>def</code> of 2 arguments, but it doesn’t look that way.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="79581" 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/how-to-make-dialyzer-more-strict/13854/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-79581" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="79581"
                     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="79587" data-post-id="79587">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote group-Erlang-Core-Team" data-username="rvirding" data-post="12" data-topic="13854">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/rvirding/48/1409_2.png" class="avatar"> rvirding:</div>
<blockquote>
<p>LFE is already typed in the same way in the same way as Erlang and Elixir so you can run dialyzer on it. And get the same results as running dialyzer on Erlang and Elixir. <img src="https://forum.elixirforum.com/images/emoji/apple/smile.png?v=15" title=":smile:" class="emoji" alt=":smile:" loading="lazy" width="20" height="20"></p>
</blockquote>
</aside>
<p>I mean in a strong and static way.  ^.^</p>
<aside class="quote group-Erlang-Core-Team" data-username="rvirding" data-post="12" data-topic="13854">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/rvirding/48/1409_2.png" class="avatar"> rvirding:</div>
<blockquote>
<p>While doing macros on top of Erlang is not really that difficult you have probably insurmountable problem and that is the syntax. Basically the macros transform function calls into other syntactic constructions. The problem is that function calls in Erlang really look like function calls so there is no real way to define new syntax. And parse transforms are about as powerful as you can get seeing you work on the whole module, but you can’t do anything about the syntax.</p>
</blockquote>
</aside>
<p>Well Elixir compiles to erlang so that step would not be ‘too’ hard, issue is that you have to translate the erlang AST to elixir’s AST, which is a lot of busy work but I don’t see it being that hard to be honest, erlang is a very simple language.  <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>
<aside class="quote group-Erlang-Core-Team" data-username="rvirding" data-post="12" data-topic="13854">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/rvirding/48/1409_2.png" class="avatar"> rvirding:</div>
<blockquote>
<p>is a call to the macro def of 2 arguments, but it doesn’t look that way.</p>
</blockquote>
</aside>
<p>It all makes much more sense when you fully expand the macro’s, it goes down to base level calls.  <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="79587" 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/how-to-make-dialyzer-more-strict/13854/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-79587" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="79587"
                     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="79589" data-post-id="79589">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>What is <a class="mention" href="/u/josevalim" rel="nofollow">@josevalim</a> opinion about statically typed Elixir ? Is it possible that one day we will see optional type checking mechanism introduced into Elixir compiler?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="79589" 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/how-to-make-dialyzer-more-strict/13854/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-79589" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="79589"
                     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 #13"></div>
  </section>
</div>
    <div class="postbit" id="79617" data-post-id="79617">
  <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">
								<p>After reading the discussion here, I have roughly the same question as <a class="mention" href="/u/tx8" rel="nofollow">@tx8</a> – are there any actionable low-hanging fruits that are foreseeably doable without the doers hating their lives?</p>
<p>I’d love a statically typed Elixir but I understand there are a lot of practical hurdles and it’s most likely not on the roadmap. In the meantime, if us the Elixir devs want to level up our game, what options do we have?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="79617" 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/how-to-make-dialyzer-more-strict/13854/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-79617" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="79617"
                     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 #14"></div>
  </section>
</div>
    <div class="postbit" id="79624" data-post-id="79624">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tmbb" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tmbb
                  </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="15" data-topic="13854">
<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>are there any actionable low-hanging fruits that are foreseeably doable without the doers hating their lives?</p>
</blockquote>
</aside>
<p>In my very uninformed opinion, no. There are no low hanging fruits here. You either go full static typing from the beginning or you’ll never get decent type inference for your program. Type inference is an all or nothing affair: you either have full decidability (e.g. Haskell or OCaml) or you have something like dialyzer. You can’t go from dyalizer to Haskell by incrementally adding more and more rules.</p>
<p>First, you need actual parametrized types, which I think dialyzer doesn’t support. You can’t have type signatures like the one from the <code>List.delete/2</code> function: <code>delete(list(), any()) :: list()</code>, which expands into <code>delete([any()] -&gt; any()) :: [any()]</code>. In this type signature, there is no relationship between the three types that appear. You’d need something like (pseudocode) <code>delete(['a], 'a) :: 'a</code>, which guarantees that the input and output list have the same type.</p>
<p>At the same time, there is a big problem with macros. Macros operate on the AST. If Elixir were to be strongly typed, the AST would have to be strongly typed as well. The most widely used decidable type system is probably the Hindley-Milner (HM) type system. Elixir’s AST can’t be represnted in its current for in that type system, because it doesn’t support heterogeneous collections. You’d need to define an AST type, with several constructors for the different types, but in such a system, writing macros is a completely different experience. t wouldn’t feel like writing Elixir as it is today. Again, such change might be worth it, but it won’t look like Elixir.</p>
<aside class="quote no-group" data-username="dimitarvp" data-post="15" data-topic="13854">
<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>In the meantime, if us the Elixir devs want to level up our game, what options do we have?</p>
</blockquote>
</aside>
<p>Write another language that compiles to the BEAM with easy (typed) FFI for Elixir and Erlang, uses mix/rebar as a build system and writes the function docs to the new documentation BEAM chunks. For now forget about reusing Elixir’s macros. If you need a macro system, write your own.</p>
<p>Alternatively, there is some new research on type checking algorithms for types that include untagged unions and intersections, which might allow you to have static types without the need for named constructors. The main problem is that type inference is much harder within this system.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="79624" 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/how-to-make-dialyzer-more-strict/13854/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-79624" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="79624"
                     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 #15"></div>
  </section>
</div>
    <div class="postbit" id="79649" data-post-id="79649">
  <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">
								<aside class="quote no-group" data-username="tmbb" data-post="16" data-topic="13854">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/t/77aa72/48.png" class="avatar"> tmbb:</div>
<blockquote>
<p>delete(['a], 'a) :: 'a,</p>
</blockquote>
</aside>
<p>This is <code>delete(list(a), a) :: list(a) when a: var</code> in elixir specs.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="79649" 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/how-to-make-dialyzer-more-strict/13854/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-79649" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="79649"
                     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 #16"></div>
  </section>
</div>
    <div class="postbit" id="79659" data-post-id="79659">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Sorry, I should have reread the typespec docs before posting. In that case, I think some typespecs should be updated to use this</p>
<p>Not that it would make much difference in practice.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="79659" 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/how-to-make-dialyzer-more-strict/13854/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-79659" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="79659"
                     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 #17"></div>
  </section>
</div>
    <div class="postbit" id="79662" data-post-id="79662">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I love types, but here</p>
<div class="youtube-onebox lazy-video-container" data-video-id="78GRqQVt6ks" data-video-title="Lambda Days 2018 - José Valim- Introducing HDD: Hughes Driven Development" data-video-start-time="" data-provider-name="youtube">
  <a href="https://www.youtube.com/watch?v=78GRqQVt6ks" target="_blank" class="video-thumbnail" rel="noopener nofollow ugc">
    <img class="youtube-thumbnail" src="https://img.youtube.com/vi/78GRqQVt6ks/maxresdefault.jpg" title="Lambda Days 2018 - José Valim- Introducing HDD: Hughes Driven Development" width="690" height="388">
  </a>
</div>

<p>Jose says the future might be Clojure Spec</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://clojure.org/about/spec">
  <header class="source">
      <img src="https://clojure.org/images/clojure-logo-icon-32.png" class="site-icon" alt="" width="32" height="32">

      <a href="https://clojure.org/about/spec" target="_blank" rel="noopener nofollow ugc">clojure.org</a>
  </header>

  <article class="onebox-body">
    

<h3><a href="https://clojure.org/about/spec" target="_blank" rel="noopener nofollow ugc">Clojure - clojure.spec - Rationale and Overview</a></h3>



  </article>

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

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

<p>which seems sensible to me.</p>
<p>Yet again, Elixir and Clojure show their likeness…</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="79662" 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/how-to-make-dialyzer-more-strict/13854/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-79662" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="79662"
                     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 #18"></div>
  </section>
</div>
    <div class="postbit" id="79665" data-post-id="79665">
  <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="tim2CF" data-post="1" data-topic="13854">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/t/3e96dc/48.png" class="avatar"> tim2CF:</div>
<blockquote>
<p>Why it not generates any warnings when there is clause where wrong value is returned from function?</p>
</blockquote>
</aside>
<p>Did you try the overspecs/underspecs flags? <a href="http://erlang.org/doc/man/dialyzer.html" class="inline-onebox" rel="nofollow">dialyzer — OTP 29.0.2 (dialyzer 6.0.1)</a></p>
<aside class="quote no-group" data-username="hypno" data-post="10" data-topic="13854">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hypno/48/9581_2.png" class="avatar"> hypno:</div>
<blockquote>
<p>I’m not an expert on types but we already have type declaration syntax that the community actively using in Elixir. The problem is how Dialyzer interprets them (too loose).</p>
</blockquote>
</aside>
<p>Dialyzer is fine for the trade-offs it chose to make. Having something more strict most likely means rejecting code that is completely valid today. Or in the best case scenario, forcing types to be explicit and not relying on inference.</p>
<p><a class="mention" href="/u/tmbb" rel="nofollow">@tmbb</a> is correct here. There aren’t low hanging fruits when it comes to types. Adding a type system involves many compromises and the compromises you are willing to make change a lot when the language already exists.</p>
<p>If you want to have type inference, then many Elixir idioms will no longer be supported. Elixir code is based on unions (it returns {:ok, _} | :error) and intersections (different clauses of a function) and those are very expensive for an inference engine.</p>
<p>We could add requirements, such as obligatory typing of inputs, but that doesn’t solve the problem that we have both typed and non-typed code and we should likely check the values at the boundaries, adding runtime cost.</p>
<p>If you want to keep the language the same and support all of the existing idioms and also not worry about conversion costs: that’s Dialyzer.</p>
<p>Long story short: we could have other type systems but you need to start from scratch and you will have to compromise in many ways.</p>
<aside class="quote no-group" data-username="mmport80" data-post="19" data-topic="13854">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mmport80/48/8995_2.png" class="avatar"> mmport80:</div>
<blockquote>
<p>Jose says the future might be Clojure Spec</p>
</blockquote>
</aside>
<p>Apologies but I did not mean that Clojure Spec is the future. It is unlikely we will have something like Clojure Spec in Elixir per-se, especially because we have typespecs and guards and adding a third option is going to bring only marginal gains. If somebody wants to explore something like Clojure Spec as a package, then please do!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="79665" data-batch-url="/posts/batch_likers">
                        7
                      </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/how-to-make-dialyzer-more-strict/13854/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-79665" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="79665"
                     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 #19"></div>
  </section>
</div>
    <div class="postbit" id="79680" data-post-id="79680">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Would it be possible through a module attribute or macro to have the compiler insert additional pattern matching / guard clauses to check parameters and return values respect the typespecs at runtime?</p>
<p>Something like a combination of dialyzer and <a href="https://github.com/vic/expat" rel="noopener nofollow ugc">expat</a> would be great.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="79680" 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/how-to-make-dialyzer-more-strict/13854/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-79680" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="79680"
                     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 #20"></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/13854/load_more?page=3">Load more posts (31 remaining)</a>
</div></template></turbo-stream>