Unbox around runRW#
Because runRW# inlines so late, we don't end up unboxing around it. For example, suppose we write
f x = runST $ do
mar <- newArray 100 x
unsafeFreeze mar
This will compile to something like
f x = case runRW# (\s ->
case newArray# 100# x s of { (# s', mar #) ->
case unsafeFreezeArray# mar s' of { (# s'', ar# #) ->
(# s'', Array ar# #) }}) of
(# _, ar #) -> ar
We generally want to pull the constructor application out of the runRW# argument:
f x = case runRW# (\s ->
case newArray# 100# x s of { (# s', mar #) ->
unsafeFreezeArray# mar s' }) of
(# _, ar# #) -> Array ar#
This exposes the Array constructor to case-of-case.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.4.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | low |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |