<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">“Inlinable” definitions can be inlined using the “inline” function as explained in the documentation:<div class=""><br class=""></div><div class=""><ul class="simple" style="font-family: "Lucida Grande", "Lucida Sans Unicode", Geneva, Verdana, sans-serif; font-size: 14px; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);"><li class="">One way to use <tt class="literal docutils" style="font-family: Consolas, "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 0.95em;">INLINABLE</tt> is in conjunction with the special function <tt class="literal docutils" style="font-family: Consolas, "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 0.95em;">inline</tt> (<a class="internal reference" href="https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#special-ids" style="color: rgb(43, 98, 140); text-decoration: none;"><em class="">Special built-in functions</em></a>). The call <tt class="literal docutils" style="font-family: Consolas, "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 0.95em;"><span class="pre">inline</span> <span class="pre">f</span></tt> tries very hard to inline <tt class="literal docutils" style="font-family: Consolas, "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 0.95em;">f</tt>. To make sure that <tt class="literal docutils" style="font-family: Consolas, "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 0.95em;">f</tt> can be inlined, it is a good idea to mark the definition of <tt class="literal docutils" style="font-family: Consolas, "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 0.95em;">f</tt> as <tt class="literal docutils" style="font-family: Consolas, "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 0.95em;">INLINABLE</tt>, so that GHC guarantees to expose an unfolding regardless of how big it is. Moreover, by annotating <tt class="literal docutils" style="font-family: Consolas, "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 0.95em;">f</tt> as <tt class="literal docutils" style="font-family: Consolas, "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 0.95em;">INLINABLE</tt>, you ensure that <tt class="literal docutils" style="font-family: Consolas, "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 0.95em;">f</tt>‘s original RHS is inlined, rather than whatever random optimised version of <tt class="literal docutils" style="font-family: Consolas, "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 0.95em;">f</tt> GHC’s optimiser has produced.</li></ul><div class="">Calling the name misleading might be a stretch. I’d be against this if it was up to the libraries list to change it, but I don’t think it’s in scope here.</div><div><br class=""><blockquote type="cite" class=""><div class="">On Jun 8, 2018, at 10:10 AM, Daniel Cartwright <<a href="mailto:chessai1996@gmail.com" class="">chessai1996@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">The "INLINABLE" pragma's name is misleading, it is more like "SPECIALISABLE". Consider the documentation for INLINABLE:<div class=""><br class=""></div><div class=""><div style="margin: 0.8em 0px; padding: 0px; font-family: "Helvetica Neue", Arial, Helvetica, sans-serif; font-size: inherit; text-align: left; background-color: rgb(255, 255, 255);" class="">Top-level definitions can be marked<span class=""> </span><code style="margin:0px;padding:0px;font-family:monospace;line-height:16.12px;background:rgb(240,240,240)" class="">INLINABLE</code>.</div><pre class="gmail-haskell" style="margin: 0px 0px 0px 1em; padding: 0.3em; font-family: monospace; line-height: 1.2; overflow: auto; background-color: rgb(240, 240, 240); border: 1px solid rgb(221, 221, 221); text-align: left; background-position: initial initial; background-repeat: initial initial;">myComplicatedFunction :: (Show a, Num a) => ...
myComplicatedFunction = ...
{-# INLINABLE myComplicatedFunction #-}</pre><div style="margin: 0.8em 0px; padding: 0px; font-family: "Helvetica Neue", Arial, Helvetica, sans-serif; font-size: inherit; text-align: left; background-color: rgb(255, 255, 255);" class="">This causes exactly two things to happens.</div><ol style="margin: 0.8em 0px 0.8em 2em; padding: 0px; font-family: "Helvetica Neue", Arial, Helvetica, sans-serif; font-size: inherit; text-align: left; background-color: rgb(255, 255, 255);" class=""><li style="margin:0px;padding:0px" class="">The function's (exact) definition is included in the interface file for the module.</li><li style="margin:0px;padding:0px" class="">The function will be specialised at use sites -- even across modules.</li></ol><div style="margin: 0.8em 0px; padding: 0px; font-family: "Helvetica Neue", Arial, Helvetica, sans-serif; font-size: inherit; text-align: left; background-color: rgb(255, 255, 255);" class="">Note that GHC is no more keen to inline an<span class=""> </span><code style="margin:0px;padding:0px;font-family:monospace;line-height:16.12px;background:rgb(240,240,240)" class="">INLINABLE</code><span class=""> </span>function than any other.</div>I propose that we deprecate "INLINABLE" over a number of years at the same time as introducing "SPECIALISABLE". This wouldn't cause breakages for a long time.</div></div>
_______________________________________________<br class="">Libraries mailing list<br class=""><a href="mailto:Libraries@haskell.org" class="">Libraries@haskell.org</a><br class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries<br class=""></div></blockquote></div><br class=""></div></body></html>