Changes between Version 6 and Version 7 of ExistingRecords


Ignore:
Timestamp:
Jan 25, 2006 11:12:34 AM (9 years ago)
Author:
malcolm.wallace@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ExistingRecords

    v6 v7  
    55 * update syntax should not bottom out when fields are undefined. as in 
    66 
    7 {{{ 
     7   {{{ 
    88 
    9 data Foo = Foo { x :: String, y :: Int } | Bar { x :: String } 
     9   data Foo = Foo { x :: String, y :: Int } | Bar { x :: String } 
    1010 
    11 foo = Bar { x = "hello } 
     11   foo = Bar { x = "hello } 
    1212 
    13 baz = foo { y = 3 } 
     13   baz = foo { y = 3 } 
    1414 
    15 should not result in an error, but rather pass foo  
    16 through unchanged. update should update the record  
    17 if it exists, but pass the type through otherwise. 
    18 This would make the update syntax actually useful 
     15   should not result in an error, but rather pass foo  
     16   through unchanged. update should update the record  
     17   if it exists, but pass the type through otherwise. 
     18   This would make the update syntax actually useful 
    1919 
    20 }}} 
     20   }}} 
    2121 
    2222 
    2323 * label-based pattern matching 
    2424 
     25   the function: 
     26   {{{ 
     27     f val { x = "foo" } = 4 
     28   }}} 
     29   should match if passed a Foo or a Bar with x being equal to "foo" and val would be bound to its argument (like an @ 
     30pattern) 
     31   {{{ 
     32    g _ { y = 3 } = 4 
     33   }}} 
     34   would match only the Bar constructor since it is the only one with a  y field. 
    2535 
     36   This would mitigate the problems caused by accessors being partial functions since you can use a simple case statement to get the effect of an accesor that returns its result in a Maybe. 
    2637 
    27 the function: 
    28 {{{ 
    29   f val { x = "foo" } = 4 
    30 }}} 
    31 should match if passed a Foo or a Bar with x being equal to "foo" and val would be bound to its argument (like an @ pattern) 
    32 {{{ 
    33  g _ { y = 3 } = 4 
    34 }}} 
    35 would match only the Bar constructor since it is the only one with a  y field. 
     38   Note from Simon.  I hate that the above defn of 'f' has just one argument (val {x="foo")),  
     39   whereas it looks as if it has two.  (This is a problem with existing Haskell.)  It looks 
     40   like 'f' has an argument 'val' and another arguement that is a free-standing record,  
     41   something we really want in the end anyhow.  Not sure how to fix this.  val@{x="foo")? 
    3642 
    37 This would mitigate the problems caused by accessors being partial functions since you can use a simple case statement to get the effect of an accesor that returns its result in a Maybe. 
     43 * first class update and setting syntax (more advanced, needs better syntax) 
    3844 
    39 Note from Simon.  I hate that the above defn of 'f' has just one argument (val {x="foo")),  
    40 whereas it looks as if it has two.  (This is a problem with existing Haskell.)  It looks 
    41 like 'f' has an argument 'val' and another arguement that is a free-standing record,  
    42 something we really want in the end anyhow.  Not sure how to fix this.  val@{x="foo")? 
     45   A syntax for updating and setting fields should be allowed. 
    4346 
    44   * first class update and setting syntax (more advanced, needs better syntax) 
     47   some possibilites are  
    4548 
    46 A syntax for updating and setting fields should be allowed. 
     49   {{{ 
    4750 
    48 some possibilites are  
     51   foo { x = } 
    4952 
    50 {{{ 
     53   would be equivalent to (\v -> foo { x = v }) 
    5154 
    52 foo { x = } 
     55   foo { x \ } 
    5356 
    54 would be equivalant to (\v -> foo { x = v }) 
     57   would be equivalent to  
    5558 
    56 foo { x \ } 
     59   (\f -> foo { x = case foo of _ {x} -> foo { x = f x }; _ -> foo })  
    5760 
    58 would be equivalant to  
     61   }}} 
    5962 
    60 (\f -> foo { x = case foo of _ {x} -> foo { x = f x }; _ -> foo })  
     63 * polymorphic record update 
    6164 
     65   Given a record like: 
     66   {{{ 
     67   data Foo a = Foo { bar :: a } 
     68   }}} 
     69   it would be nice to be able to update it like: 
     70   {{{ 
     71   f = Foo { bar = 'a' } 
     72   g = f { bar = False } 
     73   }}} 
     74   Note the change in the type of the stored field.  At the moment, such a record update must be written using the 
     75   data constructor, not the update syntax. 
    6276 
    63 }}} 
    6477 
    6578== open statement == 
     
    87100open x would be allowed at the top level, in a let binding, or in a where binding. 
    88101 
     102