#1349: Generalise the ! and UNPACK mechanism for data types, to unpack function
arguments
---------------------------------+------------------------------------------
Reporter: simonpj | Owner:
Type: task | Status: new
Priority: low | Milestone: 7.2.1
Component: Compiler | Version: 6.6.1
Keywords: | Testcase:
Blockedby: | Difficulty: Unknown
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
Comment(by batterseapower):
Simon: if the UNPACKed thing was not the first argument e.g.:
{{{
newtype Get a = C { runCont :: forall r.
Failure r ->
{-# UNPACK #-} !S ->
Success a r ->
Result r }
}}}
We might naively expand to this:
{{{
makeC :: (forall r. Failure r -> S -> Success a r -> Result r)
-> Get a
makeC f = Get (\fail i ni ra -> f fail (S i ni ra))
}}}
Could we not avoid a loss of sharing by just inserting a lot of
intermediate bindings:
{{{
newtype Get a = Cw { runCont :: forall r.
Failure r ->
B.ByteString ->
B.ByteString ->
Bool ->
Success a r ->
Result r }
makeC :: (forall r. Failure r -> S -> Success a r -> Result r)
-> Get a
makeC f = Get (\i ni ra -> f (S i ni ra))
makeC f = Get (\fail -> let ffail = f fail in \i ni ra -> ffail (S i ni
ra))
}}}
The simplifier will inline the wrapper and clean up any intermediate
bindings that can be proved to share no expensive work. This seems to
solve the work sharing issue?
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1349#comment:35>
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