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. 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. [1] http://www.haskell.org/haskellwiki/Template_Haskell On Mon, Jan 7, 2013 at 10:03 PM, Martin Drautzburg <Martin.Drautzburg@web.de
wrote:
When I :load this into ghci
import Data.Heap
heap = empty :: MinHeap (Int,String) insert (1,"kjh") heap
I get
GHC stage restriction: `heap' is used in a top-level splice or annotation, and must be imported, not defined locally In the second argument of `insert', namely `heap' In the expression: insert (1, "kjh") heap
But when I type in
import Data.Heap
let heap = empty :: MinHeap (Int,String) insert (1,"kjh") heap
everything works and I get
fromList [(1,"kjh")]
Why is that so and what can I do to prevent the "stage restriction"? -- Martin
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners