<div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif">Hi Gergo</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">If you think GHC has a but, can you open a ticket about this?   It's all getting lost in a maze of emails.</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Can you also give precise repro instructions?  In an attempt to reproduce, I have just compiled this module (the code you gave)<br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="margin-left:40px"><span style="font-family:monospace">{-# OPTIONS_GHC -fexpose-all-unfoldings #-}<br><br>module Foo where<br><br></span></div><div class="gmail_default" style="font-family:tahoma,sans-serif;margin-left:40px"><div style="margin-left:40px"><span style="font-family:monospace">nonEmptySubsequences :: [a] -> [[a]]<br>nonEmptySubsequences [] = []<br>nonEmptySubsequences (x:xs) = [x] : foldr f [] (nonEmptySubsequences xs)<br>   where<br>     f ys r = ys : (x:ys) : r<br><br>subsequences            :: [a] -> [[a]]<br>subsequences xs         =  [] : nonEmptySubsequences xs</span></div><div style="margin-left:40px"><br></div></div><div class="gmail_default" style="font-family:tahoma,sans-serif">with HEAD, and -O.  Unlike you, I see both unfoldings in the interface file.  So clearly you and I are doing different things -- but I can't work out what is different without more precision about what you are doing.   (It would be harder if it only happens when you use GHC as a library, but I think you are seeing this behaviour in regular GHC.)</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Thanks</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Simon<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 6 Apr 2022 at 03:05, Erdi, Gergo <<a href="mailto:Gergo.Erdi@sc.com">Gergo.Erdi@sc.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">PUBLIC<br>
<br>
Just so this isn't prematurely all lost, I went back and looked for this example. With the following two definitions:<br>
<br>
subsequences            :: [a] -> [[a]]<br>
subsequences xs         =  [] : nonEmptySubsequences xs<br>
<br>
nonEmptySubsequences         :: [a] -> [[a]]<br>
nonEmptySubsequences []      =  []<br>
nonEmptySubsequences (x:xs)  =  [x] : foldr f [] (nonEmptySubsequences xs)<br>
  where f ys r = ys : (x : ys) : r<br>
<br>
If I save the interface, load it back and look at the unfoldings, I see that `subsequences` has a useful unfolding:<br>
<br>
  subsequences Unf{Src=<vanilla>, TopLvl=True, Value=True,<br>
                   ConLike=True, WorkFree=True, Expandable=True,<br>
                   Guidance=IF_ARGS [0] 30 10}<br>
<br>
Whereas `nonEmptySubsequenes` has a trivial one:<br>
<br>
nonEmptySubsequences OtherCon []<br>
<br>
The interface I save is created from the ModDetails returned by tidyProgram. ExposeAllUnfoldings is set.<br>
<br>
Unfortunately, I am unable to reproduce this from the command line using the GHC executable, so before I put in the effort of making a minimal example of using the GHC API to get this result, I would first like to know if this is even an interesting case, or if there is some explanation for why one of these two would have an unfolding when the other doesn't, in certain cases. <br>
<br>
-----Original Message-----<br>
From: ghc-devs <<a href="mailto:ghc-devs-bounces@haskell.org" target="_blank">ghc-devs-bounces@haskell.org</a>> On Behalf Of Gergo Érdi<br>
Sent: Saturday, April 2, 2022 11:31 AM<br>
To: Simon Peyton Jones <<a href="mailto:simon.peytonjones@gmail.com" target="_blank">simon.peytonjones@gmail.com</a>><br>
Cc: GHC Devs <<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a>>; <a href="mailto:clash-language@googlegroups.com" target="_blank">clash-language@googlegroups.com</a><br>
Subject: [External] Re: Avoiding `OtherCon []` unfoldings, restoring definitions from unfoldings<br>
<br>
<br>
I'm using Prep's output (mostly so that it's in ANF) in my full compilation pipeline, so ideally I would save Prep'd Core in my .hi-equivalents so that I don't have to rerun Prep on them every time I use them.<br>
<br>
I'll get back to you with some concrete examples of `OtherCon []` vs.<br>
meaningful unfoldings next week.<br>
<br>
Merging with my other question about shadowing problems with `toIface*`, in summary it seems that what I really should be doing, is compiling up to Tidy, taking the `CoreBinding`s from there and using `toIfaceBinding` on them to save the definitions.<br>
<br>
This email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please delete all copies and notify the sender immediately. You may wish to refer to the incorporation details of Standard Chartered PLC, Standard Chartered Bank and their subsidiaries at https: //<a href="http://www.sc.com/en/our-locations" rel="noreferrer" target="_blank">www.sc.com/en/our-locations</a><br>
<br>
Where you have a Financial Markets relationship with Standard Chartered PLC, Standard Chartered Bank and their subsidiaries (the "Group"), information on the regulatory standards we adhere to and how it may affect you can be found in our Regulatory Compliance Statement at https: //<a href="http://www.sc.com/rcs/" rel="noreferrer" target="_blank">www.sc.com/rcs/</a> and Regulatory Compliance Disclosures at http: //<a href="http://www.sc.com/rcs/fm" rel="noreferrer" target="_blank">www.sc.com/rcs/fm</a><br>
<br>
Insofar as this communication is not sent by the Global Research team and contains any market commentary, the market commentary has been prepared by the sales and/or trading desk of Standard Chartered Bank or its affiliate. It is not and does not constitute research material, independent research, recommendation or financial advice. Any market commentary is for information purpose only and shall not be relied on for any other purpose and is subject to the relevant disclaimers available at https: //<a href="http://www.sc.com/en/regulatory-disclosures/#market-disclaimer" rel="noreferrer" target="_blank">www.sc.com/en/regulatory-disclosures/#market-disclaimer</a>.<br>
<br>
Insofar as this communication is sent by the Global Research team and contains any research materials prepared by members of the team, the research material is for information purpose only and shall not be relied on for any other purpose, and is subject to the relevant disclaimers available at https: //<a href="http://research.sc.com/research/api/application/static/terms-and-conditions" rel="noreferrer" target="_blank">research.sc.com/research/api/application/static/terms-and-conditions</a>. <br>
<br>
Insofar as this e-mail contains the term sheet for a proposed transaction, by responding affirmatively to this e-mail, you agree that you have understood the terms and conditions in the attached term sheet and evaluated the merits and risks of the transaction. We may at times also request you to sign the term sheet to acknowledge the same.<br>
<br>
Please visit https: //<a href="http://www.sc.com/en/regulatory-disclosures/dodd-frank/" rel="noreferrer" target="_blank">www.sc.com/en/regulatory-disclosures/dodd-frank/</a> for important information with respect to derivative products.<br>
</blockquote></div>