Opened 4 years ago

Closed 5 weeks ago

Last modified 5 weeks ago

#7611 closed bug (fixed)

Rewrite rules application prevented by type variable application (map id vs. map (\x -> x))

Reported by: nomeata Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.6.2
Keywords: Cc: pho@…,…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


I’m moving the discussion from (with reply at here, as a reminder for myself to work on it someday:

Short summary: a rule "map (\x -> x) = id" will not match "map id" because the latter has (in Core) an application of a type variable, despite the matcher looking through the definition of id. Doing beta-reduction (of type applications) in the matcher could fix this.

I’ll attach a test case.

Attachments (1)

0001-Add-test-case-for-7611.patch (2.0 KB) - added by nomeata 4 years ago.

Download all attachments as: .zip

Change History (13)

Changed 4 years ago by nomeata

comment:1 Changed 4 years ago by nomeata

Test case attached; you can also conveniently pull it via

git pull git:// T7611

comment:2 Changed 4 years ago by PHO

  • Cc pho@… added

comment:3 Changed 4 years ago by liyang

  • Cc… added

comment:4 Changed 4 years ago by liyang

  • Type of failure changed from None/Unknown to Runtime performance bug
  • Version changed from 7.6.1 to 7.6.2

I think this may be related, but in this case I can't see what rule I could possibly write that would fire:

{-# LANGUAGE TypeFamilies #-}
type family Unit a :: *
type instance Unit Integer = ()

{-# INLINE [1] int #-}
{-# RULES "int" int = fromInteger :: Integer -> Int #-}

-- int :: (Integral i, Unit i ~ ()) => i -> Int -- doesn't fire
int :: (Integral i) => i -> Int -- fires
int = fromIntegral

comment:5 Changed 4 years ago by igloo

  • difficulty set to Unknown
  • Milestone set to 7.8.1

comment:6 Changed 2 years ago by thoughtpolice

  • Milestone changed from 7.8.3 to 7.10.1

Moving to 7.10.1

comment:7 Changed 22 months ago by thoughtpolice

  • Milestone changed from 7.10.1 to 7.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:8 Changed 14 months ago by thoughtpolice

  • Milestone changed from 7.12.1 to 8.0.1

Milestone renamed

comment:9 Changed 9 months ago by thomie

  • Milestone 8.0.1 deleted

comment:10 Changed 5 weeks ago by nomeata

  • Resolution set to fixed
  • Status changed from new to closed

This is actually fixed, at least in 7.10, most likely by changeset:a27b2985511800fa3b740fef82ad3da9c8683302/ghc.

comment:11 Changed 5 weeks ago by simonpj

Great! Might you add a test case to make sure it stays fixed?



comment:12 Changed 5 weeks ago by Joachim Breitner <mail@…>

In 97b47d27/ghc:

Add test case for #7611

basically using the machinery from the test case of #2110.
Note: See TracTickets for help on using tickets.