<div><div><div><div><div><span class="Apple-style-span" style="font-size: small;">I&#39;m having difficulty to understand the difference between WHNF and HNF.</span></div><div><span class="Apple-style-span" style="font-size: small;"><br>
</span></div><div><span class="Apple-style-span" style="font-size: small;">Is this </span><a href="http://encyclopedia2.thefreedictionary.com/Weak+Head+Normal+Form"><span class="Apple-style-span" style="font-size: small;">explanation</span></a><span class="Apple-style-span" style="font-size: small;"> the correct one? Or is WHNF and HNF equivalent in Haskell land?</span></div>
<div><span class="Apple-style-span" style="font-size: small;"><br></span></div><div><span class="Apple-style-span" style="font-size: small;">The GHC documentation of seq says:</span></div><div><span class="Apple-style-span" style="font-family: &#39;-webkit-sans-serif&#39;; "><span class="Apple-style-span" style="font-size: small;"><span class="Apple-style-span" style="font-style: italic;">Evaluates its first argument to head normal form, and then returns its second argument as the result.</span></span></span><span class="Apple-style-span" style="font-size: small;"><span class="Apple-style-span" style="font-style: italic;"><br>
</span></span></div><div><span class="Apple-style-span" style="font-size: small;"><br></span></div><div><span class="Apple-style-span" style="font-family: &#39;-webkit-sans-serif&#39;; "><span class="Apple-style-span" style="font-size: small;">Let&#39;s try in GHCi</span></span></div>
<div><span class="Apple-style-span" style="font-family: &#39;-webkit-sans-serif&#39;; "><span class="Apple-style-span" style="font-size: small;"><br></span></span></div><div><span class="Apple-style-span" style="font-family: -webkit-sans-serif;"><div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">*Main&gt; let f = trace &quot;\\x&quot; $ \x -&gt; ((trace &quot;\\y&quot; $ \y -&gt; trace &quot;y&quot; y + trace &quot;x&quot; x) $ trace &quot;2&quot; 2)</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">*Main&gt; f `seq` ()</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">\x</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">()</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;">*Main&gt;</span></div><div>
<br></div></div></span></div><div><span class="Apple-style-span" style="font-family: &#39;-webkit-sans-serif&#39;; "><span class="Apple-style-span" style="font-size: small;">That did not evaluate anything inside the body of the first lambda, so according to the article, seq reduces to <span class="Apple-style-span" style="font-style: italic;">weak head normal form</span>, not hnf...</span></span></div>
<div><span class="Apple-style-span" style="font-family: -webkit-sans-serif; font-size: 16px;"><br></span></div><div><span class="Apple-style-span" style="font-family: -webkit-sans-serif; font-size: 16px;"><br></span></div>
</div></div></div></div>