GHC doesn't know that seq# produces something in WHNF
data Str a = Str !a
bar :: Maybe a -> IO (Str (Maybe a))
bar x = do
x' <- evaluate x
pure (Str x')
This compiles to
Test.bar1
= \ (@ a_a3Ld)
(x_a3Ah :: Maybe a_a3Ld)
(s_i3Nz :: GHC.Prim.State# GHC.Prim.RealWorld) ->
case GHC.Prim.seq#
@ (Maybe a_a3Ld) @ GHC.Prim.RealWorld x_a3Ah s_i3Nz
of
{ (# ipv_i3NC, ipv1_i3ND #) ->
(# ipv_i3NC, Test.$WStr @ (Maybe a_a3Ld) ipv1_i3ND #)
}
We suspend the application of $WStr
to ipv1_i3ND
, when all we actually need to do is apply Str
directly. We could work around this in base
by defining
evaluate x = IO $ \s ->
case seq# x s of
(# s', !x' #) -> (# s', x' #)
but that seems more than a little bit silly.
Trac metadata
Trac field | Value |
---|---|
Version | 8.4.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | simonmar |
Operating system | |
Architecture |