| Copyright | (c) Matt Hunzinger 2025 |
|---|---|
| License | BSD-style (see the LICENSE file in the distribution) |
| Maintainer | matt@hunzinger.me |
| Stability | provisional |
| Portability | non-portable (GHC extensions) |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Aztecs.ECS.Query
Description
Synopsis
- type Query = QueryT Identity
- newtype QueryT f a = Query {
- runQuery :: Components -> (Components, DynamicQueryT f a)
- entity :: QueryT f EntityID
- fetch :: forall f a. Component a => QueryT f a
- fetchMap :: forall m a. Component a => (a -> a) -> QueryT m a
- fetchMapM :: forall m a. (Monad m, Component a) => (a -> m a) -> QueryT m a
- zipFetchMap :: forall m a b. Component a => (b -> a -> a) -> QueryT m b -> QueryT m a
- zipFetchMapAccum :: forall m a b c. Component a => (b -> a -> (c, a)) -> QueryT m b -> QueryT m (c, a)
- zipFetchMapM :: forall m a b. (Monad m, Component a) => (b -> a -> m a) -> QueryT m b -> QueryT m a
- zipFetchMapAccumM :: forall m a b c. (Monad m, Component a) => (b -> a -> m (c, a)) -> QueryT m b -> QueryT m (c, a)
- with :: forall f a. Component a => QueryT f ()
- without :: forall f a. Component a => QueryT f ()
- query :: Monad m => QueryT m a -> Entities -> m ([a], Entities)
- readSingle :: (HasCallStack, Monad m) => QueryT m a -> Entities -> m (a, Entities)
- readSingle' :: (HasCallStack, Monad m) => QueryT m a -> Entities -> m (a, Components)
- readSingleMaybe :: Monad m => QueryT m a -> Entities -> m (Maybe a, Entities)
- readSingleMaybe' :: Monad m => QueryT m a -> Entities -> m (Maybe a, Components)
- querySingle :: (HasCallStack, Monad m) => QueryT m a -> Entities -> m (a, Entities)
- querySingleMaybe :: Monad m => QueryT m a -> Entities -> m (Maybe a, Entities)
- queryEntities :: Monad m => [EntityID] -> QueryT m a -> Entities -> m ([a], Entities)
- readQueryEntities :: Monad m => [EntityID] -> QueryT m a -> Entities -> m ([a], Entities)
- fromDyn :: DynamicQueryT f a -> QueryT f a
Queries
Query for matching entities.
Since: 0.11
Constructors
| Query | |
Fields
| |
Instances
| Applicative f => Applicative (QueryT f) Source # | Since: 0.11 |
| Functor (QueryT f) Source # | |
Operations
fetchMap :: forall m a. Component a => (a -> a) -> QueryT m a Source #
Fetch a component and map it, storing the result.
Since: 0.11
fetchMapM :: forall m a. (Monad m, Component a) => (a -> m a) -> QueryT m a Source #
Fetch a component and map it with a monadic function, storing the result.
Since: 0.11
zipFetchMap :: forall m a b. Component a => (b -> a -> a) -> QueryT m b -> QueryT m a Source #
Fetch a component and map it with some input, storing the result.
Since: 0.11
zipFetchMapAccum :: forall m a b c. Component a => (b -> a -> (c, a)) -> QueryT m b -> QueryT m (c, a) Source #
Fetch a component and map it with some input, storing the result and returning some output.
Since: 0.11
zipFetchMapM :: forall m a b. (Monad m, Component a) => (b -> a -> m a) -> QueryT m b -> QueryT m a Source #
Fetch a component and map it with some input and a monadic function, storing the result.
Since: 0.11
zipFetchMapAccumM :: forall m a b c. (Monad m, Component a) => (b -> a -> m (c, a)) -> QueryT m b -> QueryT m (c, a) Source #
Fetch a component and map it with some input and a monadic function, storing the result and returning some output.
Since: 0.11
Filters
with :: forall f a. Component a => QueryT f () Source #
Filter for entities with a component.
Since: 0.11
without :: forall f a. Component a => QueryT f () Source #
Filter for entities without a component.
Since: 0.11
Running
query :: Monad m => QueryT m a -> Entities -> m ([a], Entities) Source #
Match and update all entities.
Since: 0.11
readSingle :: (HasCallStack, Monad m) => QueryT m a -> Entities -> m (a, Entities) Source #
Match a single entity.
Since: 0.11
readSingle' :: (HasCallStack, Monad m) => QueryT m a -> Entities -> m (a, Components) Source #
Match a single entity.
Since: 0.11
readSingleMaybe :: Monad m => QueryT m a -> Entities -> m (Maybe a, Entities) Source #
Match a single entity, or Nothing.
Since: 0.11
readSingleMaybe' :: Monad m => QueryT m a -> Entities -> m (Maybe a, Components) Source #
Match a single entity, or Nothing.
Since: 0.11
querySingle :: (HasCallStack, Monad m) => QueryT m a -> Entities -> m (a, Entities) Source #
Match and update a single matched entity.
Since: 0.11
querySingleMaybe :: Monad m => QueryT m a -> Entities -> m (Maybe a, Entities) Source #
Match and update a single matched entity, or Nothing.
Since: 0.11
queryEntities :: Monad m => [EntityID] -> QueryT m a -> Entities -> m ([a], Entities) Source #
Match and update the specified entities.
Since: 0.11
readQueryEntities :: Monad m => [EntityID] -> QueryT m a -> Entities -> m ([a], Entities) Source #
Match the specified entities.
Since: 0.11
Conversion
fromDyn :: DynamicQueryT f a -> QueryT f a Source #
Convert a DynamicQueryT to a QueryT.
Since: 0.11