HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleapecs-0.9.6Haskell2010

Apecs.Stores

  • 5 types
  • 1 class
  • 2 values
  • Packageapecs-0.9.6
  • Exports8
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceStores.hs
newtypenewtype Map c
#

A map based on Data.IntMap.Strict. O(log(n)) for most operations.

Instances7ExplInit, ExplDestroy, ExplGet, ExplMembers, ExplSet, Cachable, …
datadata Cache (n :: Nat) s
#

A cache around another store. Caches store their members in a fixed-size vector, so read/write operations become O(1). Caches can provide huge performance boosts, especially when working with large numbers of components.

The cache size is given as a type-level argument.

Note that iterating over a cache is linear in cache size, so sparsely populated caches might decrease performance. In general, the exact size of the cache does not matter as long as it reasonably approximates the number of components present.

The cache uses entity (-2) internally to represent missing entities. If you manually manipulate Entity values, be careful that you do not use (-2)

The actual cache is not necessarily the given argument, but the next biggest power of two. This is allows most operations to be expressed as bit masks, for a large potential performance boost.

Instances7ExplInit, ExplDestroy, ExplGet, ExplMembers, ExplSet, Cachable, …
newtypenewtype Unique c
#

A Unique contains zero or one component. Writing to it overwrites both the previous component and its owner. Its main purpose is to be a Map optimized for when only ever one component inhabits it.

Instances6ExplInit, ExplDestroy, ExplGet, ExplMembers, ExplSet, Elem
newtypenewtype Global c
#

A Global contains exactly one component. The initial value is mempty from the component's Monoid instance. Querying a Global at any Entity yields this one component, effectively sharing the component between all entities.

A Global component can be read with get 0 or get 1 or even get undefined. The convenience entity global is defined as -1, and can be used to make operations on a global more explicit, i.e. 'Time t <- get global'.

You also can read and write Globals during a cmap over other components.

Instances4ExplInit, ExplGet, ExplSet, Elem
classclass Cachable s
#

Class of stores that behave like a regular map, and can therefore safely be cached. This prevents stores like Unique and Global, which do not behave like simple maps, from being cached.

Instances2Cachable
newtypenewtype ReadOnly s
#

Wrapper that makes a store read-only by hiding its ExplSet and ExplDestroy instances. This is primarily used to protect the EntityCounter from accidental overwrites. Use setReadOnly and destroyReadOnly to override.

Instances4ExplInit, ExplGet, ExplMembers, Elem