modules and re-export
Peter Thiemann
thiemann@informatik.uni-freiburg.de
20 Mar 2001 17:55:39 +0100
I have a little question about the following two modules. Suppose you
want to write your own variant of the prelude that redefines a couple
of names but leaves all the rest unchanged. The Haskell report says
that the following should work:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
module BUG2A (module BUG2A, module Prelude) where
import Prelude hiding (head)
head = "HEAD"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This overrides the definition of head and should reexport head along
with everything imported from the Prelude. Hugs98/feb2001 loads it
happily and says head :: [Char]
Now, I want to use this module as an alternative prelude:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
module BUG2B where
import qualified Prelude
import BUG2A
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unfortunately, this does not behave as (I think) it should:
Reading file "BUG2B.hs":
Parsing........................................................................
ERROR "BUG2B.hs": Entity "head" imported from module "BUG2A" already defined in module "Prelude"
However, this should be legal from my reading of the report.
Any help appreciated.
-Peter