<div dir="ltr">I think your feedback makes perfect sense<div><br></div><div>(to repeat what i said on reddit)</div><div>for <b>MVar</b>: this was an addition Dan Doel and I discussed some years ago but never quite got to. The context is </div><div>1) its totally well behaved (though in isolation theres indeed a valid argument for MutVar instead)</div><div>2) it means theres some off the shelf substrate for userland / library land experimentation with approaches to deterministic parallism/concurrency (a la the LVar package or the like)</div><div>3) more tools for writing mutable thread safe data structures which may have both pure and mutable interfaces.</div><div><br></div><div>as for <b>PrimArray</b> having more operations than the analogous Array and SmallArray, that was definitely an oversight. Its one of those things thats obvious once its said, but easy to lose track of if no one points it out when lost in the weeds</div><div><br></div><div>as for lists/fusion, your points make perfect sense.</div><div><br></div><div>please feel welcome to chip in on infrastructure/code review when you deem it worthwhile! Ryan and myself are definitely spread thin with our various other focii, and i'm told many collaborating hands make light work (ideally :) )</div><div><br></div><div>many thanks :) </div><div>-Carter</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 30, 2018 at 4:19 PM, Dr.Koster <span dir="ltr"><<a href="mailto:drkoster@qq.com" target="_blank">drkoster@qq.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="min-height:22px;margin-bottom:8px">I have make some comments on reddit, but still I want to record them here:</div><div style="min-height:22px;margin-bottom:8px">After reading the new code, I got a feeling that there're some API lacking considerations. Here is some of my personal concerns:</div><div style="min-height:22px;margin-bottom:8px"><div class="m_2405254160606228374Comment__body" style="box-sizing:border-box;overflow-x:hidden;overflow-y:auto"><div class="m_2405254160606228374md" style="box-sizing:border-box"><ol style="box-sizing:border-box;margin-top:0px;margin-bottom:9px"><li style="box-sizing:border-box"><p style="box-sizing:border-box;word-wrap:break-word;word-break:keep-all;margin:0px 0px 9px">The generalized MVar is basically useless because ST is meant to seal its state token, you won't want to add a forkST. You can argue that the atomic operations on MutVar is already added, but still I want to justify its usefulness.</p></li><li style="box-sizing:border-box"><p style="box-sizing:border-box;word-wrap:break-word;word-break:keep-all;margin:0px 0px 9px">There're too much combinators added to PrimArray, is there a plan to port these to other arrays? </p></li><li style="box-sizing:border-box"><p style="box-sizing:border-box;word-wrap:break-word;word-break:keep-all;margin:0px 0px 9px">If we ever provide toList operations, then I would really want it to be a good producer in base's fold-build fusion' view, it's robust and easy to implement, and folding is basically the same speed with List.fold and toList.</p></li></ol><p style="box-sizing:border-box;word-wrap:break-word;word-break:keep-all;margin:0px 0px 9px">Anyway it seems I missed the bike shedding, but still I want to thank for all the efforts, I'll try to follow new GitHub workflow more closely.</p></div></div><div class="m_2405254160606228374Comment__toolsContainer m_2405254160606228374clearfix" style="box-sizing:border-box;overflow:auto"></div></div><div style="min-height:22px;margin-bottom:8px">Cheers </div><div style="min-height:22px;margin-bottom:8px">Winter</div><span class="m_2405254160606228374mail-footer">发自我的iPhone</span><div id="m_2405254160606228374original-content"><br><br><div><div style="font-size:70%;padding:2px 0">------------------ Original ------------------</div><div style="font-size:70%;background:#f0f0f0;color:#212121;padding:8px;border-radius:4px"><div><b>From:</b> Carter Schonwald <<a href="mailto:carter.schonwald@gmail.com" target="_blank">carter.schonwald@gmail.com</a>></div><div><b>Date:</b> Thu,May 31,2018 2:55 AM</div><div><b>To:</b> haskell-cafe <<a href="mailto:haskell-cafe@haskell.org" target="_blank">haskell-cafe@haskell.org</a>>, Haskell Libraries <<a href="mailto:libraries@haskell.org" target="_blank">libraries@haskell.org</a>></div><div><b>Subject:</b> Re: [Haskell-cafe] ANN: primitive 0.6.4.0</div></div></div><div><div class="h5"><br><div dir="ltr">This is a pretty exciting (albeit minor version)<div><br></div><div>I'd like to especially thank David Feuer (treeowl ) and Andrew Martin (andrewthad) for their contributions</div><div><br></div><div>the change log has a huge number of bug fixes relative to 0.6.2-3</div><div><br></div><div>also we added some new modules of features </div><div><br></div><div>PrimArray --- unboxed nonsliceable vectors</div><div>MVar -- Mvars that run in any PrimMonad</div><div><br></div><div>augmented the Data.Primitive exports for increased consistency </div><div>(the new .Ptr and .Mvar modules aren't exported in this minor version so users can easily migrate)</div><div><br></div><div><h2 style="box-sizing:border-box;margin-bottom:16px;font-size:1.5em;font-weight:600;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;margin-top:0px">Changes in version 0.6.4.0</h2><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-size:16px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><li style="box-sizing:border-box"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Introduce<span> </span><code style="box-sizing:border-box">Data.Primitive.<wbr>PrimArray</code>, which offers types and function for dealing with a<span> </span><code style="box-sizing:border-box">ByteArray</code><span> </span>tagged with a phantom type variable for tracking the element type.</p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Implement<span> </span><code style="box-sizing:border-box">isByteArrayPinned</code><span> </span>an<wbr>d<span> </span><code style="box-sizing:border-box">isMutableByteArrayPinned</code>.</p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Add<span> </span><code style="box-sizing:border-box">Eq1</code>,<span> </span><code style="box-sizing:border-box">Ord1</code>,<span> </span><code style="box-sizing:border-box">Show1</code>, and<span> </span><code style="box-sizing:border-box">Read1</code><span> </span>instances for<span> </span><code style="box-sizing:border-box">Array</code><span> </span>and<span> </span><code style="box-sizing:border-box">SmallArray</code>.</p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Improve the test suite. This includes having property tests for typeclasses from<span> </span><code style="box-sizing:border-box">base</code><span> </span>such as<span> </span><code style="box-sizing:border-box">Eq</code>,<span> </span><code style="box-sizing:border-box">Ord</code>,<span> </span><code style="box-sizing:border-box">Functor</code>,<span> </span><code style="box-sizing:border-box">Applicati<wbr>ve</code>,<span> </span><code style="box-sizing:border-box">Monad</code>,<span> </span><code style="box-sizing:border-box">IsList</code>,<span> </span><code style="box-sizing:border-box">Monoid</code>,<span> </span><code style="box-sizing:border-box">Fol<wbr>dable</code>, and<span> </span><code style="box-sizing:border-box">Traversable</code>.</p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Fix the broken<span> </span><code style="box-sizing:border-box">IsList</code><span> </span>instance for<span> </span><code style="box-sizing:border-box">ByteArray</code>. The old definition would allocate a byte array of the correct size and then leave the memory unitialized instead of writing the list elements to it.</p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Fix the broken<span> </span><code style="box-sizing:border-box">Functor</code><span> </span>instance for<span> </span><code style="box-sizing:border-box">Array</code>. The old definition would allocate an array of the correct size with thunks for erroring installed at every index. It failed to replace these thunks with the result of the function applied to the elements of the argument array.</p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Fix the broken<span> </span><code style="box-sizing:border-box">Applicative</code><span> </span>instances of<span> </span><code style="box-sizing:border-box">Array</code><span> </span>and<span> </span><code style="box-sizing:border-box">SmallArray</code>. The old implementation of<span> </span><code style="box-sizing:border-box"><*></code><span> </span>for<span> </span><code style="box-sizing:border-box">Array</code>failed to initialize some elements but correctly initialized others in the resulting<span> </span><code style="box-sizing:border-box">Array</code>. It is unclear what the old behavior of<span> </span><code style="box-sizing:border-box"><*></code><span> </span>was for<span> </span><code style="box-sizing:border-box">SmallArray</code>, but it was incorrect.</p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Fix the broken<span> </span><code style="box-sizing:border-box">Monad</code><span> </span>instances for<span> </span><code style="box-sizing:border-box">Array</code><span> </span>and<span> </span><code style="box-sizing:border-box">SmallArray</code>.</p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Fix the implementation of<span> </span><code style="box-sizing:border-box">foldl1</code><span> </span>in the<span> </span><code style="box-sizing:border-box">Foldable</code><span> </span>instances for<span> </span><code style="box-sizing:border-box">Array</code><span> </span>and<span> </span><code style="box-sizing:border-box">SmallArray</code>. In both cases, the old implementation simply returned the first element of the array and made no use of the other elements in the array.</p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Fix the implementation of<span> </span><code style="box-sizing:border-box">mconcat</code><span> </span>in the<span> </span><code style="box-sizing:border-box">Monoid</code><span> </span>instance for<span> </span><code style="box-sizing:border-box">SmallArray</code>.</p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Implement<span> </span><code style="box-sizing:border-box">Data.Primitive.Ptr</code>, implementations of<span> </span><code style="box-sizing:border-box">Ptr</code><span> </span>functions that require a<span> </span><code style="box-sizing:border-box">Prim</code><span> </span>constraint instead of a<span> </span><code style="box-sizing:border-box">Storable</code><span> </span>constraint.</p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Add<span> </span><code style="box-sizing:border-box">PrimUnlifted</code><span> </span>instances for<span> </span><code style="box-sizing:border-box">TVar</code><span> </span>and<span> </span><code style="box-sizing:border-box">MVar</code>.</p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Use<span> </span><code style="box-sizing:border-box">compareByteArrays#</code><span> </span>for the<span> </span><code style="box-sizing:border-box">Eq</code><span> </span>and<span> </span><code style="box-sizing:border-box">Ord</code><span> </span>instances of<span> </span><code style="box-sizing:border-box">ByteArray</code><span> </span>when building with GHC 8.4 and newer.</p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Add<span> </span><code style="box-sizing:border-box">Prim</code><span> </span>instances for lots of types in<span> </span><code style="box-sizing:border-box">Foreign.C.Types</code><span> </span>and<span> </span><code style="box-sizing:border-box">System.<wbr>Posix.Types</code>.</p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Reexport<span> </span><code style="box-sizing:border-box">Data.Primitive.<wbr>SmallArray</code><span> </span>and<span> </span><code style="box-sizing:border-box">Data.Primitive.<wbr>UnliftedArray</code><span> </span>from<span> </span><code style="box-sizing:border-box">Data.<wbr>Primitive</code>.</p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Add fold functions and map function to<span> </span><code style="box-sizing:border-box">Data.Primitive.<wbr>UnliftedArray</code>. Add typeclass instances for<span> </span><code style="box-sizing:border-box">IsList</code>,<span> </span><code style="box-sizing:border-box">Ord</code>, and<span> </span><code style="box-sizing:border-box">Show</code>.</p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Add<span> </span><code style="box-sizing:border-box">defaultSetByteArray#</code><span> </span>and<span> </span><code style="box-sizing:border-box">d<wbr>efaultSetOffAddr#</code><span> </span>to<span> </span><code style="box-sizing:border-box">Data.<wbr>Primitive.Types</code>.</p></li></ul><br></div></div>

</div></div></div></blockquote></div><br></div>