Overloaded state-monadic function is not specialised
I have a simple typeclass-polymorphic function which fails to specialise. Here is module A which defines the function overloaded:
module A where
import Control.Monad.Trans.State
import Control.Monad
overloaded :: Ord a => a -> a -> State () ()
overloaded x y = do
() <- get
when (x <= y) (overloaded y x)
In module B I use overloaded on Ints:
module B where
import A
import Control.Monad.Trans.State
specialised :: Int -> Int -> ()
specialised x y = execState (A.overloaded x y) ()
Unfortunately the generated code is not specialised but passes an Ord dictionary around. It doesn't make any difference if I mark overloaded as INLINEABLE or not.
In the core file, overloaded has been worker-wrapper transformed but the worker is marked INLINEABLE[0] - so I'm not sure why it's not being specialised. Curiously, if I make overloaded be a normal function instead of one in the state monad, or if I replace () <- get with simply get, specialisation goes through fine.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.10.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |