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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="emadalam" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/emadalam/120/29439_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  emadalam
                    <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 certainly use environment variables in my code beyond just config files. So even though the idea of macros in <code>runtime.exs</code> is certainly nice, I still want to be able to access those environment variables values independently in my code as needed. This is why a separately initialized module where I can see/configure all the environment variables used by my app in one glance, makes more sense to me from flexibility and ease of use standpoint.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="277581" 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/mahaul-supercharge-the-environment-variables-usage-in-your-elixir-app/53752/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-277581" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="277581"
                     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="277583" data-post-id="277583">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Well, the point of configuration is to use them in your code later, just as libraries use them and you can do that easily by calling <a href="https://hexdocs.pm/elixir/1.13/Application.html#get_env/3" rel="noopener nofollow ugc"><code>get_env/3</code></a> or <a href="https://hexdocs.pm/elixir/1.13/Application.html#fetch_env/2" rel="noopener nofollow ugc"><code>fetch_env/2</code></a>, however taking in consideration the limitation of the configuration/compilation it seems that the only way to enforce something at compile-time is to make a custom module.</p>
<p>It would be great if such a functionality were to be introduced somewhere in the elixir internals so it could be used in all configurations.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="277583" 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/mahaul-supercharge-the-environment-variables-usage-in-your-elixir-app/53752/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-277583" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="277583"
                     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="277586" data-post-id="277586">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks for clarifying as I had indeed misunderstood.</p>
<aside class="quote no-group" data-username="emadalam" data-post="5" data-topic="53752">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/emadalam/48/29439_2.png" class="avatar"> emadalam:</div>
<blockquote>
<p>the confidence and guarantees you get are from using the generated functions from your code instead of using <code>System.get_env</code> with strings where there is no compile time checks if you used the correct environment variables names from various places in your code.</p>
</blockquote>
</aside>
<p>I’m still not sure I follow here though. This seems like with pattern matching you could hard code the strings for the env variables of interest and have the same sort of confidence. I can see that <code>mahaul</code> provides a single interface with the system env where you handle checking for the variables and providing defaults or handling errors rather than needing to do so everywhere you use the env variable in the application. <code>Mahaul</code> also seems to make it a lot easier to use different variables for different environments and to update them easily when the names of variables change between versions or something.</p>
<aside class="quote no-group" data-username="emadalam" data-post="5" data-topic="53752">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/emadalam/48/29439_2.png" class="avatar"> emadalam:</div>
<blockquote>
<p>Furthermore, the generated functions returns parsed values as per your provided configuration. So you can confidently use those elixir type values in your code instead of always manipulating strings that you get traditionally.</p>
</blockquote>
</aside>
<p>This sounds like a true win for me.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="277586" 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/mahaul-supercharge-the-environment-variables-usage-in-your-elixir-app/53752/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-277586" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="277586"
                     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="277590" data-post-id="277590">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="emadalam" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/emadalam/120/29439_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  emadalam
                    <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" data-username="stevensonmt" data-post="14" data-topic="53752">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/stevensonmt/48/20503_2.png" class="avatar"> stevensonmt:</div>
<blockquote>
<p>This seems like with pattern matching you could hard code the strings for the env variables of interest and have the same sort of confidence.</p>
</blockquote>
</aside>
<p>Can you give some brief example of how such a dynamic pattern matching can work at compile time? Form what I can think of, the following will give you runtime errors without any compile time warnings.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Env do
  def get_env("VAR_1"), do: "..."
  def get_env("VAR_2"), do: "..."
end

defmodule SomeModule do
  def something() do
    Env.get_env("VAR_1") # works
    Env.get_env("VAR_2") # works
    Env.get_env("VAR_3") # runtime error with no compile time warnings
  end
end
</code></pre>
<p>vs</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Env do
  use Mahaul,
    VAR_1: [type: :str],
    VAR_2: [type: :num]
end

defmodule SomeModule do
  def something() do
    Env.var_1() # works
    Env.var_2() # works
    Env.var_3() # compile time warnings for non-existing method call
  end
end
</code></pre>
<hr>
<aside class="quote no-group" data-username="stevensonmt" data-post="14" data-topic="53752">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/stevensonmt/48/20503_2.png" class="avatar"> stevensonmt:</div>
<blockquote>
<p>This sounds like a true win for me.</p>
</blockquote>
</aside>
<p><img src="https://forum.elixirforum.com/images/emoji/apple/heavy_heart_exclamation.png?v=15" title=":heavy_heart_exclamation:" class="emoji only-emoji" alt=":heavy_heart_exclamation:" loading="lazy" width="20" height="20"> <img src="https://forum.elixirforum.com/images/emoji/apple/heavy_heart_exclamation.png?v=15" title=":heavy_heart_exclamation:" class="emoji only-emoji" alt=":heavy_heart_exclamation:" loading="lazy" width="20" height="20"> <img src="https://forum.elixirforum.com/images/emoji/apple/heavy_heart_exclamation.png?v=15" title=":heavy_heart_exclamation:" class="emoji only-emoji" alt=":heavy_heart_exclamation:" 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="277590" 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/mahaul-supercharge-the-environment-variables-usage-in-your-elixir-app/53752/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-277590" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="277590"
                     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="277594" data-post-id="277594">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="emadalam" data-post="15" data-topic="53752">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/emadalam/48/29439_2.png" class="avatar"> emadalam:</div>
<blockquote>
<p>Can you give some brief example of how such a dynamic pattern matching can work at compile time? Form what I can think of, the following will give you runtime errors without any compile time warnings.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Env do
  def get_env("VAR_1"), do: "..."
  def get_env("VAR_2"), do: "..."
end

defmodule SomeModule do
  def something() do
    Env.get_env("VAR_1") # works
    Env.get_env("VAR_2") # works
    Env.get_env("VAR_3") # runtime error with no compile time warnings
  end
end
</code></pre>
</blockquote>
</aside>
<p><strong>LIGHTBULB</strong><br>
I get it now. Thanks!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="277594" 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/mahaul-supercharge-the-environment-variables-usage-in-your-elixir-app/53752/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-277594" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="277594"
                     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>