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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="stjefim" data-post="1" data-topic="69968">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/s/54ee81/48.png" class="avatar"> stjefim:</div>
<blockquote>
<p>How can I obtain module, function name and arity from a function capture (e.g. <code>&amp;MyModule.my_function/0</code>) to “save function”?</p>
</blockquote>
</aside>
<p>The specific thing you’re looking for is <code>:erlang.fun_info</code>:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex(1)&gt; f = &amp;String.capitalize/1
&amp;String.capitalize/1

iex(2)&gt; :erlang.fun_info(f)
[module: String, name: :capitalize, arity: 1, env: [], type: :external]
</code></pre>
<p>Note that it gives a possibly-unexpected result if given a capture that uses <code>&amp;n</code> forms:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex(3)&gt; f2 = &amp;String.starts_with?(&amp;1, "foo")
#Function&lt;42.39164016/1 in :erl_eval.expr/6&gt;
iex(4)&gt; :erlang.fun_info(f2)
[
  pid: #PID&lt;0.0.0&gt;,
  module: :erl_eval,
  new_index: 42,
  new_uniq: &lt;&lt;74, 179, 14, 23, 76, 2, 152, 184, 122, 207, 206, 42, 63, 68, 21,
    64&gt;&gt;,
  index: 42,
  uniq: 39164016,
  name: :"-expr/6-fun-3-",
  arity: 1,
  env: [
    {3, %{}, {:value, &amp;:elixir.eval_local_handler/2},
     {:value, &amp;:elixir.eval_external_handler/3}, %{},
     [
       {:clause, 3, [{:var, 3, :_capture@1}], [],
        [
          {:call, 3,
           {:remote, 3, {:atom, 3, String}, {:atom, 3, :starts_with?}},
           [
             {:var, 3, :_capture@1},
             {:bin, 3,
              [{:bin_element, 3, {:string, 3, ~c"foo"}, :default, :default}]}
           ]}
        ]}
     ]}
  ],
  type: :local
]
</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="359154" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/get-function-name-module-and-arity-from-function-capture/69968/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-359154" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="359154"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-most-liked cat-most-liked" title="One of the top 3 liked posts in this thread!"></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>