[Haskell-beginners] "stage restriction" when using Data.Heap

Martin Drautzburg Martin.Drautzburg at web.de
Tue Jan 8 07:03:20 CET 2013


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



More information about the Beginners mailing list