[Haskell-cafe] One of the new buzz phrases is "Event-Sourcing"; is Haskell suitable for this?

Alberto G. Corona agocorona at gmail.com
Sun Sep 30 19:15:03 CEST 2012


Hi,Marcelo,
No. .Acid state is  explcitly managed by the process by means of state
management primitives

In Control.Workflow the state is managed in a implicit way.

It is a monad transformer mainly  is designed for wrapping IO computations.

the lifting primitive, step, store the intermediate result and recover the
application state.

in acid state the process choose what to write in the state

in workflow the state written is the complete state of the process.

See the example in the documentation. the process ,

http://hackage.haskell.org/packages/archive/Workflow/0.7.0.7/doc/html/Control-Workflow.html


import Control.Workflow
import Control.Concurrent(threadDelay)
import System.IO (hFlush,stdout)

mcount n= do step
<http://hackage.haskell.org/packages/archive/Workflow/0.7.0.7/doc/html/Control-Workflow.html#v:step>
$  do
                       putStr (show n ++ " ")
                       hFlush stdout
                       threadDelay 1000000
             mcount (n+1)
             return () -- to disambiguate the return type

main= exec1 <http://hackage.haskell.org/packages/archive/Workflow/0.7.0.7/doc/html/Control-Workflow.html#v:exec1>
 "count"  $ mcount (0 :: Int)

>>> *runghc demos\sequence.hs*>0 1 2 3
>CTRL-C Pressed>>> *runghc demos\sequence.hs*>3 4 5 6 7
>CTRL-C Pressed>>> *runghc demos\sequence.hs*>7 8 9 10 11
...

in subsequent executions the process start to execute IO computations from
the last point logged:

As the documentation says  some side effect can be re-executed after
recovery if the log is not complete. This may happen after an unexpected
shutdown (in this case Contro-C has been pressed) or due to an asynchronous
log writing policy. (see
syncWrite<http://hackage.haskell.org/packages/archive/Workflow/0.7.0.7/doc/html/Control-Workflow.html#v:syncWrite>
) (writing is cached).

Althoug this is not event sourcing, The logging and recovery facilities can
be used for even sourcing.

Alberto

2012/9/30 Marcelo Sousa <dipython at gmail.com>

> Hi,
>
> On Sun, Sep 30, 2012 at 4:22 AM, Alberto G. Corona <agocorona at gmail.com>
> wrote:
> > It´´s a very iteresting concept.
> >
> > The Workflow Monad transformer [1], in Control.Workflow perform
> > logging and recovery of application istate from the log created.
> > It has no implementation of roll-back or limited recovery upto a
> > point, but this is easy to implement.
>
> Is Control.Workflow similar with acid-state with respect to the way
> you recovery the current state?
>
> > It also has many inspection and synchronization primitives. It has
> > been used also for translating the log of a program and recovering the
> > state in another machine. The log  can be pretty-printed for
> > debugging.
>
> Can you "somehow" recover impure (IO) computations?
>
> > [1] http://hackage.haskell.org/package/Workflow
>
> Regards,
> Marcelo
>
> > 2012/9/30 KC <kc1956 at gmail.com>:
> >> http://martinfowler.com/eaaDev/EventSourcing.html
> >>
> >> http://martinfowler.com/articles/lmax.html
> >>
> >>
> >> --
> >> --
> >> Regards,
> >> KC
> >>
> >> _______________________________________________
> >> Haskell-Cafe mailing list
> >> Haskell-Cafe at haskell.org
> >> http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
> >
> >
> > --
> > Alberto.
> >
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Alberto.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120930/bc2937a1/attachment.htm>


More information about the Haskell-Cafe mailing list