@hackage apecs0.9.6
Fast Entity-Component-System library for game programming
Categories
License
BSD-3-Clause
Maintainer
jonascarpay@gmail.com
Links
Versions
Installation
Dependencies (8)
- array >=0.4 && <0.6
- base >=4.9 && <5
- containers >=0.5 && <0.8
- exceptions >=0.10.0 && <0.11
- mtl >=2.2 && <2.4
- template-haskell >=2.12 && <3 Show all…
Dependents (7)
@hackage/apecs-brillo, @hackage/apecs-gloss, @hackage/apecs-physics-gloss, @hackage/cadence, @hackage/apecs-physics, @hackage/apecs-stm, Show all…
apecs
apecs is an Entity Component System (ECS) library for game development.
apecs aims to be
- Fast - Performance is competitive with Rust ECS libraries (see benchmark results below)
- Safe - Completely hides the dangers of the low-level machinery
- Concise - Game logic is expressed using a small number of powerful combinators
- Flexible - Easily add new modules or backends
- Cool

Links
- documentation on hackage
- tutorial and other examples
- community chat at
#apecson the haskell gamedev discord or#haskell-game:matrix.org
Games/articles
- Notakto, and associated blog post/apecs tutorial by @Ashe
- mallRL - a grocery shopping roguelike by @nmaehlmann
- An implementation of the Unity tutorial project using apecs by @mewhhaha
- SpaceMar by @dpwiz
- Achtung die haskell by @mewhhaha
- (Your game here)
Packages
-
apecs-physics - 2D physics using the Chipmunk2D engine
-
apecs-gloss - Simple frontend for gloss-based rendering
-
apecs-stm - STM-based stores for easy concurrency
Example
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
import Apecs
import Linear (V2 (..))
newtype Position = Position (V2 Double) deriving Show
newtype Velocity = Velocity (V2 Double) deriving Show
data Flying = Flying
makeWorldAndComponents "World" [''Position, ''Velocity, ''Flying]
game :: System World ()
game = do
newEntity (Position 0, Velocity 1)
newEntity (Position 2, Velocity 1)
newEntity (Position 1, Velocity 2, Flying)
-- 1. Add velocity to position
-- 2. Apply gravity to non-flying entities
-- 3. Print a list of entities and their positions
cmap $ \(Position p, Velocity v) -> Position (v+p)
cmap $ \(Velocity v, _ :: Not Flying) -> Velocity (v - V2 0 1)
cmapM_ $ \(Position p, Entity e) -> liftIO . print $ (e, p)
main :: IO ()
main = initWorld >>= runSystem game