Copyright | (c) Fumiaki Kinoshita 2018 |
---|---|
License | BSD3 |
Maintainer | Fumiaki Kinoshita <[email protected]> |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Data.Extensible.Struct
Description
Mutable structs
Synopsis
- data Struct s (h :: k -> Type) (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. Lookup xs k v => 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 (s :: [k]) :& (h :: k -> Type)
- type (:*) h xs = xs :& h
- unsafeFreeze :: PrimMonad m => Struct (PrimState m) h xs -> m (xs :& h)
- newFrom :: forall g h m xs. PrimMonad m => (xs :& g) -> (forall x. Membership xs x -> g x -> h x) -> m (Struct (PrimState m) h xs)
- hlookup :: Membership xs x -> (xs :& h) -> h x
- hlength :: (xs :& h) -> Int
- type family (xs :: [k]) ++ (ys :: [k]) :: [k] where ...
- happend :: (xs :& h) -> (ys :& h) -> (xs ++ ys) :& h
- hfoldrWithIndex :: (forall x. Membership xs x -> h x -> r -> r) -> r -> (xs :& h) -> r
- thaw :: PrimMonad m => (xs :& h) -> m (Struct (PrimState m) h xs)
- hfrozen :: (forall s. ST s (Struct s h xs)) -> xs :& h
- hmodify :: (forall s. Struct s h xs -> ST s ()) -> (xs :& h) -> xs :& h
- toHList :: forall h xs. (xs :& h) -> 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
.
Constructors
WrappedPointer :: !(Struct s h xs) -> !(Membership xs x) -> WrappedPointer s h (Repr h x) |
Instances
(s ~ RealWorld, Wrapper h) => HasGetter (WrappedPointer s h a) a Source # | |
Defined in Data.Extensible.Struct Methods get :: MonadIO m => WrappedPointer s h a -> m a # | |
(s ~ RealWorld, Wrapper h) => HasSetter (WrappedPointer s h a) a Source # | |
Defined in Data.Extensible.Struct Methods ($=) :: MonadIO m => WrappedPointer s h a -> a -> m () # | |
(s ~ RealWorld, Wrapper h) => HasUpdate (WrappedPointer s h a) a a Source # | |
Defined in Data.Extensible.Struct Methods ($~) :: MonadIO m => WrappedPointer s h a -> (a -> a) -> m () # ($~!) :: MonadIO m => WrappedPointer s h a -> (a -> a) -> m () # |
(-$>) :: forall k h xs v s. Lookup xs k v => 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 (s :: [k]) :& (h :: k -> Type) Source #
The type of extensible products.
(:&) :: [k] -> (k -> Type) -> Type
Instances
(Corepresentable p, Comonad (Corep p), Functor f) => Extensible f p ((:&) :: [k] -> (k -> Type) -> Type) Source # | |
Defined in Data.Extensible.Struct Associated Types type ExtensibleConstr (:&) xs h x Source # Methods pieceAt :: forall (xs :: [k0]) h (x :: k0). ExtensibleConstr (:&) xs h x => Membership xs x -> Optic' p f (xs :& h) (h x) Source # | |
(Lookup xs k2 v2, Wrapper h, Repr h v2 ~ a) => HasField (k2 :: k1) (RecordOf h xs) a Source # | |
Defined in Data.Extensible.Dictionary | |
WrapForall (Lift :: Type -> Constraint) h xs => Lift (xs :& h :: Type) Source # | |
WrapForall Unbox h (x ': xs) => Vector Vector ((x ': xs) :& h) | |
Defined in Data.Extensible.Dictionary Methods basicUnsafeFreeze :: Mutable Vector s ((x ': xs) :& h) -> ST s (Vector ((x ': xs) :& h)) basicUnsafeThaw :: Vector ((x ': xs) :& h) -> ST s (Mutable Vector s ((x ': xs) :& h)) basicLength :: Vector ((x ': xs) :& h) -> Int basicUnsafeSlice :: Int -> Int -> Vector ((x ': xs) :& h) -> Vector ((x ': xs) :& h) basicUnsafeIndexM :: Vector ((x ': xs) :& h) -> Int -> Box ((x ': xs) :& h) basicUnsafeCopy :: Mutable Vector s ((x ': xs) :& h) -> Vector ((x ': xs) :& h) -> ST s () elemseq :: Vector ((x ': xs) :& h) -> ((x ': xs) :& h) -> b -> b | |
WrapForall Unbox h (x ': xs) => MVector MVector ((x ': xs) :& h) | |
Defined in Data.Extensible.Dictionary Methods basicLength :: MVector s ((x ': xs) :& h) -> Int basicUnsafeSlice :: Int -> Int -> MVector s ((x ': xs) :& h) -> MVector s ((x ': xs) :& h) basicOverlaps :: MVector s ((x ': xs) :& h) -> MVector s ((x ': xs) :& h) -> Bool basicUnsafeNew :: Int -> ST s (MVector s ((x ': xs) :& h)) basicInitialize :: MVector s ((x ': xs) :& h) -> ST s () basicUnsafeReplicate :: Int -> ((x ': xs) :& h) -> ST s (MVector s ((x ': xs) :& h)) basicUnsafeRead :: MVector s ((x ': xs) :& h) -> Int -> ST s ((x ': xs) :& h) basicUnsafeWrite :: MVector s ((x ': xs) :& h) -> Int -> ((x ': xs) :& h) -> ST s () basicClear :: MVector s ((x ': xs) :& h) -> ST s () basicSet :: MVector s ((x ': xs) :& h) -> ((x ': xs) :& h) -> ST s () basicUnsafeCopy :: MVector s ((x ': xs) :& h) -> MVector s ((x ': xs) :& h) -> ST s () basicUnsafeMove :: MVector s ((x ': xs) :& h) -> MVector s ((x ': xs) :& h) -> ST s () basicUnsafeGrow :: MVector s ((x ': xs) :& h) -> Int -> ST s (MVector s ((x ': xs) :& h)) | |
WrapForall Arbitrary h xs => Arbitrary (xs :& h) Source # | |
Forall (KeyTargetAre KnownSymbol (Instance1 FromJSON h)) xs => FromJSON (xs :& (Field h :: Assoc Symbol v -> Type)) Source # |
|
Forall (KeyTargetAre KnownSymbol (Instance1 FromJSON h)) xs => FromJSON (xs :& Nullable (Field h :: Assoc Symbol v -> Type)) Source # | |
Forall (KeyTargetAre KnownSymbol (Instance1 ToJSON h)) xs => ToJSON (xs :& (Field h :: Assoc Symbol v -> Type)) Source # | |
Forall (KeyTargetAre KnownSymbol (Instance1 ToJSON h)) xs => ToJSON (xs :& Nullable (Field h :: Assoc Symbol v -> Type)) Source # | |
Defined in Data.Extensible.Dictionary | |
(WrapForall Semigroup h xs, WrapForall Monoid h xs) => Monoid (xs :& h) Source # | |
WrapForall Semigroup h xs => Semigroup (xs :& h) Source # | |
WrapForall Bounded h xs => Bounded (xs :& h) Source # | |
WrapForall Show h xs => Show (xs :& h) Source # | |
Forall (KeyTargetAre KnownSymbol (Instance1 FromField h)) xs => FromNamedRecord (xs :& (Field h :: Assoc Symbol v -> Type)) Source # | |
Defined in Data.Extensible.Dictionary Methods parseNamedRecord :: NamedRecord -> Parser (xs :& Field h) # | |
WrapForall FromField h xs => FromRecord (xs :& h) Source # | |
Defined in Data.Extensible.Dictionary Methods parseRecord :: Record -> Parser (xs :& h) # | |
Forall (KeyTargetAre KnownSymbol (Instance1 ToField h)) xs => ToNamedRecord (xs :& (Field h :: Assoc Symbol v -> Type)) Source # | |
Defined in Data.Extensible.Dictionary Methods toNamedRecord :: (xs :& Field h) -> NamedRecord # | |
WrapForall ToField h xs => ToRecord (xs :& h) Source # | |
Defined in Data.Extensible.Dictionary | |
WrapForall NFData h xs => NFData (xs :& h) Source # | |
Defined in Data.Extensible.Dictionary | |
WrapForall Eq h xs => Eq (xs :& h) Source # | |
(Eq (xs :& h), WrapForall Ord h xs) => Ord (xs :& h) Source # | |
Defined in Data.Extensible.Dictionary | |
(WrapForall Eq h xs, WrapForall Hashable h xs) => Hashable (xs :& h) Source # | |
Defined in Data.Extensible.Dictionary | |
WrapForall Incremental h xs => Incremental (xs :& h) Source # | |
WrapForall Pretty h xs => Pretty (xs :& h) Source # | |
Defined in Data.Extensible.Dictionary | |
WrapForall Unbox h (x ': xs) => Unbox ((x ': xs) :& h) | |
Defined in Data.Extensible.Dictionary | |
Forall (KeyIs KnownSymbol :: Assoc Symbol v -> Constraint) xs => DefaultOrdered (RecordOf h xs) Source # | |
Defined in Data.Extensible.Dictionary Methods headerOrder :: RecordOf h xs -> Header # | |
type ExtensibleConstr ((:&) :: [k] -> (k -> Type) -> Type) (xs :: [k]) (h :: k -> Type) (x :: k) Source # | |
Defined in Data.Extensible.Struct type ExtensibleConstr ((:&) :: [k] -> (k -> Type) -> Type) (xs :: [k]) (h :: k -> Type) (x :: k) = () | |
newtype MVector s (xs :& h) | |
Defined in Data.Extensible.Dictionary | |
type Delta (xs :& h) Source # | |
Defined in Data.Extensible.Dictionary | |
newtype Vector (xs :& h) | |
Defined in Data.Extensible.Dictionary |
newFrom :: forall g h m xs. PrimMonad m => (xs :& g) -> (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 -> (xs :& h) -> 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 -> (xs :& h) -> r Source #
Right-associative fold of a product.
thaw :: PrimMonad m => (xs :& h) -> m (Struct (PrimState m) h xs) Source #
Create a new Struct
from a product.