Haskell program aborts with "loop" but I think it shouldn't : <p>I have this Haskell code which when compiled with GHC and run, aborts with a loop detected.</p>

<pre><code>data Foo = Foo ()
 deriving (Eq,Show)

type Foop = Foo -&gt; ((),Foo)

noOp :: Foop
noOp st = ((),st)

someOp :: Foop
someOp st@(Foo x) = ((),st)

(&lt;+&gt;) :: Foop -&gt; Foop -&gt; Foop
(&lt;+&gt;) f g st = let ((_,st'),(_,st'')) = ((f st),(g st')) in ((),st'')

main = print $ (noOp &lt;+&gt; someOp) $ Foo ()
</code></pre>

<p>I think it shouldn't, and here are some modifications. Each of them makes the loop go away:</p>

<ul>
<li>change <code>data Foo</code> to <code>newtype Foo</code></li>
<li>change <code>(noOp &lt;+&gt; someOp)</code> to <code>(someOp &lt;+&gt; noOp)</code></li>
<li>remove the deconstruction <code>@(Foo x)</code></li>
</ul>

<p>Is this a bug in GHC or is it my lack of understanding the evaluation process?</p>
