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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group quote-modified" data-username="OvermindDL1" data-post="34" data-topic="11665">
<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>Or in OCaml:</p>
<p>let sayMe = function<br>
| 1 -&gt; “One!”<br>
| 2 -&gt; “Two!”<br>
| 3 -&gt; “Three!”<br>
(* Along with a warning for missing possible inputs, you’ll get an exception then *)</p>
<p>^.^</p>
</blockquote>
</aside>
<p>You intrigued me with this Ocaml, so I learned some basics fastly and yes it’s got really good type inferring mechanism, but… as always there are some but’s.</p>
<aside class="quote no-group" data-username="OvermindDL1" data-post="34" data-topic="11665">
<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>Verses having good type inference.  <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"></p>
</blockquote>
</aside>
<p>For Ocaml compiler code below is good, with fantastic types int, as just for programmer who wrote this code fastly. But this code got serious bug. Can you see it at first look?</p>
<p>Side note: Used Fibonacci to simplify example as much as possible.</p>
<pre data-code-wrap="ocaml"><code class="lang-ocaml">let rec do_fib = function
  | 0, prev, cur -&gt; prev
  | n, prev, cur -&gt; do_fib(n - 1, cur, prev + cur);;

(* val do_fib : int * int * int -&gt; int = &lt;fun&gt; *)

let fib n = do_fib(n, 0, 1);;

(* val fib : int -&gt; int = &lt;fun&gt; *)
</code></pre>
<p>So the bug is:</p>
<pre data-code-wrap="ocaml"><code class="lang-ocaml">fib(0);;
(* - : int = 0 *)
fib(1);;
(* - : int = 1 *)
fib(-1);;
(* BANG: forever and ever :) *)
</code></pre>
<p>So relaying only on inferring types can be sometimes really deceiving.</p>
<p>With implicit type annotation or definition you have more chance to not introduce this bug at all or if you introduce it more chance to find this bug just by reading code before running this code with bad value at runtime.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">@spec fib(non_neg_integer()) :: non_neg_integer()
def fib(n), do: fib(n, 0, 1) #omg, where is guard for n &gt;= 0?

def fib(0, prev, _),   do: prev
def fib(n, prev, cur), do: fib(n - 1, cur, prev + cur)
</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="66373" 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/does-anybody-else-feel-this-way-about-spec-visually-overpowering/11665/43">Post #42</a>
	                </div>
	            </div>
              <div id="likers-container-66373" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="66373"
                     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 #42"></div>
  </section>
</div>
    <div class="postbit" id="66771" data-post-id="66771">
  <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">
								<p>[quote=“crabonature, post:43, topic:11665”]<br>
but… as always there are some but’s.[/quote]</p>
<p>It’s a very old language so it has it’s warts, but it is very well designed though.  <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 no-group" data-username="crabonature" data-post="43" data-topic="11665">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/crabonature/48/7311_2.png" class="avatar"> crabonature:</div>
<blockquote>
<p>So relaying only on inferring types can be sometimes really deceiving.</p>
</blockquote>
</aside>
<p>MLTypes cannot protect you from logic bugs, for that you’d need something like Idris.  <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"></p>
<p>However, that can be caught more easily if you use guards with matchers like in Elixir:</p>
<pre data-code-wrap="ocaml"><code class="lang-ocaml">let rec do_fib = function
  | 0, prev, cur -&gt; prev
  | n, prev, cur when n&gt;0 -&gt; do_fib(n - 1, cur, prev + cur);;

(* val do_fib : int * int * int -&gt; int = &lt;fun&gt; *)

let fib n = do_fib(n, 0, 1);;

(* val fib : int -&gt; int = &lt;fun&gt; *)
</code></pre>
<p>Notice I added the ‘when’ there to constrain the ‘value’ (not the type), and now it will properly throw you an exception.  ^.^</p>
<p>Technically you can encode logic into the ML type system too, though it becomes more… work (though not ‘that’ different from Idris, but more wordy by <em>far</em>).</p>
<p>Idris is fascinating to learn but a bit more brain melting at times (and so sloooooow to compile).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="66771" 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/does-anybody-else-feel-this-way-about-spec-visually-overpowering/11665/44">Post #43</a>
	                </div>
	            </div>
              <div id="likers-container-66771" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="66771"
                     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 #43"></div>
  </section>
</div>
    <div class="postbit" id="67515" data-post-id="67515">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hi <a class="mention" href="/u/ryanwinchester" rel="nofollow">@ryanwinchester</a>,</p>
<p>I feel exactly the same way you do.  I understand the arguments around typing in Elixir leading to this long thread.  For now dialyzer is the best we can get.</p>
<p>Rather than fork the repo and run my own version of the extension as gonz suggests, I just keep a custom copy of the grammar file <code>elixir.json</code> along with a custom color scheme/theme file based on ST3’s Monokai in a private repo under <code>~/.vscode/extensions</code>.</p>
<p>When I want to make tweaks to syntax highlighting, I just edit the <code>elixir.json</code> grammar and optionally the theme file, then run an .exs script which copies it over the installed extension’s files.  Whenever the extension updates itself I have to manually re-run the script to copy over the files again.  This is a pain but easier IMO than the fork…pull from upstream…merge option every time there is a new extension release.</p>
<p>Here is the snippet of JSON you will need in your custom <code>elixir.json</code> file located at <code>~/.vscode/extensions/JakeBecker.elixir-ls-0.2.10/syntaxes</code> and it should work out-of-the-box with any color scheme you like:</p>
<pre data-code-wrap="json"><code class="lang-json">{
  "comment": "treat @spec as a comment/documentation to de-emphasize",
  "begin": "@spec ",
  "beginCaptures": {
    "0": {
      "name": "comment.documentation.spec.elixir"
    }
  },
  "while": "(^|\\G)(?!\\s*(def |defp ))",
  "contentName": "comment.documentation.spec.elixir"
}
</code></pre>
<p>This assumes the <code>@spec</code> line(s) are directly before a <code>def</code> or <code>defp</code> line.</p>
<p>Please let me know if this helps or if you’d like me to put a gist up.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="67515" 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/does-anybody-else-feel-this-way-about-spec-visually-overpowering/11665/45">Post #44</a>
	                </div>
	            </div>
              <div id="likers-container-67515" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="67515"
                     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 #44"></div>
  </section>
</div>
    <div class="postbit" id="67523" data-post-id="67523">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="tme_317" data-post="45" data-topic="11665">
<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/0ea827/48.png" class="avatar"> tme_317:</div>
<blockquote>
<p>This is a pain but easier IMO than the fork…pull from upstream…merge option every time there is a new extension release.</p>
</blockquote>
</aside>
<p>This should only be a <code>git pull --rebase</code>. I’m not sure what your custom script is supposed to do better than that.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="67523" 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/does-anybody-else-feel-this-way-about-spec-visually-overpowering/11665/46">Post #45</a>
	                </div>
	            </div>
              <div id="likers-container-67523" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="67523"
                     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 #45"></div>
  </section>
</div>
    <div class="postbit" id="67551" data-post-id="67551">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’m sure you are right it would be as simple as a <code>git pull --rebase</code>.  I wasn’t sure, and haven’t researched, exactly how the vscode extension automagic updater works after forking.  I didn’t want it to blow away my grammar customizations on an upstream update so I just rely on a simple script that replaces the extension grammar json file after they update with my customized one.</p>
<p>The important part to address the OP’s original question is the grammar snippet that highlights <code>@spec</code> as a comment.  I have been bothered by this also and his post made me want to finally do something about it.  It took me an hour of trial and error today to get the regex working right on multi-line specs.  Really glad I don’t have to work with regex and these textmate grammar files every day!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="67551" 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/does-anybody-else-feel-this-way-about-spec-visually-overpowering/11665/47">Post #46</a>
	                </div>
	            </div>
              <div id="likers-container-67551" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="67551"
                     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 #46"></div>
  </section>
</div>
    <div class="postbit" id="69196" data-post-id="69196">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I was thinking about this a bit more - I wonder if a problem is, the <code>@spec</code> and <code>def</code>’s aren’t lined up vertically. Haskell, IMO, isn’t as chaotic looking because of the vertical alignment:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">mult :: x -&gt; y -&gt; z
mult x y = x * y
</code></pre>
<p>So, brainstorming, if we could make <code>@sp</code> be a synonym for <code>@spec</code>, then the orig. functions would look like:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">@sp get_integration_provider!(integer) :: %IntegrationProvider{}
def get_integration_provider!(provider_id) do
</code></pre>
<p>I like that a lot. The doubled-up name makes a nice visual signpost for the start of the function. Alternatively, we could format the function start with two extra spaces:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">@spec get_integration_provider!(integer) :: %IntegrationProvider{}
def   get_integration_provider!(provider_id) do
</code></pre>
<p><a class="mention" href="/u/overminddl1" rel="nofollow">@OvermindDL1</a> Any ideas how to create this <code>@sp</code> synonym? I’d like to give that a try.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="69196" 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/does-anybody-else-feel-this-way-about-spec-visually-overpowering/11665/48">Post #47</a>
	                </div>
	            </div>
              <div id="likers-container-69196" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="69196"
                     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 #47"></div>
  </section>
</div>
    <div class="postbit" id="69200" data-post-id="69200">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>And a different brainstorm: a single unified spec+def syntactic sugar, in some format that’d be easy to expand back to the originals E.g.,</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def get_integration_provider!(provider_id ~ integer) :: %IntegrationProvider{}
</code></pre>
<p>See what I did there? <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"> I changed <code>@spec</code> to <code>def </code> and added in the parameter followed by some delineating character. I think that’d enable a mapping back to the original <code>def</code> and <code>@spec</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="69200" 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/does-anybody-else-feel-this-way-about-spec-visually-overpowering/11665/49">Post #48</a>
	                </div>
	            </div>
              <div id="likers-container-69200" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="69200"
                     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 #48"></div>
  </section>
</div>
    <div class="postbit" id="69201" data-post-id="69201">
  <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 no-group quote-modified" data-username="dogweather" data-post="48" data-topic="11665">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dogweather/48/1906_2.png" class="avatar"> dogweather:</div>
<blockquote>
<p>I was thinking about this a bit more - I wonder if a problem is, the <a class="mention" href="/u/spec" rel="nofollow">@spec</a> and def’s aren’t lined up vertically. Haskell, IMO, isn’t as chaotic looking because of the vertical alignment:</p>
<pre data-code-wrap="haskell"><code class="lang-haskell">mult :: x -&amp;gt; y -&amp;gt; z
mult x y = x * y
</code></pre>
</blockquote>
</aside>
<p>In OCaml this would be:</p>
<pre data-code-wrap="ocaml"><code class="lang-ocaml">let mult : x -&gt; y -&gt; z =
  fun x y -&gt; x * y
</code></pre>
<p>Or more succinctly as:</p>
<pre data-code-wrap="ocaml"><code class="lang-ocaml">let mult (x : x) (y : y) = x * y
</code></pre>
<p>Or entirely separate as:</p>
<pre data-code-wrap="ocaml"><code class="lang-ocaml">(* header file *)
val mult : x -&gt; y -&gt; z
(* implementation file *)
let mult x y = x * y
</code></pre>
<aside class="quote no-group" data-username="dogweather" data-post="48" data-topic="11665">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dogweather/48/1906_2.png" class="avatar"> dogweather:</div>
<blockquote>
<p>So, brainstorming, if we could make <span class="mention">@sp</span> be a synonym for <a class="mention" href="/u/spec" rel="nofollow">@spec</a>, then the orig. functions would look like:</p>
</blockquote>
</aside>
<p>The argument name still gets misaligned though?</p>
<p>Honestly I’d love some combined kind of definition, maybe like:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defs get_integration_provider!(provider_id :: integer) :: %IntegrationProvider{} do
  ...
end
</code></pre>
<p>Though I quite prefer inlined types so I can see far more easily, and it works very well when the arguments get long too as each can get on it’s own line:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def blahblah(
  arg1 :: integer,
  arg2 :: String.t,
  arg3 :: BlahblahBlah.t # Oh if only we had trailing commas allowed inside parenthesis...
) :: %BlahReturnStruct{} do
  ...
end
</code></pre>
<p>Which I find reads very well.  <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"><br>
You could even have that on just the non-implementation head, or you could have it on each head and they’d get combined properly.  <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 no-group" data-username="dogweather" data-post="48" data-topic="11665">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dogweather/48/1906_2.png" class="avatar"> dogweather:</div>
<blockquote>
<p><a class="mention" href="/u/overminddl1" rel="nofollow">@OvermindDL1</a> Any ideas how to create this <span class="mention">@sp</span> synonym? I’d like to give that a try.</p>
</blockquote>
</aside>
<p>A fairly simple <code>use ...</code> at the top could make <code>@sp</code> work like <code>@spec</code> as a synonym, the module would just convert the AST as necessary to the <code>@spec</code>’s at the end.</p>
<aside class="quote no-group" data-username="dogweather" data-post="49" data-topic="11665">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dogweather/48/1906_2.png" class="avatar"> dogweather:</div>
<blockquote>
<p>And a different brainstorm: a single unified spec+def syntactic sugar, in some format that’d be easy to expand back to the originals E.g.,</p>
</blockquote>
</aside>
<p>I’d just use <code>::</code> like I demonstrated above as it matches existing type syntax.  ^.^</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="69201" 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/does-anybody-else-feel-this-way-about-spec-visually-overpowering/11665/50">Post #49</a>
	                </div>
	            </div>
              <div id="likers-container-69201" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="69201"
                     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 #49"></div>
  </section>
</div>
    <div class="postbit" id="69251" data-post-id="69251">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="ryanwinchester" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ryanwinchester/120/9472_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  ryanwinchester
                    <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 quote-modified" data-username="OvermindDL1" data-post="50" data-topic="11665">
<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>
<pre data-code-wrap="elixir"><code class="lang-elixir">def blahblah(
  arg1 :: integer,
  arg2 :: String.t,
  arg3 :: BlahblahBlah.t # Oh if only we had trailing commas [...]
) :: %BlahReturnStruct{} do
  ...
end
</code></pre>
</blockquote>
</aside>
<p>Love it <img src="https://forum.elixirforum.com/images/emoji/apple/heart.png?v=15" title=":heart:" class="emoji" alt=":heart:" 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="69251" 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/does-anybody-else-feel-this-way-about-spec-visually-overpowering/11665/51">Post #50</a>
	                </div>
	            </div>
              <div id="likers-container-69251" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="69251"
                     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 #50"></div>
  </section>
</div>
    <div class="postbit" id="69264" data-post-id="69264">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a class="mention" href="/u/ryanwinchester" rel="nofollow">@ryanwinchester</a> just as an idea, you can put the <code>@spec</code> declaration inside the <code>@doc</code> with interpolation, and it should just work.</p>
<p>This is what I mean:</p>
<p></p><div class="lightbox-wrapper"><a class="lightbox" href="https://forum.elixirforum.com/uploads/default/original/2X/d/da2ed2a82e452ea16c420e2dd42d4b7c8f383069.png" data-download-href="https://forum.elixirforum.com/uploads/default/da2ed2a82e452ea16c420e2dd42d4b7c8f383069" title="Bildschirmfoto 2018-02-08 um 01.07.19.png" rel="nofollow"><img src="https://forum.elixirforum.com/uploads/default/original/2X/d/da2ed2a82e452ea16c420e2dd42d4b7c8f383069.png" width="385" height="189"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Bildschirmfoto 2018-02-08 um 01.07.19.png</span><span class="informations">385×189 10.6 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><p></p>
<p>The <code>@spec</code> is here visually a part of the documentation, but properly executed as code, picked up by dialyzer , ex_doc and co.</p>
<p>Update:</p>
<p>I just compiled it to docs, and found in the place of the spec expressions the string “true”. Really sad, I just began to like 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"></p>
<p>Hmm, is the return value form <code>@spec</code> really necessary, I mean <code>nil</code> would be just fine as well?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="69264" 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/does-anybody-else-feel-this-way-about-spec-visually-overpowering/11665/52">Post #51</a>
	                </div>
	            </div>
              <div id="likers-container-69264" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="69264"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #51"></div>
  </section>
</div>
</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/11665/load_more?page=6">Load more posts (2 remaining)</a>
</div></template></turbo-stream>