Opened 5 years ago

Closed 12 months ago

Last modified 12 months 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 5 years ago.

Download all attachments as: .zip

Change History (13)

Changed 5 years ago by nomeata

comment:1 Changed 5 years ago by nomeata

Test case attached; you can also conveniently pull it via

git pull git:// T7611

comment:2 Changed 5 years ago by PHO

Cc: pho@… added

comment:3 Changed 5 years ago by liyang

Cc:… added

comment:4 Changed 5 years ago by liyang

Type of failure: None/UnknownRuntime performance bug

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: Unknown
Milestone: 7.8.1

comment:6 Changed 3 years ago by thoughtpolice


Moving to 7.10.1

comment:7 Changed 3 years ago by thoughtpolice


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 2 years ago by thoughtpolice


Milestone renamed

comment:9 Changed 20 months ago by thomie

Milestone: 8.0.1

comment:10 Changed 12 months ago by nomeata

Resolution: fixed
Status: newclosed

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

comment:11 Changed 12 months ago by simonpj

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



comment:12 Changed 12 months 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.