<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>