aztecs-0.11.1: A modular game engine and Entity-Component-System (ECS) for Haskell.
Copyright(c) Matt Hunzinger 2025
LicenseBSD-style (see the LICENSE file in the distribution)
Maintainermatt@hunzinger.me
Stabilityprovisional
Portabilitynon-portable (GHC extensions)
Safe HaskellSafe-Inferred
LanguageHaskell2010

Aztecs.ECS.Query

Description

 
Synopsis

Queries

type Query = QueryT Identity Source #

Since: 0.11

newtype QueryT f a Source #

Query for matching entities.

Since: 0.11

Constructors

Query 

Fields

Instances

Instances details
Applicative f => Applicative (QueryT f) Source #

Since: 0.11

Instance details

Defined in Aztecs.ECS.Query

Methods

pure :: a -> QueryT f a #

(<*>) :: QueryT f (a -> b) -> QueryT f a -> QueryT f b #

liftA2 :: (a -> b -> c) -> QueryT f a -> QueryT f b -> QueryT f c #

(*>) :: QueryT f a -> QueryT f b -> QueryT f b #

(<*) :: QueryT f a -> QueryT f b -> QueryT f a #

Functor (QueryT f) Source # 
Instance details

Defined in Aztecs.ECS.Query

Methods

fmap :: (a -> b) -> QueryT f a -> QueryT f b #

(<$) :: a -> QueryT f b -> QueryT f a #

Operations

entity :: QueryT f EntityID Source #

Fetch the current EntityID.

Since: 0.11

fetch :: forall f a. Component a => QueryT f a Source #

Fetch a component.

Since: 0.11

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