extensible-0.4.6: Extensible, efficient, optics-friendly data types and effects

Copyright(c) Fumiaki Kinoshita 2017
LicenseBSD3
MaintainerFumiaki Kinoshita <fumiexcel@gmail.com>
Safe HaskellNone
LanguageHaskell2010

Data.Extensible.Struct

Contents

Description

Mutable structs

Synopsis

Mutable struct

data Struct s h xs Source #

Mutable type-indexed struct.

set :: PrimMonad m => Struct (PrimState m) h xs -> Membership xs x -> h x -> m () Source #

Write a value in a Struct.

get :: PrimMonad m => Struct (PrimState m) h xs -> Membership xs x -> m (h x) Source #

Read a value from a Struct.

new :: forall h m xs. (PrimMonad m, Generate xs) => (forall x. Membership xs x -> h x) -> m (Struct (PrimState m) h xs) Source #

Create a new Struct using the supplied initializer.

newRepeat :: forall h m xs. (PrimMonad m, Generate xs) => (forall x. h x) -> m (Struct (PrimState m) h xs) Source #

Create a Struct full of the specified value.

newFor :: forall proxy c h m xs. (PrimMonad m, Forall c xs) => proxy c -> (forall x. c x => Membership xs x -> h x) -> m (Struct (PrimState m) h xs) Source #

Create a new Struct using the supplied initializer with a context.

newFromHList :: forall h m xs. PrimMonad m => HList h xs -> m (Struct (PrimState m) h xs) Source #

Create a new Struct from an HList.

data WrappedPointer s h a where Source #

A pointer to an element in a Struct.

Constructors

WrappedPointer :: !(Struct s h xs) -> !(Membership xs x) -> WrappedPointer s h (Repr h x) 

Instances

((~) * s RealWorld, Wrapper k h) => HasSetter (WrappedPointer k s h a) a Source # 

Methods

($=) :: MonadIO m => WrappedPointer k s h a -> a -> m () #

((~) * s RealWorld, Wrapper k h) => HasGetter (WrappedPointer k s h a) a Source # 

Methods

get :: MonadIO m => WrappedPointer k s h a -> m a #

((~) * s RealWorld, Wrapper k h) => HasUpdate (WrappedPointer k s h a) a a Source # 

Methods

($~) :: MonadIO m => WrappedPointer k s h a -> (a -> a) -> m () #

($~!) :: MonadIO m => WrappedPointer k s h a -> (a -> a) -> m () #

(-$>) :: forall k h xs v s. Associate k v xs => Struct s h xs -> Proxy k -> WrappedPointer s h (Repr h (k :> v)) Source #

Get a WrappedPointer from a name.

Atomic operations

atomicModify :: PrimMonad m => Struct (PrimState m) h xs -> Membership xs x -> (h x -> (h x, a)) -> m a Source #

atomicModify' :: PrimMonad m => Struct (PrimState m) h xs -> Membership xs x -> (h x -> (h x, a)) -> m a Source #

atomicModify_ :: PrimMonad m => Struct (PrimState m) h xs -> Membership xs x -> (h x -> h x) -> m (h x) Source #

atomicModify'_ :: PrimMonad m => Struct (PrimState m) h xs -> Membership xs x -> (h x -> h x) -> m (h x) Source #

Immutable product

data h :* s Source #

The type of extensible products.

(:*) :: (k -> *) -> [k] -> *

Instances

(Corepresentable p, Comonad (Corep p), Functor f) => Extensible k f p ((:*) k) Source # 

Associated Types

type ExtensibleConstr f (t :: (f -> *) -> [f] -> *) (h :: f -> *) (xs :: [f]) (x :: f) :: Constraint Source #

Methods

pieceAt :: ExtensibleConstr f t h xs x => Membership f xs x -> Optic' * * ((:*) k) p (t h xs) (h x) Source #

type ExtensibleConstr k ((:*) k) h xs x Source # 
type ExtensibleConstr k ((:*) k) h xs x = ()
data MVector s ((:*) k h xs) # 
data MVector s ((:*) k h xs) = MV_Product ((:*) k (Comp k * (MVector s) h) xs)
data Vector ((:*) k h xs) # 
data Vector ((:*) k h xs) = V_Product ((:*) k (Comp k * Vector h) xs)

unsafeFreeze :: PrimMonad m => Struct (PrimState m) h xs -> m (h :* xs) Source #

Turn Struct into an immutable product. The original Struct may not be used.

newFrom :: forall g h m xs. PrimMonad m => (g :* xs) -> (forall x. Membership xs x -> g x -> h x) -> m (Struct (PrimState m) h xs) Source #

Create a new Struct using the contents of a product.

hlookup :: Membership xs x -> (h :* xs) -> h x Source #

Get an element in a product.

hlength :: (h :* xs) -> Int Source #

The size of a product.

type family (xs :: [k]) ++ (ys :: [k]) :: [k] where ... infixr 5 Source #

Equations

'[] ++ ys = ys 
(x ': xs) ++ ys = x ': (xs ++ ys) 

happend :: (h :* xs) -> (h :* ys) -> h :* (xs ++ ys) Source #

Combine products.

hfoldrWithIndex :: (forall x. Membership xs x -> h x -> r -> r) -> r -> (h :* xs) -> r Source #

Right-associative fold of a product.

thaw :: PrimMonad m => (h :* xs) -> m (Struct (PrimState m) h xs) Source #

Create a new Struct from a product.

hfrozen :: (forall s. ST s (Struct s h xs)) -> h :* xs Source #

Create a product from an ST action which returns a Struct.

hmodify :: (forall s. Struct s h xs -> ST s ()) -> (h :* xs) -> h :* xs Source #

toHList :: forall h xs. (h :* xs) -> HList h xs Source #

Convert a product into an HList.