-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Fast Entity-Component-System library for game programming
--   
--   The Entity-Component-System architecture provides an imperative game
--   programming paradigm that tackles many of the shortcomings of more
--   OO-oriented approaches. apecs is a type-driven ECS library, that
--   leverages strong typing for an expressive DSL that compiles into fast
--   game code.
@package apecs
@version 0.7.3

module Apecs.Core

-- | An Entity is just an integer, used to index into a component store. In
--   general, use <tt>newEntity</tt>, <tt>cmap</tt>, 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 <tt>w</tt> is the
--   game world variable. Systems serve to
--   
--   <ul>
--   <li>Allow type-based lookup of a component's store through
--   <tt>getStore</tt>.</li>
--   <li>Lift side effects into their host Monad.</li>
--   </ul>
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;
}

-- | <tt>Has w m c</tt> means that world <tt>w</tt> can produce a
--   <tt>Storage c</tt>.
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. <tt>Elem (Map c) =
--   c</tt>.
type family Elem s

-- | Indicates that the store <tt>s</tt> can be initialized. Generally,
--   "base" stores like <tt>Map c</tt> can be initialized, but composite
--   stores like <tt>MaybeStore s</tt> cannot.
class ExplInit m s

-- | Initialize a new empty store.
explInit :: ExplInit m s => m s

-- | Stores that we can read using <tt>explGet</tt> and
--   <tt>explExists</tt>. For some entity <tt>e</tt>, <tt>eplGet s e</tt>
--   is only guaranteed to be safe if <tt>explExists s e</tt> returns
--   <tt>True</tt>.
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.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)

module Apecs.Stores

-- | A map based on <tt>Data.IntMap.Strict</tt>. O(log(n)) for most
--   operations.
data Map c

-- | A cache around another store. Caches store their members in a
--   fixed-size vector, so operations run in O(1). Caches can provide huge
--   performance boosts, especially for 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 actually 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) to internally represent missing entities,
--   so be wary when manually manipulating entities.
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
--   <tt>Map</tt> optimized for when only ever one component inhabits it.
data Unique c

-- | A <tt>Global</tt> contains exactly one component. The initial value is
--   <a>mempty</a> from the component's <a>Monoid</a> instance.
--   
--   When operating on a Global, any entity arguments are ignored. A Global
--   component can be read with <tt>get 0</tt> or <tt>get 1</tt> or even
--   <tt>get undefined</tt>. This means that you can read and write Globals
--   while <tt>cmap</tt>ping over other components.
--   
--   The integer <tt>global</tt> is defined as -1, and can be used to make
--   operations on a global explicit, i.e. 'Time t &lt;- get global'.
data Global c

-- | An empty type class indicating that the store behaves like a regular
--   map, and can therefore safely be cached.
class Cachable 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 => 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 => 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

-- | Psuedocomponent indicating the absence of <tt>a</tt>. Mainly used as
--   e.g. <tt>cmap $ (a, Not b) -&gt; c</tt> to iterate over entities with
--   an <tt>a</tt> but no <tt>b</tt>. Can also be used to delete
--   components, like <tt>cmap $ a -&gt; (Not :: Not a)</tt> to delete
--   every <tt>a</tt> component.
data Not a
Not :: Not a

-- | Pseudostore used to produce values of type <tt>Not a</tt>, inverts
--   <tt>explExists</tt>, and destroys instead of <tt>explSet</tt>.
newtype NotStore s
NotStore :: s -> NotStore s

-- | Pseudostore used to produce values of type <tt>Maybe a</tt>. Will
--   always return <tt>True</tt> for <tt>explExists</tt>. Writing can both
--   set and delete a component using <tt>Just</tt> and <tt>Nothing</tt>
--   respectively.
newtype MaybeStore s
MaybeStore :: s -> MaybeStore s

-- | Used for <a>Either</a>, a logical disjunction between two components.
--   As expected, Either is used to model error values. Getting an
--   <tt>Either a b</tt> will first attempt to get a <tt>b</tt> and return
--   it as <tt>Right b</tt>, or if it does not exist, get an <tt>a</tt> as
--   <tt>Left a</tt>. 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 <tt>explExists</tt> and
--   <tt>explMembers</tt>, but always return <tt>Filter</tt> for
--   <tt>explGet</tt>. Can be used in cmap as <tt>cmap $ (Filter :: Filter
--   a) -&gt; b</tt>. Since the above can be written more consicely as
--   <tt>cmap $ (_ :: a) -&gt; b</tt>, it is rarely directly. More
--   interestingly, we can define reusable filters like <tt>movables =
--   Filter :: Filter (Position, Velocity)</tt>. 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 <a>Entity</a>. Always
--   returns <tt>True</tt> for <tt>explExists</tt>, and echoes back the
--   entity argument for <tt>explGet</tt>. Used in e.g. <tt>cmap $ (a, ety
--   :: Entity) -&gt; b</tt> to access the current entity.
data EntityStore
EntityStore :: EntityStore

-- | Pseudocomponent that when written to, actually writes <tt>c</tt> to
--   its entity argument. Used to dereference during a <tt>cmap</tt>.
data Redirect c
Redirect :: Entity -> c -> Redirect c
newtype RedirectStore s
RedirectStore :: s -> RedirectStore s
instance GHC.Show.Show c => GHC.Show.Show (Apecs.Components.Redirect c)
instance GHC.Classes.Eq c => GHC.Classes.Eq (Apecs.Components.Redirect c)
instance GHC.Show.Show (Apecs.Components.Filter c)
instance GHC.Classes.Eq (Apecs.Components.Filter c)
instance Apecs.Core.Component c => Apecs.Core.Component (Apecs.Components.Redirect c)
instance Apecs.Core.Has w m c => Apecs.Core.Has w m (Apecs.Components.Redirect c)
instance Apecs.Core.ExplSet m s => Apecs.Core.ExplSet m (Apecs.Components.RedirectStore s)
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 ()

-- | <tt>set</tt> 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 <tt>c</tt>
exists :: forall w m c. Get w m c => Entity -> Proxy c -> SystemT w m Bool

-- | Destroys component <tt>c</tt> 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 c. (Get w m c, Set w m c) => Entity -> (c -> c) -> SystemT w m ()

-- | <tt>modify</tt> operator
--   
--   Applies a function, if possible.
($~) :: forall w m c. (Get w m c, Set w m c) => Entity -> (c -> c) -> SystemT w m ()
infixr 2 $~

-- | Maps a function over all entities with a <tt>cx</tt>, and writes their
--   <tt>cy</tt>.
cmap :: forall w m cx cy. (Get w m cx, Members w m cx, Set w m cy) => (cx -> cy) -> SystemT w m ()

-- | Conditional <tt>cmap</tt>, 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 <tt>cx</tt>, and writes
--   their <tt>cy</tt>.
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 <tt>cx</tt>
cmapM_ :: forall w m c a. (Get w m c, Members w m c) => (c -> SystemT w m a) -> SystemT w m ()

-- | Fold over the game world; for example, <tt>cfold max (minBound ::
--   Foo)</tt> will find the maximum value of <tt>Foo</tt>. 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 ()


-- | Containment module for stores that are experimental/too weird for
--   <tt>Apecs.Stores</tt>.
module Apecs.Stores.Extra

-- | 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 <a>Stack</a> wrapper.
newtype Pushdown s c
Pushdown :: s (Stack c) -> Pushdown s c
newtype Stack c
Stack :: [c] -> Stack c
[getStack] :: Stack c -> [c]

-- | Wrapper that makes a store read-only. Use <tt>setReadOnly</tt> and
--   <tt>destroyReadOnly</tt> to override.
newtype ReadOnly s
ReadOnly :: s -> 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.Semigroup (Apecs.Stores.Extra.Stack c)
instance GHC.Base.Monoid (Apecs.Stores.Extra.Stack c)
instance Data.Foldable.Foldable Apecs.Stores.Extra.Stack
instance GHC.Base.Monad Apecs.Stores.Extra.Stack
instance GHC.Base.Applicative Apecs.Stores.Extra.Stack
instance GHC.Base.Functor Apecs.Stores.Extra.Stack
instance GHC.Show.Show c => GHC.Show.Show (Apecs.Stores.Extra.Stack c)
instance GHC.Classes.Eq c => GHC.Classes.Eq (Apecs.Stores.Extra.Stack c)
instance (GHC.Base.Functor m, Apecs.Core.ExplInit m s) => Apecs.Core.ExplInit m (Apecs.Stores.Extra.ReadOnly s)
instance Apecs.Core.ExplGet m s => Apecs.Core.ExplGet m (Apecs.Stores.Extra.ReadOnly s)
instance Apecs.Core.ExplMembers m s => Apecs.Core.ExplMembers m (Apecs.Stores.Extra.ReadOnly s)
instance (Apecs.Core.Storage c Data.Type.Equality.~ Apecs.Stores.Extra.Pushdown s c, Apecs.Core.Component c) => Apecs.Core.Component (Apecs.Stores.Extra.Stack c)
instance (Apecs.Core.Storage c Data.Type.Equality.~ Apecs.Stores.Extra.Pushdown s c, Apecs.Core.Has w m c) => Apecs.Core.Has w m (Apecs.Stores.Extra.Stack c)
instance (Apecs.Core.Elem (s (Apecs.Stores.Extra.Stack c)) Data.Type.Equality.~ Apecs.Stores.Extra.Stack c, Apecs.Core.ExplGet m (s (Apecs.Stores.Extra.Stack c))) => Apecs.Core.ExplGet m (Apecs.Stores.Extra.StackStore (Apecs.Stores.Extra.Pushdown s c))
instance (Apecs.Core.Elem (s (Apecs.Stores.Extra.Stack c)) Data.Type.Equality.~ Apecs.Stores.Extra.Stack c, Apecs.Core.ExplSet m (s (Apecs.Stores.Extra.Stack c)), Apecs.Core.ExplDestroy m (s (Apecs.Stores.Extra.Stack c))) => Apecs.Core.ExplSet m (Apecs.Stores.Extra.StackStore (Apecs.Stores.Extra.Pushdown s c))
instance (Apecs.Core.Elem (s (Apecs.Stores.Extra.Stack c)) Data.Type.Equality.~ Apecs.Stores.Extra.Stack c, Apecs.Core.ExplDestroy m (s (Apecs.Stores.Extra.Stack c))) => Apecs.Core.ExplDestroy m (Apecs.Stores.Extra.StackStore (Apecs.Stores.Extra.Pushdown s c))
instance (Apecs.Core.Elem (s (Apecs.Stores.Extra.Stack c)) Data.Type.Equality.~ Apecs.Stores.Extra.Stack c, Apecs.Core.ExplMembers m (s (Apecs.Stores.Extra.Stack c))) => Apecs.Core.ExplMembers m (Apecs.Stores.Extra.StackStore (Apecs.Stores.Extra.Pushdown s c))
instance (GHC.Base.Functor m, Apecs.Core.ExplInit m (s (Apecs.Stores.Extra.Stack c))) => Apecs.Core.ExplInit m (Apecs.Stores.Extra.Pushdown s c)
instance (GHC.Base.Monad m, Apecs.Core.ExplGet m (s (Apecs.Stores.Extra.Stack c)), Apecs.Core.Elem (s (Apecs.Stores.Extra.Stack c)) Data.Type.Equality.~ Apecs.Stores.Extra.Stack c) => Apecs.Core.ExplGet m (Apecs.Stores.Extra.Pushdown s c)
instance (GHC.Base.Monad m, Apecs.Core.ExplGet m (s (Apecs.Stores.Extra.Stack c)), Apecs.Core.ExplSet m (s (Apecs.Stores.Extra.Stack c)), Apecs.Core.Elem (s (Apecs.Stores.Extra.Stack c)) Data.Type.Equality.~ Apecs.Stores.Extra.Stack c) => Apecs.Core.ExplSet m (Apecs.Stores.Extra.Pushdown s c)
instance (GHC.Base.Monad m, Apecs.Core.ExplGet m (s (Apecs.Stores.Extra.Stack c)), Apecs.Core.ExplSet m (s (Apecs.Stores.Extra.Stack c)), Apecs.Core.ExplDestroy m (s (Apecs.Stores.Extra.Stack c)), Apecs.Core.Elem (s (Apecs.Stores.Extra.Stack c)) Data.Type.Equality.~ Apecs.Stores.Extra.Stack c) => Apecs.Core.ExplDestroy m (Apecs.Stores.Extra.Pushdown s c)
instance (GHC.Base.Monad m, Apecs.Core.ExplMembers m (s (Apecs.Stores.Extra.Stack c)), Apecs.Core.Elem (s (Apecs.Stores.Extra.Stack c)) Data.Type.Equality.~ Apecs.Stores.Extra.Stack c) => Apecs.Core.ExplMembers m (Apecs.Stores.Extra.Pushdown s c)


-- | Reactive stores module, still experimental. Adds the <tt>Reactive r
--   s</tt> store, which when wrapped around store <tt>s</tt>, will call
--   the <tt>react</tt> on its <tt>r</tt>.
--   
--   <tt>Show c =&gt; Reactive (Printer c) (Map c)</tt> will print a
--   message every time a <tt>c</tt> value is set.
--   
--   <tt>Enum c =&gt; Reactive (EnumMap c) (Map c)</tt> allows you to look
--   up entities by component value. Use e.g. <tt>rget &gt;&gt;= mapLookup
--   True</tt> to retrieve a list of entities that have a <tt>True</tt>
--   component.
module Apecs.Reactive

-- | Analogous to <tt>Elem</tt>, but for <tt>Reacts</tt> instances. For a
--   <tt>Reactive r s</tt> to be valid, <tt>ReactElem r = Elem s</tt>
type family ReactElem r

-- | Class required by <tt>Reactive</tt>. Given some <tt>r</tt> and update
--   information about some component, will run a side-effect in monad
--   <tt>m</tt>. Note that there are also instances for <tt>(,)</tt>.
class Monad m => Reacts m r
rempty :: Reacts m r => m r
react :: Reacts m r => Entity -> Maybe (ReactElem r) -> Maybe (ReactElem r) -> r -> m ()

-- | Wrapper for reactivity around some store s.
data Reactive r s
Reactive :: r -> s -> Reactive r s

-- | Reads <tt>r</tt> from the game world.
rget :: forall w m r s. (Component (ReactElem r), Has w m (ReactElem r), Storage (ReactElem r) ~ Reactive r s) => SystemT w m r

-- | Prints a message to stdout every time a component is updated.
data Printer c
Printer :: Printer c

-- | Allows you to look up entities by component value. Use e.g. <tt>rget
--   &gt;&gt;= mapLookup True</tt> to retrieve a list of entities that have
--   a <tt>True</tt> component.
newtype EnumMap c
EnumMap :: IORef (IntMap IntSet) -> EnumMap c
mapLookup :: Enum c => EnumMap c -> c -> System w [Entity]
instance (Control.Monad.IO.Class.MonadIO m, GHC.Enum.Enum c) => Apecs.Reactive.Reacts m (Apecs.Reactive.EnumMap c)
instance (Control.Monad.IO.Class.MonadIO m, GHC.Show.Show c) => Apecs.Reactive.Reacts m (Apecs.Reactive.Printer c)
instance (Apecs.Reactive.Reacts m r, Apecs.Core.ExplInit m s) => Apecs.Core.ExplInit m (Apecs.Reactive.Reactive r s)
instance (Apecs.Reactive.Reacts m r, Apecs.Core.ExplSet m s, Apecs.Core.ExplGet m s, Apecs.Core.Elem s Data.Type.Equality.~ Apecs.Reactive.ReactElem r) => Apecs.Core.ExplSet m (Apecs.Reactive.Reactive r s)
instance (Apecs.Reactive.Reacts m r, Apecs.Core.ExplDestroy m s, Apecs.Core.ExplGet m s, Apecs.Core.Elem s Data.Type.Equality.~ Apecs.Reactive.ReactElem r) => Apecs.Core.ExplDestroy m (Apecs.Reactive.Reactive r s)
instance Apecs.Core.ExplGet m s => Apecs.Core.ExplGet m (Apecs.Reactive.Reactive r s)
instance Apecs.Core.ExplMembers m s => Apecs.Core.ExplMembers m (Apecs.Reactive.Reactive r s)
instance (Apecs.Reactive.ReactElem a Data.Type.Equality.~ Apecs.Reactive.ReactElem b, Apecs.Reactive.Reacts m a, Apecs.Reactive.Reacts m b) => Apecs.Reactive.Reacts m (a, b)

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 <tt>makeWorld</tt>
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

-- | 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
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

-- | <pre>
--   makeWorld "WorldName" [''Component1, ''Component2, ...]
--   </pre>
--   
--   turns into
--   
--   <pre>
--   data WorldName = WorldName Component1 Component2 ... EntityCounter
--   instance WorldName `Has` Component1 where ...
--   instance WorldName `Has` Component2 where ...
--   ...
--   instance WorldName `Has` EntityCounter where ...
--   
--   initWorldName :: IO WorldName
--   initWorldName = WorldName &lt;$&gt; initStore &lt;*&gt; initStore &lt;*&gt; ... &lt;*&gt; initStore
--   </pre>
--   
--   |
makeWorld :: String -> [Name] -> Q [Dec]

-- | Same as <a>makeWorld</a>, but has no <a>EntityCounter</a>
makeWorldNoEC :: String -> [Name] -> Q [Dec]

-- | Same as makeWorld, but also defines <tt>Component</tt> instances with
--   a <tt>Map</tt> store.
makeWorldAndComponents :: String -> [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 <tt>w</tt> is the
--   game world variable. Systems serve to
--   
--   <ul>
--   <li>Allow type-based lookup of a component's store through
--   <tt>getStore</tt>.</li>
--   <li>Lift side effects into their host Monad.</li>
--   </ul>
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 <tt>newEntity</tt>, <tt>cmap</tt>, 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

-- | <tt>Has w m c</tt> means that world <tt>w</tt> can produce a
--   <tt>Storage c</tt>.
class (Monad m, Component c) => Has w m c
getStore :: Has w m c => SystemT w m (Storage c)

-- | Psuedocomponent indicating the absence of <tt>a</tt>. Mainly used as
--   e.g. <tt>cmap $ (a, Not b) -&gt; c</tt> to iterate over entities with
--   an <tt>a</tt> but no <tt>b</tt>. Can also be used to delete
--   components, like <tt>cmap $ a -&gt; (Not :: Not a)</tt> to delete
--   every <tt>a</tt> 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 <tt>Data.IntMap.Strict</tt>. 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
--   <tt>Map</tt> optimized for when only ever one component inhabits it.
data Unique c

-- | A <tt>Global</tt> contains exactly one component. The initial value is
--   <a>mempty</a> from the component's <a>Monoid</a> instance.
--   
--   When operating on a Global, any entity arguments are ignored. A Global
--   component can be read with <tt>get 0</tt> or <tt>get 1</tt> or even
--   <tt>get undefined</tt>. This means that you can read and write Globals
--   while <tt>cmap</tt>ping over other components.
--   
--   The integer <tt>global</tt> is defined as -1, and can be used to make
--   operations on a global explicit, i.e. 'Time t &lt;- get global'.
data Global c

-- | A cache around another store. Caches store their members in a
--   fixed-size vector, so operations run in O(1). Caches can provide huge
--   performance boosts, especially for 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 actually 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) to internally represent missing entities,
--   so be wary when manually manipulating entities.
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 ()

-- | <tt>set</tt> 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 <tt>c</tt> 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 <tt>c</tt>
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 c. (Get w m c, Set w m c) => Entity -> (c -> c) -> SystemT w m ()

-- | <tt>modify</tt> operator
--   
--   Applies a function, if possible.
($~) :: forall w m c. (Get w m c, Set w m c) => Entity -> (c -> c) -> SystemT w m ()
infixr 2 $~

-- | Maps a function over all entities with a <tt>cx</tt>, and writes their
--   <tt>cy</tt>.
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 <tt>cx</tt>, and writes
--   their <tt>cy</tt>.
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 <tt>cx</tt>
cmapM_ :: forall w m c a. (Get w m c, Members w m c) => (c -> SystemT w m a) -> SystemT w m ()

-- | Fold over the game world; for example, <tt>cfold max (minBound ::
--   Foo)</tt> will find the maximum value of <tt>Foo</tt>. 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 <tt>makeWorld</tt>
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

-- | <pre>
--   makeWorld "WorldName" [''Component1, ''Component2, ...]
--   </pre>
--   
--   turns into
--   
--   <pre>
--   data WorldName = WorldName Component1 Component2 ... EntityCounter
--   instance WorldName `Has` Component1 where ...
--   instance WorldName `Has` Component2 where ...
--   ...
--   instance WorldName `Has` EntityCounter where ...
--   
--   initWorldName :: IO WorldName
--   initWorldName = WorldName &lt;$&gt; initStore &lt;*&gt; initStore &lt;*&gt; ... &lt;*&gt; initStore
--   </pre>
--   
--   |
makeWorld :: String -> [Name] -> Q [Dec]

-- | Same as makeWorld, but also defines <tt>Component</tt> instances with
--   a <tt>Map</tt> 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 <a>IO</a> 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

-- | <a>Proxy</a> 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, <tt><a>Proxy</a> :: <a>Proxy</a> a</tt> is a safer
--   alternative to the <tt>'undefined :: a'</tt> idiom.
--   
--   <pre>
--   &gt;&gt;&gt; Proxy :: Proxy (Void, Int -&gt; Int)
--   Proxy
--   </pre>
--   
--   Proxy can even hold types of higher kinds,
--   
--   <pre>
--   &gt;&gt;&gt; Proxy :: Proxy Either
--   Proxy
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Proxy :: Proxy Functor
--   Proxy
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Proxy :: Proxy complicatedStructure
--   Proxy
--   </pre>
data Proxy (t :: k) :: forall k. () => k -> Type
Proxy :: Proxy
