This commit is contained in:
2022-07-01 12:58:47 +01:00
parent c42c2115a3
commit 650b2387b8
+4 -11
View File
@@ -1,4 +1,6 @@
module Dodge.Zone.Update where
module Dodge.Zone.Update
( updateZoning
) where
import Dodge.Data.Zoning
import StreamingHelp
import qualified Streaming.Prelude as S
@@ -7,20 +9,11 @@ import Geometry
import LensHelp
updateZoning :: Monoid (t a) => (a -> t a -> t a) -> a -> Zoning t a -> Zoning t a
{-# INLINE updateZoning #-}
updateZoning f obj zn = runIdentity (S.fold_ doinsert zn id (_znFunc zn (_znSize zn) obj))
where
doinsert znobs vxy = insertInZoneWith vxy (\_ -> f obj) (f obj mempty) znobs
--alterInZone :: (a -> Maybe (t a) -> Maybe (t a)) -> a -> Zoning
updateInZoning' :: Applicative t => (t a -> t a -> t a) -> a -> Zoning t a -> Zoning t a
updateInZoning' f obj zn = runIdentity (S.fold_ doinsert zn id (_znFunc zn (_znSize zn) obj))
where
doinsert znobs vxy = insertInZoneWith vxy f (pure obj) znobs
imInsert :: (a -> Int) -> a -> IM.IntMap a -> IM.IntMap a
imInsert getID x = IM.insert (getID x) x
insertInZoneWith
:: Int2
-> (t a -> t a -> t a) -- ^ Combining function