Skip to content
  • sheaf's avatar
    32d8fe3a
    Core Lint: ensure primops can be eta-expanded · 32d8fe3a
    sheaf authored
    This patch adds a check to Core Lint, checkCanEtaExpand,
    which ensures that primops and other wired-in functions with
    no binding such as unsafeCoerce#, oneShot, rightSection...
    can always be eta-expanded, by checking that the remaining
    argument types have a fixed RuntimeRep.
    
    Two subtleties came up:
    
      - the notion of arity in Core looks through newtypes, so we may
        need to unwrap newtypes in this check,
      - we want to avoid calling hasNoBinding on something whose unfolding
        we are in the process of linting, as this would cause a loop;
        to avoid this we add some information to the Core Lint environment
        that holds this information.
    
    Fixes #20480
    32d8fe3a
    Core Lint: ensure primops can be eta-expanded
    sheaf authored
    This patch adds a check to Core Lint, checkCanEtaExpand,
    which ensures that primops and other wired-in functions with
    no binding such as unsafeCoerce#, oneShot, rightSection...
    can always be eta-expanded, by checking that the remaining
    argument types have a fixed RuntimeRep.
    
    Two subtleties came up:
    
      - the notion of arity in Core looks through newtypes, so we may
        need to unwrap newtypes in this check,
      - we want to avoid calling hasNoBinding on something whose unfolding
        we are in the process of linting, as this would cause a loop;
        to avoid this we add some information to the Core Lint environment
        that holds this information.
    
    Fixes #20480
Loading