Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Re: Parallel processing... (David McBride) 2. Re: Parallel processing... (mike h) 3. Suggestions for way to improve / clean up this code? (Erik Tillett) 4. Re: Suggestions for way to improve / clean up this code? (Francesco Ariis) ---------------------------------------------------------------------- Message: 1 Date: Mon, 27 Mar 2017 08:21:19 -0400 From: David McBride <toa...@gmail.com> To: mike h <mike_k_hough...@yahoo.co.uk>, The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Parallel processing... Message-ID: <can+tr40c-p7wpksj6dz59vc9xc7mjg6vi-8b_sqmrehm96y...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 It's hard to say what level you'll want your libraries to be. Theoretically all the functionality you need is in base. Control.Parallel and Control.Concurrent have functions for that, although you'll have to learn how to use them from various tutorials around. If the function you are mapping is pure, you might try the parallel package. If it is monadic you might try the monad-par package. There are parMap and parFor functions in monad-par-extras package which do exactly what you are looking for. If you search for parallel on hackage you'll find a plethora of well maintained packages in this domain as it is one of those things haskell is best at. On Mon, Mar 27, 2017 at 7:04 AM, mike h <mike_k_hough...@yahoo.co.uk> wrote: > Hi, > > I have a list of lists - a grid [[ ]] of complex numbers and I map a > function over each number in the grid. Each computation on a value at (r, c) > is independent of any and all other calculations. This strikes me as being > something that can be done in parallel by creating , say 4 quadrants and > mapping over each and combining when done, or doing each row in parallel > etc. etc. > > So I'm really just asking for advice or pointers on the Haskell libraries > etc that I should start with but I'm not really looking to import an > uber-package that will do most of it for me. I want to learn a little more > Haskell by working from a few concurrency primitives. > > Thanks > > Mike > > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > ------------------------------ Message: 2 Date: Mon, 27 Mar 2017 18:05:52 +0100 From: mike h <mike_k_hough...@yahoo.co.uk> To: David McBride <toa...@gmail.com> Cc: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Parallel processing... Message-ID: <fb66db09-aec0-42c8-b7ba-47c3d3bb8...@yahoo.co.uk> Content-Type: text/plain; charset=utf-8 Thanks David, I’ll look in to the links. Mike > On 27 Mar 2017, at 13:21, David McBride <toa...@gmail.com> wrote: > > It's hard to say what level you'll want your libraries to be. > Theoretically all the functionality you need is in base. > Control.Parallel and Control.Concurrent have functions for that, > although you'll have to learn how to use them from various tutorials > around. > > If the function you are mapping is pure, you might try the parallel > package. If it is monadic you might try the monad-par package. There > are parMap and parFor functions in monad-par-extras package which do > exactly what you are looking for. > > If you search for parallel on hackage you'll find a plethora of well > maintained packages in this domain as it is one of those things > haskell is best at. > > On Mon, Mar 27, 2017 at 7:04 AM, mike h <mike_k_hough...@yahoo.co.uk> wrote: >> Hi, >> >> I have a list of lists - a grid [[ ]] of complex numbers and I map a >> function over each number in the grid. Each computation on a value at (r, c) >> is independent of any and all other calculations. This strikes me as being >> something that can be done in parallel by creating , say 4 quadrants and >> mapping over each and combining when done, or doing each row in parallel >> etc. etc. >> >> So I'm really just asking for advice or pointers on the Haskell libraries >> etc that I should start with but I'm not really looking to import an >> uber-package that will do most of it for me. I want to learn a little more >> Haskell by working from a few concurrency primitives. >> >> Thanks >> >> Mike >> >> >> _______________________________________________ >> Beginners mailing list >> Beginners@haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> ------------------------------ Message: 3 Date: Mon, 27 Mar 2017 19:54:55 -0400 From: Erik Tillett <erik.till...@gmail.com> To: beginners@haskell.org Subject: [Haskell-beginners] Suggestions for way to improve / clean up this code? Message-ID: <CAKZCEDnr2A2tcDb7S62W151eg_zSFyw8kGjwTivydMGyT=b...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" I'm looking for sugestions on how to better structure this code. I stuck it in a pastbin: https://pastebin.com/gQFmvq6W/ Would a State monad help? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20170327/61023d18/attachment-0001.html> ------------------------------ Message: 4 Date: Tue, 28 Mar 2017 02:46:26 +0200 From: Francesco Ariis <fa...@ariis.it> To: beginners@haskell.org Subject: Re: [Haskell-beginners] Suggestions for way to improve / clean up this code? Message-ID: <20170328004626.ga17...@casa.casa> Content-Type: text/plain; charset=utf-8 On Mon, Mar 27, 2017 at 07:54:55PM -0400, Erik Tillett wrote: > I'm looking for sugestions on how to better structure this code. I stuck > it in a pastbin: > > https://pastebin.com/gQFmvq6W/ > > Would a State monad help? > > Thanks! Hello Erik, a couple of notes: - boolToInt is the same as `fromEnum` λ> :t fromEnum fromEnum :: Enum a => a -> Int - there are a lot of redundant brackets, like if (zReg c) then c{pc = address} else c ^ ^ minor errors like this are easily caught by hlint As for the state monad: you are correctly using monads to capture the idea of "things that can fail" (Either), judging by the function signatures I don't see the need for a State monad (i.e. I don't see signatures that end in (Something, SomeResult). (or maybe I am misreading the code, in that case please fire again) ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 105, Issue 11 ******************************************