Edit InfixTypeConstructors authored by Simon Peyton Jones's avatar Simon Peyton Jones
......@@ -96,7 +96,7 @@ And `type` gets an extra production:
data a `Bar` b = a `BAR` b
```
## Issues
## Lexical ambiguity
......@@ -108,8 +108,15 @@ module Test ( (+) ) where
```
This export declaration is ambiguous because it is not clear if we mean to export the value operator (+), the type constructor (+), or both.
A similar issue arises with imports.
This export declaration is ambiguous because it is not clear if we mean to export the value operator (+), the type constructor (+), or both. Exactly the same issue arises for
- export lists
- import lists
- fixity declarations
- GHC's RULEs (see [ http://hackage.haskell.org/trac/ghc/ticket/2600](http://hackage.haskell.org/trac/ghc/ticket/2600)) and ANN annotations
### Solution A
......@@ -129,6 +136,9 @@ module Test ( (+)() ) where
Unfortunately, such specifications look rather odd.
### Solution B
Another solution would be to introduce a new piece of syntax which would translate to the same thing. Perhaps:
......@@ -138,7 +148,11 @@ module Test ( type (+) ) where
```
The intention here is that `type` specifies the namespace of the following name, and not that it is a type synonym.
The intention here is that `type` specifies the namespace of the following name, and not that it is a type synonym. Haskell already allows `module M` in export lists, for the same reason. It might make sense to allow `class C` as well.
Arguably `value C` would make sense too, meaning "the data constructor `C`" which currently cannot be mentioned in an export or import list except in the form `T(C)`. But that would mean a new keyword, albeit only in this context.
## References
......
......