Remove Reader monad from multiple creature ais

This commit is contained in:
2021-12-11 19:32:20 +00:00
parent 37b81c2967
commit c847955b7c
7 changed files with 78 additions and 131 deletions
+19
View File
@@ -0,0 +1,19 @@
module Dodge.Creature.ChainUpdates where
import Dodge.Data
import Data.Foldable
chainCreatureUpdatesLR'
:: [Either (World -> Creature -> Creature) (Creature -> Creature)]
-> World -> Creature -> Creature
chainCreatureUpdatesLR' ls w cr = foldr unf cr ls
where
unf (Left g) = g w
unf (Right g) = g
chainCreatureUpdatesLR
:: [Either (World -> Creature -> Creature) (Creature -> Creature)]
-> World -> Creature -> Creature
chainCreatureUpdatesLR ls w cr = foldl' unf cr ls
where
unf cr' (Left g) = g w cr'
unf cr' (Right g) = g cr'