Changes between Version 13 and Version 14 of ExtensibleRecords
 Timestamp:
 Nov 12, 2007 10:45:20 PM (9 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

ExtensibleRecords
v13 v14 81 81 Please 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 82 83 1An example to show the need for extra polymorphism in unpermuted records:83 An example to show the need for extra polymorphism in unpermuted records: 84 84 {{{ 85 type Point = { x :: Float, y:: Float}85 type Point = {X :: Float, Y :: Float} 86 86 87 87 norm :: Point > Float 88 norm p = sqrt (p. x * p.x + p.y * p.y)88 norm p = sqrt (p.X * p.X + p.Y * p.Y) 89 89 90 norm { y = 3.0, x = 4.0}  this is a type error90 norm {Y = 3.0, X = 4.0}  this is a type error, because X and Y are in the wrong order 91 91 92 norm' :: (Select x a Float, Select ya Float) => a > Float93 norm' p = sqrt (p. x * p.x + p.y * p.y)92 norm' :: (Select X a Float, Select Y a Float) => a > Float 93 norm' p = sqrt (p.X * p.X + p.Y * p.Y) 94 94 95 norm' { y = 3.0, x = 4.0}  this is OK95 norm' {Y = 3.0, X = 4.0}  this is OK, because norm' is polymorphic 96 96 }}} 97 97 98 The more complex systems support first class labels. Here is an example using the Type Families system: 99 {{{ 100 labelZip :: ({n :: a} `Disjoint` {m :: b}) => n > m > [a] > [b] > [{n :: a, m :: b}] 101 labelZip n m = zipWith (\x y > {n = x, m = y}) 102 }}} 103