<div dir="ltr">I see the type is:<br><br><p class="gmail-src"><a id="gmail-v:freeze" class="gmail-def">freeze</a> :: (<a href="https://hackage.haskell.org/package/primitive-0.6.2.0/docs/Control-Monad-Primitive.html#t:PrimMonad">PrimMonad</a> m, <a href="https://hackage.haskell.org/package/vector-0.12.0.1/docs/Data-Vector-Generic.html#t:Vector">Vector</a> v a) => <a href="https://hackage.haskell.org/package/vector-0.12.0.1/docs/Data-Vector-Generic.html#t:Mutable">Mutable</a> v (<a href="https://hackage.haskell.org/package/primitive-0.6.2.0/docs/Control-Monad-Primitive.html#t:PrimState">PrimState</a> m) a -> m (v a)</p><p class="gmail-src"><br></p><p class="gmail-src">So there is a Vector constrant that MVector will not have. Does the Mutable type family get around this somehow?</p><p class="gmail-src"><br></p><p class="gmail-src">There doesn't seem to be a freeze function specifically for Data.Vector.Unboxed.Mutable.MVector listed at: <a href="https://hackage.haskell.org/package/vector-0.12.0.1/docs/Data-Vector-Unboxed-Mutable.html">https://hackage.haskell.org/package/vector-0.12.0.1/docs/Data-Vector-Unboxed-Mutable.html</a></p><p class="gmail-src">Thanks,</p><p class="gmail-src">Cody<br></p></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Aug 5, 2017 at 9:56 PM, Amos Robinson <span dir="ltr"><<a href="mailto:amos.robinson@gmail.com" target="_blank">amos.robinson@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I think you want "Data.Vector.Generic.freeze", or unsafeFreeze if you are sure you won't modify the mutable vector after making it immutable.<div><a href="https://hackage.haskell.org/package/vector-0.12.0.1/docs/Data-Vector-Generic.html#v:freeze" target="_blank">https://hackage.haskell.org/<wbr>package/vector-0.12.0.1/docs/<wbr>Data-Vector-Generic.html#v:<wbr>freeze</a><br></div></div><br><div class="gmail_quote"><div><div class="h5"><div dir="ltr">On Sun, 6 Aug 2017 at 12:46 Cody Goodman <<a href="mailto:codygman.consulting@gmail.com" target="_blank">codygman.consulting@gmail.com</a><wbr>> wrote:<br></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><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.<wbr>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></div></div><span class="">
______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/haskell-<wbr>cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</span></blockquote></div>
</blockquote></div><br></div>