{-# language BangPatterns #-}
{-# language MagicHash #-}
{-# language RankNTypes #-}
{-# language ScopedTypeVariables #-}
{-# language TypeFamilies #-}
{-# language UnboxedTuples #-}
{-# language RoleAnnotations #-}
module Data.Primitive.Unlifted.SmallArray
(
A.SmallUnliftedArray_(..)
, A.SmallUnliftedArray
, A.SmallMutableUnliftedArray_(..)
, A.SmallMutableUnliftedArray
, newSmallUnliftedArray
, unsafeNewSmallUnliftedArray
, A.sizeofSmallUnliftedArray
, getSizeofSmallMutableUnliftedArray
, A.sameSmallMutableUnliftedArray
, shrinkSmallMutableUnliftedArray
, writeSmallUnliftedArray
, readSmallUnliftedArray
, A.indexSmallUnliftedArray
, unsafeFreezeSmallUnliftedArray
, freezeSmallUnliftedArray
, thawSmallUnliftedArray
, unsafeThawSmallUnliftedArray
, setSmallUnliftedArray
, copySmallUnliftedArray
, copySmallMutableUnliftedArray
, A.cloneSmallUnliftedArray
, cloneSmallMutableUnliftedArray
, A.emptySmallUnliftedArray
, A.singletonSmallUnliftedArray
, A.runSmallUnliftedArray
, A.dupableRunSmallUnliftedArray
, A.smallUnliftedArrayToList
, A.smallUnliftedArrayFromList
, A.smallUnliftedArrayFromListN
, A.foldrSmallUnliftedArray
, A.foldrSmallUnliftedArray'
, A.foldlSmallUnliftedArray
, A.foldlSmallUnliftedArray'
, A.foldlSmallUnliftedArrayM'
, A.traverseSmallUnliftedArray_
, A.itraverseSmallUnliftedArray_
, A.mapSmallUnliftedArray
) where
import Control.Monad.Primitive (PrimMonad,PrimState,stToPrim)
import Data.Primitive.Unlifted.Class (PrimUnlifted (..))
import qualified Data.Primitive.Unlifted.SmallArray.ST as A
import Data.Primitive.Unlifted.SmallArray.ST (SmallUnliftedArray, SmallMutableUnliftedArray)
newSmallUnliftedArray
:: (PrimMonad m, PrimUnlifted a)
=> Int
-> a
-> m (SmallMutableUnliftedArray (PrimState m) a)
newSmallUnliftedArray :: forall (m :: * -> *) a.
(PrimMonad m, PrimUnlifted a) =>
Int -> a -> m (SmallMutableUnliftedArray (PrimState m) a)
newSmallUnliftedArray Int
len a
v = ST (PrimState m) (SmallMutableUnliftedArray (PrimState m) a)
-> m (SmallMutableUnliftedArray (PrimState m) a)
forall (m :: * -> *) a. PrimMonad m => ST (PrimState m) a -> m a
stToPrim (ST (PrimState m) (SmallMutableUnliftedArray (PrimState m) a)
-> m (SmallMutableUnliftedArray (PrimState m) a))
-> ST (PrimState m) (SmallMutableUnliftedArray (PrimState m) a)
-> m (SmallMutableUnliftedArray (PrimState m) a)
forall a b. (a -> b) -> a -> b
$ Int
-> a
-> ST (PrimState m) (SmallMutableUnliftedArray (PrimState m) a)
forall a s.
PrimUnlifted a =>
Int -> a -> ST s (SmallMutableUnliftedArray s a)
A.newSmallUnliftedArray Int
len a
v
{-# inline newSmallUnliftedArray #-}
setSmallUnliftedArray
:: (PrimMonad m, PrimUnlifted a)
=> SmallMutableUnliftedArray (PrimState m) a
-> a
-> Int
-> Int
-> m ()
{-# inline setSmallUnliftedArray #-}
setSmallUnliftedArray :: forall (m :: * -> *) a.
(PrimMonad m, PrimUnlifted a) =>
SmallMutableUnliftedArray (PrimState m) a
-> a -> Int -> Int -> m ()
setSmallUnliftedArray SmallMutableUnliftedArray (PrimState m) a
mua a
v Int
off Int
len = ST (PrimState m) () -> m ()
forall (m :: * -> *) a. PrimMonad m => ST (PrimState m) a -> m a
stToPrim (ST (PrimState m) () -> m ()) -> ST (PrimState m) () -> m ()
forall a b. (a -> b) -> a -> b
$ SmallMutableUnliftedArray (PrimState m) a
-> a -> Int -> Int -> ST (PrimState m) ()
forall a s.
PrimUnlifted a =>
SmallMutableUnliftedArray s a -> a -> Int -> Int -> ST s ()
A.setSmallUnliftedArray SmallMutableUnliftedArray (PrimState m) a
mua a
v Int
off Int
len
shrinkSmallMutableUnliftedArray
:: PrimMonad m
=> SmallMutableUnliftedArray (PrimState m) a
-> Int
-> m ()
shrinkSmallMutableUnliftedArray :: forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableUnliftedArray (PrimState m) a -> Int -> m ()
shrinkSmallMutableUnliftedArray SmallMutableUnliftedArray (PrimState m) a
mary Int
sz = ST (PrimState m) () -> m ()
forall (m :: * -> *) a. PrimMonad m => ST (PrimState m) a -> m a
stToPrim (ST (PrimState m) () -> m ()) -> ST (PrimState m) () -> m ()
forall a b. (a -> b) -> a -> b
$ SmallMutableUnliftedArray (PrimState m) a
-> Int -> ST (PrimState m) ()
forall s a. SmallMutableUnliftedArray s a -> Int -> ST s ()
A.shrinkSmallMutableUnliftedArray SmallMutableUnliftedArray (PrimState m) a
mary Int
sz
{-# inline shrinkSmallMutableUnliftedArray #-}
writeSmallUnliftedArray :: (PrimMonad m, PrimUnlifted a)
=> SmallMutableUnliftedArray (PrimState m) a
-> Int
-> a
-> m ()
{-# inline writeSmallUnliftedArray #-}
writeSmallUnliftedArray :: forall (m :: * -> *) a.
(PrimMonad m, PrimUnlifted a) =>
SmallMutableUnliftedArray (PrimState m) a -> Int -> a -> m ()
writeSmallUnliftedArray SmallMutableUnliftedArray (PrimState m) a
mary Int
ix a
a = ST (PrimState m) () -> m ()
forall (m :: * -> *) a. PrimMonad m => ST (PrimState m) a -> m a
stToPrim (ST (PrimState m) () -> m ()) -> ST (PrimState m) () -> m ()
forall a b. (a -> b) -> a -> b
$ SmallMutableUnliftedArray (PrimState m) a
-> Int -> a -> ST (PrimState m) ()
forall a s.
PrimUnlifted a =>
SmallMutableUnliftedArray s a -> Int -> a -> ST s ()
A.writeSmallUnliftedArray SmallMutableUnliftedArray (PrimState m) a
mary Int
ix a
a
readSmallUnliftedArray :: (PrimMonad m, PrimUnlifted a)
=> SmallMutableUnliftedArray (PrimState m) a
-> Int
-> m a
{-# inline readSmallUnliftedArray #-}
readSmallUnliftedArray :: forall (m :: * -> *) a.
(PrimMonad m, PrimUnlifted a) =>
SmallMutableUnliftedArray (PrimState m) a -> Int -> m a
readSmallUnliftedArray SmallMutableUnliftedArray (PrimState m) a
mary Int
ix = ST (PrimState m) a -> m a
forall (m :: * -> *) a. PrimMonad m => ST (PrimState m) a -> m a
stToPrim (ST (PrimState m) a -> m a) -> ST (PrimState m) a -> m a
forall a b. (a -> b) -> a -> b
$ SmallMutableUnliftedArray (PrimState m) a
-> Int -> ST (PrimState m) a
forall a s.
PrimUnlifted a =>
SmallMutableUnliftedArray s a -> Int -> ST s a
A.readSmallUnliftedArray SmallMutableUnliftedArray (PrimState m) a
mary Int
ix
unsafeFreezeSmallUnliftedArray
:: PrimMonad m
=> SmallMutableUnliftedArray (PrimState m) a
-> m (SmallUnliftedArray a)
unsafeFreezeSmallUnliftedArray :: forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableUnliftedArray (PrimState m) a
-> m (SmallUnliftedArray a)
unsafeFreezeSmallUnliftedArray SmallMutableUnliftedArray (PrimState m) a
mary = ST (PrimState m) (SmallUnliftedArray a) -> m (SmallUnliftedArray a)
forall (m :: * -> *) a. PrimMonad m => ST (PrimState m) a -> m a
stToPrim (ST (PrimState m) (SmallUnliftedArray a)
-> m (SmallUnliftedArray a))
-> ST (PrimState m) (SmallUnliftedArray a)
-> m (SmallUnliftedArray a)
forall a b. (a -> b) -> a -> b
$ SmallMutableUnliftedArray (PrimState m) a
-> ST (PrimState m) (SmallUnliftedArray a)
forall s a.
SmallMutableUnliftedArray s a -> ST s (SmallUnliftedArray a)
A.unsafeFreezeSmallUnliftedArray SmallMutableUnliftedArray (PrimState m) a
mary
{-# inline unsafeFreezeSmallUnliftedArray #-}
copySmallUnliftedArray
:: PrimMonad m
=> SmallMutableUnliftedArray (PrimState m) a
-> Int
-> SmallUnliftedArray a
-> Int
-> Int
-> m ()
{-# inline copySmallUnliftedArray #-}
copySmallUnliftedArray :: forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableUnliftedArray (PrimState m) a
-> Int -> SmallUnliftedArray a -> Int -> Int -> m ()
copySmallUnliftedArray SmallMutableUnliftedArray (PrimState m) a
dst Int
doff SmallUnliftedArray a
src Int
soff Int
ln = ST (PrimState m) () -> m ()
forall (m :: * -> *) a. PrimMonad m => ST (PrimState m) a -> m a
stToPrim (ST (PrimState m) () -> m ()) -> ST (PrimState m) () -> m ()
forall a b. (a -> b) -> a -> b
$ SmallMutableUnliftedArray (PrimState m) a
-> Int -> SmallUnliftedArray a -> Int -> Int -> ST (PrimState m) ()
forall s a.
SmallMutableUnliftedArray s a
-> Int -> SmallUnliftedArray a -> Int -> Int -> ST s ()
A.copySmallUnliftedArray SmallMutableUnliftedArray (PrimState m) a
dst Int
doff SmallUnliftedArray a
src Int
soff Int
ln
copySmallMutableUnliftedArray
:: PrimMonad m
=> SmallMutableUnliftedArray (PrimState m) a
-> Int
-> SmallMutableUnliftedArray (PrimState m) a
-> Int
-> Int
-> m ()
{-# inline copySmallMutableUnliftedArray #-}
copySmallMutableUnliftedArray :: forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableUnliftedArray (PrimState m) a
-> Int
-> SmallMutableUnliftedArray (PrimState m) a
-> Int
-> Int
-> m ()
copySmallMutableUnliftedArray SmallMutableUnliftedArray (PrimState m) a
dst Int
doff SmallMutableUnliftedArray (PrimState m) a
src Int
soff Int
ln = ST (PrimState m) () -> m ()
forall (m :: * -> *) a. PrimMonad m => ST (PrimState m) a -> m a
stToPrim (ST (PrimState m) () -> m ()) -> ST (PrimState m) () -> m ()
forall a b. (a -> b) -> a -> b
$ SmallMutableUnliftedArray (PrimState m) a
-> Int
-> SmallMutableUnliftedArray (PrimState m) a
-> Int
-> Int
-> ST (PrimState m) ()
forall s a.
SmallMutableUnliftedArray s a
-> Int -> SmallMutableUnliftedArray s a -> Int -> Int -> ST s ()
A.copySmallMutableUnliftedArray SmallMutableUnliftedArray (PrimState m) a
dst Int
doff SmallMutableUnliftedArray (PrimState m) a
src Int
soff Int
ln
freezeSmallUnliftedArray
:: PrimMonad m
=> SmallMutableUnliftedArray (PrimState m) a
-> Int
-> Int
-> m (SmallUnliftedArray a)
freezeSmallUnliftedArray :: forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableUnliftedArray (PrimState m) a
-> Int -> Int -> m (SmallUnliftedArray a)
freezeSmallUnliftedArray SmallMutableUnliftedArray (PrimState m) a
mary Int
off Int
len = ST (PrimState m) (SmallUnliftedArray a) -> m (SmallUnliftedArray a)
forall (m :: * -> *) a. PrimMonad m => ST (PrimState m) a -> m a
stToPrim (ST (PrimState m) (SmallUnliftedArray a)
-> m (SmallUnliftedArray a))
-> ST (PrimState m) (SmallUnliftedArray a)
-> m (SmallUnliftedArray a)
forall a b. (a -> b) -> a -> b
$ SmallMutableUnliftedArray (PrimState m) a
-> Int -> Int -> ST (PrimState m) (SmallUnliftedArray a)
forall s a.
SmallMutableUnliftedArray s a
-> Int -> Int -> ST s (SmallUnliftedArray a)
A.freezeSmallUnliftedArray SmallMutableUnliftedArray (PrimState m) a
mary Int
off Int
len
{-# inline freezeSmallUnliftedArray #-}
thawSmallUnliftedArray
:: PrimMonad m
=> SmallUnliftedArray a
-> Int
-> Int
-> m (SmallMutableUnliftedArray (PrimState m) a)
{-# inline thawSmallUnliftedArray #-}
thawSmallUnliftedArray :: forall (m :: * -> *) a.
PrimMonad m =>
SmallUnliftedArray a
-> Int -> Int -> m (SmallMutableUnliftedArray (PrimState m) a)
thawSmallUnliftedArray SmallUnliftedArray a
ary Int
off Int
len = ST (PrimState m) (SmallMutableUnliftedArray (PrimState m) a)
-> m (SmallMutableUnliftedArray (PrimState m) a)
forall (m :: * -> *) a. PrimMonad m => ST (PrimState m) a -> m a
stToPrim (ST (PrimState m) (SmallMutableUnliftedArray (PrimState m) a)
-> m (SmallMutableUnliftedArray (PrimState m) a))
-> ST (PrimState m) (SmallMutableUnliftedArray (PrimState m) a)
-> m (SmallMutableUnliftedArray (PrimState m) a)
forall a b. (a -> b) -> a -> b
$ SmallUnliftedArray a
-> Int
-> Int
-> ST (PrimState m) (SmallMutableUnliftedArray (PrimState m) a)
forall a s.
SmallUnliftedArray a
-> Int -> Int -> ST s (SmallMutableUnliftedArray s a)
A.thawSmallUnliftedArray SmallUnliftedArray a
ary Int
off Int
len
unsafeThawSmallUnliftedArray
:: PrimMonad m
=> SmallUnliftedArray a
-> m (SmallMutableUnliftedArray (PrimState m) a)
{-# inline unsafeThawSmallUnliftedArray #-}
unsafeThawSmallUnliftedArray :: forall (m :: * -> *) a.
PrimMonad m =>
SmallUnliftedArray a
-> m (SmallMutableUnliftedArray (PrimState m) a)
unsafeThawSmallUnliftedArray SmallUnliftedArray a
ary = ST (PrimState m) (SmallMutableUnliftedArray (PrimState m) a)
-> m (SmallMutableUnliftedArray (PrimState m) a)
forall (m :: * -> *) a. PrimMonad m => ST (PrimState m) a -> m a
stToPrim (ST (PrimState m) (SmallMutableUnliftedArray (PrimState m) a)
-> m (SmallMutableUnliftedArray (PrimState m) a))
-> ST (PrimState m) (SmallMutableUnliftedArray (PrimState m) a)
-> m (SmallMutableUnliftedArray (PrimState m) a)
forall a b. (a -> b) -> a -> b
$ SmallUnliftedArray a
-> ST (PrimState m) (SmallMutableUnliftedArray (PrimState m) a)
forall a s.
SmallUnliftedArray a -> ST s (SmallMutableUnliftedArray s a)
A.unsafeThawSmallUnliftedArray SmallUnliftedArray a
ary
unsafeNewSmallUnliftedArray
:: PrimMonad m
=> Int
-> m (SmallMutableUnliftedArray (PrimState m) a)
{-# inline unsafeNewSmallUnliftedArray #-}
unsafeNewSmallUnliftedArray :: forall (m :: * -> *) a.
PrimMonad m =>
Int -> m (SmallMutableUnliftedArray (PrimState m) a)
unsafeNewSmallUnliftedArray Int
len = ST (PrimState m) (SmallMutableUnliftedArray (PrimState m) a)
-> m (SmallMutableUnliftedArray (PrimState m) a)
forall (m :: * -> *) a. PrimMonad m => ST (PrimState m) a -> m a
stToPrim (ST (PrimState m) (SmallMutableUnliftedArray (PrimState m) a)
-> m (SmallMutableUnliftedArray (PrimState m) a))
-> ST (PrimState m) (SmallMutableUnliftedArray (PrimState m) a)
-> m (SmallMutableUnliftedArray (PrimState m) a)
forall a b. (a -> b) -> a -> b
$ Int -> ST (PrimState m) (SmallMutableUnliftedArray (PrimState m) a)
forall s a. Int -> ST s (SmallMutableUnliftedArray s a)
A.unsafeNewSmallUnliftedArray Int
len
getSizeofSmallMutableUnliftedArray
:: PrimMonad m
=> SmallMutableUnliftedArray (PrimState m) a
-> m Int
getSizeofSmallMutableUnliftedArray :: forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableUnliftedArray (PrimState m) a -> m Int
getSizeofSmallMutableUnliftedArray SmallMutableUnliftedArray (PrimState m) a
a = ST (PrimState m) Int -> m Int
forall (m :: * -> *) a. PrimMonad m => ST (PrimState m) a -> m a
stToPrim (ST (PrimState m) Int -> m Int) -> ST (PrimState m) Int -> m Int
forall a b. (a -> b) -> a -> b
$ SmallMutableUnliftedArray (PrimState m) a -> ST (PrimState m) Int
forall s e. SmallMutableUnliftedArray s e -> ST s Int
A.getSizeofSmallMutableUnliftedArray SmallMutableUnliftedArray (PrimState m) a
a
cloneSmallMutableUnliftedArray
:: PrimMonad m
=> SmallMutableUnliftedArray (PrimState m) a
-> Int
-> Int
-> m (SmallMutableUnliftedArray (PrimState m) a)
{-# inline cloneSmallMutableUnliftedArray #-}
cloneSmallMutableUnliftedArray :: forall (m :: * -> *) a.
PrimMonad m =>
SmallMutableUnliftedArray (PrimState m) a
-> Int -> Int -> m (SmallMutableUnliftedArray (PrimState m) a)
cloneSmallMutableUnliftedArray SmallMutableUnliftedArray (PrimState m) a
mary Int
off Int
len = ST (PrimState m) (SmallMutableUnliftedArray (PrimState m) a)
-> m (SmallMutableUnliftedArray (PrimState m) a)
forall (m :: * -> *) a. PrimMonad m => ST (PrimState m) a -> m a
stToPrim (ST (PrimState m) (SmallMutableUnliftedArray (PrimState m) a)
-> m (SmallMutableUnliftedArray (PrimState m) a))
-> ST (PrimState m) (SmallMutableUnliftedArray (PrimState m) a)
-> m (SmallMutableUnliftedArray (PrimState m) a)
forall a b. (a -> b) -> a -> b
$ SmallMutableUnliftedArray (PrimState m) a
-> Int
-> Int
-> ST (PrimState m) (SmallMutableUnliftedArray (PrimState m) a)
forall s a.
SmallMutableUnliftedArray s a
-> Int -> Int -> ST s (SmallMutableUnliftedArray s a)
A.cloneSmallMutableUnliftedArray SmallMutableUnliftedArray (PrimState m) a
mary Int
off Int
len