primitive
Primitive memory-related operations
https://github.com/haskell/primitive
Version on this page: | 0.9.0.0@rev:1 |
LTS Haskell 22.39: | 0.8.0.0@rev:1 |
Stackage Nightly 2024-10-31: | 0.9.0.0@rev:2 |
Latest on Hackage: | 0.9.0.0@rev:2 |
primitive-0.9.0.0@sha256:2e08c5409e3559c7f1669ef50e9a0d9a397e68ecf51110d5e2cedf05cdd7d93c,3171
Module documentation for 0.9.0.0
This package provides various primitive memory-related operations.
Changes
Changes in version 0.9.0.0
-
Add
withByteArrayContents
,withMutableByteArrayContents
,withPrimArrayContents
,withMutablePrimArrayContents
. -
Fix signature of
keepAlive
. -
Remove re-export of
fromList
andfromListN
fromData.Primitive.Array
. -
Use
mutableByteArrayContents#
in GHC 9.2+ -
Add
Prim
instance forComplex
. -
Add
getSizeofSmallMutableArray
that wrapsgetSizeofSmallMutableArray#
fromGHC.Exts
. -
Add default definitions for the
setByteArray#
andsetOffAddr#
methods, so they don’t need to be defined explicitly anymore. -
Add standalone
sizeOfType
/alignmentOfType
(recommended oversizeOf
/alignment
) andPrim
class methodssizeOfType#
/alignmentOfType#
(recommended oversizeOf#
/alignment#
) -
Change
Show
instances ofPrimArray
,Array
, andSmallArray
. These previously used thefromListN n [...]
form, but they now used the more terse[...]
form. -
Correct the
Read
instances ofArray
andSmallArray
. These instances are supposed to be able to handle all three of these forms:fromList [...]
,fromListN n [...]
, and[...]
. They had been rejected the last form, but this mistake was discovered by the test suite when the Show instances were changed.
Changes in version 0.8.0.0
-
Add
resizeSmallMutableArray
that wrapsresizeSmallMutableArray#
fromGHC.Exts
. -
New module
Data.Primitive.PrimVar
. This is essentiallyPrimArray
with element length 1. For types withPrim
instances, this is a drop-in replacement forMutVar
with fewer indirections. -
PrimArray
’s type argument has been given a nominal role instead of a phantom role. This is a breaking change. -
Add
readCharArray
,writeCharArray
,indexCharArray
for operating on 8-bit characters in a byte array. -
When building with
base-4.17
and newer, re-export theByteArray
andMutableByteArray
types frombase
instead of defining them in this library. This does not change the user-facing interface ofData.Primitive.ByteArray
. -
Add
keepAlive
that wrapskeepAlive#
for GHC 9.2 and newer. It falls back to usingtouch
for older GHCs.
Changes in version 0.7.4.0
-
Add Lift instances (#332)
-
Expose
copyPtrToMutablePrimArray
-
Improve definitions for stimes (#326)
-
Support GHC 9.4. Note: GHC 9.4 is not released at the time of primitive-0.7.4.0’s release, so this support might be reverted by a hackage metadata revision if things change.
-
Drop support for GHC 7.10
Changes in version 0.7.3.0
-
Correct implementations of
*>
forArray
andSmallArray
. -
Drop support for GHC < 7.10
-
Export
runByteArray
andrunPrimArray
. -
Export
createArray
andcreateSmallArray
. -
Export
emptyByteArray
,emptyPrimArray
,emptyArray
andemptySmallArray
.
Changes in version 0.7.2.0
-
Add
thawByteArray
andthawPrimArray
. -
Changed the
Show
instance ofByteArray
, so that all 8-bit words are rendered as two digits. For example, display0x0D
instead of0xD
.
Changes in version 0.7.1.0
-
Introduce convenience class
MonadPrim
andMonadPrimBase
. -
Add
PrimMonad
andPrimBase
instances forLazy.ST
(GHC >= 8.2). thanks to Avi Dessauer (@Avi-D-coder) for this first contribution -
Add
freezeByteArray
andfreezePrimArray
. -
Add
compareByteArrays
. -
Add
shrinkMutableByteArray
. -
Add
Eq
instances forMutableByteArray
andMutablePrimArray
. by Andrew Martin -
Add functions for manipulating pinned Prim Arrays by Andrew Martin
-
Add
copyPtrToMutableByteArray
. -
Add
NFData
instances forByteArray
,MutableByteArray
,PrimArray
andMutablePrimArray
. by Callan McGill -
Add
shrinkSmallMutableArray
. -
Add
clonePrimArray
andcloneMutablePrimArray
. -
Add
cloneMutableByteArray
andcloneByteArray
. -
Add
Prim
instances forWordPtr
andIntPtr
. -
Add
NFData
instances forArray
andSmallArray
. by Callan McGill -
Add
copyByteArrayToPtr
andcopyMutableByteArrayToPtr
. -
Export
arrayFromList
andarrayFromListN
.
Changes in version 0.7.0.1
- Allow building with GHC 8.12. Thanks Ryan GL Scott for this and every compat patch over time.
Changes in version 0.7.0.0
-
Remove
Addr
data type, lifted code should usePtr a
now -
Define
MonadFail
instances forArray
andSmallArray
. -
Define
unsafeInterleave
. -
Add a
Prim
instance forStablePtr
-
Remove
UnliftedArray
and related type classes -
Add a lot more tests for
PrimArray
. -
Added PrimMonad instance for CPS Writer and RWS monads from Transformers
-
Remove useless accidental laziness in
atomicModifyMutVar
, making it matchatomicModifyIORef
. The semantics should be the same. -
lots of little documentation twiddles.
Changes in version 0.6.4.1
-
Add instances for the following newtypes from
base
:Const
,Identity
,Down
,Dual
,Sum
,Product
,First
,Last
,Min
,Max
-
Add
base-orphans
dependency to test suite to accomodate older versions of GHC not having instances ofShow
andEq
for some of the above newtypes.
Changes in version 0.6.4.0
-
Introduce
Data.Primitive.PrimArray
, which offers types and function for dealing with aByteArray
tagged with a phantom type variable for tracking the element type. -
Implement
isByteArrayPinned
andisMutableByteArrayPinned
. -
Add
Eq1
,Ord1
,Show1
, andRead1
instances forArray
andSmallArray
. -
Improve the test suite. This includes having property tests for typeclasses from
base
such asEq
,Ord
,Functor
,Applicative
,Monad
,IsList
,Monoid
,Foldable
, andTraversable
. -
Fix the broken
IsList
instance forByteArray
. 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. -
Fix the broken
Functor
instance forArray
. 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. -
Fix the broken
Applicative
instances ofArray
andSmallArray
. The old implementation of<*>
forArray
failed to initialize some elements but correctly initialized others in the resultingArray
. It is unclear what the old behavior of<*>
was forSmallArray
, but it was incorrect. -
Fix the broken
Monad
instances forArray
andSmallArray
. -
Fix the implementation of
foldl1
in theFoldable
instances forArray
andSmallArray
. 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. -
Fix the implementation of
mconcat
in theMonoid
instance forSmallArray
. -
Implement
Data.Primitive.Ptr
, implementations ofPtr
functions that require aPrim
constraint instead of aStorable
constraint. -
Add
PrimUnlifted
instances forTVar
andMVar
. -
Use
compareByteArrays#
for theEq
andOrd
instances ofByteArray
when building with GHC 8.4 and newer. -
Add
Prim
instances for lots of types inForeign.C.Types
andSystem.Posix.Types
. -
Reexport
Data.Primitive.SmallArray
andData.Primitive.UnliftedArray
fromData.Primitive
. -
Add fold functions and map function to
Data.Primitive.UnliftedArray
. Add typeclass instances forIsList
,Ord
, andShow
. -
Add
defaultSetByteArray#
anddefaultSetOffAddr#
toData.Primitive.Types
. -
Add
Data.Primitive.MVar
, a replacement forControl.Concurrent.MVar
that can run in anyPrimMonad
instead of justIO
. It is not a full replacement. Notably, it’s missing masking functions and support for adding finalizers.
Changes in version 0.6.3.0
-
Add
PrimMonad
instances forContT
,AccumT
, andSelectT
fromtransformers
-
Add
Eq
,Ord
,Show
, andIsList
instances forByteArray
-
Add
Semigroup
instances forArray
andSmallArray
. This allowsprimitive
to build on GHC 8.4 and later.
Changes in version 0.6.2.0
-
Drop support for GHCs before 7.4
-
SmallArray
support -
ArrayArray#
based support for more efficient arrays of unlifted pointer types -
Make
Array
and the like instances of various classes for convenient use -
Add
Prim
instances for Ptr and FunPtr -
Add
ioToPrim
,stToPrim
and unsafe counterparts for situations that would otherwise require type ascriptions onprimToPrim
-
Add
evalPrim
-
Add
PrimBase
instance forIdentityT
Changes in version 0.6.1.0
-
Use more appropriate types in internal memset functions, which prevents overflows/segfaults on 64-bit systems.
-
Fixed a warning on GHC 7.10
-
Worked around a -dcore-lint bug in GHC 7.6/7.7
Changes in version 0.6
-
Split PrimMonad into two classes to allow automatic lifting of primitive operations into monad transformers. The
internal
operation has moved to thePrimBase
class. -
Fixed the test suite on older GHCs
Changes in version 0.5.4.0
-
Changed primitive_ to work around an oddity with GHC’s code generation on certain versions that led to side effects not happening when used in conjunction with certain very unsafe IO performers.
-
Allow primitive to build on GHC 7.9
Changes in version 0.5.3.0
- Implement
cloneArray
andcloneMutableArray
primitives (with fall-back implementations for GHCs prior to version 7.2.1)
Changes in version 0.5.2.1
-
Add strict variants of
MutVar
modification functionsatomicModifyMutVar'
andmodifyMutVar'
-
Fix compilation on Solaris 10 with GNU C 3.4.3
Changes in version 0.5.1.0
- Add support for GHC 7.7’s new primitive
Bool
representation
Changes in version 0.5.0.1
- Disable array copying primitives for GHC 7.6.* and earlier
Changes in version 0.5
-
New in
Data.Primitive.MutVar
:atomicModifyMutVar
-
Efficient block fill operations:
setByteArray
,setAddr
Changes in version 0.4.1
- New module
Data.Primitive.MutVar
Changes in version 0.4.0.1
- Critical bug fix in
fillByteArray
Changes in version 0.4
-
Support for GHC 7.2 array copying primitives
-
New in
Data.Primitive.ByteArray
:copyByteArray
,copyMutableByteArray
,moveByteArray
,fillByteArray
-
Deprecated in
Data.Primitive.ByteArray
:memcpyByteArray
,memcpyByteArray'
,memmoveByteArray
,memsetByteArray
-
New in
Data.Primitive.Array
:copyArray
,copyMutableByteArray
-
New in
Data.Primitive.Addr
:copyAddr
,moveAddr
-
Deprecated in
Data.Primitive.Addr
:memcpyAddr