mischief-ecs
Safe HaskellNone
LanguageGHC2024

Mischief.ECS.World.Query

Synopsis

Documentation

has :: forall c m w. (MonadSystem w m, ToFilterComponent c) => c -> Entity -> m Bool Source #

data Query (m :: Type -> Type) a Source #

A Query is a chain of operations which return a list of values when ran.

Instances

Instances details
MonadSystem w m => Alternative (Query m) Source # 
Instance details

Defined in Mischief.ECS.World.Query

Methods

empty :: Query m a #

(<|>) :: Query m a -> Query m a -> Query m a #

some :: Query m a -> Query m [a] #

many :: Query m a -> Query m [a] #

MonadSystem w m => Applicative (Query m) Source # 
Instance details

Defined in Mischief.ECS.World.Query

Methods

pure :: a -> Query m a #

(<*>) :: Query m (a -> b) -> Query m a -> Query m b #

liftA2 :: (a -> b -> c) -> Query m a -> Query m b -> Query m c #

(*>) :: Query m a -> Query m b -> Query m b #

(<*) :: Query m a -> Query m b -> Query m a #

MonadSystem w m => Functor (Query m) Source # 
Instance details

Defined in Mischief.ECS.World.Query

Methods

fmap :: (a -> b) -> Query m a -> Query m b #

(<$) :: a -> Query m b -> Query m a #

MonadSystem w m => Monad (Query m) Source # 
Instance details

Defined in Mischief.ECS.World.Query

Methods

(>>=) :: Query m a -> (a -> Query m b) -> Query m b #

(>>) :: Query m a -> Query m b -> Query m b #

return :: a -> Query m a #

query :: MonadSystem w m => Query m out -> m [out] Source #

Run a Query, returning a list of values.

query_ :: MonadSystem w m => Query m out -> m () Source #

Run a Query.

queryOne :: MonadSystem w m => Query m out -> m (Maybe out) Source #

Run a Query, returning an arbitrary element produced by it, or nothing if the query was null.

mkQuery :: forall qd out (m :: Type -> Type). Queryable qd out => qd -> Query m out Source #

mkQuery' :: forall qd out (m :: Type -> Type). Queryable qd out => qd -> QueryFilter -> Query m out Source #

mkGet :: forall qd out (m :: Type -> Type). Queryable qd out => Entity -> qd -> Query m out Source #

mkGet' :: forall qd out (m :: Type -> Type). Queryable qd out => Entity -> qd -> QueryFilter -> Query m out Source #

single :: MonadSystem w m => Query m out -> m (Maybe out) Source #

Run a Query, returning an element only if it was the only result.

check :: forall m w. MonadSystem w m => QueryFilter -> Entity -> m Bool Source #

runWhenQ :: Typeable a => Query System a -> ([a] -> System b) -> System () Source #

Same as runWhen, but runs when the provided query is not empty.

runWhenOne :: Typeable a => Query System a -> (a -> System b) -> System () Source #

Same as runWhen, but runs when the provided query is not empty. Picks an arbitrary element to pass forward.

qcollect :: forall w (m :: Type -> Type) a. MonadSystem w m => Query m a -> Query m [a] Source #

Run a query and collect its elements into a list. The query will not stop, even if the returned list is empty.

qlift :: MonadSystem w m => m a -> Query m a Source #

Lift a system action into the query.

qiter :: forall w (m :: Type -> Type) t a. (MonadSystem w m, Foldable t) => t a -> Query m a Source #

Iterate over a Foldable (such as [] or Maybe). This will make the query run over every element from this point forward.

If you provide no elements (e.g. an empty list or Nothing), no further logic will run.

qlifter :: (MonadSystem w m, Foldable t) => m (t a) -> Query m a Source #

qlift a system and qiter over the result.

qdebug :: forall w (m :: Type -> Type). (HasCallStack, MonadSystem w m) => Text -> Query m () Source #

Logs a DEBUG message.

qinfo :: forall w (m :: Type -> Type). (HasCallStack, MonadSystem w m) => Text -> Query m () Source #

Logs an INFO message.

qwarn :: forall w (m :: Type -> Type). (HasCallStack, MonadSystem w m) => Text -> Query m () Source #

Logs a WARNING message.

qerr :: forall w (m :: Type -> Type). (HasCallStack, MonadSystem w m) => Text -> Query m () Source #

Logs an ERROR message.

qpar :: forall w (m :: Type -> Type) a. MonadSystem w m => Query ParSystem a -> Query m a Source #

Parallelize a query computation. All entities that flow through it will be divided into chunks which are ran in parallel. Automatically flushes the deferred queue after finishing.