-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A type-safe and friendly ECS for Haskell
--
-- A type-safe and friendly ECS for Haskell
@package aztecs
@version 0.2.0.0
module Data.Aztecs.Entity
data Entity (ts :: [Type])
[ENil] :: Entity '[]
[ECons] :: t -> Entity ts -> Entity (t ': ts)
type family EntityT a
class FromEntity a
fromEntity :: FromEntity a => Entity (EntityT a) -> a
class ToEntity a
toEntity :: ToEntity a => a -> Entity (EntityT a)
type family ConcatT (a :: [Type]) (b :: [Type])
type family IntersectT (a :: [Type]) (b :: [Type]) :: [Type]
class Intersect (a :: [Type]) (b :: [Type])
intersect :: Intersect a b => Entity a -> Entity b -> Entity (IntersectT a b)
type family DifferenceT (a :: [Type]) (b :: [Type]) :: [Type]
class Difference (a :: [Type]) (b :: [Type])
difference :: Difference a b => Entity a -> Entity b -> Entity (DifferenceT a b)
type family SplitT (a :: [Type]) (b :: [Type]) :: [Type]
class Split (a :: [Type]) (b :: [Type])
split :: Split a b => Entity b -> (Entity a, Entity (SplitT a b))
concat :: Entity as -> Entity bs -> Entity (ConcatT as bs)
(<&>) :: Entity as -> a -> Entity (a : as)
data a :& b
(:&) :: a -> b -> (:&) a b
instance (Data.Aztecs.Entity.Difference as b, Data.Aztecs.Entity.DifferenceT (a : as) b GHC.Types.~ Data.Aztecs.Entity.DifferenceT as b) => Data.Aztecs.Entity.Difference' 'GHC.Types.True (a : as) b
instance (Data.Aztecs.Entity.Difference as (b : bs), Data.Aztecs.Entity.DifferenceT (a : as) (b : bs) GHC.Types.~ (a : Data.Aztecs.Entity.DifferenceT as (b : bs))) => Data.Aztecs.Entity.Difference' 'GHC.Types.False (a : as) (b : bs)
instance Data.Aztecs.Entity.Difference '[] b
instance Data.Aztecs.Entity.Difference' (Data.Aztecs.Entity.ElemT a bs) (a : as) bs => Data.Aztecs.Entity.Difference (a : as) bs
instance (Data.Aztecs.Entity.Intersect as b, Data.Aztecs.Entity.ElemT a b GHC.Types.~ 'GHC.Types.True) => Data.Aztecs.Entity.Intersect' 'GHC.Types.True (a : as) b
instance (Data.Aztecs.Entity.Intersect as (b : bs), Data.Aztecs.Entity.ElemT a (b : bs) GHC.Types.~ 'GHC.Types.False) => Data.Aztecs.Entity.Intersect' 'GHC.Types.False (a : as) (b : bs)
instance Data.Aztecs.Entity.Intersect '[] b
instance Data.Aztecs.Entity.Intersect' (Data.Aztecs.Entity.ElemT a bs) (a : as) bs => Data.Aztecs.Entity.Intersect (a : as) bs
instance (Data.Aztecs.Entity.EntityT a GHC.Types.~ '[a]) => Data.Aztecs.Entity.ToEntity a
instance Data.Aztecs.Entity.ToEntity (Data.Aztecs.Entity.Entity ts)
instance (Data.Aztecs.Entity.ToEntity a, Data.Aztecs.Entity.ToEntity b, Data.Aztecs.Entity.EntityT (a Data.Aztecs.Entity.:& b) GHC.Types.~ (a : Data.Aztecs.Entity.EntityT b)) => Data.Aztecs.Entity.ToEntity (a Data.Aztecs.Entity.:& b)
instance (Data.Aztecs.Entity.EntityT a GHC.Types.~ '[a]) => Data.Aztecs.Entity.FromEntity a
instance Data.Aztecs.Entity.FromEntity (Data.Aztecs.Entity.Entity ts)
instance (Data.Aztecs.Entity.FromEntity a, Data.Aztecs.Entity.FromEntity b, Data.Aztecs.Entity.EntityT (a Data.Aztecs.Entity.:& b) GHC.Types.~ (a : Data.Aztecs.Entity.EntityT b)) => Data.Aztecs.Entity.FromEntity (a Data.Aztecs.Entity.:& b)
instance Data.Aztecs.Entity.Split '[] bs
instance Data.Aztecs.Entity.Split as bs => Data.Aztecs.Entity.Split (a : as) (a : bs)
instance (GHC.Show.Show a, Data.Aztecs.Entity.Show' (Data.Aztecs.Entity.Entity as)) => GHC.Show.Show (Data.Aztecs.Entity.Entity (a : as))
instance Data.Aztecs.Entity.Show' (Data.Aztecs.Entity.Entity '[])
instance (GHC.Show.Show a, Data.Aztecs.Entity.Show' (Data.Aztecs.Entity.Entity as)) => Data.Aztecs.Entity.Show' (Data.Aztecs.Entity.Entity (a : as))
instance GHC.Show.Show (Data.Aztecs.Entity.Entity '[])
module Data.Aztecs.Storage
class (Typeable (s a), Typeable a) => Storage s a
singleton :: Storage s a => Int -> a -> s a
all :: Storage s a => s a -> [(Int, a)]
insert :: Storage s a => Int -> a -> s a -> s a
lookup :: Storage s a => Int -> s a -> Maybe a
fromAscList :: Storage s a => [(Int, a)] -> s a
remove :: Storage s a => Int -> s a -> (Maybe a, s a)
instance Data.Typeable.Internal.Typeable a => Data.Aztecs.Storage.Storage Data.IntMap.Internal.IntMap a
module Data.Aztecs.Core
newtype EntityID
EntityID :: Int -> EntityID
[unEntityId] :: EntityID -> Int
class (Typeable a, Storage (StorageT a) a) => Component a where {
type StorageT a :: Type -> Type;
type StorageT a = IntMap;
}
newtype ComponentID
ComponentID :: Int -> ComponentID
[unComponentId] :: ComponentID -> Int
data Components
Components :: Map TypeRep ComponentID -> ComponentID -> Components
[componentIds] :: Components -> Map TypeRep ComponentID
[nextComponentId] :: Components -> ComponentID
emptyComponents :: Components
insertComponentId :: forall c. Component c => Components -> (ComponentID, Components)
lookupComponentId :: forall a. Typeable a => Components -> Maybe ComponentID
instance GHC.Show.Show Data.Aztecs.Core.EntityID
instance GHC.Classes.Ord Data.Aztecs.Core.EntityID
instance GHC.Classes.Eq Data.Aztecs.Core.EntityID
instance GHC.Show.Show Data.Aztecs.Core.ComponentID
instance GHC.Classes.Ord Data.Aztecs.Core.ComponentID
instance GHC.Classes.Eq Data.Aztecs.Core.ComponentID
instance GHC.Show.Show Data.Aztecs.Core.Components
module Data.Aztecs.Archetype
data AnyStorage
AnyStorage :: Dynamic -> (Int -> Dynamic -> Dynamic -> Dynamic) -> (Int -> Dynamic -> (Maybe Dynamic, Dynamic)) -> (Int -> Dynamic -> (Maybe AnyStorage, Dynamic)) -> AnyStorage
[storageDyn] :: AnyStorage -> Dynamic
[insertDyn] :: AnyStorage -> Int -> Dynamic -> Dynamic -> Dynamic
[removeDyn] :: AnyStorage -> Int -> Dynamic -> (Maybe Dynamic, Dynamic)
[removeAny] :: AnyStorage -> Int -> Dynamic -> (Maybe AnyStorage, Dynamic)
anyStorage :: forall s a. Storage s a => s a -> AnyStorage
newtype Archetype
Archetype :: Map ComponentID AnyStorage -> Archetype
[storages] :: Archetype -> Map ComponentID AnyStorage
empty :: Archetype
lookupStorage :: Component a => ComponentID -> Archetype -> Maybe (StorageT a a)
insert :: forall a. Component a => EntityID -> ComponentID -> a -> Archetype -> Archetype
all :: Component a => ComponentID -> Archetype -> [(EntityID, a)]
lookup :: forall a. Component a => EntityID -> ComponentID -> Archetype -> Maybe a
insertAscList :: forall a. Component a => ComponentID -> [(EntityID, a)] -> Archetype -> Archetype
remove :: EntityID -> Archetype -> (Map ComponentID Dynamic, Archetype)
removeStorages :: EntityID -> Archetype -> (Map ComponentID AnyStorage, Archetype)
instance GHC.Show.Show Data.Aztecs.Archetype.Archetype
instance GHC.Show.Show Data.Aztecs.Archetype.AnyStorage
module Data.Aztecs.World
newtype ArchetypeID
ArchetypeID :: Int -> ArchetypeID
[unArchetypeId] :: ArchetypeID -> Int
-- | World of entities and their components.
data World
World :: Map ArchetypeID Archetype -> Map (Set ComponentID) ArchetypeID -> Map ArchetypeID (Set ComponentID) -> ArchetypeID -> Components -> Map EntityID ArchetypeID -> EntityID -> World
[archetypes] :: World -> Map ArchetypeID Archetype
[archetypeIds] :: World -> Map (Set ComponentID) ArchetypeID
[archetypeComponents] :: World -> Map ArchetypeID (Set ComponentID)
[nextArchetypeId] :: World -> ArchetypeID
[components] :: World -> Components
[entities] :: World -> Map EntityID ArchetypeID
[nextEntityId] :: World -> EntityID
-- | Empty World.
empty :: World
-- | Spawn an entity with a component.
spawn :: forall a. (Component a, Typeable (StorageT a)) => a -> World -> (EntityID, World)
-- | Spawn an entity with a component and its ComponentID.
spawnWithId :: forall a. (Component a, Typeable (StorageT a)) => ComponentID -> a -> World -> (EntityID, World)
-- | Spawn an entity with a component and its ComponentID directly
-- into an archetype.
spawnWithArchetypeId :: forall a. (Component a, Typeable (StorageT a)) => a -> ComponentID -> ArchetypeID -> World -> (EntityID, World)
-- | Spawn an empty entity.
spawnEmpty :: World -> (EntityID, World)
insert :: forall a. (Component a, Typeable (StorageT a)) => EntityID -> a -> World -> World
insertWithId :: (Component a, Typeable (StorageT a)) => EntityID -> ComponentID -> a -> World -> World
-- | Insert an archetype by its set of ComponentIDs.
insertArchetype :: Set ComponentID -> Archetype -> World -> (ArchetypeID, World)
despawn :: EntityID -> World -> (Map ComponentID Dynamic, World)
instance GHC.Show.Show Data.Aztecs.World.ArchetypeID
instance GHC.Classes.Ord Data.Aztecs.World.ArchetypeID
instance GHC.Classes.Eq Data.Aztecs.World.ArchetypeID
instance GHC.Show.Show Data.Aztecs.World.World
module Data.Aztecs.Access
newtype Access m a
Access :: StateT World m a -> Access m a
[unAccess] :: Access m a -> StateT World m a
runAccess :: Access m a -> World -> m (a, World)
spawn :: (Monad m, Component a, Typeable (StorageT a)) => a -> Access m EntityID
insert :: (Monad m, Component a, Typeable (StorageT a)) => EntityID -> a -> Access m ()
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Data.Aztecs.Access.Access m)
instance GHC.Base.Monad m => GHC.Base.Monad (Data.Aztecs.Access.Access m)
instance GHC.Base.Monad m => GHC.Base.Applicative (Data.Aztecs.Access.Access m)
instance GHC.Base.Functor m => GHC.Base.Functor (Data.Aztecs.Access.Access m)
module Data.Aztecs.Query
-- | Query into the World.
newtype Query a
Query :: (Components -> (Set ComponentID, Archetype -> ([Entity a], [Entity a] -> Archetype -> Archetype))) -> Query a
[runQuery'] :: Query a -> Components -> (Set ComponentID, Archetype -> ([Entity a], [Entity a] -> Archetype -> Archetype))
(>) :: (Split a (ConcatT a b), SplitT a (ConcatT a b) ~ b) => Query a -> Query b -> Query (ConcatT a b)
fetch :: forall a. (Component a, Typeable (StorageT a)) => Query '[a]
all :: forall m a. (Monad m, ToEntity a, FromEntity a, ToQuery (EntityT a)) => Access m [a]
allWorld :: Query a -> World -> [Entity a]
map :: forall m i o. (Monad m, FromEntity i, ToEntity o, Intersect (EntityT i) (EntityT o), ToQuery (IntersectT (EntityT i) (EntityT o)), Difference (EntityT i) (EntityT o), ToQuery (DifferenceT (EntityT i) (EntityT o)), ConcatT (DifferenceT (EntityT i) (EntityT o)) (IntersectT (EntityT i) (EntityT o)) ~ EntityT i, IntersectT (EntityT i) (EntityT o) ~ EntityT o) => (i -> o) -> Access m [o]
mapWorld :: forall i o. (FromEntity i, ToEntity o, Intersect (EntityT i) (EntityT o), ToQuery (IntersectT (EntityT i) (EntityT o)), Difference (EntityT i) (EntityT o), ToQuery (DifferenceT (EntityT i) (EntityT o)), ConcatT (DifferenceT (EntityT i) (EntityT o)) (IntersectT (EntityT i) (EntityT o)) ~ EntityT i, IntersectT (EntityT i) (EntityT o) ~ EntityT o) => (i -> o) -> World -> ([o], World)
mapWith :: (FromEntity i, ToEntity o, EntityT i ~ ConcatT a b, EntityT o ~ b) => Query a -> Query b -> (i -> o) -> World -> ([o], World)
instance Data.Aztecs.Query.ToQuery '[]
instance (Data.Aztecs.Core.Component a, Data.Typeable.Internal.Typeable (Data.Aztecs.Core.StorageT a)) => Data.Aztecs.Query.ToQuery '[a]
instance (Data.Aztecs.Core.Component a, Data.Typeable.Internal.Typeable (Data.Aztecs.Core.StorageT a), Data.Aztecs.Query.ToQuery as) => Data.Aztecs.Query.ToQuery (a : as)
module Data.Aztecs
data Access m a
runAccess :: Access m a -> World -> m (a, World)
class (Typeable a, Storage (StorageT a) a) => Component a where {
type StorageT a :: Type -> Type;
type StorageT a = IntMap;
}
data EntityID
data Entity (ts :: [Type])
data a :& b
(:&) :: a -> b -> (:&) a b