<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="72306" data-post-id="72306">
  <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">
								<p>Well, how tracing uses match specs is a bit different so calling them a select spec would not fit in there. And they are so close that giving them different names would be stupid. The main difference is what you can do in the body: in tables you can basically just return data while in tracing you can control how tracing works.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="72306" 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/elixir-with-erlang-fun2ms-ets/12827/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-72306" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="72306"
                     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="72312" data-post-id="72312">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="amnu3387" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  amnu3387
                    <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">
								<p>I definitively need to dig through the docs as I’ll be using quite a bit of ETS (btw I really like them, but until now I have only used them for unique key-&gt;value, with no need to do other stuff with them).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="72312" 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/elixir-with-erlang-fun2ms-ets/12827/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-72312" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="72312"
                     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="173613" data-post-id="173613">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’ve run into the same issue.</p>
<p>When I run:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex(1)&gt; :ets.fun2ms(fn x -&gt; x end)
[{:"$1", [], [:"$1"]}]
iex(2)&gt;
</code></pre>
<p>In the iex shell, it works. But when I try to use it in my module:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  def list() do
    :mnesia.transaction(fn -&gt;
      :mnesia.select(mnesia_table_name(), :ets.fun2ms(fn x -&gt; x end))
    end)
  end

</code></pre>
<p>I get the error</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">{:aborted,
 {:badarg,
  {:ets, :fun2ms,
   [:function, :called, :with, :real, :fun, :should, :be, :transformed, :with,
    :parse_transform, :or, :called, :with, :a, :fun, :generated, :in, :the,
    :shell]}}}
</code></pre>
<p>What’s strange and why in my case the solution proposed earlier doesn’t work is that when I replace the :ets.fun2ms with the MatchSpec which I get in the iex shell, like so:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  def list() do
    :mnesia.transaction(fn -&gt;
      :mnesia.select(mnesia_table_name(), [{:"$1", [], [:"$1"]}])
    end)
  end
</code></pre>
<p>it works.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="173613" 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/elixir-with-erlang-fun2ms-ets/12827/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-173613" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="173613"
                     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="173614" data-post-id="173614">
  <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>The <code>:ets.fun2ms</code> is a placeholder function. In erlang code a “parse transform” is run over your sourcecode, which replaces all calls to the <code>:ets.fun2ms</code> with the matchspec at <em>compiletime</em>. It comes close to macros in elixir, but not quite.</p>
<p>There is a package that can be used from within elixir code:</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://hex.pm/packages/ex2ms">
  <header class="source">
      <img src="https://hex.pm/images/hex-full-a8183c4f9adac71516516d107d402b18.svg?vsn=d" class="site-icon" alt="" width="136" height="120">

      <a href="https://hex.pm/packages/ex2ms" target="_blank" rel="noopener nofollow">Hex</a>
  </header>

  <article class="onebox-body">
    <img width="160" height="160" src="https://hex.pm/images/favicon-160-3770bc59f1f8ba7656b4db5a1eacd8e3.png?vsn=d" class="thumbnail onebox-avatar" alt="">

<h3><a href="https://hex.pm/packages/ex2ms" target="_blank" rel="noopener nofollow">ex2ms</a></h3>

  <p>Translates Elixir functions to match specifications for use with `ets`.</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="173614" 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/elixir-with-erlang-fun2ms-ets/12827/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-173614" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="173614"
                     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="173622" data-post-id="173622">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks for the reply. All clear now.</p>
<p>I’m going to give <code>ex2ms</code> a shot, because I’d rather avoid more complex matchspecs in my code because I find them rather hard to read and maintain.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="173622" 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/elixir-with-erlang-fun2ms-ets/12827/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-173622" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="173622"
                     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="173627" data-post-id="173627">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Added</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">      {:ex2ms, "~&gt; 1.6"},
</code></pre>
<p>to my mix.exs but something isn’t working:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex(1)&gt; import Ex2ms
** (CompileError) iex:1: module Ex2ms is not loaded and could not be found
</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="173627" 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/elixir-with-erlang-fun2ms-ets/12827/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-173627" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="173627"
                     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="173629" data-post-id="173629">
  <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>Have you done <code>mix deps.get</code> and started iex as <code>iex -S mix</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="173629" 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/elixir-with-erlang-fun2ms-ets/12827/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-173629" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="173629"
                     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="173632" data-post-id="173632">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Yes, I have</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">$ grep ex2ms mix.exs                                                                                                     ‹ruby-2.4.4›
      {:ex2ms, "~&gt; 1.6"},


$ mix deps.get
Resolving Hex dependencies...
Dependency resolution completed:
Unchanged:
  amqp 1.4.2
  amqp_client 3.8.3
  cachex 3.2.0
  cowboy 2.7.0
  cowlib 2.8.0
  credentials_obfuscation 1.1.0
  eternal 1.2.1
  ex2ms 1.6.0
  goldrush 0.1.9
  jsx 2.9.0
  jumper 1.0.1
  lager 3.8.0
  mime 1.3.1
  plug 1.10.0
  plug_cowboy 2.2.1
  plug_crypto 1.1.2
  poison 3.1.0
  rabbit_common 3.8.3
  ranch 1.7.1
  recon 2.5.0
  sleeplocks 1.1.1
  telemetry 0.4.1
  unsafe 1.0.1
All dependencies are up to date

$ iex -S mix
Erlang/OTP 22 [erts-10.7.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe] [dtrace]

iex(1)&gt; import Ex2ms
** (CompileError) iex:1: module Ex2ms is not loaded and could not be found

</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="173632" 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/elixir-with-erlang-fun2ms-ets/12827/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-173632" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="173632"
                     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="173633" data-post-id="173633">
  <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>Works for me:</p>
<pre><code class="lang-plaintext">$ nix run nixpkgs.elixir_1_10 -c mix new foo
* creating README.md
* creating .formatter.exs
* creating .gitignore
* creating mix.exs
* creating lib
* creating lib/foo.ex
* creating test
* creating test/test_helper.exs
* creating test/foo_test.exs

Your Mix project was created successfully.
You can use "mix" to compile it, test it, and more:

    cd foo
    mix test

Run "mix help" for more commands.
$ cd foo
$ emacs mix.exs
Waiting for Emacs...
$ nix run nixpkgs.elixir_1_10 -c mix deps.get
Resolving Hex dependencies...
Dependency resolution completed:
New:
  ex2ms 1.6.0
* Getting ex2ms (Hex package)
$ nix run nixpkgs.elixir_1_10 -c iex -S mix
Erlang/OTP 22 [erts-10.7] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [hipe]

==&gt; ex2ms
Compiling 1 file (.ex)
Generated ex2ms app
==&gt; foo
Compiling 1 file (.ex)
Generated foo app
Interactive Elixir (1.10.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)&gt; import Ex2ms
Ex2ms
</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="173633" 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/elixir-with-erlang-fun2ms-ets/12827/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-173633" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="173633"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>