Specialisation doesn't kick in -- NOW WITH MINIMAL WORKING EXAMPLE (RE: Instantiation of overloaded definition *in Core*)

Simon Peyton Jones simonpj at microsoft.com
Tue Oct 19 07:53:36 UTC 2021


As for opening a ticket – a big part of the problem is that I don’t even know yet if I’m doing something wrong, or GHC is! So it’s not clear what the ticket would even be for – “I’m using the GHC API wrongly” is not a strong bug report 😊

Plenty of tickets turn out to be non-bugs.  But they are still searchable, and form a permanent record that may help others, perhaps in unexpected ways.  So I encourage you to do so.

I successfully compiled the attached Main.hs with HEAD, passing ‘-package ghc’ as a command line argument.

When I run it I get

simonpj at MSRC-3645512:~/tmp$ ./gergo

Missing file: /home/simonpj/code/HEAD-1/compiler/stage1/build/settings

So now I’m stuck again.

Simon

PS: I am leaving Microsoft at the end of November 2021, at which point simonpj at microsoft.com<mailto:simonpj at microsoft.com> will cease to work.  Use simon.peytonjones at gmail.com<mailto:simon.peytonjones at gmail.com> instead.  (For now, it just forwards to simonpj at microsoft.com.)

From: Erdi, Gergo <Gergo.Erdi at sc.com>
Sent: 19 October 2021 02:57
To: Simon Peyton Jones <simonpj at microsoft.com>; 'Matthew Pickering' <matthewtpickering at gmail.com>
Cc: Montelatici, Raphael Laurent <Raphael.Montelatici at sc.com>; 'GHC' <ghc-devs at haskell.org>
Subject: RE: Specialisation doesn't kick in -- NOW WITH MINIMAL WORKING EXAMPLE (RE: Instantiation of overloaded definition *in Core*)


PUBLIC


PUBLIC

Thanks for looking into this!

`Paths_ghc_lib` is referenced just because I am using GHC via ghc-lib. You can of course instead use a local full build of GHC for the libDir. Please find an updated version attached that does that – you’ll just have to adapt the definition of `libDir` to your environment.

As for opening a ticket – a big part of the problem is that I don’t even know yet if I’m doing something wrong, or GHC is! So it’s not clear what the ticket would even be for – “I’m using the GHC API wrongly” is not a strong bug report 😊


From: Simon Peyton Jones <simonpj at microsoft.com<mailto:simonpj at microsoft.com>>
Sent: Saturday, October 16, 2021 12:52 AM
To: Erdi, Gergo <Gergo.Erdi at sc.com<mailto:Gergo.Erdi at sc.com>>; 'Matthew Pickering' <matthewtpickering at gmail.com<mailto:matthewtpickering at gmail.com>>
Cc: Montelatici, Raphael Laurent <Raphael.Montelatici at sc.com<mailto:Raphael.Montelatici at sc.com>>; 'GHC' <ghc-devs at haskell.org<mailto:ghc-devs at haskell.org>>
Subject: [External] RE: Specialisation doesn't kick in -- NOW WITH MINIMAL WORKING EXAMPLE (RE: Instantiation of overloaded definition *in Core*)

I could not compile Main.hs:

~/code/HEAD-1/inplace/bin/ghc-stage1 -c Gergo.hs -package ghc



Gergo.hs:4:1: error:

    Could not find module ‘Paths_ghc_lib’

    Use -v (or `:set -v` in ghci) to see a list of the files searched for.

  |

4 | import qualified Paths_ghc_lib as GHC

  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

simonpj at MSRC-3645512:~/tmp$

Would you like to open a ticket rather than do this by email?

Simon

PS: I am leaving Microsoft at the end of November 2021, at which point simonpj at microsoft.com<mailto:simonpj at microsoft.com> will cease to work.  Use simon.peytonjones at gmail.com<mailto:simon.peytonjones at gmail.com> instead.  (For now, it just forwards to simonpj at microsoft.com<mailto:simonpj at microsoft.com>.)

From: Erdi, Gergo <Gergo.Erdi at sc.com<mailto:Gergo.Erdi at sc.com>>
Sent: 15 October 2021 05:35
To: Simon Peyton Jones <simonpj at microsoft.com<mailto:simonpj at microsoft.com>>; 'Matthew Pickering' <matthewtpickering at gmail.com<mailto:matthewtpickering at gmail.com>>
Cc: Montelatici, Raphael Laurent <Raphael.Montelatici at sc.com<mailto:Raphael.Montelatici at sc.com>>; 'GHC' <ghc-devs at haskell.org<mailto:ghc-devs at haskell.org>>
Subject: RE: Specialisation doesn't kick in -- NOW WITH MINIMAL WORKING EXAMPLE (RE: Instantiation of overloaded definition *in Core*)


PUBLIC


PUBLIC

OK I now have a standalone demonstrator that shows, at least, that the default method implementation is not specialized. With the attached input programs, the resulting Core (using GHC e46edfcf47d674731935b2ea1443cc7927e071fb) is as follows (only showing the relevant parts):

seq :: forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
seq
  = \ (@(m :: * -> *)) (v_srS [Occ=Once1!] :: Monad m) ->
      case v_srS of { C:Monad _ [Occ=Dead] v_srV [Occ=Once1] -> v_srV }

$dmseq :: forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
$dmseq
  = \ (@(m :: * -> *))
      ($dMonad [Occ=Once1] :: Monad m)
      (@a)
      (@b)
      (ma [Occ=Once1] :: m a)
      (mb [Occ=OnceL1] :: m b) ->
      let {
        sat_ss0 [Occ=Once1] :: a -> m b
        [LclId]
        sat_ss0 = \ _ [Occ=Dead] -> mb } in
      bind @m $dMonad @a @b ma sat_ss0

$fMonadIO :: Monad IO
$fMonadIO = C:Monad @IO bindIO $fMonadIO_$cseq;

$fMonadIO_$cseq :: forall a b. IO a -> IO b -> IO b
$fMonadIO_$cseq = \ (@a) (@b) -> $dmseq @IO $fMonadIO @a @b;

foo :: IO ()
foo = seq @IO $fMonadIO @() @() ioA ioA

If I turn on Opt_D_dump_spec, I can see that specializer *is* running, it just doesn’t *do* anything.



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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20211019/b00d6bd7/attachment-0001.html>


More information about the ghc-devs mailing list