[GHC] #7398: RULES don't apply to a newtype constructor
GHC
cvs-ghc at haskell.org
Thu Nov 8 10:10:12 CET 2012
#7398: RULES don't apply to a newtype constructor
----------------------------------------+-----------------------------------
Reporter: shachaf | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 7.6.1 | Keywords:
Os: Unknown/Multiple | Architecture: Unknown/Multiple
Failure: Incorrect result at runtime | Blockedby:
Blocking: | Related:
----------------------------------------+-----------------------------------
For some reason, RULES that involve a newtype constructor never seem to
fire. The following program demonstrates the problem:
{{{
module Main where
newtype Foo a = Foo { unFoo :: a }
deriving Show
foo :: a -> Foo a
foo = Foo
{-# RULES "rule Foo" forall v. Foo v = error "Foo" #-}
{-# RULES "rule foo" forall v. foo v = error "foo" #-}
main :: IO ()
main = do
print (Foo ())
print (foo ())
}}}
"rule foo" fires, but "rule Foo" doesn't. The program prints
{{{
Foo {unFoo = ()}
D: foo
}}}
Note that this doesn't seem to affect selectors, only constructors.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7398>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list