
13 Dec
2011
13 Dec
'11
1:55 a.m.
So I am trying to understand how acid state works. The HelloWorld example has a type Message = String data Database = Database [Message] $(deriveSafeCopy 0 'base ''Database) -- Transactions are defined to run in either the 'Update' monad -- or the 'Query' monad. addMessage :: Message -> Update Database () addMessage msg = do Database messages <- get put $ Database (msg:messages) It seems to me that since the Dababase is a list of messages every update would require acid-state to rewrite the list into the file, so each update would get slower as the list gets bigger, but what I am seeing is that updates are constant time regardless of the size of the list. So how does it work?