apecs-roaring: Roaring bitmap stores for apecs

[ bsd3, control, data, game, library ] [ Propose Tags ] [ Report a vulnerability ]

Apecs stores for flag-like components backed by CRoaring 64-bit bitmaps.


[Skip to Readme]

Modules

  • Apecs
    • Stores
      • Apecs.Stores.Flags
      • Apecs.Stores.Index
      • Apecs.Stores.Query
      • Apecs.Stores.Roaring

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 1.0
Change log CHANGELOG.md
Dependencies apecs (>=0.10 && <0.11), base (>=4.20 && <5), croaring-ffi (>=1.0 && <1.1), primitive (>=0.9 && <0.10), vector (>=0.13 && <0.14) [details]
License BSD-3-Clause
Copyright 2026 IC Rainbow
Author IC Rainbow
Maintainer aenor.realm@gmail.com
Uploaded by AlexanderBondarenko at 2026-11-09T15:33:44Z
Category Game, Control, Data
Source repo head: git clone https://gitlab.com/dpwiz/apecs-roaring
Distributions
Downloads 0 total (0 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2026-11-09 [all 2 reports]

Readme for apecs-roaring-1.0

[back to package description]

apecs-roaring

apecs stores for flag-like components and bitmap joins, backed by CRoaring 64-bit bitmaps.

See the benchmark results for how they compare with Map and Cache (tldr: counting, filtering, saving space on large-ish collections).

Usage

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}

import Apecs (Cache, Component (..), Map, cfold, makeWorld, newEntity_, runWith)
import Apecs.Stores.Flags (Flags)
import Apecs.Stores.Roaring (Roaring)
import GHC.Generics (Generic)

data Enemy = Enemy deriving (Generic)

instance Component Enemy where
  type Storage Enemy = Flags Enemy

data Dead = Dead deriving (Generic)

instance Component Dead where
  type Storage Dead = Flags Dead

newtype Health = Health Int

instance Component Health where
  type Storage Health = Roaring (Cache 1024 (Map Health))

makeWorld "World" [''Enemy, ''Dead, ''Health]

main :: IO ()
main = do
  world <- initWorld
  totalHealth <- runWith world $ do
    newEntity_ (Enemy, Health 30)
    newEntity_ (Enemy, Health 10, Dead)
    newEntity_ $ Health 50
    cfold (\total (Health health) -> total + health) 0
  print totalHealth

Query.count from Apecs.Stores.Query reads a store's size off its bitmap without visiting any entity:

enemies <- Query.count @Enemy

Every from the same module joins a tuple by intersecting bitmaps, subtracting any Not terms, and Query.count sizes the join without listing it:

cmap $ \(Every (Enemy, Health health, _ :: Not Dead)) -> Health $ health - 1
livingEnemies <- Query.count @(Every (Enemy, Not Dead))