GHC: Ticket #2822: Arity expansion not working right <p> With GHC 6.10, the arity of <tt>GHC.Handle.openFile</tt> is reported as 2. But its definition is </p> <pre class="wiki"> openFile fp im = Prelude.catch (...) (...) </pre><p> and <tt>Prelude.catch</tt> has arity 3. Somehow <tt>openFile</tt> isn't getting eta-expanded properly. </p> <p> It's not a huge deal, but arity expansion is an important optimisation so I want to track places it isn't happening. </p> en-us GHC Trac 1.0.1 igloo Sun, 07 Dec 2008 00:28:26 GMT milestone set <ul> <li><strong>milestone</strong> set to <em>6.10 branch</em> </li> </ul> Ticket batterseapower Wed, 14 Jan 2009 10:14:13 GMT <p> This is happening because at the time we compile GHC.Handle, the Prelude module has not yet been compiled. This means that Prelude.catch is pesimistically assumed to have an arity of 0, so openFile can only have an arity as large as the number of leading lambdas it has - i.e. 2. </p> <p> I don't think there is a clean solution for this without whole-program compilation. </p> Ticket simonpj Wed, 14 Jan 2009 15:41:55 GMT owner set <ul> <li><strong>owner</strong> set to <em>igloo</em> </li> </ul> <p> Ian: Max is right. Prelude does export <tt>catch</tt>, and there is a <tt>Prelude.hs-boot</tt>. </p> <p> But maybe that isn't needed any more, with the new exception story. After all, <tt>catch</tt> now seems to be defined in <tt>Control.Exception.Base</tt>, and all <tt>Prelude</tt> does is say </p> <pre class="wiki"> catch = Control.Exception.Base.catch </pre><p> which is not clever, because it pulls the defn of <tt>catch</tt> <strong>higher</strong> in the module graph. </p> <ul><li>Can you see if this particular module loop can be broken? </li><li>More generally, do you have a description of the intended module structure of <tt>base</tt>? Something like this: <a class="wiki" href="">ModuleDependencies</a>. It's very hard to unravel by just looking at the code. </li></ul><p> I'll assign this to you to look at! </p> <p> Simon </p> Ticket simonpj Thu, 15 Jan 2009 09:33:50 GMT status changed; resolution set <ul> <li><strong>status</strong> changed from <em>new</em> to <em>closed</em> </li> <li><strong>resolution</strong> set to <em>fixed</em> </li> </ul> <p> Fixed by </p> <pre class="wiki"> * Move some catch definitions around to avoid an import loop As suggested by simonpj in trac #2822. M ./Prelude.hs -27 +1 R ./Prelude.hs-boot M ./System/IO/Error.hs -2 +27 </pre><p> Thanks, Ian. </p> <p> Simon </p> Ticket simonmar Mon, 16 Nov 2009 13:28:41 GMT failure set <ul> <li><strong>failure</strong> set to <em>Runtime performance bug</em> </li> </ul> Ticket