-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Fast Entity-Component-System library for game programming -- -- apecs is a fast, type-driven Entity-Component-System library for game -- programming. @package apecs @version 0.9.2 module Apecs.Core -- | An Entity is just an integer, used to index into a component store. In -- general, use newEntity, cmap, and component tags -- instead of manipulating these directly. -- -- For performance reasons, negative values like (-1) are reserved for -- stores to represent special values, so avoid using these. newtype Entity Entity :: Int -> Entity [unEntity] :: Entity -> Int -- | A SystemT is a newtype around `ReaderT w m a`, where w is the -- game world variable. Systems serve to -- -- newtype SystemT w m a SystemT :: ReaderT w m a -> SystemT w m a [unSystem] :: SystemT w m a -> ReaderT w m a type System w a = SystemT w IO a -- | A component is defined by specifying how it is stored. The constraint -- ensures that stores and components are mapped one-to-one. class (Elem (Storage c) ~ c) => Component c where { type family Storage c; } -- | Has w m c means that world w can produce a -- Storage c. It is parameterized over m to allow -- stores to be foreign. class (Monad m, Component c) => Has w m c getStore :: Has w m c => SystemT w m (Storage c) -- | The type of components stored by a store, e.g. Elem (Map c) = -- c. type family Elem s -- | Indicates that the store s can be initialized. Generally, -- "base" stores like Map c can be initialized, but composite -- stores like MaybeStore s cannot. class ExplInit m s -- | Initialize a new empty store. explInit :: ExplInit m s => m s -- | Stores that we can read using explGet and -- explExists. For some entity e, eplGet s e -- is only guaranteed to be safe if explExists s e returns -- True. class Monad m => ExplGet m s -- | Reads a component from the store. What happens if the component does -- not exist is left undefined, and might not necessarily crash. explGet :: ExplGet m s => s -> Int -> m (Elem s) -- | Returns whether there is a component for the given index. explExists :: ExplGet m s => s -> Int -> m Bool -- | Stores that can be written. class Monad m => ExplSet m s -- | Writes a component to the store. explSet :: ExplSet m s => s -> Int -> Elem s -> m () -- | Stores that components can be removed from. class Monad m => ExplDestroy m s -- | Destroys the component for a given index. explDestroy :: ExplDestroy m s => s -> Int -> m () -- | Stores that we can request a list of member entities for. class Monad m => ExplMembers m s -- | Returns an unboxed vector of member indices explMembers :: ExplMembers m s => s -> m (Vector Int) type Get w m c = (Has w m c, ExplGet m (Storage c)) type Set w m c = (Has w m c, ExplSet m (Storage c)) type Members w m c = (Has w m c, ExplMembers m (Storage c)) type Destroy w m c = (Has w m c, ExplDestroy m (Storage c)) instance Control.Monad.Catch.MonadMask m => Control.Monad.Catch.MonadMask (Apecs.Core.SystemT w m) instance Control.Monad.Catch.MonadCatch m => Control.Monad.Catch.MonadCatch (Apecs.Core.SystemT w m) instance Control.Monad.Catch.MonadThrow m => Control.Monad.Catch.MonadThrow (Apecs.Core.SystemT w m) instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Apecs.Core.SystemT w m) instance Control.Monad.Trans.Class.MonadTrans (Apecs.Core.SystemT w) instance GHC.Base.Applicative m => GHC.Base.Applicative (Apecs.Core.SystemT w m) instance GHC.Base.Monad m => GHC.Base.Monad (Apecs.Core.SystemT w m) instance GHC.Base.Functor m => GHC.Base.Functor (Apecs.Core.SystemT w m) instance GHC.Enum.Enum Apecs.Core.Entity instance GHC.Show.Show Apecs.Core.Entity instance GHC.Classes.Ord Apecs.Core.Entity instance GHC.Classes.Eq Apecs.Core.Entity instance GHC.Num.Num Apecs.Core.Entity instance GHC.Base.Monad m => Control.Monad.Reader.Class.MonadReader w (Apecs.Core.SystemT w m) -- | This module is experimental, and its API might change between point -- releases. Use at your own risk. - module Apecs.Experimental.Components -- | Pseudocomponent that when written to, actually writes c to -- its entity argument. Can be used to write to other entities in a -- cmap. data Redirect c Redirect :: Entity -> c -> Redirect c -- | Pseudocomponent that can be read like any other component, but will -- only yield a single member when iterated over. Intended to be used as -- cmap $ Head (...) -> ... newtype Head c Head :: c -> Head c instance GHC.Show.Show c => GHC.Show.Show (Apecs.Experimental.Components.Head c) instance GHC.Classes.Eq c => GHC.Classes.Eq (Apecs.Experimental.Components.Head c) instance GHC.Show.Show c => GHC.Show.Show (Apecs.Experimental.Components.Redirect c) instance GHC.Classes.Eq c => GHC.Classes.Eq (Apecs.Experimental.Components.Redirect c) instance Apecs.Core.Component c => Apecs.Core.Component (Apecs.Experimental.Components.Head c) instance Apecs.Core.Has w m c => Apecs.Core.Has w m (Apecs.Experimental.Components.Head c) instance Apecs.Core.ExplGet m s => Apecs.Core.ExplGet m (Apecs.Experimental.Components.HeadStore s) instance Apecs.Core.ExplMembers m s => Apecs.Core.ExplMembers m (Apecs.Experimental.Components.HeadStore s) instance Apecs.Core.Component c => Apecs.Core.Component (Apecs.Experimental.Components.Redirect c) instance Apecs.Core.Has w m c => Apecs.Core.Has w m (Apecs.Experimental.Components.Redirect c) instance Apecs.Core.ExplSet m s => Apecs.Core.ExplSet m (Apecs.Experimental.Components.RedirectStore s) -- | This module is experimental, and its API might change between point -- releases. Use at your own risk. - module Apecs.Experimental.Util -- | Quantize turns a world-space coordinate into a table-space coordinate -- by dividing by the given cell size and rounding towards negative -- infinity. quantize :: (Fractional (v a), Integral b, RealFrac a, Functor v) => v a -> v a -> v b -- | Turns a table-space vector into an integral index, given some table -- size vector. Yields Nothing for out-of-bounds queries flatten :: (Applicative v, Integral a, Foldable v) => v a -> v a -> Maybe a -- | Tests whether a vector is in the region given by 0 and the size vector -- (inclusive) inbounds :: (Num a, Ord a, Applicative v, Foldable v) => v a -> v a -> Bool -- | For two table-space vectors indicating a region's bounds, gives a list -- of the vectors contained between them. This is useful for querying a -- spatial hash. region :: (Enum a, Applicative v, Traversable v) => v a -> v a -> [v a] -- | flatten, but yields garbage for out-of-bounds vectors. flatten' :: (Applicative v, Integral a, Foldable v) => v a -> v a -> a module Apecs.Stores -- | A map based on Strict. O(log(n)) for most operations. data Map c -- | A cache around another store. Caches store their members in a -- fixed-size vector, so read/write operations become O(1). Caches can -- provide huge performance boosts, especially when working with large -- numbers of components. -- -- The cache size is given as a type-level argument. -- -- Note that iterating over a cache is linear in cache size, so sparsely -- populated caches might decrease performance. In general, the -- exact size of the cache does not matter as long as it reasonably -- approximates the number of components present. -- -- The cache uses entity (-2) internally to represent missing entities. -- If you manually manipulate Entity values, be careful that you do not -- use (-2) -- -- The actual cache is not necessarily the given argument, but the next -- biggest power of two. This is allows most operations to be expressed -- as bit masks, for a large potential performance boost. data Cache (n :: Nat) s -- | A Unique contains zero or one component. Writing to it overwrites both -- the previous component and its owner. Its main purpose is to be a -- Map optimized for when only ever one component inhabits it. data Unique c -- | A Global contains exactly one component. The initial value is -- mempty from the component's Monoid instance. Querying a -- Global at any Entity yields this one component, -- effectively sharing the component between all entities. -- -- A Global component can be read with get 0 or -- get 1 or even get undefined. The -- convenience entity global is defined as -1, and can be used -- to make operations on a global more explicit, i.e. 'Time t <- get -- global'. -- -- You also can read and write Globals during a cmap over other -- components. data Global c -- | Class of stores that behave like a regular map, and can therefore -- safely be cached. This prevents stores like Unique and -- Global, which do not behave like simple maps, from being -- cached. class Cachable s -- | Wrapper that makes a store read-only by hiding its ExplSet and -- ExplDestroy instances. This is primarily used to protect the -- EntityCounter from accidental overwrites. Use -- setReadOnly and destroyReadOnly to override. data ReadOnly s setReadOnly :: forall w m s c. (Has w m c, Storage c ~ ReadOnly s, Elem s ~ c, ExplSet m s) => Entity -> c -> SystemT w m () destroyReadOnly :: forall w m s c. (Has w m c, Storage c ~ ReadOnly s, Elem s ~ c, ExplDestroy m s) => Entity -> Proxy c -> SystemT w m () instance (GHC.Base.Functor m, Apecs.Core.ExplInit m s) => Apecs.Core.ExplInit m (Apecs.Stores.ReadOnly s) instance Apecs.Core.ExplGet m s => Apecs.Core.ExplGet m (Apecs.Stores.ReadOnly s) instance Apecs.Core.ExplMembers m s => Apecs.Core.ExplMembers m (Apecs.Stores.ReadOnly s) instance (GHC.TypeNats.KnownNat n, Apecs.Stores.Cachable s) => Apecs.Stores.Cachable (Apecs.Stores.Cache n s) instance (Control.Monad.IO.Class.MonadIO m, Apecs.Core.ExplInit m s, GHC.TypeNats.KnownNat n, Apecs.Stores.Cachable s) => Apecs.Core.ExplInit m (Apecs.Stores.Cache n s) instance (Control.Monad.IO.Class.MonadIO m, Apecs.Core.ExplGet m s) => Apecs.Core.ExplGet m (Apecs.Stores.Cache n s) instance (Control.Monad.IO.Class.MonadIO m, Apecs.Core.ExplSet m s) => Apecs.Core.ExplSet m (Apecs.Stores.Cache n s) instance (Control.Monad.IO.Class.MonadIO m, Apecs.Core.ExplDestroy m s) => Apecs.Core.ExplDestroy m (Apecs.Stores.Cache n s) instance (Control.Monad.IO.Class.MonadIO m, Apecs.Core.ExplMembers m s) => Apecs.Core.ExplMembers m (Apecs.Stores.Cache n s) instance Apecs.Stores.Cachable (Apecs.Stores.Map s) instance (GHC.Base.Monoid c, Control.Monad.IO.Class.MonadIO m) => Apecs.Core.ExplInit m (Apecs.Stores.Global c) instance Control.Monad.IO.Class.MonadIO m => Apecs.Core.ExplGet m (Apecs.Stores.Global c) instance Control.Monad.IO.Class.MonadIO m => Apecs.Core.ExplSet m (Apecs.Stores.Global c) instance Control.Monad.IO.Class.MonadIO m => Apecs.Core.ExplInit m (Apecs.Stores.Unique c) instance (Control.Monad.IO.Class.MonadIO m, Data.Typeable.Internal.Typeable c) => Apecs.Core.ExplGet m (Apecs.Stores.Unique c) instance Control.Monad.IO.Class.MonadIO m => Apecs.Core.ExplSet m (Apecs.Stores.Unique c) instance Control.Monad.IO.Class.MonadIO m => Apecs.Core.ExplDestroy m (Apecs.Stores.Unique c) instance Control.Monad.IO.Class.MonadIO m => Apecs.Core.ExplMembers m (Apecs.Stores.Unique c) instance Control.Monad.IO.Class.MonadIO m => Apecs.Core.ExplInit m (Apecs.Stores.Map c) instance (Control.Monad.IO.Class.MonadIO m, Data.Typeable.Internal.Typeable c) => Apecs.Core.ExplGet m (Apecs.Stores.Map c) instance Control.Monad.IO.Class.MonadIO m => Apecs.Core.ExplSet m (Apecs.Stores.Map c) instance Control.Monad.IO.Class.MonadIO m => Apecs.Core.ExplDestroy m (Apecs.Stores.Map c) instance Control.Monad.IO.Class.MonadIO m => Apecs.Core.ExplMembers m (Apecs.Stores.Map c) module Apecs.Components -- | Pseudocomponent indicating the absence of a. Mainly used as -- e.g. cmap $ (a, Not b) -> c to iterate over entities with -- an a but no b. Can also be used to delete -- components, like cmap $ a -> (Not :: Not a) to delete -- every a component. data Not a Not :: Not a -- | Pseudostore used to produce values of type Not a, inverts -- explExists, and destroys instead of explSet. newtype NotStore s NotStore :: s -> NotStore s -- | Pseudostore used to produce values of type Maybe a. Will -- always return True for explExists. Writing can both -- set and delete a component using Just and Nothing -- respectively. newtype MaybeStore s MaybeStore :: s -> MaybeStore s -- | Used for Either, a logical disjunction between two components. -- As expected, Either is used to model error values. Getting an -- Either a b will first attempt to get a b and return -- it as Right b, or if it does not exist, get an a as -- Left a. Can also be used to set one of two things. data EitherStore sa sb EitherStore :: sa -> sb -> EitherStore sa sb -- | Pseudocomponent that functions normally for explExists and -- explMembers, but always return Filter for -- explGet. Can be used in cmap as cmap $ (Filter :: Filter -- a) -> b. Since the above can be written more consicely as -- cmap $ (_ :: a) -> b, it is rarely directly. More -- interestingly, we can define reusable filters like movables = -- Filter :: Filter (Position, Velocity). Note that 'Filter c' is -- equivalent to 'Not (Not c)'. data Filter c Filter :: Filter c newtype FilterStore s FilterStore :: s -> FilterStore s -- | Pseudostore used to produce components of type Entity. Always -- returns True for explExists, and echoes back the -- entity argument for explGet. Used in e.g. cmap $ (a, ety -- :: Entity) -> b to access the current entity. data EntityStore EntityStore :: EntityStore instance GHC.Show.Show (Apecs.Components.Filter c) instance GHC.Classes.Eq (Apecs.Components.Filter c) instance Apecs.Core.Component Apecs.Core.Entity instance GHC.Base.Monad m => Apecs.Core.Has w m Apecs.Core.Entity instance GHC.Base.Monad m => Apecs.Core.ExplGet m Apecs.Components.EntityStore instance Apecs.Core.Component c => Apecs.Core.Component (Apecs.Components.Filter c) instance Apecs.Core.Has w m c => Apecs.Core.Has w m (Apecs.Components.Filter c) instance Apecs.Core.ExplGet m s => Apecs.Core.ExplGet m (Apecs.Components.FilterStore s) instance Apecs.Core.ExplMembers m s => Apecs.Core.ExplMembers m (Apecs.Components.FilterStore s) instance (Apecs.Core.Component ca, Apecs.Core.Component cb) => Apecs.Core.Component (Data.Either.Either ca cb) instance (Apecs.Core.Has w m ca, Apecs.Core.Has w m cb) => Apecs.Core.Has w m (Data.Either.Either ca cb) instance (Apecs.Core.ExplGet m sa, Apecs.Core.ExplGet m sb) => Apecs.Core.ExplGet m (Apecs.Components.EitherStore sa sb) instance (Apecs.Core.ExplSet m sa, Apecs.Core.ExplSet m sb) => Apecs.Core.ExplSet m (Apecs.Components.EitherStore sa sb) instance (Apecs.Core.ExplDestroy m sa, Apecs.Core.ExplDestroy m sb) => Apecs.Core.ExplDestroy m (Apecs.Components.EitherStore sa sb) instance Apecs.Core.Component c => Apecs.Core.Component (GHC.Maybe.Maybe c) instance Apecs.Core.Has w m c => Apecs.Core.Has w m (GHC.Maybe.Maybe c) instance Apecs.Core.ExplGet m s => Apecs.Core.ExplGet m (Apecs.Components.MaybeStore s) instance (Apecs.Core.ExplDestroy m s, Apecs.Core.ExplSet m s) => Apecs.Core.ExplSet m (Apecs.Components.MaybeStore s) instance Apecs.Core.Component c => Apecs.Core.Component (Apecs.Components.Not c) instance Apecs.Core.Has w m c => Apecs.Core.Has w m (Apecs.Components.Not c) instance Apecs.Core.ExplGet m s => Apecs.Core.ExplGet m (Apecs.Components.NotStore s) instance Apecs.Core.ExplDestroy m s => Apecs.Core.ExplSet m (Apecs.Components.NotStore s) instance (Apecs.Core.Component t_0, Apecs.Core.Component t_1) => Apecs.Core.Component (t_0, t_1) instance (Apecs.Core.Has w m t_0, Apecs.Core.Has w m t_1) => Apecs.Core.Has w m (t_0, t_1) instance (Apecs.Core.ExplGet m t_0, Apecs.Core.ExplGet m t_1) => Apecs.Core.ExplGet m (t_0, t_1) instance (Apecs.Core.ExplSet m t_0, Apecs.Core.ExplSet m t_1) => Apecs.Core.ExplSet m (t_0, t_1) instance (Apecs.Core.ExplDestroy m t_0, Apecs.Core.ExplDestroy m t_1) => Apecs.Core.ExplDestroy m (t_0, t_1) instance (Apecs.Core.ExplMembers m t_0, Apecs.Core.ExplGet m t_1) => Apecs.Core.ExplMembers m (t_0, t_1) instance (Apecs.Core.Component t_0, Apecs.Core.Component t_1, Apecs.Core.Component t_2) => Apecs.Core.Component (t_0, t_1, t_2) instance (Apecs.Core.Has w m t_0, Apecs.Core.Has w m t_1, Apecs.Core.Has w m t_2) => Apecs.Core.Has w m (t_0, t_1, t_2) instance (Apecs.Core.ExplGet m t_0, Apecs.Core.ExplGet m t_1, Apecs.Core.ExplGet m t_2) => Apecs.Core.ExplGet m (t_0, t_1, t_2) instance (Apecs.Core.ExplSet m t_0, Apecs.Core.ExplSet m t_1, Apecs.Core.ExplSet m t_2) => Apecs.Core.ExplSet m (t_0, t_1, t_2) instance (Apecs.Core.ExplDestroy m t_0, Apecs.Core.ExplDestroy m t_1, Apecs.Core.ExplDestroy m t_2) => Apecs.Core.ExplDestroy m (t_0, t_1, t_2) instance (Apecs.Core.ExplMembers m t_0, Apecs.Core.ExplGet m t_1, Apecs.Core.ExplGet m t_2) => Apecs.Core.ExplMembers m (t_0, t_1, t_2) instance (Apecs.Core.Component t_0, Apecs.Core.Component t_1, Apecs.Core.Component t_2, Apecs.Core.Component t_3) => Apecs.Core.Component (t_0, t_1, t_2, t_3) instance (Apecs.Core.Has w m t_0, Apecs.Core.Has w m t_1, Apecs.Core.Has w m t_2, Apecs.Core.Has w m t_3) => Apecs.Core.Has w m (t_0, t_1, t_2, t_3) instance (Apecs.Core.ExplGet m t_0, Apecs.Core.ExplGet m t_1, Apecs.Core.ExplGet m t_2, Apecs.Core.ExplGet m t_3) => Apecs.Core.ExplGet m (t_0, t_1, t_2, t_3) instance (Apecs.Core.ExplSet m t_0, Apecs.Core.ExplSet m t_1, Apecs.Core.ExplSet m t_2, Apecs.Core.ExplSet m t_3) => Apecs.Core.ExplSet m (t_0, t_1, t_2, t_3) instance (Apecs.Core.ExplDestroy m t_0, Apecs.Core.ExplDestroy m t_1, Apecs.Core.ExplDestroy m t_2, Apecs.Core.ExplDestroy m t_3) => Apecs.Core.ExplDestroy m (t_0, t_1, t_2, t_3) instance (Apecs.Core.ExplMembers m t_0, Apecs.Core.ExplGet m t_1, Apecs.Core.ExplGet m t_2, Apecs.Core.ExplGet m t_3) => Apecs.Core.ExplMembers m (t_0, t_1, t_2, t_3) instance (Apecs.Core.Component t_0, Apecs.Core.Component t_1, Apecs.Core.Component t_2, Apecs.Core.Component t_3, Apecs.Core.Component t_4) => Apecs.Core.Component (t_0, t_1, t_2, t_3, t_4) instance (Apecs.Core.Has w m t_0, Apecs.Core.Has w m t_1, Apecs.Core.Has w m t_2, Apecs.Core.Has w m t_3, Apecs.Core.Has w m t_4) => Apecs.Core.Has w m (t_0, t_1, t_2, t_3, t_4) instance (Apecs.Core.ExplGet m t_0, Apecs.Core.ExplGet m t_1, Apecs.Core.ExplGet m t_2, Apecs.Core.ExplGet m t_3, Apecs.Core.ExplGet m t_4) => Apecs.Core.ExplGet m (t_0, t_1, t_2, t_3, t_4) instance (Apecs.Core.ExplSet m t_0, Apecs.Core.ExplSet m t_1, Apecs.Core.ExplSet m t_2, Apecs.Core.ExplSet m t_3, Apecs.Core.ExplSet m t_4) => Apecs.Core.ExplSet m (t_0, t_1, t_2, t_3, t_4) instance (Apecs.Core.ExplDestroy m t_0, Apecs.Core.ExplDestroy m t_1, Apecs.Core.ExplDestroy m t_2, Apecs.Core.ExplDestroy m t_3, Apecs.Core.ExplDestroy m t_4) => Apecs.Core.ExplDestroy m (t_0, t_1, t_2, t_3, t_4) instance (Apecs.Core.ExplMembers m t_0, Apecs.Core.ExplGet m t_1, Apecs.Core.ExplGet m t_2, Apecs.Core.ExplGet m t_3, Apecs.Core.ExplGet m t_4) => Apecs.Core.ExplMembers m (t_0, t_1, t_2, t_3, t_4) instance (Apecs.Core.Component t_0, Apecs.Core.Component t_1, Apecs.Core.Component t_2, Apecs.Core.Component t_3, Apecs.Core.Component t_4, Apecs.Core.Component t_5) => Apecs.Core.Component (t_0, t_1, t_2, t_3, t_4, t_5) instance (Apecs.Core.Has w m t_0, Apecs.Core.Has w m t_1, Apecs.Core.Has w m t_2, Apecs.Core.Has w m t_3, Apecs.Core.Has w m t_4, Apecs.Core.Has w m t_5) => Apecs.Core.Has w m (t_0, t_1, t_2, t_3, t_4, t_5) instance (Apecs.Core.ExplGet m t_0, Apecs.Core.ExplGet m t_1, Apecs.Core.ExplGet m t_2, Apecs.Core.ExplGet m t_3, Apecs.Core.ExplGet m t_4, Apecs.Core.ExplGet m t_5) => Apecs.Core.ExplGet m (t_0, t_1, t_2, t_3, t_4, t_5) instance (Apecs.Core.ExplSet m t_0, Apecs.Core.ExplSet m t_1, Apecs.Core.ExplSet m t_2, Apecs.Core.ExplSet m t_3, Apecs.Core.ExplSet m t_4, Apecs.Core.ExplSet m t_5) => Apecs.Core.ExplSet m (t_0, t_1, t_2, t_3, t_4, t_5) instance (Apecs.Core.ExplDestroy m t_0, Apecs.Core.ExplDestroy m t_1, Apecs.Core.ExplDestroy m t_2, Apecs.Core.ExplDestroy m t_3, Apecs.Core.ExplDestroy m t_4, Apecs.Core.ExplDestroy m t_5) => Apecs.Core.ExplDestroy m (t_0, t_1, t_2, t_3, t_4, t_5) instance (Apecs.Core.ExplMembers m t_0, Apecs.Core.ExplGet m t_1, Apecs.Core.ExplGet m t_2, Apecs.Core.ExplGet m t_3, Apecs.Core.ExplGet m t_4, Apecs.Core.ExplGet m t_5) => Apecs.Core.ExplMembers m (t_0, t_1, t_2, t_3, t_4, t_5) instance (Apecs.Core.Component t_0, Apecs.Core.Component t_1, Apecs.Core.Component t_2, Apecs.Core.Component t_3, Apecs.Core.Component t_4, Apecs.Core.Component t_5, Apecs.Core.Component t_6) => Apecs.Core.Component (t_0, t_1, t_2, t_3, t_4, t_5, t_6) instance (Apecs.Core.Has w m t_0, Apecs.Core.Has w m t_1, Apecs.Core.Has w m t_2, Apecs.Core.Has w m t_3, Apecs.Core.Has w m t_4, Apecs.Core.Has w m t_5, Apecs.Core.Has w m t_6) => Apecs.Core.Has w m (t_0, t_1, t_2, t_3, t_4, t_5, t_6) instance (Apecs.Core.ExplGet m t_0, Apecs.Core.ExplGet m t_1, Apecs.Core.ExplGet m t_2, Apecs.Core.ExplGet m t_3, Apecs.Core.ExplGet m t_4, Apecs.Core.ExplGet m t_5, Apecs.Core.ExplGet m t_6) => Apecs.Core.ExplGet m (t_0, t_1, t_2, t_3, t_4, t_5, t_6) instance (Apecs.Core.ExplSet m t_0, Apecs.Core.ExplSet m t_1, Apecs.Core.ExplSet m t_2, Apecs.Core.ExplSet m t_3, Apecs.Core.ExplSet m t_4, Apecs.Core.ExplSet m t_5, Apecs.Core.ExplSet m t_6) => Apecs.Core.ExplSet m (t_0, t_1, t_2, t_3, t_4, t_5, t_6) instance (Apecs.Core.ExplDestroy m t_0, Apecs.Core.ExplDestroy m t_1, Apecs.Core.ExplDestroy m t_2, Apecs.Core.ExplDestroy m t_3, Apecs.Core.ExplDestroy m t_4, Apecs.Core.ExplDestroy m t_5, Apecs.Core.ExplDestroy m t_6) => Apecs.Core.ExplDestroy m (t_0, t_1, t_2, t_3, t_4, t_5, t_6) instance (Apecs.Core.ExplMembers m t_0, Apecs.Core.ExplGet m t_1, Apecs.Core.ExplGet m t_2, Apecs.Core.ExplGet m t_3, Apecs.Core.ExplGet m t_4, Apecs.Core.ExplGet m t_5, Apecs.Core.ExplGet m t_6) => Apecs.Core.ExplMembers m (t_0, t_1, t_2, t_3, t_4, t_5, t_6) instance (Apecs.Core.Component t_0, Apecs.Core.Component t_1, Apecs.Core.Component t_2, Apecs.Core.Component t_3, Apecs.Core.Component t_4, Apecs.Core.Component t_5, Apecs.Core.Component t_6, Apecs.Core.Component t_7) => Apecs.Core.Component (t_0, t_1, t_2, t_3, t_4, t_5, t_6, t_7) instance (Apecs.Core.Has w m t_0, Apecs.Core.Has w m t_1, Apecs.Core.Has w m t_2, Apecs.Core.Has w m t_3, Apecs.Core.Has w m t_4, Apecs.Core.Has w m t_5, Apecs.Core.Has w m t_6, Apecs.Core.Has w m t_7) => Apecs.Core.Has w m (t_0, t_1, t_2, t_3, t_4, t_5, t_6, t_7) instance (Apecs.Core.ExplGet m t_0, Apecs.Core.ExplGet m t_1, Apecs.Core.ExplGet m t_2, Apecs.Core.ExplGet m t_3, Apecs.Core.ExplGet m t_4, Apecs.Core.ExplGet m t_5, Apecs.Core.ExplGet m t_6, Apecs.Core.ExplGet m t_7) => Apecs.Core.ExplGet m (t_0, t_1, t_2, t_3, t_4, t_5, t_6, t_7) instance (Apecs.Core.ExplSet m t_0, Apecs.Core.ExplSet m t_1, Apecs.Core.ExplSet m t_2, Apecs.Core.ExplSet m t_3, Apecs.Core.ExplSet m t_4, Apecs.Core.ExplSet m t_5, Apecs.Core.ExplSet m t_6, Apecs.Core.ExplSet m t_7) => Apecs.Core.ExplSet m (t_0, t_1, t_2, t_3, t_4, t_5, t_6, t_7) instance (Apecs.Core.ExplDestroy m t_0, Apecs.Core.ExplDestroy m t_1, Apecs.Core.ExplDestroy m t_2, Apecs.Core.ExplDestroy m t_3, Apecs.Core.ExplDestroy m t_4, Apecs.Core.ExplDestroy m t_5, Apecs.Core.ExplDestroy m t_6, Apecs.Core.ExplDestroy m t_7) => Apecs.Core.ExplDestroy m (t_0, t_1, t_2, t_3, t_4, t_5, t_6, t_7) instance (Apecs.Core.ExplMembers m t_0, Apecs.Core.ExplGet m t_1, Apecs.Core.ExplGet m t_2, Apecs.Core.ExplGet m t_3, Apecs.Core.ExplGet m t_4, Apecs.Core.ExplGet m t_5, Apecs.Core.ExplGet m t_6, Apecs.Core.ExplGet m t_7) => Apecs.Core.ExplMembers m (t_0, t_1, t_2, t_3, t_4, t_5, t_6, t_7) instance GHC.Base.Monad m => Apecs.Core.Has w m () instance Apecs.Core.Component () instance GHC.Base.Monad m => Apecs.Core.ExplGet m () instance GHC.Base.Monad m => Apecs.Core.ExplSet m () instance GHC.Base.Monad m => Apecs.Core.ExplDestroy m () instance Apecs.Core.Component c => Apecs.Core.Component (Data.Functor.Identity.Identity c) instance Apecs.Core.Has w m c => Apecs.Core.Has w m (Data.Functor.Identity.Identity c) instance Apecs.Core.ExplGet m s => Apecs.Core.ExplGet m (Data.Functor.Identity.Identity s) instance Apecs.Core.ExplSet m s => Apecs.Core.ExplSet m (Data.Functor.Identity.Identity s) instance Apecs.Core.ExplMembers m s => Apecs.Core.ExplMembers m (Data.Functor.Identity.Identity s) instance Apecs.Core.ExplDestroy m s => Apecs.Core.ExplDestroy m (Data.Functor.Identity.Identity s) module Apecs.System -- | Run a system in a game world runSystem :: SystemT w m a -> w -> m a -- | Run a system in a game world runWith :: w -> SystemT w m a -> m a -- | Read a Component get :: forall w m c. Get w m c => Entity -> SystemT w m c -- | Writes a Component to a given Entity. Will overwrite existing -- Components. set :: forall w m c. Set w m c => Entity -> c -> SystemT w m () -- | set operator -- -- Writes a Component to a given Entity. Will overwrite existing -- Components. ($=) :: forall w m c. Set w m c => Entity -> c -> SystemT w m () infixr 2 $= -- | Returns whether the given entity has component c exists :: forall w m c. Get w m c => Entity -> Proxy c -> SystemT w m Bool -- | Destroys component c for the given entity. destroy :: forall w m c. Destroy w m c => Entity -> Proxy c -> SystemT w m () -- | Applies a function, if possible. modify :: forall w m cx cy. (Get w m cx, Set w m cy) => Entity -> (cx -> cy) -> SystemT w m () -- | modify operator -- -- Applies a function, if possible. ($~) :: forall w m cx cy. (Get w m cx, Set w m cy) => Entity -> (cx -> cy) -> SystemT w m () infixr 2 $~ -- | Maps a function over all entities with a cx, and writes their -- cy. cmap :: forall w m cx cy. (Get w m cx, Members w m cx, Set w m cy) => (cx -> cy) -> SystemT w m () -- | Conditional cmap, that first tests whether the argument -- satisfies some property. The entity needs to have both a cx and cp -- component. cmapIf :: forall w m cp cx cy. (Get w m cx, Get w m cp, Members w m cx, Set w m cy) => (cp -> Bool) -> (cx -> cy) -> SystemT w m () -- | Monadically iterates over all entites with a cx, and writes -- their cy. cmapM :: forall w m cx cy. (Get w m cx, Set w m cy, Members w m cx) => (cx -> SystemT w m cy) -> SystemT w m () -- | Monadically iterates over all entites with a cx cmapM_ :: forall w m c. (Get w m c, Members w m c) => (c -> SystemT w m ()) -> SystemT w m () -- | Fold over the game world; for example, cfold max (minBound :: -- Foo) will find the maximum value of Foo. Strict in the -- accumulator. cfold :: forall w m c a. (Members w m c, Get w m c) => (a -> c -> a) -> a -> SystemT w m a -- | Monadically fold over the game world. Strict in the accumulator. cfoldM :: forall w m c a. (Members w m c, Get w m c) => (a -> c -> SystemT w m a) -> a -> SystemT w m a -- | Monadically fold over the game world. Strict in the accumulator. cfoldM_ :: forall w m c a. (Members w m c, Get w m c) => (a -> c -> SystemT w m a) -> a -> SystemT w m () -- | This module is experimental, and its API might change between point -- releases. Use at your own risk. module Apecs.Experimental.Stores -- | Overrides a store to have history/pushdown semantics. Setting this -- store adds a new value on top of the stack. Destroying pops the stack. -- You can view the entire stack using the Stack wrapper. newtype Pushdown s c Pushdown :: s (Stack c) -> Pushdown s c newtype Stack c Stack :: [c] -> Stack c [getStack] :: Stack c -> [c] instance GHC.Base.Semigroup (Apecs.Experimental.Stores.Stack c) instance GHC.Base.Monoid (Apecs.Experimental.Stores.Stack c) instance Data.Foldable.Foldable Apecs.Experimental.Stores.Stack instance GHC.Base.Monad Apecs.Experimental.Stores.Stack instance GHC.Base.Applicative Apecs.Experimental.Stores.Stack instance GHC.Base.Functor Apecs.Experimental.Stores.Stack instance GHC.Show.Show c => GHC.Show.Show (Apecs.Experimental.Stores.Stack c) instance GHC.Classes.Eq c => GHC.Classes.Eq (Apecs.Experimental.Stores.Stack c) instance (Apecs.Core.Storage c Data.Type.Equality.~ Apecs.Experimental.Stores.Pushdown s c, Apecs.Core.Component c) => Apecs.Core.Component (Apecs.Experimental.Stores.Stack c) instance (Apecs.Core.Storage c Data.Type.Equality.~ Apecs.Experimental.Stores.Pushdown s c, Apecs.Core.Has w m c) => Apecs.Core.Has w m (Apecs.Experimental.Stores.Stack c) instance (Apecs.Core.Elem (s (Apecs.Experimental.Stores.Stack c)) Data.Type.Equality.~ Apecs.Experimental.Stores.Stack c, Apecs.Core.ExplGet m (s (Apecs.Experimental.Stores.Stack c))) => Apecs.Core.ExplGet m (Apecs.Experimental.Stores.StackStore (Apecs.Experimental.Stores.Pushdown s c)) instance (Apecs.Core.Elem (s (Apecs.Experimental.Stores.Stack c)) Data.Type.Equality.~ Apecs.Experimental.Stores.Stack c, Apecs.Core.ExplSet m (s (Apecs.Experimental.Stores.Stack c)), Apecs.Core.ExplDestroy m (s (Apecs.Experimental.Stores.Stack c))) => Apecs.Core.ExplSet m (Apecs.Experimental.Stores.StackStore (Apecs.Experimental.Stores.Pushdown s c)) instance (Apecs.Core.Elem (s (Apecs.Experimental.Stores.Stack c)) Data.Type.Equality.~ Apecs.Experimental.Stores.Stack c, Apecs.Core.ExplDestroy m (s (Apecs.Experimental.Stores.Stack c))) => Apecs.Core.ExplDestroy m (Apecs.Experimental.Stores.StackStore (Apecs.Experimental.Stores.Pushdown s c)) instance (Apecs.Core.Elem (s (Apecs.Experimental.Stores.Stack c)) Data.Type.Equality.~ Apecs.Experimental.Stores.Stack c, Apecs.Core.ExplMembers m (s (Apecs.Experimental.Stores.Stack c))) => Apecs.Core.ExplMembers m (Apecs.Experimental.Stores.StackStore (Apecs.Experimental.Stores.Pushdown s c)) instance (GHC.Base.Functor m, Apecs.Core.ExplInit m (s (Apecs.Experimental.Stores.Stack c))) => Apecs.Core.ExplInit m (Apecs.Experimental.Stores.Pushdown s c) instance (GHC.Base.Monad m, Apecs.Core.ExplGet m (s (Apecs.Experimental.Stores.Stack c)), Apecs.Core.Elem (s (Apecs.Experimental.Stores.Stack c)) Data.Type.Equality.~ Apecs.Experimental.Stores.Stack c) => Apecs.Core.ExplGet m (Apecs.Experimental.Stores.Pushdown s c) instance (GHC.Base.Monad m, Apecs.Core.ExplGet m (s (Apecs.Experimental.Stores.Stack c)), Apecs.Core.ExplSet m (s (Apecs.Experimental.Stores.Stack c)), Apecs.Core.Elem (s (Apecs.Experimental.Stores.Stack c)) Data.Type.Equality.~ Apecs.Experimental.Stores.Stack c) => Apecs.Core.ExplSet m (Apecs.Experimental.Stores.Pushdown s c) instance (GHC.Base.Monad m, Apecs.Core.ExplGet m (s (Apecs.Experimental.Stores.Stack c)), Apecs.Core.ExplSet m (s (Apecs.Experimental.Stores.Stack c)), Apecs.Core.ExplDestroy m (s (Apecs.Experimental.Stores.Stack c)), Apecs.Core.Elem (s (Apecs.Experimental.Stores.Stack c)) Data.Type.Equality.~ Apecs.Experimental.Stores.Stack c) => Apecs.Core.ExplDestroy m (Apecs.Experimental.Stores.Pushdown s c) instance (GHC.Base.Monad m, Apecs.Core.ExplMembers m (s (Apecs.Experimental.Stores.Stack c)), Apecs.Core.Elem (s (Apecs.Experimental.Stores.Stack c)) Data.Type.Equality.~ Apecs.Experimental.Stores.Stack c) => Apecs.Core.ExplMembers m (Apecs.Experimental.Stores.Pushdown s c) -- | This module is experimental, and its API might change between point -- releases. Use at your own risk. -- -- Adds the Reactive r s store, which when wrapped around store -- s, will call the react on its r. -- -- Show c => Reactive (Printer c) (Map c) will print a -- message every time a c value is set. -- -- Enum c => Reactive (EnumMap c) (Map c) allows you to look -- up entities by component value. Use e.g. rget >>= mapLookup -- True to retrieve a list of entities that have a True -- component. module Apecs.Experimental.Reactive -- | Class required by Reactive. Given some r and update -- information about some component, will run a side-effect in monad -- m. Note that there are also instances for (,). class Monad m => Reacts m r rempty :: Reacts m r => m r react :: Reacts m r => Entity -> Maybe (Elem r) -> Maybe (Elem r) -> r -> m () -- | Wrapper for reactivity around some store s. data Reactive r s -- | Performs an action with a reactive state token. withReactive :: forall w m r s a. (Component (Elem r), Has w m (Elem r), Storage (Elem r) ~ Reactive r s) => (r -> m a) -> SystemT w m a -- | Allows you to look up entities by component value. Use e.g. -- withReactive $ mapLookup True to retrieve a list of entities -- that have a True component. Based on an IntMap -- IntSet internally. data EnumMap c enumLookup :: (MonadIO m, Enum c) => c -> EnumMap c -> m [Entity] -- | Allows you to look up entities by component value. Based on a Map -- c IntSet internally data OrdMap c ordLookup :: (MonadIO m, Ord c) => c -> OrdMap c -> m [Entity] -- | Allows you to look up entities by component value. Based on an -- IOArray c IntSet internally data IxMap c ixLookup :: (MonadIO m, Ix c) => c -> IxMap c -> m [Entity] instance (Control.Monad.IO.Class.MonadIO m, GHC.Arr.Ix c, GHC.Enum.Bounded c) => Apecs.Experimental.Reactive.Reacts m (Apecs.Experimental.Reactive.IxMap c) instance (Control.Monad.IO.Class.MonadIO m, GHC.Classes.Ord c) => Apecs.Experimental.Reactive.Reacts m (Apecs.Experimental.Reactive.OrdMap c) instance (Control.Monad.IO.Class.MonadIO m, GHC.Enum.Enum c) => Apecs.Experimental.Reactive.Reacts m (Apecs.Experimental.Reactive.EnumMap c) instance (Control.Monad.IO.Class.MonadIO m, GHC.Show.Show c) => Apecs.Experimental.Reactive.Reacts m (Apecs.Experimental.Reactive.Printer c) instance (Apecs.Experimental.Reactive.Reacts m r, Apecs.Core.ExplInit m s) => Apecs.Core.ExplInit m (Apecs.Experimental.Reactive.Reactive r s) instance (Apecs.Experimental.Reactive.Reacts m r, Apecs.Core.ExplSet m s, Apecs.Core.ExplGet m s, Apecs.Core.Elem s Data.Type.Equality.~ Apecs.Core.Elem r) => Apecs.Core.ExplSet m (Apecs.Experimental.Reactive.Reactive r s) instance (Apecs.Experimental.Reactive.Reacts m r, Apecs.Core.ExplDestroy m s, Apecs.Core.ExplGet m s, Apecs.Core.Elem s Data.Type.Equality.~ Apecs.Core.Elem r) => Apecs.Core.ExplDestroy m (Apecs.Experimental.Reactive.Reactive r s) instance Apecs.Core.ExplGet m s => Apecs.Core.ExplGet m (Apecs.Experimental.Reactive.Reactive r s) instance Apecs.Core.ExplMembers m s => Apecs.Core.ExplMembers m (Apecs.Experimental.Reactive.Reactive r s) module Apecs.Util -- | Explicitly invoke the garbage collector runGC :: System w () -- | Convenience entity, for use in places where the entity value does not -- matter, i.e. a global store. global :: Entity -- | Component used by newEntity to track the number of issued entities. -- Automatically added to any world created with makeWorld newtype EntityCounter EntityCounter :: Sum Int -> EntityCounter [getCounter] :: EntityCounter -> Sum Int -- | Bumps the EntityCounter and yields its value nextEntity :: (MonadIO m, Get w m EntityCounter) => SystemT w m Entity -- | Writes the given components to a new entity, and yields that entity. -- The return value is often ignored. newEntity :: (MonadIO m, Set w m c, Get w m EntityCounter) => c -> SystemT w m Entity instance GHC.Show.Show Apecs.Util.EntityCounter instance GHC.Classes.Eq Apecs.Util.EntityCounter instance GHC.Base.Monoid Apecs.Util.EntityCounter instance GHC.Base.Semigroup Apecs.Util.EntityCounter instance Apecs.Core.Component Apecs.Util.EntityCounter module Apecs.TH -- | The typical way to create a world record, associated -- Has instances, and initialization function. -- --
--   makeWorld "MyWorld" [''Component1, ''Component2, ...]
--   
-- -- turns into -- --
--   data MyWorld = MyWorld Component1 Component2 ... EntityCounter
--   instance MyWorld `Has` Component1 where ...
--   instance MyWorld `Has` Component2 where ...
--   ...
--   instance MyWorld `Has` EntityCounter where ...
--   
--   initMyWorld :: IO MyWorld
--   initMyWorld = MyWorld <$> initStore <*> initStore <*> ... <*> initStore
--   
makeWorld :: String -> [Name] -> Q [Dec] -- | Same as makeWorld, but does not include an EntityCounter -- You don't typically want to use this, but it's exposed in case you -- know what you're doing. makeWorldNoEC :: String -> [Name] -> Q [Dec] -- | Calls makeWorld and makeMapComponents, i.e. makes a -- world and also defines Component instances with a Map -- store. makeWorldAndComponents :: String -> [Name] -> Q [Dec] -- | Creates Component instances with Map stores makeMapComponents :: [Name] -> Q [Dec] -- | This module forms the apecs Prelude. It selectively re-exports the -- user-facing functions from the submodules. module Apecs -- | A SystemT is a newtype around `ReaderT w m a`, where w is the -- game world variable. Systems serve to -- -- newtype SystemT w m a SystemT :: ReaderT w m a -> SystemT w m a [unSystem] :: SystemT w m a -> ReaderT w m a type System w a = SystemT w IO a -- | A component is defined by specifying how it is stored. The constraint -- ensures that stores and components are mapped one-to-one. class (Elem (Storage c) ~ c) => Component c where { type family Storage c; } -- | An Entity is just an integer, used to index into a component store. In -- general, use newEntity, cmap, and component tags -- instead of manipulating these directly. -- -- For performance reasons, negative values like (-1) are reserved for -- stores to represent special values, so avoid using these. newtype Entity Entity :: Int -> Entity [unEntity] :: Entity -> Int -- | Has w m c means that world w can produce a -- Storage c. It is parameterized over m to allow -- stores to be foreign. class (Monad m, Component c) => Has w m c getStore :: Has w m c => SystemT w m (Storage c) -- | Pseudocomponent indicating the absence of a. Mainly used as -- e.g. cmap $ (a, Not b) -> c to iterate over entities with -- an a but no b. Can also be used to delete -- components, like cmap $ a -> (Not :: Not a) to delete -- every a component. data Not a Not :: Not a type Get w m c = (Has w m c, ExplGet m (Storage c)) type Set w m c = (Has w m c, ExplSet m (Storage c)) type Destroy w m c = (Has w m c, ExplDestroy m (Storage c)) type Members w m c = (Has w m c, ExplMembers m (Storage c)) -- | A map based on Strict. O(log(n)) for most operations. data Map c -- | A Unique contains zero or one component. Writing to it overwrites both -- the previous component and its owner. Its main purpose is to be a -- Map optimized for when only ever one component inhabits it. data Unique c -- | A Global contains exactly one component. The initial value is -- mempty from the component's Monoid instance. Querying a -- Global at any Entity yields this one component, -- effectively sharing the component between all entities. -- -- A Global component can be read with get 0 or -- get 1 or even get undefined. The -- convenience entity global is defined as -1, and can be used -- to make operations on a global more explicit, i.e. 'Time t <- get -- global'. -- -- You also can read and write Globals during a cmap over other -- components. data Global c -- | A cache around another store. Caches store their members in a -- fixed-size vector, so read/write operations become O(1). Caches can -- provide huge performance boosts, especially when working with large -- numbers of components. -- -- The cache size is given as a type-level argument. -- -- Note that iterating over a cache is linear in cache size, so sparsely -- populated caches might decrease performance. In general, the -- exact size of the cache does not matter as long as it reasonably -- approximates the number of components present. -- -- The cache uses entity (-2) internally to represent missing entities. -- If you manually manipulate Entity values, be careful that you do not -- use (-2) -- -- The actual cache is not necessarily the given argument, but the next -- biggest power of two. This is allows most operations to be expressed -- as bit masks, for a large potential performance boost. data Cache (n :: Nat) s -- | Initialize a new empty store. explInit :: ExplInit m s => m s -- | Read a Component get :: forall w m c. Get w m c => Entity -> SystemT w m c -- | Writes a Component to a given Entity. Will overwrite existing -- Components. set :: forall w m c. Set w m c => Entity -> c -> SystemT w m () -- | set operator -- -- Writes a Component to a given Entity. Will overwrite existing -- Components. ($=) :: forall w m c. Set w m c => Entity -> c -> SystemT w m () infixr 2 $= -- | Destroys component c for the given entity. destroy :: forall w m c. Destroy w m c => Entity -> Proxy c -> SystemT w m () -- | Returns whether the given entity has component c exists :: forall w m c. Get w m c => Entity -> Proxy c -> SystemT w m Bool -- | Applies a function, if possible. modify :: forall w m cx cy. (Get w m cx, Set w m cy) => Entity -> (cx -> cy) -> SystemT w m () -- | modify operator -- -- Applies a function, if possible. ($~) :: forall w m cx cy. (Get w m cx, Set w m cy) => Entity -> (cx -> cy) -> SystemT w m () infixr 2 $~ -- | Maps a function over all entities with a cx, and writes their -- cy. cmap :: forall w m cx cy. (Get w m cx, Members w m cx, Set w m cy) => (cx -> cy) -> SystemT w m () -- | Monadically iterates over all entites with a cx, and writes -- their cy. cmapM :: forall w m cx cy. (Get w m cx, Set w m cy, Members w m cx) => (cx -> SystemT w m cy) -> SystemT w m () -- | Monadically iterates over all entites with a cx cmapM_ :: forall w m c. (Get w m c, Members w m c) => (c -> SystemT w m ()) -> SystemT w m () -- | Fold over the game world; for example, cfold max (minBound :: -- Foo) will find the maximum value of Foo. Strict in the -- accumulator. cfold :: forall w m c a. (Members w m c, Get w m c) => (a -> c -> a) -> a -> SystemT w m a -- | Monadically fold over the game world. Strict in the accumulator. cfoldM :: forall w m c a. (Members w m c, Get w m c) => (a -> c -> SystemT w m a) -> a -> SystemT w m a -- | Monadically fold over the game world. Strict in the accumulator. cfoldM_ :: forall w m c a. (Members w m c, Get w m c) => (a -> c -> SystemT w m a) -> a -> SystemT w m () -- | Run a system in a game world runSystem :: SystemT w m a -> w -> m a -- | Run a system in a game world runWith :: w -> SystemT w m a -> m a -- | Explicitly invoke the garbage collector runGC :: System w () -- | Component used by newEntity to track the number of issued entities. -- Automatically added to any world created with makeWorld data EntityCounter -- | Writes the given components to a new entity, and yields that entity. -- The return value is often ignored. newEntity :: (MonadIO m, Set w m c, Get w m EntityCounter) => c -> SystemT w m Entity -- | Convenience entity, for use in places where the entity value does not -- matter, i.e. a global store. global :: Entity -- | The typical way to create a world record, associated -- Has instances, and initialization function. -- --
--   makeWorld "MyWorld" [''Component1, ''Component2, ...]
--   
-- -- turns into -- --
--   data MyWorld = MyWorld Component1 Component2 ... EntityCounter
--   instance MyWorld `Has` Component1 where ...
--   instance MyWorld `Has` Component2 where ...
--   ...
--   instance MyWorld `Has` EntityCounter where ...
--   
--   initMyWorld :: IO MyWorld
--   initMyWorld = MyWorld <$> initStore <*> initStore <*> ... <*> initStore
--   
makeWorld :: String -> [Name] -> Q [Dec] -- | Calls makeWorld and makeMapComponents, i.e. makes a -- world and also defines Component instances with a Map -- store. makeWorldAndComponents :: String -> [Name] -> Q [Dec] -- | Retrieves a function of the current environment. asks :: MonadReader r m => (r -> a) -> m a -- | Retrieves the monad environment. ask :: MonadReader r m => m r -- | Lift a computation from the IO monad. liftIO :: MonadIO m => IO a -> m a -- | Lift a computation from the argument monad to the constructed monad. lift :: (MonadTrans t, Monad m) => m a -> t m a -- | Proxy is a type that holds no data, but has a phantom parameter -- of arbitrary type (or even kind). Its use is to provide type -- information, even though there is no value available of that type (or -- it may be too costly to create one). -- -- Historically, Proxy :: Proxy a is a safer -- alternative to the 'undefined :: a' idiom. -- --
--   >>> Proxy :: Proxy (Void, Int -> Int)
--   Proxy
--   
-- -- Proxy can even hold types of higher kinds, -- --
--   >>> Proxy :: Proxy Either
--   Proxy
--   
-- --
--   >>> Proxy :: Proxy Functor
--   Proxy
--   
-- --
--   >>> Proxy :: Proxy complicatedStructure
--   Proxy
--   
data Proxy (t :: k) :: forall k. () => k -> Type Proxy :: Proxy