[GHC] #1349: Generalise the ! and UNPACK mechanism for data
types, to unpack function arguments
GHC
cvs-ghc at haskell.org
Fri May 14 09:29:56 EDT 2010
#1349: Generalise the ! and UNPACK mechanism for data types, to unpack function
arguments
---------------------------------+------------------------------------------
Reporter: simonpj | Owner:
Type: task | Status: new
Priority: normal | Milestone: 6.12.3
Component: Compiler | Version: 6.6.1
Keywords: | Difficulty: Unknown
Os: Unknown/Multiple | Testcase:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
Comment(by tibbe):
While working on a builder monoid for `Data.Text` I ran in to a problem
related to lack of unpacking for continuation arguments. Using these
types:
{{{
data Buffer s = Buffer {-# UNPACK #-} !(A.MArray s Word16)
{-# UNPACK #-} !Int -- offset
{-# UNPACK #-} !Int -- used units
{-# UNPACK #-} !Int -- length left
newtype Builder = Builder {
runBuilder :: forall s. (Buffer s -> ST s [S.Text])
-> Buffer s
-> ST s [S.Text]
}
}}}
the following module generates bad code with lots of boxing and closures:
{{{
module Loop (loop) where
import Data.Monoid (mappend, mempty)
import Data.Text.Lazy.Builder
loop :: Int -> Builder
loop n = go 0 mempty
where
go i acc
| i < n = go (i+1) (acc `mappend` singleton 'a')
| otherwise = acc
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1349#comment:15>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list