Opened 15 months ago

Last modified 12 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: 7.8.3
Component: Compiler Version: 7.6.2
Keywords: Cc: pho@…,…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:


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 15 months ago.

Download all attachments as: .zip

Change History (6)

Changed 15 months ago by nomeata

comment:1 Changed 15 months ago by nomeata

Test case attached; you can also conveniently pull it via

git pull git:// T7611

comment:2 Changed 15 months ago by PHO

  • Cc pho@… added

comment:3 Changed 14 months ago by liyang

  • Cc… added

comment:4 Changed 14 months 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 12 months ago by igloo

  • Difficulty set to Unknown
  • Milestone set to 7.8.1
Note: See TracTickets for help on using tickets.