Changes between Version 1 and Version 2 of LiberalTypeSynonyms


Ignore:
Timestamp:
Apr 22, 2008 11:15:39 PM (6 years ago)
Author:
simonmar@…
Comment:

document the choice about when kind inference takes place, and add Ross's objections

Legend:

Unmodified
Added
Removed
Modified
  • LiberalTypeSynonyms

    v1 v2  
    1414Adopt GHC's approach to type synonym expansion. 
    1515 
     16== Design choices == 
     17 
     18Should kind inference be done before, or after expanding type synonyms?  That is, should a type synonym have a fixed kind or not? 
     19 
     20Currently GHC does kind inference before expanding type synonyms, and gives each type synonym a fixed kind.  The following program is rejected: 
     21 
     22{{{ 
     23type T f a = f a 
     24 
     25x :: T (T (,) Int) Float 
     26x = (1,2.0) 
     27}}} 
     28gives 
     29{{{ 
     30syn.hs:5:10: 
     31    `(,)' is not applied to enough type arguments 
     32    Expected kind `* -> *', but `(,)' has kind `* -> * -> *' 
     33    In the type `T (,) Int' 
     34    In the type `T (T (,) Int) Float' 
     35    In the type signature for `x': 
     36      x :: T (T (,) Int) Float  
     37}}} 
     38 
     39In favour of GHC's approach is that type errors are more likely to be given in terms of types that the programmer actually wrote.  However, this does reject more programs, and perhaps it would be simpler to treat type synonyms uniformly as macros, without kinds? 
     40 
    1641== References == 
    1742 * [http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html#type-synonyms GHC Documentation] 
     
    2752== Cons == 
    2853 
    29  * any? 
     54 * It's so ... syntactic. 
     55 * There are the usual worries about deferred checking leading to less 
     56   informative diagnostics.