<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Rowan,<div class=""><br class=""></div><div class="">The problem is that generalizing a let-binding turns something that looks like a constant into a function. This means that repeated use of the variable will evaluate it separately each time. This can be observed to slow down a program. A key point of the monomorphism restriction is to prevent non-functions from actually being functions. This applies equally well to implicit parameters as to other constraints.</div><div class=""><br class=""></div><div class="">Richard<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Mar 24, 2022, at 5:37 PM, rowan goemans <<a href="mailto:goemansrowan@gmail.com" class="">goemansrowan@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" class="">
<div class=""><p class="">Hi Richard,</p><p class="">Thanks for answering. I have made a tiny change to GHC in a fork
that lifts the monomorphization restriction but only for implicit
params. See this commit:
<a class="moz-txt-link-freetext" href="https://gitlab.haskell.org/rowanG/ghc/-/merge_requests/1/diffs?commit_id=35fcad2d7f556706dd129a57815abe421a559861">https://gitlab.haskell.org/rowanG/ghc/-/merge_requests/1/diffs?commit_id=35fcad2d7f556706dd129a57815abe421a559861</a></p><p class="">Is there some example I could run to see in action why the
monomorphisation restriction is required? I looked at the Haskell
report and I don't immediately see why the points raised apply to
implicit params. I get a feeling that monomorph(Contains only a
concrete type like Int or Bool) implicit params would never be a
problem and maybe only polymorphic ones are?</p><p class="">Rowan Goemans<br class="">
</p>
<div class="moz-cite-prefix">On 3/24/22 20:05, Richard Eisenberg
wrote:<br class="">
</div>
<blockquote type="cite" cite="mid:010f017fbd52381d-a86b123e-7216-4cd2-b2ae-3169c8717091-000000@us-east-2.amazonses.com" class="">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" class="">
<br class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On Mar 24, 2022, at 9:04 AM, rowan goemans <<a href="mailto:goemansrowan@gmail.com" class="moz-txt-link-freetext" moz-do-not-send="true">goemansrowan@gmail.com</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class=""><span style="caret-color: rgb(0, 0, 0);
font-family: Helvetica; font-size: 14px; font-style:
normal; font-variant-caps: normal; font-weight: normal;
letter-spacing: normal; text-align: start; text-indent:
0px; text-transform: none; white-space: normal;
word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none; float: none; display: inline
!important;" class="">is this by design/expected though?</span></div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">It is by design, yes. With a sufficiently nuanced
expectation, I would also say it's expected. (Though, to be
fair, if I were not primed to be thinking about the
monomorphism restriction, I can't honestly say I would get it
right if quizzed.)</div>
<br class="">
<blockquote type="cite" class="">
<div class=""><span style="caret-color: rgb(0, 0, 0);
font-family: Helvetica; font-size: 14px; font-style:
normal; font-variant-caps: normal; font-weight: normal;
letter-spacing: normal; text-align: start; text-indent:
0px; text-transform: none; white-space: normal;
word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none; float: none; display: inline
!important;" class="">Would there be interest in fixing
this in GHC?</span></div>
</blockquote>
</div>
<br class="">
<div class="">Figuring out when to generalize a local binding is a
hard problem. So, there is definitely interest in finding a
better way to do it, but I don't think anyone knows a design
that meets the most expectations. Language design is hard! :)</div>
<div class=""><br class="">
</div>
<div class="">Richard</div>
</blockquote>
</div>
_______________________________________________<br class="">Haskell-Cafe mailing list<br class="">To (un)subscribe, modify options or view archives go to:<br class=""><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="">Only members subscribed via the mailman list are allowed to post.</div></blockquote></div><br class=""></div></body></html>