Opened 3 years ago

Last modified 3 months ago

#7611 new bug

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

Reported by: nomeata Owned by:
Priority: normal Milestone: 8.0.1
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 3 years ago.

Download all attachments as: .zip

Change History (9)

Changed 3 years ago by nomeata

comment:1 Changed 3 years ago by nomeata

Test case attached; you can also conveniently pull it via

git pull git:// T7611

comment:2 Changed 3 years ago by PHO

  • Cc pho@… added

comment:3 Changed 3 years ago by liyang

  • Cc… added

comment:4 Changed 3 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 3 years ago by igloo

  • difficulty set to Unknown
  • Milestone set to 7.8.1

comment:6 Changed 19 months ago by thoughtpolice

  • Milestone changed from 7.8.3 to 7.10.1

Moving to 7.10.1

comment:7 Changed 11 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 3 months ago by thoughtpolice

  • Milestone changed from 7.12.1 to 8.0.1

Milestone renamed

Note: See TracTickets for help on using tickets.