Specializer doesn't kick in when using GHC API
Migrated from this ghc-devs
thread. The gist of it is that I am trying to use GHC's API to compile a bunch of modules into Core, with specialization turned on.
According to Simon, the default implementation of my seq
method should be specialized for my IO
type. However, the dumped Core shows this is not the case:
foo :: IO ()
foo = seq @IO $fMonadIO @() @() ioA ioA
seq :: forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
seq
= \ (@(m :: * -> *)) (v_srS [Occ=Once1!] :: Monad m) ->
case v_srS of { C:Monad _ [Occ=Dead] v_srV [Occ=Once1] -> v_srV }
$fMonadIO [InlPrag=CONLIKE] :: Monad IO
$fMonadIO = C:Monad @IO bindIO $fMonadIO_$cseq;
$fMonadIO_$cseq [Occ=LoopBreaker] :: forall a b. IO a -> IO b -> IO b
$fMonadIO_$cseq = \ (@a) (@b) -> $dmseq @IO $fMonadIO @a @b;
$dmseq :: forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
$dmseq
= \ (@(m :: * -> *))
($dMonad [Occ=Once1] :: Monad m)
(@a)
(@b)
(ma [Occ=Once1] :: m a)
(mb [Occ=OnceL1] :: m b) ->
let {
sat_ss0 [Occ=Once1] :: a -> m b
[LclId]
sat_ss0 = \ _ [Occ=Dead] -> mb } in
bind @m $dMonad @a @b ma sat_ss0
I would expect there to be an IO
-specialized version of $dmseq
which in turn would use bindIO
directly.
Source file: Main.hs
Input files: