<div dir="ltr">You can avoid the underscores by defining the constants as pattern synonyms so that they are syntactically more like constructors. This also, of course, allows you to use them as patterns, which can also be nice for constants.<div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 6, 2017 at 9:09 AM, MarLinn <span dir="ltr"><<a href="mailto:monkleyon@gmail.com" target="_blank">monkleyon@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <br>
    <blockquote type="cite">
      <div dir="ltr">
        <div><a href="https://gist.github.com/snoyberg/20243aae347b38ad09daaf8b129e2efb" target="_blank">https://gist.github.com/snoybe<wbr>rg/20243aae347b38ad09daaf8b129<wbr>e2efb</a><br>
        </div>
        <div><br>
        </div>
        <div>It's got some magic values in a few places (especially that
          65!)<br>
        </div>
      </div>
    </blockquote>
    <br>
    <p>Off topic, but sometimes when I find myself using magic values I
      can't/won't get rid off, I'll just apply the good old habits
      learned in Java times. For example you might find a section at the
      top of a file with things like</p>
    <pre><span class="m_-6745835357095620959m_1563677389548060987pl-c1">  _DAYS_IN_A_WEEK_ , _KNOWN_SIZE_OF_POINT_ :: INT<span class="m_-6745835357095620959m_1563677389548060987pl-c1">

        -- | Seems to be a good approximation for now
        _DAYS_IN_A_WEEK_ = 7

        -- | When you ask "What's the point", this will not answer your question.
        _KNOWN_SIZE_OF_POINT_ = </span>65
</span><span class="m_-6745835357095620959m_1563677389548060987pl-c1"></span></pre>
    <p>Uppercase makes it easy to identify these as constants/magic
      values. The underscore in front works as an initial lowercase
      letter so they can be used as values despite uppercase.<br>
    </p>
    <p>The goal is not necessarily to make these values easy to change,
      but to add documentation to usage sites.</p>
    <p>It's unnecessary In such a quick demonstration, but I wanted to
      take the opportunity to throw in my
      _VALUE_OF_CONTRIBUTION_IN_CENT<wbr>S_ cents because I haven't seen
      others do something like this.</p>
    <p><br>
    </p>
    <p>Cheers,<br>
      MarLinn</p>
    <p><br>
    </p>
    <p>PS: The underscore does introduce its own error message though.<br>
    </p>
    <pre>    • Found hole: _VALUE_OF_CONTRIBUTION_IN_CENT<wbr>S_ :: Double
      Or perhaps ‘_VALUE_OF_CONTRIBUTION_IN_CEN<wbr>TS_’ is mis-spelled, or not in scope
</pre>
    <p><br>
    </p>
  </div>

<br>______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/haskell-caf<wbr>e</a><br>
Only members subscribed via the mailman list are allowed to post.<br></blockquote></div><br></div></div>