[Haskell-beginners] ACID-state - how does it evaluate data

Antoine Latter aslatter at gmail.com
Thu Oct 4 19:38:19 CEST 2012

On Thu, Oct 4, 2012 at 3:06 AM, Konrad Szyc <konrad.s at gmail.com> wrote:
> Dear Haskell-Beginners
> I have a problem understanding how ACID-state stores its data. To be
> more specific, I would like to know how does it deal with lazy
> evaluation. I suppose it tries to "strictly" evaluate functions before
> serializing, but then how does it handle infinitely-recursive
> structures?

The acid-state library uses the safecopy library to perform
serialization and deserialization:


The safecopy library has template-haskell functions to write
serializers and de-serializers for your types for you, however you may
hand-write them if you desire.

The auto-generated serialization code will fully-evaluate their
arguments, and I have no idea what they would do if a type had cycles
in it.

In order to write code to be aware of laziness and cycles you would
need to use some very low-level hooks in GHC (or whichever compiler
you are using) and put that knowledge into your hand-written
serializer and deserializer for your type.

So the short answer is "No".


More information about the Beginners mailing list