{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Aztecs.ECS.System
( System,
SystemT (..),
ArrowReaderSystem (..),
ArrowSystem (..),
ArrowQueueSystem (..),
fromReader,
)
where
import Aztecs.ECS.Access
import Aztecs.ECS.Query (Query (..), QueryFilter (..), ReadsWrites (..))
import qualified Aztecs.ECS.Query as Q
import Aztecs.ECS.Query.Reader (DynamicQueryFilter (..), QueryReader (..))
import Aztecs.ECS.System.Class
import Aztecs.ECS.System.Dynamic
import Aztecs.ECS.System.Reader
import qualified Aztecs.ECS.World.Archetype as A
import Aztecs.ECS.World.Archetypes (Node (..))
import Aztecs.ECS.World.Bundle
import Aztecs.ECS.World.Components (Components)
import Control.Arrow
import Control.Category
import Control.Monad.Identity
import qualified Data.Foldable as F
import Prelude hiding (all, filter, id, map, (.))
import qualified Prelude hiding (filter, id, map)
type System = SystemT Identity
newtype SystemT m i o = System
{
forall (m :: * -> *) i o.
SystemT m i o
-> Components -> (DynamicSystemT m i o, ReadsWrites, Components)
runSystem :: Components -> (DynamicSystemT m i o, ReadsWrites, Components)
}
deriving ((forall a b. (a -> b) -> SystemT m i a -> SystemT m i b)
-> (forall a b. a -> SystemT m i b -> SystemT m i a)
-> Functor (SystemT m i)
forall a b. a -> SystemT m i b -> SystemT m i a
forall a b. (a -> b) -> SystemT m i a -> SystemT m i b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
forall (m :: * -> *) i a b. a -> SystemT m i b -> SystemT m i a
forall (m :: * -> *) i a b.
(a -> b) -> SystemT m i a -> SystemT m i b
$cfmap :: forall (m :: * -> *) i a b.
(a -> b) -> SystemT m i a -> SystemT m i b
fmap :: forall a b. (a -> b) -> SystemT m i a -> SystemT m i b
$c<$ :: forall (m :: * -> *) i a b. a -> SystemT m i b -> SystemT m i a
<$ :: forall a b. a -> SystemT m i b -> SystemT m i a
Functor)
instance (Monad m) => Category (SystemT m) where
id :: forall a. SystemT m a a
id = (Components -> (DynamicSystemT m a a, ReadsWrites, Components))
-> SystemT m a a
forall (m :: * -> *) i o.
(Components -> (DynamicSystemT m i o, ReadsWrites, Components))
-> SystemT m i o
System ((Components -> (DynamicSystemT m a a, ReadsWrites, Components))
-> SystemT m a a)
-> (Components -> (DynamicSystemT m a a, ReadsWrites, Components))
-> SystemT m a a
forall a b. (a -> b) -> a -> b
$ \Components
cs -> ((Entities -> a -> (a, View, AccessT m (), DynamicSystemT m a a))
-> DynamicSystemT m a a
forall (m :: * -> *) i o.
(Entities -> i -> (o, View, AccessT m (), DynamicSystemT m i o))
-> DynamicSystemT m i o
DynamicSystem ((Entities -> a -> (a, View, AccessT m (), DynamicSystemT m a a))
-> DynamicSystemT m a a)
-> (Entities -> a -> (a, View, AccessT m (), DynamicSystemT m a a))
-> DynamicSystemT m a a
forall a b. (a -> b) -> a -> b
$ \Entities
_ a
i -> (a
i, View
forall a. Monoid a => a
mempty, () -> AccessT m ()
forall a. a -> AccessT m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (), DynamicSystemT m a a
forall a. DynamicSystemT m a a
forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id), ReadsWrites
forall a. Monoid a => a
mempty, Components
cs)
System Components -> (DynamicSystemT m b c, ReadsWrites, Components)
f . :: forall b c a. SystemT m b c -> SystemT m a b -> SystemT m a c
. System Components -> (DynamicSystemT m a b, ReadsWrites, Components)
g = (Components -> (DynamicSystemT m a c, ReadsWrites, Components))
-> SystemT m a c
forall (m :: * -> *) i o.
(Components -> (DynamicSystemT m i o, ReadsWrites, Components))
-> SystemT m i o
System ((Components -> (DynamicSystemT m a c, ReadsWrites, Components))
-> SystemT m a c)
-> (Components -> (DynamicSystemT m a c, ReadsWrites, Components))
-> SystemT m a c
forall a b. (a -> b) -> a -> b
$ \Components
cs ->
let (DynamicSystemT m b c
f', ReadsWrites
rwsF, Components
cs') = Components -> (DynamicSystemT m b c, ReadsWrites, Components)
f Components
cs
(DynamicSystemT m a b
g', ReadsWrites
rwsG, Components
cs'') = Components -> (DynamicSystemT m a b, ReadsWrites, Components)
g Components
cs'
in (DynamicSystemT m b c
f' DynamicSystemT m b c
-> DynamicSystemT m a b -> DynamicSystemT m a c
forall b c a.
DynamicSystemT m b c
-> DynamicSystemT m a b -> DynamicSystemT m a c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. DynamicSystemT m a b
g', ReadsWrites
rwsF ReadsWrites -> ReadsWrites -> ReadsWrites
forall a. Semigroup a => a -> a -> a
<> ReadsWrites
rwsG, Components
cs'')
instance (Monad m) => Arrow (SystemT m) where
arr :: forall b c. (b -> c) -> SystemT m b c
arr b -> c
f = (Components -> (DynamicSystemT m b c, ReadsWrites, Components))
-> SystemT m b c
forall (m :: * -> *) i o.
(Components -> (DynamicSystemT m i o, ReadsWrites, Components))
-> SystemT m i o
System ((Components -> (DynamicSystemT m b c, ReadsWrites, Components))
-> SystemT m b c)
-> (Components -> (DynamicSystemT m b c, ReadsWrites, Components))
-> SystemT m b c
forall a b. (a -> b) -> a -> b
$ \Components
cs -> ((Entities -> b -> (c, View, AccessT m (), DynamicSystemT m b c))
-> DynamicSystemT m b c
forall (m :: * -> *) i o.
(Entities -> i -> (o, View, AccessT m (), DynamicSystemT m i o))
-> DynamicSystemT m i o
DynamicSystem ((Entities -> b -> (c, View, AccessT m (), DynamicSystemT m b c))
-> DynamicSystemT m b c)
-> (Entities -> b -> (c, View, AccessT m (), DynamicSystemT m b c))
-> DynamicSystemT m b c
forall a b. (a -> b) -> a -> b
$ \Entities
_ b
i -> (b -> c
f b
i, View
forall a. Monoid a => a
mempty, () -> AccessT m ()
forall a. a -> AccessT m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (), (b -> c) -> DynamicSystemT m b c
forall b c. (b -> c) -> DynamicSystemT m b c
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr b -> c
f), ReadsWrites
forall a. Monoid a => a
mempty, Components
cs)
first :: forall b c d. SystemT m b c -> SystemT m (b, d) (c, d)
first (System Components -> (DynamicSystemT m b c, ReadsWrites, Components)
f) = (Components
-> (DynamicSystemT m (b, d) (c, d), ReadsWrites, Components))
-> SystemT m (b, d) (c, d)
forall (m :: * -> *) i o.
(Components -> (DynamicSystemT m i o, ReadsWrites, Components))
-> SystemT m i o
System ((Components
-> (DynamicSystemT m (b, d) (c, d), ReadsWrites, Components))
-> SystemT m (b, d) (c, d))
-> (Components
-> (DynamicSystemT m (b, d) (c, d), ReadsWrites, Components))
-> SystemT m (b, d) (c, d)
forall a b. (a -> b) -> a -> b
$ \Components
cs ->
let (DynamicSystemT m b c
f', ReadsWrites
rwsF, Components
cs') = Components -> (DynamicSystemT m b c, ReadsWrites, Components)
f Components
cs in (DynamicSystemT m b c -> DynamicSystemT m (b, d) (c, d)
forall b c d.
DynamicSystemT m b c -> DynamicSystemT m (b, d) (c, d)
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first DynamicSystemT m b c
f', ReadsWrites
rwsF, Components
cs')
SystemT m b c
f &&& :: forall b c c'.
SystemT m b c -> SystemT m b c' -> SystemT m b (c, c')
&&& SystemT m b c'
g = (Components
-> (DynamicSystemT m b (c, c'), ReadsWrites, Components))
-> SystemT m b (c, c')
forall (m :: * -> *) i o.
(Components -> (DynamicSystemT m i o, ReadsWrites, Components))
-> SystemT m i o
System ((Components
-> (DynamicSystemT m b (c, c'), ReadsWrites, Components))
-> SystemT m b (c, c'))
-> (Components
-> (DynamicSystemT m b (c, c'), ReadsWrites, Components))
-> SystemT m b (c, c')
forall a b. (a -> b) -> a -> b
$ \Components
cs ->
let (DynamicSystemT m b c
dynF, ReadsWrites
rwsA, Components
cs') = SystemT m b c
-> Components -> (DynamicSystemT m b c, ReadsWrites, Components)
forall (m :: * -> *) i o.
SystemT m i o
-> Components -> (DynamicSystemT m i o, ReadsWrites, Components)
runSystem SystemT m b c
f Components
cs
(DynamicSystemT m b c'
dynG, ReadsWrites
rwsB, Components
cs'') = SystemT m b c'
-> Components -> (DynamicSystemT m b c', ReadsWrites, Components)
forall (m :: * -> *) i o.
SystemT m i o
-> Components -> (DynamicSystemT m i o, ReadsWrites, Components)
runSystem SystemT m b c'
g Components
cs'
dynS :: DynamicSystemT m b (c, c')
dynS = if ReadsWrites -> ReadsWrites -> Bool
Q.disjoint ReadsWrites
rwsA ReadsWrites
rwsB then DynamicSystemT m b c
dynF DynamicSystemT m b c
-> DynamicSystemT m b c' -> DynamicSystemT m b (c, c')
forall b c c'.
DynamicSystemT m b c
-> DynamicSystemT m b c' -> DynamicSystemT m b (c, c')
forall (a :: * -> * -> *) b c c'.
Arrow a =>
a b c -> a b c' -> a b (c, c')
&&& DynamicSystemT m b c'
dynG else DynamicSystemT m b c
-> DynamicSystemT m b c' -> DynamicSystemT m b (c, c')
forall (m :: * -> *) i a b.
Monad m =>
DynamicSystemT m i a
-> DynamicSystemT m i b -> DynamicSystemT m i (a, b)
raceDyn DynamicSystemT m b c
dynF DynamicSystemT m b c'
dynG
in (DynamicSystemT m b (c, c')
dynS, ReadsWrites
rwsA ReadsWrites -> ReadsWrites -> ReadsWrites
forall a. Semigroup a => a -> a -> a
<> ReadsWrites
rwsB, Components
cs'')
instance (Monad m) => ArrowChoice (SystemT m) where
left :: forall b c d. SystemT m b c -> SystemT m (Either b d) (Either c d)
left (System Components -> (DynamicSystemT m b c, ReadsWrites, Components)
f) = (Components
-> (DynamicSystemT m (Either b d) (Either c d), ReadsWrites,
Components))
-> SystemT m (Either b d) (Either c d)
forall (m :: * -> *) i o.
(Components -> (DynamicSystemT m i o, ReadsWrites, Components))
-> SystemT m i o
System ((Components
-> (DynamicSystemT m (Either b d) (Either c d), ReadsWrites,
Components))
-> SystemT m (Either b d) (Either c d))
-> (Components
-> (DynamicSystemT m (Either b d) (Either c d), ReadsWrites,
Components))
-> SystemT m (Either b d) (Either c d)
forall a b. (a -> b) -> a -> b
$ \Components
cs -> let (DynamicSystemT m b c
f', ReadsWrites
rwsF, Components
cs') = Components -> (DynamicSystemT m b c, ReadsWrites, Components)
f Components
cs in (DynamicSystemT m b c -> DynamicSystemT m (Either b d) (Either c d)
forall b c d.
DynamicSystemT m b c -> DynamicSystemT m (Either b d) (Either c d)
forall (a :: * -> * -> *) b c d.
ArrowChoice a =>
a b c -> a (Either b d) (Either c d)
left DynamicSystemT m b c
f', ReadsWrites
rwsF, Components
cs')
instance (Monad m) => ArrowLoop (SystemT m) where
loop :: forall b d c. SystemT m (b, d) (c, d) -> SystemT m b c
loop (System Components
-> (DynamicSystemT m (b, d) (c, d), ReadsWrites, Components)
f) = (Components -> (DynamicSystemT m b c, ReadsWrites, Components))
-> SystemT m b c
forall (m :: * -> *) i o.
(Components -> (DynamicSystemT m i o, ReadsWrites, Components))
-> SystemT m i o
System ((Components -> (DynamicSystemT m b c, ReadsWrites, Components))
-> SystemT m b c)
-> (Components -> (DynamicSystemT m b c, ReadsWrites, Components))
-> SystemT m b c
forall a b. (a -> b) -> a -> b
$ \Components
cs -> let (DynamicSystemT m (b, d) (c, d)
f', ReadsWrites
rwsF, Components
cs') = Components
-> (DynamicSystemT m (b, d) (c, d), ReadsWrites, Components)
f Components
cs in (DynamicSystemT m (b, d) (c, d) -> DynamicSystemT m b c
forall b d c.
DynamicSystemT m (b, d) (c, d) -> DynamicSystemT m b c
forall (a :: * -> * -> *) b d c.
ArrowLoop a =>
a (b, d) (c, d) -> a b c
loop DynamicSystemT m (b, d) (c, d)
f', ReadsWrites
rwsF, Components
cs')
instance (Monad m) => ArrowReaderSystem QueryReader (SystemT m) where
all :: forall i a. QueryReader i a -> SystemT m i [a]
all = ReaderSystemT m i [a] -> SystemT m i [a]
forall (m :: * -> *) i o.
Monad m =>
ReaderSystemT m i o -> SystemT m i o
fromReader (ReaderSystemT m i [a] -> SystemT m i [a])
-> (QueryReader i a -> ReaderSystemT m i [a])
-> QueryReader i a
-> SystemT m i [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. QueryReader i a -> ReaderSystemT m i [a]
forall i a. QueryReader i a -> ReaderSystemT m i [a]
forall (q :: * -> * -> *) (arr :: * -> * -> *) i a.
ArrowReaderSystem q arr =>
q i a -> arr i [a]
all
filter :: forall a. QueryReader () a -> QueryFilter -> SystemT m () [a]
filter QueryReader () a
q = ReaderSystemT m () [a] -> SystemT m () [a]
forall (m :: * -> *) i o.
Monad m =>
ReaderSystemT m i o -> SystemT m i o
fromReader (ReaderSystemT m () [a] -> SystemT m () [a])
-> (QueryFilter -> ReaderSystemT m () [a])
-> QueryFilter
-> SystemT m () [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. QueryReader () a -> QueryFilter -> ReaderSystemT m () [a]
forall a. QueryReader () a -> QueryFilter -> ReaderSystemT m () [a]
forall (q :: * -> * -> *) (arr :: * -> * -> *) a.
ArrowReaderSystem q arr =>
q () a -> QueryFilter -> arr () [a]
filter QueryReader () a
q
instance (Monad m) => ArrowSystem Query (SystemT m) where
map :: forall i a. Query i a -> SystemT m i [a]
map Query i a
q = (Components -> (DynamicSystemT m i [a], ReadsWrites, Components))
-> SystemT m i [a]
forall (m :: * -> *) i o.
(Components -> (DynamicSystemT m i o, ReadsWrites, Components))
-> SystemT m i o
System ((Components -> (DynamicSystemT m i [a], ReadsWrites, Components))
-> SystemT m i [a])
-> (Components
-> (DynamicSystemT m i [a], ReadsWrites, Components))
-> SystemT m i [a]
forall a b. (a -> b) -> a -> b
$ \Components
cs ->
let !(ReadsWrites
rws, Components
cs', DynamicQuery i a
dynQ) = Query i a
-> Components -> (ReadsWrites, Components, DynamicQuery i a)
forall i o.
Query i o
-> Components -> (ReadsWrites, Components, DynamicQuery i o)
runQuery Query i a
q Components
cs
in (Set ComponentID -> DynamicQuery i a -> DynamicSystemT m i [a]
forall i o.
Set ComponentID -> DynamicQuery i o -> DynamicSystemT m i [o]
forall (q :: * -> * -> *) (arr :: * -> * -> *) i o.
ArrowDynamicSystem q arr =>
Set ComponentID -> q i o -> arr i [o]
mapDyn (ReadsWrites -> Set ComponentID
Q.reads ReadsWrites
rws Set ComponentID -> Set ComponentID -> Set ComponentID
forall a. Semigroup a => a -> a -> a
<> ReadsWrites -> Set ComponentID
Q.writes ReadsWrites
rws) DynamicQuery i a
dynQ, ReadsWrites
rws, Components
cs')
filterMap :: forall i a. Query i a -> QueryFilter -> SystemT m i [a]
filterMap Query i a
q QueryFilter
qf = (Components -> (DynamicSystemT m i [a], ReadsWrites, Components))
-> SystemT m i [a]
forall (m :: * -> *) i o.
(Components -> (DynamicSystemT m i o, ReadsWrites, Components))
-> SystemT m i o
System ((Components -> (DynamicSystemT m i [a], ReadsWrites, Components))
-> SystemT m i [a])
-> (Components
-> (DynamicSystemT m i [a], ReadsWrites, Components))
-> SystemT m i [a]
forall a b. (a -> b) -> a -> b
$ \Components
cs ->
let !(ReadsWrites
rws, Components
cs', DynamicQuery i a
dynQ) = Query i a
-> Components -> (ReadsWrites, Components, DynamicQuery i a)
forall i o.
Query i o
-> Components -> (ReadsWrites, Components, DynamicQuery i o)
runQuery Query i a
q Components
cs
!(DynamicQueryFilter
dynQf, Components
cs'') = QueryFilter -> Components -> (DynamicQueryFilter, Components)
runQueryFilter QueryFilter
qf Components
cs'
f' :: Node -> Bool
f' Node
n =
(ComponentID -> Bool) -> Set ComponentID -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
F.all (\ComponentID
cId -> ComponentID -> Archetype -> Bool
A.member ComponentID
cId (Archetype -> Bool) -> Archetype -> Bool
forall a b. (a -> b) -> a -> b
$ Node -> Archetype
nodeArchetype Node
n) (DynamicQueryFilter -> Set ComponentID
filterWith DynamicQueryFilter
dynQf)
Bool -> Bool -> Bool
&& (ComponentID -> Bool) -> Set ComponentID -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
F.all (\ComponentID
cId -> Bool -> Bool
not (ComponentID -> Archetype -> Bool
A.member ComponentID
cId (Archetype -> Bool) -> Archetype -> Bool
forall a b. (a -> b) -> a -> b
$ Node -> Archetype
nodeArchetype Node
n)) (DynamicQueryFilter -> Set ComponentID
filterWithout DynamicQueryFilter
dynQf)
in (Set ComponentID
-> DynamicQuery i a -> (Node -> Bool) -> DynamicSystemT m i [a]
forall i o.
Set ComponentID
-> DynamicQuery i o -> (Node -> Bool) -> DynamicSystemT m i [o]
forall (q :: * -> * -> *) (arr :: * -> * -> *) i o.
ArrowDynamicSystem q arr =>
Set ComponentID -> q i o -> (Node -> Bool) -> arr i [o]
filterMapDyn (ReadsWrites -> Set ComponentID
Q.reads ReadsWrites
rws Set ComponentID -> Set ComponentID -> Set ComponentID
forall a. Semigroup a => a -> a -> a
<> ReadsWrites -> Set ComponentID
Q.writes ReadsWrites
rws) DynamicQuery i a
dynQ Node -> Bool
f', ReadsWrites
rws, Components
cs'')
mapSingle :: forall i a. Query i a -> SystemT m i a
mapSingle Query i a
q = (Components -> (DynamicSystemT m i a, ReadsWrites, Components))
-> SystemT m i a
forall (m :: * -> *) i o.
(Components -> (DynamicSystemT m i o, ReadsWrites, Components))
-> SystemT m i o
System ((Components -> (DynamicSystemT m i a, ReadsWrites, Components))
-> SystemT m i a)
-> (Components -> (DynamicSystemT m i a, ReadsWrites, Components))
-> SystemT m i a
forall a b. (a -> b) -> a -> b
$ \Components
cs ->
let !(ReadsWrites
rws, Components
cs', DynamicQuery i a
dynQ) = Query i a
-> Components -> (ReadsWrites, Components, DynamicQuery i a)
forall i o.
Query i o
-> Components -> (ReadsWrites, Components, DynamicQuery i o)
runQuery Query i a
q Components
cs
in (Set ComponentID -> DynamicQuery i a -> DynamicSystemT m i a
forall i o.
Set ComponentID -> DynamicQuery i o -> DynamicSystemT m i o
forall (q :: * -> * -> *) (arr :: * -> * -> *) i o.
ArrowDynamicSystem q arr =>
Set ComponentID -> q i o -> arr i o
mapSingleDyn (ReadsWrites -> Set ComponentID
Q.reads ReadsWrites
rws Set ComponentID -> Set ComponentID -> Set ComponentID
forall a. Semigroup a => a -> a -> a
<> ReadsWrites -> Set ComponentID
Q.writes ReadsWrites
rws) DynamicQuery i a
dynQ, ReadsWrites
rws, Components
cs')
mapSingleMaybe :: forall i a. Query i a -> SystemT m i (Maybe a)
mapSingleMaybe Query i a
q = (Components
-> (DynamicSystemT m i (Maybe a), ReadsWrites, Components))
-> SystemT m i (Maybe a)
forall (m :: * -> *) i o.
(Components -> (DynamicSystemT m i o, ReadsWrites, Components))
-> SystemT m i o
System ((Components
-> (DynamicSystemT m i (Maybe a), ReadsWrites, Components))
-> SystemT m i (Maybe a))
-> (Components
-> (DynamicSystemT m i (Maybe a), ReadsWrites, Components))
-> SystemT m i (Maybe a)
forall a b. (a -> b) -> a -> b
$ \Components
cs ->
let !(ReadsWrites
rws, Components
cs', DynamicQuery i a
dynQ) = Query i a
-> Components -> (ReadsWrites, Components, DynamicQuery i a)
forall i o.
Query i o
-> Components -> (ReadsWrites, Components, DynamicQuery i o)
runQuery Query i a
q Components
cs
in (Set ComponentID -> DynamicQuery i a -> DynamicSystemT m i (Maybe a)
forall i o.
Set ComponentID -> DynamicQuery i o -> DynamicSystemT m i (Maybe o)
forall (q :: * -> * -> *) (arr :: * -> * -> *) i o.
ArrowDynamicSystem q arr =>
Set ComponentID -> q i o -> arr i (Maybe o)
mapSingleMaybeDyn (ReadsWrites -> Set ComponentID
Q.reads ReadsWrites
rws Set ComponentID -> Set ComponentID -> Set ComponentID
forall a. Semigroup a => a -> a -> a
<> ReadsWrites -> Set ComponentID
Q.writes ReadsWrites
rws) DynamicQuery i a
dynQ, ReadsWrites
rws, Components
cs')
instance (Monad m) => ArrowQueueSystem Bundle (AccessT m) (SystemT m) where
queue :: forall i. (i -> AccessT m ()) -> SystemT m i ()
queue i -> AccessT m ()
f = (Components -> (DynamicSystemT m i (), ReadsWrites, Components))
-> SystemT m i ()
forall (m :: * -> *) i o.
(Components -> (DynamicSystemT m i o, ReadsWrites, Components))
-> SystemT m i o
System ((Components -> (DynamicSystemT m i (), ReadsWrites, Components))
-> SystemT m i ())
-> (Components -> (DynamicSystemT m i (), ReadsWrites, Components))
-> SystemT m i ()
forall a b. (a -> b) -> a -> b
$ \Components
cs -> ((i -> AccessT m ()) -> DynamicSystemT m i ()
forall i. (i -> AccessT m ()) -> DynamicSystemT m i ()
forall b (m :: * -> *) (arr :: * -> * -> *) i.
ArrowQueueSystem b m arr =>
(i -> m ()) -> arr i ()
queue i -> AccessT m ()
f, ReadsWrites
forall a. Monoid a => a
mempty, Components
cs)
fromReader :: (Monad m) => ReaderSystemT m i o -> SystemT m i o
fromReader :: forall (m :: * -> *) i o.
Monad m =>
ReaderSystemT m i o -> SystemT m i o
fromReader (ReaderSystem Components
-> (DynamicReaderSystemT m i o, Set ComponentID, Components)
f) = (Components -> (DynamicSystemT m i o, ReadsWrites, Components))
-> SystemT m i o
forall (m :: * -> *) i o.
(Components -> (DynamicSystemT m i o, ReadsWrites, Components))
-> SystemT m i o
System ((Components -> (DynamicSystemT m i o, ReadsWrites, Components))
-> SystemT m i o)
-> (Components -> (DynamicSystemT m i o, ReadsWrites, Components))
-> SystemT m i o
forall a b. (a -> b) -> a -> b
$ \Components
cs ->
let (DynamicReaderSystemT m i o
f', Set ComponentID
rs, Components
cs') = Components
-> (DynamicReaderSystemT m i o, Set ComponentID, Components)
f Components
cs in (DynamicReaderSystemT m i o -> DynamicSystemT m i o
forall (m :: * -> *) i o.
DynamicReaderSystemT m i o -> DynamicSystemT m i o
fromDynReaderSystem DynamicReaderSystemT m i o
f', Set ComponentID -> Set ComponentID -> ReadsWrites
ReadsWrites Set ComponentID
rs Set ComponentID
forall a. Monoid a => a
mempty, Components
cs')