microgroove-0.1.0.0: Array-backed extensible records

Safe HaskellNone
LanguageHaskell2010

Data.Microgroove.MRec

Synopsis

Documentation

newtype MRec s f us Source #

A mutable heterogeneous record represented by an untyped mutable vector

Constructors

MRec# (MVector s Any) 

new# :: forall f xs m. (KnownNat (Length xs), PrimMonad m) => m (MRec (PrimState m) f xs) Source #

Create a mutable record of the given shape. The memory is not initialized

rmap :: forall g m f xs. PrimMonad m => (forall x. f x -> g x) -> MRec (PrimState m) f xs -> m (MRec (PrimState m) g xs) Source #

Modify a mutable record in place by mapping a natural tranformation. O(n)

crmap :: forall c g m f xs. (AllF c f xs, PrimMonad m) => (forall x. c (f x) => f x -> g x) -> MRec (PrimState m) f xs -> m (MRec (PrimState m) g xs) Source #

Modify a mutable record in place by mapping a natural tranformation that can make use of the provided constraint. Ex: `crmap @Show (K . show) :: (MRec s f xs) -> ST s (MRec s (K String) xs)` O(n)

toMVector :: forall r m f xs. PrimMonad m => (forall x. f x -> r) -> MRec (PrimState m) f xs -> m (MVector (PrimState m) r) Source #

Convert a mutable record to a mutable vector by mapping to a homogeneous type O(n)

ctoMVector :: forall c r m f xs. (AllF c f xs, PrimMonad m) => (forall x. c (f x) => f x -> r) -> MRec (PrimState m) f xs -> m (MVector (PrimState m) r) Source #

Convert a mutable record to a mutable vector by mapping to a homogeneous type, making use of provided constraint O(n)

modify :: forall n xs fx f m. (fx ~ f (xs !! n), PrimMonad m, KnownNat n) => (fx -> fx) -> MRec (PrimState m) f xs -> m () Source #

Modify a record in place by appling an endofunctor at the index. O(1)

setAt :: forall n x xs f m. (PrimMonad m, KnownNat n) => f x -> MRec (PrimState m) f xs -> m (MRec (PrimState m) f (SetAt n xs x)) Source #

Modify a record in place by setting its value at an index. May change record type. O(1)