[Haskell-cafe] Some thoughts on Type-Directed Name Resolution -record update
Donn Cave
donn at avvanta.com
Fri Feb 10 04:22:44 CET 2012
Quoth AntC <anthony_clayden at clear.net.nz>,
...
> No, Donn, it's not the lack of syntax, it's the lack of semantics for first-
> class (polymorphic) record update. And there's very little that's obvious.
Ah, you're right, I certainly shouldn't have used the word "syntax" there.
But just to be clear on the point, I wonder if you could expand on what
you mean by "polymorphic" above.
I mean, when I wrote
modifyRecord :: RecordType r => (a -> a) -> (r -> a) -> r -> r
... while this does obviously represent a polymorphic function,
if I write
data Config { tempo :: Int, ...}
f = modifyRecord tempo (+20)
... then f has type Config -> Config, it isn't polymorphic.
I am however vaguely aware that some parties to the Record
Question would like to make record fields themselves polymorphic, so
that 'tempo' could be defined for multiple record types and 'f'
would, I suppose, have a type like RecordThatHasTempo r => r -> r
Maybe that's semantically more like "overloading", but in any case,
it isn't strictly necessary in order to support first class updates,
true?
Donn
More information about the Haskell-Cafe
mailing list