Re: [Haskell-cafe] Monads

2012-09-30 Thread Tillmann Rendel

Vasili I. Galchin wrote:

I would an examples of monads that are pure, i.e. no side-effects.


One view of programming in monadic style is: You call return and = all 
the time. (Either you call it directly, or do notation calls it for 
you). So if you want to understand whether a monad has side-effects, 
you should look at the implementation of return and =. If the 
implementation of return and = is written in pure Haskell (without 
unsafePerformIO or calling C code etc.), the monad is pure.


  Tillmann

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Monads

2012-09-30 Thread Albert Y. C. Lai

On 12-09-29 09:57 PM, Vasili I. Galchin wrote:

 I would an examples of monads that are pure, i.e. no side-effects.


What does side effect mean, to you? Definition?

Because some people say State has no side effect, and some other 
people say State has side effects. The two groups use different 
definitions.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2012-09-30 Thread Marcelo Sousa
Hi,

On Sun, Sep 30, 2012 at 4:22 AM, Alberto G. Corona agocor...@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 kc1...@gmail.com:
 http://martinfowler.com/eaaDev/EventSourcing.html

 http://martinfowler.com/articles/lmax.html


 --
 --
 Regards,
 KC

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe



 --
 Alberto.

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2012-09-30 Thread Alberto G. Corona
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 100
 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
syncWritehttp://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 dipyt...@gmail.com

 Hi,

 On Sun, Sep 30, 2012 at 4:22 AM, Alberto G. Corona agocor...@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 kc1...@gmail.com:
  http://martinfowler.com/eaaDev/EventSourcing.html
 
  http://martinfowler.com/articles/lmax.html
 
 
  --
  --
  Regards,
  KC
 
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 
 
  --
  Alberto.
 
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe




-- 
Alberto.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2012-09-30 Thread Bardur Arantsson
On 09/30/2012 02:46 AM, KC wrote:
 http://martinfowler.com/eaaDev/EventSourcing.html
 
 http://martinfowler.com/articles/lmax.html
 
 

Sure, why not? See

http://hackage.haskell.org/package/cqrs-0.8.0
and http://hackage.haskell.org/package/cqrs-example-0.8.0

for an example application.

I should note that the cqrs package API is by no means finalized;
there are some limitations(*) to the current implementation, but I've
not had time to actually get rid of those limitations.

(*) The major ones being the requirement for a global version number and
lack of streaming event sourcing.




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Monads

2012-09-30 Thread wren ng thornton

On 9/30/12 7:00 AM, Tillmann Rendel wrote:

Vasili I. Galchin wrote:

I would an examples of monads that are pure, i.e. no side-effects.


One view of programming in monadic style is: You call return and = all
the time. (Either you call it directly, or do notation calls it for
you). So if you want to understand whether a monad has side-effects,
you should look at the implementation of return and =. If the
implementation of return and = is written in pure Haskell (without
unsafePerformIO or calling C code etc.), the monad is pure.


I'm not sure return and bind will give you the information you seek, 
however. In order to obey the monad laws, return and bind must be (for 
all intents and purposes) pure.


The place to look for impurities is the primitive operations of the 
monad; i.e., those which cannot be implemented using return and bind. 
These are the operations which take you out of a free monad and the 
operations which must be given some special semantic interpretation.



--
Live well,
~wren

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Possible bug in Criterion or Statistics package

2012-09-30 Thread Ben Gamari
Aleksey Khudyakov alexey.sklad...@gmail.com writes:

 On 13.08.2012 19:43, Ryan Newton wrote:
 Terrible!  Quite sorry that this seems to be a bug in the monad-par library.

 I'm copying some of the other monad-par authors and we hopefully can get
 to the bottom of this.  If it's not possible to create a smaller
 reproducer, is it possible to share the original test that triggers this
 problem?  In the meantime, it's good that you can at least run without
 parallelism.

 Here is slightly simplified original test case. By itself program is 
 very small but there is statistics and criterion on top of the monad-par
 Failure occurs in the function 
 Statistics.Resampling.Bootstrap.bootstrapBCA. However I couldn't trigger 
 bug with mock data.

Has there been any progress or an official bug report on this?

Cheers,

- Ben


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Monads

2012-09-30 Thread Jake McArthur
On Sep 30, 2012 10:56 AM, Albert Y. C. Lai tre...@vex.net wrote:

 On 12-09-29 09:57 PM, Vasili I. Galchin wrote:

  I would an examples of monads that are pure, i.e. no
side-effects.


 What does side effect mean, to you? Definition?

When discussing monads, at least, a side effect is an effect that is
triggered by merely evaluating an expression. A monad is an interface that
decouples effects from evaluation.


 Because some people say State has no side effect, and some other people
say State has side effects. The two groups use different definitions.


 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Monads

2012-09-30 Thread Kristopher Micinski
On Sun, Sep 30, 2012 at 6:33 PM, Jake McArthur jake.mcart...@gmail.com wrote:

 On Sep 30, 2012 10:56 AM, Albert Y. C. Lai tre...@vex.net wrote:

 On 12-09-29 09:57 PM, Vasili I. Galchin wrote:

  I would an examples of monads that are pure, i.e. no
 side-effects.


 What does side effect mean, to you? Definition?

 When discussing monads, at least, a side effect is an effect that is
 triggered by merely evaluating an expression. A monad is an interface that
 decouples effects from evaluation.


Ohh, I like that quote.., that's another good one..

kris

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2012-09-30 Thread Joey Adams
On Sat, Sep 29, 2012 at 8:46 PM, KC kc1...@gmail.com wrote:
 http://martinfowler.com/eaaDev/EventSourcing.html

 http://martinfowler.com/articles/lmax.html

This notion of Capture all changes to an application state as a
sequence of events sounds a lot like what John Carmack did in Quake 3
[1]:

 I settled on combining all forms of input into a single system event queue, 
 similar to the windows message queue. My original intention was to just 
 rigorously define where certain functions were called and cut down the number 
 of required system entry points, but it turned out to have much stronger 
 benefits.

 [1]: http://www.team5150.com/~andrew/carmack/johnc_plan_1998.html#d19981014

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Monads

2012-09-30 Thread Albert Y. C. Lai

On 12-09-30 06:33 PM, Jake McArthur wrote:

When discussing monads, at least, a side effect is an effect that is
triggered by merely evaluating an expression. A monad is an interface
that decouples effects from evaluation.


I don't understand that definition. Or maybe I do subconsciously.

I have

s :: State Int ()
s = do { x - get; put (x+1) }

Is there an effect triggered by merely evaluating s?

I have

m :: IO ()
m = if True then putStrLn x else putChar 'y'

Is there an effect triggered by merely evaluating m?

What counts as evaluate?

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe