Specializing functions with implicit parameters

Simon Peyton Jones simonpj at microsoft.com
Mon Mar 16 17:08:31 UTC 2020


Spot on Alexis.    Should not be hard to fix this.

I think the best thing would be in mkCallUDs

  *   not to use SpecDict for implicit parameters; instead use UnspecArg
  *   don’t require length theta = length dicts.  Need to think about what else instead.  Isn’t it implied by the arity test?

Make a ticket!  Happy to help if you or Sandy need anything from me.

Simon


From: ghc-devs <ghc-devs-bounces at haskell.org> On Behalf Of Alexis King
Sent: 15 March 2020 02:47
To: Sandy Maguire <sandy at sandymaguire.me>
Cc: ghc-devs <ghc-devs at haskell.org>
Subject: Re: Specializing functions with implicit parameters

On Mar 14, 2020, at 20:03, Sandy Maguire <sandy at sandymaguire.me<mailto:sandy at sandymaguire.me>> wrote:

What GHC are you testing against? I suspect https://gitlab.haskell.org/ghc/ghc/merge_requests/668<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.haskell.org%2Fghc%2Fghc%2Fmerge_requests%2F668&data=02%7C01%7Csimonpj%40microsoft.com%7Cfc70cfc46c7146c59bd008d7c88b2c76%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637198372382352399&sdata=C%2BzhSCJ2EREtrQD%2FZedu03w0NxQKOnszWKXiKY5cSc4%3D&reserved=0> will fix this.

I’ve tested against HEAD. I think the change you link is helpful, but it doesn’t quite get there: the usage gets dumped before specHeader even gets a chance to look at the call. The relevant bit of code is here:

https://gitlab.haskell.org/ghc/ghc/blob/1de3ab4a147eeb0b34b24a3c0e91f174e6e5cb79/compiler/specialise/Specialise.hs#L2274-2302<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.haskell.org%2Fghc%2Fghc%2Fblob%2F1de3ab4a147eeb0b34b24a3c0e91f174e6e5cb79%2Fcompiler%2Fspecialise%2FSpecialise.hs%23L2274-2302&data=02%7C01%7Csimonpj%40microsoft.com%7Cfc70cfc46c7146c59bd008d7c88b2c76%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637198372382352399&sdata=qfC7hSxoWNABKLpgJe6kqzTeDG1jmLwyane9W8UCOh4%3D&reserved=0>

Specifically, this line seals the deal:

    ClassPred cls _ -> not (isIPClass cls)  -- Superclasses can't be IPs

So maybe the right fix is just to change the role of type_determines_value so that it turns SpecDicts into UnspecArgs, and then with your change everything would just happily work out.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20200316/ea104cdd/attachment.html>


More information about the ghc-devs mailing list