Casey Basichis | 6 Jan 18:01 2013
Picon

Undo records

Hi,

I am still getting a hang of Haskell.  Sorry if the answer is obvious.

What sorts of packages and approaches should I be looking at if I was looking to store something like an Undo stack into a database.

Each table would refer to a function. 
Each records input and outputs would specify both a table ID and record ID.  
The records would also have a data and a Process ID to associate all functions to a specific process and give them an order.

No records are ever deleted.  Rolling something back is instead a process of recreating a new, modified graph by taking the old graph from the database.

I should note that while I can generate some of the boiler parts from template haskell in advance I'm ultimately using a stage 1 compiler with no GHCI o template haskell.

Thanks,
Casey

--
Casey James Basichis
Composer - Cartoon Network
http://www.caseyjamesbasichis.com
caseybasichis <at> gmail.com
310.387.7540
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Ben Doyle | 9 Jan 20:40 2013
Picon

Re: Undo records

I think acid-state (http://hackage.haskell.org/package/acid-state) might do what you want, at least in broad strokes. It uses a durable transaction log to store query and update events. 


As far as I know, the interface to the library doesn't expose an undo/rollback function, so you'd have a bit of work to do to extend it to your use case. But the core functionality to make it possible should be there. 

Can you use ghc extensions aside from Template Haskell? Template Haskell you can do without with acid-state, but without GADTs and so on you'll have problems.

On Sun, Jan 6, 2013 at 12:01 PM, Casey Basichis <caseybasichis <at> gmail.com> wrote:
Hi,

I am still getting a hang of Haskell.  Sorry if the answer is obvious.

What sorts of packages and approaches should I be looking at if I was looking to store something like an Undo stack into a database.

Each table would refer to a function. 
Each records input and outputs would specify both a table ID and record ID.  
The records would also have a data and a Process ID to associate all functions to a specific process and give them an order.

No records are ever deleted.  Rolling something back is instead a process of recreating a new, modified graph by taking the old graph from the database.

I should note that while I can generate some of the boiler parts from template haskell in advance I'm ultimately using a stage 1 compiler with no GHCI o template haskell.

Thanks,
Casey

--
Casey James Basichis
Composer - Cartoon Network
http://www.caseyjamesbasichis.com
caseybasichis <at> gmail.com
310.387.7540

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Casey Basichis | 9 Jan 21:02 2013
Picon

Re: Undo records

Hi Ben,

Thanks for the reply.

I am planning on using Persistent which can work without template haskell, though I am planning on using the TH on my workstation to create the boiler code parts of the database setup.

The part that I'm having trouble with is collecting the composed functions. It may be a very typical problem but I'm just lost.

Let me just describe a simple example;

A message comes through the FFI to:

Haskell chooses criteria to select a sequence of data from the database
--- many functions exist to do this, some may take a random number as a parameter, the seed needs to be stored
Haskell similarly chooses a process to apply to the data
--- A random number or other deterministic chain of functions
The results from the processing are loaded into memory - (these are not the focus here)
The minimal chain of functions, parameters and seeds is stored to allow for a deterministic recall/modification
--- The input parameters and output parameters are Table and Row ID's 

So Haskell isn't reacting to many input events, just a trigger that may come with a few initialization parameters.

If a function is composed of other functions which do not depend on external state they should not need to be stored in the database as they are implicit.

I imagine this is a monad problem, but kind and what other things spring to mind that might help in approaching this kind of problem?

Thanks,
Casey



On Wed, Jan 9, 2013 at 11:40 AM, Ben Doyle <benjamin.peter.doyle <at> gmail.com> wrote:
I think acid-state (http://hackage.haskell.org/package/acid-state) might do what you want, at least in broad strokes. It uses a durable transaction log to store query and update events. 

As far as I know, the interface to the library doesn't expose an undo/rollback function, so you'd have a bit of work to do to extend it to your use case. But the core functionality to make it possible should be there. 

Can you use ghc extensions aside from Template Haskell? Template Haskell you can do without with acid-state, but without GADTs and so on you'll have problems.

On Sun, Jan 6, 2013 at 12:01 PM, Casey Basichis <caseybasichis <at> gmail.com> wrote:
Hi,

I am still getting a hang of Haskell.  Sorry if the answer is obvious.

What sorts of packages and approaches should I be looking at if I was looking to store something like an Undo stack into a database.

Each table would refer to a function. 
Each records input and outputs would specify both a table ID and record ID.  
The records would also have a data and a Process ID to associate all functions to a specific process and give them an order.

No records are ever deleted.  Rolling something back is instead a process of recreating a new, modified graph by taking the old graph from the database.

I should note that while I can generate some of the boiler parts from template haskell in advance I'm ultimately using a stage 1 compiler with no GHCI o template haskell.

Thanks,
Casey

--
Casey James Basichis
Composer - Cartoon Network
http://www.caseyjamesbasichis.com
caseybasichis <at> gmail.com
310.387.7540

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe





--
Casey James Basichis
Composer - Cartoon Network
http://www.caseyjamesbasichis.com
caseybasichis <at> gmail.com
310.387.7540
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Gmane