Changes between Version 12 and Version 13 of ExtensibleRecords


Ignore:
Timestamp:
Nov 12, 2007 5:26:34 PM (6 years ago)
Author:
guest
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ExtensibleRecords

    v12 v13  
    3131By '''constant shape''' we mean that the field names of a record are given literally, though the values and types of the fields could be variables. 
    3232 
     33= Constant Record Types = 
     34 
     35An important difference between the various proposals is what constitutes a valid record, and similarly a valid record type. The key points are: 
     36 
     37 * Permutativity:: Are `{x :: Int, y :: Int}` and `{y :: Int, x :: Int}` the same type? The '''Poor Man's Records''' system distinguishes these two, which makes implementation much simpler, but means that any function which accepts permuted records must be polymorphic. 
     38 * Repeated Fields:: Is `{x :: Int, x :: Int}` a valid record type? Both '''Poor Man's Records''' and '''Scoped Labels''' allow this type, but other systems consider this an error. 
     39 
    3340= Type Systems = 
    3441 
    35 The most important difference between the various record proposals seems to be the expressive power of their type systems. Most systems depend on special predicates in the type context. As usual there is a trade-off between power and simplicity. 
     42The most important difference between the various record proposals seems to be the expressive power of their type systems. Most systems depend on special predicates in the type context to govern the possible forms of record polymorphism. As usual there is a trade-off between power and simplicity. 
    3643 
    3744 No predicates:: You can get away without any predicates if you are prepared to allow records to have multiple fields with the same label. In the '''scoped labels''' system, the syntactic form of the type matches that of the record, so you can type the operators by 
     
    6976 * partial evaluation of type class programs: to achieve constant time record field access. Again, this feature is not specific to records, but crucial for record programming practice. 
    7077 * portability: it would be nice if extensible records libraries were portable over multiple Haskell implementations. That not only means that these implementations need to support the same features, but that they need to interpret these features in the same way (this is currently not the case for the interaction of functional dependencies and type class overlap resolution in GHC and Hugs). 
     78 
     79= Examples = 
     80 
     81Please put examples here, if possible using the above notation. The aim is to find out which features of the various systems are important in practice, so uncontrived examples which illustrate differences between the systems are wanted! 
     82 
     83 1 An example to show the need for extra polymorphism in unpermuted records: 
     84{{{ 
     85type Point = {x :: Float, y :: Float} 
     86 
     87norm :: Point -> Float 
     88norm p = sqrt (p.x * p.x + p.y * p.y) 
     89 
     90norm {y = 3.0, x = 4.0}    -- this is a type error 
     91 
     92norm' :: (Select x a Float, Select y a Float) => a -> Float 
     93norm' p = sqrt (p.x * p.x + p.y * p.y) 
     94 
     95norm' {y = 3.0, x = 4.0}    -- this is OK 
     96}}} 
     97