primal-0.1.0.0: Primeval world of Haskell.

Copyright(c) Alexey Kuleshevich 2020
LicenseBSD3
MaintainerAlexey Kuleshevich <alexey@kuleshevi.ch>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Foreign.Prim.Ptr

Contents

Description

 
Synopsis

Documentation

module GHC.Ptr

plusOffPtr :: Prim e => Ptr e -> Off e -> Ptr e Source #

minusOffPtr :: Prim e => Ptr e -> Ptr e -> Off e Source #

Find the offset in number of elements that is between the two pointers by subtracting one address from another and dividing the result by the size of an element.

Since: 0.1.0

minusOffRemPtr :: Prim e => Ptr e -> Ptr e -> (Off e, Off Word8) Source #

Same as minusOffPtr, but will also return the remainder in bytes that is left over.

Since: 0.1.0

minusByteOffPtr :: Ptr e -> Ptr e -> Off Word8 Source #

Find the offset in bytes that is between the two pointers by subtracting one address from another.

Since: 0.1.0

readPtr :: (MonadPrim s m, Prim e) => Ptr e -> m e Source #

readOffPtr :: (MonadPrim s m, Prim e) => Ptr e -> Off e -> m e Source #

readByteOffPtr :: (MonadPrim s m, Prim e) => Ptr e -> Off Word8 -> m e Source #

writePtr :: (MonadPrim s m, Prim e) => Ptr e -> e -> m () Source #

writeOffPtr :: (MonadPrim s m, Prim e) => Ptr e -> Off e -> e -> m () Source #

writeByteOffPtr :: (MonadPrim s m, Prim e) => Ptr e -> Off Word8 -> e -> m () Source #

setOffPtr Source #

Arguments

:: (MonadPrim s m, Prim e) 
=> Ptr e

Chunk of memory to fill

-> Off e

Offset in number of elements

-> Count e

Number of cells to fill

-> e

A value to fill the cells with

-> m () 

copyPtrToPtr :: (MonadPrim s m, Prim e) => Ptr e -> Off e -> Ptr e -> Off e -> Count e -> m () Source #

copyByteOffPtrToPtr :: (MonadPrim s m, Prim e) => Ptr e -> Off Word8 -> Ptr e -> Off Word8 -> Count e -> m () Source #

movePtrToPtr :: (MonadPrim s m, Prim e) => Ptr e -> Off e -> Ptr e -> Off e -> Count e -> m () Source #

moveByteOffPtrToPtr :: (MonadPrim s m, Prim e) => Ptr e -> Off Word8 -> Ptr e -> Off Word8 -> Count e -> m () Source #

comparePtrToPtr :: Prim e => Ptr e -> Off e -> Ptr e -> Off e -> Count e -> Ordering Source #

Compare memory between two pointers. Offsets and count is in number of elements, instead of byte count. Use compareByteOffPtrToPtr when offset in bytes is required.

compareByteOffPtrToPtr :: Prim e => Ptr e -> Off Word8 -> Ptr e -> Off Word8 -> Count e -> Ordering Source #

Same as comparePtrToPtr, except offset is in bytes instead of number of elements.

freeHaskellFunPtr :: MonadPrim s m => FunPtr a -> m () Source #

Same as freeHaskellFunPtr

Since: 0.1.0

data Ptr a #

A value of type Ptr a represents a pointer to an object, or an array of objects, which may be marshalled to or from Haskell values of type a.

The type a will often be an instance of class Storable which provides the marshalling operations. However this is not essential, and you can provide your own operations to access the pointer. For example you might write small foreign functions to get or set the fields of a C struct.

Instances
NFData1 Ptr

Since: deepseq-1.4.3.0

Instance details

Defined in Control.DeepSeq

Methods

liftRnf :: (a -> ()) -> Ptr a -> () #

Generic1 (URec (Ptr ()) :: k -> Type) 
Instance details

Defined in GHC.Generics

Associated Types

type Rep1 (URec (Ptr ())) :: k -> Type #

Methods

from1 :: URec (Ptr ()) a -> Rep1 (URec (Ptr ())) a #

to1 :: Rep1 (URec (Ptr ())) a -> URec (Ptr ()) a #

Eq (Ptr a)

Since: base-2.1

Instance details

Defined in GHC.Ptr

Methods

(==) :: Ptr a -> Ptr a -> Bool #

(/=) :: Ptr a -> Ptr a -> Bool #

Ord (Ptr a)

Since: base-2.1

Instance details

Defined in GHC.Ptr

Methods

compare :: Ptr a -> Ptr a -> Ordering #

(<) :: Ptr a -> Ptr a -> Bool #

(<=) :: Ptr a -> Ptr a -> Bool #

(>) :: Ptr a -> Ptr a -> Bool #

(>=) :: Ptr a -> Ptr a -> Bool #

max :: Ptr a -> Ptr a -> Ptr a #

min :: Ptr a -> Ptr a -> Ptr a #

Show (Ptr a)

Since: base-2.1

Instance details

Defined in GHC.Ptr

Methods

showsPrec :: Int -> Ptr a -> ShowS #

show :: Ptr a -> String #

showList :: [Ptr a] -> ShowS #

NFData (Ptr a)

Since: deepseq-1.4.2.0

Instance details

Defined in Control.DeepSeq

Methods

rnf :: Ptr a -> () #

Prim (Ptr a) Source # 
Instance details

Defined in Data.Prim.Class

Associated Types

type PrimBase (Ptr a) :: Type Source #

type SizeOf (Ptr a) :: Nat Source #

type Alignment (Ptr a) :: Nat Source #

Atomic (Ptr a) Source # 
Instance details

Defined in Data.Prim.Atomic

Functor (URec (Ptr ()) :: Type -> Type)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Methods

fmap :: (a -> b) -> URec (Ptr ()) a -> URec (Ptr ()) b #

(<$) :: a -> URec (Ptr ()) b -> URec (Ptr ()) a #

Foldable (URec (Ptr ()) :: Type -> Type)

Since: base-4.9.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => URec (Ptr ()) m -> m #

foldMap :: Monoid m => (a -> m) -> URec (Ptr ()) a -> m #

foldr :: (a -> b -> b) -> b -> URec (Ptr ()) a -> b #

foldr' :: (a -> b -> b) -> b -> URec (Ptr ()) a -> b #

foldl :: (b -> a -> b) -> b -> URec (Ptr ()) a -> b #

foldl' :: (b -> a -> b) -> b -> URec (Ptr ()) a -> b #

foldr1 :: (a -> a -> a) -> URec (Ptr ()) a -> a #

foldl1 :: (a -> a -> a) -> URec (Ptr ()) a -> a #

toList :: URec (Ptr ()) a -> [a] #

null :: URec (Ptr ()) a -> Bool #

length :: URec (Ptr ()) a -> Int #

elem :: Eq a => a -> URec (Ptr ()) a -> Bool #

maximum :: Ord a => URec (Ptr ()) a -> a #

minimum :: Ord a => URec (Ptr ()) a -> a #

sum :: Num a => URec (Ptr ()) a -> a #

product :: Num a => URec (Ptr ()) a -> a #

Traversable (URec (Ptr ()) :: Type -> Type)

Since: base-4.9.0.0

Instance details

Defined in Data.Traversable

Methods

traverse :: Applicative f => (a -> f b) -> URec (Ptr ()) a -> f (URec (Ptr ()) b) #

sequenceA :: Applicative f => URec (Ptr ()) (f a) -> f (URec (Ptr ()) a) #

mapM :: Monad m => (a -> m b) -> URec (Ptr ()) a -> m (URec (Ptr ()) b) #

sequence :: Monad m => URec (Ptr ()) (m a) -> m (URec (Ptr ()) a) #

Eq (URec (Ptr ()) p)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Methods

(==) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool #

(/=) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool #

Ord (URec (Ptr ()) p)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Methods

compare :: URec (Ptr ()) p -> URec (Ptr ()) p -> Ordering #

(<) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool #

(<=) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool #

(>) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool #

(>=) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool #

max :: URec (Ptr ()) p -> URec (Ptr ()) p -> URec (Ptr ()) p #

min :: URec (Ptr ()) p -> URec (Ptr ()) p -> URec (Ptr ()) p #

Generic (URec (Ptr ()) p) 
Instance details

Defined in GHC.Generics

Associated Types

type Rep (URec (Ptr ()) p) :: Type -> Type #

Methods

from :: URec (Ptr ()) p -> Rep (URec (Ptr ()) p) x #

to :: Rep (URec (Ptr ()) p) x -> URec (Ptr ()) p #

data URec (Ptr ()) (p :: k)

Used for marking occurrences of Addr#

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

data URec (Ptr ()) (p :: k) = UAddr {}
type Rep1 (URec (Ptr ()) :: k -> Type)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

type Rep1 (URec (Ptr ()) :: k -> Type) = D1 (MetaData "URec" "GHC.Generics" "base" False) (C1 (MetaCons "UAddr" PrefixI True) (S1 (MetaSel (Just "uAddr#") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (UAddr :: k -> Type)))
type PrimBase (Ptr a) Source # 
Instance details

Defined in Data.Prim.Class

type PrimBase (Ptr a) = Ptr a
type SizeOf (Ptr a) Source # 
Instance details

Defined in Data.Prim.Class

type SizeOf (Ptr a) = 8
type Alignment (Ptr a) Source # 
Instance details

Defined in Data.Prim.Class

type Alignment (Ptr a) = 8
type Rep (URec (Ptr ()) p)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

type Rep (URec (Ptr ()) p) = D1 (MetaData "URec" "GHC.Generics" "base" False) (C1 (MetaCons "UAddr" PrefixI True) (S1 (MetaSel (Just "uAddr#") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (UAddr :: Type -> Type)))

data FunPtr a #

A value of type FunPtr a is a pointer to a function callable from foreign code. The type a will normally be a foreign type, a function type with zero or more arguments where

A value of type FunPtr a may be a pointer to a foreign function, either returned by another foreign function or imported with a a static address import like

foreign import ccall "stdlib.h &free"
  p_free :: FunPtr (Ptr a -> IO ())

or a pointer to a Haskell function created using a wrapper stub declared to produce a FunPtr of the correct type. For example:

type Compare = Int -> Int -> Bool
foreign import ccall "wrapper"
  mkCompare :: Compare -> IO (FunPtr Compare)

Calls to wrapper stubs like mkCompare allocate storage, which should be released with freeHaskellFunPtr when no longer required.

To convert FunPtr values to corresponding Haskell functions, one can define a dynamic stub for the specific foreign type, e.g.

type IntFunction = CInt -> IO ()
foreign import ccall "dynamic"
  mkFun :: FunPtr IntFunction -> IntFunction
Instances
NFData1 FunPtr

Since: deepseq-1.4.3.0

Instance details

Defined in Control.DeepSeq

Methods

liftRnf :: (a -> ()) -> FunPtr a -> () #

Eq (FunPtr a) 
Instance details

Defined in GHC.Ptr

Methods

(==) :: FunPtr a -> FunPtr a -> Bool #

(/=) :: FunPtr a -> FunPtr a -> Bool #

Ord (FunPtr a) 
Instance details

Defined in GHC.Ptr

Methods

compare :: FunPtr a -> FunPtr a -> Ordering #

(<) :: FunPtr a -> FunPtr a -> Bool #

(<=) :: FunPtr a -> FunPtr a -> Bool #

(>) :: FunPtr a -> FunPtr a -> Bool #

(>=) :: FunPtr a -> FunPtr a -> Bool #

max :: FunPtr a -> FunPtr a -> FunPtr a #

min :: FunPtr a -> FunPtr a -> FunPtr a #

Show (FunPtr a)

Since: base-2.1

Instance details

Defined in GHC.Ptr

Methods

showsPrec :: Int -> FunPtr a -> ShowS #

show :: FunPtr a -> String #

showList :: [FunPtr a] -> ShowS #

NFData (FunPtr a)

Since: deepseq-1.4.2.0

Instance details

Defined in Control.DeepSeq

Methods

rnf :: FunPtr a -> () #

Prim (FunPtr a) Source # 
Instance details

Defined in Data.Prim.Class

Associated Types

type PrimBase (FunPtr a) :: Type Source #

type SizeOf (FunPtr a) :: Nat Source #

type Alignment (FunPtr a) :: Nat Source #

Atomic (FunPtr a) Source # 
Instance details

Defined in Data.Prim.Atomic

type PrimBase (FunPtr a) Source # 
Instance details

Defined in Data.Prim.Class

type PrimBase (FunPtr a) = Ptr a
type SizeOf (FunPtr a) Source # 
Instance details

Defined in Data.Prim.Class

type Alignment (FunPtr a) Source # 
Instance details

Defined in Data.Prim.Class

castPtrToFunPtr :: Ptr a -> FunPtr b #

Casts a Ptr to a FunPtr.

Note: this is valid only on architectures where data and function pointers range over the same set of addresses, and should only be used for bindings to external libraries whose interface already relies on this assumption.

castFunPtrToPtr :: FunPtr a -> Ptr b #

Casts a FunPtr to a Ptr.

Note: this is valid only on architectures where data and function pointers range over the same set of addresses, and should only be used for bindings to external libraries whose interface already relies on this assumption.

castFunPtr :: FunPtr a -> FunPtr b #

Casts a FunPtr to a FunPtr of a different type.

nullFunPtr :: FunPtr a #

The constant nullFunPtr contains a distinguished value of FunPtr that is not associated with a valid memory location.

minusPtr :: Ptr a -> Ptr b -> Int #

Computes the offset required to get from the second to the first argument. We have

p2 == p1 `plusPtr` (p2 `minusPtr` p1)

alignPtr :: Ptr a -> Int -> Ptr a #

Given an arbitrary address and an alignment constraint, alignPtr yields the next higher address that fulfills the alignment constraint. An alignment constraint x is fulfilled by any address divisible by x. This operation is idempotent.

plusPtr :: Ptr a -> Int -> Ptr b #

Advances the given address by the given offset in bytes.

castPtr :: Ptr a -> Ptr b #

The castPtr function casts a pointer from one type to another.

nullPtr :: Ptr a #

The constant nullPtr contains a distinguished value of Ptr that is not associated with a valid memory location.

newtype WordPtr #

An unsigned integral type that can be losslessly converted to and from Ptr. This type is also compatible with the C99 type uintptr_t, and can be marshalled to and from that type safely.

Constructors

WordPtr Word 
Instances
Bounded WordPtr 
Instance details

Defined in Foreign.Ptr

Enum WordPtr 
Instance details

Defined in Foreign.Ptr

Eq WordPtr 
Instance details

Defined in Foreign.Ptr

Methods

(==) :: WordPtr -> WordPtr -> Bool #

(/=) :: WordPtr -> WordPtr -> Bool #

Integral WordPtr 
Instance details

Defined in Foreign.Ptr

Num WordPtr 
Instance details

Defined in Foreign.Ptr

Ord WordPtr 
Instance details

Defined in Foreign.Ptr

Read WordPtr 
Instance details

Defined in Foreign.Ptr

Real WordPtr 
Instance details

Defined in Foreign.Ptr

Show WordPtr 
Instance details

Defined in Foreign.Ptr

Storable WordPtr 
Instance details

Defined in Foreign.Ptr

Bits WordPtr 
Instance details

Defined in Foreign.Ptr

FiniteBits WordPtr 
Instance details

Defined in Foreign.Ptr

Prim WordPtr Source # 
Instance details

Defined in Data.Prim.Class

Associated Types

type PrimBase WordPtr :: Type Source #

type SizeOf WordPtr :: Nat Source #

type Alignment WordPtr :: Nat Source #

AtomicBits WordPtr Source # 
Instance details

Defined in Data.Prim.Atomic

Methods

atomicAndFetchOldMutableByteArray# :: MutableByteArray# s -> Int# -> WordPtr -> State# s -> (#State# s, WordPtr#) Source #

atomicAndFetchNewMutableByteArray# :: MutableByteArray# s -> Int# -> WordPtr -> State# s -> (#State# s, WordPtr#) Source #

atomicNandFetchOldMutableByteArray# :: MutableByteArray# s -> Int# -> WordPtr -> State# s -> (#State# s, WordPtr#) Source #

atomicNandFetchNewMutableByteArray# :: MutableByteArray# s -> Int# -> WordPtr -> State# s -> (#State# s, WordPtr#) Source #

atomicOrFetchOldMutableByteArray# :: MutableByteArray# s -> Int# -> WordPtr -> State# s -> (#State# s, WordPtr#) Source #

atomicOrFetchNewMutableByteArray# :: MutableByteArray# s -> Int# -> WordPtr -> State# s -> (#State# s, WordPtr#) Source #

atomicXorFetchOldMutableByteArray# :: MutableByteArray# s -> Int# -> WordPtr -> State# s -> (#State# s, WordPtr#) Source #

atomicXorFetchNewMutableByteArray# :: MutableByteArray# s -> Int# -> WordPtr -> State# s -> (#State# s, WordPtr#) Source #

atomicAndFetchOldOffAddr# :: Addr# -> Int# -> WordPtr -> State# s -> (#State# s, WordPtr#) Source #

atomicAndFetchNewOffAddr# :: Addr# -> Int# -> WordPtr -> State# s -> (#State# s, WordPtr#) Source #

atomicNandFetchOldOffAddr# :: Addr# -> Int# -> WordPtr -> State# s -> (#State# s, WordPtr#) Source #

atomicNandFetchNewOffAddr# :: Addr# -> Int# -> WordPtr -> State# s -> (#State# s, WordPtr#) Source #

atomicOrFetchOldOffAddr# :: Addr# -> Int# -> WordPtr -> State# s -> (#State# s, WordPtr#) Source #

atomicOrFetchNewOffAddr# :: Addr# -> Int# -> WordPtr -> State# s -> (#State# s, WordPtr#) Source #

atomicXorFetchOldOffAddr# :: Addr# -> Int# -> WordPtr -> State# s -> (#State# s, WordPtr#) Source #

atomicXorFetchNewOffAddr# :: Addr# -> Int# -> WordPtr -> State# s -> (#State# s, WordPtr#) Source #

AtomicCount WordPtr Source # 
Instance details

Defined in Data.Prim.Atomic

Atomic WordPtr Source # 
Instance details

Defined in Data.Prim.Atomic

type PrimBase WordPtr Source # 
Instance details

Defined in Data.Prim.Class

type SizeOf WordPtr Source # 
Instance details

Defined in Data.Prim.Class

type Alignment WordPtr Source # 
Instance details

Defined in Data.Prim.Class

ptrToWordPtr :: Ptr a -> WordPtr #

casts a Ptr to a WordPtr

wordPtrToPtr :: WordPtr -> Ptr a #

casts a WordPtr to a Ptr

newtype IntPtr #

A signed integral type that can be losslessly converted to and from Ptr. This type is also compatible with the C99 type intptr_t, and can be marshalled to and from that type safely.

Constructors

IntPtr Int 
Instances
Bounded IntPtr 
Instance details

Defined in Foreign.Ptr

Enum IntPtr 
Instance details

Defined in Foreign.Ptr

Eq IntPtr 
Instance details

Defined in Foreign.Ptr

Methods

(==) :: IntPtr -> IntPtr -> Bool #

(/=) :: IntPtr -> IntPtr -> Bool #

Integral IntPtr 
Instance details

Defined in Foreign.Ptr

Num IntPtr 
Instance details

Defined in Foreign.Ptr

Ord IntPtr 
Instance details

Defined in Foreign.Ptr

Read IntPtr 
Instance details

Defined in Foreign.Ptr

Real IntPtr 
Instance details

Defined in Foreign.Ptr

Show IntPtr 
Instance details

Defined in Foreign.Ptr

Storable IntPtr 
Instance details

Defined in Foreign.Ptr

Bits IntPtr 
Instance details

Defined in Foreign.Ptr

FiniteBits IntPtr 
Instance details

Defined in Foreign.Ptr

Prim IntPtr Source # 
Instance details

Defined in Data.Prim.Class

Associated Types

type PrimBase IntPtr :: Type Source #

type SizeOf IntPtr :: Nat Source #

type Alignment IntPtr :: Nat Source #

AtomicBits IntPtr Source # 
Instance details

Defined in Data.Prim.Atomic

Methods

atomicAndFetchOldMutableByteArray# :: MutableByteArray# s -> Int# -> IntPtr -> State# s -> (#State# s, IntPtr#) Source #

atomicAndFetchNewMutableByteArray# :: MutableByteArray# s -> Int# -> IntPtr -> State# s -> (#State# s, IntPtr#) Source #

atomicNandFetchOldMutableByteArray# :: MutableByteArray# s -> Int# -> IntPtr -> State# s -> (#State# s, IntPtr#) Source #

atomicNandFetchNewMutableByteArray# :: MutableByteArray# s -> Int# -> IntPtr -> State# s -> (#State# s, IntPtr#) Source #

atomicOrFetchOldMutableByteArray# :: MutableByteArray# s -> Int# -> IntPtr -> State# s -> (#State# s, IntPtr#) Source #

atomicOrFetchNewMutableByteArray# :: MutableByteArray# s -> Int# -> IntPtr -> State# s -> (#State# s, IntPtr#) Source #

atomicXorFetchOldMutableByteArray# :: MutableByteArray# s -> Int# -> IntPtr -> State# s -> (#State# s, IntPtr#) Source #

atomicXorFetchNewMutableByteArray# :: MutableByteArray# s -> Int# -> IntPtr -> State# s -> (#State# s, IntPtr#) Source #

atomicAndFetchOldOffAddr# :: Addr# -> Int# -> IntPtr -> State# s -> (#State# s, IntPtr#) Source #

atomicAndFetchNewOffAddr# :: Addr# -> Int# -> IntPtr -> State# s -> (#State# s, IntPtr#) Source #

atomicNandFetchOldOffAddr# :: Addr# -> Int# -> IntPtr -> State# s -> (#State# s, IntPtr#) Source #

atomicNandFetchNewOffAddr# :: Addr# -> Int# -> IntPtr -> State# s -> (#State# s, IntPtr#) Source #

atomicOrFetchOldOffAddr# :: Addr# -> Int# -> IntPtr -> State# s -> (#State# s, IntPtr#) Source #

atomicOrFetchNewOffAddr# :: Addr# -> Int# -> IntPtr -> State# s -> (#State# s, IntPtr#) Source #

atomicXorFetchOldOffAddr# :: Addr# -> Int# -> IntPtr -> State# s -> (#State# s, IntPtr#) Source #

atomicXorFetchNewOffAddr# :: Addr# -> Int# -> IntPtr -> State# s -> (#State# s, IntPtr#) Source #

AtomicCount IntPtr Source # 
Instance details

Defined in Data.Prim.Atomic

Atomic IntPtr Source # 
Instance details

Defined in Data.Prim.Atomic

type PrimBase IntPtr Source # 
Instance details

Defined in Data.Prim.Class

type SizeOf IntPtr Source # 
Instance details

Defined in Data.Prim.Class

type Alignment IntPtr Source # 
Instance details

Defined in Data.Prim.Class

ptrToIntPtr :: Ptr a -> IntPtr #

casts a Ptr to an IntPtr

intPtrToPtr :: IntPtr -> Ptr a #

casts an IntPtr to a Ptr

Atomic

casOffPtr Source #

Arguments

:: (MonadPrim s m, Atomic e) 
=> Ptr e

Array to be mutated

-> Off e

Index is in elements of a, rather than bytes.

-> e

Expected old value

-> e

New value

-> m e 

Perform atomic modification of an element in the Ptr at the supplied index. Returns the artifact of computation b. Offset is in number of elements, rather than bytes. Implies a full memory barrier.

Note - Bounds are not checked, therefore this function is unsafe.

Since: 0.1.0

atomicModifyOffPtr Source #

Arguments

:: (MonadPrim s m, Atomic e) 
=> Ptr e

Array to be mutated

-> Off e

Index is in elements of a, rather than bytes.

-> (e -> (e, b))

Function that is applied to the old value and returns new value and some artifact of computation b

-> m b 

Perform atomic modification of an element in the Ptr at the supplied index. Returns the artifact of computation b. Offset is in number of elements, rather than bytes. Implies a full memory barrier.

Note - Bounds are not checked, therefore this function is unsafe.

Since: 0.1.0

atomicModifyOffPtr_ Source #

Arguments

:: (MonadPrim s m, Atomic e) 
=> Ptr e

Array to be mutated

-> Off e

Index is in elements of a, rather than bytes.

-> (e -> e)

Function that is applied to the old value and returns new value.

-> m () 

Perform atomic modification of an element in the Ptr at the supplied index. Offset is in number of elements, rather than bytes. Implies a full memory barrier.

Note - Bounds are not checked, therefore this function is unsafe.

Since: 0.1.0

atomicModifyFetchOldOffPtr Source #

Arguments

:: (MonadPrim s m, Atomic e) 
=> Ptr e

Array to be mutated

-> Off e

Index is in elements of a, rather than bytes.

-> (e -> e)

Function that is applied to the old value and returns the new value

-> m e 

Perform atomic modification of an element in the Ptr at the supplied index. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.

Note - Bounds are not checked, therefore this function is unsafe.

Since: 0.1.0

atomicModifyFetchNewOffPtr Source #

Arguments

:: (MonadPrim s m, Atomic e) 
=> Ptr e

Array to be mutated

-> Off e

Index is in elements of a, rather than bytes.

-> (e -> e)

Function that is applied to the old value and returns the new value

-> m e 

Perform atomic modification of an element in the Ptr at the supplied index. Offset is in number of elements, rather than bytes. Implies a full memory barrier.

Note - Bounds are not checked, therefore this function is unsafe.

Since: 0.1.0

Numeric

atomicAddFetchOldOffPtr :: (MonadPrim s m, AtomicCount e) => Ptr e -> Off e -> e -> m e Source #

Add a numeric value to an element of a Ptr, corresponds to (+) done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.

Note - Bounds are not checked, therefore this function is unsafe.

Since: 0.1.0

atomicAddFetchNewOffPtr :: (MonadPrim s m, AtomicCount e) => Ptr e -> Off e -> e -> m e Source #

Add a numeric value to an element of a Ptr, corresponds to (+) done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.

Note - Bounds are not checked, therefore this function is unsafe.

Since: 0.1.0

atomicSubFetchOldOffPtr :: (MonadPrim s m, AtomicCount e) => Ptr e -> Off e -> e -> m e Source #

Subtract a numeric value from an element of a Ptr, corresponds to (-) done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.

Note - Bounds are not checked, therefore this function is unsafe.

Since: 0.1.0

atomicSubFetchNewOffPtr :: (MonadPrim s m, AtomicCount e) => Ptr e -> Off e -> e -> m e Source #

Subtract a numeric value from an element of a Ptr, corresponds to (-) done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.

Note - Bounds are not checked, therefore this function is unsafe.

Since: 0.1.0

Binary

atomicAndFetchOldOffPtr :: (MonadPrim s m, AtomicBits e) => Ptr e -> Off e -> e -> m e Source #

Binary conjunction (AND) of an element of a Ptr with the supplied value, corresponds to (.&.) done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.

Note - Bounds are not checked, therefore this function is unsafe.

Since: 0.1.0

atomicAndFetchNewOffPtr :: (MonadPrim s m, AtomicBits e) => Ptr e -> Off e -> e -> m e Source #

Binary conjunction (AND) of an element of a Ptr with the supplied value, corresponds to (.&.) done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.

Note - Bounds are not checked, therefore this function is unsafe.

Since: 0.1.0

atomicNandFetchOldOffPtr :: (MonadPrim s m, AtomicBits e) => Ptr e -> Off e -> e -> m e Source #

Negation of binary conjunction (NAND) of an element of a Ptr with the supplied value, corresponds to \x y -> complement (x .&. y) done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.

Note - Bounds are not checked, therefore this function is unsafe.

Since: 0.1.0

atomicNandFetchNewOffPtr :: (MonadPrim s m, AtomicBits e) => Ptr e -> Off e -> e -> m e Source #

Negation of binary conjunction (NAND) of an element of a Ptr with the supplied value, corresponds to \x y -> complement (x .&. y) done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.

Note - Bounds are not checked, therefore this function is unsafe.

Since: 0.1.0

atomicOrFetchOldOffPtr :: (MonadPrim s m, AtomicBits e) => Ptr e -> Off e -> e -> m e Source #

Binary disjunction (OR) of an element of a Ptr with the supplied value, corresponds to (.|.) done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.

Note - Bounds are not checked, therefore this function is unsafe.

Since: 0.1.0

atomicOrFetchNewOffPtr :: (MonadPrim s m, AtomicBits e) => Ptr e -> Off e -> e -> m e Source #

Binary disjunction (OR) of an element of a Ptr with the supplied value, corresponds to (.|.) done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.

Note - Bounds are not checked, therefore this function is unsafe.

Since: 0.1.0

atomicXorFetchOldOffPtr :: (MonadPrim s m, AtomicBits e) => Ptr e -> Off e -> e -> m e Source #

Binary exclusive disjunction (XOR) of an element of a Ptr with the supplied value, corresponds to xor done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.

Note - Bounds are not checked, therefore this function is unsafe.

Since: 0.1.0

atomicXorFetchNewOffPtr :: (MonadPrim s m, AtomicBits e) => Ptr e -> Off e -> e -> m e Source #

Binary exclusive disjunction (XOR) of an element of a Ptr with the supplied value, corresponds to xor done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.

Note - Bounds are not checked, therefore this function is unsafe.

Since: 0.1.0

atomicNotFetchOldOffPtr :: (MonadPrim s m, AtomicBits e) => Ptr e -> Off e -> m e Source #

Binary negation (NOT) of an element of a Ptr, corresponds to (complement) done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.

Note - Bounds are not checked, therefore this function is unsafe.

Since: 0.1.0

atomicNotFetchNewOffPtr :: (MonadPrim s m, AtomicBits e) => Ptr e -> Off e -> m e Source #

Binary negation (NOT) of an element of a Ptr, corresponds to (complement) done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.

Note - Bounds are not checked, therefore this function is unsafe.

Since: 0.1.0

Prefetch

prefetchPtr0 :: MonadPrim s m => Ptr e -> m () Source #

prefetchPtr1 :: MonadPrim s m => Ptr a -> m () Source #

prefetchPtr2 :: MonadPrim s m => Ptr e -> m () Source #

prefetchPtr3 :: MonadPrim s m => Ptr e -> m () Source #

prefetchOffPtr0 :: (MonadPrim s m, Prim e) => Ptr e -> Off e -> m () Source #

prefetchOffPtr1 :: (MonadPrim s m, Prim e) => Ptr e -> Off e -> m () Source #

prefetchOffPtr2 :: (MonadPrim s m, Prim e) => Ptr e -> Off e -> m () Source #

prefetchOffPtr3 :: (MonadPrim s m, Prim e) => Ptr e -> Off e -> m () Source #