Opened 2 years ago

Last modified 6 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.12.1
Component: Compiler Version: 7.6.2
Keywords: Cc: pho@…, hackage.haskell.org@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

I’m moving the discussion from
http://www.haskell.org/pipermail/glasgow-haskell-users/2013-January/023522.html (with reply at http://www.haskell.org/pipermail/glasgow-haskell-users/2013-January/023531.html) 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 2 years ago.

Download all attachments as: .zip

Change History (8)

Changed 2 years ago by nomeata

comment:1 Changed 2 years ago by nomeata

Test case attached; you can also conveniently pull it via

git pull git://git.nomeata.de/ghc-testsuite.git T7611

comment:2 Changed 2 years ago by PHO

  • Cc pho@… added

comment:3 Changed 2 years ago by liyang

  • Cc hackage.haskell.org@… added

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

  • difficulty set to Unknown
  • Milestone set to 7.8.1

comment:6 Changed 14 months ago by thoughtpolice

  • Milestone changed from 7.8.3 to 7.10.1

Moving to 7.10.1

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

Note: See TracTickets for help on using tickets.