title: Elixir's anonymous function written in external .ex file can't run with interactive shell
body: <p>I can write an anonymous function in the interactive shell directly like below.  </p>
  
  <pre><code>iex&gt; total_bottles_milk = fn total -&gt; total * 2 end  
  iex&gt; total_bottles_milk.(2)
  </code></pre>
  
  <p>However, if I write in an external file and run in the interactive shell, it shows a Compile Error.  </p>
  
  <p>My file name and directory path is lib/expense.ex  </p>
  
  <p>Below is my code </p>
  
  <pre><code>defmodule Expense do
  
      total_bread_slices = fn total -&gt; (total * 10) / 100 end
      total_bottles_milk = fn total -&gt; total * 2 end
      total_cakes = fn total -&gt; total * 15 end
  
      def total_expense(bread_slices, bottles_of_milk, cakes) do
          total_bread_slices.(bread_slices) + total_bottles_milk.(bottles_of_milk) + total_cakes.(cakes)
      end
  
  end
  </code></pre>
  
  <p>When I go into the folder path and run <code>iex -S mix</code> to run my Expense module, terminal shows Compilation error.<br>
  I'm wondering only I can run anonymous function directly into the interactive shell and not from external sources and compile it. I want to write my function as a first-class citizen. And if there is a way, how can I do it?</p>