<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>I think debating the overall idea before implementing is a great idea. Here's my reason why I like these: it allows a library designer to change an internal representation of a previously-concrete datatype while providing backward compatibility. Since the datatype had been exporting its constructors, clients might have used record update. Now the author can change the datatype and add pattern synonyms to keep the interface constant. Without the feature proposed here, such a change would be impossible.</div><div><br></div><div>Furthermore, record update syntax is awfully convenient, and may be attractive to new libraries with abstract types. I haven't tried to do it, but I imagine you could do some cool lens-like constructs with proper (ab)use of this feature.</div><div><br></div><div>Richard</div><br><div><div>On Aug 11, 2015, at 9:05 AM, Dr. ÉRDI Gergő <<a href="mailto:gergo@erdi.hu">gergo@erdi.hu</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><p dir="ltr">Record field updates via patsyns looks very weird to me (and, as just a user, it would be unexpected). Can't we do just matchers and builders for now, and add field updaters as a second step, if there's concensus that it's a Good Idea? </p><p dir="ltr">Bye,<br>
Gergo</p>
<div class="gmail_quote">On 11 Aug 2015 07:11, "Matthew Pickering" <<a href="mailto:matthewtpickering@gmail.com">matthewtpickering@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I was looking at implementing #8582 but before I got too far I thought<br>
it best to clear up a few design points.<br>
<br>
A summary can be found below and a more fleshed out version with some<br>
examples can be found on the wiki page[1].<br>
<br>
My main question is about how best to deal with record updates. Say<br>
that Foo is a record pattern synonym then how would we expect the<br>
following program to behave?<br>
<br>
```<br>
foo a@Foo{..} = a {bar = baz}<br>
```<br>
<br>
Then say that `pattern Foo{bar} = Just bar`, how should the following<br>
two programs behave? Is this partiality any different to that caused<br>
by ordinary use of pattern synonyms? (At least partiality in patterns<br>
is warned but how comprehensive is the coverage?)<br>
<br>
```<br>
foo :: Maybe a -> Maybe Int<br>
foo x = x {bar = 5}<br>
<br>
-- error as `bar` unique determines that we need Foo<br>
bar = Nothing {bar = 5}<br>
```<br>
<br>
Abandoning record updates seems to make record syntax for pattern<br>
synonyms far less useful and confusing to users. Is this design how<br>
others have imagined it? I have cced Gergő who originally implemented<br>
the extension and created #8582.<br>
<br>
Matt<br>
<br>
----<br>
<br>
Unidirectional patterns<br>
* Provide the same ability to match as normal records (RecordWildcards etc)<br>
* Provide selector functions<br>
<br>
Bidirectional patterns<br>
* Provide the constructor which can be used as normal record constructors<br>
<br>
Record Updates - unclear<br>
* Generalise update syntax to arbitrary expressions?<br>
<br>
<br>
[1]: <a href="https://ghc.haskell.org/trac/ghc/wiki/PatternSynonyms#RecordPatternSynonyms" rel="noreferrer" target="_blank">https://ghc.haskell.org/trac/ghc/wiki/PatternSynonyms#RecordPatternSynonyms</a><br>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div>
_______________________________________________<br>ghc-devs mailing list<br><a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs<br></blockquote></div><br></body></html>