#2440: Bad code with type families
-----------------------------------------+----------------------------------
Reporter: rl | Owner:
Type: run-time performance bug | Status: new
Priority: normal | Component: Compiler
Version: 6.9 | Severity: normal
Keywords: | Testcase:
Architecture: Unknown | Os: Unknown
-----------------------------------------+----------------------------------
{{{
{-# LANGUAGE TypeFamilies, ScopedTypeVariables #-}
module Foo (foo) where
import Control.Monad.ST
import Data.STRef
class V v where
type M v :: * -> *
rd :: v -> Int -> M v Int
data Vec s = Vec (STRef s Int)
instance V (Vec s) where
type M (Vec s) = ST s
rd (Vec r) n = do
m <- readSTRef r
return (m+n)
foo :: forall s. Vec s -> Int -> ST s Int
foo v n = go n
where
go 0 = return 0
go n = do
m <- rd v n -- :: ST s Int
go m
}}}
ghc -O2 generates rather bad code for this (look at $wfoo). If I uncomment
the type signature in the second to last line, the code becomes much
better. It would be nice if this worked without the signature since I
can't add it in the real code.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2440>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs