[Haskell-cafe] exceptions, errors, random
Dennis Raddle
dennis.raddle at gmail.com
Fri Jun 23 04:54:38 UTC 2017
Thanks for pointing me to mwc-random. I like that they provide a normal
distribution; that is handy.
I think by asking me parallelism or concurrency, you mean do I have
algorithms that interact as they run in separate threads?
This is a backtracking search algorithm, so each thread can explore a
subset of the search space with no need to communicate with other threads.
Does that mean "concurrency"?
This is a pretty simple task. I hope that I don't have to delve deeply into
concurrency/parallelism.
D
On Tue, Jun 20, 2017 at 3:59 PM, Ivan Lazar Miljenovic <
ivan.miljenovic at gmail.com> wrote:
> On 21 June 2017 at 03:19, Dennis Raddle <dennis.raddle at gmail.com> wrote:
> > Looking at my application needs, such as access to pseudorandom numbers
> and
> > threads, does this suggest a particular course of action?
>
> For randomness, probably mwc-random, carrying the seed around in a
> StateT with IO on the bottom of the stack.
>
> For multi-threaded: parallelism or concurrency? Simon Marlow's
> Parallel and Concurrent Programming in Haskell is an excellent book on
> the topic: http://shop.oreilly.com/product/0636920026365.do
>
> >
> > D
> >
> >
> > On Tue, Jun 20, 2017 at 1:40 AM, Ivan Lazar Miljenovic
> > <ivan.miljenovic at gmail.com> wrote:
> >>
> >> There are two general schools of thought as to how to deal with
> >> exceptions:
> >>
> >> * ExceptT/MonadError from transformers/mtl:
> >>
> >> http://www.mega-nerd.com/erikd/Blog/CodeHacking/
> Haskell/what_do_you_mean.html
> >>
> >> * The exceptions package (which is a lifted variant of
> >> Control.Exception in base):
> >> https://www.fpcomplete.com/blog/2016/11/exceptions-best-
> practices-haskell
> >>
> >> On 20 June 2017 at 15:53, Dennis Raddle <dennis.raddle at gmail.com>
> wrote:
> >> > Just want to bump this request as I have not gotten a reply.
> >> >
> >> > On Fri, Jun 16, 2017 at 1:45 PM, Dennis Raddle <
> dennis.raddle at gmail.com>
> >> > wrote:
> >> >>
> >> >> I am wondering what exception/error and random classes I should use
> for
> >> >> my
> >> >> application.
> >> >>
> >> >> The application will be doing Monte Carlo backtracking search. I want
> >> >> it
> >> >> to be multithreaded and run on all four cores on my MacBook.
> >> >>
> >> >> I need detailed error messages in order to investigate errors. So I
> >> >> will
> >> >> throw errors or exceptions, then catch them in lower functions and
> >> >> annotate
> >> >> them with the parameters or computations within the lower function,
> >> >> then
> >> >> re-throw until finally the exception pops into the terminal.
> >> >>
> >> >> Because it's multi-threaded, at least some parts will needs to be in
> >> >> IO.
> >> >> Also, because it's a Monte Carlo algorithm it will need to make
> >> >> pseudorandom
> >> >> choices.
> >> >>
> >> >> Perhaps I should put everything in the IO monad? This will give me
> >> >> access
> >> >> to threads and the standard generator seed. But how about throwing,
> >> >> catching/rethrowing exceptions in IO? I have done this in pure code
> >> >> before:
> >> >> not sure if it's better to do it that way, in which case I could put
> >> >> some
> >> >> kind of state monad to hold the random seed together with an error
> >> >> monad and
> >> >> IO at the core of the monad stack.
> >> >>
> >> >> Any advice welcome.
> >> >> D
> >> >>
> >> >
> >> >
> >> > _______________________________________________
> >> > Haskell-Cafe mailing list
> >> > To (un)subscribe, modify options or view archives go to:
> >> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> >> > Only members subscribed via the mailman list are allowed to post.
> >>
> >>
> >>
> >> --
> >> Ivan Lazar Miljenovic
> >> Ivan.Miljenovic at gmail.com
> >> http://IvanMiljenovic.wordpress.com
> >
> >
>
>
>
> --
> Ivan Lazar Miljenovic
> Ivan.Miljenovic at gmail.com
> http://IvanMiljenovic.wordpress.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170622/01a1e763/attachment.html>
More information about the Haskell-Cafe
mailing list