<div dir="ltr">
This doesn't seem to eliminate the need for the GHC type checking hack. <div><br></div><div>You still have to instantiate the type of the single argument to ($) with a polytype to typecheck the usual <font face="monospace, monospace">runST $ do ...</font> idiom.<div><br></div><div><p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,250,231)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">Prelude <a href="http://Control.Monad.ST">Control.Monad.ST</a>> runST $ pure ()</span></p>
<p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,250,231)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">()</span></p>
<p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,250,231)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">Prelude <a href="http://Control.Monad.ST">Control.Monad.ST</a>> let ($) a = a</span></p>
<p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,250,231)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">Prelude <a href="http://Control.Monad.ST">Control.Monad.ST</a>> runST $ pure ()</span></p>
<p class="gmail-p2" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,250,231);min-height:13px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,250,231)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><b><interactive>:4:1: </b></span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(255,68,27)"><b>error:</b></span></p>
<p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,250,231)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><b><span class="gmail-Apple-converted-space"> </span>• Couldn't match type ‘forall s. ST s t’ with ‘f0 ()’</b></span></p>
<p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,250,231)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><b><span class="gmail-Apple-converted-space"> </span>Expected type: f0 () -> t</b></span></p>
<p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,250,231)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><b><span class="gmail-Apple-converted-space"> </span>Actual type: (forall s. ST s t) -> t</b></span></p>
<p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,250,231)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><b><span class="gmail-Apple-converted-space"> </span>• In the first argument of ‘($)’, namely ‘runST’</b></span></p>
<p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,250,231)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><b><span class="gmail-Apple-converted-space"> </span>In the expression: runST $ pure ()</b></span></p>
<p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,250,231)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><b><span class="gmail-Apple-converted-space"> </span>In an equation for ‘it’: it = runST $ pure ()</b></span></p>
<p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,250,231)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><b><span class="gmail-Apple-converted-space"> </span>• Relevant bindings include it :: t (bound at <interactive>:4:1)</b></span></p><p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,250,231)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><b><br></b></span></p><div><br></div></div></div><div>-Edward</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 28, 2017 at 12:59 PM, David Feuer <span dir="ltr"><<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">It's still a binary operator syntactically. The negation operator is an entirely different kettle of fish.</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Dec 28, 2017 11:59 AM, "Jeffrey Brown" <<a href="mailto:jeffbrown.the@gmail.com" target="_blank">jeffbrown.the@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"><div dir="ltr">The Wiki says in a few places that Haskell only has one unary operator, negation. those spots would need updating.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 28, 2017 at 8:04 AM, Ryan Trinkle <span dir="ltr"><<a href="mailto:ryan.trinkle@gmail.com" target="_blank">ryan.trinkle@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Agreed. I've always taught ($) as "a parenthesis that goes as far forward as it can". That seems to be a pretty good heuristic for people to use, and it's a whole lot easier than explaining operator precedence in enough detail that the behavior becomes clear from first principles.</div><div class="m_-7285396309124980771m_8471890985839987850HOEnZb"><div class="m_-7285396309124980771m_8471890985839987850h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 27, 2017 at 9:39 PM, Theodore Lief Gannon <span dir="ltr"><<a href="mailto:tanuki@gmail.com" target="_blank">tanuki@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">So far as pedagogy is concerned, ($) is already one of those things people tend to learn how to use before they really understand the mechanism. And for my part, I think if it were immediately obvious that it's just infix id, it would have helped my early understanding of id! +1 from the peanut gallery.</div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_-7285396309124980771m_8471890985839987850m_-3216040986890901516h5">On Dec 27, 2017 6:17 PM, "David Feuer" <<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>> wrote:<br type="attribution"></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_-7285396309124980771m_8471890985839987850m_-3216040986890901516h5"><div dir="ltr"><div dir="auto">Currently, we have something like<div dir="auto"><br></div><div dir="auto"> ($) :: forall r1 r2 (a :: TYPE r1) (b :: TYPE r2).</div><div dir="auto"> (a -> b) -> a -> b</div><div dir="auto"> f $ x = f x</div><div dir="auto"><br></div><div dir="auto">And that's only part of the story: GHC has a hack in the type checker to give ($) an impredicative type when fully applied. This allows it to be used when its function argument requires a polymorphic argument.</div><div dir="auto"><br></div><div dir="auto">This whole complicated situation could be resolved in a very simple manner: change the type and definition thus.</div><div dir="auto"><br></div><div dir="auto"> ($) :: a -> a</div><div dir="auto"> ($) f = f</div><div dir="auto"><br></div><div dir="auto">All the type complications go away altogether, and ($) becomes plain Haskell 98.<br><br>There are only three potential downsides I can think of:</div><div dir="auto"><br></div><div dir="auto">1. The optimizer will see `($) x` as fully applied, which could change its behavior in some cases. There might be circumstances where that is bad. I doubt there will be many.</div><div dir="auto"><br></div><div dir="auto">2. The new type signature may obscure the purpose of the operator to beginners. But based on my experience on StackOverflow, it seems beginners tend to struggle with the idea of ($) anyway; this may not make it much worse. I suspect good Haddocks will help alleviate this concern.</div><div dir="auto"><br></div><div dir="auto">3. Some type family and class instances may not be resolved under certain circumstances which I suspect occur very rarely in practice.</div><div dir="auto"><br></div><div dir="auto"> class C a where</div><div dir="auto"> m :: (a -> a) -> ()</div><div dir="auto"> instance C (a -> b) where</div><div dir="auto"> m _ = ()</div><div dir="auto"> test :: ()</div><div dir="auto"> test = m ($)</div><div dir="auto"><br></div><div dir="auto">Today, this compiles with no difficulties; with the proposed change, the user would have to supply a type signature to make it work:</div><div dir="auto"><br></div><div dir="auto"> test = m (($) :: (a -> b) -> (a -> b))<br><br></div><div>This can also change when an INCOHERENT instance is selected under similarly contrived circumstances, but those who use such generally deserve what they get.<br><br></div><div>David<br></div></div>
</div>
<br></div></div>______________________________<wbr>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/libraries</a><br>
<br></blockquote></div></div>
<br>______________________________<wbr>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/libraries</a><br>
<br></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/libraries</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_-7285396309124980771m_8471890985839987850gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Jeff Brown | Jeffrey Benjamin Brown</div><div dir="ltr"><a href="https://msu.edu/~brown202/" style="font-size:12.8px" target="_blank">Website</a> | <a href="https://www.facebook.com/mejeff.younotjeff" style="font-size:12.8px" target="_blank">Facebook</a> | <a href="https://www.linkedin.com/in/jeffreybenjaminbrown" style="font-size:12.8px" target="_blank">LinkedIn</a><span style="font-size:12.8px">(spammy, so I often miss messages here) </span><span style="font-size:12.8px">|</span><span style="font-size:12.8px"> </span><a href="https://github.com/jeffreybenjaminbrown" style="font-size:12.8px" target="_blank">Github</a><span style="font-size:12.8px"> </span></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
</div>
<br>______________________________<wbr>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/libraries</a><br>
<br></blockquote></div></div>
</div></div><br>______________________________<wbr>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/libraries</a><br>
<br></blockquote></div><br></div></div>