к
foldrM f z = foldr (\a b -> b >>= \b' -> f a b') (pure z)
foldrM' :: Monad m => (a -> b -> m b) -> b -> [a] -> m b
foldrM' f z [] = pure z
foldrM' f z (a : xs) = do
b <- foldrM' f z xs
f a b
Size: a a a
к
A
AP
AP
ListT State a
и StateT [] a
AP
State World [a]
~ State World a
тут нет второго слояAP
[State World a]
~ [a]
тут тожеAP
AP
A
newtype Actions a = Actions{runActions::StateT World [] a}
instance Monad Actions where
(Actions xs) >>= k = Actions . StateT $ nubBy (sameWorld `on` snd) . runWorld
where runWorld = runStateT $ do
x <- xs
runActions $ k x
A
к
AP
к
A
к
AP
A
A
AP
A