Wow, Daniel, that helped a lot with the counter, thank you!
But my "real" code continues eating memory like crazy even after updating it to modify'. I assume it could be something similar?
Can you spot something bad in the following one?
data RefField a = RefField String (a -> ByteString)
ref :: [RefField a] -> Pipe a a (StateT (IndexTables ByteString) IO) ()
ref fields =
let updateTables x ts = F.foldl' (\s' (RefField n f) -> tableInsert n (f x) s') ts fields
in forever $ await >>= (\x -> do { S.modify' (updateTables x); yield x })
And IndexTable is just a wrapper for Map. I tried to use Data.Map.Strict and it didn't help...
Cheers,
Alexey.