<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<blockquote
cite="mid:CAKT9ecMJSkGPEpqVTFOg-kSgxu0XrCXqNLSbmobY0-TF0KKpQg@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><a moz-do-not-send="true"
href="https://gist.github.com/snoyberg/20243aae347b38ad09daaf8b129e2efb">https://gist.github.com/snoyberg/20243aae347b38ad09daaf8b129e2efb</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="pl-c1"> _DAYS_IN_A_WEEK_ , _KNOWN_SIZE_OF_POINT_ :: INT<span class="pl-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="pl-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_CENTS_ 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_CENTS_ :: Double
Or perhaps ‘_VALUE_OF_CONTRIBUTION_IN_CENTS_’ is mis-spelled, or not in scope
</pre>
<p><br>
</p>
</body>
</html>