
#14882: memchr# -------------------------------------+------------------------------------- Reporter: andrewthad | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by andrewthad): That does work. However, I prefer to avoid using the FFI where possible. My reasons (which I’ll admit are not entirely compelling) are: it’s syntactically unappealing, it prevents optimizations (barely relevant in this case though), and it doesn’t work with GHCJS. I noticed from looking at the source for Data.Primitive.ByteArray that copyByteArray# and friends weren’t always provided by GHC.Prim. https://hackage.haskell.org/package/primitive-0.6.3.0/docs/src/Data- Primitive-ByteArray.html#MutableByteArray For super old GHCs, they were just an FFI call to memcpy. But these were eventually brought into GHC.Prim. I don’t know why this decision was made, but I’m glad that it was. I would like more ByteArray operations that correspond to manually super optimized standard c library functions to be made available as primitives. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14882#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler