Start to add basic gibbing

This commit is contained in:
2022-06-03 18:00:07 +01:00
parent b50e53f400
commit dd985c6a49
7 changed files with 60 additions and 11 deletions
+21
View File
@@ -0,0 +1,21 @@
module Dodge.Base.NewID where
import qualified IntMapHelp as IM
import LensHelp
-- | place an new object into an intmap and update its id
plNewUpID :: ALens' b (IM.IntMap a)
-> ALens' a Int
-> a
-> b
-> (Int,b)
plNewUpID l li x w = (i,w & l #%~ IM.insert i (x & li #~ i))
where
i = IM.newKey $ w ^# l
-- | place an new object into an intmap and update its id
plNew :: ALens' b (IM.IntMap a)
-> ALens' a Int
-> a
-> b
-> b
plNew l li x = snd . plNewUpID l li x