On 21-May-2000, Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> wrote:
> Sun, 21 May 2000 17:26:13 +1000, Fergus Henderson <[EMAIL PROTECTED]> pisze:
>
> > But being able to import and/or re-export such symbols is necessary
> > if you want to be able to implement an alternative prelude.
>
> No: they can be simply always available, just as \ and let.
OK, I guess that would work too.
Just to elaborate a little: with this suggestion, I suppose the
following module would be legal:
module Foo(List, nil, cons) where
import Prelude ()
type List t = [t]
nil = []
cons = (:)
Neither Hugs nor ghc currently allow this; Hugs complains about `:'
being undefined (but allows it if the definition of cons is replaced
with e.g. `cons = cons'), while ghc complains about both `:'
and `Prelude.[]' not being in scope.
But looking at the Haskell report, I think your suggestion looks
like it is the correct interpretation of the current wording,
and Hugs and ghc are wrong. The current wording is as follows:
| 5.5.3 Closure
|
| Every module in a Haskell program must be closed. That is, every name explicitly
|mentioned
| by the source code must be either defined locally or imported from another module.
| Entities that the compiler requires for type checking or other compile time
|analysis need
| not be imported if they are not mentioned by name.
Note that `:' and `[]' are not names (see 2.4).
P.S.
On a related note, Hugs and ghc both allow the following module
module Bar(List(..)) where
type List = []
without complaint, but according to the Haskell report (5.2) the
syntax `<typename>(..)' should only be used for algebraic data types,
not for type synonyms.
--
Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED] | -- the last words of T. S. Garp.