Questions tagged [acid-state]

A Haskell library that adds ACID (Atomicity, Consistency, Isolation and Durability) guarantees to any serializable Haskell data structure.

See

24 questions
58
votes
1 answer

How to handle changing the implementation of Events when using Data.Acid

I have a moderately sized application that uses Data.Acid for persistence and I've encountered a situation where I need to update the implementation of one of my Update events for the next version of the server. I.e. I have something like myUpdate…
shang
  • 24,642
  • 3
  • 58
  • 86
7
votes
1 answer

Use acid-state like event log in Haskell

I'm using acid-state in a project and I quite like it. I like how easy it is to add persistence to plain Haskell datatypes without much boilerplate. As far as I understand, acid-state keeps a log of events, instead of writing out the entire new…
xnyhps
  • 3,306
  • 17
  • 21
6
votes
1 answer

How to zoom in acid-state?

data Foo = Foo { _bar :: Map String Integer } deriving (Eq, Ord, Read, Show, Data, Typeable) $(deriveSafeCopy 0 'base 'Foo) $(makeLenses ''Foo) Given the above code I am under the impression that it should be possible to do this: addEntry ::…
fho
  • 6,787
  • 26
  • 71
5
votes
1 answer

How to use Network.WebSockets.Snap in a snaplet?

It would be nice to be able to use the Network.WebSockets module from inside a snaplet, but I can't figure out how to actually do it. Using the runWebSocketsSnap :: MonadSnap m => ServerApp -> m () function from Network.WebSockets.Snap it is easy to…
5
votes
1 answer

Acid-state: MonadState instance for Update

I'm trying acid-state. The documentation states that Update st is an instance of MonadState st. I tried different things, but my compiler doesn't want to see that :( I tried the HelloWorld.hs from examples, but got the same…
Yuras
  • 13,856
  • 1
  • 45
  • 58
4
votes
2 answers

Avoiding Errors caused by IO when talking to a database inside of a WAI handler

I am writing a web service in haskell using warp, wai, and acid-state. As of now, I have two handler functions that require database interaction, the latter of which is giving me trouble. The first, is registration: registerUser :: AcidState…
user3594595
4
votes
1 answer

How can a monadic/sequential migration be implemented for data in acid-state?

Current state I have two data types. data Foo = Foo { fooId :: RecordId Foo , bars :: [RecordId Bar] ... } data Bar = Bar { barId :: RecordId Bar ... } This schema allows for each Foo to refer to an arbitrary list of Bars.…
matchwood
  • 257
  • 1
  • 7
4
votes
1 answer

Running template haskell in template haskell

insertST :: StateDecoder -> SomeState -> Update SomeState SomeThing insertST stDecoder st = ... the stuff in StateDecoder can't be used in $(makeAcidic ''SomeState ['insertST]) but if I declare a state and wrap it like this ... myDecoder ::…
TallerGhostWalt
  • 464
  • 3
  • 11
4
votes
1 answer

Unexpected return type of Acid State query (Happstack)

I'm trying to extend Happstack crash course blog with some additional functionality: displaying a list of all tags on home page. My blog record looks like this: data Blog = Blog { nextPostId :: PostId , posts :: IxSet Post , allTags…
eugenia
  • 43
  • 5
3
votes
1 answer

Haskell: acid-state over multiple files?

I have a file structure like this: --- Database.hs --- data Database = ... ... --- User.hs --- import Database addUser :: Update Database () ... --- Post.hs import Database addPost :: Update Database () ... The problem is that I need to called…
sqd
  • 1,485
  • 13
  • 23
3
votes
1 answer

How can I get cabal to install acid-state?

I'm a newbie to Haskell, and wanted to try the acid-state library, but I get the following output when trying to install it: >cabal install acid-state Resolving dependencies... Configuring acid-state-0.7.5... Building…
Diego Saa
  • 1,426
  • 1
  • 13
  • 23
2
votes
1 answer

Making sequences of events atomic in acid-state

I am strugging with grouping sequences of events into one atomic transaction. Consider a Map stored in acid-state, and imagine you want to implement Data.Map.alter. The function that takes a maybe-value and returns one cannot be stored in the…
user2645074
  • 107
  • 8
2
votes
1 answer

Ambiguous Type Variable in AcidState functions

I've got a situation in a Haskell web project where I'm getting the error Ambiguous type variable. The relevant code is --- Other import statements import qualified Model as Model ---------- HTTP Handlers needItem db user itemName = do …
Inaimathi
  • 13,853
  • 9
  • 49
  • 93
2
votes
1 answer

acid-state convenience wrapper without template haskell?

In acid-state tutorial all the examples use Template Haskell. However, due to some reasons I am not very keen on using it. I know one can use acid-state without template haskell, as shown…
Andriy Drozdyuk
  • 58,435
  • 50
  • 171
  • 272
1
vote
1 answer

Testing Acid-State with hspec

i'm a haskell noob and have problems with testing functions with acid-states.This ist my Datastructure data UserState = UserState { name :: String } deriving (Eq, Ord, Read, Show, Data, Typeable) and this is the function i want to test: setName…
alex.b
  • 184
  • 1
  • 2
  • 15
1
2