optimiseStm :: Stm Kernels -> UnstreamM [Stm Kernels]
optimiseStm (Let pat aux (Op (Kernel desc space ts body))) = do
  stms' <- localScope (scopeOfKernelSpace space) $
           runBinder_ $ optimiseInKernelStms $ kernelBodyStms body
  return [Let pat aux $ Op $ Kernel desc space ts $ body { kernelBodyStms = stms' }]
optimiseStm :: Stm Kernels -> UnstreamM [Stm Kernels]
optimiseStm (Let pat aux (Op (Kernel desc space ts body))) = do
  stms' <- localScope (scopeOfKernelSpace space) $
           runBinder_ $ optimiseInKernelStms $ kernelBodyStms body
  return [Let pat aux $ Op $ Kernel desc space ts $ body { kernelBodyStms = stms' }]
optimiseStm (Let pat aux (Op (Kernel desc space ts body))) = do
  stms' <- localScope (scopeOfKernelSpace space) $
           runBinder_ $ optimiseInKernelStms $ kernelBodyStms body
  return [Let pat aux $ Op $ Kernel desc space ts $ body { kernelBodyStms = stms' }]