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?) 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? (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 would appreciate an answer on the first question (export of (:)) andrew Andrew U. Frank Geoinformation E127 phone: +43 1 588 01 12710 TU Vienna secr. +43 1 588 01 12700 Gusshausstrasse 27-29 fax +43 1 588 01 12799 A-1040 Vienna Austria cellular phone +43 676 41925 72 http://www.geoinfo.tuwien.ac.at/persons/frank/frank.html
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?)
http://www.haskell.org/onlinereport/syntax-iso.html does not permit an export of (:) as : is not a valid varsym (as : is not a valid symbol). Even for something like []((:)) the grammar says (:) would have to be a cname (= var | con) or qvar whereas it is a qcon (so the : is a gconsym. Of course, the [] bit isn't valid either.
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?
I would have expected list syntax to work regardless of whether you imported it from the Prelude as it cannot be redefined - is that not the case? (I haven't actually tried to do anything like that myself). Thanks Ian
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?
hello, Andrew Frank wrote:
(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))
the latest report is availabel online at haskell.org, and also as a book. currently the text about the prelude is as follows: The Prelude module is imported automatically into all modules as if by the statement `import Prelude', if and only if it is not imported with an explicit import declaration. This provision for explicit import allows entities defined in the Prelude to be selectively imported, just like those from any other module. thus if there is an explicit import of the Prelude, it behaves as any other import declaration would. for example if a programmer writes: import Prelude hiding (foldr) 'Prelude.foldr' is not in scope. hope this helps iavor -- ================================================== | Iavor S. Diatchki, Ph.D. student | | Department of Computer Science and Engineering | | School of OGI at OHSU | | http://www.cse.ogi.edu/~diatchki | ==================================================
participants (4)
-
Andrew Frank -
Ian Lynagh -
Iavor Diatchki -
Ross Paterson