<div dir="ltr"><div dir="ltr"><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Sep 11, 2020 at 11:22 PM Anthony Clayden <<a href="mailto:anthony_clayden@clear.net.nz">anthony_clayden@clear.net.nz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><font face="monospace">> On
<span style="color:rgb(0,0,0);font-size:medium">Fri Sep 11 08:08:54 UTC 2020, </span>
<span style="color:rgb(0,0,0);font-size:medium">Viktor Dukhovni wrote:</span></font><div><br></div><div><font face="monospace">> </font><span style="color:rgb(0,0,0);font-family:monospace,monospace;font-size:1em;white-space:pre-wrap">With this particular type, I'd argue the real problem is adding the </span><span style="color:rgb(0,0,0);font-family:monospace,monospace;font-size:1em;white-space:pre-wrap">constraints to the constructors in the first place. </span></div><div><font face="monospace">> </font><span style="color:rgb(0,0,0);font-family:monospace,monospace;font-size:1em;white-space:pre-wrap"> With the </span><span style="color:rgb(0,0,0);font-family:monospace,monospace;font-size:1em;white-space:pre-wrap">constructors unconstrained, one gains the ability to define Functor </span><span style="color:rgb(0,0,0);font-family:monospace,monospace;font-size:1em;white-space:pre-wrap">instances, use Applicatives, ...</span></div><div><span style="color:rgb(0,0,0);font-family:monospace,monospace;font-size:1em;white-space:pre-wrap"><br></span></div><div></div></div></blockquote><div><br></div><div>No that isn't going to work. As Phil Wadler says here</div><div><a href="http://web.archive.org/web/20151001115936/http://code.haskell.org/~dons/haskell-1990-2000/msg04062.html">http://web.archive.org/web/20151001115936/http://code.haskell.org/~dons/haskell-1990-2000/msg04062.html</a><br></div><div>what's really going on is that we want some invariant to hold over the data structure. A set's elements must be unique; so we need `Eq` to be able to test that; but `Eq` alone doesn't capture the whole invariant.</div><div><br></div><div>So take an instance for Functor Set: `fmap` is to apply some arbitrary function to the elements of the set; there's no guarantee that the values returned will still be unique after applying the function. (Indeed there's no guarantee the function's return type is in `Eq`.) Then we need something within the overloading for `fmap` that will check uniqueness; and that'll need an `Eq` constraint.</div><div><br></div><div>Or you decorate every call to those constructor classes/methods with post-processing to fix up the mess. Which obfuscates the logic in your elegant pointfree style.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Or the 'Partial Type Constructors' paper shows a possible approach -- which is really orthogonal to its main topic.<br></div><div><br></div></div></blockquote><div><br></div><div>That paper picks up on a paper from John Hughes 1999, which is tackling exactly the same requirements.</div><div> </div><div>AntC</div></div></div>