Skip to content

Optimise typeKind and TyCon

This ticket records two ideas

  1. TyCon is a sum of six constructors. That means that even tyConUnique requires a six-way branch to get the unique. Moreover quite a few fields are common across all the constructors: Name, Unique, [TyConBinder] etc. So it might be better to represent TyCon as a tuple of all its common fields, with the last field being a 6-way sum for the details.

    See branch wip/T21623-tycon and !9351 (closed). See also #22503 (closed)

    Status: done, landed

  2. typeKind is a heavily used function, but I think it can be made faster. Notably

    typeKind (TyConApp tc tys) = piResultTys (tyConKind tc) tys

    does more work than necessary, esp in the case where the TyCon is saturated and has a closed kind.

    Status: stalled:: I have a branch wip/T21623-faster but puzzlingly it doesn't go faster; it goes slower! I lack the cycles to pursue this, so I'm parking it for now

Edited by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information