<div dir="ltr">The GHC stage restriction is an error invoked when some Template Haskell [1] construct requires the evaluation of run-time values at compile time. I am going out on a limb and assuming that same code probably works in GHCI because the interpreter does not have a discrete compile-time phase.<div>
<br></div><div style>I assume that MinHeap is templated, but exactly how I do not know. Maybe someone who is more familiar with Data.Heap will have an answer.</div><div style><br></div><div>[1] <a href="http://www.haskell.org/haskellwiki/Template_Haskell">http://www.haskell.org/haskellwiki/Template_Haskell</a><br>
<div><br></div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jan 7, 2013 at 10:03 PM, Martin Drautzburg <span dir="ltr">&lt;<a href="mailto:Martin.Drautzburg@web.de" target="_blank">Martin.Drautzburg@web.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">When I :load this into ghci<br>
<br>
import Data.Heap<br>
<br>
heap = empty :: MinHeap (Int,String)<br>
insert (1,&quot;kjh&quot;) heap<br>
<br>
I get<br>
<br>
    GHC stage restriction: `heap&#39;<br>
      is used in a top-level splice or annotation,<br>
      and must be imported, not defined locally<br>
    In the second argument of `insert&#39;, namely `heap&#39;<br>
    In the expression: insert (1, &quot;kjh&quot;) heap<br>
<br>
But when I type in<br>
<br>
import Data.Heap<br>
<br>
let heap = empty :: MinHeap (Int,String)<br>
insert (1,&quot;kjh&quot;) heap<br>
<br>
everything works and I get<br>
<br>
 fromList [(1,&quot;kjh&quot;)]<br>
<br>
Why is that so and what can I do to prevent the &quot;stage restriction&quot;?<br>
<span class="HOEnZb"><font color="#888888">--<br>
Martin<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</font></span></blockquote></div><br></div>