
On Tue, Jan 08, 2013 at 07:03:20AM +0100, Martin Drautzburg 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"?
Twan's analysis is correct. But wow, that's a horrible error message. Do you by any chance have the TemplateHaskell extension enabled (either with {-# LANGUAGE TemplateHaskell #-} at the top or your file, or with :set -XTemplateHaskell in a .ghci file, or anything like that)? If not this should really be filed as a bug, GHC has no business giving TH-related error messages without TH being turned on. -Brent