You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It turns out that Data.Vector.Generic.unstreamM will more-often-than-not fail to fuse. For evidence look no farther than the implementation:
unstreamM:: (Monadm, Vectorva) =>MBundlemua->m (va)
{-# INLINE_FUSED unstreamM #-}
unstreamM s =do
xs <-MBundle.toList s
return$ unstream $Bundle.unsafeFromList (MBundle.size s) xs
unstreamPrimM:: (PrimMonadm, Vectorva) =>MBundlemua->m (va)
{-# INLINE_FUSED unstreamPrimM #-}
unstreamPrimM s =M.munstream s >>= unsafeFreeze
-- FIXME: the next two functions are only necessary for the specialisationsunstreamPrimM_IO::Vectorva=>MBundleIOua->IO (va)
{-# INLINE unstreamPrimM_IO #-}
unstreamPrimM_IO = unstreamPrimM
unstreamPrimM_ST::Vectorva=>MBundle (STs) ua->STs (va)
{-# INLINE unstreamPrimM_ST #-}
unstreamPrimM_ST = unstreamPrimM
{-# RULES
"unstreamM[IO]" unstreamM = unstreamPrimM_IO
"unstreamM[ST]" unstreamM = unstreamPrimM_ST #-}
Note how unstreamM bundle will materialise the stream contents as a list in all monads except IO and ST. This seems Very Bad, although I'm not sure what can really be done. In principle we could use unstreamPrimM for any PrimMonad, but this of course we can't know during simplification.
The text was updated successfully, but these errors were encountered:
bgamari
added a commit
to bgamari/fcs-sim
that referenced
this issue
Apr 12, 2018
This looks very similar to the issue of traverseing arrays. haskell/primitive#146 shows a way to work around it for appropriate monad transformer stacks on ST and IO. It's also possible to work around for some well-behaved "pure" monads like Either e. I don't know of a more general solution.
It turns out that
Data.Vector.Generic.unstreamM
will more-often-than-not fail to fuse. For evidence look no farther than the implementation:Note how
unstreamM bundle
will materialise the stream contents as a list in all monads exceptIO
andST
. This seems Very Bad, although I'm not sure what can really be done. In principle we could useunstreamPrimM
for anyPrimMonad
, but this of course we can't know during simplification.The text was updated successfully, but these errors were encountered: