On Tue, Feb 1, 2011 at 9:23 PM, Ben Millwood <span dir="ltr">&lt;<a href="mailto:haskell@benmachine.co.uk">haskell@benmachine.co.uk</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Tue, Feb 1, 2011 at 9:52 AM, Max Bolingbroke<br>
&lt;<a href="mailto:batterseapower@hotmail.com">batterseapower@hotmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Local declarations at module scope can be emulated using pattern bindings:<br>
&gt;<br>
&gt; &quot;&quot;&quot;<br>
&gt; (foo, bar) = (foo, bar)<br>
&gt;  where<br>
&gt;    foo = ..<br>
&gt;    bar = ..<br>
&gt;    private = ...<br>
&gt; &quot;&quot;&quot;<br>
&gt;<br>
&gt; If instance declarations supported pattern bindings you could get the<br>
&gt; same effect for your instances too. This would be a minimal change<br>
&gt; that avoided introducing any extra syntax.<br></div></blockquote><div><br></div><div>It&#39;s a nice trick! Although it does look strange, it may be reasonable to allow pattern bindings in instance declarations regardless of the original proposal. Is it correct that, currently, pattern bindings are allowed everywhere but in instance declarations? If so, why not in instance declarations too?</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">This is kind of ugly, I think, and there are proposals to make pattern</div>
bindings monomorphic which would make this sort of thing no longer<br>
possible in general.</blockquote><div><br></div><div>I think the proposals to make pattern bindings monomorphic only concern pattern bindings without type annotations. Instance methods do have type annotations in the class declaration so even if pattern bindings without type signatures would be monomorphic, instance methods bound using pattern bindings need not be.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> I think I would be in favour of a declaration analogue to let.</blockquote><div><br></div><div>I agree that using pattern bindings for the original task would work around a missing syntax extension. But at least this workaround may be easily implementable and making it possible seems to fix an inconsistency by making the use of pattern bindings more orthogonal.</div>
<div><br></div><div>Sebastian</div></div>