illegal export of lone data constructor

Ross Paterson ross at soi.city.ac.uk
Wed Sep 17 14:51:31 EDT 2003


On Sat, Sep 13, 2003 at 04:57:34PM +0200, Andrew Frank wrote:
> i am moving fom the nov 99 to the nov 02 hugs.exe (under windows)
> when recompiling old files i find two problems which i do not understand:
> 
> i want to export (:) from the prelude because i do not use the standard
> prelude usually.
> 
> module XX ( (:), ....)
> does not work (it did before). now i get the error "illegal export of lone
> data constructor"
> i do not see any hint in the report (nov 99) that (:) cannot be exported.
> (it may be unusual, but not illegal?)

It's illegal all right: the list of things you can export (in 5.2) doesn't
include data constructors, unless inside data types, and even then not (:).
Hugs is now a bit closer to the Report.

> the goal is to export certain functions from the prelude (especially (:),
> which cannot be redefined) but not all of it. how can this be achieved?

In Haskell 98 it is neither possible nor necessary to export (:),
but Hugs incorrectly permits and requires the Prelude to export it.
(This is unlikely to be fixed soon.)  One possibility is:

module MyPrelude (module Prelude, foldr) where
import Prelude hiding (foldr)
foldr = "foo"

> (minor point:
> my report says that the prelude module is always available as qualified
> import (p. 71)
> the hugs now (2002) seem to require an explicite import qualified (after a
> import Prelude hiding (stuff))

I can't find that in my copy (which doesn't have page numbers) -- what
section is that?


More information about the Hugs-Bugs mailing list