[External] Is Prep supposed to keep thing in (reverse) dependency order?

Erdi, Gergo Gergo.Erdi at sc.com
Fri Nov 4 01:31:03 UTC 2022


PUBLIC

Never mind, I think I got myself confused about different stages of the pipeline. The order of binds generated by Prep is correct, what was tripping me up really was that sat_s2iCp is a local Id bound by a top-level bind. But that's OK, I handle this situation now and everything else works out. Sorry!

-----Original Message-----
From: ghc-devs <ghc-devs-bounces at haskell.org> On Behalf Of √ČRDI Gergo
Sent: Thursday, November 3, 2022 5:47 PM
To: GHC Devs <ghc-devs at haskell.org>
Subject: [External] Is Prep supposed to keep thing in (reverse) dependency order?

ATTENTION: This email came from an external source. Do not open attachments or click on links from unknown senders or unexpected emails. Always report suspicious emails using the Report As Phishing button in Outlook to protect the Bank and our clients.


Hi,

I was under the impression that the Prep'd Core is still in reverse dependency order, i.e. if definition A refers to intra-module definition B, then A's binding will always be preceding B's binding. I've been exploiting this (hopefully not made-up and accidental!) property in my work so far.

However, for the following input:

```

$s$fFunctorFun_$sfmap
   :: forall a b.
      (a -> b)
      -> Fun '[AnnexType, CSASource, Currency, String] a
      -> Fun '[AnnexType, CSASource, Currency, String] b $s$fFunctorFun_$sfmap
   = (\ (@a)
        (@b)
        (f :: a -> b)
        (g :: Fun '[AnnexType, CSASource, Currency, String] a)
        (x1 :: AnnexType) ->
        let {
          g1 :: TFun '[CSASource, Currency, String] a
          g1
            = (g `cast` <Co:32>) x1 } in
        (\ (x2 :: CSASource) ->
           $s$fApplicativeFun_$s$fFunctorFun2
             @Currency
             @a
             @b
             f
             (((g1 `cast` <Co:55>) x2)
           `cast` <Co:22>)
        `cast` <Co:148>)
     `cast` <Co:125>)
```

I am getting the following output from Prep:

```
sat_s2iCp
   :: forall a b.
      (a -> b)
      -> Fun '[AnnexType, CSASource, Currency, String] a
      -> Fun '[AnnexType, CSASource, Currency, String] b sat_s2iCp
   = (\ (@a)
        (@b)
        (f :: a -> b)
        (g :: Fun '[AnnexType, CSASource, Currency, String] a)
        (x1 :: AnnexType) ->
        let {
          g1 :: TFun '[CSASource, Currency, String] a
          g1
            = (g `cast` <Co:32>) x1 } in
        let {
          sat_s2iCo :: CSASource -> Currency -> Fun '[String] b
          sat_s2iCo
            = \ (x2 :: CSASource) ->
                $s$fApplicativeFun_$s$fFunctorFun2
                  @Currency
                  @a
                  @b
                  f
                  (((g1 `cast` <Co:55>) x2) `cast` <Co:22>) } in
        sat_s2iCo
        `cast` <Co:148>)
     `cast` <Co:125>


$s$fFunctorFun_$sfmap
   :: forall a b.
      (a -> b)
      -> Fun '[AnnexType, CSASource, Currency, String] a
      -> Fun '[AnnexType, CSASource, Currency, String] b $s$fFunctorFun_$sfmap
   = \ (@a)
       (@b)
       (eta_B0 :: a -> b)
       (eta_B1 :: Fun '[AnnexType, CSASource, Currency, String] a) ->
       sat_s2iCp @a @b eta_B0 eta_B1
```

Note that the body of `$s$fFunctorFun_$sfmap` has been lifted out to `sat_s2iCp`, but the binding of `sat_s2iCp` precedes the binding of `$s$fFunctorFun_$sfmap`.

Is this expected, for some reason, or is this a GHC bug? If the latter, I'm happy to file a ticket but I can't promise an actual end-to-end compilable reproducer...
_______________________________________________
ghc-devs mailing list
ghc-devs at haskell.org
https://clicktime.symantec.com/15tpDJfA3uiEzBJsnQUvo?h=L7HCari1kV6LycjbY5WpaWCMbvgGs4-4hXbMYMfiHcI=&u=http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

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: //www.sc.com/en/our-locations

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: //www.sc.com/rcs/ and Regulatory Compliance Disclosures at http: //www.sc.com/rcs/fm

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: //www.sc.com/en/regulatory-disclosures/#market-disclaimer.

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: //research.sc.com/research/api/application/static/terms-and-conditions. 

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.

Please visit https: //www.sc.com/en/regulatory-disclosures/dodd-frank/ for important information with respect to derivative products.


More information about the ghc-devs mailing list