Retrieve or initialize a world, then run a system in it.
main = runReloadable initWorld $ do
newEntity (Position 0, Velocity 1)
cmap $ \(Position p, Velocity v) -> Position (p + v)
:: a typeCtrl KGHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11
Moduleapecs-0.10.1Haskell2010
This module is experimental, and its API might change between point releases. Use at your own risk.
Utilities for persisting an apecs world across GHCi reloads using foreign-store.
This is intended for development workflows only — do not use in production.
Important: if you change your world's type (e.g. add or remove components), you must call resetWorld or restart GHCi. The foreign store is not type-safe across type changes.
Typical usage:
mainDev :: IO ()
mainDev = runReloadable initWorld someSystem
Retrieve or initialize a world, then run a system in it.
main = runReloadable initWorld $ do
newEntity (Position 0, Velocity 1)
cmap $ \(Position p, Velocity v) -> Position (p + v)
Retrieve or initialize a world at a specified index, then run a system in it.
main = runReloadableAt 0 initWorld $ do
newEntity (Position 0, Velocity 1)
cmap $ \(Position p, Velocity v) -> Position (p + v)
Default foreign store index (0). Sufficient when only one world is used in a GHCi session. Use a different index if you need multiple independent worlds.
Look up a world in the foreign store at the given index. If one exists, return it. Otherwise, run the initialization action, persist the result, and return it.
Persist a world value at the given foreign store index, overwriting any previous value.
Discard any persisted world at the given index, initialize a fresh one, persist it, and return it.
A hideously unsafe store. Only for use if you are suave.