Is simplified subsumption really necessary?

Simon Peyton Jones simonpj at microsoft.com
Sun Jun 20 21:22:38 UTC 2021


Yes, maybe the seq thing would be possible.   But it feels like a hack, and I'm far from convinced that the optimiser would really eliminate the overhead.    If I was convinced that deep subsumption was really better, it might be worth investigating the hack more deeply.   But in fact I've become convinced of the opposite, that deep subsumption just isn't worth the extra complexity - the simpler system allows Quick Look for example.

Simon

From: John Ericson <john.ericson at obsidian.systems>
Sent: 20 June 2021 18:07
To: ghc-devs <ghc-devs at haskell.org>; Simon Peyton Jones <simonpj at microsoft.com>
Subject: Re: Is simplified subsumption really necessary?


I'm sorry, I misunderstood the paper and thought the depth of the instantiation and subsumption could be varied more independently.

That said, what about the seq example below? Does forcing any function that is eta expanded like that sketchy to you? There is still a runtime cost to the eta expansion, but think with more elbow grease that could also be addressed (post-type-erasure optimization or new coercions).

John
On 6/18/21 3:56 PM, Simon Peyton Jones wrote:
Richard's paper argues for lazy rather than eager instantiation.

It does not argue for deep rather than shallow subsumption and instantiation; on the contrary, it argues for shallow.  (That is, for "simple subsumption".)   And it is simple subsumption that is the focus of this conversation.

Simon

From: John Ericson <john.ericson at obsidian.systems><mailto:john.ericson at obsidian.systems>
Sent: 18 June 2021 16:56
To: ghc-devs <ghc-devs at haskell.org><mailto:ghc-devs at haskell.org>
Cc: Simon Peyton Jones <simonpj at microsoft.com><mailto:simonpj at microsoft.com>
Subject: Re: Is simplified subsumption really necessary?


On 6/16/21 12:00 PM, Simon Peyton Jones via ghc-devs wrote:
 I'm sorry to hear that Chris.   It's exactly backwards from what I would expect - the typing rules with simple subsumption are, well, simpler than those for complicated subsumption, and so one might hope that your intuition had fewer complexities to grapple with.

In https://richarde.dev/papers/2021/stability/stability.pdf<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fricharde.dev%2Fpapers%2F2021%2Fstability%2Fstability.pdf&data=04%7C01%7Csimonpj%40microsoft.com%7Cb9916cabe3744e44375008d9340dca51%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637598056497592691%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=SqgQIEVpLIARanGOqvKDNOjG%2FtLFZ6v1XVXzCFD1FQE%3D&reserved=0> it is written

The analysis around stability in this paper strongly suggests that GHC should use the lazy, shallow approach to instantiation. Yet the struggles with lazy instantiation above remain. In order to simplify the implementation, GHC has recently (for GHC 9.0) switched to use exclusively eager instantiation.This choice sacrifices stability for convenience in implementation.

I think the principles outlined in the paper are very good, and explain the queasiness some users may feel in 9.0

But wouldn't it be possible to choose a desugaring with seq that doesn't do so?

I just don't know how to do that.  Maybe someone else does.

Is it not

  f `seq` \x -> f x

and similar? I haven't thought about the issue in a while or in very much depth, but when I first discussed the proposal years back with some other people at work, they spit-balled the same counter-proposal.

----

Having little "skin in the game" as I haven't yet ported any serious programs over to 9.0, I suppose I am glad the experimentation with QuickLook is happening, and OK that our accepting on-par fewer programs now opens design space for later (i.e. we got the breakage out of the way.) But I certainly think there are improvements in the spirit outlined in Richard's paper to be done down the road.

John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20210620/285f8d21/attachment.html>


More information about the ghc-devs mailing list