Skip to content

Mark Generic instances inlineable

Summary

The GHC.Generic methods to and from are currently not marked INLINE when instances are derived with DeriveGeneric. For sufficiently big types, this indeed prevents inlining.

Is there ever a reason not to want them to inline?

Steps to reproduce

Define a sufficiently big data type and try to get to . from to simplify to a strict identity function.

Here's an example with a type with 5 constructors and 12 fields total: https://gist.github.com/Lysxia/b9e3e95a0711f87a84f72555da77801b

Expected behavior

The simplified Core of the above example should not have any GHC.Generics machinery left.

Environment

  • GHC version used: 8.10
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information