<div dir="ltr"><div><div><div>I want to do this so I can use the Data.Vector.Unboxed.Generic functions requiring the Vector constraint, namely the maxIndex function. Implementing maxIndex for Data.Vector.Unboxed.Mutable.MVector would be useful as well, but I'm even more confused at how to do that or where to begin.<br></div><div><br>Here is some stubbed out code demonstrating this.<br><br>{-# Language ScopedTypeVariables #-}<br>module Main where<br><br>import Control.Monad.Primitive<br>import qualified Data.Vector.Unboxed<br>import qualified Data.Vector.Generic as VG<br>import qualified Data.Vector.Unboxed.Mutable as VM<br>import qualified Data.Vector.Unboxed as V<br><br>toImmutable :: VM.MVector RealWorld Int -> V.Vector Int<br>toImmutable = undefined<br><br>main :: IO ()<br>main = do<br>  v :: VM.MVector RealWorld Int <- VM.new 1<br>  VM.write v 0 (3 :: Int)<br>  x <- VM.read v 0<br>  -- y <- VG.head . toImmutable $ v<br>  -- print y<br>  print $ VM.length v<br><br>{-<br></div><div>Thanks,<br><br><br></div><div>Cody<br>-}<br></div></div></div></div>