Copyright | (c) Fumiaki Kinoshita 2018 |
---|---|
License | BSD3 |
Maintainer | Fumiaki Kinoshita <fumiexcel@gmail.com> |
Safe Haskell | None |
Language | Haskell2010 |
Mutable structs
Synopsis
- data Struct s (h :: k -> *) (xs :: [k])
- set :: PrimMonad m => Struct (PrimState m) h xs -> Membership xs x -> h x -> m ()
- get :: PrimMonad m => Struct (PrimState m) h xs -> Membership xs x -> m (h x)
- new :: forall h m xs. (PrimMonad m, Generate xs) => (forall x. Membership xs x -> h x) -> m (Struct (PrimState m) h xs)
- newRepeat :: forall h m xs. (PrimMonad m, Generate xs) => (forall x. h x) -> m (Struct (PrimState m) h xs)
- 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)
- newFromHList :: forall h m xs. PrimMonad m => HList h xs -> m (Struct (PrimState m) h xs)
- data WrappedPointer s h a where
- WrappedPointer :: !(Struct s h xs) -> !(Membership xs x) -> WrappedPointer s h (Repr h x)
- (-$>) :: forall k h xs v s. Associate k v xs => Struct s h xs -> Proxy k -> WrappedPointer s h (Repr h (k :> v))
- atomicModify :: PrimMonad m => Struct (PrimState m) h xs -> Membership xs x -> (h x -> (h x, a)) -> m a
- atomicModify' :: PrimMonad m => Struct (PrimState m) h xs -> Membership xs x -> (h x -> (h x, a)) -> m a
- atomicModify_ :: PrimMonad m => Struct (PrimState m) h xs -> Membership xs x -> (h x -> h x) -> m (h x)
- atomicModify'_ :: PrimMonad m => Struct (PrimState m) h xs -> Membership xs x -> (h x -> h x) -> m (h x)
- data (h :: k -> *) :* (s :: [k])
- unsafeFreeze :: PrimMonad m => Struct (PrimState m) h xs -> m (h :* xs)
- 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)
- hlookup :: Membership xs x -> (h :* xs) -> h x
- hlength :: (h :* xs) -> Int
- type family (xs :: [k]) ++ (ys :: [k]) :: [k] where ...
- happend :: (h :* xs) -> (h :* ys) -> h :* (xs ++ ys)
- hfoldrWithIndex :: (forall x. Membership xs x -> h x -> r -> r) -> r -> (h :* xs) -> r
- thaw :: PrimMonad m => (h :* xs) -> m (Struct (PrimState m) h xs)
- hfrozen :: (forall s. ST s (Struct s h xs)) -> h :* xs
- hmodify :: (forall s. Struct s h xs -> ST s ()) -> (h :* xs) -> h :* xs
- toHList :: forall h xs. (h :* xs) -> HList h xs
Mutable 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
.
WrappedPointer :: !(Struct s h xs) -> !(Membership xs x) -> WrappedPointer s h (Repr h x) |
Instances
(s ~ RealWorld, Wrapper h) => HasSetter (WrappedPointer s h a) a Source # | |
Defined in Data.Extensible.Struct ($=) :: MonadIO m => WrappedPointer s h a -> a -> m () # | |
(s ~ RealWorld, Wrapper h) => HasGetter (WrappedPointer s h a) a Source # | |
Defined in Data.Extensible.Struct get :: MonadIO m => WrappedPointer s h a -> m a # | |
(s ~ RealWorld, Wrapper h) => HasUpdate (WrappedPointer s h a) a a Source # | |
Defined in Data.Extensible.Struct ($~) :: MonadIO m => WrappedPointer s h a -> (a -> a) -> m () # ($~!) :: MonadIO m => WrappedPointer 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 #
Atomically modify an element in a Struct
.
atomicModify' :: PrimMonad m => Struct (PrimState m) h xs -> Membership xs x -> (h x -> (h x, a)) -> m a Source #
Strict version of atomicModify
.
atomicModify_ :: PrimMonad m => Struct (PrimState m) h xs -> Membership xs x -> (h x -> h x) -> m (h x) Source #
Apply a function to an element atomically.
atomicModify'_ :: PrimMonad m => Struct (PrimState m) h xs -> Membership xs x -> (h x -> h x) -> m (h x) Source #
Strict version of atomicModify_
.
Immutable product
data (h :: k -> *) :* (s :: [k]) Source #
The type of extensible products.
(:*) :: (k -> *) -> [k] -> *
Instances
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.
type family (xs :: [k]) ++ (ys :: [k]) :: [k] where ... infixr 5 Source #
Concatenate type level lists
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.