Changes between Version 10 and Version 11 of InfixTypeConstructors


Ignore:
Timestamp:
Nov 25, 2010 11:23:20 AM (3 years ago)
Author:
simonpj@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • InfixTypeConstructors

    v10 v11  
    6666}}} 
    6767 
    68 == Issues == 
     68== Lexical ambiguity == 
    6969 
    7070The second proposal---to treat all infix operators as type constructors---leads to an ambiguity in import/export declarations: 
     
    7373}}} 
    7474 
    75 This export declaration is ambiguous because it is not clear if we mean to export the value operator (+), the type constructor (+), or both. 
    76 A similar issue arises with imports. 
     75This 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 
     76 * export lists 
     77 * import lists 
     78 * fixity declarations 
     79 * GHC's RULEs (see http://hackage.haskell.org/trac/ghc/ticket/2600) and ANN annotations 
    7780 
     81=== Solution A === 
    7882One possible solution is to state that, when written on their own, infix operators in import/export specifications refer to the value level. 
    7983So in the above example we would be exporting the value operator (+). 
     
    8690Unfortunately, such specifications look rather odd. 
    8791 
     92=== Solution B === 
    8893Another solution would be to introduce a new piece of syntax which would translate to the same thing.  Perhaps: 
    8994{{{ 
    9095module Test ( type (+) ) where 
    9196}}} 
    92 The intention here is that `type` specifies the namespace of the following name, and not that it is a type synonym. 
     97The 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.   
     98 
     99Arguably `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. 
    93100 
    94101