Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,360
    • Issues 5,360
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 567
    • Merge requests 567
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #17958
Closed
Open
Issue created Mar 24, 2020 by Ben Gamari@bgamari🐢Maintainer

Optimise nullary type synonym comparisons and avoid allocating TYPE TyConApps

TysPrim.liftedTypeKind is GHC's representation of the GHC.Type.Type type and consequently works its way into many ASTs. As of GHC 8.10 it has the form TyConApp TYPE ['LiftedPtrRep]. This is unfortunate since we must traverse this type very often during typechecking (e.g. for comparison and unification). This particularly bad in the common case where when we are testing for equality between two liftedTypeKind types.

It would be better if we rather wrote liftedTypeKind in terms of the GHC.Type.Type type synonym: liftedTypeKind = TyConApp typeTyCon []. In this case, comparing two liftedTypeKind types would merely require comparing the keys of the TyCons.

To take advantage of this some changes in our type comparison functions will be needed. Currently our type comparison functions (e.g. GHC.Core.Type.eqType; see list below) expand type synonyms as their first step. However, this leaves some obvious money on the table in the case of nullary type synonyms like Type. It would be much better if we handled the case of nullary TyConApps explicitly to catch the case that they are the same TyCon.

Affected comparison functions:

  • GHC.Core.Type.cmpType
  • TcType.tcEqType
  • TcCanonical.can_eq_nc’
  • GHC.Core.Unify.unify_ty
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking