A type-safe and friendly ECS for Haskell.
- High-performance: Components are stored by their unique sets in vector-based archetypes
- Dynamic components: Scripts and remote interfaces can create unique components with runtime-specified components
- Type-safe DSL: Components and systems are accessed by marker types that determine their storage
- Modular design: Aztecs can be extended for a variety of use cases
import Control.Arrow
import Data.Aztecs
import qualified Data.Aztecs.Access as A
import qualified Data.Aztecs.System as S
import qualified Data.Aztecs.World as W
newtype Position = Position Int deriving (Show)
instance Component Position
newtype Velocity = Velocity Int deriving (Show)
instance Component Velocity
data Setup
instance System IO Setup where
task = S.queue (A.spawn_ (Position 0 :& Velocity 1))
data Movement
instance System IO Movement where
task = S.map (\(Position x :& Velocity v) -> Position (x + v)) >>> S.run print
main :: IO ()
main = do
w <- S.runSystem @_ @Setup W.empty
_ <- S.runSystem @_ @Movement w
return ()
Aztecs is currently faster than bevy-ecs, a popular and high-performance ECS written in Rust, for simple mutating queries.
Aztecs' approach to type-safety is inspired by Bevy, but with direct archetype-based storage similar to Flecs.