[GHC] #9339: last is not a good consumer
GHC
ghc-devs at haskell.org
Mon Jul 21 16:37:32 UTC 2014
#9339: last is not a good consumer
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: | Version: 7.8.3
libraries/base | Keywords:
Resolution: | Operating System: Unknown/Multiple
Differential Revisions: | Type of failure: Runtime
Architecture: | performance bug
Unknown/Multiple | Test Case:
Difficulty: Unknown | Blocking:
Blocked By: |
Related Tickets: |
-------------------------------------+-------------------------------------
Comment (by nomeata):
Still not a full evaluation, but some more factoids:
With
{{{
myLast2 = foldl (\_ x -> x) undefined
}}}
I get
{{{
myLast2 :: forall a. [a] -> a
myLast2 = \ (@ a) -> foldl (myLast1) (undefined)
}}}
while when used (in the same model, non-fusing), this gets turned into the
nice
{{{
Rec {
main_go :: [Int] -> Int -> Int
main_go =
\ (ds :: [Int]) (eta :: Int) ->
case ds of _ {
[] -> eta;
: y ys -> main_go ys y
}
end Rec }
}}}
Writing
{{{
myLast2 = inline foldl (\_ x -> x) undefined
}}}
also gives
{{{
Rec {
myLast1 :: forall a. [a] -> a -> a
myLast1 =
\ (@ a) (ds :: [a]) (eta :: a) ->
case ds of _ {
[] -> eta;
: y ys -> myLast1 ys y
}
end Rec }
myLast2 :: forall a. [a] -> a
myLast2 = \ (@ a) (xs :: [a]) -> myLast1 xs (undefined)
}}}
So it looks good even when not fused. (Measurements are yet pending.)
for the exported module, but when used, it produce
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9339#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list