aztecs-0.12.0: 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

fetchMaybe :: forall f a. Component a => QueryT f (Maybe a) Source #

Fetch a component, or Nothing.

Since: 0.12

fetchMap :: forall f a. Component a => (a -> a) -> QueryT f a Source #

Fetch a component and map it, storing the result.

Since: 0.11

fetchMapM :: forall f a. (Monad f, Component a) => (a -> f a) -> QueryT f a Source #

Fetch a component and map it with a monadic function, storing the result.

Since: 0.11

zipFetchMap :: forall f a b. Component a => (b -> a -> a) -> QueryT f b -> QueryT f a Source #

Fetch a component and map it with some input, storing the result.

Since: 0.11

zipFetchMapAccum :: forall f a b c. Component a => (b -> a -> (c, a)) -> QueryT f b -> QueryT f (c, a) Source #

Fetch a component and map it with some input, storing the result and returning some output.

Since: 0.11

zipFetchMapM :: forall f a b. (Monad f, Component a) => (b -> a -> f a) -> QueryT f b -> QueryT f a Source #

Fetch a component and map it with some input and a monadic function, storing the result.

Since: 0.11

zipFetchMapAccumM :: forall f a b c. (Monad f, Component a) => (b -> a -> f (c, a)) -> QueryT f b -> QueryT f (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

Conversion

fromDyn :: DynamicQueryT f a -> QueryT f a Source #

Convert a DynamicQueryT to a QueryT.

Since: 0.11

liftQuery :: (MonadTrans g, Monad (g f), Monad f) => QueryT f a -> QueryT (g f) a Source #

Running

Writing

query :: Applicative f => QueryT f a -> Entities -> f ([a], Entities) Source #

Match and update all entities.

Since: 0.11

querySingle :: (HasCallStack, Applicative f) => QueryT f a -> Entities -> f (a, Entities) Source #

Match and update a single matched entity.

Since: 0.12

querySingleMaybe :: Applicative m => QueryT m a -> Entities -> m (Maybe a, Entities) Source #

Match and update a single matched entity, or Nothing.

Since: 0.12

queryEntities :: Monad m => [EntityID] -> QueryT m a -> Entities -> m ([a], Entities) Source #

Match and update the specified entities.

Since: 0.12

Reading

readQueryEntities :: Applicative f => [EntityID] -> QueryT f a -> Entities -> f ([a], Entities) Source #

Match the specified entities.

Since: 0.12

readQuery :: Applicative f => QueryT f a -> Entities -> f ([a], Entities) Source #

Match and update all entities.

Since: 0.12

readQuerySingle :: (HasCallStack, Applicative f) => QueryT f a -> Entities -> f (a, Entities) Source #

Match a single entity.

Since: 0.12

readQuerySingleMaybe :: Applicative f => QueryT f a -> Entities -> f (Maybe a, Entities) Source #

Match a single entity, or Nothing.

Since: 0.12