Changes between Version 10 and Version 11 of Records/OverloadedRecordFields/OverloadedLabels


Ignore:
Timestamp:
Jun 4, 2017 12:52:14 PM (3 years ago)
Author:
isovector
Comment:

update article so it isn't TypeApplication ignorant

Legend:

Unmodified
Added
Removed
Modified
  • Records/OverloadedRecordFields/OverloadedLabels

    v10 v11  
    1717--    ip :: forall x a. IP x a => a
    1818}}}
    19  * When you write `?x` in an expression, what GHC does today is to replace it with `(ip @ "x" @ alpha)`, where `alpha` is a unification variable and `@` is type application.  (This isn't valid source Haskell, which doesnt have type application, but GHC certainly does have type application internally, so we don't need proxy arguments here.
     19 * When you write `?x` in an expression, what GHC does today is to replace it with `(ip @"x" @alpha)`, where `alpha` is a unification variable and `@` is type application.
    2020
    21  * Of course, that call `(ip @ "x" @ alpha)` gives rise to a constraint `IP "x" alpha`, which must be satisfied by the context.
     21 * Of course, that call `(ip @"x" @alpha)` gives rise to a constraint `IP "x" alpha`, which must be satisfied by the context.
    2222
    2323 * The form `?x` in an expression is only valid with `{-# LANGUAGE ImplicitParameters #-}`
     
    5555Notice that overloaded labels might be useful for all sorts of things that are nothing to do with records; that is why they don't mention "record" in their name.
    5656
    57 User code can call `fromLabel` directly (unlike `ip`), thanks to the proxy argument.  When we have explicit type application we could consider dropping the argument again.
     57User code can call `fromLabel` directly (unlike `ip`), thanks to the proxy argument.
    5858
    5959=== Syntax ===
     
    6161It's not absolutely necessary to use `#x` for a field.  Here are some alternatives:
    6262
    63 * We could use `@x`, though that would prevent it being used for explicit type application (which is common practice in writing, even if the extension to permit it in Haskell syntax hasn't made much progress). This is the syntax used by [http://hackage.haskell.org/package/record-preprocessor record-preprocessor].
    64 
    65 * We could say "if there is at least one data type in scope with a field `x`, then `x` is treated like `(fromLabel @ "x" @ alpha)`".  But I hate it.  And it doesn't work for virtual fields like `#area` above.
     63* We could say "if there is at least one data type in scope with a field `x`, then `x` is treated like `(fromLabel @"x" @alpha)`".  But I hate it.  And it doesn't work for virtual fields like `#area` above.
    6664
    6765* (Suggested by Edward K.)  We could define a magic module `GHC.ImplicitValues`, and say that if you say