> The good news is that ghc (4.04) does not follow the Haskell 98
> report -- it accepts the following code, apparently as an
> extension to Haskell 98 (even without `-fglasgow-exts'):
> 
>       module Example(Prelude.[](..)) where
>       import Prelude([](..))
> 
> Similarly, it also accepts
> 
>       module Example(Prelude.[]((:), [])) where
>       import Prelude([]((:), []))

This good news also extends to nhc98 and (excluding the "Prelude."
qualification on the export list) hbc.

Since the implementations mostly seem to agree on this interpretation
of the Report, I'd guess that it was probably the intended meaning.
If the Report's grammar excludes the naming of gtycons in the export
list, that is probably an oversight which should be corrected.

> Hugs rejects:
>       import Prelude ()
>       cons :: a -> [a]
>       cons h t = h : t

And Hugs still rejects it, even if cons is given the correct type
signature. :-)

> The report is actually a bit unclear: it says that `:' is a special
> syntax, and it gives a definition of `:' in the Prelude, but it
> doesn't actually say that `:' always refers to the Prelude version.

Section 2.4, Identifiers and Operators, says (:) is a reservedop.

    Note that a colon by itself, ":", is reserved solely for use as the
    Haskell list constructor; this makes its treatment uniform with other
    parts of list syntax, such as "[]" and "[a,b]".

In other words, you cannot redefine : as a constructor - it is reserved
in the same sense as language keywords are reserved.

Regards,
    Malcolm


Reply via email to