Changes between Version 1 and Version 2 of Records/DeclaredOverloadedRecordFields/NoMonoRecordFields


Ignore:
Timestamp:
Mar 26, 2012 8:26:39 PM (3 years ago)
Author:
AntC
Comment:

Add use case

Legend:

Unmodified
Added
Removed
Modified
  • Records/DeclaredOverloadedRecordFields/NoMonoRecordFields

    v1 v2  
    66There is to be a compiler flag '''-XNoMonoRecordFields'''. (Default value '''‑XMonoRecordFields''', to give H98 behaviour.)
    77
    8 -XNoMonoRecordFields suppresses creating the field selector function from the field name in a record-style data declaration.
     8`-XNoMonoRecordFields` suppresses creating the field selector function from the field name in a record-style data declaration.
    99
    1010Suppressing the function frees up the namespace, to be able to experiment with various record/field approaches -- including the 'cottage industry' of Template Haskell solutions.
    1111
    12 -XNoMonoRecordFields implies -XDisambiguateRecordFields -- otherwise the only way to access record fields is positionally. It also implies ‑XNamedFieldPuns and ‑XRecordWildCards to support field access and update. (IMHO, suppressing the field selector function should always have been part of -XDisambiguateRecordFields. I'm by no means the first to make that observation.)
     12`-XNoMonoRecordFields` implies `-XDisambiguateRecordFields` -- otherwise the only way to access record fields is positionally. It also implies `‑XNamedFieldPuns` and `‑XRecordWildCards` to support field access and update. (IMHO, suppressing the field selector function should always have been part of `-XDisambiguateRecordFields`. I'm by no means the first to make that observation.)
    1313
    14 Note that the field name is still valid within the scope of a pattern match, or record update inside the {...} constructor syntax.
     14Note that the field name is still valid within the scope of a pattern match, or record update inside the `{...}` constructor syntax.
     15
     16Example use case: http://www.haskell.org/pipermail/haskell-cafe/2009-May/061879.html (referred from an old Wiki discussion on TDNR http://www.haskell.org/haskellwiki/TypeDirectedNameResolution .)
    1517
    1618
     
    2830type `T` and field label `x` are exported, but not data constructor `MkT`, so `x` is unusable.
    2931
    30 (Without the ‑XNoMonoRecordFields flag, field selector function `x` would be exported.)
     32(Without the `‑XNoMonoRecordFields` flag, field selector function `x` would be exported.)
    3133