INLINABLE pragma and newtype wrappers prevent inlining
In #5327 (closed), we allowed case-of-known constructor to see through bindings that were marked as INLINABLE and used newtypes. However, this works only if the newtype does not have a wrapper. The following code, which is the same as T5237 except for the extra type parameters in Size, does not cause the optimization to fire.
{-# LANGUAGE GADTs, ExplicitForAll #-}
module T16254 where
newtype Size a b where
Size :: forall b a. Int -> Size a b
{-# INLINABLE val2 #-}
val2 = Size 17
f n = case val2 of Size s -> s + s > n
The reason is that exprIsConApp_maybe sees $WSize (I# 17#), which is an application with a nontrivial argument. In general, this could cause duplication of work, but in this case we're dealing with a newtype wrapper, so this is safe.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.6.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |