Skip to content

GitLab

  • Menu
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 4,868
    • Issues 4,868
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 456
    • Merge requests 456
  • 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 Compiler
  • GHCGHC
  • Issues
  • #18557
Closed
Open
Created Aug 10, 2020 by Simon Peyton Jones@simonpjDeveloper

NOINLINE and INLINABLE should be legal together

Suppose (see #17752 (closed)) we have a recursive function with a RULE

elem :: Eq a => a -> [a] -> [a]
{-# NOINLNE[1] elem #-}
elem = ...elem...

{-# RULES
"elem/build"    forall x (g :: forall b . (a -> b -> b) -> b -> b)
   . elem x (build g) = g (\ y r -> (x == y) || r) False
 #-}

The NOINLINE pragma is there to ensure elem doesn't inline before the RULE has had a chance to fire.

But after it's had its chance to fire (and failed to do so) we may well want to specialise elem. Since it is recursive we'd usually write

{-# INLINABLE  elem #-}  

But GHC doesn't allow that:

test.hs:24:15: error:
    Duplicate INLINABLE pragmas for `elem'
-}

We should make it possible to have both a NOLININE[n] pragma and an INLINABLE pragma. There's no contradiction!

We might want to warn about NOLININE vs INLINABLE since it's silly to keep the unfolding for a function that cannot, ever, be inlined.

We'd need to take care that specialisation rules don't fire if we in an NOINLNE phase.

Edited Aug 10, 2020 by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking